View Javadoc

1   /*
2    * <cvs:source>$Source: /devel/astrogrid/community/resolver/src/java/org/astrogrid/community/resolver/CommunityAccountResolver.java,v $</cvs:source>
3    * <cvs:author>$Author: jdt $</cvs:author>
4    * <cvs:date>$Date: 2004/10/29 15:50:05 $</cvs:date>
5    * <cvs:version>$Revision: 1.7 $</cvs:version>
6    *
7    * <cvs:log>
8    *   $Log: CommunityAccountResolver.java,v $
9    *   Revision 1.7  2004/10/29 15:50:05  jdt
10   *   merges from Community_AdminInterface (bug 579)
11   *
12   *   Revision 1.6.18.1  2004/10/18 22:10:28  KevinBenson
13   *   some bug fixes to the PermissionManager.  Also made it throw some exceptions.
14   *   Made  it and GroupManagerImnpl use the Resolver objects to actually get a group(PermissionManageriMnpl)
15   *   or account (GroupMember) from the other community.  Changed also for it to grab a ResourceData from the
16   *   database to verifity it is in our database.  Add a few of these resolver dependencies as well.
17   *   And last but not least fixed the GroupMemberData object to get rid of a few set methods so Castor
18   *   will now work correctly in Windows
19   *
20   *   Revision 1.6  2004/09/16 23:18:08  dave
21   *   Replaced debug logging in Community.
22   *   Added stream close() to FileStore.
23   *
24   *   Revision 1.5.82.1  2004/09/16 09:58:48  dave
25   *   Replaced debug with commons logging ....
26   *
27   *   Revision 1.5  2004/06/18 13:45:20  dave
28   *   Merged development branch, dave-dev-200406081614, into HEAD
29   *
30   *   Revision 1.4.32.1  2004/06/17 13:38:59  dave
31   *   Tidied up old CVS log entries
32   *
33   * </cvs:log>
34   *
35   */
36  package org.astrogrid.community.resolver ;
37  
38  import org.apache.commons.logging.Log ;
39  import org.apache.commons.logging.LogFactory ;
40  
41  import java.net.URL ;
42  import org.astrogrid.store.Ivorn ;
43  
44  import org.astrogrid.community.common.policy.data.AccountData ;
45  
46  import org.astrogrid.community.common.ivorn.CommunityIvornParser ;
47  import org.astrogrid.community.client.policy.manager.PolicyManagerDelegate ;
48  
49  import org.astrogrid.community.resolver.policy.manager.PolicyManagerResolver ;
50  
51  import org.astrogrid.registry.RegistryException;
52  import org.astrogrid.community.common.exception.CommunityPolicyException ;
53  import org.astrogrid.community.common.exception.CommunityServiceException ;
54  import org.astrogrid.community.common.exception.CommunityIdentifierException ;
55  import org.astrogrid.community.resolver.exception.CommunityResolverException ;
56  
57  /***
58   * A utility to resolve Ivorn identifiers into Community Account data.
59   *
60   */
61  public class CommunityAccountResolver
62      {
63      /***
64       * Our debug logger.
65       *
66       */
67      private static Log log = LogFactory.getLog(CommunityAccountResolver.class);
68  
69      /***
70       * Public constructor, using the default Registry service.
71       *
72       */
73      public CommunityAccountResolver()
74          {
75          resolver = new PolicyManagerResolver() ;
76          }
77  
78      /***
79       * Public constructor, for a specific Registry service.
80       * @param registry The endpoint address for our RegistryDelegate.
81       *
82       */
83      public CommunityAccountResolver(URL registry)
84          {
85          resolver = new PolicyManagerResolver(registry) ;
86          }
87  
88      /***
89       * Our PolicyManager resolver.
90       *
91       */
92      private PolicyManagerResolver resolver ;
93  
94      /***
95       * Resolve a Community identifier into an AccountData.
96       * @param ivorn The Community Account identifier.
97       * @return An AccountData for the Account.
98       * @throws CommunityPolicyException If the Community cannot locate the Account.
99       * @throws CommunityServiceException If an error occurs in the Community service.
100      * @throws CommunityIdentifierException If the identifier is not valid.
101      * @throws CommunityResolverException If the Community is unable to resolve the identifier.
102      * @throws RegistryException If the Registry is unable to resolve the identifier.
103      *
104      */
105     public AccountData resolve(Ivorn ivorn)
106         throws CommunityServiceException,
107             CommunityIdentifierException,
108             CommunityPolicyException,
109             CommunityResolverException,
110             RegistryException
111         {
112         log.debug("") ;
113         log.debug("----\"----") ;
114         log.debug("CommunityAccountResolver.resolve()") ;
115         log.debug("  Ivorn : " + ivorn) ;
116         //
117         // Check for null param.
118         if (null == ivorn)
119             {
120             throw new CommunityIdentifierException(
121                 "Null identifier"
122                 ) ;
123             }
124         //
125         // Parse the Ivorn and then resolve the result.
126         return resolve(
127             new CommunityIvornParser(ivorn)
128             ) ;
129         }
130 
131     /***
132      * Resolve a Community identifier into an AccountData.
133      * @param parser The Community Account identifier.
134      * @return An AccountData for the Account.
135      * @throws CommunityPolicyException If the Community cannot locate the Account.
136      * @throws CommunityServiceException If an error occurs in the Community service.
137      * @throws CommunityIdentifierException If the identifier is not valid.
138      * @throws CommunityResolverException If the Community is unable to resolve the identifier.
139      * @throws RegistryException If the Registry is unable to resolve the identifier.
140      *
141      */
142     public AccountData resolve(CommunityIvornParser parser)
143         throws CommunityServiceException,
144             CommunityIdentifierException,
145             CommunityPolicyException,
146             CommunityResolverException,
147             RegistryException
148         {
149         log.debug("") ;
150         log.debug("----\"----") ;
151         log.debug("CommunityAccountResolver.resolve()") ;
152         log.debug("  Ivorn : " + ((null != parser) ? parser.getIvorn() : null)) ;
153         //
154         // Check for null param.
155         if (null == parser)
156             {
157             throw new CommunityIdentifierException(
158                 "Null identifier"
159                 ) ;
160             }
161         //
162         // Resolve the ivorn into a PolicyManagerDelegate.
163         PolicyManagerDelegate delegate = resolver.resolve(parser) ;
164         //
165         // Ask the PolicyManagerDelegate for the AccountData.
166         return delegate.getAccount(
167             parser.getAccountIdent()
168             ) ;
169         }
170     }