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.wsrf.impl;
36
37 import java.util.Properties;
38
39 import org.apache.muse.util.xml.XmlUtils;
40 import org.apache.muse.ws.addressing.soap.SoapFault;
41 import org.apache.xmlbeans.XmlException;
42 import org.ogf.graap.wsag.api.WsagConstants;
43 import org.ogf.graap.wsag.api.exceptions.ResourceUnavailableException;
44 import org.ogf.graap.wsag.api.exceptions.ResourceUnknownException;
45 import org.ogf.graap.wsag.api.security.ISecurityProperties;
46 import org.ogf.graap.wsag.client.remote.WsrfResourceClient;
47 import org.ogf.graap.wsag.wsrf.AgreementAcceptanceClient;
48 import org.ogf.schemas.graap.wsAgreement.AcceptAgreementResponseDocument;
49 import org.ogf.schemas.graap.wsAgreement.RejectAgreementResponseDocument;
50 import org.w3.x2005.x08.addressing.EndpointReferenceType;
51 import org.w3c.dom.Element;
52
53
54
55
56
57
58
59 public class RemoteAgreementAcceptanceClientImpl implements AgreementAcceptanceClient
60 {
61
62 private WsrfResourceClient client;
63
64
65
66
67
68
69
70
71
72 public RemoteAgreementAcceptanceClientImpl( EndpointReferenceType epr,
73 ISecurityProperties securityProperties )
74 {
75 this( new WsrfResourceClient( epr, securityProperties ) );
76 }
77
78 private RemoteAgreementAcceptanceClientImpl( WsrfResourceClient client )
79 {
80 this.client = client;
81 }
82
83
84
85
86 public void accept() throws ResourceUnknownException, ResourceUnavailableException
87 {
88 try
89 {
90 Element inputType = XmlUtils.createElement( WsagConstants.WSAG_ACCEPT_AGREEMENT_INPUT_QNAME );
91 Element body = XmlUtils.createElement( WsagConstants.WSAG_ACCEPT_AGREEMENT_QNAME );
92 body.appendChild( body.getOwnerDocument().importNode( inputType, true ) );
93 Element response = client.invoke( WsagConstants.WSAG_ACCEPT_AGREEMENT_ACTION, body );
94
95 AcceptAgreementResponseDocument respDoc =
96 AcceptAgreementResponseDocument.Factory.parse( response );
97 respDoc.getAcceptAgreementResponse();
98 }
99 catch ( SoapFault e )
100 {
101 throw new ResourceUnavailableException( e );
102 }
103 catch ( XmlException e )
104 {
105 throw new ResourceUnavailableException( e );
106 }
107 catch ( Exception e )
108 {
109 throw new ResourceUnavailableException( e );
110 }
111 }
112
113
114
115
116 public void reject() throws ResourceUnknownException, ResourceUnavailableException
117 {
118 try
119 {
120 Element inputType = XmlUtils.createElement( WsagConstants.WSAG_REJECT_AGREEMENT_INPUT_QNAME );
121 Element body = XmlUtils.createElement( WsagConstants.WSAG_REJECT_AGREEMENT_QNAME );
122 body.appendChild( body.getOwnerDocument().importNode( inputType, true ) );
123 Element response = client.invoke( WsagConstants.WSAG_REJECT_AGREEMENT_ACTION, body );
124
125 RejectAgreementResponseDocument respDoc =
126 RejectAgreementResponseDocument.Factory.parse( response );
127 respDoc.getRejectAgreementResponse();
128 }
129 catch ( SoapFault e )
130 {
131 throw new ResourceUnavailableException( e );
132 }
133 catch ( XmlException e )
134 {
135 throw new ResourceUnavailableException( e );
136 }
137 catch ( Exception e )
138 {
139 throw new ResourceUnavailableException( e );
140 }
141 }
142
143
144
145
146 public EndpointReferenceType getEndpoint()
147 {
148 return client.getEndpoint();
149 }
150
151
152
153
154 public Properties getProperties()
155 {
156 return client.getProperties();
157 }
158
159
160
161
162 public ISecurityProperties getSecurityProperties()
163 {
164 return client.getSecurityProperties();
165 }
166
167
168
169
170 public boolean isUsingTrace()
171 {
172 return client.isUsingTrace();
173 }
174
175
176
177
178 public void setProperties( Properties properties )
179 {
180 client.setProperties( properties );
181 }
182
183
184
185
186 public void setTrace( boolean trace )
187 {
188 client.setTrace( trace );
189 }
190
191 }