1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.apache.ws.scout.registry; |
17 | |
|
18 | |
import java.io.ByteArrayInputStream; |
19 | |
import java.io.ByteArrayOutputStream; |
20 | |
import java.io.IOException; |
21 | |
import java.io.StringReader; |
22 | |
import java.net.URI; |
23 | |
import java.net.URISyntaxException; |
24 | |
import java.security.AccessController; |
25 | |
import java.security.PrivilegedAction; |
26 | |
import java.util.Arrays; |
27 | |
import java.util.Properties; |
28 | |
|
29 | |
import javax.xml.bind.JAXBContext; |
30 | |
import javax.xml.bind.JAXBElement; |
31 | |
import javax.xml.bind.JAXBException; |
32 | |
import javax.xml.bind.Marshaller; |
33 | |
import javax.xml.bind.Unmarshaller; |
34 | |
import javax.xml.parsers.DocumentBuilder; |
35 | |
import javax.xml.parsers.DocumentBuilderFactory; |
36 | |
import javax.xml.parsers.ParserConfigurationException; |
37 | |
import javax.xml.registry.InvalidRequestException; |
38 | |
import javax.xml.transform.stream.StreamSource; |
39 | |
|
40 | |
import org.apache.commons.logging.Log; |
41 | |
import org.apache.commons.logging.LogFactory; |
42 | |
import org.apache.ws.scout.model.uddi.v2.AssertionStatusReport; |
43 | |
import org.apache.ws.scout.model.uddi.v2.AuthToken; |
44 | |
import org.apache.ws.scout.model.uddi.v2.BindingDetail; |
45 | |
import org.apache.ws.scout.model.uddi.v2.BindingTemplate; |
46 | |
import org.apache.ws.scout.model.uddi.v2.BusinessDetail; |
47 | |
import org.apache.ws.scout.model.uddi.v2.BusinessEntity; |
48 | |
import org.apache.ws.scout.model.uddi.v2.BusinessList; |
49 | |
import org.apache.ws.scout.model.uddi.v2.BusinessService; |
50 | |
import org.apache.ws.scout.model.uddi.v2.CategoryBag; |
51 | |
import org.apache.ws.scout.model.uddi.v2.DeleteBinding; |
52 | |
import org.apache.ws.scout.model.uddi.v2.DeleteBusiness; |
53 | |
import org.apache.ws.scout.model.uddi.v2.DeletePublisherAssertions; |
54 | |
import org.apache.ws.scout.model.uddi.v2.DeleteService; |
55 | |
import org.apache.ws.scout.model.uddi.v2.DeleteTModel; |
56 | |
import org.apache.ws.scout.model.uddi.v2.DiscoveryURLs; |
57 | |
import org.apache.ws.scout.model.uddi.v2.DispositionReport; |
58 | |
import org.apache.ws.scout.model.uddi.v2.FindBinding; |
59 | |
import org.apache.ws.scout.model.uddi.v2.FindBusiness; |
60 | |
import org.apache.ws.scout.model.uddi.v2.FindQualifiers; |
61 | |
import org.apache.ws.scout.model.uddi.v2.FindService; |
62 | |
import org.apache.ws.scout.model.uddi.v2.FindTModel; |
63 | |
import org.apache.ws.scout.model.uddi.v2.GetAssertionStatusReport; |
64 | |
import org.apache.ws.scout.model.uddi.v2.GetAuthToken; |
65 | |
import org.apache.ws.scout.model.uddi.v2.GetBusinessDetail; |
66 | |
import org.apache.ws.scout.model.uddi.v2.GetPublisherAssertions; |
67 | |
import org.apache.ws.scout.model.uddi.v2.GetRegisteredInfo; |
68 | |
import org.apache.ws.scout.model.uddi.v2.GetServiceDetail; |
69 | |
import org.apache.ws.scout.model.uddi.v2.GetTModelDetail; |
70 | |
import org.apache.ws.scout.model.uddi.v2.IdentifierBag; |
71 | |
import org.apache.ws.scout.model.uddi.v2.Name; |
72 | |
import org.apache.ws.scout.model.uddi.v2.ObjectFactory; |
73 | |
import org.apache.ws.scout.model.uddi.v2.PublisherAssertion; |
74 | |
import org.apache.ws.scout.model.uddi.v2.PublisherAssertions; |
75 | |
import org.apache.ws.scout.model.uddi.v2.RegisteredInfo; |
76 | |
import org.apache.ws.scout.model.uddi.v2.SaveBinding; |
77 | |
import org.apache.ws.scout.model.uddi.v2.SaveBusiness; |
78 | |
import org.apache.ws.scout.model.uddi.v2.SaveService; |
79 | |
import org.apache.ws.scout.model.uddi.v2.SaveTModel; |
80 | |
import org.apache.ws.scout.model.uddi.v2.ServiceDetail; |
81 | |
import org.apache.ws.scout.model.uddi.v2.ServiceList; |
82 | |
import org.apache.ws.scout.model.uddi.v2.SetPublisherAssertions; |
83 | |
import org.apache.ws.scout.model.uddi.v2.TModel; |
84 | |
import org.apache.ws.scout.model.uddi.v2.TModelBag; |
85 | |
import org.apache.ws.scout.model.uddi.v2.TModelDetail; |
86 | |
import org.apache.ws.scout.model.uddi.v2.TModelList; |
87 | |
import org.apache.ws.scout.transport.Transport; |
88 | |
import org.apache.ws.scout.transport.TransportException; |
89 | |
import org.apache.ws.scout.util.XMLUtils; |
90 | |
import org.w3c.dom.Document; |
91 | |
import org.w3c.dom.Element; |
92 | |
import org.w3c.dom.NodeList; |
93 | |
import org.xml.sax.SAXException; |
94 | |
|
95 | |
|
96 | |
|
97 | |
|
98 | |
|
99 | |
|
100 | |
|
101 | |
|
102 | |
|
103 | |
|
104 | |
|
105 | |
|
106 | |
|
107 | |
public class RegistryImpl implements IRegistry { |
108 | |
|
109 | |
public static final String DEFAULT_ADMIN_ENDPOINT = "http://localhost:8080/juddi/admin"; |
110 | |
public static final String DEFAULT_TRANSPORT_CLASS = "org.apache.ws.scout.transport.SaajTransport"; |
111 | |
public static final String DEFAULT_SECURITY_PROVIDER = "com.sun.net.ssl.internal.ssl.Provider"; |
112 | |
public static final String DEFAULT_PROTOCOL_HANDLER = "com.sun.net.ssl.internal.www.protocol"; |
113 | |
public static final String DEFAULT_UDDI_VERSION = "2.0"; |
114 | |
public static final String DEFAULT_UDDI_NAMESPACE = "urn:uddi-org:api_v2"; |
115 | |
|
116 | |
private URI adminURI; |
117 | |
private URI inquiryURI; |
118 | |
private URI publishURI; |
119 | |
private URI securityURI; |
120 | |
|
121 | |
private Transport transport; |
122 | |
|
123 | |
private String securityProvider; |
124 | |
private String protocolHandler; |
125 | |
private String uddiVersion; |
126 | |
private String uddiNamespace; |
127 | |
|
128 | 0 | private ObjectFactory objectFactory = new ObjectFactory(); |
129 | |
|
130 | 0 | private Marshaller marshaller = null; |
131 | 0 | private Unmarshaller unmarshaller = null; |
132 | |
|
133 | 0 | private static Log log = LogFactory.getLog(RegistryImpl.class); |
134 | |
|
135 | |
|
136 | |
|
137 | |
|
138 | |
|
139 | |
public RegistryImpl(Properties props) throws InvalidRequestException { |
140 | 0 | super(); |
141 | |
|
142 | 0 | this.init(props); |
143 | 0 | } |
144 | |
|
145 | |
|
146 | |
|
147 | |
|
148 | |
|
149 | |
private void init(Properties props) throws InvalidRequestException { |
150 | |
|
151 | |
|
152 | 0 | if (props == null) props = new Properties(); |
153 | |
|
154 | |
|
155 | |
try { |
156 | 0 | setInquiryURI(new URI(props.getProperty(ConnectionFactoryImpl.QUERYMANAGER_PROPERTY))); |
157 | 0 | if (props.containsKey(ConnectionFactoryImpl.LIFECYCLEMANAGER_PROPERTY)) { |
158 | 0 | setPublishURI(new URI(props.getProperty(ConnectionFactoryImpl.LIFECYCLEMANAGER_PROPERTY))); |
159 | |
} |
160 | 0 | String securityURL = props.getProperty(ConnectionFactoryImpl.SECURITYMANAGER_PROPERTY, |
161 | |
props.getProperty(ConnectionFactoryImpl.LIFECYCLEMANAGER_PROPERTY)); |
162 | 0 | if (securityURL!=null) setSecurityURI(new URI(securityURL)); |
163 | 0 | setAdminURI(new URI(props.getProperty(ConnectionFactoryImpl.ADMIN_ENDPOINT_PROPERTY, DEFAULT_ADMIN_ENDPOINT))); |
164 | 0 | setSecurityProvider(props.getProperty(ConnectionFactoryImpl.SECURITY_PROVIDER_PROPERTY, DEFAULT_SECURITY_PROVIDER)); |
165 | 0 | setProtocolHandler(props.getProperty(ConnectionFactoryImpl.PROTOCOL_HANDLER_PROPERTY, DEFAULT_PROTOCOL_HANDLER)); |
166 | 0 | setUddiVersion(props.getProperty(ConnectionFactoryImpl.UDDI_VERSION_PROPERTY, DEFAULT_UDDI_VERSION)); |
167 | 0 | setUddiNamespace(props.getProperty(ConnectionFactoryImpl.UDDI_NAMESPACE_PROPERTY, DEFAULT_UDDI_NAMESPACE)); |
168 | 0 | setTransport(getTransport(props.getProperty(ConnectionFactoryImpl.TRANSPORT_CLASS_PROPERTY, DEFAULT_TRANSPORT_CLASS))); |
169 | |
|
170 | 0 | JAXBContext context = JAXBContextUtil.getContext(JAXBContextUtil.UDDI_V2_VERSION); |
171 | 0 | unmarshaller = context.createUnmarshaller(); |
172 | 0 | marshaller = context.createMarshaller(); |
173 | 0 | } catch (URISyntaxException muex) { |
174 | 0 | throw new InvalidRequestException(muex.getMessage(),muex); |
175 | 0 | } catch(JAXBException e) { |
176 | 0 | throw new RuntimeException(e); |
177 | 0 | } |
178 | 0 | } |
179 | |
|
180 | |
|
181 | |
|
182 | |
|
183 | |
|
184 | |
|
185 | |
|
186 | |
public String execute(String uddiRequest, String urltype) |
187 | |
throws TransportException { |
188 | 0 | URI endPointURL = null; |
189 | 0 | if (urltype.equalsIgnoreCase("INQUIRY")) |
190 | 0 | endPointURL = this.getInquiryURI(); |
191 | |
else |
192 | 0 | endPointURL = this.getPublishURI(); |
193 | |
|
194 | |
|
195 | |
|
196 | |
|
197 | 0 | return transport.send(uddiRequest, endPointURL); |
198 | |
} |
199 | |
|
200 | |
|
201 | |
|
202 | |
|
203 | |
public JAXBElement<?> execute(JAXBElement<?> uddiRequest, URI endPointURI) |
204 | |
throws RegistryException { |
205 | |
|
206 | 0 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
207 | |
|
208 | |
Document doc; |
209 | |
try { |
210 | 0 | DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance(); |
211 | 0 | docBuilderFactory.setNamespaceAware(true); |
212 | 0 | DocumentBuilder docBuilder= docBuilderFactory.newDocumentBuilder(); |
213 | 0 | this.marshaller.marshal(uddiRequest, baos); |
214 | 0 | doc = docBuilder.parse(new ByteArrayInputStream(baos.toByteArray())); |
215 | 0 | } catch (SAXException saxe) { |
216 | 0 | throw (new RegistryException(saxe)); |
217 | 0 | } catch (ParserConfigurationException pce) { |
218 | 0 | throw (new RegistryException(pce)); |
219 | 0 | } catch (IOException ioe) { |
220 | 0 | throw (new RegistryException(ioe)); |
221 | 0 | } catch (JAXBException ioe) { |
222 | 0 | throw (new RegistryException(ioe)); |
223 | 0 | } |
224 | 0 | Element request = doc.getDocumentElement(); |
225 | |
|
226 | 0 | request.setAttribute("xmlns", this.getUddiNamespace()); |
227 | 0 | if (!"3.0".equals(this.getUddiVersion())) { |
228 | 0 | request.setAttribute("generic", this.getUddiVersion()); |
229 | |
} |
230 | |
|
231 | |
|
232 | |
|
233 | |
|
234 | |
|
235 | |
Element response; |
236 | |
try { |
237 | 0 | response = transport.send(request, endPointURI); |
238 | 0 | } catch (TransportException te) { |
239 | 0 | throw new RegistryException(te); |
240 | 0 | } |
241 | |
|
242 | |
|
243 | |
|
244 | |
|
245 | |
|
246 | |
|
247 | |
|
248 | |
|
249 | |
|
250 | |
|
251 | |
|
252 | |
|
253 | |
|
254 | |
|
255 | |
|
256 | 0 | if (response.getNamespaceURI()==null) { |
257 | 0 | response.setAttributeNS("http://www.w3.org/2000/xmlns/","xmlns", this.getUddiNamespace()); |
258 | |
} |
259 | |
|
260 | |
|
261 | |
|
262 | |
|
263 | |
|
264 | |
|
265 | 0 | String responseName = response.getLocalName(); |
266 | 0 | if (responseName == null) { |
267 | 0 | throw new RegistryException("Unsupported response " |
268 | |
+ "from registry. A value was not present."); |
269 | |
} |
270 | |
|
271 | 0 | if (responseName.toLowerCase().equals("fault")) { |
272 | 0 | NodeList nodeList = null; |
273 | |
|
274 | |
|
275 | 0 | String fCode = null; |
276 | 0 | nodeList = response.getElementsByTagName("faultcode"); |
277 | 0 | if (nodeList.getLength() > 0) |
278 | 0 | fCode = nodeList.item(0).getNodeValue(); |
279 | |
|
280 | 0 | String fString = null; |
281 | 0 | nodeList = response.getElementsByTagName("faultstring"); |
282 | 0 | if (nodeList.getLength() > 0) |
283 | 0 | fString = nodeList.item(0).getNodeValue(); |
284 | |
|
285 | 0 | String fActor = null; |
286 | 0 | nodeList = response.getElementsByTagName("faultactor"); |
287 | 0 | if (nodeList.getLength() > 0) |
288 | 0 | fActor = nodeList.item(0).getNodeValue(); |
289 | |
|
290 | 0 | DispositionReport dispRpt = null; |
291 | |
|
292 | 0 | nodeList = response.getElementsByTagName("detail"); |
293 | 0 | if (nodeList.getLength() > 0) { |
294 | 0 | nodeList = ((Element) nodeList.item(0)) |
295 | |
.getElementsByTagName("dispositionReport"); |
296 | 0 | if (nodeList.getLength() > 0) { |
297 | 0 | JAXBElement<DispositionReport> dispRptObj = null; |
298 | |
try { |
299 | 0 | dispRptObj = (JAXBElement<DispositionReport>) unmarshaller.unmarshal((Element) nodeList |
300 | |
.item(0)); |
301 | 0 | } catch (JAXBException xmle) { |
302 | 0 | throw (new RegistryException(xmle)); |
303 | 0 | } |
304 | 0 | dispRpt = dispRptObj.getValue(); |
305 | |
} |
306 | |
} |
307 | |
|
308 | 0 | RegistryException e = new RegistryException(fCode, fString, fActor, dispRpt); |
309 | |
|
310 | |
|
311 | 0 | throw e; |
312 | |
} |
313 | |
|
314 | |
|
315 | |
|
316 | |
|
317 | |
|
318 | |
|
319 | |
|
320 | |
|
321 | |
|
322 | |
|
323 | |
|
324 | 0 | JAXBElement<?> uddiResponse = null; |
325 | |
try { |
326 | 0 | String xml = XMLUtils.convertNodeToXMLString(response); |
327 | 0 | log.debug("Response is: " + xml); |
328 | |
|
329 | 0 | StringReader reader = new StringReader(xml); |
330 | 0 | uddiResponse = (JAXBElement<?>) unmarshaller.unmarshal(new StreamSource(reader)); |
331 | |
|
332 | |
|
333 | |
|
334 | 0 | } catch (JAXBException xmle) { |
335 | 0 | throw (new RegistryException(xmle)); |
336 | 0 | } |
337 | |
|
338 | 0 | return uddiResponse; |
339 | |
} |
340 | |
|
341 | |
|
342 | |
|
343 | |
|
344 | |
public URI getAdminURI() { |
345 | 0 | return this.adminURI; |
346 | |
} |
347 | |
|
348 | |
|
349 | |
|
350 | |
|
351 | |
|
352 | |
public void setAdminURI(URI url) { |
353 | 0 | this.adminURI = url; |
354 | 0 | } |
355 | |
|
356 | |
|
357 | |
|
358 | |
|
359 | |
public URI getInquiryURI() { |
360 | 0 | return this.inquiryURI; |
361 | |
} |
362 | |
|
363 | |
|
364 | |
|
365 | |
|
366 | |
|
367 | |
public void setInquiryURI(URI inquiryURI) { |
368 | 0 | this.inquiryURI = inquiryURI; |
369 | 0 | } |
370 | |
|
371 | |
|
372 | |
|
373 | |
|
374 | |
public String getProtocolHandler() { |
375 | 0 | return this.protocolHandler; |
376 | |
} |
377 | |
|
378 | |
|
379 | |
|
380 | |
|
381 | |
|
382 | |
public void setProtocolHandler(String protocolHandler) { |
383 | 0 | this.protocolHandler = protocolHandler; |
384 | 0 | } |
385 | |
|
386 | |
|
387 | |
|
388 | |
|
389 | |
public URI getPublishURI() { |
390 | 0 | return this.publishURI; |
391 | |
} |
392 | |
|
393 | |
|
394 | |
|
395 | |
|
396 | |
public URI getSecurityURI() { |
397 | 0 | return this.securityURI; |
398 | |
} |
399 | |
|
400 | |
|
401 | |
|
402 | |
|
403 | |
|
404 | |
public void setPublishURI(URI publishURI) { |
405 | 0 | this.publishURI = publishURI; |
406 | 0 | } |
407 | |
|
408 | |
|
409 | |
|
410 | |
|
411 | |
|
412 | |
public void setSecurityURI(URI securityURI) { |
413 | 0 | this.securityURI = securityURI; |
414 | 0 | } |
415 | |
|
416 | |
|
417 | |
|
418 | |
|
419 | |
public String getSecurityProvider() { |
420 | 0 | return this.securityProvider; |
421 | |
} |
422 | |
|
423 | |
|
424 | |
|
425 | |
|
426 | |
|
427 | |
public void setSecurityProvider(String securityProvider) { |
428 | 0 | this.securityProvider = securityProvider; |
429 | 0 | } |
430 | |
|
431 | |
|
432 | |
|
433 | |
|
434 | |
public Transport getTransport() { |
435 | 0 | return transport; |
436 | |
} |
437 | |
|
438 | |
|
439 | |
|
440 | |
|
441 | |
|
442 | |
public void setTransport(Transport transport) { |
443 | 0 | this.transport = transport; |
444 | 0 | } |
445 | |
|
446 | |
|
447 | |
|
448 | |
|
449 | |
public String getUddiNamespace() { |
450 | 0 | return this.uddiNamespace; |
451 | |
} |
452 | |
|
453 | |
|
454 | |
|
455 | |
|
456 | |
|
457 | |
public void setUddiNamespace(String uddiNS) { |
458 | 0 | this.uddiNamespace = uddiNS; |
459 | 0 | } |
460 | |
|
461 | |
|
462 | |
|
463 | |
|
464 | |
public String getUddiVersion() { |
465 | 0 | return this.uddiVersion; |
466 | |
} |
467 | |
|
468 | |
|
469 | |
|
470 | |
|
471 | |
|
472 | |
public void setUddiVersion(String uddiVersion) { |
473 | 0 | this.uddiVersion = uddiVersion; |
474 | 0 | } |
475 | |
|
476 | |
|
477 | |
|
478 | |
|
479 | |
|
480 | |
|
481 | |
|
482 | |
public DispositionReport deleteBinding(String authInfo, |
483 | |
String[] bindingKeyArray) throws RegistryException { |
484 | 0 | DeleteBinding request = this.objectFactory.createDeleteBinding(); |
485 | |
|
486 | 0 | if (authInfo != null) { |
487 | 0 | request.setAuthInfo(authInfo); |
488 | |
} |
489 | |
|
490 | 0 | if (bindingKeyArray != null) { |
491 | 0 | request.getBindingKey().addAll(Arrays.asList(bindingKeyArray)); |
492 | |
} |
493 | |
|
494 | |
DispositionReport dr; |
495 | 0 | JAXBElement<?> o = execute(this.objectFactory.createDeleteBinding(request), this.getPublishURI()); |
496 | 0 | dr = (DispositionReport) o.getValue(); |
497 | |
|
498 | 0 | return dr; |
499 | |
} |
500 | |
|
501 | |
|
502 | |
|
503 | |
|
504 | |
|
505 | |
|
506 | |
public DispositionReport deleteBusiness(String authInfo, |
507 | |
String[] businessKeyArray) throws RegistryException { |
508 | 0 | DeleteBusiness request = this.objectFactory.createDeleteBusiness(); |
509 | |
|
510 | 0 | if (authInfo != null) { |
511 | 0 | request.setAuthInfo(authInfo); |
512 | |
} |
513 | |
|
514 | 0 | if (businessKeyArray != null) { |
515 | 0 | request.getBusinessKey().addAll(Arrays.asList(businessKeyArray)); |
516 | |
} |
517 | |
|
518 | |
DispositionReport dr; |
519 | 0 | JAXBElement<?> o = execute(this.objectFactory.createDeleteBusiness(request), this.getPublishURI()); |
520 | 0 | dr = (DispositionReport) o.getValue(); |
521 | |
|
522 | 0 | return dr; |
523 | |
} |
524 | |
|
525 | |
|
526 | |
|
527 | |
|
528 | |
public DispositionReport deletePublisherAssertions(String authInfo, |
529 | |
PublisherAssertion[] assertionArray) throws RegistryException { |
530 | 0 | DeletePublisherAssertions request = this.objectFactory.createDeletePublisherAssertions(); |
531 | |
|
532 | 0 | if (authInfo != null) { |
533 | 0 | request.setAuthInfo(authInfo); |
534 | |
} |
535 | |
|
536 | 0 | if (assertionArray != null) { |
537 | 0 | request.getPublisherAssertion().addAll(Arrays.asList(assertionArray)); |
538 | |
} |
539 | |
|
540 | |
DispositionReport dr; |
541 | 0 | JAXBElement<?> o = execute(this.objectFactory.createDeletePublisherAssertions(request), |
542 | |
this.getPublishURI()); |
543 | 0 | dr = (DispositionReport) o.getValue(); |
544 | |
|
545 | 0 | return dr; |
546 | |
} |
547 | |
|
548 | |
|
549 | |
|
550 | |
|
551 | |
|
552 | |
|
553 | |
|
554 | |
public DispositionReport deleteService(String authInfo, |
555 | |
String[] serviceKeyArray) throws RegistryException { |
556 | 0 | DeleteService request = this.objectFactory.createDeleteService(); |
557 | |
|
558 | 0 | if (authInfo != null) { |
559 | 0 | request.setAuthInfo(authInfo); |
560 | |
} |
561 | |
|
562 | 0 | if (serviceKeyArray != null) { |
563 | 0 | request.getServiceKey().addAll(Arrays.asList(serviceKeyArray)); |
564 | |
} |
565 | |
|
566 | |
DispositionReport dr; |
567 | 0 | JAXBElement<?> o = execute(this.objectFactory.createDeleteService(request), |
568 | |
this.getPublishURI()); |
569 | 0 | dr = (DispositionReport) o.getValue(); |
570 | |
|
571 | 0 | return dr; |
572 | |
} |
573 | |
|
574 | |
|
575 | |
|
576 | |
|
577 | |
|
578 | |
|
579 | |
|
580 | |
|
581 | |
public DispositionReport deleteTModel(String authInfo, |
582 | |
String[] tModelKeyArray) throws RegistryException { |
583 | 0 | DeleteTModel request = this.objectFactory.createDeleteTModel(); |
584 | |
|
585 | 0 | if (authInfo != null) { |
586 | 0 | request.setAuthInfo(authInfo); |
587 | |
} |
588 | |
|
589 | 0 | if (tModelKeyArray != null) { |
590 | 0 | request.getTModelKey().addAll(Arrays.asList(tModelKeyArray)); |
591 | |
} |
592 | |
|
593 | |
DispositionReport dr; |
594 | 0 | JAXBElement<?> o = execute(this.objectFactory.createDeleteTModel(request), |
595 | |
this.getPublishURI()); |
596 | 0 | dr = (DispositionReport) o.getValue(); |
597 | |
|
598 | 0 | return dr; |
599 | |
} |
600 | |
|
601 | |
|
602 | |
|
603 | |
|
604 | |
|
605 | |
|
606 | |
|
607 | |
public BusinessList findBusiness(Name[] nameArray, |
608 | |
DiscoveryURLs discoveryURLs, IdentifierBag identifierBag, |
609 | |
CategoryBag categoryBag, TModelBag tModelBag, |
610 | |
FindQualifiers findQualifiers, int maxRows) |
611 | |
throws RegistryException { |
612 | 0 | FindBusiness request = this.objectFactory.createFindBusiness(); |
613 | |
|
614 | 0 | if (nameArray != null) { |
615 | 0 | request.getName().addAll(Arrays.asList(nameArray)); |
616 | |
} |
617 | |
|
618 | 0 | if (discoveryURLs != null) { |
619 | 0 | request.setDiscoveryURLs(discoveryURLs); |
620 | |
} |
621 | |
|
622 | 0 | if (identifierBag != null) { |
623 | 0 | request.setIdentifierBag(identifierBag); |
624 | |
} |
625 | |
|
626 | 0 | if (categoryBag != null) { |
627 | 0 | request.setCategoryBag(categoryBag); |
628 | |
} |
629 | |
|
630 | 0 | if (tModelBag != null) { |
631 | 0 | request.setTModelBag(tModelBag); |
632 | |
} else { |
633 | 0 | request.setTModelBag(this.objectFactory.createTModelBag()); |
634 | |
} |
635 | |
|
636 | 0 | if (findQualifiers != null) { |
637 | 0 | request.setFindQualifiers(findQualifiers); |
638 | |
} |
639 | |
|
640 | 0 | request.setMaxRows(maxRows); |
641 | |
|
642 | |
BusinessList bl; |
643 | 0 | JAXBElement<?> o = execute(this.objectFactory.createFindBusiness(request), |
644 | |
this.getInquiryURI()); |
645 | 0 | bl = (BusinessList) o.getValue(); |
646 | |
|
647 | 0 | return bl; |
648 | |
} |
649 | |
|
650 | |
|
651 | |
|
652 | |
|
653 | |
|
654 | |
|
655 | |
|
656 | |
public BindingDetail findBinding(String serviceKey, |
657 | |
CategoryBag categoryBag, TModelBag tModelBag, |
658 | |
FindQualifiers findQualifiers, int maxRows) |
659 | |
throws RegistryException { |
660 | |
|
661 | |
|
662 | |
|
663 | |
|
664 | |
|
665 | |
|
666 | 0 | FindBinding request = this.objectFactory.createFindBinding(); |
667 | |
|
668 | 0 | if (serviceKey != null) { |
669 | 0 | request.setServiceKey(serviceKey); |
670 | |
} |
671 | |
|
672 | 0 | if (tModelBag != null) { |
673 | 0 | request.setTModelBag(tModelBag); |
674 | |
} else { |
675 | 0 | TModelBag tmb = this.objectFactory.createTModelBag(); |
676 | 0 | request.setTModelBag(tmb); |
677 | |
} |
678 | |
|
679 | 0 | if (findQualifiers != null) { |
680 | 0 | request.setFindQualifiers(findQualifiers); |
681 | |
} |
682 | 0 | request.setMaxRows(maxRows); |
683 | |
|
684 | |
BindingDetail bd; |
685 | 0 | JAXBElement<?> o = execute(this.objectFactory.createFindBinding(request), |
686 | |
this.getInquiryURI()); |
687 | 0 | bd = (BindingDetail) o.getValue(); |
688 | |
|
689 | 0 | return bd; |
690 | |
} |
691 | |
|
692 | |
|
693 | |
|
694 | |
|
695 | |
|
696 | |
|
697 | |
|
698 | |
|
699 | |
|
700 | |
public ServiceList findService(String businessKey, Name[] nameArray, |
701 | |
CategoryBag categoryBag, TModelBag tModelBag, |
702 | |
FindQualifiers findQualifiers, int maxRows) |
703 | |
throws RegistryException { |
704 | 0 | FindService request = this.objectFactory.createFindService(); |
705 | |
|
706 | 0 | if (businessKey != null) { |
707 | 0 | request.setBusinessKey(businessKey); |
708 | |
} |
709 | |
|
710 | 0 | if (nameArray != null) { |
711 | 0 | request.getName().addAll(Arrays.asList(nameArray)); |
712 | |
} |
713 | |
|
714 | 0 | if (categoryBag != null) { |
715 | 0 | request.setCategoryBag(categoryBag); |
716 | |
} |
717 | |
|
718 | 0 | if (tModelBag != null) { |
719 | 0 | request.setTModelBag(tModelBag); |
720 | |
} |
721 | |
|
722 | 0 | if (findQualifiers != null) { |
723 | 0 | request.setFindQualifiers(findQualifiers); |
724 | |
} |
725 | |
|
726 | 0 | request.setMaxRows(maxRows); |
727 | |
|
728 | |
ServiceList sl; |
729 | 0 | JAXBElement<?> o = execute(this.objectFactory.createFindService(request), |
730 | |
this.getInquiryURI()); |
731 | 0 | sl = (ServiceList) o.getValue(); |
732 | |
|
733 | 0 | return sl; |
734 | |
} |
735 | |
|
736 | |
|
737 | |
|
738 | |
|
739 | |
|
740 | |
|
741 | |
|
742 | |
public TModelList findTModel(String name, CategoryBag categoryBag, |
743 | |
IdentifierBag identifierBag, FindQualifiers findQualifiers, |
744 | |
int maxRows) throws RegistryException { |
745 | 0 | FindTModel request = this.objectFactory.createFindTModel(); |
746 | |
|
747 | 0 | Name jaxbName = this.objectFactory.createName(); |
748 | |
|
749 | 0 | if (name != null) { |
750 | 0 | jaxbName.setValue(name); |
751 | |
} |
752 | |
|
753 | 0 | request.setName(jaxbName); |
754 | |
|
755 | 0 | if (categoryBag != null) { |
756 | 0 | request.setCategoryBag(categoryBag); |
757 | |
} |
758 | |
|
759 | 0 | if (identifierBag != null) { |
760 | 0 | request.setIdentifierBag(identifierBag); |
761 | |
} |
762 | |
|
763 | 0 | if (findQualifiers != null) { |
764 | 0 | request.setFindQualifiers(findQualifiers); |
765 | |
} |
766 | |
|
767 | 0 | request.setMaxRows(maxRows); |
768 | |
|
769 | |
TModelList tml; |
770 | 0 | JAXBElement<?> o = execute(this.objectFactory.createFindTModel(request), |
771 | |
this.getInquiryURI()); |
772 | 0 | tml = (TModelList) o.getValue(); |
773 | |
|
774 | 0 | return tml; |
775 | |
} |
776 | |
|
777 | |
|
778 | |
|
779 | |
|
780 | |
public AssertionStatusReport getAssertionStatusReport(String authInfo, |
781 | |
String completionStatus) throws RegistryException { |
782 | 0 | GetAssertionStatusReport request = this.objectFactory.createGetAssertionStatusReport(); |
783 | |
|
784 | 0 | if (authInfo != null) { |
785 | 0 | request.setAuthInfo(authInfo); |
786 | |
} |
787 | |
|
788 | 0 | if (completionStatus != null) { |
789 | 0 | request.setCompletionStatus(completionStatus); |
790 | |
} |
791 | |
|
792 | |
AssertionStatusReport asr; |
793 | 0 | JAXBElement<?> o = execute(this.objectFactory.createGetAssertionStatusReport(request), |
794 | |
this.getPublishURI()); |
795 | 0 | asr = (AssertionStatusReport) o.getValue(); |
796 | |
|
797 | 0 | return asr; |
798 | |
} |
799 | |
|
800 | |
|
801 | |
|
802 | |
|
803 | |
|
804 | |
|
805 | |
|
806 | |
|
807 | |
|
808 | |
public AuthToken getAuthToken(String userID, String cred) |
809 | |
throws RegistryException { |
810 | 0 | GetAuthToken request = this.objectFactory.createGetAuthToken(); |
811 | |
|
812 | 0 | if (userID != null) { |
813 | 0 | request.setUserID(userID); |
814 | |
} |
815 | |
|
816 | 0 | if (cred != null) { |
817 | 0 | request.setCred(cred); |
818 | |
} |
819 | |
|
820 | 0 | URI getAuthTokenURI = getSecurityURI();; |
821 | |
|
822 | |
AuthToken at; |
823 | 0 | JAXBElement<?> o = execute(this.objectFactory.createGetAuthToken(request), |
824 | |
getAuthTokenURI); |
825 | 0 | at = (AuthToken) o.getValue(); |
826 | |
|
827 | 0 | return at; |
828 | |
} |
829 | |
|
830 | |
|
831 | |
|
832 | |
|
833 | |
|
834 | |
|
835 | |
|
836 | |
public BusinessDetail getBusinessDetail(String businessKey) |
837 | |
throws RegistryException { |
838 | 0 | String[] keys = new String[1]; |
839 | 0 | keys[0] = businessKey; |
840 | |
|
841 | 0 | return getBusinessDetail(keys); |
842 | |
} |
843 | |
|
844 | |
|
845 | |
|
846 | |
|
847 | |
|
848 | |
|
849 | |
|
850 | |
public BusinessDetail getBusinessDetail(String[] businessKeyArray) |
851 | |
throws RegistryException { |
852 | 0 | GetBusinessDetail request = this.objectFactory.createGetBusinessDetail(); |
853 | |
|
854 | 0 | if (businessKeyArray != null) { |
855 | 0 | request.getBusinessKey().addAll(Arrays.asList(businessKeyArray)); |
856 | |
} |
857 | |
|
858 | |
BusinessDetail bd; |
859 | 0 | JAXBElement<?> o = execute(this.objectFactory.createGetBusinessDetail(request), |
860 | |
this.getInquiryURI()); |
861 | 0 | bd = (BusinessDetail) o.getValue(); |
862 | 0 | return bd; |
863 | |
} |
864 | |
|
865 | |
|
866 | |
|
867 | |
|
868 | |
public PublisherAssertions getPublisherAssertions(String authInfo) |
869 | |
throws RegistryException { |
870 | 0 | GetPublisherAssertions request = this.objectFactory.createGetPublisherAssertions(); |
871 | |
|
872 | 0 | if (authInfo != null) { |
873 | 0 | request.setAuthInfo(authInfo); |
874 | |
} |
875 | |
|
876 | |
PublisherAssertions pa; |
877 | 0 | JAXBElement<?> o = execute(this.objectFactory.createGetPublisherAssertions(request), |
878 | |
this.getPublishURI()); |
879 | 0 | pa = (PublisherAssertions) o.getValue(); |
880 | |
|
881 | 0 | return pa; |
882 | |
} |
883 | |
|
884 | |
|
885 | |
|
886 | |
|
887 | |
public RegisteredInfo getRegisteredInfo(String authInfo) |
888 | |
throws RegistryException { |
889 | 0 | GetRegisteredInfo request = this.objectFactory.createGetRegisteredInfo(); |
890 | |
|
891 | 0 | if (authInfo != null) { |
892 | 0 | request.setAuthInfo(authInfo); |
893 | |
} |
894 | |
|
895 | |
RegisteredInfo ri; |
896 | 0 | JAXBElement<?> o = execute(this.objectFactory.createGetRegisteredInfo(request), |
897 | |
this.getPublishURI()); |
898 | 0 | ri = (RegisteredInfo) o.getValue(); |
899 | |
|
900 | 0 | return ri; |
901 | |
} |
902 | |
|
903 | |
|
904 | |
|
905 | |
|
906 | |
|
907 | |
|
908 | |
|
909 | |
public ServiceDetail getServiceDetail(String serviceKey) |
910 | |
throws RegistryException { |
911 | 0 | String[] keys = new String[1]; |
912 | 0 | keys[0] = serviceKey; |
913 | |
|
914 | 0 | return getServiceDetail(keys); |
915 | |
} |
916 | |
|
917 | |
|
918 | |
|
919 | |
|
920 | |
|
921 | |
|
922 | |
|
923 | |
public ServiceDetail getServiceDetail(String[] serviceKeyArray) |
924 | |
throws RegistryException { |
925 | 0 | GetServiceDetail request = this.objectFactory.createGetServiceDetail(); |
926 | |
|
927 | 0 | if (serviceKeyArray != null) { |
928 | 0 | request.getServiceKey().addAll(Arrays.asList(serviceKeyArray)); |
929 | |
} |
930 | |
|
931 | |
ServiceDetail sd; |
932 | 0 | JAXBElement<?> o = execute(this.objectFactory.createGetServiceDetail(request), |
933 | |
this.getInquiryURI()); |
934 | 0 | sd = (ServiceDetail) o.getValue(); |
935 | |
|
936 | 0 | return sd; |
937 | |
} |
938 | |
|
939 | |
|
940 | |
|
941 | |
|
942 | |
|
943 | |
|
944 | |
|
945 | |
public TModelDetail getTModelDetail(String tModelKey) |
946 | |
throws RegistryException { |
947 | 0 | String[] keys = new String[1]; |
948 | 0 | keys[0] = tModelKey; |
949 | |
|
950 | 0 | return getTModelDetail(keys); |
951 | |
} |
952 | |
|
953 | |
|
954 | |
|
955 | |
|
956 | |
|
957 | |
|
958 | |
|
959 | |
public TModelDetail getTModelDetail(String[] tModelKeyArray) |
960 | |
throws RegistryException { |
961 | 0 | GetTModelDetail request = this.objectFactory.createGetTModelDetail(); |
962 | |
|
963 | 0 | if (tModelKeyArray != null) { |
964 | 0 | request.getTModelKey().addAll(Arrays.asList(tModelKeyArray)); |
965 | |
} |
966 | |
|
967 | |
TModelDetail tmd; |
968 | 0 | JAXBElement<?> o = execute(this.objectFactory.createGetTModelDetail(request), |
969 | |
this.getInquiryURI()); |
970 | 0 | tmd = (TModelDetail) o.getValue(); |
971 | |
|
972 | 0 | return tmd; |
973 | |
} |
974 | |
|
975 | |
|
976 | |
|
977 | |
|
978 | |
public PublisherAssertions setPublisherAssertions(String authInfo, |
979 | |
PublisherAssertion[] assertionArray) throws RegistryException { |
980 | 0 | SetPublisherAssertions request = this.objectFactory.createSetPublisherAssertions(); |
981 | |
|
982 | 0 | if (authInfo != null) { |
983 | 0 | request.setAuthInfo(authInfo); |
984 | |
} |
985 | |
|
986 | 0 | if (assertionArray != null) { |
987 | 0 | request.getPublisherAssertion().addAll(Arrays.asList(assertionArray)); |
988 | |
} |
989 | |
|
990 | |
PublisherAssertions pa; |
991 | 0 | JAXBElement<?> o = execute(this.objectFactory.createSetPublisherAssertions(request), |
992 | |
this.getPublishURI()); |
993 | 0 | pa = (PublisherAssertions) o.getValue(); |
994 | |
|
995 | 0 | return pa; |
996 | |
} |
997 | |
|
998 | |
|
999 | |
|
1000 | |
|
1001 | |
|
1002 | |
|
1003 | |
|
1004 | |
|
1005 | |
public BindingDetail saveBinding(String authInfo, |
1006 | |
BindingTemplate[] bindingArray) throws RegistryException { |
1007 | 0 | SaveBinding request = this.objectFactory.createSaveBinding(); |
1008 | |
|
1009 | 0 | if (authInfo != null) { |
1010 | 0 | request.setAuthInfo(authInfo); |
1011 | |
} |
1012 | |
|
1013 | 0 | if (bindingArray != null) { |
1014 | 0 | request.getBindingTemplate().addAll(Arrays.asList(bindingArray)); |
1015 | |
} |
1016 | |
|
1017 | |
BindingDetail bd; |
1018 | 0 | JAXBElement<?> o = execute(this.objectFactory.createSaveBinding(request), |
1019 | |
this.getPublishURI()); |
1020 | 0 | bd = (BindingDetail) o.getValue(); |
1021 | |
|
1022 | 0 | return bd; |
1023 | |
} |
1024 | |
|
1025 | |
|
1026 | |
|
1027 | |
|
1028 | |
|
1029 | |
|
1030 | |
|
1031 | |
|
1032 | |
|
1033 | |
public BusinessDetail saveBusiness(String authInfo, |
1034 | |
BusinessEntity[] businessArray) throws RegistryException { |
1035 | 0 | SaveBusiness request = this.objectFactory.createSaveBusiness(); |
1036 | |
|
1037 | 0 | if (authInfo != null) { |
1038 | 0 | request.setAuthInfo(authInfo); |
1039 | |
} |
1040 | |
|
1041 | 0 | if (businessArray != null) { |
1042 | 0 | request.getBusinessEntity().addAll(Arrays.asList(businessArray)); |
1043 | |
} |
1044 | |
|
1045 | |
BusinessDetail bd; |
1046 | 0 | JAXBElement<?> o = execute(this.objectFactory.createSaveBusiness(request), |
1047 | |
this.getPublishURI()); |
1048 | 0 | bd = (BusinessDetail) o.getValue(); |
1049 | |
|
1050 | 0 | return bd; |
1051 | |
} |
1052 | |
|
1053 | |
|
1054 | |
|
1055 | |
|
1056 | |
|
1057 | |
|
1058 | |
|
1059 | |
public ServiceDetail saveService(String authInfo, |
1060 | |
BusinessService[] serviceArray) throws RegistryException { |
1061 | 0 | SaveService request = this.objectFactory.createSaveService(); |
1062 | |
|
1063 | 0 | if (authInfo != null) { |
1064 | 0 | request.setAuthInfo(authInfo); |
1065 | |
} |
1066 | |
|
1067 | 0 | if (serviceArray != null) { |
1068 | 0 | request.getBusinessService().addAll(Arrays.asList(serviceArray)); |
1069 | |
} |
1070 | |
|
1071 | |
ServiceDetail sd; |
1072 | 0 | JAXBElement<?> o = execute(this.objectFactory.createSaveService(request), |
1073 | |
this.getPublishURI()); |
1074 | 0 | sd = (ServiceDetail) o.getValue(); |
1075 | |
|
1076 | 0 | return sd; |
1077 | |
} |
1078 | |
|
1079 | |
|
1080 | |
|
1081 | |
|
1082 | |
|
1083 | |
|
1084 | |
public TModelDetail saveTModel(String authInfo, TModel[] tModelArray) |
1085 | |
throws RegistryException { |
1086 | 0 | SaveTModel request = this.objectFactory.createSaveTModel(); |
1087 | |
|
1088 | 0 | if (authInfo != null) { |
1089 | 0 | request.setAuthInfo(authInfo); |
1090 | |
} |
1091 | |
|
1092 | 0 | if (tModelArray != null) { |
1093 | 0 | request.getTModel().addAll(Arrays.asList(tModelArray)); |
1094 | |
} |
1095 | |
|
1096 | |
TModelDetail tmd; |
1097 | 0 | JAXBElement<?> o = execute(this.objectFactory.createSaveTModel(request), |
1098 | |
this.getPublishURI()); |
1099 | 0 | tmd = (TModelDetail) o.getValue(); |
1100 | 0 | return tmd; |
1101 | |
} |
1102 | |
|
1103 | |
|
1104 | |
|
1105 | |
|
1106 | |
|
1107 | |
|
1108 | |
|
1109 | |
|
1110 | |
public Transport getTransport(String className) { |
1111 | 0 | Transport transport = null; |
1112 | 0 | Class transportClass = null; |
1113 | |
|
1114 | |
|
1115 | |
|
1116 | 0 | if (className == null) |
1117 | 0 | className = DEFAULT_TRANSPORT_CLASS; |
1118 | |
|
1119 | |
try { |
1120 | |
|
1121 | 0 | transportClass = getClassForName(className); |
1122 | 0 | } catch (ClassNotFoundException cnfex) { |
1123 | 0 | throw new RuntimeException(cnfex); |
1124 | 0 | } |
1125 | |
|
1126 | |
try { |
1127 | |
|
1128 | 0 | transport = (Transport) transportClass.newInstance(); |
1129 | 0 | } catch (Exception ex) { |
1130 | 0 | throw new RuntimeException(ex); |
1131 | 0 | } |
1132 | |
|
1133 | 0 | return transport; |
1134 | |
} |
1135 | |
|
1136 | |
|
1137 | |
|
1138 | |
|
1139 | |
|
1140 | |
|
1141 | |
|
1142 | |
|
1143 | |
public static Class getClassForName(String name) |
1144 | |
throws ClassNotFoundException, NoClassDefFoundError { |
1145 | 0 | Class clazz = null; |
1146 | |
|
1147 | |
try { |
1148 | |
|
1149 | 0 | ClassLoader ccl = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() |
1150 | 0 | { |
1151 | |
public ClassLoader run() { |
1152 | 0 | return Thread.currentThread().getContextClassLoader(); |
1153 | |
} |
1154 | |
}); |
1155 | |
|
1156 | 0 | clazz = Class.forName(name, true, ccl); |
1157 | 0 | } catch (Exception e) { |
1158 | 0 | log.debug("Failed to load the class " + name + " with context class loader " + e); |
1159 | 0 | } |
1160 | |
|
1161 | 0 | if (null == clazz) { |
1162 | 0 | ClassLoader scl = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() |
1163 | 0 | { |
1164 | |
public ClassLoader run() { |
1165 | 0 | return ClassLoader.getSystemClassLoader(); |
1166 | |
} |
1167 | |
}); |
1168 | |
|
1169 | |
try { |
1170 | 0 | clazz = Class.forName(name, true, scl); |
1171 | 0 | } catch (Exception e) { |
1172 | 0 | throw new RuntimeException(e); |
1173 | 0 | } |
1174 | |
} |
1175 | |
|
1176 | 0 | return clazz; |
1177 | |
} |
1178 | |
} |