1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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 }