KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > shark > ExecutionAdmin


1 package org.enhydra.shark;
2
3 import java.util.ArrayList JavaDoc;
4 import java.util.HashMap JavaDoc;
5 import java.util.Iterator JavaDoc;
6 import java.util.List JavaDoc;
7 import java.util.Map JavaDoc;
8
9 import org.enhydra.shark.api.RootException;
10 import org.enhydra.shark.api.SharkTransaction;
11 import org.enhydra.shark.api.client.wfbase.BaseException;
12 import org.enhydra.shark.api.client.wfmodel.WfActivity;
13 import org.enhydra.shark.api.client.wfmodel.WfActivityIterator;
14 import org.enhydra.shark.api.client.wfmodel.WfAssignment;
15 import org.enhydra.shark.api.client.wfmodel.WfAssignmentIterator;
16 import org.enhydra.shark.api.client.wfmodel.WfProcess;
17 import org.enhydra.shark.api.client.wfmodel.WfProcessIterator;
18 import org.enhydra.shark.api.client.wfmodel.WfProcessMgr;
19 import org.enhydra.shark.api.client.wfmodel.WfResource;
20 import org.enhydra.shark.api.client.wfservice.ConnectFailed;
21 import org.enhydra.shark.api.client.wfservice.ExecutionAdministration;
22 import org.enhydra.shark.api.client.wfservice.NotConnected;
23 import org.enhydra.shark.api.client.wfservice.WfProcessMgrIterator;
24 import org.enhydra.shark.api.client.wfservice.WfResourceIterator;
25 import org.enhydra.shark.api.common.SharkConstants;
26 import org.enhydra.shark.api.internal.caching.CacheMgr;
27 import org.enhydra.shark.api.internal.instancepersistence.ActivityPersistenceInterface;
28 import org.enhydra.shark.api.internal.instancepersistence.ActivityVariablePersistenceInterface;
29 import org.enhydra.shark.api.internal.instancepersistence.PersistenceException;
30 import org.enhydra.shark.api.internal.instancepersistence.PersistentManagerInterface;
31 import org.enhydra.shark.api.internal.instancepersistence.ProcessPersistenceInterface;
32 import org.enhydra.shark.api.internal.instancepersistence.ProcessVariablePersistenceInterface;
33 import org.enhydra.shark.api.internal.processlocking.LockMaster;
34 import org.enhydra.shark.api.internal.security.SecurityManager;
35 import org.enhydra.shark.api.internal.working.CallbackUtilities;
36 import org.enhydra.shark.api.internal.working.WfActivityInternal;
37 import org.enhydra.shark.api.internal.working.WfAssignmentInternal;
38 import org.enhydra.shark.api.internal.working.WfProcessInternal;
39 import org.enhydra.shark.api.internal.working.WfProcessMgrInternal;
40 import org.enhydra.shark.api.internal.working.WfResourceInternal;
41
42 /**
43  * The client interface through which client accesses the engine
44  * objects, and performs the various actions on engine.
45  *
46  * @author Sasa Bojanic
47  * @version 1.1
48  */

