View Javadoc

1   /*
2    * <cvs:source>$Source: /devel/astrogrid/community/client/src/java/org/astrogrid/community/client/policy/manager/PolicyManagerCoreDelegate.java,v $</cvs:source>
3    * <cvs:author>$Author: jdt $</cvs:author>
4    * <cvs:date>$Date: 2004/11/22 13:03:04 $</cvs:date>
5    * <cvs:version>$Revision: 1.11 $</cvs:version>
6    *
7    * <cvs:log>
8    *   $Log: PolicyManagerCoreDelegate.java,v $
9    *   Revision 1.11  2004/11/22 13:03:04  jdt
10   *   Merges from Comm_KMB_585
11   *
12   *
13   *   Revision 1.9.18.1.4.4  2004/11/12 09:12:09  KevinBenson
14   *   Still need to javadoc and check exceptions on a couple of new methods
15   *   for ResourceManager and PermissionManager, but for the most part it is ready.
16   *   I will also add some stylesheets around the jsp pages later.
17   *
18   *   Revision 1.9.18.1.4.3  2004/11/10 12:28:54  KevinBenson
19   *   needed to add throw exceptions
20   *
21   *   Revision 1.9.18.1.4.2  2004/11/08 22:08:21  KevinBenson
22   *   added groupmember and permissionmanager tests.  Changed the install.xml to use eperate file names
23   *   instead of the same filename
24   *
25   *   Revision 1.9.18.1.4.1  2004/11/05 08:55:49  KevinBenson
26   *   Moved the GroupMember out of PolicyManager in the commons and client section.
27   *   Added more unit tests for GroupMember and PermissionManager for testing.
28   *   Still have some errors that needs some fixing.
29   *
30   *   Revision 1.10  2004/10/29 15:50:05  jdt
31   *   merges from Community_AdminInterface (bug 579)
32   *
33   *   Revision 1.9.18.1  2004/10/18 22:10:28  KevinBenson
34   *   some bug fixes to the PermissionManager.  Also made it throw some exceptions.
35   *   Made  it and GroupManagerImnpl use the Resolver objects to actually get a group(PermissionManageriMnpl)
36   *   or account (GroupMember) from the other community.  Changed also for it to grab a ResourceData from the
37   *   database to verifity it is in our database.  Add a few of these resolver dependencies as well.
38   *   And last but not least fixed the GroupMemberData object to get rid of a few set methods so Castor
39   *   will now work correctly in Windows
40   *
41   *   Revision 1.9  2004/09/16 23:18:08  dave
42   *   Replaced debug logging in Community.
43   *   Added stream close() to FileStore.
44   *
45   *   Revision 1.8.82.1  2004/09/16 09:58:48  dave
46   *   Replaced debug with commons logging ....
47   *
48   *   Revision 1.8  2004/06/18 13:45:19  dave
49   *   Merged development branch, dave-dev-200406081614, into HEAD
50   *
51   *   Revision 1.7.32.3  2004/06/17 15:10:03  dave
52   *   Removed unused imports (PMD report).
53   *
54   *   Revision 1.7.32.2  2004/06/17 13:38:58  dave
55   *   Tidied up old CVS log entries
56   *
57   * </cvs:log>
58   *
59   */
60  package org.astrogrid.community.client.policy.manager ;
61  
62  import org.apache.commons.logging.Log ;
63  import org.apache.commons.logging.LogFactory ;
64  
65  import java.rmi.RemoteException ;
66  
67  import org.astrogrid.community.client.service.CommunityServiceCoreDelegate ;
68  
69  import org.astrogrid.community.common.policy.data.AccountData ;
70  import org.astrogrid.community.common.policy.data.GroupData ;
71  import org.astrogrid.community.common.policy.data.ResourceData ;
72  import org.astrogrid.community.common.policy.data.PolicyPermission ;
73  import org.astrogrid.community.common.policy.data.GroupMemberData ;
74  
75  import org.astrogrid.community.common.policy.manager.PolicyManager ;
76  
77  import org.astrogrid.community.common.exception.CommunityPolicyException     ;
78  import org.astrogrid.community.common.exception.CommunityServiceException    ;
79  import org.astrogrid.community.common.exception.CommunityResourceException   ;
80  import org.astrogrid.community.common.exception.CommunityIdentifierException ;
81  
82  
83  /***
84   * The core delegate for our PolicyManager service.
85   * This acts as a wrapper for a PolicyManager service, and converts RemoteExceptions into CommunityServiceException.
86   * @todo Refactor this as a number of smaller classes.
87   *
88   */
89  public class PolicyManagerCoreDelegate
90      extends CommunityServiceCoreDelegate
91      implements PolicyManager, PolicyManagerDelegate
92      {
93      /***
94       * Our debug logger.
95       *
96       */
97      private static Log log = LogFactory.getLog(PolicyManagerCoreDelegate.class);
98  
99      /***
100      * Public constructor.
101      *
102      */
103     protected PolicyManagerCoreDelegate()
104         {
105         }
106 
107     /***
108      * Our PolicyManager service.
109      *
110      */
111     private PolicyManager manager = null ;
112 
113     /***
114      * Get a reference to our PolicyManager service.
115      *
116      */
117     protected PolicyManager getPolicyManager()
118         {
119         return this.manager ;
120         }
121 
122     /***
123      * Set our our PolicyManager service.
124      *
125      */
126     protected void setPolicyManager(PolicyManager manager)
127         {
128         this.setCommunityService(manager) ;
129         this.manager = manager ;
130         }
131 
132     /***
133      * Add a new Account, given the Account ident.
134      * @param  ident The Account identifier.
135      * @return An AccountData for the Account.
136      * @throws CommunityIdentifierException If the identifier is not valid.
137      * @throws CommunityPolicyException If the identifier is already in the database.
138      * @throws CommunityServiceException If there is an internal error in the service.
139      *
140      */
141     public AccountData addAccount(String ident)
142         throws CommunityServiceException, CommunityIdentifierException, CommunityPolicyException
143         {
144         //
145         // If we have a valid service reference.
146         if (null != this.manager)
147             {
148             //
149             // Try calling the service method.
150             try {
151                 return this.manager.addAccount(ident) ;
152                 }
153             //
154             // Catch anything that went BANG.
155             catch (RemoteException ouch)
156                 {
157                 //
158                 // Try converting the Exception.
159                 policyException(ouch) ;
160                 serviceException(ouch) ;
161                 identifierException(ouch) ;
162                 //
163                 // If we get this far, then we don't know what it is.
164                 throw new CommunityServiceException(
165                     "WebService call failed - " + ouch,
166                     ouch
167                     ) ;
168                 }
169             }
170         //
171         // If we don't have a valid service.
172         else {
173             throw new CommunityServiceException(
174                 "Service not initialised"
175                 ) ;
176             }
177         }
178 
179     /***
180      * Add a new Account, given the Account data.
181      * @param  account The AccountData to add.
182      * @return A new AccountData for the Account.
183      * @throws CommunityIdentifierException If the identifier is not valid.
184      * @throws CommunityPolicyException If the identifier is already in the database.
185      * @throws CommunityServiceException If there is an internal error in the service.
186      *
187      */
188     public AccountData addAccount(AccountData account)
189         throws CommunityServiceException, CommunityIdentifierException, CommunityPolicyException
190         {
191         //
192         // If we have a valid service reference.
193         if (null != this.manager)
194             {
195             //
196             // Try calling the service method.
197             try {
198                 return this.manager.addAccount(account) ;
199                 }
200             //
201             // Catch anything that went BANG.
202             catch (RemoteException ouch)
203                 {
204                 //
205                 // Try converting the Exception.
206                 policyException(ouch) ;
207                 serviceException(ouch) ;
208                 identifierException(ouch) ;
209                 //
210                 // If we get this far, then we don't know what it is.
211                 throw new CommunityServiceException(
212                     "WebService call failed - " + ouch,
213                     ouch
214                     ) ;
215                 }
216             }
217         //
218         // If we don't have a valid service.
219         else {
220             throw new CommunityServiceException(
221                 "Service not initialised"
222                 ) ;
223             }
224         }
225 
226     /***
227      * Request an Account details, given the Account ident.
228      * @param  ident The Account identifier.
229      * @return An AccountData for the Account.
230      * @throws CommunityIdentifierException If the identifier is not valid.
231      * @throws CommunityPolicyException If the identifier is not in the database.
232      * @throws CommunityServiceException If there is an internal error in the service.
233      *
234      */
235     public AccountData getAccount(String ident)
236         throws CommunityServiceException, CommunityIdentifierException, CommunityPolicyException
237         {
238         //
239         // If we have a valid service reference.
240         if (null != this.manager)
241             {
242             //
243             // Try calling the service method.
244             try {
245                 return this.manager.getAccount(ident) ;
246                 }
247             //
248             // Catch anything that went BANG.
249             catch (RemoteException ouch)
250                 {
251                 //
252                 // Try converting the Exception.
253                 policyException(ouch) ;
254                 serviceException(ouch) ;
255                 identifierException(ouch) ;
256                 //
257                 // If we get this far, then we don't know what it is.
258                 throw new CommunityServiceException(
259                     "WebService call failed - " + ouch,
260                     ouch
261                     ) ;
262                 }
263             }
264         //
265         // If we don't have a valid service.
266         else {
267             throw new CommunityServiceException(
268                 "Service not initialised"
269                 ) ;
270             }
271         }
272 
273     /***
274      * Update an Account.
275      * @param  account The new AccountData to update.
276      * @return A new AccountData for the Account.
277      * @throws CommunityIdentifierException If the identifier is not valid.
278      * @throws CommunityPolicyException If the identifier is not in the database.
279      * @throws CommunityServiceException If there is an internal error in the service.
280      *
281      */
282     public AccountData setAccount(AccountData account)
283         throws CommunityServiceException, CommunityIdentifierException, CommunityPolicyException
284         {
285         //
286         // If we have a valid service reference.
287         if (null != this.manager)
288             {
289             //
290             // Try calling the service method.
291             try {
292                 return this.manager.setAccount(account) ;
293                 }
294             //
295             // Catch anything that went BANG.
296             catch (RemoteException ouch)
297                 {
298                 //
299                 // Try converting the Exception.
300                 policyException(ouch) ;
301                 serviceException(ouch) ;
302                 identifierException(ouch) ;
303                 //
304                 // If we get this far, then we don't know what it is.
305                 throw new CommunityServiceException(
306                     "WebService call failed - " + ouch,
307                     ouch
308                     ) ;
309                 }
310             }
311         //
312         // If we don't have a valid service.
313         else {
314             throw new CommunityServiceException(
315                 "Service not initialised"
316                 ) ;
317             }
318         }
319 
320     /***
321      * Delete an Account.
322      * @param  ident The Account identifier.
323      * @return The AccountData for the old Account.
324      * @throws CommunityIdentifierException If the identifier is not valid.
325      * @throws CommunityPolicyException If the identifier is not in the database.
326      * @throws CommunityServiceException If there is an internal error in the service.
327      *
328      */
329     public AccountData delAccount(String ident)
330         throws CommunityServiceException, CommunityIdentifierException, CommunityPolicyException
331         {
332         //
333         // If we have a valid service reference.
334         if (null != this.manager)
335             {
336             //
337             // Try calling the service method.
338             try {
339                 return this.manager.delAccount(ident) ;
340                 }
341             //
342             // Catch anything that went BANG.
343             catch (RemoteException ouch)
344                 {
345                 //
346                 // Try converting the Exception.
347                 policyException(ouch) ;
348                 serviceException(ouch) ;
349                 identifierException(ouch) ;
350                 //
351                 // If we get this far, then we don't know what it is.
352                 throw new CommunityServiceException(
353                     "WebService call failed - " + ouch,
354                     ouch
355                     ) ;
356                 }
357             }
358         //
359         // If we don't have a valid service.
360         else {
361             throw new CommunityServiceException(
362                 "Service not initialised"
363                 ) ;
364             }
365         }
366 
367     /***
368      * Request a list of local Accounts.
369      * @return An array of AccountData objects.
370      * @throws CommunityServiceException If there is an internal error in the service.
371      *
372      */
373     public Object[] getLocalAccounts()
374         throws CommunityServiceException
375         {
376         //
377         // If we have a valid service reference.
378         if (null != this.manager)
379             {
380             //
381             // Try calling the service method.
382             try {
383                 return this.manager.getLocalAccounts() ;
384                 }
385             //
386             // Catch anything that went BANG.
387             catch (RemoteException ouch)
388                 {
389                 //
390                 // Try converting the Exception.
391                 serviceException(ouch) ;
392                 //
393                 // If we get this far, then we don't know what it is.
394                 throw new CommunityServiceException(
395                     "WebService call failed - " + ouch,
396                     ouch
397                     ) ;
398                 }
399             }
400         //
401         // If we don't have a valid service.
402         else {
403             throw new CommunityServiceException(
404                 "Service not initialised"
405                 ) ;
406             }
407         }
408 
409     /***
410      * Add a new Group.
411      * @param  ident The Group identifier.
412      * @return A GroupData for the Group.
413      * @throws CommunityIdentifierException If the identifier is not valid.
414      * @throws CommunityPolicyException If the identifier is already in the database.
415      * @throws CommunityServiceException If there is an internal error in the service.
416      *
417      */
418     public GroupData addGroup(String ident)
419         throws CommunityServiceException, CommunityIdentifierException, CommunityPolicyException
420         {
421         //
422         // If we have a valid service reference.
423         if (null != this.manager)
424             {
425             //
426             // Try calling the service method.
427             try {
428                 return this.manager.addGroup(ident) ;
429                 }
430             //
431             // Catch anything that went BANG.
432             catch (RemoteException ouch)
433                 {
434                 //
435                 // Try converting the Exception.
436                 policyException(ouch) ;
437                 serviceException(ouch) ;
438                 identifierException(ouch) ;
439                 //
440                 // If we get this far, then we don't know what it is.
441                 throw new CommunityServiceException(
442                     "WebService call failed - " + ouch,
443                     ouch
444                     ) ;
445                 }
446             }
447         //
448         // If we don't have a valid service.
449         else {
450             throw new CommunityServiceException(
451                 "Service not initialised"
452                 ) ;
453             }
454         }
455 
456     /***
457      * Add a new Group.
458      * @param  group The GroupData to add.
459      * @return A new GroupData for the Group.
460      * @throws CommunityIdentifierException If the identifier is not valid.
461      * @throws CommunityPolicyException If the identifier is already in the database.
462      * @throws CommunityServiceException If there is an internal error in the service.
463      *
464      */
465     public GroupData addGroup(GroupData data)
466         throws CommunityServiceException, CommunityIdentifierException, CommunityPolicyException
467         {
468         //
469         // If we have a valid service reference.
470         if (null != this.manager)
471             {
472             //
473             // Try calling the service method.
474             try {
475                 return this.manager.addGroup(data) ;
476                 }
477             //
478             // Catch anything that went BANG.
479             catch (RemoteException ouch)
480                 {
481                 //
482                 // Try converting the Exception.
483                 policyException(ouch) ;
484                 serviceException(ouch) ;
485                 identifierException(ouch) ;
486                 //
487                 // If we get this far, then we don't know what it is.
488                 throw new CommunityServiceException(
489                     "WebService call failed - " + ouch,
490                     ouch
491                     ) ;
492                 }
493             }
494         //
495         // If we don't have a valid service.
496         else {
497             throw new CommunityServiceException(
498                 "Service not initialised"
499                 ) ;
500             }
501         }
502 
503     /***
504      * Request a Group details.
505      * @param  ident The Group identifier.
506      * @return A GroupData for the Group.
507      * @throws CommunityIdentifierException If the identifier is not valid.
508      * @throws CommunityPolicyException If the identifier is not in the database.
509      * @throws CommunityServiceException If there is an internal error in the service.
510      *
511      */
512     public GroupData getGroup(String ident)
513         throws CommunityServiceException, CommunityIdentifierException, CommunityPolicyException
514         {
515         //
516         // If we have a valid service reference.
517         if (null != this.manager)
518             {
519             //
520             // Try calling the service method.
521             try {
522                 return this.manager.getGroup(ident) ;
523                 }
524             //
525             // Catch anything that went BANG.
526             catch (RemoteException ouch)
527                 {
528                 //
529                 // Try converting the Exception.
530                 policyException(ouch) ;
531                 serviceException(ouch) ;
532                 identifierException(ouch) ;
533                 //
534                 // If we get this far, then we don't know what it is.
535                 throw new CommunityServiceException(
536                     "WebService call failed - " + ouch,
537                     ouch
538                     ) ;
539                 }
540             }
541         //
542         // If we don't have a valid service.
543         else {
544             throw new CommunityServiceException(
545                 "Service not initialised"
546                 ) ;
547             }
548         }
549 
550     /***
551      * Update a Group.
552      * @param  data The new GroupData to update.
553      * @return A new GroupData for the Group.
554      * @throws CommunityIdentifierException If the identifier is not valid.
555      * @throws CommunityPolicyException If the identifier is not in the database.
556      * @throws CommunityServiceException If there is an internal error in the service.
557      *
558      */
559     public GroupData setGroup(GroupData data)
560         throws CommunityServiceException, CommunityIdentifierException, CommunityPolicyException
561         {
562         //
563         // If we have a valid service reference.
564         if (null != this.manager)
565             {
566             //
567             // Try calling the service method.
568             try {
569                 return this.manager.setGroup(data) ;
570                 }
571             //
572             // Catch anything that went BANG.
573             catch (RemoteException ouch)
574                 {
575                 //
576                 // Try converting the Exception.
577                 policyException(ouch) ;
578                 serviceException(ouch) ;
579                 identifierException(ouch) ;
580                 //
581                 // If we get this far, then we don't know what it is.
582                 throw new CommunityServiceException(
583                     "WebService call failed - " + ouch,
584                     ouch
585                     ) ;
586                 }
587             }
588         //
589         // If we don't have a valid service.
590         else {
591             throw new CommunityServiceException(
592                 "Service not initialised"
593                 ) ;
594             }
595         }
596 
597     /***
598      * Delete a Group.
599      * @param  ident The Group identifier.
600      * @return The GroupData for the old Group.
601      * @throws CommunityIdentifierException If the identifier is not valid.
602      * @throws CommunityPolicyException If the identifier is not in the database.
603      * @throws CommunityServiceException If there is an internal error in the service.
604      *
605      */
606     public GroupData delGroup(String ident)
607         throws CommunityServiceException, CommunityIdentifierException, CommunityPolicyException 
608         {
609         //
610         // If we have a valid service reference.
611         if (null != this.manager)
612             {
613             //
614             // Try calling the service method.
615             try {
616                 return this.manager.delGroup(ident) ;
617                 }
618             //
619             // Catch anything that went BANG.
620             catch (RemoteException ouch)
621                 {
622                 //
623                 // Try converting the Exception.
624                 policyException(ouch) ;
625                 serviceException(ouch) ;
626                 identifierException(ouch) ;
627                 //
628                 // If we get this far, then we don't know what it is.
629                 throw new CommunityServiceException(
630                     "WebService call failed - " + ouch,
631                     ouch
632                     ) ;
633                 }
634             }
635         //
636         // If we don't have a valid service.
637         else {
638             throw new CommunityServiceException(
639                 "Service not initialised"
640                 ) ;
641             }
642         }
643 
644     /***
645      * Request a list of local Groups.
646      * @return An array of GroupData objects.
647      * @throws CommunityServiceException If there is an internal error in the service.
648      *
649      */
650     public Object[] getLocalGroups()
651         throws CommunityServiceException
652         {
653         //
654         // If we have a valid service reference.
655         if (null != this.manager)
656             {
657             //
658             // Try calling the service method.
659             try {
660                 return this.manager.getLocalGroups() ;
661                 }
662             //
663             // Catch anything that went BANG.
664             catch (RemoteException ouch)
665                 {
666                 //
667                 // Try converting the Exception.
668                 serviceException(ouch) ;
669                 //
670                 // If we get this far, then we don't know what it is.
671                 throw new CommunityServiceException(
672                     "WebService call failed - " + ouch,
673                     ouch
674                     ) ;
675                 }
676             }
677         //
678         // If we don't have a valid service.
679         else {
680             throw new CommunityServiceException(
681                 "Service not initialised"
682                 ) ;
683             }
684         }
685 
686     /***
687      * Request a list of local Groups that an Account belongs to, given the Account ident.
688      * @param  account The Account ifentifier.
689      * @return An array of GroupData objects.
690      * @throws CommunityServiceException If there is an internal error in the service.
691      *
692      */
693     public Object[] getLocalAccountGroups(String account)
694         throws CommunityServiceException, CommunityIdentifierException
695         {
696         //
697         // If we have a valid service reference.
698         if (null != this.manager)
699             {
700             //
701             // Try calling the service method.
702             try {
703                 return this.manager.getLocalAccountGroups(account) ;
704                 }
705             //
706             // Catch anything that went BANG.
707             catch (RemoteException ouch)
708                 {
709                 //
710                 // Try converting the Exception.
711                 serviceException(ouch) ;
712                 identifierException(ouch) ;
713                 //
714                 // If we get this far, then we don't know what it is.
715                 throw new CommunityServiceException(
716                     "WebService call failed - " + ouch,
717                     ouch
718                     ) ;
719                 }
720             }
721         //
722         // If we don't have a valid service.
723         else {
724             throw new CommunityServiceException(
725                 "Service not initialised"
726                 ) ;
727             }
728         }
729 
730     /***
731      * Register a new Resource.
732      * @return A new ResourceData object to represent the resource.
733      * @throws CommunityServiceException If there is an internal error in the service.
734      *
735      */
736     public ResourceData addResource()
737         throws CommunityServiceException
738         {
739         //
740         // If we have a valid service reference.
741         if (null != this.manager)
742             {
743             //
744             // Try calling the service method.
745             try {
746                 return this.manager.addResource() ;
747                 }
748             //
749             // Catch anything that went BANG.
750             catch (RemoteException ouch)
751                 {
752                 //
753                 // Try converting the Exception.
754                 serviceException(ouch) ;
755                 //
756                 // If we get this far, then we don't know what it is.
757                 throw new CommunityServiceException(
758                     "WebService call failed - " + ouch,
759                     ouch
760                     ) ;
761                 }
762             }
763         //
764         // If we don't have a valid service.
765         else {
766             throw new CommunityServiceException(
767                 "Service not initialised"
768                 ) ;
769             }
770         }
771 
772     /***
773      * Request the details for a Resource.
774      * @param The resource identifier.
775      * @return The requested ResourceData object.
776      * @throws CommunityResourceException If unable to locate the resource.
777      * @throws CommunityServiceException If there is an internal error in the service.
778      * @throws CommunityIdentifierException If the resource identifier is not valid.
779      *
780      */
781    public ResourceData getResource(String ident)
782         throws CommunityIdentifierException, CommunityResourceException, CommunityServiceException
783         {
784         //
785         // If we have a valid service reference.
786         if (null != this.manager)
787             {
788             //
789             // Try calling the service method.
790             try {
791                 return this.manager.getResource(ident) ;
792                 }
793             //
794             // Catch anything that went BANG.
795             catch (RemoteException ouch)
796                 {
797                 //
798                 // Try converting the Exception.
799                 serviceException(ouch) ;
800                 resourceException(ouch) ;
801                 identifierException(ouch) ;
802                 //
803                 // If we get this far, then we don't know what it is.
804                 throw new CommunityServiceException(
805                     "WebService call failed - " + ouch,
806                     ouch
807                     ) ;
808                 }
809             }
810         //
811         // If we don't have a valid service.
812         else {
813             throw new CommunityServiceException(
814                 "Service not initialised"
815                 ) ;
816             }
817         }
818    
819    /***
820     * Request the details for a Resource.
821     * @param The resource identifier.
822     * @return The requested ResourceData object.
823     * @throws CommunityResourceException If unable to locate the resource.
824     * @throws CommunityServiceException If there is an internal error in the service.
825     * @throws CommunityIdentifierException If the resource identifier is not valid.
826     *
827     */
828    public Object[] getResources()
829        {
830        //
831        // If we have a valid service reference.
832        if (null != this.manager)
833            {
834            //
835            // Try calling the service method.
836            try {
837                return this.manager.getResources() ;
838                }
839            //
840            // Catch anything that went BANG.
841            catch (RemoteException ouch)
842                {
843                //
844                // Try converting the Exception.
845                //serviceException(ouch) ;
846                //resourceException(ouch) ;
847                //identifierException(ouch) ;
848                }
849        }
850            return null;
851    }
852    
853 
854     /***
855      * Update the details for a Resource.
856      * @param The ResourceData to update.
857      * @return The updated ResourceData.
858      * @throws CommunityResourceException If unable to locate the resource.
859      * @throws CommunityServiceException If there is an internal error in the service.
860      * @throws CommunityIdentifierException If the resource identifier is not valid.
861      *
862      */
863     public ResourceData setResource(ResourceData resource)
864         throws CommunityIdentifierException, CommunityResourceException, CommunityServiceException
865         {
866         //
867         // If we have a valid service reference.
868         if (null != this.manager)
869             {
870             //
871             // Try calling the service method.
872             try {
873                 return this.manager.setResource(resource) ;
874                 }
875             //
876             // Catch anything that went BANG.
877             catch (RemoteException ouch)
878                 {
879                 //
880                 // Try converting the Exception.
881                 serviceException(ouch) ;
882                 resourceException(ouch) ;
883                 identifierException(ouch) ;
884                 //
885                 // If we get this far, then we don't know what it is.
886                 throw new CommunityServiceException(
887                     "WebService call failed - " + ouch,
888                     ouch
889                     ) ;
890                 }
891             }
892         //
893         // If we don't have a valid service.
894         else {
895             throw new CommunityServiceException(
896                 "Service not initialised"
897                 ) ;
898             }
899         }
900 
901     /***
902      * Delete a Resource.
903      * @param The resource identifier.
904      * @return The original ResourceData.
905      * @throws CommunityResourceException If unable to locate the resource.
906      * @throws CommunityServiceException If there is an internal error in the service.
907      * @throws CommunityIdentifierException If the identifier is not valid.
908      *
909      */
910     public ResourceData delResource(String ident)
911         throws CommunityIdentifierException, CommunityResourceException, CommunityServiceException
912         {
913         //
914         // If we have a valid service reference.
915         if (null != this.manager)
916             {
917             //
918             // Try calling the service method.
919             try {
920                 return this.manager.delResource(ident) ;
921                 }
922             //
923             // Catch anything that went BANG.
924             catch (RemoteException ouch)
925                 {
926                 //
927                 // Try converting the Exception.
928                 serviceException(ouch) ;
929                 resourceException(ouch) ;
930                 identifierException(ouch) ;
931                 //
932                 // If we get this far, then we don't know what it is.
933                 throw new CommunityServiceException(
934                     "WebService call failed - " + ouch,
935                     ouch
936                     ) ;
937                 }
938             }
939         //
940         // If we don't have a valid service.
941         else {
942             throw new CommunityServiceException(
943                 "Service not initialised"
944                 ) ;
945             }
946         }
947 
948     /***
949      * Create a new PolicyPermission.
950      * @todo Better Exception handling.
951      *
952      */
953     public PolicyPermission addPermission(String resource, String group, String action)
954         throws CommunityServiceException, CommunityIdentifierException, CommunityPolicyException
955         {
956         PolicyPermission result = null ;
957         //
958         // If we have a valid service reference.
959         if (null != this.manager)
960             {
961             //
962             // Try calling the service method.
963             try {
964                 result = this.manager.addPermission(resource, group, action) ;
965                 }
966             //
967             // Catch anything that went BANG.
968             catch (RemoteException ouch)
969                 {
970                 //
971                 // Unpack the RemoteException, and re-throw the real Exception.
972                 //
973                 }
974             }
975         return result ;
976         }
977 
978     /***
979      * Request a PolicyPermission.
980      * @todo Better Exception handling.
981      *
982      */
983     public PolicyPermission getPermission(String resource, String group, String action)
984         throws CommunityServiceException, CommunityIdentifierException, CommunityPolicyException    
985         {
986         PolicyPermission result = null ;
987         //
988         // If we have a valid service reference.
989         if (null != this.manager)
990             {
991             //
992             // Try calling the service method.
993             try {
994                 result = this.manager.getPermission(resource, group, action) ;
995                 }
996             //
997             // Catch anything that went BANG.
998             catch (RemoteException ouch)
999                 {
1000                 //
1001                 // Unpack the RemoteException, and re-throw the real Exception.
1002                 //
1003                 }
1004             }
1005         return result ;
1006         }
1007     
1008     /***
1009      * Request a PolicyPermission.
1010      * @todo Better Exception handling.
1011      *
1012      */
1013     public Object[] getPermissions()    
1014         {
1015         Object[] result = null ;
1016         //
1017         // If we have a valid service reference.
1018         if (null != this.manager)
1019             {
1020             //
1021             // Try calling the service method.
1022             try {
1023                 result = this.manager.getPermissions();
1024                 }
1025             //
1026             // Catch anything that went BANG.
1027             catch (RemoteException ouch)
1028                 {
1029                 //
1030                 // Unpack the RemoteException, and re-throw the real Exception.
1031                 //
1032                 }
1033             }
1034         return result ;
1035      }
1036     
1037 
1038     /***
1039      * Update a PolicyPermission.
1040      * @todo Better Exception handling.
1041      *
1042      */
1043     public PolicyPermission setPermission(PolicyPermission permission)
1044         throws CommunityServiceException, CommunityIdentifierException, CommunityPolicyException
1045         {
1046         PolicyPermission result = null ;
1047         //
1048         // If we have a valid service reference.
1049         if (null != this.manager)
1050             {
1051             //
1052             // Try calling the service method.
1053             try {
1054                 result = this.manager.setPermission(permission) ;
1055                 }
1056             //
1057             // Catch anything that went BANG.
1058             catch (RemoteException ouch)
1059                 {
1060                 //
1061                 // Unpack the RemoteException, and re-throw the real Exception.
1062                 //
1063                 }
1064             }
1065         return result ;
1066         }
1067 
1068     /***
1069      * Delete a PolicyPermission.
1070      * @todo Better Exception handling.
1071      *
1072      */
1073     public boolean delPermission(String resource, String group, String action)
1074        throws CommunityServiceException, CommunityIdentifierException, CommunityPolicyException
1075         {
1076         boolean result = false ;
1077         //
1078         // If we have a valid service reference.
1079         if (null != this.manager)
1080             {
1081             //
1082             // Try calling the service method.
1083             try {
1084                 result = this.manager.delPermission(resource, group, action) ;
1085                 }
1086             //
1087             // Catch anything that went BANG.
1088             catch (RemoteException ouch)
1089                 {
1090                 //
1091                 // Unpack the RemoteException, and re-throw the real Exception.
1092                 //
1093                 }
1094             }
1095         return result ;
1096         }
1097 
1098     /***
1099      * Add an Account to a Group.
1100      * The group must be local, but Account can be local or remote.
1101      * @param  account The Account identifier.
1102      * @param  group   The Group identifier.
1103      * @return An GroupMemberData to confirm the membership.
1104      * @throws CommunityIdentifierException If one of the identifiers is not valid.
1105      * @throws CommunityPolicyException If one the identifiers is not in the database.
1106      * @throws CommunityServiceException If there is an internal error in the service.
1107      *
1108      */
1109     public GroupMemberData addGroupMember(String account, String group)
1110         throws CommunityServiceException, CommunityIdentifierException, CommunityPolicyException
1111         {
1112         //
1113         // If we have a valid service reference.
1114         if (null != this.manager)
1115             {
1116             //
1117             // Try calling the service method.
1118             try {
1119                 return this.manager.addGroupMember(account, group) ;
1120                 }
1121             //
1122             // Catch anything that went BANG.
1123             catch (RemoteException ouch)
1124                 {
1125                 //
1126                 // Try converting the Exception.
1127                 policyException(ouch) ;
1128                 serviceException(ouch) ;
1129                 identifierException(ouch) ;
1130                 //
1131                 // If we get this far, then we don't know what it is.
1132                 throw new CommunityServiceException(
1133                     "WebService call failed - " + ouch,
1134                     ouch
1135                     ) ;
1136                 }
1137             }
1138         //
1139         // If we don't have a valid service.
1140         else {
1141             throw new CommunityServiceException(
1142                 "Service not initialised"
1143                 ) ;
1144             }
1145         }
1146 
1147     /***
1148      * Remove an Account from a Group.
1149      * The group must be local, but Account can be local or remote.
1150      * @param  account The Account identifier.
1151      * @param  group   The Group identifier.
1152      * @return A GroupMemberData to confirm the membership.
1153      * @throws CommunityIdentifierException If one of the identifiers is not valid.
1154      * @throws CommunityPolicyException If one the identifiers is not in the database.
1155      * @throws CommunityServiceException If there is an internal error in the service.
1156      *
1157      */
1158     public GroupMemberData delGroupMember(String account, String group)
1159         throws CommunityServiceException, CommunityPolicyException, CommunityIdentifierException
1160         {
1161         //
1162         // If we have a valid service reference.
1163         if (null != this.manager)
1164             {
1165             //
1166             // Try calling the service method.
1167             try {
1168                 return this.manager.delGroupMember(account, group) ;
1169                 }
1170             //
1171             // Catch anything that went BANG.
1172             catch (RemoteException ouch)
1173                 {
1174                 //
1175                 // Try converting the Exception.
1176                 policyException(ouch) ;
1177                 serviceException(ouch) ;
1178                 identifierException(ouch) ;
1179                 //
1180                 // If we get this far, then we don't know what it is.
1181                 throw new CommunityServiceException(
1182                     "WebService call failed - " + ouch,
1183                     ouch
1184                     ) ;
1185                 }
1186             }
1187         //
1188         // If we don't have a valid service.
1189         else {
1190             throw new CommunityServiceException(
1191                 "Service not initialised"
1192                 ) ;
1193             }
1194         }
1195 
1196     /***
1197      * Request a list of Group members.
1198      * The group must be local.
1199      * @param  group   The Group identifier.
1200      * @return An array of GroupMemberData objects..
1201      * @throws CommunityIdentifierException If one of the identifiers is not valid.
1202      * @throws CommunityPolicyException If one the identifiers is not in the database.
1203      * @throws CommunityServiceException If there is an internal error in the service.
1204      *
1205      */
1206     public Object[] getGroupMembers(String group)
1207         throws CommunityServiceException, CommunityPolicyException, CommunityIdentifierException
1208         {
1209         //
1210         // If we have a valid service reference.
1211         if (null != this.manager)
1212             {
1213             //
1214             // Try calling the service method.
1215             try {
1216                 return this.manager.getGroupMembers(group) ;
1217                 }
1218             //
1219             // Catch anything that went BANG.
1220             catch (RemoteException ouch)
1221                 {
1222                 //
1223                 // Try converting the Exception.
1224                 policyException(ouch) ;
1225                 serviceException(ouch) ;
1226                 identifierException(ouch) ;
1227                 //
1228                 // If we get this far, then we don't know what it is.
1229                 throw new CommunityServiceException(
1230                     "WebService call failed - " + ouch,
1231                     ouch
1232                     ) ;
1233                 }
1234             }
1235         //
1236         // If we don't have a valid service.
1237         else {
1238             throw new CommunityServiceException(
1239                 "Service not initialised"
1240                 ) ;
1241             }
1242         }
1243     
1244     /***
1245      * Request a list of Group members.
1246      * The group must be local.
1247      * @param  group   The Group identifier.
1248      * @return An array of GroupMemberData objects..
1249      * @throws CommunityIdentifierException If one of the identifiers is not valid.
1250      * @throws CommunityPolicyException If one the identifiers is not in the database.
1251      * @throws CommunityServiceException If there is an internal error in the service.
1252      *
1253      */
1254     public GroupMemberData getGroupMember(String account, String group)
1255         throws CommunityServiceException, CommunityPolicyException, CommunityIdentifierException
1256         {
1257         //
1258         // If we have a valid service reference.
1259         if (null != this.manager)
1260             {
1261             //
1262             // Try calling the service method.
1263             try {
1264                 return this.manager.getGroupMember(account,group) ;
1265                 }
1266             //
1267             // Catch anything that went BANG.
1268             catch (RemoteException ouch)
1269                 {
1270                 //
1271                 // Try converting the Exception.
1272                 policyException(ouch) ;
1273                 serviceException(ouch) ;
1274                 identifierException(ouch) ;
1275                 //
1276                 // If we get this far, then we don't know what it is.
1277                 throw new CommunityServiceException(
1278                     "WebService call failed - " + ouch,
1279                     ouch
1280                     ) ;
1281                 }
1282             }
1283         //
1284         // If we don't have a valid service.
1285         else {
1286             throw new CommunityServiceException(
1287                 "Service not initialised"
1288                 ) ;
1289             }
1290         }    
1291     
1292     /***
1293      * Request a list of Group members.
1294      * The group must be local.
1295      * @param  group   The Group identifier.
1296      * @return An array of GroupMemberData objects..
1297      * @throws CommunityIdentifierException If one of the identifiers is not valid.
1298      * @throws CommunityPolicyException If one the identifiers is not in the database.
1299      * @throws CommunityServiceException If there is an internal error in the service.
1300      *
1301      */
1302     public Object[] getGroupMembers()
1303         throws CommunityServiceException, CommunityPolicyException, CommunityIdentifierException
1304         {
1305         //
1306         // If we have a valid service reference.
1307         if (null != this.manager)
1308             {
1309             //
1310             // Try calling the service method.
1311             try {
1312                 return this.manager.getGroupMembers() ;
1313                 }
1314             //
1315             // Catch anything that went BANG.
1316             catch (RemoteException ouch)
1317                 {
1318                 //
1319                 // Try converting the Exception.
1320                 policyException(ouch) ;
1321                 serviceException(ouch) ;
1322                 identifierException(ouch) ;
1323                 //
1324                 // If we get this far, then we don't know what it is.
1325                 throw new CommunityServiceException(
1326                     "WebService call failed - " + ouch,
1327                     ouch
1328                     ) ;
1329                 }
1330             }
1331         //
1332         // If we don't have a valid service.
1333         else {
1334             throw new CommunityServiceException(
1335                 "Service not initialised"
1336                 ) ;
1337             }
1338         }
1339     
1340     
1341     }