1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.fosstrak.epcis.repository.query;
22
23 import org.fosstrak.epcis.model.ArrayOfString;
24 import org.fosstrak.epcis.model.EmptyParms;
25 import org.fosstrak.epcis.model.GetSubscriptionIDs;
26 import org.fosstrak.epcis.model.ImplementationException;
27 import org.fosstrak.epcis.model.ImplementationExceptionSeverity;
28 import org.fosstrak.epcis.model.Poll;
29 import org.fosstrak.epcis.model.QueryResults;
30 import org.fosstrak.epcis.model.Subscribe;
31 import org.fosstrak.epcis.model.Unsubscribe;
32 import org.fosstrak.epcis.model.VoidHolder;
33 import org.fosstrak.epcis.repository.EpcisQueryControlInterface;
34 import org.fosstrak.epcis.soap.DuplicateSubscriptionExceptionResponse;
35 import org.fosstrak.epcis.soap.EPCISServicePortType;
36 import org.fosstrak.epcis.soap.ImplementationExceptionResponse;
37 import org.fosstrak.epcis.soap.InvalidURIExceptionResponse;
38 import org.fosstrak.epcis.soap.NoSuchNameExceptionResponse;
39 import org.fosstrak.epcis.soap.NoSuchSubscriptionExceptionResponse;
40 import org.fosstrak.epcis.soap.QueryParameterExceptionResponse;
41 import org.fosstrak.epcis.soap.QueryTooComplexExceptionResponse;
42 import org.fosstrak.epcis.soap.QueryTooLargeExceptionResponse;
43 import org.fosstrak.epcis.soap.SecurityExceptionResponse;
44 import org.fosstrak.epcis.soap.SubscribeNotPermittedExceptionResponse;
45 import org.fosstrak.epcis.soap.SubscriptionControlsExceptionResponse;
46 import org.fosstrak.epcis.soap.ValidationExceptionResponse;
47 import org.apache.commons.logging.Log;
48 import org.apache.commons.logging.LogFactory;
49
50
51
52
53
54
55
56
57 public class QueryOperationsWebService implements EPCISServicePortType {
58
59 private static final Log LOG = LogFactory.getLog(QueryOperationsWebService.class);
60
61 private EpcisQueryControlInterface queryModule;
62
63 public QueryOperationsWebService() {
64 }
65
66 public QueryOperationsWebService(EpcisQueryControlInterface queryModule) {
67 this.queryModule = queryModule;
68 }
69
70
71
72
73 public ArrayOfString getQueryNames(EmptyParms empty) throws ImplementationExceptionResponse,
74 SecurityExceptionResponse, ValidationExceptionResponse {
75 ArrayOfString aos = new ArrayOfString();
76 aos.getString().addAll(queryModule.getQueryNames());
77 return aos;
78 }
79
80
81
82
83 public String getStandardVersion(EmptyParms empty) throws ImplementationExceptionResponse,
84 SecurityExceptionResponse, ValidationExceptionResponse {
85 return queryModule.getStandardVersion();
86 }
87
88
89
90
91 public ArrayOfString getSubscriptionIDs(GetSubscriptionIDs req) throws ImplementationExceptionResponse,
92 SecurityExceptionResponse, ValidationExceptionResponse, NoSuchNameExceptionResponse {
93 ArrayOfString aos = new ArrayOfString();
94 aos.getString().addAll(queryModule.getSubscriptionIDs(req.getQueryName()));
95 return aos;
96 }
97
98
99
100
101 public String getVendorVersion(EmptyParms empty) throws ImplementationExceptionResponse, SecurityExceptionResponse,
102 ValidationExceptionResponse {
103 return queryModule.getVendorVersion();
104 }
105
106
107
108
109 public QueryResults poll(Poll poll) throws ImplementationExceptionResponse, QueryTooComplexExceptionResponse,
110 QueryTooLargeExceptionResponse, SecurityExceptionResponse, ValidationExceptionResponse,
111 NoSuchNameExceptionResponse, QueryParameterExceptionResponse {
112
113 try {
114 return queryModule.poll(poll.getQueryName(), poll.getParams());
115 } catch (ImplementationExceptionResponse e) {
116 throw e;
117 } catch (QueryTooComplexExceptionResponse e) {
118 throw e;
119 } catch (QueryTooLargeExceptionResponse e) {
120 throw e;
121 } catch (SecurityExceptionResponse e) {
122 throw e;
123 } catch (ValidationExceptionResponse e) {
124 throw e;
125 } catch (NoSuchNameExceptionResponse e) {
126 throw e;
127 } catch (QueryParameterExceptionResponse e) {
128 throw e;
129 } catch (Exception e) {
130 String msg = "Unexpected error occurred while processing request";
131 LOG.error(msg, e);
132 ImplementationException ie = new ImplementationException();
133 ie.setReason(msg);
134 ie.setSeverity(ImplementationExceptionSeverity.ERROR);
135 if (poll != null) {
136 ie.setQueryName(poll.getQueryName());
137 }
138 throw new ImplementationExceptionResponse(msg, ie, e);
139 }
140 }
141
142
143
144
145 public VoidHolder subscribe(Subscribe subscribe) throws DuplicateSubscriptionExceptionResponse,
146 ImplementationExceptionResponse, QueryTooComplexExceptionResponse, SecurityExceptionResponse,
147 InvalidURIExceptionResponse, ValidationExceptionResponse, SubscribeNotPermittedExceptionResponse,
148 NoSuchNameExceptionResponse, SubscriptionControlsExceptionResponse, QueryParameterExceptionResponse {
149
150 try {
151 queryModule.subscribe(subscribe.getQueryName(), subscribe.getParams(), subscribe.getDest(),
152 subscribe.getControls(), subscribe.getSubscriptionID());
153 return new VoidHolder();
154 } catch (DuplicateSubscriptionExceptionResponse e) {
155 throw e;
156 } catch (ImplementationExceptionResponse e) {
157 throw e;
158 } catch (QueryTooComplexExceptionResponse e) {
159 throw e;
160 } catch (SecurityExceptionResponse e) {
161 throw e;
162 } catch (InvalidURIExceptionResponse e) {
163 throw e;
164 } catch (ValidationExceptionResponse e) {
165 throw e;
166 } catch (SubscribeNotPermittedExceptionResponse e) {
167 throw e;
168 } catch (NoSuchNameExceptionResponse e) {
169 throw e;
170 } catch (SubscriptionControlsExceptionResponse e) {
171 throw e;
172 } catch (QueryParameterExceptionResponse e) {
173 throw e;
174 } catch (Exception e) {
175 String msg = "Unknown error occurred while processing request";
176 LOG.error(msg, e);
177 ImplementationException ie = new ImplementationException();
178 ie.setReason(msg);
179 ie.setSeverity(ImplementationExceptionSeverity.ERROR);
180 if (subscribe != null) {
181 ie.setQueryName(subscribe.getQueryName());
182 ie.setSubscriptionID(subscribe.getSubscriptionID());
183 }
184 throw new ImplementationExceptionResponse(msg, ie, e);
185 }
186 }
187
188
189
190
191 public VoidHolder unsubscribe(Unsubscribe unsubscribe) throws ImplementationExceptionResponse,
192 SecurityExceptionResponse, ValidationExceptionResponse, NoSuchSubscriptionExceptionResponse {
193
194 try {
195 queryModule.unsubscribe(unsubscribe.getSubscriptionID());
196 return new VoidHolder();
197 } catch (ImplementationExceptionResponse e) {
198 throw e;
199 } catch (SecurityExceptionResponse e) {
200 throw e;
201 } catch (NoSuchSubscriptionExceptionResponse e) {
202 throw e;
203 } catch (Exception e) {
204 String msg = "Unknown error occurred while processing request";
205 LOG.error(msg, e);
206 ImplementationException ie = new ImplementationException();
207 ie.setReason(msg);
208 ie.setSeverity(ImplementationExceptionSeverity.ERROR);
209 if (unsubscribe != null) {
210 ie.setSubscriptionID(unsubscribe.getSubscriptionID());
211 }
212 throw new ImplementationExceptionResponse(msg, ie, e);
213 }
214 }
215
216
217
218
219 public EpcisQueryControlInterface getQueryModule() {
220 return queryModule;
221 }
222
223
224
225
226
227 public void setQueryModule(EpcisQueryControlInterface queryModule) {
228 this.queryModule = queryModule;
229 }
230
231 }