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.remote;
36
37 import java.util.Properties;
38
39 import org.ogf.graap.wsag.api.AgreementOffer;
40 import org.ogf.graap.wsag.api.WsagConstants;
41 import org.ogf.graap.wsag.api.client.AgreementClient;
42 import org.ogf.graap.wsag.api.client.AgreementFactoryClient;
43 import org.ogf.graap.wsag.api.client.NegotiationClient;
44 import org.ogf.graap.wsag.api.client.WsClient;
45 import org.ogf.graap.wsag.api.exceptions.AgreementFactoryException;
46 import org.ogf.graap.wsag.api.exceptions.NegotiationFactoryException;
47 import org.ogf.graap.wsag.api.exceptions.ResourceUnavailableException;
48 import org.ogf.graap.wsag.api.exceptions.ResourceUnknownException;
49 import org.ogf.graap.wsag.api.security.ISecurityProperties;
50 import org.ogf.graap.wsag.client.impl.AgreementFactoryFacade;
51 import org.ogf.schemas.graap.wsAgreement.AgreementTemplateType;
52 import org.ogf.schemas.graap.wsAgreement.negotiation.NegotiationContextType;
53 import org.w3.x2005.x08.addressing.EndpointReferenceDocument;
54 import org.w3.x2005.x08.addressing.EndpointReferenceType;
55
56
57
58
59
60
61
62 public class RemoteAgreementFactoryClientImpl
63 implements AgreementFactoryClient
64 {
65
66 private AgreementFactoryFacade facade;
67
68
69
70
71
72
73
74
75
76
77 public RemoteAgreementFactoryClientImpl( EndpointReferenceType epr, ISecurityProperties securityProperties )
78 {
79
80 try
81 {
82
83
84
85 String factoryURI = epr.getAddress().getStringValue();
86 String registryURI =
87 factoryURI.substring( 0, factoryURI.indexOf( WsagConstants.AGREEMENT_FACTORY_SERVICE_URI ) )
88 + WsagConstants.AGREEMENT_REGISTRY_SERVICE_URI;
89
90 EndpointReferenceDocument registryEPR = EndpointReferenceDocument.Factory.newInstance();
91 registryEPR.addNewEndpointReference().addNewAddress().setStringValue( registryURI );
92 registryEPR.getEndpointReference().addNewReferenceParameters().set( epr.getReferenceParameters() );
93
94
95
96
97 RemoteAgreementFactoryServiceImpl factoryClient =
98 new RemoteAgreementFactoryServiceImpl( epr, securityProperties );
99 RemoteAgreementRegistryServiceImpl registryClient =
100 new RemoteAgreementRegistryServiceImpl( registryEPR.getEndpointReference(),
101 securityProperties );
102
103 facade = new AgreementFactoryFacade( factoryClient, registryClient, securityProperties );
104 }
105 catch ( Exception e )
106 {
107 throw new RuntimeException( e );
108 }
109
110 }
111
112
113
114
115 @Override
116 public AgreementFactoryClient clone() throws CloneNotSupportedException
117 {
118 return new RemoteAgreementFactoryClientImpl( getEndpoint(), getSecurityProperties().clone() );
119 }
120
121
122
123
124 public WsClient getWebServiceClient()
125 {
126 return facade.getWebServiceClient();
127 }
128
129
130
131
132 public AgreementClient createAgreement( AgreementOffer offer )
133 throws AgreementFactoryException, ResourceUnknownException, ResourceUnavailableException
134 {
135 return facade.createAgreement( offer );
136 }
137
138
139
140
141 public AgreementClient createPendingAgreement( AgreementOffer offer )
142 throws AgreementFactoryException, ResourceUnknownException, ResourceUnavailableException
143 {
144 return facade.createPendingAgreement( offer );
145 }
146
147
148
149
150 public AgreementClient createPendingAgreement( AgreementOffer offer, EndpointReferenceType acceptanceEPR )
151 throws AgreementFactoryException, ResourceUnknownException, ResourceUnavailableException
152 {
153 return facade.createPendingAgreement( offer, acceptanceEPR );
154 }
155
156
157
158
159 public EndpointReferenceType getEndpoint()
160 {
161 return facade.getEndpoint();
162 }
163
164
165
166
167 public Properties getProperties()
168 {
169 return facade.getProperties();
170 }
171
172
173
174
175 public String getResourceId() throws ResourceUnknownException, ResourceUnavailableException
176 {
177 return facade.getResourceId();
178 }
179
180
181
182
183 public ISecurityProperties getSecurityProperties()
184 {
185 return facade.getSecurityProperties();
186 }
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206 public AgreementTemplateType getTemplate( String name, String id )
207 throws ResourceUnknownException, ResourceUnavailableException
208 {
209 return facade.getTemplate( name, id );
210 }
211
212
213
214
215 public AgreementTemplateType[] getTemplates()
216 throws ResourceUnknownException, ResourceUnavailableException
217 {
218 return facade.getTemplates();
219 }
220
221
222
223
224 public boolean isUsingTrace()
225 {
226 return facade.isUsingTrace();
227 }
228
229
230
231
232 public AgreementClient[] listAgreements() throws ResourceUnknownException, ResourceUnavailableException
233 {
234 return facade.listAgreements();
235 }
236
237
238
239
240 public void setProperties( Properties properties )
241 {
242 facade.setProperties( properties );
243 }
244
245
246
247
248 public void setTrace( boolean trace )
249 {
250 facade.setTrace( trace );
251 }
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272 public NegotiationClient initiateNegotiation( NegotiationContextType context )
273 throws NegotiationFactoryException, ResourceUnknownException, ResourceUnavailableException
274 {
275 return facade.initiateNegotiation( context );
276 }
277
278 }