1 package org.enhydra.shark; 2 3 import java.util.ArrayList ; 4 import java.util.List ; 5 import org.enhydra.shark.api.RootException; 6 import org.enhydra.shark.api.SharkTransaction; 7 import org.enhydra.shark.api.client.wfbase.BaseException; 8 import org.enhydra.shark.api.client.wfmodel.InvalidPerformer; 9 import org.enhydra.shark.api.client.wfmodel.WfEventAudit; 10 import org.enhydra.shark.api.client.wfmodel.WfProcess; 11 import org.enhydra.shark.api.client.wfmodel.WfProcessIterator; 12 import org.enhydra.shark.api.client.wfmodel.WfRequester; 13 import org.enhydra.shark.api.internal.instancepersistence.ProcessPersistenceInterface; 14 import org.enhydra.shark.api.internal.security.SecurityManager; 15 16 17 21 public class WfRequesterWrapper implements WfRequester { 22 23 private String userAuth; 24 private String resourceUsername; 25 26 protected WfRequesterWrapper (String userAuth,String resUsername) { 27 this.userAuth=userAuth; 28 this.resourceUsername=resUsername; 29 } 30 31 34 public int how_many_performer () throws BaseException { 35 int ret=-1; 36 SharkTransaction t = null; 37 try { 38 t = SharkUtilities.createTransaction(); 39 ret = how_many_performer(t); 40 } catch (RootException e) { 42 SharkUtilities.emptyCaches(t); 44 throw (BaseException)e; 45 } finally { 46 SharkUtilities.releaseTransaction(t); 47 } 48 return ret; 49 } 50 51 public int how_many_performer (SharkTransaction t) throws BaseException { 52 SecurityManager sm=SharkEngineManager.getInstance().getSecurityManager(); 53 if (sm!=null) { 54 try { 55 sm.check_requester_how_many_performer(t, 56 resourceUsername, 57 userAuth); 58 } catch (Exception ex) { 59 throw new BaseException(ex); 60 } 61 } 62 try { 63 return SharkEngineManager 64 .getInstance() 65 .getInstancePersistenceManager() 66 .getResourceRequestersProcessIds(resourceUsername,t).size(); 67 } catch (Exception ex) { 68 throw new BaseException(ex); 69 } 70 } 71 72 75 public WfProcessIterator get_iterator_performer () throws BaseException { 76 WfProcessIterator ret=null; 77 SharkTransaction t = null; 78 try { 79 t = SharkUtilities.createTransaction(); 80 ret = get_iterator_performer(t); 81 } catch (RootException e) { 83 SharkUtilities.emptyCaches(t); 85 throw (BaseException)e; 86 } finally { 87 SharkUtilities.releaseTransaction(t); 88 } 89 return ret; 90 } 91 92 public WfProcessIterator get_iterator_performer (SharkTransaction t) throws BaseException { 93 SecurityManager sm=SharkEngineManager.getInstance().getSecurityManager(); 94 if (sm!=null) { 95 try { 96 sm.check_requester_get_iterator_performer(t, 97 resourceUsername, 98 userAuth); 99 } catch (Exception ex) { 100 throw new BaseException(ex); 101 } 102 } 103 return SharkEngineManager.getInstance().getObjectFactory().createProcessIteratorWrapper(t,userAuth,resourceUsername,true); 104 } 105 106 110 public WfProcess[] get_sequence_performer (int max_number) throws BaseException { 111 WfProcess[] ret=null; 112 SharkTransaction t = null; 113 try { 114 t = SharkUtilities.createTransaction(); 115 ret = get_sequence_performer(t,max_number); 116 } catch (RootException e) { 118 SharkUtilities.emptyCaches(t); 120 throw (BaseException)e; 121 } finally { 122 SharkUtilities.releaseTransaction(t); 123 } 124 return ret; 125 } 126 127 public WfProcess[] get_sequence_performer (SharkTransaction t,int max_number) throws BaseException { 128 SecurityManager sm=SharkEngineManager.getInstance().getSecurityManager(); 129 if (sm!=null) { 130 try { 131 sm.check_requester_get_sequence_performer(t, 132 resourceUsername, 133 userAuth); 134 } catch (Exception ex) { 135 throw new BaseException(ex); 136 } 137 } 138 List alist = SharkUtilities.createResourceRequesterPerformersWrapper(t,userAuth,resourceUsername); 139 if (max_number > alist.size() || max_number<=0) { 140 max_number = alist.size(); 141 } 142 WfProcess[] ret = new WfProcess[max_number]; 143 alist.subList(0, max_number).toArray(ret); 144 return ret; 145 } 146 147 151 public boolean is_member_of_performer (WfProcess member) throws BaseException { 152 boolean ret=false; 153 SharkTransaction t = null; 154 try { 155 t = SharkUtilities.createTransaction(); 156 ret = is_member_of_performer(t,member); 157 } catch (RootException e) { 159 SharkUtilities.emptyCaches(t); 161 throw (BaseException)e; 162 } finally { 163 SharkUtilities.releaseTransaction(t); 164 } 165 return ret; 166 } 167 168 public boolean is_member_of_performer (SharkTransaction t,WfProcess member) throws BaseException { 169 SecurityManager sm=SharkEngineManager.getInstance().getSecurityManager(); 170 if (sm!=null) { 171 try { 172 sm.check_requester_is_member_of_performer(t, 173 resourceUsername, 174 userAuth); 175 } catch (Exception ex) { 176 throw new BaseException(ex); 177 } 178 } 179 try { 180 String procId=member.key(t); 181 List ids=SharkEngineManager.getInstance().getInstancePersistenceManager().getResourceRequestersProcessIds(resourceUsername,t); 182 return ids.contains(procId); 183 } catch (Exception ex) { 184 throw new BaseException(ex); 185 } 186 } 187 188 191 public void receive_event (WfEventAudit event) throws BaseException, InvalidPerformer { 192 SharkTransaction t = null; 193 try { 194 t = SharkUtilities.createTransaction(); 195 receive_event(t,event); 196 } catch (RootException e) { 198 SharkUtilities.emptyCaches(t); 200 throw (BaseException)e; 201 } finally { 202 SharkUtilities.releaseTransaction(t); 203 } 204 } 205 206 public void receive_event (SharkTransaction t,WfEventAudit event) throws BaseException, InvalidPerformer { 207 SecurityManager sm=SharkEngineManager.getInstance().getSecurityManager(); 208 if (sm!=null) { 209 try { 210 sm.check_requester_receive_event(t, 211 resourceUsername, 212 userAuth); 213 } catch (Exception ex) { 214 throw new BaseException(ex); 215 } 216 } 217 } 218 219 } 220 221 | Popular Tags |