KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > nightlabs > ipanema > organisation > OrganisationManagerBean


1 /*
2  * Created on 23.02.2004
3  */

4 package com.nightlabs.ipanema.organisation;
5
6 import java.rmi.RemoteException JavaDoc;
7 import java.util.Collection JavaDoc;
8 import java.util.List JavaDoc;
9 import java.util.Properties JavaDoc;
10
11 import javax.ejb.CreateException JavaDoc;
12 import javax.ejb.EJBException JavaDoc;
13 import javax.ejb.SessionBean JavaDoc;
14 import javax.ejb.SessionContext JavaDoc;
15 import javax.jdo.FetchPlan;
16 import javax.jdo.JDOObjectNotFoundException;
17 import javax.jdo.PersistenceManager;
18 import javax.naming.InitialContext JavaDoc;
19
20 import org.apache.log4j.Logger;
21
22 import com.nightlabs.ModuleException;
23 import com.nightlabs.ipanema.base.BaseSessionBeanImpl;
24 import com.nightlabs.ipanema.security.User;
25 import com.nightlabs.ipanema.security.UserManager;
26 import com.nightlabs.ipanema.security.UserManagerHome;
27 import com.nightlabs.ipanema.security.UserManagerUtil;
28 import com.nightlabs.ipanema.server.id.ServerID;
29 import com.nightlabs.ipanema.servermanager.IpanemaServerManager;
30 import com.nightlabs.ipanema.servermanager.config.OrganisationCf;
31
32 /**
33  *
34  * @author nick@nightlabs.de
35  */

36
37
38 /**
39  * @ejb.bean name="ipanema/ejb/IpanemaBaseBean/OrganisationManager"
40  * jndi-name="ipanema/ejb/IpanemaBaseBean/OrganisationManager"
41  * type="Stateful"
42  *
43  * @ejb.util generate = "physical"
44  **/

