View Javadoc

1   /*
2    * <cvs:source>$Source: /devel/astrogrid/community/common/src/java/org/astrogrid/community/common/ivorn/CommunityAccountIvornFactory.java,v $</cvs:source>
3    * <cvs:author>$Author: dave $</cvs:author>
4    * <cvs:date>$Date: 2004/06/18 13:45:20 $</cvs:date>
5    * <cvs:version>$Revision: 1.5 $</cvs:version>
6    *
7    * <cvs:log>
8    *   $Log: CommunityAccountIvornFactory.java,v $
9    *   Revision 1.5  2004/06/18 13:45:20  dave
10   *   Merged development branch, dave-dev-200406081614, into HEAD
11   *
12   *   Revision 1.4.32.2  2004/06/17 14:50:01  dave
13   *   Removed unused imports (PMD report).
14   *
15   *   Revision 1.4.32.1  2004/06/17 13:38:58  dave
16   *   Tidied up old CVS log entries
17   *
18   * </cvs:log>
19   *
20   */
21  package org.astrogrid.community.common.ivorn ;
22  
23  import java.net.URISyntaxException ;
24  
25  import org.astrogrid.store.Ivorn ;
26  import org.astrogrid.common.ivorn.MockIvorn ;
27  
28  import org.astrogrid.community.common.exception.CommunityServiceException ;
29  import org.astrogrid.community.common.exception.CommunityIdentifierException ;
30  
31  /***
32   * A factory for generating Community Account identifiers.
33   *
34   */
35  public class CommunityAccountIvornFactory
36      extends CommunityIvornFactory
37      {
38      /***
39       * Create a local Community Account Ivorn.
40       * @param account   The Account name, without the Community ident.
41       * @throws CommunityIdentifierException If the identifiers are not valid.
42       * @throws CommunityServiceException If the local Community identifier is not set.
43       *
44       */
45      public static Ivorn createLocal(String account)
46          throws CommunityServiceException, CommunityIdentifierException
47          {
48          return createIvorn(
49              CommunityIvornParser.getLocalIdent(),
50              account
51              ) ;
52          }
53  
54      /***
55       * Create a local Community Account Ivorn.
56       * @param account   The Account name, without the Community ident.
57       * @param resource  The resource, added after the account.
58       * @throws CommunityIdentifierException If the identifiers are not valid.
59       * @throws CommunityServiceException If the local Community identifier is not set.
60       *
61       */
62      public static Ivorn createLocal(String account, String resource)
63          throws CommunityServiceException, CommunityIdentifierException
64          {
65          return createIvorn(
66              CommunityIvornParser.getLocalIdent(),
67              account,
68              resource
69              ) ;
70          }
71  
72      /***
73       * Create a Community Account Ivorn.
74       * @param community The Community ident, with no extra fields.
75       * @param account   The Account name, without the Community ident.
76       * @throws CommunityIdentifierException If the identifiers are not valid.
77       *
78       */
79      public static Ivorn createIvorn(String community, String account)
80          throws CommunityIdentifierException
81          {
82          try {
83              return new Ivorn(
84                  createIdent(
85                      community,
86                      account
87                      )
88                  ) ;
89              }
90          catch (URISyntaxException ouch)
91              {
92              throw new CommunityIdentifierException(
93                  ouch
94                  ) ;
95              }
96          }
97  
98      /***
99       * Create a Community Account Ivorn.
100      * @param community The Community ident, with no extra fields.
101      * @param account   The Account name, without the Community ident.
102      * @param resource  The resource, added after the account.
103      * @throws CommunityIdentifierException If the identifiers are not valid.
104      *
105      */
106     public static Ivorn createIvorn(String community, String account, String resource)
107         throws CommunityIdentifierException
108         {
109         try {
110             return new Ivorn(
111                 createIdent(
112                     community,
113                     account,
114                     resource
115                     )
116                 ) ;
117             }
118         catch (URISyntaxException ouch)
119             {
120             throw new CommunityIdentifierException(
121                 ouch
122                 ) ;
123             }
124         }
125 
126     /***
127      * Create a mock Community Account Ivorn.
128      * @param community The Community ident, with no extra fields.
129      * @param account   The Account name, without the Community ident.
130      * @throws CommunityIdentifierException If the identifiers are not valid.
131      *
132      */
133     public static Ivorn createMock(String community, String account)
134         throws CommunityIdentifierException
135         {
136         try {
137             return new MockIvorn(
138                 community,
139                 account
140                 ) ;
141             }
142         catch (URISyntaxException ouch)
143             {
144             throw new CommunityIdentifierException(
145                 ouch
146                 ) ;
147             }
148         }
149     }