View Javadoc

1   /*
2    * <cvs:source>$Source: /devel/astrogrid/community/common/src/java/org/astrogrid/community/common/ivorn/CommunityServiceIvornFactory.java,v $</cvs:source>
3    * <cvs:author>$Author: dave $</cvs:author>
4    * <cvs:date>$Date: 2004/09/16 23:18:08 $</cvs:date>
5    * <cvs:version>$Revision: 1.5 $</cvs:version>
6    *
7    * <cvs:log>
8    *   $Log: CommunityServiceIvornFactory.java,v $
9    *   Revision 1.5  2004/09/16 23:18:08  dave
10   *   Replaced debug logging in Community.
11   *   Added stream close() to FileStore.
12   *
13   *   Revision 1.4.82.1  2004/09/16 09:58:48  dave
14   *   Replaced debug with commons logging ....
15   *
16   *   Revision 1.4  2004/06/18 13:45:20  dave
17   *   Merged development branch, dave-dev-200406081614, into HEAD
18   *
19   *   Revision 1.3.36.2  2004/06/17 14:50:01  dave
20   *   Removed unused imports (PMD report).
21   *
22   *   Revision 1.3.36.1  2004/06/17 13:38:58  dave
23   *   Tidied up old CVS log entries
24   *
25   * </cvs:log>
26   *
27   */
28  package org.astrogrid.community.common.ivorn ;
29  
30  import java.net.URISyntaxException ;
31  
32  import org.astrogrid.store.Ivorn ;
33  
34  import org.astrogrid.common.ivorn.MockIvorn ;
35  import org.astrogrid.community.common.exception.CommunityIdentifierException ;
36  
37  /***
38   * A factory for generating Community Service identifiers.
39   *
40   */
41  public class CommunityServiceIvornFactory
42      extends CommunityIvornFactory
43      {
44  
45      /***
46       * Create a community service Ivorn.
47       * @param community The Community ident, with no extra fields.
48       * @param service   The Java class of the service interface we want.
49       * @return A new Ivorn, or null if the Community ident is null.
50       * @throws CommunityIdentifierException If the identifiers are not valid.
51       *
52       */
53      public static Ivorn createIvorn(String community, Class service)
54          throws CommunityIdentifierException
55          {
56          if (null == community)
57          	{
58          	throw new CommunityIdentifierException(
59          		"Null Community identifier"
60          		) ;
61          	}
62          if (null == service)
63          	{
64          	throw new CommunityIdentifierException(
65          		"Null service type"
66          		) ;
67          	}
68          try {
69              return new Ivorn(
70                  createIdent(
71                      community,
72                      service.getName()
73                      )
74                  ) ;
75              }
76          catch (URISyntaxException ouch)
77              {
78              throw new CommunityIdentifierException(
79                  ouch
80                  ) ;
81              }
82          }
83  
84      /***
85       * Create a mock service Ivorn.
86       * @param community The Community ident, with no extra fields.
87       * @param service   The Java class of the service interface we want.
88       * @return A new Ivorn, or null if the Community ident is null.
89       * @throws CommunityIdentifierException If the identifiers are not valid.
90       *
91       */
92      public static Ivorn createMock(String community, Class service)
93          throws CommunityIdentifierException
94          {
95          if (null == community)
96          	{
97          	throw new CommunityIdentifierException(
98          		"Null Community identifier"
99          		) ;
100         	}
101         if (null == service)
102         	{
103         	throw new CommunityIdentifierException(
104         		"Null service type"
105         		) ;
106         	}
107         try {
108             return new MockIvorn(
109                 createIdent(
110                     community,
111                     service.getName()
112                     )
113                 ) ;
114             }
115         catch (URISyntaxException ouch)
116             {
117             throw new CommunityIdentifierException(
118                 ouch
119                 ) ;
120             }
121         }
122     }