1 package org.enhydra.shark.corba; 2 3 import org.enhydra.shark.corba.WorkflowService.*; 4 import org.omg.CORBA.ORB ; 5 import org.omg.WfBase.BaseException; 6 import org.omg.WfBase.NameValue; 7 8 14 public class MappingAdminCORBA extends _MappingAdministrationImplBase implements 15 Collective { 16 private SharkCORBAServer myServer; 17 18 private String userId; 19 20 private boolean connected = false; 21 22 private org.enhydra.shark.api.client.wfservice.ParticipantMappingAdministration participantMappingManager; 23 24 private org.enhydra.shark.api.client.wfservice.ApplicationMappingAdministration applicationMappingManager; 25 26 public MappingAdminCORBA(SharkCORBAServer server, 27 org.enhydra.shark.api.client.wfservice.ParticipantMappingAdministration mm, 28 org.enhydra.shark.api.client.wfservice.ApplicationMappingAdministration aa) { 29 this.myServer = server; 30 this.participantMappingManager = mm; 31 this.applicationMappingManager = aa; 32 if (myServer.trackObjects) { 33 __collective = new Collective.CollectiveCORBA(); 34 } 35 } 36 37 public void connect(String userId, 38 String password, 39 String engineName, 40 String scope) throws BaseException, ConnectFailed { 41 this.userId = userId; 42 43 try { 44 if (!myServer.validateUser(userId, password)) { throw new ConnectFailed("Connection failed, invalid username or password"); } 45 connected = true; 46 participantMappingManager.connect(userId); 47 applicationMappingManager.connect(userId); 48 } catch (ConnectFailed cf) { 49 throw cf; 50 } catch (Exception ex) { 51 throw new BaseException(); 52 } 53 } 54 55 public void disconnect() throws BaseException, NotConnected { 56 if (!connected) { throw new NotConnected("The connection is not established..."); } 57 connected = false; 58 this.__disband(this._orb()); 59 } 60 61 public ParticipantMap[] getAllParticipants() throws BaseException, 62 NotConnected { 63 if (!connected) { throw new NotConnected("The connection is not established..."); } 64 try { 65 return SharkCORBAUtilities.makeCORBAParticipantMaps(this, 66 participantMappingManager.getAllParticipants()); 67 } catch (Exception ex) { 68 throw new BaseException(); 69 } 70 } 71 72 public ParticipantMap[] getAllParticipantsFromPkg(String pkgId) throws BaseException, 73 NotConnected { 74 if (!connected) { throw new NotConnected("The connection is not established..."); } 75 try { 76 return SharkCORBAUtilities.makeCORBAParticipantMaps(this, 77 participantMappingManager.getAllParticipants(pkgId)); 78 } catch (Exception ex) { 79 throw new BaseException(); 80 } 81 } 82 83 public ParticipantMap[] getAllParticipantsFromPkgProcess(String pkgId, 84 String pDefId) throws BaseException, 85 NotConnected { 86 if (!connected) { throw new NotConnected("The connection is not established..."); } 87 try { 88 return SharkCORBAUtilities.makeCORBAParticipantMaps(this, 89 participantMappingManager.getAllParticipants(pkgId)); 90 } catch (Exception ex) { 91 throw new BaseException(); 92 } 93 } 94 95 public String [] getAllGroupnames() throws BaseException, NotConnected { 96 if (!connected) { throw new NotConnected("The connection is not established..."); } 97 try { 98 return participantMappingManager.getAllGroupnames(); 99 } catch (Exception ex) { 100 throw new BaseException(); 101 } 102 } 103 104 public String [] getAllUsers() throws BaseException, NotConnected { 105 if (!connected) { throw new NotConnected("The connection is not established..."); } 106 try { 107 return participantMappingManager.getAllUsers(); 108 } catch (Exception ex) { 109 throw new BaseException(); 110 } 111 } 112 113 public String [] getAllUsersForGroup(String groupName) throws BaseException, 114 NotConnected { 115 if (!connected) { throw new NotConnected("The connection is not established..."); } 116 try { 117 return participantMappingManager.getAllUsers(groupName); 118 } catch (Exception ex) { 119 throw new BaseException(); 120 } 121 } 122 123 public ParticipantMap[] getAllParticipantMappings() throws BaseException, 124 NotConnected { 125 if (!connected) { throw new NotConnected("The connection is not established..."); } 126 try { 127 return SharkCORBAUtilities.makeCORBAParticipantMaps(this, 128 participantMappingManager.getAllParticipantMappings()); 129 } catch (Exception ex) { 130 ex.printStackTrace(); 131 throw new BaseException(); 132 } 133 } 134 135 public void addParticipantMapping(ParticipantMap pm) throws BaseException, 136 NotConnected { 137 if (!connected) { throw new NotConnected("The connection is not established..."); } 138 try { 139 participantMappingManager.addParticipantMapping(SharkCORBAUtilities.fillParticipantMap(participantMappingManager.createParticipantMap(), 140 pm)); 141 } catch (Exception ex) { 142 throw new BaseException(); 143 } 144 } 145 146 public void removeParticipantMapping(ParticipantMap pm) throws BaseException, 147 NotConnected { 148 if (!connected) { throw new NotConnected("The connection is not established..."); } 149 try { 150 participantMappingManager.removeParticipantMapping(SharkCORBAUtilities.fillParticipantMap(participantMappingManager.createParticipantMap(), 151 pm)); 152 } catch (Exception ex) { 153 throw new BaseException(); 154 } 155 } 156 157 public ParticipantMap[] getParticipantMappings(String packageId, 158 String processDefinitionId, 159 String participantId) throws BaseException, 160 NotConnected { 161 if (!connected) { throw new NotConnected("The connection is not established..."); } 162 try { 163 return SharkCORBAUtilities.makeCORBAParticipantMaps(this, 164 participantMappingManager.getParticipantMappings(packageId, 165 processDefinitionId, 166 participantId)); 167 } catch (Exception ex) { 168 throw new BaseException(); 169 } 170 } 171 172 public void removeParticipantMappings(String packageId, 173 String processDefinitionId, 174 String participantId) throws BaseException, 175 NotConnected { 176 if (!connected) { throw new NotConnected("The connection is not established..."); } 177 try { 178 participantMappingManager.removeParticipantMappings(packageId, 179 processDefinitionId, 180 participantId); 181 } catch (Exception ex) { 182 throw new BaseException(); 183 } 184 } 185 186 public void removeParticipantMappingsForUser(String username) throws BaseException, 187 NotConnected { 188 if (!connected) { throw new NotConnected("The connection is not established..."); } 189 try { 190 participantMappingManager.removeParticipantMappings(username); 191 } catch (Exception ex) { 192 throw new BaseException(); 193 } 194 } 195 196 public ParticipantMap createParticipantMap() throws BaseException, 197 NotConnected { 198 if (!connected) { throw new NotConnected("The connection is not established..."); } 199 return new ParticipantMapCORBA(this); 200 } 201 202 public ApplicationMap[] getAllApplications() throws BaseException, 203 NotConnected { 204 if (!connected) { throw new NotConnected("The connection is not established..."); } 205 try { 206 return SharkCORBAUtilities.makeCORBAApplicationMaps(this, 207 applicationMappingManager.getAllApplications()); 208 } catch (Exception ex) { 209 throw new BaseException(); 210 } 211 } 212 213 public ApplicationMap[] getAllApplicationsFromPkg(String pkgId) throws BaseException, 214 NotConnected { 215 if (!connected) { throw new NotConnected("The connection is not established..."); } 216 try { 217 return SharkCORBAUtilities.makeCORBAApplicationMaps(this, 218 applicationMappingManager.getAllApplications(pkgId)); 219 } catch (Exception ex) { 220 throw new BaseException(); 221 } 222 } 223 224 public ApplicationMap[] getAllApplicationsFromPkgProcess(String pkgId, 225 String pDefId) throws BaseException, 226 NotConnected { 227 if (!connected) { throw new NotConnected("The connection is not established..."); } 228 try { 229 return SharkCORBAUtilities.makeCORBAApplicationMaps(this, 230 applicationMappingManager.getAllApplications(pkgId, 231 pDefId)); 232 } catch (Exception ex) { 233 throw new BaseException(); 234 } 235 } 236 237 public String [] getDefinedToolAgents() throws BaseException, NotConnected { 238 if (!connected) { throw new NotConnected("The connection is not established..."); } 239 try { 240 return applicationMappingManager.getDefinedToolAgents(); 241 } catch (Exception ex) { 242 throw new BaseException(); 243 } 244 } 245 246 public NameValue[] getToolAgentsInfo() throws BaseException, NotConnected { 247 if (!connected) { throw new NotConnected("The connection is not established..."); } 248 try { 249 return SharkCORBAUtilities.makeCORBANameValueArray(this._orb(), 250 applicationMappingManager.getToolAgentsInfo()); 251 } catch (Exception ex) { 252 throw new BaseException(); 253 } 254 } 255 256 public String getToolAgentInfo(String toolAgentFullClassName) throws BaseException, 257 NotConnected { 258 if (!connected) { throw new NotConnected("The connection is not established..."); } 259 try { 260 return applicationMappingManager.getToolAgentInfo(toolAgentFullClassName); 261 } catch (Exception ex) { 262 throw new BaseException(); 263 } 264 } 265 266 public void addApplicationMapping(ApplicationMap am) throws BaseException, 267 NotConnected { 268 if (!connected) { throw new NotConnected("The connection is not established..."); } 269 try { 270 applicationMappingManager.addApplicationMapping(SharkCORBAUtilities.fillApplicationMap(applicationMappingManager.createApplicationMap(), 271 am)); 272 } catch (Exception ex) { 273 throw new BaseException(); 274 } 275 } 276 277 public ApplicationMap getApplicationMapping(String pkgId, 278 String pDefId, 279 String appDefId) throws BaseException, 280 NotConnected { 281 if (!connected) { throw new NotConnected("The connection is not established..."); } 282 try { 283 return new ApplicationMapCORBA(this, 284 applicationMappingManager.getApplicationMapping(pkgId, 285 pDefId, 286 appDefId)); 287 } catch (Exception ex) { 288 throw new BaseException(); 289 } 290 } 291 292 public void removeApplicationMapping(String packageId, 293 String processDefinitionId, 294 String applicationId) throws BaseException, 295 NotConnected { 296 if (!connected) { throw new NotConnected("The connection is not established..."); } 297 try { 298 applicationMappingManager.removeApplicationMapping(packageId, 299 processDefinitionId, 300 applicationId); 301 } catch (Exception ex) { 302 throw new BaseException(); 303 } 304 } 305 306 public ApplicationMap[] getApplicationMappings() throws BaseException, 307 NotConnected { 308 if (!connected) { throw new NotConnected("The connection is not established..."); } 309 try { 310 return SharkCORBAUtilities.makeCORBAApplicationMaps(this, 311 applicationMappingManager.getApplicationMappings()); 312 } catch (Exception ex) { 313 throw new BaseException(); 314 } 315 } 316 317 public ApplicationMap createApplicationMap() throws BaseException, 318 NotConnected { 319 if (!connected) { throw new NotConnected("The connection is not established..."); } 320 return new ApplicationMapCORBA(this); 321 } 322 323 Collective __collective; 324 325 public void __recruit(org.omg.CORBA.Object obj) { 326 if (myServer.trackObjects) 327 __collective.__recruit(obj); 328 } 329 330 public void __leave(org.omg.CORBA.Object obj) { 331 if (myServer.trackObjects) 332 __collective.__leave(obj); 333 } 334 335 public void __disband(ORB _orb) { 336 if (myServer.trackObjects) { 337 __collective.__disband(_orb); 338 } 339 this._orb().disconnect(this); 340 } 341 } | Popular Tags |