49 public class ExecutionAdmin implements ExecutionAdministration {
50
51    private String JavaDoc userId;
52    private boolean connected=false;
53
54    private String JavaDoc connectionKey;
55
56
57    private CallbackUtilities cus;
58    protected ExecutionAdmin () {
59       this.cus=SharkEngineManager.getInstance().getCallbackUtilities();
60    }
61
62    public void connect (String JavaDoc userId,String JavaDoc password,String JavaDoc engineName,String JavaDoc scope) throws BaseException, ConnectFailed {
63       SharkTransaction t = null;
64       try {
65          t = SharkUtilities.createTransaction();
66          connect(t, userId, password, engineName, scope);
67          SharkUtilities.commitTransaction(t);
68       } catch (RootException e) {
69          SharkUtilities.rollbackTransaction(t,e);
70          if (e instanceof ConnectFailed)
71             throw (ConnectFailed)e;
72          else if (e instanceof BaseException)
73             throw (BaseException)e;
74          else
75             throw new BaseException(e);
76       } finally {
77          SharkUtilities.releaseTransaction(t);
78       }
79    }
80
81    public void connect (SharkTransaction t,String JavaDoc userId,String JavaDoc password,String JavaDoc engineName,String JavaDoc scope) throws BaseException, ConnectFailed {
82       this.userId=userId;
83
84       SecurityManager JavaDoc sm=SharkEngineManager.getInstance().getSecurityManager();
85       if (sm!=null) {
86          try {
87             sm.check_executionadministration_connect(t,userId);
88          } catch (Exception JavaDoc ex) {
89             throw new BaseException(ex);
90          }
91       }
92       try {
93          if (!SharkUtilities.validateUser(userId,password)) {
94             cus.info("ExecutionAdmin -> Login failed: Invalid username or password"+userId);
95             throw new ConnectFailed("Connection failed, invalid username or password");
96          }
97
98          if (SharkUtilities.getResource(t, userId)==null) {
99             WfResourceInternal resInternal=SharkEngineManager
100                .getInstance()
101                .getObjectFactory()
102                .createResource(t,userId);
103          }
104          connectionKey=SharkUtilities.connect(userId);
105          connected=true;
106          cus.info("ExecutionAdmin -> User "+userId+" with connection key "+connectionKey+" is logged on");
107       } catch (Exception JavaDoc ex) {
108          if (ex instanceof ConnectFailed) {
109             throw (ConnectFailed)ex;
110          }
111          cus.info("ExecutionAdmin -> Unexpected error while user "+userId+" loggs on");
112          ex.printStackTrace();
113          throw new BaseException(ex);
114       }
115    }
116
117    public void disconnect () throws BaseException, NotConnected {
118       SharkTransaction t = null;
119       try {
120          t = SharkUtilities.createTransaction();
121          disconnect(t);
122          //SharkUtilities.commitTransaction(t);
123
} catch (RootException e) {
124          //SharkUtilities.rollbackTransaction(t);
125
SharkUtilities.emptyCaches(t);
126          if (e instanceof NotConnected)
127             throw (NotConnected)e;
128          else if (e instanceof BaseException)
129             throw (BaseException)e;
130          else
131             throw new BaseException(e);
132       } finally {
133          SharkUtilities.releaseTransaction(t);
134       }
135    }
136
137    public void disconnect (SharkTransaction t) throws BaseException, NotConnected {
138       if (!connected) {
139          throw new NotConnected("The connection is not established...");
140       }
141       try {
142          SharkUtilities.disconnect(connectionKey);
143          connected=false;
144          cus.info("ExecutionAdmin -> User "+userId+" with connection key "+connectionKey+" is logged off");
145       } catch (Exception JavaDoc ex) {
146          if (ex instanceof NotConnected) {
147             throw (NotConnected)ex;
148          }
149          cus.info("ExecutionAdmin -> Unexpected error while user "+userId+" loggs off");
150          throw new BaseException(ex);
151       }
152    }
153
154    public WfProcessMgrIterator get_iterator_processmgr () throws BaseException, NotConnected {
155       WfProcessMgrIterator ret = null;
156       SharkTransaction t = null;
157       try {
158          t = SharkUtilities.createTransaction();
159          ret = get_iterator_processmgr(t);
160          //SharkUtilities.commitTransaction(t);
161
} catch (RootException e) {
162          //SharkUtilities.rollbackTransaction(t);
163
SharkUtilities.emptyCaches(t);
164          if (e instanceof NotConnected)
165             throw (NotConnected)e;
166          else if (e instanceof BaseException)
167             throw (BaseException)e;
168          else
169             throw new BaseException(e);
170       } finally {
171          SharkUtilities.releaseTransaction(t);
172       }
173       return ret;
174    }
175
176    public WfProcessMgrIterator get_iterator_processmgr (SharkTransaction t) throws BaseException, NotConnected {
177       if (!connected) {
178          throw new NotConnected("The connection is not established...");
179       }
180       SecurityManager JavaDoc sm=SharkEngineManager.getInstance().getSecurityManager();
181       if (sm!=null) {
182          try {
183             sm.check_executionadministration_get_iterator_processmgr(t,userId);
184          } catch (Exception JavaDoc ex) {
185             throw new BaseException(ex);
186          }
187       }
188       try {
189          WfProcessMgrIterator ret=SharkEngineManager.getInstance().
190             getObjectFactory().createProcessMgrIteratorWrapper(t,userId);
191          return ret;
192       } catch (Exception JavaDoc ex) {
193          cus.info("ExecutionAdmin -> Unexpected error while user tries to get process managers iterator");
194          throw new BaseException(ex);
195       }
196    }
197
198    public WfProcessMgr[] get_sequence_processmgr (int max_number) throws BaseException, NotConnected {
199       WfProcessMgr[] ret = null;
200       SharkTransaction t = null;
201       try {
202          t = SharkUtilities.createTransaction();
203          ret = get_sequence_processmgr(t, max_number);
204          //SharkUtilities.commitTransaction(t);
205
} catch (RootException e) {
206          //SharkUtilities.rollbackTransaction(t);
207
SharkUtilities.emptyCaches(t);
208          if (e instanceof NotConnected)
209             throw (NotConnected)e;
210          else if (e instanceof BaseException)
211             throw (BaseException)e;
212          else
213             throw new BaseException(e);
214       } finally {
215          SharkUtilities.releaseTransaction(t);
216       }
217       return ret;
218    }
219
220    public WfProcessMgr[] get_sequence_processmgr (SharkTransaction t,int max_number) throws BaseException, NotConnected {
221       if (!connected) {
222          throw new NotConnected("The connection is not established...");
223       }
224       SecurityManager JavaDoc sm=SharkEngineManager.getInstance().getSecurityManager();
225       if (sm!=null) {
226          try {
227             sm.check_executionadministration_get_sequence_processmgr(t,userId);
228          } catch (Exception JavaDoc ex) {
229             throw new BaseException(ex);
230          }
231       }
232       try {
233          return SharkEngineManager
234             .getInstance()
235             .getObjectFactory()
236             .createProcessMgrIteratorWrapper(t,userId)
237             .get_next_n_sequence (t,max_number);
238       } catch (Exception JavaDoc ex) {
239          cus.info("ExecutionAdmin -> Unexpected error while user tries to get the list of process managers");
240          throw new BaseException(ex);
241       }
242    }
243
244    public WfResourceIterator get_iterator_resource () throws BaseException, NotConnected {
245       WfResourceIterator ret = null;
246       SharkTransaction t = null;
247       try {
248          t = SharkUtilities.createTransaction();
249          ret = get_iterator_resource(t);
250          //SharkUtilities.commitTransaction(t);
251
} catch (RootException e) {
252          //SharkUtilities.rollbackTransaction(t);
253
SharkUtilities.emptyCaches(t);
254          if (e instanceof NotConnected)
255             throw (NotConnected)e;
256          else if (e instanceof BaseException)
257             throw (BaseException)e;
258          else
259             throw new BaseException(e);
260       } finally {
261          SharkUtilities.releaseTransaction(t);
262       }
263       return ret;
264    }
265
266    public WfResourceIterator get_iterator_resource (SharkTransaction t) throws BaseException, NotConnected {
267       if (!connected) {
268          throw new NotConnected("The connection is not established...");
269       }
270       SecurityManager JavaDoc sm=SharkEngineManager.getInstance().getSecurityManager();
271       if (sm!=null) {
272          try {
273             sm.check_executionadministration_get_iterator_resource(t,userId);
274          } catch (Exception JavaDoc ex) {
275             throw new BaseException(ex);
276          }
277       }
278       try {
279          return SharkEngineManager
280             .getInstance()
281             .getObjectFactory()
282             .createResourceIteratorWrapper(t,userId);
283       } catch (Exception JavaDoc ex) {
284          cus.info("ExecutionAdmin -> Unexpected error while user tries to get resource's iterator");
285          throw new BaseException(ex);
286       }
287    }
288
289    public WfResource[] get_sequence_resource (int max_number) throws BaseException, NotConnected {
290       WfResource[] ret = null;
291       SharkTransaction t = null;
292       try {
293          t = SharkUtilities.createTransaction();
294          ret = get_sequence_resource(t, max_number);
295          //SharkUtilities.commitTransaction(t);
296
} catch (RootException e) {
297          //SharkUtilities.rollbackTransaction(t);
298
SharkUtilities.emptyCaches(t);
299          if (e instanceof NotConnected)
300             throw (NotConnected)e;
301          else if (e instanceof BaseException)
302             throw (BaseException)e;
303          else
304             throw new BaseException(e);
305       } finally {
306          SharkUtilities.releaseTransaction(t);
307       }
308       return ret;
309    }
310
311    public WfResource[] get_sequence_resource (SharkTransaction t,int max_number) throws BaseException, NotConnected {
312       if (!connected) {
313          throw new NotConnected("The connection is not established...");
314       }
315       SecurityManager JavaDoc sm=SharkEngineManager.getInstance().getSecurityManager();
316       if (sm!=null) {
317          try {
318             sm.check_executionadministration_get_sequence_resource(t,userId);
319          } catch (Exception JavaDoc ex) {
320             throw new BaseException(ex);
321          }
322       }
323
324       try {
325          return SharkEngineManager
326             .getInstance()
327             .getObjectFactory()
328             .createResourceIteratorWrapper(t,userId)
329             .get_next_n_sequence (max_number);
330       } catch (Exception JavaDoc ex) {
331          cus.info("ExecutionAdmin -> Unexpected error while user tries to get the list of resources");
332          throw new BaseException(ex);
333       }
334    }
335
336    public Map JavaDoc getLoggedUsers () throws BaseException, NotConnected {
337       Map JavaDoc ret = null;
338       SharkTransaction t = null;
339       try {
340          t = SharkUtilities.createTransaction();
341          ret = getLoggedUsers(t);
342          //SharkUtilities.commitTransaction(t);
343
} catch (RootException e) {
344          //SharkUtilities.rollbackTransaction(t);
345
SharkUtilities.emptyCaches(t);
346          if (e instanceof NotConnected)
347             throw (NotConnected)e;
348          else if (e instanceof BaseException)
349             throw (BaseException)e;
350          else
351             throw new BaseException(e);
352       } finally {
353          SharkUtilities.releaseTransaction(t);
354       }
355       return ret;
356    }
357
358    public Map JavaDoc getLoggedUsers(SharkTransaction t) throws BaseException, NotConnected {
359       if (!connected) {
360          throw new NotConnected("The connection is not established...");
361       }
362       SecurityManager JavaDoc sm=SharkEngineManager.getInstance().getSecurityManager();
363       if (sm!=null) {
364          try {
365             sm.check_executionadministration_getLoggedUsers(t,userId);
366          } catch (Exception JavaDoc ex) {
367             throw new BaseException(ex);
368          }
369       }
370       try {
371          Map JavaDoc ret=SharkUtilities.getLoggedUsers();
372          return ret;
373       } catch (Exception JavaDoc ex) {
374          cus.info("ExecutionAdmin -> Unexpected error while user tries to get logged users");
375          throw new BaseException(ex);
376       }
377    }
378
379    public void startActivity (String JavaDoc procId,String JavaDoc blockActId,String JavaDoc actDefId) throws BaseException, NotConnected {
380       SharkTransaction t = null;
381       try {
382          t = SharkUtilities.createTransaction();
383          startActivity(t, procId, blockActId, actDefId);
384          SharkUtilities.commitTransaction(t);
385       } catch (RootException e) {
386          SharkUtilities.rollbackTransaction(t,e);
387          if (e instanceof NotConnected)
388             throw (NotConnected)e;
389          else if (e instanceof BaseException)
390             throw (BaseException)e;
391          else
392             throw new BaseException(e);
393       } finally {
394          SharkUtilities.releaseTransaction(t);
395       }
396    }
397
398    public void startActivity (SharkTransaction t,String JavaDoc procId,String JavaDoc blockActId,String JavaDoc actDefId) throws BaseException, NotConnected {
399       if (!connected) {
400          throw new NotConnected("The connection is not established...");
401       }
402       try {
403          WfProcessInternal proc=SharkUtilities.getProcess(t, procId);
404          SecurityManager JavaDoc sm=SharkEngineManager.getInstance().getSecurityManager();
405          if (sm!=null) {
406             sm.check_executionadministration_startActivity(t,
407                                                            procId,
408                                                            userId,
409                                                            proc.requester(t).getResourceRequesterUsername(t));
410          }
411          proc.start_activity(t, actDefId, blockActId);
412       } catch (Exception JavaDoc ex) {
413          throw new BaseException(ex);
414       }
415    }
416
417    public WfProcessMgr getProcessMgr (String JavaDoc name) throws BaseException, NotConnected {
418       WfProcessMgr ret = null;
419       SharkTransaction t = null;
420       try {
421          t = SharkUtilities.createTransaction();
422          ret = getProcessMgr(t, name);
423          //SharkUtilities.commitTransaction(t);
424
} catch (RootException e) {
425          //SharkUtilities.rollbackTransaction(t);
426
SharkUtilities.emptyCaches(t);
427          if (e instanceof NotConnected)
428             throw (NotConnected)e;
429          else if (e instanceof BaseException)
430             throw (BaseException)e;
431          else
432             throw new BaseException(e);
433       } finally {
434          SharkUtilities.releaseTransaction(t);
435       }
436       return ret;
437    }
438
439    public WfProcessMgr getProcessMgr (SharkTransaction t,String JavaDoc name) throws BaseException, NotConnected {
440       if (!connected) {
441          throw new NotConnected("The connection is not established...");
442       }
443       SecurityManager JavaDoc sm=SharkEngineManager.getInstance().getSecurityManager();
444       if (sm!=null) {
445          try {
446             sm.check_executionadministration_getProcessMgr(t,name,userId);
447          } catch (Exception JavaDoc ex) {
448             throw new BaseException(ex);
449          }
450       }
451       try {
452          return (null != SharkUtilities.getProcessMgr(t, name))
453             ? SharkEngineManager.getInstance().getObjectFactory().createProcessMgrWrapper(userId,name)
454             : null;
455       } catch (Exception JavaDoc ex) {
456          throw new BaseException(ex);
457       }
458    }
459
460    public WfProcessMgr getProcessMgr (String JavaDoc pkgId,String JavaDoc pDefId) throws BaseException, NotConnected {
461       WfProcessMgr ret = null;
462       SharkTransaction t = null;
463       try {
464          t = SharkUtilities.createTransaction();
465          ret = getProcessMgr(t, pkgId, pDefId);
466          //SharkUtilities.commitTransaction(t);
467
} catch (RootException e) {
468          //SharkUtilities.rollbackTransaction(t);
469
SharkUtilities.emptyCaches(t);
470          if (e instanceof NotConnected)
471             throw (NotConnected)e;
472          else if (e instanceof BaseException)
473             throw (BaseException)e;
474          else
475             throw new BaseException(e);
476       } finally {
477          SharkUtilities.releaseTransaction(t);
478       }
479       return ret;
480    }
481
482    public WfProcessMgr getProcessMgr (SharkTransaction t,String JavaDoc pkgId,String JavaDoc pDefId) throws BaseException, NotConnected {
483       if (!connected) {
484          throw new NotConnected("The connection is not established...");
485       }
486       try {
487          String JavaDoc curVer=SharkUtilities.getCurrentPkgVersion(pkgId,false);
488          String JavaDoc mgrName=SharkUtilities.createProcessMgrKey(pkgId,curVer,pDefId);
489          SecurityManager JavaDoc sm=SharkEngineManager.getInstance().getSecurityManager();
490          if (sm!=null) {
491             sm.check_executionadministration_getProcessMgr(t,mgrName,userId);
492          }
493          return (null != SharkUtilities.getProcessMgr(t, mgrName))
494             ? SharkEngineManager.getInstance().getObjectFactory().createProcessMgrWrapper(userId,mgrName)
495             : null;
496       } catch (Exception JavaDoc ex) {
497          throw new BaseException(ex);
498       }
499    }
500
501    public WfProcessMgr getProcessMgr (String JavaDoc pkgId,String JavaDoc pkgVer,String JavaDoc pDefId) throws BaseException, NotConnected {
502       WfProcessMgr ret = null;
503       SharkTransaction t = null;
504       try {
505          t = SharkUtilities.createTransaction();
506          ret = getProcessMgr(t, pkgId, pkgVer, pDefId);
507          //SharkUtilities.commitTransaction(t);
508
} catch (RootException e) {
509          //SharkUtilities.rollbackTransaction(t);
510
SharkUtilities.emptyCaches(t);
511          if (e instanceof NotConnected)
512             throw (NotConnected)e;
513          else if (e instanceof BaseException)
514             throw (BaseException)e;
515          else
516             throw new BaseException(e);
517       } finally {
518          SharkUtilities.releaseTransaction(t);
519       }
520       return ret;
521    }
522
523    public WfProcessMgr getProcessMgr (SharkTransaction t,String JavaDoc pkgId,String JavaDoc pkgVer,String JavaDoc pDefId) throws BaseException, NotConnected {
524       if (!connected) {
525          throw new NotConnected("The connection is not established...");
526       }
527       try {
528          String JavaDoc mgrName=SharkUtilities.createProcessMgrKey(pkgId,pkgVer,pDefId);
529          SecurityManager JavaDoc sm=SharkEngineManager.getInstance().getSecurityManager();
530          if (sm!=null) {
531             sm.check_executionadministration_getProcessMgr(t,mgrName,userId);
532          }
533          return (null != SharkUtilities.getProcessMgr(t, mgrName))
534             ? SharkEngineManager.getInstance().getObjectFactory().createProcessMgrWrapper(userId,mgrName)
535             : null;
536       } catch (Exception JavaDoc ex) {
537          throw new BaseException(ex);
538       }
539    }
540
541    public WfProcess getProcess (String JavaDoc procId) throws BaseException, NotConnected {
542       WfProcess ret = null;
543       SharkTransaction t = null;
544       try {
545          t = SharkUtilities.createTransaction();
546          ret = getProcess(t, procId);
547          //SharkUtilities.commitTransaction(t);
548
} catch (RootException e) {
549          //SharkUtilities.rollbackTransaction(t);
550
SharkUtilities.emptyCaches(t);
551          if (e instanceof NotConnected)
552             throw (NotConnected)e;
553          else if (e instanceof BaseException)
554             throw (BaseException)e;
555          else
556             throw new BaseException(e);
557       } finally {
558          SharkUtilities.releaseTransaction(t);
559       }
560       return ret;
561    }
562
563    public WfProcess getProcess (SharkTransaction t,String JavaDoc procId) throws BaseException, NotConnected {
564       if (!connected) {
565          throw new NotConnected("The connection is not established...");
566       }
567       try {
568          WfProcessInternal proc=SharkUtilities.getProcess(t, procId);
569          SecurityManager JavaDoc sm=SharkEngineManager.getInstance().getSecurityManager();
570          if (sm!=null && proc!=null) {
571             sm.check_executionadministration_getProcess(t,
572                                                         procId,
573                                                         userId,
574                                                         proc.requester(t).getResourceRequesterUsername(t));
575          }
576          return (null != proc)
577             ? SharkEngineManager.getInstance().getObjectFactory().createProcessWrapper(userId,proc.manager_name(t),procId)
578             : null;
579       } catch (Exception JavaDoc ex) {
580          throw new BaseException(ex);
581       }
582    }
583
584    public WfActivity getActivity (String JavaDoc procId,String JavaDoc actId) throws BaseException, NotConnected {
585       WfActivity ret = null;
586       SharkTransaction t = null;
587       try {
588          t = SharkUtilities.createTransaction();
589          ret = getActivity(t, procId, actId);
590          //SharkUtilities.commitTransaction(t);
591
} catch (RootException e) {
592          //SharkUtilities.rollbackTransaction(t);
593
SharkUtilities.emptyCaches(t);
594          if (e instanceof NotConnected)
595             throw (NotConnected)e;
596          else if (e instanceof BaseException)
597             throw (BaseException)e;
598          else
599             throw new BaseException(e);
600       } finally {
601          SharkUtilities.releaseTransaction(t);
602       }
603       return ret;
604    }
605
606    public WfActivity getActivity (SharkTransaction t,String JavaDoc procId,String JavaDoc actId) throws BaseException, NotConnected {
607       if (!connected) {
608          throw new NotConnected("The connection is not established...");
609       }
610       try {
611          WfActivityInternal act=SharkUtilities.getActivity(t, procId, actId);
612          SecurityManager JavaDoc sm=SharkEngineManager.getInstance().getSecurityManager();
613          if (sm!=null && act!=null) {
614             sm.check_executionadministration_getActivity(t,
615                                                          procId,
616                                                          actId,
617                                                          userId,
618                                                          act.container(t).requester(t).getResourceRequesterUsername(t),
619                                                          act.getResourceUsername(t),
620                                                          act.getAssignmentResourceIds(t));
621          }
622          return (null != act)
623             ? SharkEngineManager.getInstance().getObjectFactory().createActivityWrapper(userId,act.manager_name(t),procId,actId)
624             : null;
625       } catch (Exception JavaDoc ex) {
626          throw new BaseException(ex);
627       }
628    }
629
630    public WfResource getResource (String JavaDoc username) throws BaseException, NotConnected {
631       WfResource ret = null;
632       SharkTransaction t = null;
633       try {
634          t = SharkUtilities.createTransaction();
635          ret = getResource(t, username);
636          //SharkUtilities.commitTransaction(t);
637
} catch (RootException e) {
638          //SharkUtilities.rollbackTransaction(t);
639
SharkUtilities.emptyCaches(t);
640          if (e instanceof NotConnected)
641             throw (NotConnected)e;
642          else if (e instanceof BaseException)
643             throw (BaseException)e;
644          else
645             throw new BaseException(e);
646       } finally {
647          SharkUtilities.releaseTransaction(t);
648       }
649       return ret;
650    }
651
652    public WfResource getResource (SharkTransaction t,String JavaDoc username) throws BaseException, NotConnected {
653       if (!connected) {
654          throw new NotConnected("The connection is not established...");
655       }
656       SecurityManager JavaDoc sm=SharkEngineManager.getInstance().getSecurityManager();
657       if (sm!=null) {
658          try {
659             sm.check_executionadministration_getResource(t,username,userId);
660          } catch (Exception JavaDoc ex) {
661             throw new BaseException(ex);
662          }
663       }
664       try {
665          return (null != SharkUtilities.getResource(t,username))
666             ? SharkEngineManager.getInstance().getObjectFactory().createResourceWrapper(userId,username)
667             : null;
668       } catch (Exception JavaDoc ex) {
669          throw new BaseException(ex);
670       }
671    }
672
673    public WfAssignment getAssignment (String JavaDoc procId,String JavaDoc actId,String JavaDoc username) throws BaseException, NotConnected {
674       WfAssignment ret = null;
675       SharkTransaction t = null;
676       try {
677          t = SharkUtilities.createTransaction();
678          ret = getAssignment(t, procId, actId, username);
679          //SharkUtilities.commitTransaction(t);
680
} catch (RootException e) {
681          //SharkUtilities.rollbackTransaction(t);
682
SharkUtilities.emptyCaches(t);
683          if (e instanceof NotConnected)
684             throw (NotConnected)e;
685          else if (e instanceof BaseException)
686             throw (BaseException)e;
687          else
688             throw new BaseException(e);
689       } finally {
690          SharkUtilities.releaseTransaction(t);
691       }
692       return ret;
693    }
694
695    public WfAssignment getAssignment (SharkTransaction t,String JavaDoc procId,String JavaDoc actId,String JavaDoc username) throws BaseException, NotConnected {
696       if (!connected) {
697          throw new NotConnected("The connection is not established...");
698       }
699       try {
700          WfAssignmentInternal ass=SharkUtilities.getAssignment(t, procId, actId, username);
701          SecurityManager JavaDoc sm=SharkEngineManager.getInstance().getSecurityManager();
702          if (sm!=null && ass!=null) {
703             sm.check_executionadministration_getAssignment(t,
704                                                            procId,
705                                                            actId,
706                                                            username,
707                                                            userId,
708                                                            ass.activity(t).container(t).requester(t).getResourceRequesterUsername(t),
709                                                            ass.activity(t).getResourceUsername(t),
710                                                            ass.activity(t).getAssignmentResourceIds(t));
711          }
712          return (null != ass)
713             ? SharkEngineManager.getInstance().getObjectFactory().createAssignmentWrapper(userId,ass.managerName(t),procId,actId,username)
714             : null;
715       } catch (Exception JavaDoc ex) {
716          throw new BaseException(ex);
717       }
718    }
719
720    public WfAssignment getAssignment (String JavaDoc procId,String JavaDoc assId) throws BaseException, NotConnected {
721       WfAssignment ret = null;
722       SharkTransaction t = null;
723       try {
724          t = SharkUtilities.createTransaction();
725          ret = getAssignment(t, procId, assId);
726          //SharkUtilities.commitTransaction(t);
727
} catch (RootException e) {
728          //SharkUtilities.rollbackTransaction(t);
729
SharkUtilities.emptyCaches(t);
730          if (e instanceof NotConnected)
731             throw (NotConnected)e;
732          else if (e instanceof BaseException)
733             throw (BaseException)e;
734          else
735             throw new BaseException(e);
736       } finally {
737          SharkUtilities.releaseTransaction(t);
738       }
739       return ret;
740    }
741
742    public WfAssignment getAssignment (SharkTransaction t,String JavaDoc procId,String JavaDoc assId) throws BaseException, NotConnected {
743       if (!connected) {
744          throw new NotConnected("The connection is not established...");
745       }
746       try {
747          WfProcessInternal proc=SharkUtilities.getProcess(t,procId);
748          SecurityManager JavaDoc sm=SharkEngineManager.getInstance().getSecurityManager();
749          if (sm!=null && proc!=null) {
750             sm.check_executionadministration_getAssignment(t,
751                                                            procId,
752                                                            assId,
753                                                            userId,
754                                                            proc.requester(t).getResourceRequesterUsername(t));
755          }
756
757          return (null != proc)
758             ? SharkUtilities.getAssignmentWrapper(t, userId, procId, assId)
759             : null;
760       } catch (Exception JavaDoc ex) {
761          throw new BaseException(ex);
762       }
763    }
764
765    public void reevaluateAssignments () throws BaseException, NotConnected {
766       SharkTransaction t = null;
767       try {
768          t = SharkUtilities.createTransaction();
769          reevaluateAssignments(t);
770          SharkUtilities.commitTransaction(t);
771       } catch (RootException e) {
772          SharkUtilities.rollbackTransaction(t,e);
773          if (e instanceof NotConnected)
774             throw (NotConnected)e;
775          else if (e instanceof BaseException)
776             throw (BaseException)e;
777          else
778             throw new BaseException(e);
779       } finally {
780          SharkUtilities.releaseTransaction(t);
781       }
782    }
783
784    public void reevaluateAssignments (SharkTransaction t) throws BaseException, NotConnected {
785       if (!connected) {
786          throw new NotConnected("The connection is not established...");
787       }
788       SecurityManager JavaDoc sm=SharkEngineManager.getInstance().getSecurityManager();
789       if (sm!=null) {
790          try {
791             sm.check_executionadministration_reevaluateAssignments(t,userId);
792          } catch (Exception JavaDoc ex) {
793             throw new BaseException(ex);
794          }
795       }
796       SharkUtilities.reevaluateAssignments(t);
797    }
798
799    public void reevaluateAssignments (String JavaDoc pkgId) throws BaseException, NotConnected {
800       SharkTransaction t = null;
801       try {
802          t = SharkUtilities.createTransaction();
803          reevaluateAssignments(t,pkgId);
804          SharkUtilities.commitTransaction(t);
805       } catch (RootException e) {
806          SharkUtilities.rollbackTransaction(t,e);
807          if (e instanceof NotConnected)
808             throw (NotConnected)e;
809          else if (e instanceof BaseException)
810             throw (BaseException)e;
811          else
812             throw new BaseException(e);
813       } finally {
814          SharkUtilities.releaseTransaction(t);
815       }
816    }
817
818    public void reevaluateAssignments (SharkTransaction t,String JavaDoc pkgId) throws BaseException, NotConnected {
819       if (!connected) {
820          throw new NotConnected("The connection is not established...");
821       }
822       SecurityManager JavaDoc sm=SharkEngineManager.getInstance().getSecurityManager();
823       if (sm!=null) {
824          try {
825             sm.check_executionadministration_reevaluateAssignments(t,userId);
826          } catch (Exception JavaDoc ex) {
827             throw new BaseException(ex);
828          }
829       }
830       WfProcessMgrIterator iter=SharkEngineManager.getInstance().
831          getObjectFactory().createProcessMgrIteratorWrapper(t,userId);
832       String JavaDoc query="packageId.equals(\""+pkgId+"\")";
833       try {
834          iter.set_query_expression(t,query);
835       } catch (Exception JavaDoc ex) {
836          throw new BaseException(ex);
837       }
838       WfProcessMgr[] mgrs=iter.get_next_n_sequence(t,0);
839       if (mgrs!=null) {
840          for (int i=0; i<mgrs.length; i++) {
841             String JavaDoc mgrName=mgrs[i].name(t);
842             SharkUtilities.reevalAssignments(t,mgrName);
843          }
844       }
845    }
846
847    public void reevaluateAssignments (String JavaDoc pkgId,String JavaDoc pDefId) throws BaseException, NotConnected {
848       SharkTransaction t = null;
849       try {
850          t = SharkUtilities.createTransaction();
851          reevaluateAssignments(t,pkgId,pDefId);
852          SharkUtilities.commitTransaction(t);
853       } catch (RootException e) {
854          SharkUtilities.rollbackTransaction(t,e);
855          if (e instanceof NotConnected)
856             throw (NotConnected)e;
857          else if (e instanceof BaseException)
858             throw (BaseException)e;
859          else
860             throw new BaseException(e);
861       } finally {
862          SharkUtilities.releaseTransaction(t);
863       }
864    }
865
866    public void reevaluateAssignments (SharkTransaction t,String JavaDoc pkgId,String JavaDoc pDefId) throws BaseException, NotConnected {
867       if (!connected) {
868          throw new NotConnected("The connection is not established...");
869       }
870       SecurityManager JavaDoc sm=SharkEngineManager.getInstance().getSecurityManager();
871       if (sm!=null) {
872          try {
873             sm.check_executionadministration_reevaluateAssignments(t,userId);
874          } catch (Exception JavaDoc ex) {
875             throw new BaseException(ex);
876          }
877       }
878       WfProcessMgrIterator iter=SharkEngineManager.getInstance().
879          getObjectFactory().createProcessMgrIteratorWrapper(t,userId);
880       String JavaDoc query="packageId.equals(\""+pkgId+"\") && processDefinitionId.equals(\""+pDefId+"\")";
881       try {
882          iter.set_query_expression(t,query);
883       } catch (Exception JavaDoc ex) {
884          throw new BaseException(ex);
885       }
886       WfProcessMgr[] mgrs=iter.get_next_n_sequence(t,0);
887       if (mgrs!=null) {
888          for (int i=0; i<mgrs.length; i++) {
889             String JavaDoc mgrName=mgrs[i].name(t);
890             SharkUtilities.reevalAssignments(t,mgrName);
891          }
892       }
893    }
894
895    public void reevaluateAssignments (String JavaDoc pkgId,String JavaDoc pDefId,String JavaDoc aDefId) throws BaseException, NotConnected {
896       SharkTransaction t = null;
897       try {
898          t = SharkUtilities.createTransaction();
899          reevaluateAssignments(t,pkgId,pDefId,aDefId);
900          SharkUtilities.commitTransaction(t);
901       } catch (RootException e) {
902          SharkUtilities.rollbackTransaction(t,e);
903          if (e instanceof NotConnected)
904             throw (NotConnected)e;
905          else if (e instanceof BaseException)
906             throw (BaseException)e;
907          else
908             throw new BaseException(e);
909       } finally {
910          SharkUtilities.releaseTransaction(t);
911       }
912    }
913
914    public void reevaluateAssignments (SharkTransaction t,String JavaDoc pkgId,String JavaDoc pDefId,String JavaDoc aDefId) throws BaseException, NotConnected {
915       if (!connected) {
916          throw new NotConnected("The connection is not established...");
917       }
918       SecurityManager JavaDoc sm=SharkEngineManager.getInstance().getSecurityManager();
919       if (sm!=null) {
920          try {
921             sm.check_executionadministration_reevaluateAssignments(t,userId);
922          } catch (Exception JavaDoc ex) {
923             throw new BaseException(ex);
924          }
925       }
926
927       WfProcessMgrIterator iter=SharkEngineManager.getInstance().
928          getObjectFactory().createProcessMgrIteratorWrapper(t,userId);
929       String JavaDoc query="packageId.equals(\""+pkgId+"\") && processDefinitionId.equals(\""+pDefId+"\")";
930       try {
931          iter.set_query_expression(t,query);
932       } catch (Exception JavaDoc ex) {
933          throw new BaseException(ex);
934       }
935       WfProcessMgr[] mgrs=iter.get_next_n_sequence(t,0);
936       if (mgrs!=null) {
937          for (int i=0; i<mgrs.length; i++) {
938             String JavaDoc mgrName=mgrs[i].name(t);
939
940             List JavaDoc l=SharkUtilities.createProcessMgrsProcessWrappers(t,userId,mgrName);
941             Iterator JavaDoc it=l.iterator();
942             while (it.hasNext()) {
943                WfProcess p=(WfProcess)it.next();
944                String JavaDoc procId=p.key(t);
945                WfActivityIterator actIter=SharkEngineManager
946                   .getInstance()
947                   .getObjectFactory()
948                   .createActivityIteratorWrapper(t,userId,procId);
949                String JavaDoc actQuery="definitionId.equals(\""+aDefId+"\")";
950                try {
951                   actIter.set_query_expression(t,actQuery);
952                } catch (Exception JavaDoc ex) {
953                   throw new BaseException(ex);
954                }
955                WfActivity[] acts=actIter.get_next_n_sequence(t,0);
956                for (int j=0; j<acts.length; j++) {
957                   WfActivity act=acts[j];
958                   WfActivityInternal aint=SharkUtilities.getActivity(t,procId,act.key(t));
959                   aint.reevaluateAssignments(t);
960                }
961             }
962          }
963       }
964    }
965
966    public void deleteClosedProcesses () throws BaseException, NotConnected {
967       SharkTransaction t = null;
968       try {
969          t = SharkUtilities.createTransaction();
970          deleteClosedProcesses(t);
971          SharkUtilities.commitTransaction(t);
972       } catch (RootException e) {
973          SharkUtilities.rollbackTransaction(t,e);
974          if (e instanceof NotConnected)
975             throw (NotConnected)e;
976          else if (e instanceof BaseException)
977             throw (BaseException)e;
978          else
979             throw new BaseException(e);
980       } finally {
981          SharkUtilities.releaseTransaction(t);
982       }
983    }
984
985    public void deleteClosedProcesses (SharkTransaction t) throws BaseException, NotConnected {
986       if (!connected) {
987          throw new NotConnected("The connection is not established...");
988       }
989       SecurityManager JavaDoc sm=SharkEngineManager.getInstance().getSecurityManager();
990       if (sm!=null) {
991          try {
992             sm.check_executionadministration_reevaluateAssignments(t,userId);
993          } catch (Exception JavaDoc ex) {
994             throw new BaseException(ex);
995          }
996       }
997       LockMaster lm=SharkEngineManager.getInstance().getLockMaster();
998       try {
999          PersistentManagerInterface ipm=SharkEngineManager.getInstance().getInstancePersistenceManager();
1000         List JavaDoc procs=ipm.getAllFinishedProcesses(t);
1001         cus.info("ExecutionAdmin -> Deleting "+procs.size()+" closed processes:");
1002         for (Iterator JavaDoc i=procs.iterator(); i.hasNext();) {
1003            ProcessPersistenceInterface po=(ProcessPersistenceInterface)i.next();
1004            if (po.getActivityRequesterId()!=null) {
1005               ActivityPersistenceInterface apo=ipm.restoreActivity(po.getActivityRequesterId(),t);
1006               if (apo!=null && apo.getState().startsWith(SharkConstants.STATEPREFIX_OPEN)) {
1007                  cus.info("... Process " + po.getId()+" can't be deleted yet because it has active activity requester!");
1008                  continue;
1009               }
1010            }
1011            cus.info("... Deleting process "+po.getId());
1012            if (lm!=null) {
1013               lm.lock(t,po.getId());
1014            }
1015            ipm.deleteProcess(po.getId(),true,t);
1016            CacheMgr cm=SharkEngineManager.getInstance().getCacheManager();
1017            if (cm!=null) {
1018               cm.getProcessCache().remove(po.getId());
1019            }
1020         }
1021      } catch (Exception JavaDoc ex) {
1022         throw new BaseException(ex);
1023      }
1024   }
1025
1026   public void deleteClosedProcesses (java.util.Date JavaDoc closedBefore) throws BaseException, NotConnected {
1027      SharkTransaction t = null;
1028      try {
1029         t = SharkUtilities.createTransaction();
1030         deleteClosedProcesses(t,closedBefore);
1031         SharkUtilities.commitTransaction(t);
1032      } catch (RootException e) {
1033         SharkUtilities.rollbackTransaction(t,e);
1034         if (e instanceof NotConnected)
1035            throw (NotConnected)e;
1036         else if (e instanceof BaseException)
1037            throw (BaseException)e;
1038         else
1039            throw new BaseException(e);
1040      } finally {
1041         SharkUtilities.releaseTransaction(t);
1042      }
1043   }
1044
1045   public void deleteClosedProcesses (SharkTransaction t,java.util.Date JavaDoc closedBefore) throws BaseException, NotConnected {
1046      if (!connected) {
1047         throw new NotConnected("The connection is not established...");
1048      }
1049      SecurityManager JavaDoc sm=SharkEngineManager.getInstance().getSecurityManager();
1050      if (sm!=null) {
1051         try {
1052            sm.check_executionadministration_deleteClosedProcesses(t,userId);
1053         } catch (Exception JavaDoc ex) {
1054            throw new BaseException(ex);
1055         }
1056      }
1057      LockMaster lm=SharkEngineManager.getInstance().getLockMaster();
1058      try {
1059         PersistentManagerInterface ipm=SharkEngineManager.getInstance().getInstancePersistenceManager();
1060         List JavaDoc procs=ipm.getAllFinishedProcesses(t,closedBefore);
1061         cus.info("ExecutionAdmin -> Deleting "+procs.size()+" processes closed before "+closedBefore+":");
1062         for (Iterator JavaDoc i=procs.iterator(); i.hasNext();) {
1063            ProcessPersistenceInterface po=(ProcessPersistenceInterface)i.next();
1064            if (po.getActivityRequesterId()!=null) {
1065               ActivityPersistenceInterface apo=ipm.restoreActivity(po.getActivityRequesterId(),t);
1066               if (apo!=null && apo.getState().startsWith(SharkConstants.STATEPREFIX_OPEN)) {
1067                  cus.info("... Process " + po.getId()+" can't be deleted yet because it has active activity requester!");
1068                  continue;
1069               }
1070            }
1071            cus.info("... Deleting process "+po.getId());
1072            if (lm!=null) {
1073               lm.lock(t,po.getId());
1074            }
1075            ipm.deleteProcess(po.getId(),true,t);
1076            CacheMgr cm=SharkEngineManager.getInstance().getCacheManager();
1077            if (cm!=null) {
1078               cm.getProcessCache().remove(po.getId());
1079            }
1080         }
1081      } catch (Exception JavaDoc ex) {
1082         throw new BaseException(ex);
1083      }
1084   }
1085
1086   public void deleteClosedProcesses (String JavaDoc pkgId) throws BaseException, NotConnected {
1087      SharkTransaction t = null;
1088      try {
1089         t = SharkUtilities.createTransaction();
1090         deleteClosedProcesses(t,pkgId);
1091         SharkUtilities.commitTransaction(t);
1092      } catch (RootException e) {
1093         SharkUtilities.rollbackTransaction(t,e);
1094         if (e instanceof NotConnected)
1095            throw (NotConnected)e;
1096         else if (e instanceof BaseException)
1097            throw (BaseException)e;
1098         else
1099            throw new BaseException(e);
1100      } finally {
1101         SharkUtilities.releaseTransaction(t);
1102      }
1103   }
1104
1105   public void deleteClosedProcesses (SharkTransaction t,String JavaDoc pkgId) throws BaseException, NotConnected {
1106      if (!connected) {
1107         throw new NotConnected("The connection is not established...");
1108      }
1109      SecurityManager JavaDoc sm=SharkEngineManager.getInstance().getSecurityManager();
1110      if (sm!=null) {
1111         try {
1112            sm.check_executionadministration_deleteClosedProcesses(t,userId);
1113         } catch (Exception JavaDoc ex) {
1114            throw new BaseException(ex);
1115         }
1116      }
1117      LockMaster lm=SharkEngineManager.getInstance().getLockMaster();
1118      try {
1119         PersistentManagerInterface ipm=SharkEngineManager.getInstance().getInstancePersistenceManager();
1120         List JavaDoc procs=ipm.getAllFinishedProcesses(t,pkgId);
1121         cus.info("ExecutionAdmin -> Deleting "+procs.size()+" closed processes for package Id="+pkgId+":");
1122         for (Iterator JavaDoc i=procs.iterator(); i.hasNext();) {
1123            ProcessPersistenceInterface po=(ProcessPersistenceInterface)i.next();
1124            if (po.getActivityRequesterId()!=null) {
1125               ActivityPersistenceInterface apo=ipm.restoreActivity(po.getActivityRequesterId(),t);
1126               if (apo!=null && apo.getState().startsWith(SharkConstants.STATEPREFIX_OPEN)) {
1127                  cus.info("... Process " + po.getId()+" can't be deleted yet because it has active activity requester!");
1128                  continue;
1129               }
1130            }
1131            cus.info("... Deleting process "+po.getId());
1132            if (lm!=null) {
1133               lm.lock(t,po.getId());
1134            }
1135            ipm.deleteProcess(po.getId(),true,t);
1136            CacheMgr cm=SharkEngineManager.getInstance().getCacheManager();
1137            if (cm!=null) {
1138               cm.getProcessCache().remove(po.getId());
1139            }
1140         }
1141      } catch (Exception JavaDoc ex) {
1142         throw new BaseException(ex);
1143      }
1144   }
1145
1146   public void deleteClosedProcessesForMgr (String JavaDoc mgrName) throws BaseException, NotConnected {
1147      SharkTransaction t=null;
1148      try {
1149         t = SharkUtilities.createTransaction();
1150         deleteClosedProcessesForMgr(t,mgrName);
1151         SharkUtilities.commitTransaction(t);
1152      } catch (RootException e) {
1153         SharkUtilities.rollbackTransaction(t,e);
1154         if (e instanceof NotConnected)
1155            throw (NotConnected)e;
1156         else if (e instanceof BaseException)
1157            throw (BaseException)e;
1158         else
1159            throw new BaseException(e);
1160      } finally {
1161         SharkUtilities.releaseTransaction(t);
1162      }
1163   }
1164
1165   public void deleteClosedProcessesForMgr (SharkTransaction t,String JavaDoc mgrName) throws BaseException, NotConnected {
1166      if (!connected) {
1167         throw new NotConnected("The connection is not established...");
1168      }
1169      SecurityManager JavaDoc sm=SharkEngineManager.getInstance().getSecurityManager();
1170      if (sm!=null) {
1171         try {
1172            sm.check_executionadministration_deleteClosedProcesses(t,userId);
1173         } catch (Exception JavaDoc ex) {
1174            throw new BaseException(ex);
1175         }
1176      }
1177      LockMaster lm=SharkEngineManager.getInstance().getLockMaster();
1178      try {
1179         String JavaDoc pkgId=SharkUtilities.getProcessMgrPkgId(mgrName);
1180         String JavaDoc pDefId=SharkUtilities.getProcessMgrProcDefId(mgrName);
1181         String JavaDoc pkgVer=SharkUtilities.getProcessMgrVersion(mgrName);
1182
1183
1184         PersistentManagerInterface ipm=SharkEngineManager.getInstance().getInstancePersistenceManager();
1185         List JavaDoc procs=ipm.getAllFinishedProcesses(t,pkgId,pDefId,pkgVer);
1186         cus.info("ExecutionAdmin -> Deleting "+procs.size()+" closed processes for package Id="+pkgId+", version="+pkgVer+", pDefId= :"+pDefId);
1187         for (Iterator JavaDoc i=procs.iterator(); i.hasNext();) {
1188            ProcessPersistenceInterface po=(ProcessPersistenceInterface)i.next();
1189            if (po.getActivityRequesterId()!=null) {
1190               ActivityPersistenceInterface apo=ipm.restoreActivity(po.getActivityRequesterId(),t);
1191               if (apo!=null && apo.getState().startsWith(SharkConstants.STATEPREFIX_OPEN)) {
1192                  cus.info("... Process " + po.getId()+" can't be deleted yet because it has active activity requester!");
1193                  continue;
1194               }
1195            }
1196            cus.info("... Deleting process "+po.getId());
1197            if (lm!=null) {
1198               lm.lock(t,po.getId());
1199            }
1200            ipm.deleteProcess(po.getId(),true,t);
1201            CacheMgr cm=SharkEngineManager.getInstance().getCacheManager();
1202            if (cm!=null) {
1203               cm.getProcessCache().remove(po.getId());
1204            }
1205         }
1206      } catch (Exception JavaDoc ex) {
1207         throw new BaseException(ex);
1208      }
1209   }
1210
1211   public void deleteClosedProcessesWithVersion (String JavaDoc pkgId,String JavaDoc pkgVer) throws BaseException, NotConnected {
1212      SharkTransaction t=null;
1213      try {
1214         t = SharkUtilities.createTransaction();
1215         deleteClosedProcessesWithVersion(t,pkgId,pkgVer);
1216         SharkUtilities.commitTransaction(t);
1217      } catch (RootException e) {
1218         SharkUtilities.rollbackTransaction(t,e);
1219         if (e instanceof NotConnected)
1220            throw (NotConnected)e;
1221         else if (e instanceof BaseException)
1222            throw (BaseException)e;
1223         else
1224            throw new BaseException(e);
1225      } finally {
1226         SharkUtilities.releaseTransaction(t);
1227      }
1228   }
1229
1230   public void deleteClosedProcessesWithVersion (SharkTransaction t,String JavaDoc pkgId,String JavaDoc pkgVer) throws BaseException, NotConnected {
1231      if (!connected) {
1232         throw new NotConnected("The connection is not established...");
1233      }
1234      SecurityManager JavaDoc sm=SharkEngineManager.getInstance().getSecurityManager();
1235      if (sm!=null) {
1236         try {
1237            sm.check_executionadministration_deleteClosedProcesses(t,userId);
1238         } catch (Exception JavaDoc ex) {
1239            throw new BaseException(ex);
1240         }
1241      }
1242      LockMaster lm=SharkEngineManager.getInstance().getLockMaster();
1243      try {
1244         PersistentManagerInterface ipm=SharkEngineManager.getInstance().getInstancePersistenceManager();
1245         List JavaDoc procs=ipm.getAllFinishedProcesses(t,pkgId,null,pkgVer);
1246         cus.info("ExecutionAdmin -> Deleting "+procs.size()+" closed processes for package Id="+pkgId+", version="+pkgVer+" :");
1247         for (Iterator JavaDoc i=procs.iterator(); i.hasNext();) {
1248            ProcessPersistenceInterface po=(ProcessPersistenceInterface)i.next();
1249            if (po.getActivityRequesterId()!=null) {
1250               ActivityPersistenceInterface apo=ipm.restoreActivity(po.getActivityRequesterId(),t);
1251               if (apo!=null && apo.getState().startsWith(SharkConstants.STATEPREFIX_OPEN)) {
1252                  cus.info("... Process " + po.getId()+" can't be deleted yet because it has active activity requester!");
1253                  continue;
1254               }
1255            }
1256            cus.info("... Deleting process "+po.getId());
1257            if (lm!=null) {
1258               lm.lock(t,po.getId());
1259            }
1260            ipm.deleteProcess(po.getId(),true,t);
1261            CacheMgr cm=SharkEngineManager.getInstance().getCacheManager();
1262            if (cm!=null) {
1263               cm.getProcessCache().remove(po.getId());
1264            }
1265         }
1266      } catch (Exception JavaDoc ex) {
1267         throw new BaseException(ex);
1268      }
1269   }
1270
1271   public void deleteClosedProcesses (String JavaDoc pkgId,String JavaDoc pDefId) throws BaseException, NotConnected {
1272      SharkTransaction t = null;
1273      try {
1274         t = SharkUtilities.createTransaction();
1275         deleteClosedProcesses(t,pkgId,pDefId);
1276         SharkUtilities.commitTransaction(t);
1277      } catch (RootException e) {
1278         SharkUtilities.rollbackTransaction(t,e);
1279         if (e instanceof NotConnected)
1280            throw (NotConnected)e;
1281         else if (e instanceof BaseException)
1282            throw (BaseException)e;
1283         else
1284            throw new BaseException(e);
1285      } finally {
1286         SharkUtilities.releaseTransaction(t);
1287      }
1288   }
1289
1290   public void deleteClosedProcesses (SharkTransaction t,String JavaDoc pkgId,String JavaDoc pDefId) throws BaseException, NotConnected {
1291      if (!connected) {
1292         throw new NotConnected("The connection is not established...");
1293      }
1294      SecurityManager JavaDoc sm=SharkEngineManager.getInstance().getSecurityManager();
1295      if (sm!=null) {
1296         try {
1297            sm.check_executionadministration_deleteClosedProcesses(t,userId);
1298         } catch (Exception JavaDoc ex) {
1299            throw new BaseException(ex);
1300         }
1301      }
1302      LockMaster lm=SharkEngineManager.getInstance().getLockMaster();
1303      try {
1304         PersistentManagerInterface ipm=SharkEngineManager.getInstance().getInstancePersistenceManager();
1305         List JavaDoc procs=ipm.getAllFinishedProcesses(t,pkgId,pDefId);
1306         cus.info("ExecutionAdmin -> Deleting "+procs.size()+" closed processes for packageId="+pkgId+"and processDefinitionId="+pDefId+":");
1307         for (Iterator JavaDoc i=procs.iterator(); i.hasNext();) {
1308            ProcessPersistenceInterface po=(ProcessPersistenceInterface)i.next();
1309            if (po.getActivityRequesterId()!=null) {
1310               ActivityPersistenceInterface apo=ipm.restoreActivity(po.getActivityRequesterId(),t);
1311               if (apo!=null && apo.getState().startsWith(SharkConstants.STATEPREFIX_OPEN)) {
1312                  cus.info("... Process " + po.getId()+" can't be deleted yet because it has active activity requester!");
1313                  continue;
1314               }
1315            }
1316            cus.info("... Deleting process "+po.getId());
1317            if (lm!=null) {
1318               lm.lock(t,po.getId());
1319            }
1320            ipm.deleteProcess(po.getId(),true,t);
1321            CacheMgr cm=SharkEngineManager.getInstance().getCacheManager();
1322            if (cm!=null) {
1323               cm.getProcessCache().remove(po.getId());
1324            }
1325         }
1326      } catch (Exception JavaDoc ex) {
1327         throw new BaseException(ex);
1328      }
1329   }
1330
1331   public void deleteClosedProcess (String JavaDoc procId) throws BaseException, NotConnected {
1332      SharkTransaction t = null;
1333      try {
1334         t = SharkUtilities.createTransaction();
1335         deleteClosedProcess(t, procId);
1336         SharkUtilities.commitTransaction(t);
1337      } catch (RootException e) {
1338         SharkUtilities.rollbackTransaction(t,e);
1339         if (e instanceof NotConnected)
1340            throw (NotConnected)e;
1341         else if (e instanceof BaseException)
1342            throw (BaseException)e;
1343         else
1344            throw new BaseException(e);
1345      } finally {
1346         SharkUtilities.releaseTransaction(t);
1347      }
1348   }
1349
1350   public void deleteClosedProcess (SharkTransaction t,String JavaDoc procId) throws BaseException, NotConnected {
1351      if (!connected) {
1352         throw new NotConnected("The connection is not established...");
1353      }
1354      SecurityManager JavaDoc sm=SharkEngineManager.getInstance().getSecurityManager();
1355      if (sm!=null) {
1356         try {
1357            sm.check_executionadministration_deleteClosedProcesses(t,userId);
1358         } catch (Exception JavaDoc ex) {
1359            throw new BaseException(ex);
1360         }
1361      }
1362      LockMaster lm=SharkEngineManager.getInstance().getLockMaster();
1363      try {
1364
1365         PersistentManagerInterface ipm=SharkEngineManager.getInstance().getInstancePersistenceManager();
1366         ProcessPersistenceInterface po=ipm.restoreProcess(procId,t);
1367         if (po.getState().startsWith(SharkConstants.STATEPREFIX_OPEN)) {
1368            throw new BaseException("Can't delete processes which are not closed");
1369         }
1370         if (po.getActivityRequesterId()!=null) {
1371            ActivityPersistenceInterface apo=ipm.restoreActivity(po.getActivityRequesterId(),t);
1372            if (apo!=null && apo.getState().startsWith(SharkConstants.STATEPREFIX_OPEN)) {
1373               cus.info("... Process " + po.getId()+" can't be deleted yet because it has active activity requester!");
1374               return;
1375            }
1376         }
1377         cus.info("... Deleting process "+po.getId());
1378         if (lm!=null) {
1379            lm.lock(t,po.getId());
1380         }
1381         ipm.deleteProcess(po.getId(),true,t);
1382         CacheMgr cm=SharkEngineManager.getInstance().getCacheManager();
1383         if (cm!=null) {
1384            cm.getProcessCache().remove(po.getId());
1385         }
1386      } catch (Exception JavaDoc ex) {
1387         throw new BaseException("Problems with deleting process for Id "+procId,ex);
1388      }
1389   }
1390
1391   public String JavaDoc[] deleteClosedProcessesForMgr(String JavaDoc mgrName,
1392                                               int procPerTrans,
1393                                               int failures2ignore) throws BaseException,
1394      NotConnected {
1395      if (!connected) { throw new NotConnected("The connection is not established..."); }
1396      SecurityManager JavaDoc sm=SharkEngineManager.getInstance().getSecurityManager();
1397      if (sm!=null) {
1398         SharkTransaction t=null;
1399         try {
1400            t = SharkUtilities.createTransaction();
1401            sm.check_executionadministration_deleteClosedProcesses(t,userId);
1402            SharkUtilities.commitTransaction(t);
1403         } catch (RootException e) {
1404            SharkUtilities.rollbackTransaction(t,e);
1405            if (e instanceof NotConnected)
1406               throw (NotConnected)e;
1407            else if (e instanceof BaseException)
1408               throw (BaseException)e;
1409            else
1410               throw new BaseException(e);
1411         } finally {
1412            SharkUtilities.releaseTransaction(t);
1413         }
1414      }
1415      List JavaDoc instancesFailed2check = new ArrayList JavaDoc();
1416      Iterator JavaDoc iterProcesses = null;
1417      List JavaDoc currentBatch = null;
1418
1419      List JavaDoc procs=null;
1420      SharkTransaction t = null;
1421      PersistentManagerInterface ipm=SharkEngineManager.getInstance().getInstancePersistenceManager();
1422      try {
1423         t = SharkUtilities.createTransaction();
1424         procs = ipm.getAllFinishedProcesses(t);
1425         cus.info("ExecutionAdmin -> Deleting "
1426                     + procs.size() + " closed processes:");
1427      } catch (RootException e) {
1428         SharkUtilities.rollbackTransaction(t,e);
1429         throw new BaseException(e);
1430      } finally {
1431         SharkUtilities.releaseTransaction(t);
1432      }
1433      LockMaster lm=SharkEngineManager.getInstance().getLockMaster();
1434      do {
1435         t = null;
1436         currentBatch = new ArrayList JavaDoc();
1437         try {
1438            t = SharkUtilities.createTransaction();
1439            String JavaDoc pkgId = SharkUtilities.getProcessMgrPkgId(mgrName);
1440            String JavaDoc pDefId = SharkUtilities.getProcessMgrProcDefId(mgrName);
1441            String JavaDoc pkgVer = SharkUtilities.getProcessMgrVersion(mgrName);
1442
1443            iterProcesses = procs.iterator();
1444            for (int n = 0; n < procPerTrans; ++n) {
1445               if (!iterProcesses.hasNext()) {
1446                  break;
1447               }
1448               ProcessPersistenceInterface po = (ProcessPersistenceInterface) iterProcesses.next();
1449               iterProcesses.remove();
1450               if (po.getActivityRequesterId()!=null) {
1451                  ActivityPersistenceInterface apo=ipm.restoreActivity(po.getActivityRequesterId(),t);
1452                  if (apo!=null && apo.getState().startsWith(SharkConstants.STATEPREFIX_OPEN)) {
1453                     cus.info("... Process " + po.getId()+" can't be deleted yet because it has active activity requester!");
1454                     continue;
1455                  }
1456               }
1457               cus.info("... Deleting process "+po.getId());
1458               if (lm!=null) {
1459                  lm.lock(t,po.getId());
1460               }
1461               ipm.deleteProcess(po.getId(),true,t);
1462               CacheMgr cm=SharkEngineManager.getInstance().getCacheManager();
1463               if (cm!=null) {
1464                  cm.getProcessCache().remove(po.getId());
1465               }
1466               currentBatch.add(po.getId());
1467            }
1468            SharkUtilities.commitTransaction(t);
1469         } catch (RootException _) {
1470            SharkUtilities.rollbackTransaction(t,_);
1471            instancesFailed2check.addAll(currentBatch);
1472            // may log something
1473
} finally {
1474            SharkUtilities.releaseTransaction(t);
1475         }
1476         System.err.println("\ttransaction finished: batch size:"+currentBatch.size());
1477      } while (instancesFailed2check.size() <= failures2ignore
1478               && iterProcesses.hasNext());
1479      String JavaDoc[] ret = new String JavaDoc[instancesFailed2check.size()];
1480      instancesFailed2check.toArray(ret);
1481      System.err.println(" deleting finished: failed:"+ret.length);
1482      return ret;
1483   }
1484
1485   public String JavaDoc[] deleteClosedProcesses (
1486      int procPerTrans,
1487      int failures2ignore) throws BaseException, NotConnected {
1488      if (!connected) { throw new NotConnected("The connection is not established..."); }
1489      SecurityManager JavaDoc sm=SharkEngineManager.getInstance().getSecurityManager();
1490      if (sm!=null) {
1491         SharkTransaction t=null;
1492         try {
1493            t = SharkUtilities.createTransaction();
1494            sm.check_executionadministration_deleteClosedProcesses(t,userId);
1495            SharkUtilities.commitTransaction(t);
1496         } catch (RootException e) {
1497            SharkUtilities.rollbackTransaction(t,e);
1498            if (e instanceof NotConnected)
1499               throw (NotConnected)e;
1500            else if (e instanceof BaseException)
1501               throw (BaseException)e;
1502            else
1503               throw new BaseException(e);
1504         } finally {
1505            SharkUtilities.releaseTransaction(t);
1506         }
1507      }
1508      List JavaDoc instancesFailed2check = new ArrayList JavaDoc();
1509      Iterator JavaDoc iterProcesses = null;
1510      List JavaDoc currentBatch = null;
1511
1512      List JavaDoc procs=null;
1513      SharkTransaction t = null;
1514      PersistentManagerInterface ipm=SharkEngineManager.getInstance().getInstancePersistenceManager();
1515//long tg0=System.currentTimeMillis();
1516
try {
1517         t = SharkUtilities.createTransaction();
1518         procs = ipm.getAllFinishedProcesses(t);
1519         cus.info("ExecutionAdmin -> Deleting "
1520                     + procs.size() + " closed processes:");
1521      } catch (RootException e) {
1522         SharkUtilities.rollbackTransaction(t,e);
1523         throw new BaseException(e);
1524      } finally {
1525         SharkUtilities.releaseTransaction(t);
1526      }
1527//System.out.println("GAFPST="+(System.currentTimeMillis()-tg0));
1528
LockMaster lm=SharkEngineManager.getInstance().getLockMaster();
1529// long t0, t1, t2, t3, t4, t5, t6, tc=0;
1530
// long td1=0, td2=0, td3=0;
1531

1532      do {
1533// t0=System.currentTimeMillis();
1534
t=null;
1535         currentBatch = new ArrayList JavaDoc();
1536         try {
1537            t = SharkUtilities.createTransaction();
1538
1539            iterProcesses = procs.iterator();
1540            for (int n = 0; n < procPerTrans; ++n) {
1541// t1=System.currentTimeMillis();
1542
if (!iterProcesses.hasNext()) {
1543                  break;
1544               }
1545               ProcessPersistenceInterface po = (ProcessPersistenceInterface) iterProcesses.next();
1546               iterProcesses.remove();
1547
1548               /*if (po.getActivityRequesterId()!=null) {
1549                  ActivityPersistenceInterface apo=ipm.restoreActivity(po.getActivityRequesterId(),t);
1550                  if (apo!=null && apo.getState().startsWith(SharkConstants.STATEPREFIX_OPEN)) {
1551                     cus.info("... Process " + po.getId()+" can't be deleted yet because it has active activity requester!");
1552                     continue;
1553                  }
1554               }*/

1555               cus.info("... Deleting process "+po.getId());
1556               if (lm!=null) {
1557                  lm.lock(t,po.getId());
1558               }
1559// t2=System.currentTimeMillis();
1560
// td1+=(t2-t1);
1561
ipm.deleteProcess(po.getId(),true,t);
1562// t3=System.currentTimeMillis();
1563
// td2+=(t3-t2);
1564
CacheMgr cm=SharkEngineManager.getInstance().getCacheManager();
1565               if (cm!=null) {
1566                  cm.getProcessCache().remove(po.getId());
1567               }
1568               currentBatch.add(po.getId());
1569// t4=System.currentTimeMillis();
1570
// td3+=(t4-t3);
1571

1572            }
1573// t5=System.currentTimeMillis();
1574
SharkUtilities.commitTransaction(t);
1575// t6=System.currentTimeMillis();
1576
// tc+=(t6-t5);
1577
} catch (RootException _) {
1578            SharkUtilities.rollbackTransaction(t,_);
1579            instancesFailed2check.addAll(currentBatch);
1580// _.printStackTrace();
1581
// may log something
1582
} finally {
1583            SharkUtilities.releaseTransaction(t);
1584         }
1585// System.out.println("CBT="+(System.currentTimeMillis()-t0)+", TD1="+td1+", TD2="+td2+", TD3="+td3+", TC="+tc);
1586
System.err.println("\ttransaction finished: batch size:"+currentBatch.size());
1587      } while (instancesFailed2check.size() <= failures2ignore
1588               && iterProcesses.hasNext());
1589      String JavaDoc[] ret = new String JavaDoc[instancesFailed2check.size()];
1590      instancesFailed2check.toArray(ret);
1591      System.err.println(" deleting finished: failed:"+ret.length);
1592//System.out.println("TD1="+td1+", TD2="+td2+", TD3="+td3);
1593
return ret;
1594   }
1595
1596   public Map JavaDoc getProcessMgrInputSignature(String JavaDoc name) throws BaseException, NotConnected {
1597      Map JavaDoc ret = null;
1598      SharkTransaction t = null;
1599      try {
1600         t = SharkUtilities.createTransaction();
1601         ret = getProcessMgrInputSignature(t, name);
1602         //SharkUtilities.commitTransaction(t);
1603
} catch (RootException e) {
1604         //SharkUtilities.rollbackTransaction(t);
1605
SharkUtilities.emptyCaches(t);
1606         if (e instanceof NotConnected)
1607            throw (NotConnected)e;
1608         else if (e instanceof BaseException)
1609            throw (BaseException)e;
1610         else
1611            throw new BaseException(e);
1612      } finally {
1613         SharkUtilities.releaseTransaction(t);
1614      }
1615      return ret;
1616   }
1617
1618   public Map JavaDoc getProcessMgrInputSignature(SharkTransaction t, String JavaDoc name) throws BaseException, NotConnected {
1619      return getProcessMgrInputSignature(t,
1620                                         SharkUtilities.getProcessMgrPkgId(name),
1621                                         SharkUtilities.getProcessMgrVersion(name),
1622                                         SharkUtilities.getProcessMgrProcDefId(name));
1623   }
1624
1625   public Map JavaDoc getProcessMgrInputSignature(String JavaDoc pkgId, String JavaDoc pDefId) throws BaseException, NotConnected {
1626      Map JavaDoc ret = null;
1627      SharkTransaction t = null;
1628      try {
1629         t = SharkUtilities.createTransaction();
1630         ret = getProcessMgrInputSignature(t, pkgId, pDefId);
1631         //SharkUtilities.commitTransaction(t);
1632
} catch (RootException e) {
1633         //SharkUtilities.rollbackTransaction(t);
1634
SharkUtilities.emptyCaches(t);
1635         if (e instanceof NotConnected)
1636            throw (NotConnected)e;
1637         else if (e instanceof BaseException)
1638            throw (BaseException)e;
1639         else
1640            throw new BaseException(e);
1641      } finally {
1642         SharkUtilities.releaseTransaction(t);
1643      }
1644      return ret;
1645   }
1646
1647   public Map JavaDoc getProcessMgrInputSignature(SharkTransaction t, String JavaDoc pkgId, String JavaDoc pDefId) throws BaseException, NotConnected {
1648      return getProcessMgrInputSignature(t,
1649                                         pkgId,
1650                                         SharkUtilities.getCurrentPkgVersion(pkgId,
1651                                                                             false),
1652                                         pDefId);
1653
1654   }
1655
1656   public Map JavaDoc getProcessMgrInputSignature(String JavaDoc pkgId, String JavaDoc pkgVer, String JavaDoc pDefId) throws BaseException, NotConnected {
1657      Map JavaDoc ret = null;
1658      SharkTransaction t = null;
1659      try {
1660         t = SharkUtilities.createTransaction();
1661         ret = getProcessMgrInputSignature(t, pkgId, pkgVer, pDefId);
1662         //SharkUtilities.commitTransaction(t);
1663
} catch (RootException e) {
1664         //SharkUtilities.rollbackTransaction(t);
1665
SharkUtilities.emptyCaches(t);
1666         if (e instanceof NotConnected)
1667            throw (NotConnected)e;
1668         else if (e instanceof BaseException)
1669            throw (BaseException)e;
1670         else
1671            throw new BaseException(e);
1672      } finally {
1673         SharkUtilities.releaseTransaction(t);
1674      }
1675      return ret;
1676   }
1677
1678   public Map JavaDoc getProcessMgrInputSignature(SharkTransaction t,
1679                                          String JavaDoc pkgId,
1680                                          String JavaDoc pkgVer,
1681                                          String JavaDoc pDefId) throws BaseException,
1682      NotConnected {
1683      if (!connected) {
1684         throw new NotConnected("The connection is not established...");
1685      }
1686      try {
1687         String JavaDoc mgrName=SharkUtilities.createProcessMgrKey(pkgId,pkgVer,pDefId);
1688         SecurityManager JavaDoc sm=SharkEngineManager.getInstance().getSecurityManager();
1689         if (sm!=null) {
1690            sm.check_executionadministration_getProcessMgr(t,mgrName,userId);
1691         }
1692         WfProcessMgrInternal a = SharkUtilities.getProcessMgr(t, mgrName);
1693         if (null != a) {
1694            return a.input_signature(t);
1695         }
1696         return null;
1697      } catch (Exception JavaDoc ex) {
1698         throw new BaseException(ex);
1699      }
1700   }
1701
1702   public Object JavaDoc getProcessContext(String JavaDoc procId, String JavaDoc variableName) throws BaseException, NotConnected {
1703      Object JavaDoc ret = null;
1704      SharkTransaction t = null;
1705      try {
1706         t = SharkUtilities.createTransaction();
1707         ret = getProcessContext(t, procId, variableName);
1708         //SharkUtilities.commitTransaction(t);
1709
} catch (RootException e) {
1710         //SharkUtilities.rollbackTransaction(t);
1711
SharkUtilities.emptyCaches(t);
1712         if (e instanceof NotConnected)
1713            throw (NotConnected)e;
1714         else if (e instanceof BaseException)
1715            throw (BaseException)e;
1716         else
1717            throw new BaseException(e);
1718      } finally {
1719         SharkUtilities.releaseTransaction(t);
1720      }
1721      return ret;
1722   }
1723
1724   public Object JavaDoc getProcessContext(SharkTransaction t,
1725                                   String JavaDoc procId,
1726                                   String JavaDoc variableName) throws BaseException,
1727      NotConnected {
1728      if (!connected) {
1729         throw new NotConnected("The connection is not established...");
1730      }
1731      try {
1732         // SecurityManager
1733
// sm=SharkEngineManager.getInstance().getSecurityManager();
1734
// if (sm!=null) {
1735
// sm.check_executionadministration_getProcessMgr(t,mgrName,userId);
1736
// }
1737

1738         PersistentManagerInterface ipm = SharkEngineManager.getInstance()
1739            .getInstancePersistenceManager();
1740         ProcessVariablePersistenceInterface a = ipm.createProcessVariable();
1741         a.setDefinitionId(variableName);
1742         a.setProcessId(procId);
1743         if (ipm.restore(a, t)) {
1744            return a.getValue();
1745         }
1746      } catch (PersistenceException ex) {
1747         throw new BaseException(ex);
1748      }
1749      throw new BaseException("variable not found");
1750   }
1751
1752   public Map JavaDoc getProcessContext(String JavaDoc procId, String JavaDoc[] variableNames) throws BaseException, NotConnected {
1753      Map JavaDoc ret = null;
1754      SharkTransaction t = null;
1755      try {
1756         t = SharkUtilities.createTransaction();
1757         ret = getProcessContext(t, procId, variableNames);
1758         //SharkUtilities.commitTransaction(t);
1759
} catch (RootException e) {
1760         //SharkUtilities.rollbackTransaction(t);
1761
SharkUtilities.emptyCaches(t);
1762         if (e instanceof NotConnected)
1763            throw (NotConnected)e;
1764         else if (e instanceof BaseException)
1765            throw (BaseException)e;
1766         else
1767            throw new BaseException(e);
1768      } finally {
1769         SharkUtilities.releaseTransaction(t);
1770      }
1771      return ret;
1772   }
1773
1774   public Map JavaDoc getProcessContext(SharkTransaction t, String JavaDoc procId, String JavaDoc[] variableNames) throws BaseException, NotConnected {
1775      if (!connected) {
1776         throw new NotConnected("The connection is not established...");
1777      }
1778      Map JavaDoc ret = new HashMap JavaDoc();
1779      // SecurityManager
1780
// sm=SharkEngineManager.getInstance().getSecurityManager();
1781
// if (sm!=null) {
1782
// sm.check_executionadministration_getProcessMgr(t,mgrName,userId);
1783
// }
1784

1785      for (int i = 0; i < variableNames.length; i++) {
1786         ret.put(variableNames[i],getProcessContext(t,procId,variableNames[i]));
1787      }
1788      return ret;
1789   }
1790
1791   public Object JavaDoc getActivityContext(String JavaDoc procId, String JavaDoc actId, String JavaDoc variableName) throws BaseException, NotConnected {
1792      Object JavaDoc ret = null;
1793      SharkTransaction t = null;
1794      try {
1795         t = SharkUtilities.createTransaction();
1796         ret = getActivityContext(t, procId, actId, variableName);
1797         //SharkUtilities.commitTransaction(t);
1798
} catch (RootException e) {
1799         //SharkUtilities.rollbackTransaction(t);
1800
SharkUtilities.emptyCaches(t);
1801         if (e instanceof NotConnected)
1802            throw (NotConnected)e;
1803         else if (e instanceof BaseException)
1804            throw (BaseException)e;
1805         else
1806            throw new BaseException(e);
1807      } finally {
1808         SharkUtilities.releaseTransaction(t);
1809      }
1810      return ret;
1811   }
1812
1813   public Object JavaDoc getActivityContext(SharkTransaction t, String JavaDoc procId, String JavaDoc actId, String JavaDoc variableName) throws BaseException, NotConnected {
1814      if (!connected) {
1815         throw new NotConnected("The connection is not established...");
1816      }
1817      try {
1818         // SecurityManager
1819
// sm=SharkEngineManager.getInstance().getSecurityManager();
1820
// if (sm!=null) {
1821
// sm.check_executionadministration_getProcessMgr(t,mgrName,userId);
1822
// }
1823

1824         PersistentManagerInterface ipm = SharkEngineManager.getInstance()
1825            .getInstancePersistenceManager();
1826         ActivityVariablePersistenceInterface a = ipm.createActivityVariable();
1827         a.setDefinitionId(variableName);
1828         a.setActivityId(actId);
1829         if (ipm.restore(a, t)) {
1830            return a.getValue();
1831         }
1832      } catch (PersistenceException ex) {
1833         throw new BaseException(ex);
1834      }
1835      throw new BaseException("variable not found");
1836   }
1837
1838   public Map JavaDoc getActivityContext(String JavaDoc procId,
1839                                 String JavaDoc actId,
1840                                 String JavaDoc[] variableNames) throws BaseException,
1841      NotConnected {
1842      Map JavaDoc ret = null;
1843      SharkTransaction t = null;
1844      try {
1845         t = SharkUtilities.createTransaction();
1846         ret = getActivityContext(t, procId, actId, variableNames);
1847         //SharkUtilities.commitTransaction(t);
1848
} catch (RootException e) {
1849         //SharkUtilities.rollbackTransaction(t);
1850
SharkUtilities.emptyCaches(t);
1851         if (e instanceof NotConnected)
1852            throw (NotConnected) e;
1853         else if (e instanceof BaseException)
1854            throw (BaseException) e;
1855         else
1856            throw new BaseException(e);
1857      } finally {
1858         SharkUtilities.releaseTransaction(t);
1859      }
1860      return ret;
1861   }
1862
1863   public Map JavaDoc getActivityContext(SharkTransaction t, String JavaDoc procId, String JavaDoc actId, String JavaDoc[] variableNames) throws BaseException, NotConnected {
1864      if (!connected) {
1865         throw new NotConnected("The connection is not established...");
1866      }
1867      Map JavaDoc ret = new HashMap JavaDoc();
1868      // SecurityManager
1869
// sm=SharkEngineManager.getInstance().getSecurityManager();
1870
// if (sm!=null) {
1871
// sm.check_executionadministration_getProcessMgr(t,mgrName,userId);
1872
// }
1873

1874      for (int i = 0; i < variableNames.length; i++) {
1875         ret.put(variableNames[i],getActivityContext(t,procId, actId,variableNames[i]));
1876      }
1877      return ret;
1878   }
1879
1880   public WfAssignmentIterator get_iterator_assignment() throws NotConnected, BaseException {
1881      WfAssignmentIterator ret = null;
1882      SharkTransaction t = null;
1883      try {
1884         t = SharkUtilities.createTransaction();
1885         ret = get_iterator_assignment(t);
1886         //SharkUtilities.commitTransaction(t);
1887
} catch (RootException e) {
1888         //SharkUtilities.rollbackTransaction(t);
1889
SharkUtilities.emptyCaches(t);
1890         if (e instanceof NotConnected)
1891            throw (NotConnected) e;
1892         else if (e instanceof BaseException)
1893            throw (BaseException) e;
1894         else
1895            throw new BaseException(e);
1896      } finally {
1897         SharkUtilities.releaseTransaction(t);
1898      }
1899      return ret;
1900   }
1901
1902   public WfAssignmentIterator get_iterator_assignment (SharkTransaction t) throws NotConnected, BaseException {
1903      return SharkEngineManager.getInstance()
1904         .getObjectFactory()
1905         .createAssignmentIteratorWrapper(t, userId, null);
1906   }
1907
1908   public WfProcessIterator get_iterator_process() throws NotConnected, BaseException {
1909      WfProcessIterator ret = null;
1910      SharkTransaction t = null;
1911      try {
1912         t = SharkUtilities.createTransaction();
1913         ret = get_iterator_process(t);
1914         //SharkUtilities.commitTransaction(t);
1915
} catch (RootException e) {
1916         //SharkUtilities.rollbackTransaction(t);
1917
SharkUtilities.emptyCaches(t);
1918         if (e instanceof NotConnected)
1919            throw (NotConnected) e;
1920         else if (e instanceof BaseException)
1921            throw (BaseException) e;
1922         else
1923            throw new BaseException(e);
1924      } finally {
1925         SharkUtilities.releaseTransaction(t);
1926      }
1927      return ret;
1928   }
1929
1930   public WfProcessIterator get_iterator_process (SharkTransaction t) throws NotConnected, BaseException {
1931      return SharkEngineManager.getInstance()
1932         .getObjectFactory()
1933         .createProcessIteratorWrapper(t, userId, null, false);
1934   }
1935
1936   public WfActivityIterator get_iterator_activity() throws NotConnected, BaseException {
1937      WfActivityIterator ret = null;
1938      SharkTransaction t = null;
1939      try {
1940         t = SharkUtilities.createTransaction();
1941         ret = get_iterator_activity(t);
1942         //SharkUtilities.commitTransaction(t);
1943
} catch (RootException e) {
1944         //SharkUtilities.rollbackTransaction(t);
1945
SharkUtilities.emptyCaches(t);
1946         if (e instanceof NotConnected)
1947            throw (NotConnected) e;
1948         else if (e instanceof BaseException)
1949            throw (BaseException) e;
1950         else
1951            throw new BaseException(e);
1952      } finally {
1953         SharkUtilities.releaseTransaction(t);
1954      }
1955      return ret;
1956   }
1957
1958   public WfActivityIterator get_iterator_activity (SharkTransaction t) throws NotConnected, BaseException {
1959      return SharkEngineManager.getInstance()
1960         .getObjectFactory()
1961         .createActivityIteratorWrapper(t, userId, null);
1962   }
1963
1964   // Prevents memory leak if client forgets to disconnect
1965
public void finalize() throws Throwable JavaDoc {
1966      if (connected) {
1967         connected=false;
1968         SharkUtilities.disconnect(connectionKey);
1969         cus.info("ExecutionAdmin -> User "+userId+" with connection key "+connectionKey+" is automatically disconnected");
1970      }
1971   }
1972}
1973
1974
Popular Tags