KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > shark > corba > poa > MappingAdminCORBA


1 package org.enhydra.shark.corba.poa;
2
3 import org.enhydra.shark.corba.WorkflowService.*;
4 import org.enhydra.shark.corba.poa.ApplicationMapCORBA;
5 import org.enhydra.shark.corba.poa.Collective;
6 import org.omg.CORBA.ORB JavaDoc;
7 import org.omg.WfBase.BaseException;
8 import org.omg.WfBase.NameValue;
9 import org.omg.PortableServer.POAPackage.ServantAlreadyActive JavaDoc;
10 import org.omg.PortableServer.POAPackage.WrongPolicy JavaDoc;
11 import org.omg.PortableServer.POAPackage.ServantNotActive JavaDoc;
12
13 /**
14  * Create participant and procedure mapping classes and provides a way
15  * to retrieve its objects.
16  *
17  * @author David Forslund
18  */

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

368    }
369 }
Popular Tags