View Javadoc

1   /*
2    * Copyright 2010 Fraunhofer Gesellschaft, Munich, Germany,
3    * for its Fraunhofer Institute for Computer Architecture and Software
4    * Technology (FIRST), Berlin, Germany. All rights reserved.
5    * http://www.first.fraunhofer.de/
6    */
7   
8   package net.kwfgrid.gwes.client;
9   
10  import org.apache.axis2.AxisFault;
11  import org.apache.log4j.Logger;
12  import net.kwfgrid.gwes.Constants;
13  import net.kwfgrid.gwes.WorkflowStatus;
14  
15  import java.lang.*;
16  import java.util.Hashtable;
17  import java.util.regex.Pattern;
18  
19  /**
20   * Class that provides local GWES interface and invokes remote GWES using Axis2 stubs.
21   * Singleton pattern. Caches connector objects.
22   * 
23   * @author Andreas Hoheisel
24   *         (<a href="http://www.andreas-hoheisel.de">www.andreas-hoheisel.de</a>)
25   * @version $Id: RemoteGWES.java 1542 2011-08-18 11:59:01Z hoheisel $
26   */
27  public class RemoteGWES implements net.kwfgrid.gwes.GWES {
28  
29      final static Logger logger = Logger.getLogger(RemoteGWES.class);
30  
31      /**
32       * Key is gwesServiceUrl, value is RemoteGWES.
33       */
34      private static Hashtable<String,RemoteGWES> instances = new Hashtable<String,RemoteGWES>();
35  
36      private GWESStub stub;
37  
38      protected static final Pattern PATTERN_WORKFLOW_NOT_AVAILABLE = Pattern.compile("(?s).*Workflow.*is not available.*", Pattern.DOTALL);
39  
40      /**
41       * Create new or return existing RemoteGWES instance to GWES with service URL as specified by system property.
42       * @see net.kwfgrid.gwes.Constants#PROP_SYSTEM_GWES_SERVICE_BASE_URL_INTERNAL
43       * @return
44       * @throws Exception
45       */
46      public synchronized static RemoteGWES getInstance() throws Exception {
47          String gwesServiceUrl = System.getProperty(Constants.PROP_SYSTEM_GWES_SERVICE_BASE_URL_INTERNAL) + "/services/GWES";
48          if (gwesServiceUrl.equals("null/services/GWES")) {
49              throw new Exception("The GWES client has not been configured correctly. Please set the property "
50                      + Constants.PROP_SYSTEM_GWES_SERVICE_BASE_URL_INTERNAL + " in the file gwes.properties or as system property");
51          }
52  
53          return getInstance(gwesServiceUrl);
54      }
55  
56      /**
57       * Create new or return existing RemoteGWES instance to GWES with service URL as specified by paramter gwesServiceUrl.
58       * @return
59       * @throws Exception
60       */
61      public synchronized static RemoteGWES getInstance(String gwesServiceUrl) throws Exception {
62          RemoteGWES _instance = instances.get(gwesServiceUrl);
63          if (_instance == null) {
64              _instance = new RemoteGWES(gwesServiceUrl);
65              instances.put(gwesServiceUrl,_instance);
66          }
67          return _instance;
68      }
69  
70      private RemoteGWES(String gwesServiceUrl) throws Exception {
71          stub = new GWESStub(gwesServiceUrl);
72          logger.info("connected to " + gwesServiceUrl);
73      }
74  
75      /**
76       * Sets the timeout for the connection with the remote gwes in milli seconds.
77       * Default value is set in {@link org.apache.axis2.client.Options#DEFAULT_TIMEOUT_MILLISECONDS}
78       * @param timeout The timeout in milli seconds.
79       */
80      public void setTimeout(long timeout) {
81          stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(timeout);
82      }
83      
84      /*********************************************************************************
85       * Interface GWES
86       *********************************************************************************/
87  
88      public String initiate(String gworkflowdl, String userID) throws
89              net.kwfgrid.gworkflowdl.structure.WorkflowFormatException,
90              net.kwfgrid.gwes.exception.StateTransitionException,
91              net.kwfgrid.gwes.exception.LoggingException,
92              net.kwfgrid.gwes.exception.GWESException,
93              net.kwfgrid.gwes.exception.WorkflowSecurityException,
94              java.rmi.RemoteException {
95          logger.debug("initiate()...");
96          try {
97              GWESStub.Initiate params = new GWESStub.Initiate();
98              params.setWorkflowDescription(gworkflowdl);
99              params.setUserID(userID);
100             GWESStub.InitiateResponse response = stub.initiate(params);
101             return response.get_return();
102         } catch (WorkflowFormatException e) {
103             throw new net.kwfgrid.gworkflowdl.structure.WorkflowFormatException(e.getMessage(), e);
104         } catch (StateTransitionException e) {
105             throw new net.kwfgrid.gwes.exception.StateTransitionException(e.getMessage(), e);
106         } catch (LoggingException e) {
107             throw new net.kwfgrid.gwes.exception.LoggingException(e.getMessage(), e);
108         } catch (WorkflowSecurityException e) {
109             throw new net.kwfgrid.gwes.exception.WorkflowSecurityException(e.getMessage(), e);
110         } catch (GWESException e) {
111             throw new net.kwfgrid.gwes.exception.GWESException(e.getMessage(), e);
112 //        } catch (RemoteException e) {
113 //            throw new java.rmi.RemoteException(e.getMessage(), e);
114         }
115     }
116 
117     public void start(String workflowID, String userID) throws
118             net.kwfgrid.gwes.exception.NoSuchWorkflowException,
119             net.kwfgrid.gwes.exception.StateTransitionException,
120             net.kwfgrid.gwes.exception.LoggingException,
121             net.kwfgrid.gwes.exception.WorkflowSecurityException,
122             net.kwfgrid.gwes.exception.GWESException,
123             java.rmi.RemoteException {
124         logger.debug("start("+workflowID+")...");
125         try {
126             GWESStub.Start params = new GWESStub.Start();
127             params.setWorkflowID(workflowID);
128             params.setUserID(userID);
129             stub.start(params);
130         } catch (NoSuchWorkflowException e) {
131             throw new net.kwfgrid.gwes.exception.NoSuchWorkflowException(e.getMessage(), e);
132         } catch (StateTransitionException e) {
133             throw new net.kwfgrid.gwes.exception.StateTransitionException(e.getMessage(), e);
134         } catch (LoggingException e) {
135             throw new net.kwfgrid.gwes.exception.LoggingException(e.getMessage(), e);
136         } catch (WorkflowSecurityException e) {
137             throw new net.kwfgrid.gwes.exception.WorkflowSecurityException(e.getMessage(), e);
138         } catch (GWESException e) {
139             throw new net.kwfgrid.gwes.exception.GWESException(e.getMessage(), e);
140 //        } catch (RemoteException e) {
141 //            throw new java.rmi.RemoteException(e.getMessage(), e);
142         }
143     }
144 
145     public void suspend(String workflowID, String userID) throws
146             net.kwfgrid.gwes.exception.NoSuchWorkflowException,
147             net.kwfgrid.gwes.exception.StateTransitionException,
148             net.kwfgrid.gwes.exception.LoggingException,
149             net.kwfgrid.gwes.exception.WorkflowSecurityException,
150             net.kwfgrid.gwes.exception.GWESException,
151             java.rmi.RemoteException {
152         logger.debug("suspend("+workflowID+")...");
153         try {
154             GWESStub.Suspend params = new GWESStub.Suspend();
155             params.setWorkflowID(workflowID);
156             params.setUserID(userID);
157             stub.suspend(params);
158         } catch (NoSuchWorkflowException e) {
159             throw new net.kwfgrid.gwes.exception.NoSuchWorkflowException(e.getMessage(), e);
160         } catch (StateTransitionException e) {
161             throw new net.kwfgrid.gwes.exception.StateTransitionException(e.getMessage(), e);
162         } catch (LoggingException e) {
163             throw new net.kwfgrid.gwes.exception.LoggingException(e.getMessage(), e);
164         } catch (WorkflowSecurityException e) {
165             throw new net.kwfgrid.gwes.exception.WorkflowSecurityException(e.getMessage(), e);
166         } catch (GWESException e) {
167             throw new net.kwfgrid.gwes.exception.GWESException(e.getMessage(), e);
168 //        } catch (RemoteException e) {
169 //            throw new java.rmi.RemoteException(e.getMessage(), e);
170         }
171     }
172 
173     public void resume(String workflowID, String userID) throws
174             net.kwfgrid.gwes.exception.NoSuchWorkflowException,
175             net.kwfgrid.gwes.exception.StateTransitionException,
176             net.kwfgrid.gwes.exception.LoggingException,
177             net.kwfgrid.gwes.exception.WorkflowSecurityException,
178             net.kwfgrid.gwes.exception.GWESException,
179             java.rmi.RemoteException {
180         logger.debug("resume("+workflowID+")...");
181         try {
182             GWESStub.Resume params = new GWESStub.Resume();
183             params.setWorkflowID(workflowID);
184             params.setUserID(userID);
185             stub.resume(params);
186         } catch (NoSuchWorkflowException e) {
187             throw new net.kwfgrid.gwes.exception.NoSuchWorkflowException(e.getMessage(), e);
188         } catch (StateTransitionException e) {
189             throw new net.kwfgrid.gwes.exception.StateTransitionException(e.getMessage(), e);
190         } catch (LoggingException e) {
191             throw new net.kwfgrid.gwes.exception.LoggingException(e.getMessage(), e);
192         } catch (WorkflowSecurityException e) {
193             throw new net.kwfgrid.gwes.exception.WorkflowSecurityException(e.getMessage(), e);
194         } catch (GWESException e) {
195             throw new net.kwfgrid.gwes.exception.GWESException(e.getMessage(), e);
196 //        } catch (RemoteException e) {
197 //            throw new java.rmi.RemoteException(e.getMessage(), e);
198         }
199     }
200 
201     public void abort(String workflowID, String userID) throws
202             net.kwfgrid.gwes.exception.NoSuchWorkflowException,
203             net.kwfgrid.gwes.exception.StateTransitionException,
204             net.kwfgrid.gwes.exception.LoggingException,
205             net.kwfgrid.gwes.exception.WorkflowSecurityException,
206             net.kwfgrid.gwes.exception.GWESException,
207             java.rmi.RemoteException {
208         logger.debug("abort("+workflowID+")...");
209         try {
210             GWESStub.Abort params = new GWESStub.Abort();
211             params.setWorkflowID(workflowID);
212             params.setUserID(userID);
213             stub.abort(params);
214         } catch (NoSuchWorkflowException e) {
215             throw new net.kwfgrid.gwes.exception.NoSuchWorkflowException(e.getMessage(), e);
216         } catch (StateTransitionException e) {
217             throw new net.kwfgrid.gwes.exception.StateTransitionException(e.getMessage(), e);
218         } catch (LoggingException e) {
219             throw new net.kwfgrid.gwes.exception.LoggingException(e.getMessage(), e);
220         } catch (WorkflowSecurityException e) {
221             throw new net.kwfgrid.gwes.exception.WorkflowSecurityException(e.getMessage(), e);
222         } catch (GWESException e) {
223             throw new net.kwfgrid.gwes.exception.GWESException(e.getMessage(), e);
224 //        } catch (RemoteException e) {
225 //            throw new java.rmi.RemoteException(e.getMessage(), e);
226         }
227     }
228 
229     public String restart(String workflowID, String userID) throws
230             net.kwfgrid.gwes.exception.NoSuchWorkflowException,
231             net.kwfgrid.gworkflowdl.structure.WorkflowFormatException,
232             net.kwfgrid.gwes.exception.DatabaseException,
233             net.kwfgrid.gwes.exception.StateTransitionException,
234             net.kwfgrid.gwes.exception.LoggingException,
235             net.kwfgrid.gwes.exception.WorkflowSecurityException,
236             net.kwfgrid.gwes.exception.GWESException,
237             java.rmi.RemoteException {
238         logger.debug("restart("+workflowID+")...");
239         try {
240             GWESStub.Restart params = new GWESStub.Restart();
241             params.setWorkflowID(workflowID);
242             params.setUserID(userID);
243             GWESStub.RestartResponse response = stub.restart(params);
244             return response.get_return();
245         } catch (NoSuchWorkflowException e) {
246             throw new net.kwfgrid.gwes.exception.NoSuchWorkflowException(e.getMessage(), e);
247         } catch (WorkflowFormatException e) {
248             throw new net.kwfgrid.gworkflowdl.structure.WorkflowFormatException(e.getMessage(), e);
249         } catch (DatabaseException e) {
250             throw new net.kwfgrid.gwes.exception.DatabaseException(e.getMessage(), e);
251         } catch (StateTransitionException e) {
252             throw new net.kwfgrid.gwes.exception.StateTransitionException(e.getMessage(), e);
253         } catch (LoggingException e) {
254             throw new net.kwfgrid.gwes.exception.LoggingException(e.getMessage(), e);
255         } catch (WorkflowSecurityException e) {
256             throw new net.kwfgrid.gwes.exception.WorkflowSecurityException(e.getMessage(), e);
257         } catch (GWESException e) {
258             throw new net.kwfgrid.gwes.exception.GWESException(e.getMessage(), e);
259 //        } catch (RemoteException e) {
260 //            throw new java.rmi.RemoteException(e.getMessage(), e);
261         }
262     }
263 
264     public String getWorkflowDescription(String workflowID, String userID) throws
265             net.kwfgrid.gwes.exception.NoSuchWorkflowException,
266             net.kwfgrid.gwes.exception.DatabaseException,
267             net.kwfgrid.gwes.exception.LoggingException,
268             net.kwfgrid.gwes.exception.WorkflowSecurityException,
269             net.kwfgrid.gwes.exception.GWESException,
270             java.rmi.RemoteException {
271         logger.debug("getWorkflowDescription("+workflowID+")...");
272         try {
273             GWESStub.GetWorkflowDescription params = new GWESStub.GetWorkflowDescription();
274             params.setWorkflowID(workflowID);
275             params.setUserID(userID);
276             GWESStub.GetWorkflowDescriptionResponse response = stub.getWorkflowDescription(params);
277             return response.get_return();
278         } catch (NoSuchWorkflowException e) {
279             throw new net.kwfgrid.gwes.exception.NoSuchWorkflowException(e.getMessage(), e);
280         } catch (DatabaseException e) {
281             throw new net.kwfgrid.gwes.exception.DatabaseException(e.getMessage(), e);
282         } catch (LoggingException e) {
283             throw new net.kwfgrid.gwes.exception.LoggingException(e.getMessage(), e);
284         } catch (WorkflowSecurityException e) {
285             throw new net.kwfgrid.gwes.exception.WorkflowSecurityException(e.getMessage(), e);
286         } catch (GWESException e) {
287             throw new net.kwfgrid.gwes.exception.GWESException(e.getMessage(), e);
288 //        } catch (RemoteException e) {
289 //            throw new java.rmi.RemoteException(e.getMessage(), e);
290         }
291     }
292 
293     public void setWorkflowDescription(String workflowID, String gworkflowdl, String userID) throws
294             net.kwfgrid.gwes.exception.NoSuchWorkflowException,
295             net.kwfgrid.gwes.exception.StateTransitionException,
296             net.kwfgrid.gworkflowdl.structure.WorkflowFormatException,
297             net.kwfgrid.gwes.exception.LoggingException,
298             net.kwfgrid.gwes.exception.GWESException,
299             net.kwfgrid.gwes.exception.WorkflowSecurityException,
300             java.rmi.RemoteException {
301         logger.debug("setWorkflowDescription("+workflowID+")...");
302         try {
303             GWESStub.SetWorkflowDescription params = new GWESStub.SetWorkflowDescription();
304             params.setWorkflowID(workflowID);
305             params.setGworkflowdl(gworkflowdl);
306             params.setUserID(userID);
307             stub.setWorkflowDescription(params);
308         } catch (NoSuchWorkflowException e) {
309             throw new net.kwfgrid.gwes.exception.NoSuchWorkflowException(e.getMessage(), e);
310         } catch (StateTransitionException e) {
311             throw new net.kwfgrid.gwes.exception.StateTransitionException(e.getMessage(), e);
312         } catch (WorkflowFormatException e) {
313             throw new net.kwfgrid.gworkflowdl.structure.WorkflowFormatException(e.getMessage(), e);
314         } catch (LoggingException e) {
315             throw new net.kwfgrid.gwes.exception.LoggingException(e.getMessage(), e);
316         } catch (WorkflowSecurityException e) {
317             throw new net.kwfgrid.gwes.exception.WorkflowSecurityException(e.getMessage(), e);
318         } catch (GWESException e) {
319             throw new net.kwfgrid.gwes.exception.GWESException(e.getMessage(), e);
320 //        } catch (RemoteException e) {
321 //            throw new java.rmi.RemoteException(e.getMessage(), e);
322         }
323     }
324 
325     public int getStatus(String workflowID, String userID) throws
326             net.kwfgrid.gwes.exception.NoSuchWorkflowException,
327             net.kwfgrid.gwes.exception.LoggingException,
328             net.kwfgrid.gwes.exception.DatabaseException,
329             net.kwfgrid.gwes.exception.WorkflowSecurityException,
330             net.kwfgrid.gwes.exception.GWESException,
331             java.rmi.RemoteException {
332         logger.debug("getStatus("+workflowID+")...");
333         try {
334             GWESStub.GetStatus params = new GWESStub.GetStatus();
335             params.setWorkflowID(workflowID);
336             params.setUserID(userID);
337             GWESStub.GetStatusResponse response = stub.getStatus(params);
338             return response.get_return();
339         } catch (NoSuchWorkflowException e) {
340             throw new net.kwfgrid.gwes.exception.NoSuchWorkflowException(e.getMessage(), e);
341         } catch (DatabaseException e) {
342             throw new net.kwfgrid.gwes.exception.DatabaseException(e.getMessage(), e);
343         } catch (LoggingException e) {
344             throw new net.kwfgrid.gwes.exception.LoggingException(e.getMessage(), e);
345         } catch (WorkflowSecurityException e) {
346             throw new net.kwfgrid.gwes.exception.WorkflowSecurityException(e.getMessage(), e);
347         } catch (GWESException e) {
348             throw new net.kwfgrid.gwes.exception.GWESException(e.getMessage(), e);
349 //        } catch (RemoteException e) {
350 //            throw new java.rmi.RemoteException(e.getMessage(), e);
351         }
352     }
353 
354     public int waitForStatusChangeFrom(String workflowID, int oldStatus, String userID) throws
355             net.kwfgrid.gwes.exception.NoSuchWorkflowException,
356             java.rmi.RemoteException,
357             net.kwfgrid.gwes.exception.LoggingException,
358             net.kwfgrid.gwes.exception.WorkflowSecurityException,
359             net.kwfgrid.gwes.exception.GWESException,
360             java.lang.InterruptedException {
361         if (logger.isDebugEnabled()) logger.debug("waitForStatusChangeFrom("+workflowID+", "+ WorkflowStatus.getStatusAsString(oldStatus)+")...");
362         try {
363             GWESStub.WaitForStatusChangeFrom params = new GWESStub.WaitForStatusChangeFrom();
364             params.setWorkflowID(workflowID);
365             params.setOldStatus(oldStatus);
366             params.setUserID(userID);
367             GWESStub.WaitForStatusChangeFromResponse response = stub.waitForStatusChangeFrom(params);
368             return response.get_return();
369         } catch (NoSuchWorkflowException e) {
370             throw new net.kwfgrid.gwes.exception.NoSuchWorkflowException(e.getMessage(), e);
371         } catch ( net.kwfgrid.gwes.client.InterruptedException e) {
372             throw new java.lang.InterruptedException(e.getMessage());
373         } catch (LoggingException e) {
374             throw new net.kwfgrid.gwes.exception.LoggingException(e.getMessage(), e);
375         } catch (WorkflowSecurityException e) {
376             throw new net.kwfgrid.gwes.exception.WorkflowSecurityException(e.getMessage(), e);
377         } catch (GWESException e) {
378             throw new net.kwfgrid.gwes.exception.GWESException(e.getMessage(), e);
379 //        } catch (RemoteException e) {
380 //            throw new java.rmi.RemoteException(e.getMessage(), e);
381         }
382     }
383 
384     public int waitForStatusChangeToCompletedOrTerminated(String workflowID, String userID) throws
385             net.kwfgrid.gwes.exception.NoSuchWorkflowException,
386             net.kwfgrid.gwes.exception.LoggingException,
387             net.kwfgrid.gwes.exception.WorkflowSecurityException,
388             net.kwfgrid.gwes.exception.GWESException,
389             java.rmi.RemoteException,
390             java.lang.InterruptedException {
391         logger.debug("waitForStatusChangeToCompletedOrTerminated("+workflowID+")...");
392         try {
393             GWESStub.WaitForStatusChangeToCompletedOrTerminated params = new GWESStub.WaitForStatusChangeToCompletedOrTerminated();
394             params.setWorkflowID(workflowID);
395             params.setUserID(userID);
396             GWESStub.WaitForStatusChangeToCompletedOrTerminatedResponse response = stub.waitForStatusChangeToCompletedOrTerminated(params);
397             return response.get_return();
398         } catch (NoSuchWorkflowException e) {
399             throw new net.kwfgrid.gwes.exception.NoSuchWorkflowException(e.getMessage(), e);
400         } catch ( net.kwfgrid.gwes.client.InterruptedException e) {
401             throw new java.lang.InterruptedException(e.getMessage());
402         } catch (LoggingException e) {
403             throw new net.kwfgrid.gwes.exception.LoggingException(e.getMessage(), e);
404         } catch (WorkflowSecurityException e) {
405             throw new net.kwfgrid.gwes.exception.WorkflowSecurityException(e.getMessage(), e);
406         } catch (GWESException e) {
407             throw new net.kwfgrid.gwes.exception.GWESException(e.getMessage(), e);
408 //        } catch (RemoteException e) {
409 //            throw new java.rmi.RemoteException(e.getMessage(), e);
410         }
411     }
412 
413     public String[] getWorkflowIDs(int level, String userID) throws
414             net.kwfgrid.gwes.exception.DatabaseException,
415             net.kwfgrid.gwes.exception.LoggingException,
416             net.kwfgrid.gwes.exception.WorkflowSecurityException,
417             net.kwfgrid.gwes.exception.GWESException,
418             java.rmi.RemoteException {
419         logger.debug("getWorkflowIDs(level="+level+")...");
420         try {
421             GWESStub.GetWorkflowIDs params = new GWESStub.GetWorkflowIDs();
422             params.setLevel(level);
423             params.setUserID(userID);
424             GWESStub.GetWorkflowIDsResponse response = stub.getWorkflowIDs(params);
425             return response.get_return();
426         } catch (DatabaseException e) {
427             throw new net.kwfgrid.gwes.exception.DatabaseException(e.getMessage(), e);
428         } catch (LoggingException e) {
429             throw new net.kwfgrid.gwes.exception.LoggingException(e.getMessage(), e);
430         } catch (WorkflowSecurityException e) {
431             throw new net.kwfgrid.gwes.exception.WorkflowSecurityException(e.getMessage(), e);
432         } catch (GWESException e) {
433             throw new net.kwfgrid.gwes.exception.GWESException(e.getMessage(), e);
434 //        } catch (RemoteException e) {
435 //            throw new java.rmi.RemoteException(e.getMessage(), e);
436         }
437     }
438 
439     public String[][] getWorkflowStatusArray(int level, String userID) throws
440 //            net.kwfgrid.gwes.exception.DatabaseException,
441             net.kwfgrid.gwes.exception.LoggingException,
442             net.kwfgrid.gwes.exception.WorkflowSecurityException,
443             net.kwfgrid.gwes.exception.GWESException,
444             java.rmi.RemoteException {
445         logger.debug("getWorkflowStatusArray(level="+level+")...");
446         try {
447             GWESStub.GetWorkflowStatusArray params = new GWESStub.GetWorkflowStatusArray();
448             params.setLevel(level);
449             params.setUserID(userID);
450             GWESStub.GetWorkflowStatusArrayResponse response = stub.getWorkflowStatusArray(params);
451             return convertArrayOfStrings(response.get_return());
452 //        } catch (DatabaseException e) {
453 //            throw new net.kwfgrid.gwes.exception.DatabaseException(e.getMessage(), e);
454         } catch (LoggingException e) {
455             throw new net.kwfgrid.gwes.exception.LoggingException(e.getMessage(), e);
456         } catch (WorkflowSecurityException e) {
457             throw new net.kwfgrid.gwes.exception.WorkflowSecurityException(e.getMessage(), e);
458         } catch (GWESException e) {
459             throw new net.kwfgrid.gwes.exception.GWESException(e.getMessage(), e);
460 //        } catch (RemoteException e) {
461 //            throw new java.rmi.RemoteException(e.getMessage(), e);
462         }
463     }
464 
465     public String store(String workflowID, String userID) throws
466             net.kwfgrid.gwes.exception.NoSuchWorkflowException,
467             net.kwfgrid.gwes.exception.DatabaseException,
468             net.kwfgrid.gwes.exception.LoggingException,
469             net.kwfgrid.gwes.exception.WorkflowSecurityException,
470             net.kwfgrid.gwes.exception.GWESException,
471             java.rmi.RemoteException {
472         logger.debug("store("+workflowID+")...");
473         try {
474             GWESStub.Store params = new GWESStub.Store();
475             params.setWorkflowID(workflowID);
476             params.setUserID(userID);
477             GWESStub.StoreResponse response = stub.store(params);
478             return response.get_return();
479         } catch (NoSuchWorkflowException e) {
480             throw new net.kwfgrid.gwes.exception.NoSuchWorkflowException(e.getMessage(), e);
481         } catch (DatabaseException e) {
482             throw new net.kwfgrid.gwes.exception.DatabaseException(e.getMessage(), e);
483         } catch (LoggingException e) {
484             throw new net.kwfgrid.gwes.exception.LoggingException(e.getMessage(), e);
485         } catch (WorkflowSecurityException e) {
486             throw new net.kwfgrid.gwes.exception.WorkflowSecurityException(e.getMessage(), e);
487         } catch (GWESException e) {
488             throw new net.kwfgrid.gwes.exception.GWESException(e.getMessage(), e);
489 //        } catch (RemoteException e) {
490 //            throw new java.rmi.RemoteException(e.getMessage(), e);
491         }
492     }
493 
494     public String restore(String workflowID, String userID) throws
495             net.kwfgrid.gwes.exception.NoSuchWorkflowException,
496             net.kwfgrid.gworkflowdl.structure.WorkflowFormatException,
497             net.kwfgrid.gwes.exception.DatabaseException,
498             net.kwfgrid.gwes.exception.StateTransitionException,
499             net.kwfgrid.gwes.exception.LoggingException,
500             net.kwfgrid.gwes.exception.WorkflowSecurityException,
501             net.kwfgrid.gwes.exception.GWESException,
502             java.rmi.RemoteException {
503         logger.debug("restore("+workflowID+")...");
504         try {
505             GWESStub.Restore params = new GWESStub.Restore();
506             params.setWorkflowID(workflowID);
507             params.setUserID(userID);
508             GWESStub.RestoreResponse response = stub.restore(params);
509             return response.get_return();
510         } catch (NoSuchWorkflowException e) {
511             throw new net.kwfgrid.gwes.exception.NoSuchWorkflowException(e.getMessage(), e);
512         } catch (WorkflowFormatException e) {
513             throw new net.kwfgrid.gworkflowdl.structure.WorkflowFormatException(e.getMessage(), e);
514         } catch (DatabaseException e) {
515             throw new net.kwfgrid.gwes.exception.DatabaseException(e.getMessage(), e);
516         } catch (StateTransitionException e) {
517             throw new net.kwfgrid.gwes.exception.StateTransitionException(e.getMessage(), e);
518         } catch (LoggingException e) {
519             throw new net.kwfgrid.gwes.exception.LoggingException(e.getMessage(), e);
520         } catch (WorkflowSecurityException e) {
521             throw new net.kwfgrid.gwes.exception.WorkflowSecurityException(e.getMessage(), e);
522         } catch (GWESException e) {
523             throw new net.kwfgrid.gwes.exception.GWESException(e.getMessage(), e);
524 //        } catch (RemoteException e) {
525 //            throw new java.rmi.RemoteException(e.getMessage(), e);
526         }
527     }
528 
529     public String[] getData(String workflowID, String placeID, String userID) throws
530             net.kwfgrid.gwes.exception.NoSuchWorkflowException,
531             net.kwfgrid.gwes.exception.LoggingException,
532             net.kwfgrid.gwes.exception.DatabaseException,
533             net.kwfgrid.gwes.exception.WorkflowSecurityException,
534             net.kwfgrid.gwes.exception.GWESException,
535             java.rmi.RemoteException {
536         if (logger.isDebugEnabled()) logger.debug("getData("+workflowID+", placeID="+placeID+")...");
537         try {
538             GWESStub.GetData params = new GWESStub.GetData();
539             params.setWorkflowID(workflowID);
540             params.setPlaceID(placeID);
541             params.setUserID(userID);
542             GWESStub.GetDataResponse response = stub.getData(params);
543             return response.get_return();
544         } catch (NoSuchWorkflowException e) {
545             throw new net.kwfgrid.gwes.exception.NoSuchWorkflowException(e.getMessage(), e);
546         } catch (DatabaseException e) {
547             throw new net.kwfgrid.gwes.exception.DatabaseException(e.getMessage(), e);
548         } catch (LoggingException e) {
549             throw new net.kwfgrid.gwes.exception.LoggingException(e.getMessage(), e);
550         } catch (WorkflowSecurityException e) {
551             throw new net.kwfgrid.gwes.exception.WorkflowSecurityException(e.getMessage(), e);
552         } catch (GWESException e) {
553             throw new net.kwfgrid.gwes.exception.GWESException(e.getMessage(), e);
554 //        } catch (RemoteException e) {
555 //            throw new java.rmi.RemoteException(e.getMessage(), e);
556         }
557     }
558 
559     public void setDescription(String workflowID, String description, String userID) throws
560             net.kwfgrid.gwes.exception.NoSuchWorkflowException,
561             net.kwfgrid.gwes.exception.DatabaseException,
562             net.kwfgrid.gwes.exception.LoggingException,
563             net.kwfgrid.gwes.exception.WorkflowSecurityException,
564             java.rmi.RemoteException,
565             net.kwfgrid.gwes.exception.GWESException {
566         logger.debug("setDescription("+workflowID+")...");
567         try {
568             GWESStub.SetDescription params = new GWESStub.SetDescription();
569             params.setWorkflowID(workflowID);
570             params.setDescription(description);
571             params.setUserID(userID);
572             stub.setDescription(params);
573         } catch (NoSuchWorkflowException e) {
574             throw new net.kwfgrid.gwes.exception.NoSuchWorkflowException(e.getMessage(), e);
575         } catch (DatabaseException e) {
576             throw new net.kwfgrid.gwes.exception.DatabaseException(e.getMessage(), e);
577         } catch (LoggingException e) {
578             throw new net.kwfgrid.gwes.exception.LoggingException(e.getMessage(), e);
579         } catch (WorkflowSecurityException e) {
580             throw new net.kwfgrid.gwes.exception.WorkflowSecurityException(e.getMessage(), e);
581         } catch (GWESException e) {
582             throw new net.kwfgrid.gwes.exception.GWESException(e.getMessage(), e);
583 //        } catch (RemoteException e) {
584 //            throw new java.rmi.RemoteException(e.getMessage(), e);
585         }
586     }
587 
588     public String getDescription(String workflowID, String userID) throws
589             net.kwfgrid.gwes.exception.NoSuchWorkflowException,
590             net.kwfgrid.gwes.exception.DatabaseException,
591             net.kwfgrid.gwes.exception.LoggingException,
592             net.kwfgrid.gwes.exception.WorkflowSecurityException,
593             java.rmi.RemoteException,
594             net.kwfgrid.gwes.exception.GWESException {
595         logger.debug("getDescription("+workflowID+")...");
596         try {
597             GWESStub.GetDescription params = new GWESStub.GetDescription();
598             params.setWorkflowID(workflowID);
599             params.setUserID(userID);
600             GWESStub.GetDescriptionResponse response = stub.getDescription(params);
601             return response.get_return();
602         } catch (NoSuchWorkflowException e) {
603             throw new net.kwfgrid.gwes.exception.NoSuchWorkflowException(e.getMessage(), e);
604         } catch (DatabaseException e) {
605             throw new net.kwfgrid.gwes.exception.DatabaseException(e.getMessage(), e);
606         } catch (LoggingException e) {
607             throw new net.kwfgrid.gwes.exception.LoggingException(e.getMessage(), e);
608         } catch (WorkflowSecurityException e) {
609             throw new net.kwfgrid.gwes.exception.WorkflowSecurityException(e.getMessage(), e);
610         } catch (GWESException e) {
611             throw new net.kwfgrid.gwes.exception.GWESException(e.getMessage(), e);
612 //        } catch (RemoteException e) {
613 //            throw new java.rmi.RemoteException(e.getMessage(), e);
614         }
615     }
616 
617     public void setProperty(String workflowID, String name, String value, String userID) throws
618             net.kwfgrid.gwes.exception.NoSuchWorkflowException,
619             net.kwfgrid.gworkflowdl.structure.WorkflowFormatException,
620             net.kwfgrid.gwes.exception.DatabaseException,
621             net.kwfgrid.gwes.exception.LoggingException,
622             net.kwfgrid.gwes.exception.WorkflowSecurityException,
623             java.rmi.RemoteException,
624             net.kwfgrid.gwes.exception.GWESException {
625         logger.debug("setProperty("+workflowID+")...");
626         try {
627             GWESStub.SetProperty params = new GWESStub.SetProperty();
628             params.setWorkflowID(workflowID);
629             params.setName(name);
630             params.setValue(value);
631             params.setUserID(userID);
632             stub.setProperty(params);
633         } catch (NoSuchWorkflowException e) {
634             throw new net.kwfgrid.gwes.exception.NoSuchWorkflowException(e.getMessage(), e);
635         } catch (WorkflowFormatException e) {
636             throw new net.kwfgrid.gworkflowdl.structure.WorkflowFormatException(e.getMessage(), e);
637         } catch (DatabaseException e) {
638             throw new net.kwfgrid.gwes.exception.DatabaseException(e.getMessage(), e);
639         } catch (LoggingException e) {
640             throw new net.kwfgrid.gwes.exception.LoggingException(e.getMessage(), e);
641         } catch (WorkflowSecurityException e) {
642             throw new net.kwfgrid.gwes.exception.WorkflowSecurityException(e.getMessage(), e);
643         } catch (GWESException e) {
644             throw new net.kwfgrid.gwes.exception.GWESException(e.getMessage(), e);
645 //        } catch (RemoteException e) {
646 //            throw new java.rmi.RemoteException(e.getMessage(), e);
647         }
648     }
649 
650     public String getProperty(String workflowID, String name, String userID) throws
651             net.kwfgrid.gwes.exception.NoSuchWorkflowException,
652             net.kwfgrid.gworkflowdl.structure.WorkflowFormatException,
653             net.kwfgrid.gwes.exception.DatabaseException,
654             net.kwfgrid.gwes.exception.LoggingException,
655             net.kwfgrid.gwes.exception.WorkflowSecurityException,
656             java.rmi.RemoteException,
657             net.kwfgrid.gwes.exception.GWESException {
658         logger.debug("getProperty("+workflowID+")...");
659         try {
660             GWESStub.GetProperty params = new GWESStub.GetProperty();
661             params.setWorkflowID(workflowID);
662             params.setName(name);
663             params.setUserID(userID);
664             GWESStub.GetPropertyResponse response = stub.getProperty(params);
665             return response.get_return();
666         } catch (NoSuchWorkflowException e) {
667             throw new net.kwfgrid.gwes.exception.NoSuchWorkflowException(e.getMessage(), e);
668         } catch (WorkflowFormatException e) {
669             throw new net.kwfgrid.gworkflowdl.structure.WorkflowFormatException(e.getMessage(), e);
670         } catch (DatabaseException e) {
671             throw new net.kwfgrid.gwes.exception.DatabaseException(e.getMessage(), e);
672         } catch (LoggingException e) {
673             throw new net.kwfgrid.gwes.exception.LoggingException(e.getMessage(), e);
674         } catch (WorkflowSecurityException e) {
675             throw new net.kwfgrid.gwes.exception.WorkflowSecurityException(e.getMessage(), e);
676         } catch (GWESException e) {
677             throw new net.kwfgrid.gwes.exception.GWESException(e.getMessage(), e);
678 //        } catch (RemoteException e) {
679 //            throw new java.rmi.RemoteException(e.getMessage(), e);
680         }
681     }
682 
683     public String[][] getProperties(String workflowID, String userID) throws
684             net.kwfgrid.gwes.exception.NoSuchWorkflowException,
685             net.kwfgrid.gworkflowdl.structure.WorkflowFormatException,
686             net.kwfgrid.gwes.exception.DatabaseException,
687             net.kwfgrid.gwes.exception.LoggingException,
688             net.kwfgrid.gwes.exception.WorkflowSecurityException,
689             java.rmi.RemoteException,
690             net.kwfgrid.gwes.exception.GWESException {
691         logger.debug("getProperties("+workflowID+")...");
692         try {
693             GWESStub.GetProperties params = new GWESStub.GetProperties();
694             params.setWorkflowID(workflowID);
695             params.setUserID(userID);
696             GWESStub.GetPropertiesResponse response = stub.getProperties(params);
697             return convertArrayOfStrings(response.get_return());
698         } catch (NoSuchWorkflowException e) {
699             throw new net.kwfgrid.gwes.exception.NoSuchWorkflowException(e.getMessage(), e);
700         } catch (WorkflowFormatException e) {
701             throw new net.kwfgrid.gworkflowdl.structure.WorkflowFormatException(e.getMessage(), e);
702         } catch (DatabaseException e) {
703             throw new net.kwfgrid.gwes.exception.DatabaseException(e.getMessage(), e);
704         } catch (LoggingException e) {
705             throw new net.kwfgrid.gwes.exception.LoggingException(e.getMessage(), e);
706         } catch (WorkflowSecurityException e) {
707             throw new net.kwfgrid.gwes.exception.WorkflowSecurityException(e.getMessage(), e);
708         } catch (GWESException e) {
709             throw new net.kwfgrid.gwes.exception.GWESException(e.getMessage(), e);
710 //        } catch (RemoteException e) {
711 //            throw new java.rmi.RemoteException(e.getMessage(), e);
712         }
713     }
714 
715     public String[] getCheckpoints(String workflowID, String userID) throws
716 //            net.kwfgrid.gwes.exception.NoSuchWorkflowException,
717             net.kwfgrid.gwes.exception.DatabaseException ,
718             net.kwfgrid.gwes.exception.LoggingException,
719             net.kwfgrid.gwes.exception.WorkflowSecurityException,
720             java.rmi.RemoteException,
721             net.kwfgrid.gwes.exception.GWESException {
722         logger.debug("getCheckpoints("+workflowID+")...");
723         try {
724             GWESStub.GetCheckpoints params = new GWESStub.GetCheckpoints();
725             params.setWorkflowID(workflowID);
726             params.setUserID(userID);
727             GWESStub.GetCheckpointsResponse response = stub.getCheckpoints(params);
728             return response.get_return();
729 //        } catch (NoSuchWorkflowException e) {
730 //            throw new net.kwfgrid.gwes.exception.NoSuchWorkflowException(e.getMessage(), e);
731         } catch (DatabaseException e) {
732             throw new net.kwfgrid.gwes.exception.DatabaseException(e.getMessage(), e);
733         } catch (LoggingException e) {
734             throw new net.kwfgrid.gwes.exception.LoggingException(e.getMessage(), e);
735         } catch (WorkflowSecurityException e) {
736             throw new net.kwfgrid.gwes.exception.WorkflowSecurityException(e.getMessage(), e);
737         } catch (GWESException e) {
738             throw new net.kwfgrid.gwes.exception.GWESException(e.getMessage(), e);
739 //        } catch (RemoteException e) {
740 //            throw new java.rmi.RemoteException(e.getMessage(), e);
741         }
742     }
743 
744     public void remove(String workflowID, int level, String userID) throws
745             net.kwfgrid.gwes.exception.NoSuchWorkflowException,
746             net.kwfgrid.gwes.exception.DatabaseException,
747             net.kwfgrid.gwes.exception.LoggingException,
748             net.kwfgrid.gwes.exception.WorkflowSecurityException,
749             java.rmi.RemoteException,
750             net.kwfgrid.gwes.exception.GWESException {
751         logger.debug("remove("+workflowID+")...");
752         try {
753             GWESStub.Remove params = new GWESStub.Remove();
754             params.setWorkflowID(workflowID);
755             params.setLevel(level);
756             params.setUserID(userID);
757             stub.remove(params);
758         } catch (NoSuchWorkflowException e) {
759             throw new net.kwfgrid.gwes.exception.NoSuchWorkflowException(e.getMessage(), e);
760         } catch (DatabaseException e) {
761             throw new net.kwfgrid.gwes.exception.DatabaseException(e.getMessage(), e);
762         } catch (LoggingException e) {
763             throw new net.kwfgrid.gwes.exception.LoggingException(e.getMessage(), e);
764         } catch (WorkflowSecurityException e) {
765             throw new net.kwfgrid.gwes.exception.WorkflowSecurityException(e.getMessage(), e);
766         } catch (GWESException e) {
767             throw new net.kwfgrid.gwes.exception.GWESException(e.getMessage(), e);
768 //        } catch (RemoteException e) {
769 //            throw new java.rmi.RemoteException(e.getMessage(), e);
770         }
771     }
772 
773     public String[][] getActivityStatusArray(String workflowID, String userID) throws
774             net.kwfgrid.gwes.exception.NoSuchWorkflowException,
775             net.kwfgrid.gwes.exception.LoggingException,
776             net.kwfgrid.gwes.exception.WorkflowSecurityException,
777             net.kwfgrid.gwes.exception.GWESException,
778             java.rmi.RemoteException {
779         logger.debug("getActivityStatusArray("+workflowID+")...");
780         try {
781             GWESStub.GetActivityStatusArray params = new GWESStub.GetActivityStatusArray();
782             params.setWorkflowID(workflowID);
783             params.setUserID(userID);
784             GWESStub.GetActivityStatusArrayResponse response = stub.getActivityStatusArray(params);
785             return convertArrayOfStrings(response.get_return());
786         } catch (NoSuchWorkflowException e) {
787             throw new net.kwfgrid.gwes.exception.NoSuchWorkflowException(e.getMessage(), e);
788         } catch (AxisFault e) {
789             if (PATTERN_WORKFLOW_NOT_AVAILABLE.matcher(e.getMessage()).matches()) {
790                 throw new net.kwfgrid.gwes.exception.NoSuchWorkflowException("Workflow with ID '"+workflowID+"' is not available in memory!",e);
791             }
792             else throw new java.rmi.RemoteException(e.getMessage(), e);
793         } catch (LoggingException e) {
794             throw new net.kwfgrid.gwes.exception.LoggingException(e.getMessage(), e);
795         } catch (WorkflowSecurityException e) {
796             throw new net.kwfgrid.gwes.exception.WorkflowSecurityException(e.getMessage(), e);
797         } catch (GWESException e) {
798             throw new net.kwfgrid.gwes.exception.GWESException(e.getMessage(), e);
799 //        } catch (RemoteException e) {
800 //            throw new java.rmi.RemoteException(e.getMessage(), e);
801         }
802     }
803 
804     public String[] getAvailableResources(String ofClass, String userID) throws
805             net.kwfgrid.gwes.exception.DatabaseException,
806             net.kwfgrid.gwes.exception.LoggingException,
807             net.kwfgrid.gwes.exception.WorkflowSecurityException,
808             net.kwfgrid.gwes.exception.GWESException,
809             java.rmi.RemoteException {
810         logger.debug("getAvailableResources("+ofClass+")...");
811         try {
812             GWESStub.GetAvailableResources params = new GWESStub.GetAvailableResources();
813             params.setOfClass(ofClass);
814             params.setUserID(userID);
815             GWESStub.GetAvailableResourcesResponse response = stub.getAvailableResources(params);
816             return response.get_return();
817         } catch (DatabaseException e) {
818             throw new net.kwfgrid.gwes.exception.DatabaseException(e.getMessage(), e);
819         } catch (LoggingException e) {
820             throw new net.kwfgrid.gwes.exception.LoggingException(e.getMessage(), e);
821         } catch (WorkflowSecurityException e) {
822             throw new net.kwfgrid.gwes.exception.WorkflowSecurityException(e.getMessage(), e);
823         } catch (GWESException e) {
824             throw new net.kwfgrid.gwes.exception.GWESException(e.getMessage(), e);
825 //        } catch (RemoteException e) {
826 //            throw new java.rmi.RemoteException(e.getMessage(), e);
827         }
828     }
829 
830     public String getResourceDescription(String resourceUri, String userID) throws
831             net.kwfgrid.gwes.exception.DatabaseException,
832             net.kwfgrid.gwes.exception.LoggingException,
833             net.kwfgrid.gwes.exception.WorkflowSecurityException,
834             net.kwfgrid.gwes.exception.GWESException,
835             java.rmi.RemoteException {
836         logger.debug("getResourceDescription("+resourceUri+")...");
837         try {
838             GWESStub.GetResourceDescription params = new GWESStub.GetResourceDescription();
839             params.setResourceUri(resourceUri);
840             params.setUserID(userID);
841             GWESStub.GetResourceDescriptionResponse response = stub.getResourceDescription(params);
842             return response.get_return();
843         } catch (DatabaseException e) {
844             throw new net.kwfgrid.gwes.exception.DatabaseException(e.getMessage(), e);
845         } catch (LoggingException e) {
846             throw new net.kwfgrid.gwes.exception.LoggingException(e.getMessage(), e);
847         } catch (WorkflowSecurityException e) {
848             throw new net.kwfgrid.gwes.exception.WorkflowSecurityException(e.getMessage(), e);
849         } catch (GWESException e) {
850             throw new net.kwfgrid.gwes.exception.GWESException(e.getMessage(), e);
851 //        } catch (RemoteException e) {
852 //            throw new java.rmi.RemoteException(e.getMessage(), e);
853         }
854     }
855 
856     /********************************************************************************
857      * Private classes
858      ********************************************************************************/
859 
860     /**
861      * Convert ArrayOfString[] object, defined by Axis2 Stub, to String[][].
862      * @param arrayOfStrings
863      * @return Same object as String[][]. If arrayOfStrings parameter is null, then an
864      * empty String[][] object is returned (not null!)
865      */
866     private String[][] convertArrayOfStrings(GWESStub.ArrayOfString[] arrayOfStrings) {
867         if (arrayOfStrings == null || arrayOfStrings.length == 0) return new String[0][];
868         String[][] ret = new String[arrayOfStrings.length][];
869         for (int i=0; i<arrayOfStrings.length; i++) {
870             if (arrayOfStrings[i]==null) ret[i] = new String[0];
871             else ret[i]=arrayOfStrings[i].getArray();
872         }
873         return ret;
874     }
875 
876 }
877