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
29
30
31
32
33
34
35 package org.ogf.graap.wsag.client.impl;
36
37 import java.util.Properties;
38
39 import org.ogf.graap.wsag.api.AgreementOffer;
40 import org.ogf.graap.wsag.api.client.AgreementClient;
41 import org.ogf.graap.wsag.api.client.AgreementFactoryClient;
42 import org.ogf.graap.wsag.api.client.AgreementFactoryService;
43 import org.ogf.graap.wsag.api.client.AgreementRegistryService;
44 import org.ogf.graap.wsag.api.client.NegotiationClient;
45 import org.ogf.graap.wsag.api.client.WsClient;
46 import org.ogf.graap.wsag.api.exceptions.AgreementFactoryException;
47 import org.ogf.graap.wsag.api.exceptions.NegotiationFactoryException;
48 import org.ogf.graap.wsag.api.exceptions.ResourceUnavailableException;
49 import org.ogf.graap.wsag.api.exceptions.ResourceUnknownException;
50 import org.ogf.graap.wsag.api.security.ISecurityProperties;
51 import org.ogf.schemas.graap.wsAgreement.AgreementTemplateType;
52 import org.ogf.schemas.graap.wsAgreement.negotiation.NegotiationContextType;
53 import org.w3.x2005.x08.addressing.EndpointReferenceType;
54
55
56
57
58
59
60
61 public class AgreementFactoryFacade
62 implements AgreementFactoryClient
63 {
64
65
66
67
68 private final AgreementFactoryService factoryClient;
69
70
71
72
73 private final AgreementRegistryService registryClient;
74
75
76
77
78 private Properties properties = new Properties();
79
80
81
82
83 private final ISecurityProperties securityProperties;
84
85
86
87
88
89
90
91
92
93
94
95
96
97 public AgreementFactoryFacade( AgreementFactoryService factoryClient,
98 AgreementRegistryService registryClient,
99 ISecurityProperties securityProperties )
100 {
101 this.factoryClient = factoryClient;
102 this.registryClient = registryClient;
103 this.securityProperties = securityProperties;
104
105 factoryClient.getWebServiceClient().setProperties( properties );
106 registryClient.getWebServiceClient().setProperties( properties );
107 }
108
109
110
111
112
113
114 public AgreementTemplateType[] getTemplates()
115 throws ResourceUnknownException, ResourceUnavailableException
116 {
117 return factoryClient.getTemplates();
118 }
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137 public AgreementClient createAgreement( AgreementOffer offer )
138 throws AgreementFactoryException, ResourceUnknownException, ResourceUnavailableException
139 {
140 return factoryClient.createAgreement( offer );
141 }
142
143
144
145
146
147
148 public AgreementClient createPendingAgreement( AgreementOffer offer )
149 throws AgreementFactoryException, ResourceUnknownException, ResourceUnavailableException
150 {
151 return factoryClient.createPendingAgreement( offer );
152 }
153
154
155
156
157
158
159 public AgreementClient createPendingAgreement( AgreementOffer offer, EndpointReferenceType acceptanceEPR )
160 throws AgreementFactoryException, ResourceUnknownException, ResourceUnavailableException
161 {
162 return factoryClient.createPendingAgreement( offer, acceptanceEPR );
163 }
164
165
166
167
168
169
170 public NegotiationClient initiateNegotiation( NegotiationContextType context )
171 throws NegotiationFactoryException, ResourceUnknownException, ResourceUnavailableException
172 {
173 return factoryClient.initiateNegotiation( context );
174 }
175
176
177
178
179 public String getResourceId() throws ResourceUnknownException, ResourceUnavailableException
180 {
181 return factoryClient.getResourceId();
182 }
183
184
185
186
187
188
189
190 public AgreementTemplateType getTemplate( String name, String id )
191 throws ResourceUnknownException, ResourceUnavailableException
192 {
193 if ( name == null )
194 {
195 return null;
196 }
197
198 id = ( id != null ) ? id : "";
199
200 AgreementTemplateType[] templates = getTemplates();
201
202 for ( int i = 0; i < templates.length; i++ )
203 {
204 if ( name.equalsIgnoreCase( templates[i].getName() ) )
205 {
206
207 String actualId =
208 ( templates[i].getTemplateId() != null ) ? templates[i].getTemplateId() : "";
209
210 if ( id.equalsIgnoreCase( actualId ) )
211 {
212 return templates[i];
213 }
214 }
215 }
216
217 return null;
218 }
219
220
221
222
223
224
225
226
227
228 @Override
229 public AgreementFactoryClient clone() throws CloneNotSupportedException
230 {
231 return new AgreementFactoryFacade( factoryClient, registryClient, securityProperties.clone() );
232 }
233
234
235
236
237
238
239
240
241
242
243
244
245 public AgreementClient[] listAgreements() throws ResourceUnknownException, ResourceUnavailableException
246 {
247 return registryClient.listAgreements();
248 }
249
250
251
252
253
254
255
256 public void setTrace( boolean trace )
257 {
258 factoryClient.getWebServiceClient().setTrace( trace );
259 registryClient.getWebServiceClient().setTrace( trace );
260 }
261
262
263
264
265 public boolean isUsingTrace()
266 {
267 return factoryClient.getWebServiceClient().isUsingTrace()
268 && registryClient.getWebServiceClient().isUsingTrace();
269 }
270
271
272
273
274 public Properties getProperties()
275 {
276 return properties;
277 }
278
279
280
281
282
283 public void setProperties( Properties properties )
284 {
285 this.properties = properties;
286 factoryClient.getWebServiceClient().setProperties( properties );
287 registryClient.getWebServiceClient().setProperties( properties );
288 }
289
290
291
292
293 public EndpointReferenceType getEndpoint()
294 {
295 return factoryClient.getWebServiceClient().getEndpoint();
296 }
297
298
299
300
301 public ISecurityProperties getSecurityProperties()
302 {
303 return securityProperties;
304 }
305
306
307
308
309 public WsClient getWebServiceClient()
310 {
311 return this;
312 }
313
314
315
316
317 public AgreementFactoryService getAgreementFactoryClient()
318 {
319 return factoryClient;
320 }
321
322
323
324
325 public AgreementRegistryService getAgreementRegistryClient()
326 {
327 return registryClient;
328 }
329 }