KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > shark > corba > UserGroupAdminCORBA


1 package org.enhydra.shark.corba;
2
3 import org.omg.WfBase.*;
4 import org.enhydra.shark.corba.WorkflowService.*;
5
6
7
8 /**
9  * Interface used to perform some administrative operations.
10  * @author Sasa Bojanic
11  */

12 public class UserGroupAdminCORBA extends _UserGroupAdministrationImplBase {
13    private SharkCORBAServer myServer;
14
15    private String JavaDoc userId;
16    private boolean connected=false;
17
18    org.enhydra.shark.api.client.wfservice.UserGroupAdministration myUGAdmin;
19
20    UserGroupAdminCORBA (SharkCORBAServer server,org.enhydra.shark.api.client.wfservice.UserGroupAdministration uga) {
21       this.myServer=server;
22       this.myUGAdmin=uga;
23    }
24
25    public void connect(String JavaDoc userId, String JavaDoc password, String JavaDoc engineName, String JavaDoc scope) throws BaseException, ConnectFailed {
26       this.userId=userId;
27
28       try {
29          if (!myServer.validateUser(userId,password)) {
30             throw new ConnectFailed("Connection failed, invalid username or password");
31          }
32          connected=true;
33          myUGAdmin.connect(userId);
34       } catch (ConnectFailed cf) {
35          throw cf;
36       } catch (Exception JavaDoc ex) {
37          throw new BaseException();
38       }
39    }
40
41    public void disconnect() throws BaseException, NotConnected {
42       if (!connected) {
43          throw new NotConnected("The connection is not established...");
44       }
45       connected=false;
46       this._orb().disconnect(this);
47    }
48
49    public String JavaDoc[] getAllGroupnames () throws BaseException, NotConnected {
50       if (!connected) {
51          throw new NotConnected("The connection is not established...");
52       }
53       try {
54          return myUGAdmin.getAllGroupnames();
55       } catch (Exception JavaDoc e) {
56          throw new BaseException();
57       }
58    }
59
60    public String JavaDoc[] getAllUsers () throws BaseException, NotConnected {
61       if (!connected) {
62          throw new NotConnected("The connection is not established...");
63       }
64       try {
65          return myUGAdmin.getAllUsers();
66       } catch (Exception JavaDoc e) {
67          throw new BaseException();
68       }
69    }
70
71    public String JavaDoc[] getAllImmediateUsers (String JavaDoc groupName) throws BaseException, NotConnected {
72       if (!connected) {
73          throw new NotConnected("The connection is not established...");
74       }
75       try {
76          return myUGAdmin.getAllImmediateUsers(groupName);
77       } catch (Exception JavaDoc e) {
78          throw new BaseException();
79       }
80    }
81
82    public String JavaDoc[] getAllUsersForGroup (String JavaDoc groupName) throws BaseException, NotConnected {
83       if (!connected) {
84          throw new NotConnected("The connection is not established...");
85       }
86       try {
87          return myUGAdmin.getAllUsers(groupName);
88       } catch (Exception JavaDoc e) {
89          throw new BaseException();
90       }
91    }
92
93    public String JavaDoc[] getAllUsersForGroups(String JavaDoc[] groupNames) throws BaseException, NotConnected {
94       if (!connected) {
95          throw new NotConnected("The connection is not established...");
96       }
97       try {
98          return myUGAdmin.getAllUsers(groupNames);
99       } catch (Exception JavaDoc e) {
100          throw new BaseException();
101       }
102    }
103
104    public String JavaDoc[] getAllSubgroups (String JavaDoc groupName) throws BaseException, NotConnected {
105       if (!connected) {
106          throw new NotConnected("The connection is not established...");
107       }
108       try {
109          return myUGAdmin.getAllSubgroups(groupName);
110       } catch (Exception JavaDoc e) {
111          throw new BaseException();
112       }
113    }
114
115    public String JavaDoc[] getAllSubgroupsForGroups(String JavaDoc[] groupNames) throws BaseException, NotConnected {
116       if (!connected) {
117          throw new NotConnected("The connection is not established...");
118       }
119       try {
120          return myUGAdmin.getAllSubgroups(groupNames);
121       } catch (Exception JavaDoc e) {
122          throw new BaseException();
123       }
124    }
125
126    public String JavaDoc[] getAllImmediateSubgroups (String JavaDoc groupName) throws BaseException, NotConnected {
127       if (!connected) {
128          throw new NotConnected("The connection is not established...");
129       }
130       try {
131          return myUGAdmin.getAllImmediateSubgroups(groupName);
132       } catch (Exception JavaDoc e) {
133          throw new BaseException();
134       }
135    }
136
137    public void createGroup (String JavaDoc groupName,String JavaDoc description) throws BaseException, NotConnected {
138       if (!connected) {
139          throw new NotConnected("The connection is not established...");
140       }
141       try {
142          myUGAdmin.createGroup(groupName,description);
143       } catch (Exception JavaDoc e) {
144          throw new BaseException();
145       }
146    }
147
148    public void removeGroup (String JavaDoc groupName) throws BaseException, NotConnected {
149       if (!connected) {
150          throw new NotConnected("The connection is not established...");
151       }
152       try {
153          myUGAdmin.removeGroup(groupName);
154       } catch (Exception JavaDoc e) {
155          throw new BaseException();
156       }
157    }
158
159    public boolean doesGroupExist (String JavaDoc groupName) throws BaseException, NotConnected {
160       if (!connected) {
161          throw new NotConnected("The connection is not established...");
162       }
163       try {
164          return myUGAdmin.doesGroupExist(groupName);
165       } catch (Exception JavaDoc e) {
166          throw new BaseException();
167       }
168    }
169
170    public boolean doesGroupBelongToGroup (String JavaDoc groupName, String JavaDoc subgroupName) throws BaseException, NotConnected {
171       if (!connected) {
172          throw new NotConnected("The connection is not established...");
173       }
174       try {
175          return myUGAdmin.doesGroupBelongToGroup(groupName,subgroupName);
176       } catch (Exception JavaDoc e) {
177          throw new BaseException();
178       }
179    }
180
181    public void updateGroup (String JavaDoc groupName,String JavaDoc description) throws BaseException, NotConnected {
182       if (!connected) {
183          throw new NotConnected("The connection is not established...");
184       }
185       try {
186          myUGAdmin.updateGroup(groupName,description);
187       } catch (Exception JavaDoc e) {
188          throw new BaseException();
189       }
190    }
191
192    public void addGroupToGroup (String JavaDoc groupName,String JavaDoc subgroupName) throws BaseException, NotConnected {
193       if (!connected) {
194          throw new NotConnected("The connection is not established...");
195       }
196       try {
197          myUGAdmin.addGroupToGroup(groupName,subgroupName);
198       } catch (Exception JavaDoc e) {
199          throw new BaseException();
200       }
201    }
202
203    public void removeGroupFromGroup (String JavaDoc groupName,String JavaDoc subgroupName) throws BaseException, NotConnected {
204       if (!connected) {
205          throw new NotConnected("The connection is not established...");
206       }
207       try {
208          myUGAdmin.removeGroupFromGroup(groupName,subgroupName);
209       } catch (Exception JavaDoc e) {
210          throw new BaseException();
211       }
212    }
213
214    public void removeGroupTree (String JavaDoc groupName) throws BaseException, NotConnected {
215       if (!connected) {
216          throw new NotConnected("The connection is not established...");
217       }
218       try {
219          myUGAdmin.removeGroupTree(groupName);
220       } catch (Exception JavaDoc e) {
221          throw new BaseException();
222       }
223    }
224
225    public void removeUsersFromGroupTree (String JavaDoc groupName) throws BaseException, NotConnected {
226       if (!connected) {
227          throw new NotConnected("The connection is not established...");
228       }
229       try {
230          myUGAdmin.removeUsersFromGroupTree(groupName);
231       } catch (Exception JavaDoc e) {
232          throw new BaseException();
233       }
234    }
235
236    public void moveGroup (String JavaDoc currentParentGroup,
237                           String JavaDoc newParentGroup,
238                           String JavaDoc subgroupName) throws BaseException, NotConnected {
239       if (!connected) {
240          throw new NotConnected("The connection is not established...");
241       }
242       try {
243          myUGAdmin.moveGroup(currentParentGroup,newParentGroup,subgroupName);
244       } catch (Exception JavaDoc e) {
245          throw new BaseException();
246       }
247    }
248
249    public String JavaDoc getGroupDescription (String JavaDoc groupName) throws BaseException, NotConnected {
250       if (!connected) {
251          throw new NotConnected("The connection is not established...");
252       }
253       try {
254          return myUGAdmin.getGroupDescription(groupName);
255       } catch (Exception JavaDoc e) {
256          throw new BaseException();
257       }
258    }
259
260    public void addUserToGroup (String JavaDoc groupName,String JavaDoc username) throws BaseException, NotConnected {
261       if (!connected) {
262          throw new NotConnected("The connection is not established...");
263       }
264       try {
265          myUGAdmin.addUserToGroup(groupName,username);
266       } catch (Exception JavaDoc e) {
267          throw new BaseException();
268       }
269    }
270
271    public void removeUserFromGroup (String JavaDoc groupName,String JavaDoc username) throws BaseException, NotConnected {
272       if (!connected) {
273          throw new NotConnected("The connection is not established...");
274       }
275       try {
276          myUGAdmin.removeUserFromGroup(groupName,username);
277       } catch (Exception JavaDoc e) {
278          throw new BaseException();
279       }
280    }
281
282    public void moveUser (String JavaDoc currentGroup,
283                          String JavaDoc newGroup,
284                          String JavaDoc username) throws BaseException, NotConnected {
285       if (!connected) {
286          throw new NotConnected("The connection is not established...");
287       }
288       try {
289          myUGAdmin.moveUser(currentGroup,newGroup,username);
290       } catch (Exception JavaDoc e) {
291          throw new BaseException();
292       }
293    }
294
295    public boolean doesUserBelongToGroup (String JavaDoc groupName,String JavaDoc username) throws BaseException, NotConnected {
296       if (!connected) {
297          throw new NotConnected("The connection is not established...");
298       }
299       try {
300          return myUGAdmin.doesUserBelongToGroup(groupName,username);
301       } catch (Exception JavaDoc e) {
302          throw new BaseException();
303       }
304    }
305
306    public void createUser (String JavaDoc groupName,String JavaDoc username, String JavaDoc password, String JavaDoc firstName, String JavaDoc lastName, String JavaDoc emailAddress) throws BaseException, NotConnected {
307       if (!connected) {
308          throw new NotConnected("The connection is not established...");
309       }
310       try {
311          myUGAdmin.createUser(groupName,username,password,firstName,lastName,emailAddress);
312       } catch (Exception JavaDoc e) {
313          throw new BaseException();
314       }
315    }
316
317    public void removeUser (String JavaDoc username) throws BaseException, NotConnected {
318       if (!connected) {
319          throw new NotConnected("The connection is not established...");
320       }
321       try {
322          myUGAdmin.removeUser(username);
323       } catch (Exception JavaDoc e) {
324          throw new BaseException();
325       }
326    }
327
328    public void updateUser (String JavaDoc username,String JavaDoc firstName, String JavaDoc lastName, String JavaDoc emailAddress) throws BaseException, NotConnected {
329       if (!connected) {
330          throw new NotConnected("The connection is not established...");
331       }
332       try {
333          myUGAdmin.updateUser(username,firstName,lastName,emailAddress);
334       } catch (Exception JavaDoc e) {
335          throw new BaseException();
336       }
337    }
338
339    public void setPassword (String JavaDoc username,String JavaDoc password) throws BaseException, NotConnected {
340       if (!connected) {
341          throw new NotConnected("The connection is not established...");
342       }
343       try {
344          myUGAdmin.setPassword(username,password);
345       } catch (Exception JavaDoc e) {
346          throw new BaseException();
347       }
348    }
349
350    public boolean doesUserExist (String JavaDoc username) throws BaseException, NotConnected {
351       if (!connected) {
352          throw new NotConnected("The connection is not established...");
353       }
354       try {
355          return myUGAdmin.doesUserExist(username);
356       } catch (Exception JavaDoc e) {
357          throw new BaseException();
358       }
359    }
360
361    public String JavaDoc getUserRealName (String JavaDoc username) throws BaseException, NotConnected {
362       if (!connected) {
363          throw new NotConnected("The connection is not established...");
364       }
365       try {
366          return myUGAdmin.getUserRealName(username);
367       } catch (Exception JavaDoc e) {
368          throw new BaseException();
369       }
370    }
371
372    public String JavaDoc getUserFirstName (String JavaDoc username) throws BaseException, NotConnected {
373       if (!connected) {
374          throw new NotConnected("The connection is not established...");
375       }
376       try {
377          return myUGAdmin.getUserFirstName(username);
378       } catch (Exception JavaDoc e) {
379          throw new BaseException();
380       }
381    }
382
383    public String JavaDoc getUserLastName (String JavaDoc username) throws BaseException, NotConnected {
384       if (!connected) {
385          throw new NotConnected("The connection is not established...");
386       }
387       try {
388          return myUGAdmin.getUserLastName(username);
389       } catch (Exception JavaDoc e) {
390          throw new BaseException();
391       }
392    }
393
394    public String JavaDoc getUserEMailAddress (String JavaDoc username) throws BaseException, NotConnected {
395       if (!connected) {
396          throw new NotConnected("The connection is not established...");
397       }
398       try {
399          return myUGAdmin.getUserEMailAddress(username);
400       } catch (Exception JavaDoc e) {
401          throw new BaseException();
402       }
403    }
404
405 }
406
Popular Tags