formatAdapter.formatSequences and maintain annotation after undo
[jalview.git] / src / ext / jemboss / soap / JembossRun.java
1 /********************************************************************
2 *
3 *  This library is free software; you can redistribute it and/or
4 *  modify it under the terms of the GNU Library General Public
5 *  License as published by the Free Software Foundation; either
6 *  version 2 of the License, or (at your option) any later version.
7 *
8 *  This library is distributed in the hope that it will be useful,
9 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 *  Library General Public License for more details.
12 *
13 *  You should have received a copy of the GNU Library General Public
14 *  License along with this library; if not, write to the
15 *  Free Software Foundation, Inc., 59 Temple Place - Suite 330,
16 *  Boston, MA  02111-1307, USA.
17 *
18 *  Based on EmbreoRun
19 *
20 *  @author: Copyright (C) Tim Carver
21 *
22 ********************************************************************/
23
24
25 package ext.jemboss.soap;
26
27 import java.io.*;
28 import java.util.*;
29
30 import ext.jemboss.JembossParams;
31
32 /**
33 *
34 * Executes an application on a server
35 *
36 */
37 public class JembossRun
38 {
39
40   /** status message */
41   private String statusmsg;
42   /** status of the request */
43   private String status;
44   /** program result */
45   private Hashtable proganswer;
46
47   /**
48   *
49   * @param appl         defining command
50   * @param options      defining options
51   * @param filesToMove  Hashtable of filenames and contents
52   * @param mysettings   jemboss properties
53   * @throws JembossSoapException if authentication fails
54   *
55   */
56   public JembossRun(String appl, String options, Hashtable filesToMove,
57                     JembossParams mysettings) throws JembossSoapException
58   {
59
60     String fulloptions;
61
62     Vector params = new Vector();
63     params.addElement(appl);
64
65      //construct a full options string
66     fulloptions = "mode="+mysettings.getCurrentMode()+" "+options;
67 //   if (mysettings.getUseX11())
68 //     fulloptions = "display="+mysettings.getX11display()+" "+fulloptions;
69     params.addElement(fulloptions);
70
71     // just pass the hash
72     params.addElement(filesToMove);
73
74     PrivateRequest eRun;
75     try
76     {
77       eRun = new PrivateRequest(mysettings,
78                                "run_prog", params);
79     }
80     catch (JembossSoapException e)
81     {
82       throw new JembossSoapException("Authentication Failed");
83     }
84
85     proganswer = eRun.getHash();
86     status = proganswer.get("status").toString();
87     statusmsg = proganswer.get("msg").toString();
88
89     proganswer.remove("status");  // delete the status/msg
90     proganswer.remove("msg");
91   }
92
93
94   /**
95   *
96   * The status of the request
97   * @return     0 for success
98   *
99   */
100   public String getStatus()
101   {
102     return status;
103   }
104
105   /**
106   *
107   * A status message or description of a error
108   * @return     status message
109   *
110   */
111   public String getStatusMsg()
112   {
113     return statusmsg;
114   }
115
116   /**
117   *
118   * Get a Hashtable of filenames and their contents generated by
119   * running the application
120   * @return     results
121   *
122   */
123   public Hashtable hash()
124   {
125     return proganswer;
126   }
127
128
129   /**
130   *
131   * Get a result from the result Hashtable
132   * @param key  key into the results Hashtable
133   * @return     element in the results Hashtable
134   *
135   */
136   public Object get(Object key)
137   {
138     return proganswer.get(key);
139   }
140
141 }
142