45 public abstract class OrganisationManagerBean
46     extends BaseSessionBeanImpl
47     implements SessionBean JavaDoc
48 {
49     public static final Logger LOGGER = Logger.getLogger(OrganisationManagerBean.class);
50     
51     /**
52      * @see com.nightlabs.ipanema.base.BaseSessionBeanImpl#setSessionContext(javax.ejb.SessionContext)
53      */

54     public void setSessionContext(SessionContext JavaDoc sessionContext)
55             throws EJBException JavaDoc, RemoteException JavaDoc
56     {
57         System.out.println(this.getClass().getName() + ".setSessionContext("+sessionContext+")");
58         super.setSessionContext(sessionContext);
59     }
60     /**
61      * _Guest_ needs to be able to instantiate this EJB, because of the orga registration.
62      *
63      * @ejb.create-method
64      * @ejb.permission role-name="_Guest_"
65      * @!!!ejb.permission role-name="_ServerAdmin_, OrganisationManager-read"
66      */

67     public void ejbCreate()
68     throws CreateException JavaDoc
69     {
70         System.out.println(this.getClass().getName() + ".ejbCreate()");
71 // try
72
// {
73
// System.out.println("OrganisationManager created by " + this.getPrincipalString());
74
// }
75
// catch (ModuleException e)
76
// {
77
// throw new CreateException(e.getMessage());
78
// }
79
}
80     /**
81      * @see javax.ejb.SessionBean#ejbRemove()
82      *
83      * @ejb.permission unchecked="true"
84      */

85     public void ejbRemove() throws EJBException JavaDoc, RemoteException JavaDoc { }
86
87     /**
88      * This method creates a representative organisation on this server. Note,
89      * that it cannot be converted into a real organisation afterwards. This
90      * representative cannot start operation before its masterOrganisation has
91      * accepted it.
92      *
93      * @param organisationID The organisationID of the representative. Must be new and unique in the whole network (means world!).
94      * @param organisationDisplayName A nice name that will be used to display the new representative organisation.
95      * @param masterOrganisationID The organisationID of the master organisation, this new slave is representing.
96      * @throws ModuleException
97      *
98      * @ejb.interface-method
99      * @!ejb.transaction type = "Required"
100      * @ejb.transaction type = "Never"
101      * @ejb.permission role-name="_ServerAdmin_"
102      */

103     public void createOrganisation(String JavaDoc organisationID, String JavaDoc organisationDisplayName, String JavaDoc masterOrganisationID)
104         throws ModuleException
105     {
106         IpanemaServerManager ism = getIpanemaServerManager();
107         try {
108             ism.createOrganisation(organisationID, organisationDisplayName, masterOrganisationID);
109         } finally {
110             ism.close();
111         }
112     }
113
114     /**
115      * This method creates a real organisation on this server. It cannot be converted into
116      * a representative afterwards!
117      *
118      * @param organisationID The ID of the new organisation. It must be unique in the whole world.
119      * @param organisationDisplayName A nice name that will be used to display the new representative organisation.
120      * @param userID The userID of the first user to create within the new organisation. It will have all necessary permissions to manage users and roles within the new organisation.
121      * @param password The password of the new user.
122      * @param isServerAdmin Whether this user should have global server administration permissions.
123      * @throws ModuleException
124      *
125      * @ejb.interface-method
126      * @!ejb.transaction type = "Required"
127      * @ejb.transaction type = "Never"
128      * @ejb.permission role-name="_ServerAdmin_"
129      */

130     public void createOrganisation(String JavaDoc organisationID, String JavaDoc organisationDisplayName, String JavaDoc userID, String JavaDoc password, boolean isServerAdmin)
131         throws ModuleException
132     {
133         IpanemaServerManager ism = getIpanemaServerManager();
134         try {
135             ism.createOrganisation(organisationID, organisationDisplayName, userID, password, isServerAdmin);
136         } finally {
137             ism.close();
138         }
139     }
140
141
142     /**
143      * @ejb.interface-method
144      * @ejb.permission role-name="_ServerAdmin_"
145      **/

146     public List JavaDoc getOrganisationCfs(boolean sorted)
147         throws ModuleException
148     {
149         IpanemaServerManager ism = getIpanemaServerManager();
150         try {
151             return ism.getOrganisationCfs(sorted);
152         } finally {
153             ism.close();
154         }
155     }
156
157     /**
158      * @ejb.interface-method
159      * @ejb.permission role-name="_ServerAdmin_"
160      **/

161     public OrganisationCf getOrganisationConfig(String JavaDoc organisationID)
162         throws ModuleException
163     {
164         IpanemaServerManager ism = getIpanemaServerManager();
165         try {
166             return ism.getOrganisationConfig(organisationID);
167         } finally {
168             ism.close();
169         }
170     }
171
172     /**
173      * This method finds out whether the current
174      *
175      * @ejb.interface-method
176      * @ejb.permission role-name="_Guest_"
177      *
178      * @see com.nightlabs.ipanema.servermanager.IpanemaServerManagerFactory#isOrganisationCfsEmpty()
179      */

180     public boolean isOrganisationCfsEmpty()
181         throws ModuleException
182     {
183         IpanemaServerManager ism = getIpanemaServerManager();
184         try {
185             return ism.isOrganisationCfsEmpty();
186         } finally {
187             ism.close();
188         }
189     }
190
191     /**
192      * @ejb.interface-method
193      * @ejb.permission role-name="OrganisationManager-read"
194      **/

195     public Collection JavaDoc getPendingRegistrations(String JavaDoc[] fetchGroups)
196         throws ModuleException
197     {
198         PersistenceManager pm = getPersistenceManager();
199         try {
200             if (fetchGroups != null) {
201                 FetchPlan fetchPlan = pm.getFetchPlan();
202                 for (int i = 0; i < fetchGroups.length; ++i)
203                     fetchPlan.addGroup(fetchGroups[i]);
204             }
205
206             return pm.detachCopyAll(
207                     LocalOrganisation.getLocalOrganisation(pm).getPendingRegistrations());
208         } finally {
209             pm.close();
210         }
211     }
212
213     /**
214      * This method is called by the other organisation to inform this
215      * one that the registration has been accepted.
216      * <br/><br/>
217      * Though, there
218      * is no j2ee security, it is quite hard to guess the correct
219      * registrationID. Additionally, the organisation is read out
220      * of the IpanemaPrincipal and must match the other organisationID.
221      *
222      * @ejb.interface-method
223      * @ejb.transaction type = "Required"
224      * @ejb.permission role-name="_Guest_"
225      **/

226     public void notifyAcceptRegistration(String JavaDoc registrationID, Organisation grantOrganisation, String JavaDoc userPassword)
227         throws ModuleException
228     {
229         if (registrationID == null)
230             throw new NullPointerException JavaDoc("registrationID");
231
232         if (userPassword == null)
233             throw new NullPointerException JavaDoc("userPassword");
234
235         String JavaDoc userID = getPrincipal().getUserID();
236         if (!userID.startsWith(User.USERID_PREFIX_TYPE_ORGANISATION))
237             throw new IllegalStateException JavaDoc("This method can only be executed by an organisation!");
238
239         String JavaDoc grantOrganisationID = userID.substring(User.USERID_PREFIX_TYPE_ORGANISATION.length());
240
241         PersistenceManager pm = getPersistenceManager();
242         try {
243             LocalOrganisation localOrganisation = LocalOrganisation.getLocalOrganisation(pm);
244             RegistrationStatus registrationStatus = localOrganisation.getPendingRegistration(grantOrganisationID);
245             if (registrationStatus == null)
246                 throw new IllegalStateException JavaDoc("There is no pending registration for applicantOrganisationID=\""+getOrganisationID()+"\" and grantOrganisationID=\""+grantOrganisationID+"\"!");
247
248             if (!registrationID.equals(registrationStatus.getRegistrationID()))
249                 throw new IllegalArgumentException JavaDoc("The given registrationID \""+registrationID+"\" does not match the pending registration for applicantOrganisationID=\""+getOrganisationID()+"\" and grantOrganisationID=\""+grantOrganisationID+"\"!");
250
251             localOrganisation.setPassword(grantOrganisationID, userPassword);
252             registrationStatus.accept(User.getUser(pm, getPrincipal()));
253
254             // It seems, there is a bug in JPOX (foreign key constraint error) and therefore,
255
// we need to persist the server manually...
256
try {
257                 pm.getObjectById(ServerID.create(grantOrganisation.getServer().getServerID()));
258             } catch (JDOObjectNotFoundException x) {
259                 pm.makePersistent(grantOrganisation.getServer());
260             }
261             pm.makePersistent(grantOrganisation);
262         } finally {
263             pm.close();
264         }
265     }
266     
267     /**
268      * @ejb.interface-method
269      * @ejb.transaction type = "Required"
270      * @ejb.permission role-name="_Guest_"
271      **/

272     public void notifyRejectRegistration(String JavaDoc registrationID)
273         throws ModuleException
274     {
275         if (registrationID == null)
276             throw new NullPointerException JavaDoc("registrationID");
277
278         String JavaDoc userID = getPrincipal().getUserID();
279         if (!userID.startsWith(User.USERID_PREFIX_TYPE_ORGANISATION))
280             throw new IllegalStateException JavaDoc("This method can only be executed by an organisation!");
281
282         String JavaDoc grantOrganisationID = userID.substring(User.USERID_PREFIX_TYPE_ORGANISATION.length());
283
284         PersistenceManager pm = getPersistenceManager();
285         try {
286             LocalOrganisation localOrganisation = LocalOrganisation.getLocalOrganisation(pm);
287             RegistrationStatus registrationStatus = localOrganisation.getPendingRegistration(grantOrganisationID);
288             if (registrationStatus == null)
289                 throw new IllegalStateException JavaDoc("There is no pending registration for applicantOrganisationID=\""+getOrganisationID()+"\" and grantOrganisationID=\""+grantOrganisationID+"\"!");
290
291             if (!registrationID.equals(registrationStatus.getRegistrationID()))
292                 throw new IllegalArgumentException JavaDoc("The given registrationID \""+registrationID+"\" does not match the pending registration for applicantOrganisationID=\""+getOrganisationID()+"\" and grantOrganisationID=\""+grantOrganisationID+"\"!");
293
294             User user = User.getUser(pm, getOrganisationID(), userID);
295             // user.setPassword(null); // login is impossible with a null password
296
pm.deletePersistent(user);
297
298             registrationStatus.reject(null);
299             // TODO we must remove the pending registration after the user has seen, that
300
// it was rejected.
301
// localOrganisation.removePendingRegistration(grantOrganisationID);
302
} finally {
303             pm.close();
304         }
305     }
306
307     /**
308      * This method is called by the client (a user who has organisation administrative
309      * rights) to accept a registration. The registration must have been previously
310      * applied for by the other organisation.
311      *
312      * @ejb.interface-method
313      * @ejb.transaction type = "Required"
314      * @ejb.permission role-name="OrganisationManager-write"
315      **/

316     public void acceptRegistration(String JavaDoc applicantOrganisationID)
317         throws ModuleException
318     {
319         PersistenceManager pm = getPersistenceManager();
320         try {
321             LocalOrganisation localOrganisation = LocalOrganisation.getLocalOrganisation(pm);
322             
323             RegistrationStatus registrationStatus = localOrganisation
324                     .getPendingRegistration(applicantOrganisationID);
325
326             if (registrationStatus == null)
327                 throw new IllegalArgumentException JavaDoc("There is no pending registration for applicantOrganisation \""+applicantOrganisationID+"\" at grantOrganisation \""+getOrganisationID()+"\"!");
328
329             // We have to create a user for the new organisation. Therefore,
330
// generate a password with a random length between 8 and 16 characters.
331
String JavaDoc usrPassword = User.generatePassword(8, 16);
332
333             try {
334                 // Create the user if it doesn't yet exist
335
String JavaDoc userID = User.USERID_PREFIX_TYPE_ORGANISATION + applicantOrganisationID;
336                 try {
337                     User user = User.getUser(pm, getOrganisationID(), userID);
338                     user.setPasswordPlain(usrPassword); // set the new password, if the user already exists
339
} catch (JDOObjectNotFoundException x) {
340                     // Create the user
341
UserManager userManager = UserManagerUtil.getHome().create();
342                     User user = new User(userID);
343                     user.setPassword(usrPassword);
344                     userManager.saveUser(user);
345                     userManager.remove();
346                 }
347
348                 pm.getFetchPlan().addGroup(FetchPlan.ALL);
349                 Organisation grantOrganisation = (Organisation) pm.detachCopy(
350                         localOrganisation.getOrganisation());
351
352                 // Now, we notify the other organisation that its request has been
353
// accepted.
354
OrganisationManager organisationManager = OrganisationManagerUtil.getHome(getInitialContextProps(applicantOrganisationID)).create();
355                 organisationManager.notifyAcceptRegistration(
356                         registrationStatus.getRegistrationID(), grantOrganisation, usrPassword);
357                 organisationManager.remove();
358             } catch (RuntimeException JavaDoc x) {
359                 throw x;
360             } catch (ModuleException x) {
361                 throw x;
362             } catch (Exception JavaDoc x) {
363                 throw new ModuleException(x);
364             }
365
366             // We close the RegistrationStatus by accepting
367
// and remove it from the pending ones.
368
registrationStatus.accept(User.getUser(pm, getPrincipal()));
369             localOrganisation.removePendingRegistration(applicantOrganisationID);
370
371         } finally {
372             pm.close();
373         }
374     }
375
376     /**
377      * @ejb.interface-method
378      * @ejb.transaction type = "Required"
379      * @ejb.permission role-name="OrganisationManager-write"
380      **/

381     public void rejectRegistration(String JavaDoc applicantOrganisationID)
382         throws ModuleException
383     {
384         PersistenceManager pm = getPersistenceManager();
385         try {
386             LocalOrganisation localOrganisation = LocalOrganisation.getLocalOrganisation(pm);
387             
388             RegistrationStatus registrationStatus = localOrganisation
389                     .getPendingRegistration(applicantOrganisationID);
390
391             if (registrationStatus == null)
392                 throw new IllegalArgumentException JavaDoc("There is no pending registration for applicantOrganisation \""+applicantOrganisationID+"\" at grantOrganisation \""+getOrganisationID()+"\"!");
393
394             try {
395                 // Now, we notify the other organisation that its request has been
396
// rejected.
397
OrganisationManager organisationManager = OrganisationManagerUtil.getHome(getInitialContextProps(applicantOrganisationID)).create();
398                 organisationManager.notifyRejectRegistration(registrationStatus.getRegistrationID());
399                 // Because notifyRejectRegistration drops our user remotely, we cannot execute
400
// any command there anymore - not even remove the bean.
401
// organisationManager.remove();
402
} catch (RuntimeException JavaDoc x) {
403                 throw x;
404             } catch (ModuleException x) {
405                 throw x;
406             } catch (Exception JavaDoc x) {
407                 throw new ModuleException(x);
408             }
409
410             // We close the RegistrationStatus by rejecting
411
// and remove it from the pending ones.
412
registrationStatus.reject(User.getUser(pm, getPrincipal()));
413             localOrganisation.removePendingRegistration(applicantOrganisationID);
414         } finally {
415             pm.close();
416         }
417     }
418
419     /**
420      * @ejb.interface-method
421      * @ejb.transaction type = "Required"
422      * @ejb.permission role-name="OrganisationManager-write"
423      **/

424     public void cancelRegistration(String JavaDoc grantOrganisationID)
425         throws ModuleException
426     {
427         PersistenceManager pm = getPersistenceManager();
428         try {
429             LocalOrganisation localOrganisation = LocalOrganisation.getLocalOrganisation(pm);
430             RegistrationStatus registrationStatus = localOrganisation.getPendingRegistration(grantOrganisationID);
431             if (registrationStatus == null)
432                 throw new IllegalArgumentException JavaDoc("There is no pending registration for grantOrganisation \""+grantOrganisationID+"\" at applicantOrganisation \""+getOrganisationID()+"\"!");
433
434             try {
435                 // Create the initial context properties to connect to the remote server.
436
Properties JavaDoc props = new Properties JavaDoc();
437                 props.put(InitialContext.INITIAL_CONTEXT_FACTORY, registrationStatus.getInitialContextFactory());
438                 props.put(InitialContext.PROVIDER_URL, registrationStatus.getInitialContextURL());
439
440                 // Obtain the OrganisationLinker EJB and request registration
441
OrganisationLinker organisationLinker = OrganisationLinkerUtil.getHome(props).create();
442                 organisationLinker.cancelRegistration(
443                         registrationStatus.getRegistrationID(),
444                         getOrganisationID(), grantOrganisationID);
445                 organisationLinker.remove();
446             } catch (ModuleException e) {
447                 throw e;
448             } catch (Exception JavaDoc e) {
449                 throw new ModuleException(e);
450             }
451
452             // Delete the user we previously created.
453
User user = User.getUser(
454                     pm, getOrganisationID(),
455                     User.USERID_PREFIX_TYPE_ORGANISATION + grantOrganisationID);
456             pm.deletePersistent(user);
457
458             // We close the RegistrationStatus by cancelling
459
// and remove it from the pending ones.
460
registrationStatus.cancel(User.getUser(pm, getPrincipal()));
461             localOrganisation.removePendingRegistration(grantOrganisationID);
462         } finally {
463             pm.close();
464         }
465     }
466
467     /**
468      * This method is called by a client. It is the first step to make two
469      * organisations know each other. It creates a user for the new organisation
470      * and requests to be registered at the other organisation.
471      *
472      * @ejb.interface-method
473      * @ejb.transaction type = "Required"
474      * @ejb.permission role-name="OrganisationManager-write"
475      **/

476     public void beginRegistration(
477             String JavaDoc initialContextFactory, String JavaDoc initialContextURL, String JavaDoc organisationID)
478         throws ModuleException
479     {
480         String JavaDoc registrationID = getOrganisationID()
481                 + '-' + Long.toHexString(System.currentTimeMillis())
482                 + '-' + Integer.toHexString((int)Math.round(Integer.MAX_VALUE * Math.random()));
483
484         // fetch and detach our local organisation (containing the local server)
485
Organisation myOrganisation;
486         PersistenceManager pm = getPersistenceManager();
487         try {
488             LocalOrganisation localOrganisation = LocalOrganisation.getLocalOrganisation(pm);
489
490             // We need to find out, whether the applicant organisation has already
491
// been successfully registered (status accepted).
492
// If there is currently a pending registration, it will be cancelled.
493
RegistrationStatus.ensureRegisterability(
494                     pm, localOrganisation, organisationID);
495
496             pm.getFetchPlan().addGroup(FetchPlan.ALL);
497             myOrganisation = (Organisation) pm.detachCopy(localOrganisation.getOrganisation());
498
499             RegistrationStatus registrationStatus = new RegistrationStatus(
500                     registrationID,
501                     organisationID, User.getUser(pm, getPrincipal()),
502                     initialContextFactory, initialContextURL);
503
504             localOrganisation.addPendingRegistration(registrationStatus);
505             
506             // We have to create a user for the new organisation. Therefore,
507
// generate a password with a random length between 8 and 16 characters.
508
String JavaDoc usrPassword = User.generatePassword(8, 16);
509
510             try {
511                 // Create the user if it doesn't yet exist
512
String JavaDoc userID = User.USERID_PREFIX_TYPE_ORGANISATION + organisationID;
513                 try {
514                     User user = User.getUser(pm, getOrganisationID(), userID);
515                     user.setPasswordPlain(usrPassword); // set the new password, if the user already exists
516
} catch (JDOObjectNotFoundException x) {
517                     // Create the user
518
UserManager userManager = UserManagerUtil.getHome().create();
519                     User user = new User(userID);
520                     user.setPassword(usrPassword);
521                     userManager.saveUser(user);
522                     userManager.remove();
523                 }
524     
525                 // Create the initial context properties to connect to the remote server.
526
Properties JavaDoc props = new Properties JavaDoc();
527                 props.put(InitialContext.INITIAL_CONTEXT_FACTORY, initialContextFactory);
528                 props.put(InitialContext.PROVIDER_URL, initialContextURL);
529     
530                 // Obtain the OrganisationLinker EJB and request registration
531
OrganisationLinker organisationLinker = OrganisationLinkerUtil.getHome(props).create();
532                 organisationLinker.requestRegistration(registrationID, myOrganisation, organisationID, usrPassword);
533                 organisationLinker.remove();
534     
535             } catch (ModuleException e) {
536                 throw e;
537             } catch (Exception JavaDoc e) {
538                 throw new ModuleException(e);
539             }
540         } finally {
541             pm.close();
542         }
543     }
544     
545     /**
546      * This method is called by a client. After we began a registration and
547      * the partner has either rejected or accepted, we still have the
548      * RegistrationStatus in the list of pending registrations. This
549      * is for the user to recognize that the other organisation has reacted
550      * and what this reaction was (accept or reject).
551      *
552      * @ejb.interface-method
553      * @ejb.transaction type = "Required"
554      * @ejb.permission role-name="OrganisationManager-write"
555      **/

556     public void ackRegistration(
557             String JavaDoc grantOrganisationID)
558         throws ModuleException
559     {
560         PersistenceManager pm = getPersistenceManager();
561         try {
562             LocalOrganisation localOrganisation = LocalOrganisation.getLocalOrganisation(pm);
563             RegistrationStatus registrationStatus = localOrganisation.getPendingRegistration(grantOrganisationID);
564             if (registrationStatus == null)
565                 throw new IllegalArgumentException JavaDoc("There is no pending registration for grantOrganisation \""+grantOrganisationID+"\" at applicantOrganisation \""+getOrganisationID()+"\"!");
566
567             if (registrationStatus.getCloseDT() == null)
568                 throw new IllegalArgumentException JavaDoc("The registration for grantOrganisation \""+grantOrganisationID+"\" at applicantOrganisation \""+getOrganisationID()+"\" is still open and has neither been rejected nor accepted!");
569
570             localOrganisation.removePendingRegistration(grantOrganisationID);
571         } finally {
572             pm.close();
573         }
574     }
575     
576     /**
577      * @ejb.interface-method
578      * @ejb.transaction type = "Required"
579      * @ejb.permission role-name="_Guest_"
580      **/

581     public void testBackhand(String JavaDoc[] organisationIDs)
582         throws ModuleException
583     {
584         LOGGER.info("testBackhand ("+organisationIDs.length+"): begin: principal="+getPrincipalString());
585         if (organisationIDs != null && organisationIDs.length > 0) {
586             String JavaDoc organisationID = organisationIDs[0];
587             String JavaDoc[] bhOrgaIDs = new String JavaDoc[organisationIDs.length - 1];
588             for (int i = 1; i < organisationIDs.length; ++i) {
589                 bhOrgaIDs[i-1] = organisationIDs[i];
590             }
591
592 // String username;
593
// String password;
594
// PersistenceManager pm = getPersistenceManager();
595
// try {
596
// LocalOrganisation localOrganisation = LocalOrganisation.getLocalOrganisation(pm);
597
//
598
// password = localOrganisation.getPassword(organisationID);
599
//
600
// username = User.USERID_PREFIX_TYPE_ORGANISATION
601
// + localOrganisation.getOrganisationID()
602
// + '@'
603
// + organisationID;
604
// } finally {
605
// pm.close();
606
// }
607

608             LOGGER.info("testBackhand ("+organisationIDs.length+"): backhanding to organisation \""+organisationID+"\"");
609             try {
610                 LOGGER.info("testBackhand ("+organisationIDs.length+"): OrganisationManagerUtil.getHome(...)");
611                 OrganisationManager organisationManager = OrganisationManagerUtil.getHome(getInitialContextProps(organisationID)).create();
612                 
613                 LOGGER.info("testBackhand ("+organisationIDs.length+"): UserManagerUtil.getHome()");
614                 UserManagerHome userManagerHome = UserManagerUtil.getHome();
615                 
616                 LOGGER.info("testBackhand ("+organisationIDs.length+"): userManagerHome.create()");
617                 UserManager userManager = userManagerHome.create();
618
619                 LOGGER.info("testBackhand ("+organisationIDs.length+"): organisationManager.testBackhand(...)");
620                 organisationManager.testBackhand(bhOrgaIDs);
621
622                 LOGGER.info("testBackhand ("+organisationIDs.length+"): userManager.whoami()");
623                 userManager.whoami();
624
625                 organisationManager.remove();
626                 userManager.remove();
627             } catch (RuntimeException JavaDoc e) {
628                 throw e;
629             } catch (ModuleException e) {
630                 throw e;
631             } catch (Exception JavaDoc e) {
632                 throw new ModuleException(e);
633             }
634         }
635         LOGGER.info("testBackhand ("+organisationIDs.length+"): end: principal="+getPrincipalString());
636     }
637
638 // /**
639
// * This method returns all organisations that the current organisation knows.
640
// *
641
// * @return a Collection of instances of type Organisation
642
// *
643
// * @ejb.interface-method
644
// */
645
// public Collection getOrganisations()
646
// {
647
// PersistenceManager pm = persistenceManagerFactory.getPersistenceManager();
648
//
649
// Collection organisations = new HashSet();
650
// for (Iterator it = pm.getExtent(Organisation.class, true).iterator(); it.hasNext(); ) {
651
// Organisation o = (Organisation) it.next();
652
// pm.retrieve(o.getServer());
653
// pm.makeTransient(o);
654
// pm.makeTransient(o.getServer());
655
// organisations.add(o);
656
// }
657
//
658
// pm.close();
659
//
660
// return organisations;
661
// }
662

663 }
Popular Tags