This project has retired. For details please refer to its Attic page.
UDDIClerk xref
View Javadoc
1   /*
2    * Copyright 2001-2010 The Apache Software Foundation.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   *
16   */
17  package org.apache.juddi.v3.client.config;
18  
19  import java.io.Serializable;
20  import java.lang.reflect.UndeclaredThrowableException;
21  import java.net.URL;
22  import java.rmi.RemoteException;
23  import java.util.ArrayList;
24  import java.util.Date;
25  import java.util.HashMap;
26  import java.util.HashSet;
27  import java.util.List;
28  import java.util.Map;
29  import java.util.Properties;
30  import java.util.Set;
31  
32  import javax.wsdl.Definition;
33  import javax.xml.ws.Holder;
34  import javax.xml.ws.soap.SOAPFaultException;
35  
36  import org.apache.commons.configuration.ConfigurationException;
37  import org.apache.commons.logging.Log;
38  import org.apache.commons.logging.LogFactory;
39  import org.apache.juddi.api_v3.AccessPointType;
40  import org.apache.juddi.api_v3.Clerk;
41  import org.apache.juddi.api_v3.ClerkDetail;
42  import org.apache.juddi.api_v3.Node;
43  import org.apache.juddi.api_v3.NodeDetail;
44  import org.apache.juddi.api_v3.SaveClerk;
45  import org.apache.juddi.api_v3.SaveNode;
46  import org.apache.juddi.v3.client.UDDIConstants;
47  import org.apache.juddi.v3.client.cryptor.CryptorFactory;
48  import org.apache.juddi.v3.client.mapping.URLLocalizerDefaultImpl;
49  import org.apache.juddi.v3.client.mapping.wsdl.ReadWSDL;
50  import org.apache.juddi.v3.client.mapping.wsdl.WSDL2UDDI;
51  import org.apache.juddi.v3.client.transport.TransportException;
52  import org.uddi.api_v3.BindingDetail;
53  import org.uddi.api_v3.BindingTemplate;
54  import org.uddi.api_v3.BusinessDetail;
55  import org.uddi.api_v3.BusinessEntity;
56  import org.uddi.api_v3.BusinessService;
57  import org.uddi.api_v3.BusinessServices;
58  import org.uddi.api_v3.CategoryBag;
59  import org.uddi.api_v3.DeleteBinding;
60  import org.uddi.api_v3.DeleteBusiness;
61  import org.uddi.api_v3.DeleteService;
62  import org.uddi.api_v3.DeleteTModel;
63  import org.uddi.api_v3.Description;
64  import org.uddi.api_v3.DiscardAuthToken;
65  import org.uddi.api_v3.DispositionReport;
66  import org.uddi.api_v3.FindRelatedBusinesses;
67  import org.uddi.api_v3.FindTModel;
68  import org.uddi.api_v3.GetAuthToken;
69  import org.uddi.api_v3.GetBindingDetail;
70  import org.uddi.api_v3.GetBusinessDetail;
71  import org.uddi.api_v3.GetServiceDetail;
72  import org.uddi.api_v3.GetTModelDetail;
73  import org.uddi.api_v3.InstanceDetails;
74  import org.uddi.api_v3.KeyedReference;
75  import org.uddi.api_v3.Name;
76  import org.uddi.api_v3.OverviewDoc;
77  import org.uddi.api_v3.OverviewURL;
78  import org.uddi.api_v3.PublisherAssertion;
79  import org.uddi.api_v3.PublisherAssertions;
80  import org.uddi.api_v3.RelatedBusinessesList;
81  import org.uddi.api_v3.Result;
82  import org.uddi.api_v3.SaveBinding;
83  import org.uddi.api_v3.SaveBusiness;
84  import org.uddi.api_v3.SaveService;
85  import org.uddi.api_v3.SaveTModel;
86  import org.uddi.api_v3.ServiceDetail;
87  import org.uddi.api_v3.TModel;
88  import org.uddi.api_v3.TModelDetail;
89  import org.uddi.api_v3.TModelInstanceInfo;
90  import org.uddi.api_v3.TModelList;
91  import org.uddi.sub_v3.DeleteSubscription;
92  import org.uddi.sub_v3.Subscription;
93  import org.uddi.v3_service.DispositionReportFaultMessage;
94  
95  /**
96   * The UDDIClerk provides an easy way to access a UDDI service. The clerk can be
97   * configured programmatically, but it is recommended to specify the server
98   * endpoint and access credentials in a uddi.xml file.
99   *
100  * Recommended use:
101  * <pre>
102  * {@code
103  * UDDIClient uddiClient = new UDDIClient();
104  * UDDIClerk clerk = uddiClient.getClerk(clerkName);
105  * }
106  * </pre> where the clerkName "MyClerk" is defined as attribute on the clerk
107  * element
108  * <pre>
109  * {@code
110  *  <clerks registerOnStartup="true">
111  *    <clerk name="MyClerk" node="default" publisher="root" password="root" isPasswordEncrypted="false" cryptoProvider="">
112  *      <class>org.apache.juddi.example.HelloWorldImpl</class>
113  *    </clerk>
114  *  </clerks>
115  * }
116  * </pre> Credentials: In the clerk section you need to specify the publisher to
117  * be used, as well the password. The password can be encrypted and a
118  * cryptoProvider class can be set.
119  *
120  * UDDI Annotations: If you want to register classes containing UDDIAnnotations,
121  * then you need to set registerOnStartup="true" and you can list the classes
122  * with the annotations as subelements. See the HelloWorldImpl class above, as
123  * well as the uddi-annotations example.
124  *
125  * @author kstam
126  *
127  */
128 public class UDDIClerk implements Serializable {
129 
130         private static final long serialVersionUID = -8597375975981358134L;
131 
132         private static final Log log = LogFactory.getLog(UDDIClerk.class);
133         protected String name;
134         protected UDDINode uddiNode;
135         protected String publisher;
136         protected String password;
137         private Date tokenBirthDate;
138         private String authToken;
139         private String cryptoProvider;
140         private boolean isencrypted = false;
141         private String[] classWithAnnotations;
142         private WSDL[] wsdls;
143         private String managerName;
144         private Map<String, Properties> services = new HashMap<String, Properties>();
145 
146         /**
147          * use caution calling the default constructor, many of the functions of
148          * the UDDI Clerk will not function unless manually set. The Node must
149          * be set for using most of the functions provided by this class.
150          */
151         public UDDIClerk() {
152                 super();
153         }
154 
155         public UDDIClerk(Clerk clerk) {
156                 super();
157                 this.name = clerk.getName();
158                 this.password = clerk.getPassword();
159                 this.publisher = clerk.getPublisher();
160                 this.uddiNode = new UDDINode(clerk.getNode());
161         }
162 
163         /**
164          * A list of classes defined in the config file that have UDDI
165          * Annotations on them for automated registration
166          * <br>client.clerks.clerk(" + i + ").class
167          *
168          * @return classes with UDDI Annotations
169          * @see org.apache.juddi.v3.annotations.UDDIService
170          * @see org.apache.juddi.v3.annotations.UDDIServiceBinding
171          */
172         public String[] getClassWithAnnotations() {
173                 return classWithAnnotations;
174         }
175 
176         /**
177          * Returns the UDDI node that this clerk is associated with
178          * client.clerks.clerk(" + i + ")@node
179          *
180          * @return UDDINode
181          */
182         public UDDINode getUDDINode() {
183                 return this.uddiNode;
184         }
185         
186         public UDDINode getUDDINode(Node apinode) {
187                 if (apinode==null)
188                         return this.uddiNode;
189                 if (nodecache.containsKey(apinode.getClientName() + apinode+getName()))
190                         return nodecache.get(apinode.getClientName() + apinode+getName());
191                 UDDINode node = new UDDINode(apinode);
192                 nodecache.put(apinode.getClientName() + apinode+getName(),node);
193                 return node;
194         }
195         Map <String, UDDINode> nodecache = new HashMap<String, UDDINode>();
196         /**
197          * A list of classes defined in the config file that have UDDI
198          * Annotations on them for automated registration
199          * <br>client.clerks.clerk(" + i + ").class
200          *
201          * @see org.apache.juddi.v3.annotations.UDDIService
202          * @see org.apache.juddi.v3.annotations.UDDIServiceBinding
203          */
204         public void setClassWithAnnotations(String[] classWithAnnotations) {
205                 this.classWithAnnotations = classWithAnnotations;
206         }
207 
208         /**
209          * This is not used within the jUDDI code base and will be removed in the next release
210          *
211          * @return a map
212          * @deprecated 
213          */
214         @Deprecated
215         public Map<String, Properties> getServices() {
216                 return services;
217         }
218 
219         /**
220          * This is not used within the jUDDI code base and will be removed in the next release
221          * @param services
222          * @deprecated 
223          */
224         @Deprecated
225         public void setServices(Map<String, Properties> services) {
226                 this.services = services;
227         }
228 
229         /**
230          * The client manager name as defined in the config file client[@name]
231          *
232          * @return the manager name
233          */
234         public String getManagerName() {
235                 return managerName;
236         }
237 
238         /**
239          * The client manager name as defined in the config file client[@name]
240          *
241          * @param managerName
242          */
243         public void setManagerName(String managerName) {
244                 this.managerName = managerName;
245         }
246 
247         /**
248          * Performans the process of parsing the configuration defined wsdls to
249          * UDDI. This is a convenience wrapper Note, if registration fails, no
250          * exception is thrown
251          */
252         public void registerWsdls() {
253                 registerWsdls(null);
254         }
255 
256         /**
257          * Registers the WSDL files referenced in the clerk onto the UDDI node
258          * referenced by the clerk. Note, if registration fails, no exception is
259          * thrown
260          * <pre>
261          * {@code
262          * <clerks registerOnStartup="false">
263          *     <clerk name="joe" node="default" publisher="joepublisher" password="joepublisher" isPasswordEncrypted="false" cryptoProvider="">
264          *        <wsdl businessName="WSDL-Business">wsdl/helloworld.wsdl</wsdl>
265          *     </clerk>
266          *  </clerks>
267          * }
268          * </pre>
269          *
270          * @param localizerBaseUrl - The baseUrl part which will be used when
271          * building the bindingTemplate.
272          */
273         public void registerWsdls(URL localizerBaseUrl) {
274                 if (this.getWsdls() != null) {
275                         Properties properties = new Properties();
276                         properties.putAll(this.getUDDINode().getProperties());
277 
278                         for (WSDL wsdl : this.getWsdls()) {
279                                 try {
280                                         URL wsdlUrl = this.getClass().getClassLoader().getResource(wsdl.getFileName());
281                                         ReadWSDL rw = new ReadWSDL();
282                                         Definition wsdlDefinition = rw.readWSDL(wsdlUrl);
283                                         if (wsdl.keyDomain != null) {
284                                                 properties.setProperty("keyDomain", wsdl.keyDomain);
285                                         }
286                                         if (wsdl.businessKey != null) {
287                                                 properties.setProperty("businessKey", wsdl.getBusinessKey());
288                                         }
289 
290                                         WSDL2UDDI wsdl2UDDI = new WSDL2UDDI(this, new URLLocalizerDefaultImpl(localizerBaseUrl), properties);
291                                         wsdl2UDDI.registerBusinessServices(wsdlDefinition);
292                                 } catch (Exception e) {
293                                         log.error("Unable to register wsdl " + wsdl.getFileName() + " ." + e.getMessage(), e);
294                                 } catch (Throwable t) {
295                                         log.error("Unable to register wsdl " + wsdl.getFileName() + " ." + t.getMessage(), t);
296                                 }
297                         }
298                 }
299         }
300 
301         /**
302          * Registers a WSDL Definition onto the UDDI node referenced by the
303          * clerk. Note, if registration fails, no exception is thrown
304          *
305          * @param wsdlDefinition - the WSDL Definition
306          * @param keyDomain - the keyDomain which will be used to construct the
307          * UDDI key IDs. If left null the keyDomain defined in the node's
308          * properties will be used.
309          * @param businessKey - the key of the business to which this service
310          * belongs. If left null the businessKey defined in the node's
311          * properties will be used.
312          *
313          */
314         public void registerWsdls(Definition wsdlDefinition, String keyDomain, String businessKey) {
315 
316                 try {
317                         Properties properties = new Properties();
318                         properties.putAll(this.getUDDINode().getProperties());
319                         if (keyDomain != null) {
320                                 properties.setProperty("keyDomain", keyDomain);
321                         }
322                         if (businessKey != null) {
323                                 properties.setProperty("businessKey", businessKey);
324                         }
325 
326                         WSDL2UDDI wsdl2UDDI = new WSDL2UDDI(this, new URLLocalizerDefaultImpl(), properties);
327                         wsdl2UDDI.registerBusinessServices(wsdlDefinition);
328                 } catch (Exception e) {
329                         log.error("Unable to register wsdl " + " ." + e.getMessage(), e);
330                 } catch (Throwable t) {
331                         log.error("Unable to register wsdl " + " ." + t.getMessage(), t);
332                 }
333         }
334 
335         /**
336          * Removes the UDDI data structures belonging to the WSDLs for this
337          * clerk from the UDDI node. Note, if registration fails, no exception
338          * is thrown
339          */
340         public void unRegisterWsdls() {
341                 if (this.getWsdls() != null) {
342                         Properties properties = new Properties();
343                         properties.putAll(this.getUDDINode().getProperties());
344 
345                         for (WSDL wsdl : this.getWsdls()) {
346                                 try {
347                                         URL wsdlUrl = this.getClass().getClassLoader().getResource(wsdl.getFileName());
348                                         ReadWSDL rw = new ReadWSDL();
349                                         Definition wsdlDefinition = rw.readWSDL(wsdlUrl);
350                                         if (wsdl.keyDomain != null) {
351                                                 properties.setProperty("keyDomain", wsdl.keyDomain);
352                                         }
353                                         if (wsdl.businessKey != null) {
354                                                 properties.setProperty("businessKey", wsdl.getBusinessKey());
355                                         }
356 
357                                         WSDL2UDDI wsdl2UDDI = new WSDL2UDDI(this, new URLLocalizerDefaultImpl(), properties);
358                                         wsdl2UDDI.unRegisterBusinessServices(wsdlDefinition);
359                                 } catch (Exception e) {
360                                         log.error("Unable to register wsdl " + wsdl.getFileName() + " ." + e.getMessage(), e);
361                                 } catch (Throwable t) {
362                                         log.error("Unable to register wsdl " + wsdl.getFileName() + " ." + t.getMessage(), t);
363                                 }
364                         }
365                 }
366         }
367 
368         /**
369          * Registers the Subscription that is passed in to the UDDI node for
370          * this clerk.
371          *
372          * Note, if registration fails, no exception is thrown
373          *
374          * @param subscription
375          * @return a subscription object, or null if failed
376          */
377         public Subscription register(Subscription subscription) {
378                 return register(subscription, this.getUDDINode().getApiNode());
379         }
380 
381         /**
382          * Register a Subscription to UDDI node passed in. Make sure you use a
383          * clerk that has credentials for this node. Note, if registration
384          * fails, no exception is thrown
385          *
386          * @param subscription a UDDI subscription, remember only one filter
387          * type is allowed by UDDI
388          * @param node the UDDI node referenced from the config file
389          * @return the potentially UDDI server modified subscription
390          */
391         public Subscription register(Subscription subscription, Node node) {
392 
393                 log.info("Registering subscription with key " + subscription.getSubscriptionKey());
394                 Holder<List<Subscription>> holder = new Holder<List<Subscription>>();
395                 try {
396                         List<Subscription> subscriptions = new ArrayList<Subscription>();
397                         subscriptions.add(subscription);
398                         holder.value = subscriptions;
399                         getUDDINode(node).getTransport().getUDDISubscriptionService(node.getSubscriptionUrl()).
400                                 saveSubscription(getAuthToken(node.getSecurityUrl()), holder);
401                         if (log.isDebugEnabled()) {
402                                 log.debug("Registering subscription " + subscription.getSubscriptionKey() + " completed.");
403                         }
404                 } catch (Exception e) {
405                         log.error("Unable to register subscription " + subscription.getSubscriptionKey()
406                                 + " ." + e.getMessage(), e);
407                 } catch (Throwable t) {
408                         log.error("Unable to register subscriptionl " + subscription.getSubscriptionKey()
409                                 + " ." + t.getMessage(), t);
410                 }
411                 subscription = holder.value.get(0);
412                 return subscription;
413         }
414 
415         /**
416          * Register a tModel, using the node of current clerk ('this'). Note, if
417          * registration fails, no exception is thrown
418          *
419          * @param tModel
420          * @return the TModelDetail of the newly registered TModel
421          */
422         public TModelDetail register(TModel tModel) {
423                 return register(tModel, this.getUDDINode().getApiNode());
424         }
425 
426         /**
427          * Register a tModel. Note, if registration fails, no exception is
428          * thrown
429          *
430          * @param tModel
431          * @param node
432          * @return a tModel object or null if registration failed
433          */
434         public TModelDetail register(TModel tModel, Node node) {
435                 TModelDetail tModelDetail = null;
436                 log.info("Registering tModel with key " + tModel.getTModelKey());
437                 try {
438                         SaveTModel saveTModel = new SaveTModel();
439                         saveTModel.setAuthInfo(getAuthToken(node.getSecurityUrl()));
440                         saveTModel.getTModel().add(tModel);
441                         tModelDetail = getUDDINode(node).getTransport().getUDDIPublishService(node.getPublishUrl()).saveTModel(saveTModel);
442                         if (log.isDebugEnabled()) {
443                                 log.debug("Registering tModel " + tModel.getTModelKey() + " completed.");
444                         }
445                 } catch (Exception e) {
446                         log.error("Unable to register tModel " + tModel.getTModelKey()
447                                 + " ." + e.getMessage(), e);
448                 } catch (Throwable t) {
449                         log.error("Unable to register tModel " + tModel.getTModelKey()
450                                 + " ." + t.getMessage(), t);
451                 }
452                 return tModelDetail;
453         }
454 
455         /**
456          * Register a BindingTemplate, using the node of current clerk ('this').
457          * Note, if registration fails, no exception is thrown
458          *
459          * @param binding
460          * @return a binding object or null
461          */
462         public BindingTemplate register(BindingTemplate binding) {
463                 return register(binding, this.getUDDINode().getApiNode());
464         }
465 
466         /**
467          * Register a BindingTemplate. Note, if registration fails, no exception
468          * is thrown
469          *
470          * @param binding
471          * @param node
472          * @return a binding object or null
473          */
474         public BindingTemplate register(BindingTemplate binding, Node node) {
475 
476                 BindingTemplate bindingTemplate = null;
477                 log.info("Registering bindingTemplate with key " + binding.getBindingKey());
478                 try {
479                         SaveBinding saveBinding = new SaveBinding();
480                         saveBinding.setAuthInfo(getAuthToken(node.getSecurityUrl()));
481                         saveBinding.getBindingTemplate().add(binding);
482                         BindingDetail bindingDetail = getUDDINode(node).getTransport().getUDDIPublishService(node.getPublishUrl()).saveBinding(saveBinding);
483                         bindingTemplate = bindingDetail.getBindingTemplate().get(0);
484                         if (log.isDebugEnabled()) {
485                                 log.debug("Registering template binding " + bindingTemplate.getBindingKey() + " completed.");
486                         }
487                 } catch (Exception e) {
488                         log.error("Unable to register template binding " + binding.getBindingKey()
489                                 + " ." + e.getMessage(), e);
490                 } catch (Throwable t) {
491                         log.error("Unable to register template binding " + binding.getBindingKey()
492                                 + " ." + t.getMessage(), t);
493                 }
494                 return bindingTemplate;
495         }
496 
497         /**
498          * Register a service, using the node of current clerk ('this'). Note,
499          * if registration fails, no exception is thrown and null is returned
500          *
501          * @param service
502          * @return a service object or null
503          */
504         public BusinessService register(BusinessService service) {
505                 return register(service, this.getUDDINode().getApiNode());
506         }
507 
508         /**
509          * Register a service.
510          *
511          * Note, if registration fails, no exception is thrown
512          *
513          * @param service the element returned by the server, it may be modified
514          * from the original
515          * @param node
516          * @return the potentially modified service by the UDDI server or NULL if save failed
517          */
518         public BusinessService register(BusinessService service, Node node) {
519 
520                 BusinessService businessService = null;
521                 if (service.getName().isEmpty()){
522                         log.error("Unable to register service, a 'name' element is required");
523                         return null;
524                 }
525                 log.info("Registering service " + service.getName().get(0).getValue()
526                         + " with key " + service.getServiceKey());
527                 try {
528                         SaveService saveService = new SaveService();
529                         saveService.setAuthInfo(getAuthToken(node.getSecurityUrl()));
530                         saveService.getBusinessService().add(service);
531                         ServiceDetail serviceDetail = getUDDINode(node).getTransport().getUDDIPublishService(node.getPublishUrl()).saveService(saveService);
532                         businessService = serviceDetail.getBusinessService().get(0);
533                         if (log.isDebugEnabled()) {
534                                 log.debug("Registering service " + service.getName().get(0).getValue() + " completed.");
535                         }
536                 } catch (Exception e) {
537                         log.error("Unable to register service " + service.getName().get(0).getValue()
538                                 + " ." + e.getMessage(), e);
539                 } catch (Throwable t) {
540                         log.error("Unable to register service " + service.getName().get(0).getValue()
541                                 + " ." + t.getMessage(), t);
542                 }
543                 return businessService;
544         }
545 
546         /**
547          * registers a UDDI business. This is a convenience wrapper
548          *
549          * @param business
550          * @return a possibility modified business entity as registered or NULL if the save failed
551          */
552         public BusinessEntity register(BusinessEntity business) {
553                 return register(business, this.getUDDINode().getApiNode());
554         }
555 
556         /**
557          * Registers a UDDI Business referencing the specified Node from the
558          * config file
559          *
560          * @param business
561          * @param node
562          * @return a possibility modified business entity as registered or NULL if the save failed
563          */
564         public BusinessEntity register(BusinessEntity business, Node node) {
565 
566                 if (business.getName().get(0) == null) {
567                         log.error("Unable to register business because no Name elements have been added.");
568                         return null;
569                 }
570                 BusinessEntity businessEntity = null;
571                 log.info("Registering business " + business.getName().get(0).getValue()
572                         + " with key " + business.getBusinessKey());
573                 try {
574                         SaveBusiness saveBusiness = new SaveBusiness();
575                         saveBusiness.setAuthInfo(getAuthToken(node.getSecurityUrl()));
576                         saveBusiness.getBusinessEntity().add(business);
577                         BusinessDetail businessDetail = getUDDINode(node).getTransport().getUDDIPublishService(node.getPublishUrl()).saveBusiness(saveBusiness);
578                         businessEntity = businessDetail.getBusinessEntity().get(0);
579                         if (log.isDebugEnabled()) {
580                                 log.debug("Registering businessEntity " + businessEntity.getName().get(0).getValue() + " completed.");
581                         }
582                 } catch (Exception e) {
583                         log.error("Unable to register business " + business.getName().get(0).getValue()
584                                 + " ." + e.getMessage(), e);
585                 } catch (Throwable t) {
586                         log.error("Unable to register business " + business.getName().get(0).getValue()
587                                 + " ." + t.getMessage(), t);
588                 }
589                 return businessEntity;
590         }
591 
592         /**
593          * removes a business from UDDI. This is a convenience wrapper Note, if
594          * registration fails, no exception is thrown
595          *
596          * @param businessKey
597          */
598         public void unRegisterBusiness(String businessKey) {
599                 unRegisterBusiness(businessKey, this.getUDDINode().getApiNode());
600         }
601 
602         /**
603          * Unregisters the service with specified serviceKey using the specified
604          * Node, as defined in the config file Note, if registration fails, no
605          * exception is thrown
606          *
607          * @param businessKey
608          * @param node
609          */
610         public void unRegisterBusiness(String businessKey, Node node) {
611                 log.info("UnRegistering the business " + businessKey);
612                 try {
613                         DeleteBusiness deleteBusiness = new DeleteBusiness();
614                         deleteBusiness.setAuthInfo(getAuthToken(node.getSecurityUrl()));
615                         deleteBusiness.getBusinessKey().add(businessKey);
616                         getUDDINode(node).getTransport().getUDDIPublishService(node.getPublishUrl()).deleteBusiness(deleteBusiness);
617                 } catch (Exception e) {
618                         log.error("Unable to register service " + businessKey
619                                 + " ." + e.getMessage(), e);
620                 }
621         }
622 
623         /**
624          * removes a service by key. This is a convenience wrapper Note, if
625          * registration fails, no exception is thrown
626          *
627          * @param serviceKey
628          */
629         public void unRegisterService(String serviceKey) {
630                 unRegisterService(serviceKey, this.getUDDINode().getApiNode());
631         }
632 
633         /**
634          * Unregisters the service with specified serviceKey. Note, if
635          * registration fails, no exception is thrown
636          *
637          * @param serviceKey
638          * @param node
639          */
640         public void unRegisterService(String serviceKey, Node node) {
641                 log.info("UnRegistering the service " + serviceKey);
642                 try {
643                         DeleteService deleteService = new DeleteService();
644                         deleteService.setAuthInfo(getAuthToken(node.getSecurityUrl()));
645                         deleteService.getServiceKey().add(serviceKey);
646                         getUDDINode(node).getTransport().getUDDIPublishService(node.getPublishUrl()).deleteService(deleteService);
647                 } catch (Exception e) {
648                         log.error("Unable to register service " + serviceKey
649                                 + " ." + e.getMessage(), e);
650                 }
651         }
652 
653         /**
654          * removes a binding by key. This is a convenience wrapper Note, if
655          * registration fails, no exception is thrown
656          *
657          * @param bindingKey
658          */
659         public void unRegisterBinding(String bindingKey) {
660                 unRegisterBinding(bindingKey, this.getUDDINode().getApiNode());
661         }
662 
663         /**
664          * Unregisters the BindingTemplate with specified bindingKey and
665          * referenced node defined in the config file Note, if registration
666          * fails, no exception is thrown
667          *
668          * @param bindingKey
669          * @param node
670          */
671         public void unRegisterBinding(String bindingKey, Node node) {
672                 log.info("UnRegistering binding key " + bindingKey);
673                 try {
674                         DeleteBinding deleteBinding = new DeleteBinding();
675                         deleteBinding.setAuthInfo(getAuthToken(node.getSecurityUrl()));
676                         deleteBinding.getBindingKey().add(bindingKey);
677                         getUDDINode(node).getTransport().getUDDIPublishService(node.getPublishUrl()).deleteBinding(deleteBinding);
678                 } catch (Exception e) {
679                         log.error("Unable to unregister bindingkey " + bindingKey
680                                 + " ." + e.getMessage(), e);
681                 }
682         }
683 
684         /**
685          * removes a tModel. Note, UDDI just flags tModels as deleted, it will
686          * still be accessible but not returned in a search. This is a
687          * convenience wrapper Note, if registration fails, no exception is
688          * thrown
689          *
690          * @param tModelKey
691          */
692         public void unRegisterTModel(String tModelKey) {
693                 unRegisterTModel(tModelKey, this.getUDDINode().getApiNode());
694         }
695 
696         /**
697          * Unregisters the BindingTemplate with specified bindingKey. Note, if
698          * registration fails, no exception is thrown
699          *
700          * @param tModelKey
701          * @param node
702          */
703         public void unRegisterTModel(String tModelKey, Node node) {
704                 log.info("UnRegistering tModel key " + tModelKey);
705                 try {
706                         String authToken = getAuthToken(node.getSecurityUrl());
707                         DeleteTModel deleteTModel = new DeleteTModel();
708                         deleteTModel.setAuthInfo(authToken);
709                         deleteTModel.getTModelKey().add(tModelKey);
710                         getUDDINode(node).getTransport().getUDDIPublishService(node.getPublishUrl()).deleteTModel(deleteTModel);
711                 } catch (Exception e) {
712                         log.error("Unable to unregister tModelkey " + tModelKey
713                                 + " ." + e.getMessage(), e);
714                 }
715         }
716 
717         /**
718          * removes a subscription by key. This is a convenience wrapper Note, if
719          * registration fails, no exception is thrown
720          *
721          * @param subscriptionKey
722          */
723         public void unRegisterSubscription(String subscriptionKey) {
724                 unRegisterSubscription(subscriptionKey, this.getUDDINode().getApiNode());
725         }
726 
727         /**
728          * removes a subscription by key, referencing the specified node in the
729          * config file Note, if registration fails, no exception is thrown
730          *
731          * @param subscriptionKey
732          * @param node
733          */
734         public void unRegisterSubscription(String subscriptionKey, Node node) {
735                 log.info("UnRegistering subscription with key " + subscriptionKey);
736                 try {
737                         String authToken = getAuthToken(node.getSecurityUrl());
738                         DeleteSubscription deleteSubscription = new DeleteSubscription();
739                         deleteSubscription.setAuthInfo(authToken);
740                         deleteSubscription.getSubscriptionKey().add(subscriptionKey);
741                         getUDDINode(node).getTransport().getUDDISubscriptionService(node.getSubscriptionUrl()).deleteSubscription(deleteSubscription);
742                 } catch (Exception e) {
743                         log.error("Unable to unregister subscription key " + subscriptionKey
744                                 + " ." + e.getMessage(), e);
745                 }
746         }
747 
748         /**
749          * finds a tmodel. This is a convenience wrapper
750          *
751          * @param findTModel
752          * @return null if not found or error
753          * @throws RemoteException
754          * @throws ConfigurationException
755          * @throws TransportException
756          */
757         public TModelList findTModel(FindTModel findTModel) throws RemoteException, ConfigurationException, TransportException {
758                 return findTModel(findTModel, this.getUDDINode().getApiNode());
759         }
760 
761         /**
762          * finds a tModel
763          *
764          * @param findTModel
765          * @param node
766          * @return null if not found or error
767          * @throws RemoteException
768          * @throws TransportException
769          * @throws ConfigurationException
770          */
771         public TModelList findTModel(FindTModel findTModel, Node node) throws RemoteException,
772                 TransportException, ConfigurationException {
773 
774                 findTModel.setAuthInfo(getAuthToken(node.getSecurityUrl()));
775                 try {
776                         TModelList tModelList = getUDDINode(node).getTransport().getUDDIInquiryService(node.getInquiryUrl()).findTModel(findTModel);
777                         return tModelList;
778                 } catch (DispositionReportFaultMessage dr) {
779                         DispositionReport report = DispositionReportFaultMessage.getDispositionReport(dr);
780                         checkForErrorInDispositionReport(report, null, null);
781                 } catch (SOAPFaultException sfe) {
782                         DispositionReport report = DispositionReportFaultMessage.getDispositionReport(sfe);
783                         checkForErrorInDispositionReport(report, null, null);
784                 } catch (UndeclaredThrowableException ute) {
785                         DispositionReport report = DispositionReportFaultMessage.getDispositionReport(ute);
786                         checkForErrorInDispositionReport(report, null, null);
787                 }catch (Throwable t){
788                      throw new RemoteException("Unhandled exception", t);
789                 }
790                 return null;
791         }
792 
793         /**
794          * Gets the details of a tModel by the key. This is a convenience
795          * wrapper
796          *
797          * @param tModelKey
798          * @return null if not found or error, otherwise the details of the
799          * tModel(s)
800          * @throws RemoteException
801          * @throws ConfigurationException
802          * @throws TransportException
803          */
804         public TModelDetail getTModelDetail(String tModelKey) throws RemoteException, ConfigurationException, TransportException {
805                 GetTModelDetail getTModelDetail = new GetTModelDetail();
806                 getTModelDetail.getTModelKey().add(tModelKey);
807                 return getTModelDetail(getTModelDetail);
808         }
809 
810         /**
811          * Gets the details of a tModel by the key. This is a convenience
812          * wrapper
813          *
814          * @param getTModelDetail
815          * @return null if not found or error
816          * @throws RemoteException
817          * @throws ConfigurationException
818          * @throws TransportException
819          */
820         public TModelDetail getTModelDetail(GetTModelDetail getTModelDetail) throws RemoteException, ConfigurationException, TransportException {
821                 return getTModelDetail(getTModelDetail, this.getUDDINode().getApiNode());
822         }
823 
824         /**
825          * Gets the details of a tModel by the key using the referenced Node
826          * from the config file
827          *
828          * @param getTModelDetail
829          * @param node
830          * @return null if not found or error
831          * @throws RemoteException
832          * @throws TransportException
833          * @throws ConfigurationException
834          */
835         public TModelDetail getTModelDetail(GetTModelDetail getTModelDetail, Node node) throws RemoteException,
836                 TransportException, ConfigurationException {
837 
838                 getTModelDetail.setAuthInfo(getAuthToken(node.getSecurityUrl()));
839                 try {
840                         TModelDetail tModelDetail = getUDDINode(node).getTransport().getUDDIInquiryService(node.getInquiryUrl()).getTModelDetail(getTModelDetail);
841                         return tModelDetail;
842                 } catch (DispositionReportFaultMessage dr) {
843                         DispositionReport report = DispositionReportFaultMessage.getDispositionReport(dr);
844                         checkForErrorInDispositionReport(report, null, null);
845                 } catch (SOAPFaultException sfe) {
846                         DispositionReport report = DispositionReportFaultMessage.getDispositionReport(sfe);
847                         checkForErrorInDispositionReport(report, null, null);
848                 } catch (UndeclaredThrowableException ute) {
849                         DispositionReport report = DispositionReportFaultMessage.getDispositionReport(ute);
850                         checkForErrorInDispositionReport(report, null, null);
851                 }catch (Throwable t){
852                      throw new RemoteException("Unhandled exception", t);
853                 }
854                 return null;
855         }
856 
857         /**
858          * Finds a service by the key, . This is a convenience wrapper
859          *
860          * @param serviceKey
861          * @return null if not found or error
862          * @throws RemoteException
863          * @throws TransportException
864          * @throws ConfigurationException
865          */
866         public BusinessService getServiceDetail(String serviceKey) throws RemoteException,
867                 TransportException, ConfigurationException {
868                 return getServiceDetail(serviceKey, this.getUDDINode().getApiNode());
869         }
870 
871         /**
872          * Finds a service by the key, . This is a convenience wrapper
873          *
874          * @param serviceKey
875          * @return null if not found or error
876          * @throws RemoteException
877          * @throws TransportException
878          * @throws ConfigurationException
879          * @deprecated see getServiceDetail
880          */
881         @Deprecated
882         public BusinessService findService(String serviceKey) throws RemoteException,
883                 TransportException, ConfigurationException {
884                 return getServiceDetail(serviceKey, this.getUDDINode().getApiNode());
885         }
886 
887         /**
888          * Finds a service by the key, referencing the specific Node from the
889          * configuration file
890          *
891          * @param serviceKey
892          * @param node
893          * @return null if not found or error
894          * @throws RemoteException
895          * @throws TransportException
896          * @throws ConfigurationException
897          * @deprecated see getServiceDetail
898          */
899         @Deprecated
900         public BusinessService findService(String serviceKey, Node node) throws RemoteException,
901                 TransportException, ConfigurationException {
902                 return getServiceDetail(serviceKey, node);
903         }
904 
905         /**
906          * Finds a service by the key, referencing the specific Node from the
907          * configuration file
908          *
909          * @param serviceKey
910          * @param node
911          * @return null if not found or error
912          * @throws RemoteException
913          * @throws TransportException
914          * @throws ConfigurationException
915          */
916         public BusinessService getServiceDetail(String serviceKey, Node node) throws RemoteException,
917                 TransportException, ConfigurationException {
918                 GetServiceDetail getServiceDetail = new GetServiceDetail();
919                 getServiceDetail.getServiceKey().add(serviceKey);
920                 getServiceDetail.setAuthInfo(getAuthToken(node.getSecurityUrl()));
921                 try {
922                         ServiceDetail sd = getUDDINode(node).getTransport().getUDDIInquiryService(node.getInquiryUrl()).getServiceDetail(getServiceDetail);
923                         List<BusinessService> businessServiceList = sd.getBusinessService();
924                         if (businessServiceList.size() == 0) {
925                                 throw new ConfigurationException("Could not find Service with key=" + serviceKey);
926                         }
927                         return businessServiceList.get(0);
928                 } catch (DispositionReportFaultMessage dr) {
929                         DispositionReport report = DispositionReportFaultMessage.getDispositionReport(dr);
930                         checkForErrorInDispositionReport(report, DispositionReport.E_INVALID_KEY_PASSED, serviceKey);
931                 } catch (SOAPFaultException sfe) {
932                         DispositionReport report = DispositionReportFaultMessage.getDispositionReport(sfe);
933                         checkForErrorInDispositionReport(report, DispositionReport.E_INVALID_KEY_PASSED, serviceKey);
934                 } catch (UndeclaredThrowableException ute) {
935                         DispositionReport report = DispositionReportFaultMessage.getDispositionReport(ute);
936                         checkForErrorInDispositionReport(report, DispositionReport.E_INVALID_KEY_PASSED, serviceKey);
937                 }catch (Throwable t){
938                      throw new RemoteException("Unhandled exception", t);
939                 }
940                 return null;
941         }
942 
943         /**
944          *
945          * @param bindingKey
946          * @return returns a binding template or null if not found
947          * @throws DispositionReportFaultMessage
948          * @throws RemoteException
949          * @throws TransportException
950          * @throws ConfigurationException
951          * @deprecated see getServiceBindingDetail
952          */
953         @Deprecated
954         public BindingTemplate findServiceBinding(String bindingKey) throws DispositionReportFaultMessage, RemoteException,
955                 TransportException, ConfigurationException {
956                 return getServiceBindingDetail(bindingKey, this.getUDDINode().getApiNode());
957         }
958 
959         /**
960          * gets a binding detail by key
961          *
962          * @param bindingKey
963          * @return null if not found or error, or the binding template
964          * @throws DispositionReportFaultMessage
965          * @throws RemoteException
966          * @throws TransportException
967          * @throws ConfigurationException
968          */
969         public BindingTemplate getServiceBindingDetail(String bindingKey) throws DispositionReportFaultMessage, RemoteException,
970                 TransportException, ConfigurationException {
971                 return getServiceBindingDetail(bindingKey, this.getUDDINode().getApiNode());
972         }
973 
974         /**
975          * @deprecated use getServiceBindingDetail instead
976          * @param bindingKey
977          * @param node
978          * @return null if not found
979          * @throws DispositionReportFaultMessage
980          * @throws RemoteException
981          * @throws TransportException
982          * @throws ConfigurationException
983          * @deprecated
984          */
985         @Deprecated
986         public BindingTemplate findServiceBinding(String bindingKey, Node node) throws DispositionReportFaultMessage, RemoteException,
987                 TransportException, ConfigurationException {
988                 return getServiceBindingDetail(bindingKey, node);
989 
990         }
991 
992         /**
993          * Gets the details of a specific service binding key
994          *
995          * @param bindingKey
996          * @param node
997          * @return null if not found, or error, or the details of the binding
998          * @throws DispositionReportFaultMessage
999          * @throws RemoteException
1000          * @throws TransportException
1001          * @throws ConfigurationException
1002          */
1003         public BindingTemplate getServiceBindingDetail(String bindingKey, Node node) throws DispositionReportFaultMessage, RemoteException,
1004                 TransportException, ConfigurationException {
1005                 GetBindingDetail getBindingDetail = new GetBindingDetail();
1006                 getBindingDetail.getBindingKey().add(bindingKey);
1007                 getBindingDetail.setAuthInfo(getAuthToken(node.getSecurityUrl()));
1008                 try {
1009                         BindingDetail bd = getUDDINode(node).getTransport().getUDDIInquiryService(node.getInquiryUrl()).getBindingDetail(getBindingDetail);
1010                         List<BindingTemplate> bindingTemplateList = bd.getBindingTemplate();
1011                         if (bindingTemplateList.size() == 0) {
1012                                 throw new ConfigurationException("Could not find ServiceBinding with key=" + bindingKey);
1013                         }
1014                         return bindingTemplateList.get(0);
1015                 } catch (DispositionReportFaultMessage dr) {
1016                         DispositionReport report = DispositionReportFaultMessage.getDispositionReport(dr);
1017                         checkForErrorInDispositionReport(report, DispositionReport.E_INVALID_KEY_PASSED, bindingKey);
1018                 } catch (SOAPFaultException sfe) {
1019                         DispositionReport report = DispositionReportFaultMessage.getDispositionReport(sfe);
1020                         checkForErrorInDispositionReport(report, DispositionReport.E_INVALID_KEY_PASSED, bindingKey);
1021                 } catch (UndeclaredThrowableException ute) {
1022                         DispositionReport report = DispositionReportFaultMessage.getDispositionReport(ute);
1023                         checkForErrorInDispositionReport(report, DispositionReport.E_INVALID_KEY_PASSED, bindingKey);
1024                 }catch (Throwable t){
1025                      throw new RemoteException("Unhandled exception", t);
1026                 }
1027                 return null;
1028         }
1029 
1030         /**
1031          * finds a business
1032          *
1033          * @deprecated Use getBusinessDetail instead
1034          * @param businessKey
1035          * @return BusinessEntity if found, or null if not found.
1036          * @throws RemoteException
1037          * @throws TransportException
1038          * @throws ConfigurationException
1039          */
1040         @Deprecated
1041         public BusinessEntity findBusiness(String businessKey) throws RemoteException,
1042                 TransportException, ConfigurationException {
1043                 return getBusinessDetail(businessKey, this.getUDDINode().getApiNode());
1044         }
1045 
1046         /**
1047          * Looks up the BusinessEntiry in the registry, will return null if is
1048          * not found.
1049          *
1050          * @deprecated Use getBusinessDetail instead
1051          * @param businessKey - the key we are looking for
1052          * @param node - the node which is going to be queried
1053          * @return BusinessEntity if found, or null if not found.
1054          * @throws RemoteException
1055          * @throws TransportException
1056          * @throws ConfigurationException
1057          */
1058         @Deprecated
1059         public BusinessEntity findBusiness(String businessKey, Node node) throws RemoteException,
1060                 TransportException, ConfigurationException {
1061                 return getBusinessDetail(businessKey, node);
1062         }
1063 
1064         /**
1065          * Looks up the BusinessEntiry in the registry, will return null if is
1066          * not found.
1067          *
1068          * @param businessKey - the key we are looking for
1069          * @return BusinessEntity is found, or null if not found.
1070          * @throws RemoteException
1071          * @throws TransportException
1072          * @throws ConfigurationException
1073          */
1074         public BusinessEntity getBusinessDetail(String businessKey) throws RemoteException,
1075                 TransportException, ConfigurationException {
1076                 return getBusinessDetail(businessKey, this.getUDDINode().getApiNode());
1077         }
1078 
1079         /**
1080          * Looks up the BusinessEntiry in the registry, will return null if is
1081          * not found.
1082          *
1083          * @param businessKey - the key we are looking for
1084          * @param node - the node which is going to be queried
1085          * @return BusinessEntity is found, or null if not found.
1086          * @throws RemoteException
1087          * @throws TransportException
1088          * @throws ConfigurationException
1089          */
1090         public BusinessEntity getBusinessDetail(String businessKey, Node node) throws RemoteException,
1091                 TransportException, ConfigurationException {
1092                 GetBusinessDetail getBusinessDetail = new GetBusinessDetail();
1093                 getBusinessDetail.getBusinessKey().add(businessKey);
1094                 getBusinessDetail.setAuthInfo(node.getSecurityUrl());
1095                 try {
1096                         BusinessDetail bd = getUDDINode(node).getTransport().getUDDIInquiryService(node.getInquiryUrl()).getBusinessDetail(getBusinessDetail);
1097                         return bd.getBusinessEntity().get(0);
1098                 } catch (DispositionReportFaultMessage dr) {
1099                         DispositionReport report = DispositionReportFaultMessage.getDispositionReport(dr);
1100                         checkForErrorInDispositionReport(report, DispositionReport.E_INVALID_KEY_PASSED, businessKey);
1101                 } catch (SOAPFaultException sfe) {
1102                         DispositionReport report = DispositionReportFaultMessage.getDispositionReport(sfe);
1103                         checkForErrorInDispositionReport(report, DispositionReport.E_INVALID_KEY_PASSED, businessKey);
1104                 } catch (UndeclaredThrowableException ute) {
1105                         DispositionReport report = DispositionReportFaultMessage.getDispositionReport(ute);
1106                         checkForErrorInDispositionReport(report, DispositionReport.E_INVALID_KEY_PASSED, businessKey);
1107                 }catch (Throwable t){
1108                      throw new RemoteException("Unhandled exception", t);
1109                 }
1110                 return null;
1111         }
1112 
1113         /**
1114          * Looks up the BusinessEntity in the registry for "related" businesses.
1115          * This means that there is a business relationship defined. This is
1116          * also referred to as a "Publisher Assertion",
1117          *
1118          * @see PublisherAssertion
1119          * @see PublisherAssertions
1120          * @param businessKey - the key we are looking for
1121          * @param node - the node which is going to be queried
1122          * @return BusinessEntity is found, or null if not found.
1123          * @throws RemoteException
1124          * @throws TransportException
1125          * @throws ConfigurationException
1126          */
1127         public RelatedBusinessesList findRelatedBusinesses(String businessKey, Node node) throws RemoteException,
1128                 TransportException, ConfigurationException {
1129                 FindRelatedBusinesses findRelatedBusinesses = new FindRelatedBusinesses();
1130                 findRelatedBusinesses.setBusinessKey(businessKey);
1131                 findRelatedBusinesses.setAuthInfo(node.getSecurityUrl());
1132                 try {
1133                         RelatedBusinessesList rbl = getUDDINode(node).getTransport().getUDDIInquiryService(node.getInquiryUrl()).findRelatedBusinesses(findRelatedBusinesses);
1134                         return rbl;
1135                 } catch (DispositionReportFaultMessage dr) {
1136                         DispositionReport report = DispositionReportFaultMessage.getDispositionReport(dr);
1137                         checkForErrorInDispositionReport(report, DispositionReport.E_INVALID_KEY_PASSED, businessKey);
1138                 } catch (SOAPFaultException sfe) {
1139                         DispositionReport report = DispositionReportFaultMessage.getDispositionReport(sfe);
1140                         checkForErrorInDispositionReport(report, DispositionReport.E_INVALID_KEY_PASSED, businessKey);
1141                 } catch (UndeclaredThrowableException ute) {
1142                         DispositionReport report = DispositionReportFaultMessage.getDispositionReport(ute);
1143                         checkForErrorInDispositionReport(report, DispositionReport.E_INVALID_KEY_PASSED, businessKey);
1144                 }catch (Throwable t){
1145                      throw new RemoteException("Unhandled exception", t);
1146                 }
1147                 return null;
1148         }
1149 
1150         private void checkForErrorInDispositionReport(DispositionReport report, String Error, String entityKey) {
1151 
1152                 if (entityKey != null && report != null && report.countainsErrorCode(DispositionReport.E_INVALID_KEY_PASSED)) {
1153                         log.info("entityKey " + entityKey + " was not found in the registry");
1154                 } else {
1155                         if (report == null) {
1156                                 log.info("Missing DispositionReport");
1157                         } else {
1158                                 for (Result result : report.getResult()) {
1159                                         log.error(result.getErrInfo().getErrCode() + " " + result.getErrInfo().getValue());
1160                                 }
1161                         }
1162                 }
1163         }
1164 
1165         /**
1166          * kills the current auth token, aka Logout current Node
1167          */
1168         public void discardAuthToken() {
1169                 discardAuthToken(authToken);
1170         }
1171 
1172         /**
1173          * kills the provided auth token, aka Logout
1174          *
1175          * @param token
1176          */
1177         public void discardAuthToken(String token) {
1178                 if (token != null) {
1179                         try {
1180                                 DiscardAuthToken discardAuthToken = new DiscardAuthToken();
1181                                 discardAuthToken.setAuthInfo(token);
1182                                 getUDDINode().getTransport().getUDDISecurityService(getUDDINode().getSecurityUrl()).discardAuthToken(discardAuthToken);
1183                                 token = null;
1184                         } catch (Exception ex) {
1185                                 log.warn("Error discarding auth token: " + ex.getMessage());
1186                                 log.debug("Error discarding auth token: " + ex.getMessage(), ex);
1187                         }
1188                 }
1189         }
1190 
1191         /**
1192          * kills the provided auth token, aka Logout
1193          *
1194          * @param token
1195          * @param endpoint
1196          */
1197         public void discardAuthToken(String token, String endpoint) {
1198                 if (token != null) {
1199                         try {
1200                                 DiscardAuthToken discardAuthToken = new DiscardAuthToken();
1201                                 discardAuthToken.setAuthInfo(token);
1202                                 getUDDINode().getTransport().getUDDISecurityService(endpoint).discardAuthToken(discardAuthToken);
1203                                 token = null;
1204                         } catch (Exception ex) {
1205                                 log.warn("Error discarding auth token: " + ex.getMessage());
1206                                 log.debug("Error discarding auth token: " + ex.getMessage(), ex);
1207                         }
1208                 }
1209         }
1210 
1211         /**
1212          * Gets an auth token from the uddi server using the uddi auth token
1213          * <br>
1214          * Notice: never log auth tokens! Treat it like a password
1215          *
1216          * Calls 
1217          * @return  getAuthToken(getUDDINode().getSecurityUrl());
1218          * @throws TransportException
1219          * @throws DispositionReportFaultMessage
1220          * @throws RemoteException
1221          * @since 3.2
1222          */
1223         public String getAuthToken() throws TransportException, DispositionReportFaultMessage, RemoteException {
1224                 return getAuthToken(getUDDINode().getSecurityUrl());
1225         }
1226         /**
1227          * Gets an auth token from the uddi server using the uddi auth token
1228          * <br>
1229          * Notice: never log auth tokens! Treat it like a password
1230          *
1231          * notes: changed to public to have access from the subscription
1232          * callback API 8/20/2013 AO
1233          *
1234          * @param endpointURL
1235          * @return an auth token
1236          * @throws TransportException
1237          * @throws DispositionReportFaultMessage
1238          * @throws RemoteException
1239          */
1240         public String getAuthToken(String endpointURL) throws TransportException, DispositionReportFaultMessage, RemoteException {
1241                 //if the token is older then 10 minutes discard it, and create a new one.
1242                 if ((authToken != null && !"".equals(authToken)) && (tokenBirthDate != null && System.currentTimeMillis() > tokenBirthDate.getTime() + 600000)) {
1243                         DiscardAuthToken discardAuthToken = new DiscardAuthToken();
1244                         discardAuthToken.setAuthInfo(authToken);
1245                         getUDDINode().getTransport().getUDDISecurityService(endpointURL).discardAuthToken(discardAuthToken);
1246                         authToken = null;
1247                 }
1248                 if (authToken == null || "".equals(authToken)) {
1249                         if (getPublisher()==null || getPassword()==null){
1250                                 log.warn("No credentials provided for login!");
1251                                 return null;
1252                         }
1253                         tokenBirthDate = new Date();
1254                         GetAuthToken getAuthToken = new GetAuthToken();
1255                         getAuthToken.setUserID(getPublisher());
1256                         if (isencrypted) {
1257                                 if (cryptoProvider == null) {
1258                                         log.fatal("Credentials are encrypted but no cryptoProvider was defined in the config file!");
1259                                 } else {
1260                                         try {
1261                                                 getAuthToken.setCred(CryptorFactory.getCryptor(this.cryptoProvider).decrypt(getPassword()));
1262                                         } catch (Exception ex) {
1263                                                 log.fatal("Unable to decrypt credentials! sending it as is", ex);
1264                                                 getAuthToken.setCred(getPassword());
1265                                         }
1266                                 }
1267                         } else {
1268                                 log.warn("Hey, I couldn't help but notice that your credentials aren't encrypted. Please consider doing so");
1269                                 getAuthToken.setCred(getPassword());
1270                         }
1271                         authToken = getUDDINode().getTransport().getUDDISecurityService(endpointURL).getAuthToken(getAuthToken).getAuthInfo();
1272                 }
1273                 return authToken;
1274         }
1275 
1276         /**
1277          * This calls a jUDDI implementation specific API call and is used to
1278          * help configure internode communication between jUDDI servers. This is
1279          * NOT part of the UDDI specification.<br>
1280          * Note: this API call should only be used with secure ports (SSL/TLS)
1281          *
1282          * @param node
1283          * @return a node or null if registration fails
1284          */
1285         public NodeDetail saveNode(Node node) {
1286                 NodeDetail nodeDetail = null;
1287                 try {
1288                         log.info("Sending Node " + node.getName() + " info to jUDDI " + getUDDINode(node).getName());
1289                         SaveNode saveNode = new SaveNode();
1290                         saveNode.setAuthInfo(getAuthToken(node.getSecurityUrl()));
1291                         saveNode.getNode().add(node);
1292                         nodeDetail = getUDDINode(node).getTransport().getJUDDIApiService(node.getJuddiApiUrl()).saveNode(saveNode);
1293                 } catch (Exception e) {
1294                         log.error("Unable to save node " + node.getName()
1295                                 + " ." + e.getMessage(), e);
1296                 } catch (Throwable t) {
1297                         log.error("Unable to save node " + node.getName()
1298                                 + " ." + t.getMessage(), t);
1299                 }
1300                 return nodeDetail;
1301         }
1302 
1303         /**
1304          * This calls a jUDDI implementation specific API call and is used to
1305          * help configure internode communication between jUDDI servers. This is
1306          * NOT part of the UDDI specification.<br>
1307          * Note: this API call should only be used with secure ports (SSL/TLS)
1308          *
1309          * @param senderClerk
1310          * @return null if registration fails
1311          */
1312         public ClerkDetail saveClerk(UDDIClerk senderClerk) {
1313                 ClerkDetail clerkDetail = null;
1314                 try {
1315                         log.debug("Sending Clerk " + senderClerk.getName() + " info to jUDDI " + getUDDINode().getName());
1316                         SaveClerk saveClerk = new SaveClerk();
1317                         saveClerk.setAuthInfo(getAuthToken(senderClerk.getUDDINode().getSecurityUrl()));
1318                         saveClerk.getClerk().add(getApiClerk());
1319                         clerkDetail = getUDDINode().getTransport().getJUDDIApiService(senderClerk.getUDDINode().getJuddiApiUrl()).saveClerk(saveClerk);
1320                 } catch (Exception e) {
1321                         log.error("Unable to save clerk " + getName()
1322                                 + " ." + e.getMessage(), e);
1323                 } catch (Throwable t) {
1324                         log.error("Unable to save clerk " + getName()
1325                                 + " ." + t.getMessage(), t);
1326                 }
1327                 return clerkDetail;
1328         }
1329 
1330         /**
1331          * The API Clerk is the JAXWS generated "Clerk" element that is used
1332          * both on the jUDDI Client and on the jUDDI Web Service (not part of
1333          * the UDDI spec).
1334          *
1335          * @return the config file defined clerk
1336          */
1337         public Clerk getApiClerk() {
1338                 Clerk apiClerk = new Clerk();
1339                 apiClerk.setName(name);
1340                 apiClerk.setNode(uddiNode.getApiNode());
1341                 apiClerk.setPassword(password);
1342                 apiClerk.setPublisher(publisher);
1343                 return apiClerk;
1344         }
1345 
1346         /**
1347          * client.clerks.clerk(" + i + ")[@name]
1348          *
1349          * @return name
1350          */
1351         public String getName() {
1352                 return name;
1353         }
1354 
1355         /**
1356          * client.clerks.clerk(" + i + ")[@name]
1357          *
1358          * @param name
1359          */
1360         public void setName(String name) {
1361                 this.name = name;
1362         }
1363 
1364         /**
1365          * client.clerks.clerk(" + i + ")[@node] reference to UDDI Node
1366          *
1367          * @param uddiNode
1368          */
1369         public void setUDDINode(UDDINode uddiNode) {
1370                 this.uddiNode = uddiNode;
1371         }
1372 
1373         /**
1374          * This is the username client.clerks.clerk(" + i + ")[@publisher]
1375          *
1376          * @return the username
1377          */
1378         public String getPublisher() {
1379                 return publisher;
1380         }
1381 
1382         /**
1383          * This is the username client.clerks.clerk(" + i + ")[@publisher]
1384          *
1385          * @param publisher
1386          */
1387         public void setPublisher(String publisher) {
1388                 this.publisher = publisher;
1389         }
1390 
1391         /**
1392          * If the password is encrypted, it will be decrypted if possible,
1393          * otherwise the cipher text will be returned. client.clerks.clerk(" + i
1394          * + ")[@password]
1395          *
1396          * @return unencrypted password
1397          */
1398         public String getPassword() {
1399                 if (isencrypted) {
1400                         try {
1401                                 return CryptorFactory.getCryptor(cryptoProvider).decrypt(password);
1402                         } catch (Exception ex) {
1403                                 log.fatal("Unable to decrypt the password", ex);
1404                         }
1405                 }
1406                 return password;
1407         }
1408 
1409         /**
1410          * If the password is encrypted, it cipher text is returned, otherwise
1411          * the clear text will be returned. client.clerks.clerk(" + i +
1412          * ")[@password]
1413          *
1414          * @return password as is in the config file
1415          */
1416         public String getRawPassword() {
1417                 return password;
1418         }
1419 
1420         /**
1421          * Use with caution, don't forget to set the IsEncrypted and Crypto
1422          * provider client.clerks.clerk(" + i + ")[@password]
1423          *
1424          * @param password
1425          */
1426         public void setPassword(String password) {
1427                 this.password = password;
1428         }
1429 
1430         /**
1431          * Used for the automated registration of services via WSDL2UDDI<br>
1432          * config file: client.clerks.clerk(" + i + ").wsdl
1433          *
1434          * @return a WSDL array
1435          * @see WSDL2UDDI
1436          */
1437         public WSDL[] getWsdls() {
1438                 return wsdls;
1439         }
1440 
1441         /**
1442          * Used for the automated registration of services via WSDL2UDDI<br>
1443          * config file: client.clerks.clerk(" + i + ").wsdl
1444          *
1445          * @param wsdls
1446          * @see WSDL2UDDI
1447          */
1448         public void setWsdls(WSDL[] wsdls) {
1449                 this.wsdls = wsdls;
1450         }
1451 
1452         /**
1453          * client.clerks.clerk(" + i + ")[@cryptoProvider]
1454          *
1455          * @param clazz
1456          */
1457         public void setCryptoProvider(String clazz) {
1458                 this.cryptoProvider = clazz;
1459         }
1460 
1461         /**
1462          * client.clerks.clerk(" + i + ")[@isPasswordEncrypted] default is false
1463          *
1464          * @param option
1465          */
1466         public void setIsPasswordEncrypted(boolean option) {
1467                 this.isencrypted = option;
1468         }
1469 
1470         /**
1471          * client.clerks.clerk(" + i + ")[@cryptoProvider]
1472          *
1473          * @return may be null if not defined
1474          */
1475         public String getCryptoProvider() {
1476                 return this.cryptoProvider;
1477         }
1478 
1479         /**
1480          * client.clerks.clerk(" + i + ")[@isPasswordEncrypted]
1481          *
1482          * @return true/false
1483          */
1484         public boolean getIsPasswordEncrypted() {
1485                 return this.isencrypted;
1486 
1487         }
1488 
1489         /**
1490          * Internal classed used for wsdl registration
1491          */
1492         public static class WSDL {
1493 
1494                 private String businessKey;
1495                 private String keyDomain;
1496                 private String fileName;
1497 
1498                 public String getBusinessKey() {
1499                         return businessKey;
1500                 }
1501 
1502                 public void setBusinessKey(String businessKey) {
1503                         this.businessKey = businessKey;
1504                 }
1505 
1506                 public String getFileName() {
1507                         return fileName;
1508                 }
1509 
1510                 public void setFileName(String fileName) {
1511                         this.fileName = fileName;
1512                 }
1513 
1514                 public String getKeyDomain() {
1515                         return keyDomain;
1516                 }
1517 
1518                 public void setKeyDomain(String keyDomain) {
1519                         this.keyDomain = keyDomain;
1520                 }
1521         }
1522 
1523         /**
1524          * A helper function to create a tModel key generator.<br>
1525          * Why would I want a key generator? In UDDIv3, you're suppose to
1526          * specify what you want the keys (unique identifiers) to be, however
1527          * there's a number of naming rules associated with the keys. Generally,
1528          * use the FQDN of your business or organization. Optionally, when
1529          * saving an UDDI entity, you can just leave the key name blank and the
1530          * server should generate one for you. It's normally a UUID that's not
1531          * easy to remember. In this case, there's no need to call this method.
1532          * <br><br>
1533          * In addition, no changes are made to the UDDI server. You'll have to
1534          * do that one using code similar to this:
1535          * <pre>
1536          * UDDIClerk clerk = ...
1537          * TModel keygen = UDDIClerk.createKeyGenator("uddi:mydomain.com:keygenerator", "my domain", "en");
1538          * clerk.register(keygen);
1539          *
1540          * @param partitionName think of this as the domain, i.e. juddi.apache.org, but it can really be anything you want. This will become part of the
1541          * key associated with the tModel generator (uddi:juddi.apache.org:keygenerator). The colon ":" is the delimitor, so avoid using them unless you want to
1542          * create nested key domains. If you're missing the "uddi:" prefix or the ":keygenerator" suffix, it will be added automatically.
1543          * @param DescriptiveName required. max length is 255 char
1544          * @param DescriptiveNameLanguage optional, max length is 26 char
1545          * @return a populated tModel entity representing a tModel key
1546          * generator. No changes are made to any connect UDDI service
1547          * @since 3.2
1548          */
1549         public static TModel createKeyGenator(String partitionName, String DescriptiveName, String DescriptiveNameLanguage) {
1550                 if (partitionName == null || partitionName.length() == 0 || partitionName.length() > 255) {
1551                         throw new IllegalArgumentException();
1552                 }
1553 
1554                 if (DescriptiveName == null || DescriptiveName.length() == 0 || DescriptiveName.length() > 255) {
1555                         throw new IllegalArgumentException();
1556                 }
1557                 if (!partitionName.startsWith("uddi:")) {
1558                         //throw new IllegalArgumentException("partitionName must have a 'uddi:' prefix");
1559                         partitionName = "uddi:" + partitionName;
1560 
1561                 }
1562                 if (!partitionName.endsWith(":keygenerator")) {
1563                         //throw new IllegalArgumentException("partitionName must have a ':keygenerator' postfix");
1564                         partitionName = partitionName + ":keygenerator";
1565                 }
1566                 TModel tm = new TModel();
1567                 tm.setName(new Name());
1568                 tm.getName().setValue(DescriptiveName);
1569                 tm.getName().setLang(DescriptiveNameLanguage);
1570                 tm.setCategoryBag(new CategoryBag());
1571                 KeyedReference kr = new KeyedReference();
1572                 kr.setTModelKey(UDDIConstants.KEY_GENERATOR_TMODEL);
1573                 kr.setKeyName(UDDIConstants.KEY_GENERATOR);
1574                 kr.setKeyValue(UDDIConstants.KEY_GENERATOR_VALUE);
1575                 tm.getCategoryBag().getKeyedReference().add(kr);
1576                 OverviewDoc overviewDoc = new OverviewDoc();
1577                 OverviewURL overviewUrl = new OverviewURL();
1578                 overviewUrl.setUseType("text");
1579                 overviewUrl.setValue("http://uddi.org/pubs/uddi_v3.htm#keyGen");
1580                 overviewDoc.setOverviewURL(overviewUrl);
1581                 tm.getOverviewDoc().add(overviewDoc);
1582                 tm.setTModelKey(partitionName.toLowerCase());
1583                 return tm;
1584         }
1585 
1586         /**
1587          * This is a convenience function that will build and return a
1588          * TModelInstanceInfo as described in the following link that will
1589          * enable you to tag web services registered in UDDI with some kind of
1590          * version information.<Br><Br>
1591          * Article source: <a
1592          * href="http://www.ibm.com/developerworks/webservices/library/ws-version/">http://www.ibm.com/developerworks/webservices/library/ws-version/</a>
1593          * <Br><Br>
1594          *
1595          * When using this tModel as a tModelInstance, it can be used to
1596          * describe a version associated with either a service interface, a
1597          * bindingTemplate service instance. Note: This is a jUDDI specific
1598          * addon and may not be present in other registries
1599          *
1600          * @param version From the article, no specificity is provided on what
1601          * to use as a value, but we recommend that you use the string
1602          * representation of major.minor[.build[.revision]].<br>
1603          * Example
1604          * <ul>
1605          * <li>6.1.2.3</li>
1606          * <li>1.0</li>
1607          * <li>0.1</li>
1608          * </ul>
1609          * @return TModelInstanceInfo populated as described in the article,
1610          * plus some descriptive information
1611          */
1612         public static TModelInstanceInfo createServiceInterfaceVersion(String version, String lang) throws IllegalArgumentException {
1613                 if (version == null) {
1614                         throw new IllegalArgumentException();
1615                 }
1616                 TModelInstanceInfo tt = new TModelInstanceInfo();
1617                 tt.setTModelKey(UDDIConstants.VERSION_TMODEL);
1618                 tt.setInstanceDetails(new InstanceDetails());
1619                 tt.getInstanceDetails().setInstanceParms(version);
1620 
1621                 OverviewDoc doc = new OverviewDoc();
1622                 doc.setOverviewURL(new OverviewURL("http://www.ibm.com/developerworks/webservices/library/ws-version/", "text"));
1623                 doc.getDescription().add(new Description(
1624                         "Describes a version associated with either a service interface, a bindingTemplate service instance.", lang));
1625                 tt.getDescription().add(new Description("Describes a version associated with either a service interface, a bindingTemplate service instance.", lang));
1626                 tt.getInstanceDetails().getOverviewDoc().add(doc);
1627                 return tt;
1628         }
1629 
1630         /**
1631          * This is a convenience function that will filter a list of binding
1632          * templates and return a list of bindings matching the specified
1633          * version number.
1634          *
1635          * This implements and expands upon service versioning described in the
1636          * following link and will enable you to tag web services registered in
1637          * UDDI with some kind of version information.<Br><Br>
1638          * Article source: <a
1639          * href="http://www.ibm.com/developerworks/webservices/library/ws-version/">http://www.ibm.com/developerworks/webservices/library/ws-version/</a>
1640          * <Br><Br>
1641          * see {@link #createServiceInterfaceVersion createServiceInterfaceVersion} 
1642          *  for more information<Br><br>
1643          *
1644          * This function operates using tModelInstances that are used to
1645          * describe a version associated with either a service interface, a
1646          * bindingTemplate service instance. Note: This is a jUDDI specific
1647          * addon and may not be present in other registries
1648          *
1649          * @param version From the article, no specificity is provided on what
1650          * to use as a value, but we recommend that you use the string
1651          * representation of major.minor[.build[.revision]].<br>
1652          * Example
1653          * <ul>
1654          * <li>6.1.2.3</li>
1655          * <li>1.0</li>
1656          * <li>0.1</li>
1657          * </ul>
1658          * @param bindingTemplate the input binding template, must not be null
1659          * @return a list if binding templates where the version equals ignoring
1660          * case trimmed equals the version value
1661          * @throws IllegalArgumentException if the version or bindingTemplate is null
1662          */
1663         public static Set<BindingTemplate> getBindingByVersion(String version, List<BindingTemplate> bindingTemplate) throws IllegalArgumentException {
1664                 if (version == null) {
1665                         throw new IllegalArgumentException();
1666                 }
1667                 if (bindingTemplate == null) {
1668                         throw new IllegalArgumentException();
1669                 }
1670                 Set<BindingTemplate> ret = new HashSet<BindingTemplate>();
1671                 for (int i = 0; i < bindingTemplate.size(); i++) {
1672                         if (bindingTemplate.get(i).getTModelInstanceDetails() != null) {
1673                                 for (int k = 0; k < bindingTemplate.get(i).getTModelInstanceDetails().getTModelInstanceInfo().size(); k++) {
1674                                         if (bindingTemplate.get(i).getTModelInstanceDetails().getTModelInstanceInfo().get(k).getTModelKey().equalsIgnoreCase(UDDIConstants.VERSION_TMODEL)) {
1675                                                 if (bindingTemplate.get(i).getTModelInstanceDetails().getTModelInstanceInfo().get(k).getInstanceDetails() != null) {
1676                                                         if (bindingTemplate.get(i).getTModelInstanceDetails().getTModelInstanceInfo().get(k).getInstanceDetails().getInstanceParms() != null) {
1677                                                                 if (bindingTemplate.get(i).getTModelInstanceDetails().getTModelInstanceInfo().get(k).getInstanceDetails().getInstanceParms().trim().equalsIgnoreCase(version.trim())) {
1678                                                                         ret.add(bindingTemplate.get(i));
1679                                                                         break;
1680                                                                 }
1681                                                         }
1682                                                 }
1683                                         }
1684                                 }
1685                         }
1686                 }
1687                 return ret;
1688         }
1689 
1690         /**
1691          * JUDDI-700 This implements the "find_endpoints" pattern as described
1692          * in Alex O'Ree's Master's Thesis on UDDI. Basically, UDDI never
1693          * provided a 'simple' way to get a list of execution URLs for a web
1694          * service. This function will resolve all AccessPoint and
1695          * HostingRedictor indirections and provide to you a list of URLs that
1696          * <i>should</i> be accessible for the given service.
1697          *
1698          * @param serviceKey
1699          * @return a list of URI endpoints
1700          */
1701         public List<String> getEndpoints(String serviceKey) {
1702                 List<String> items = new ArrayList<String>();
1703                 BusinessService serviceDetail = null;
1704                 try {
1705                         serviceDetail = this.getServiceDetail(serviceKey);
1706                 } catch (Exception ex) {
1707                         log.error("Unable to fetch the specified service's details", ex);
1708                 }
1709                 if (serviceDetail == null) {
1710                         return items;
1711                 }
1712 
1713                 if (serviceDetail.getBindingTemplates() != null) {
1714                         for (int k = 0; k < serviceDetail.getBindingTemplates().getBindingTemplate().size(); k++) {
1715                                 try {
1716                                         items.addAll(ParseBinding(serviceDetail.getBindingTemplates().getBindingTemplate().get(k)));
1717                                 } catch (Exception ex) {
1718                                         log.warn(ex);
1719                                 }
1720                         }
1721                 }
1722 
1723                 return items;
1724         }
1725 
1726         private List<String> GetBindingInfo(String value) throws Exception {
1727                 List<String> items = new ArrayList<String>();
1728                 if (value == null) {
1729                         return items;
1730                 }
1731 
1732                 GetBindingDetail b = new GetBindingDetail();
1733                 b.setAuthInfo(getAuthToken(this.getApiClerk().getNode().getSecurityUrl()));
1734                 b.getBindingKey().add(value);
1735                 BindingDetail bindingDetail = getUDDINode().getTransport().getUDDIInquiryService(this.getApiClerk().getNode().getInquiryUrl()).getBindingDetail(b);
1736                 for (int i = 0; i < bindingDetail.getBindingTemplate().size(); i++) {
1737                         items.addAll(ParseBinding(bindingDetail.getBindingTemplate().get(i)));
1738                 }
1739                 return items;
1740         }
1741 
1742         private List<String> ParseBinding(BindingTemplate get) throws Exception {
1743                 List<String> items = new ArrayList<String>();
1744                 if (get == null || get.getAccessPoint() == null) {
1745                         return items;
1746                 }
1747                 if (get.getHostingRedirector() != null) {
1748                         //hosting Redirector is the same as "reference this other binding template". It's actually deprecated so 
1749                         //don't expect to see this too often
1750                         items.addAll(GetBindingInfo(get.getHostingRedirector().getBindingKey()));
1751                 }
1752                 if (get.getAccessPoint() != null) {
1753                         String usetype = get.getAccessPoint().getUseType();
1754                         if (usetype == null) {
1755                                 //this is unexpected, usetype is a required field
1756                                 items.add(get.getAccessPoint().getValue());
1757                         } else if (usetype.equalsIgnoreCase(AccessPointType.BINDING_TEMPLATE.toString())) {
1758                                 //referencing another binding template
1759                                 items.addAll(GetBindingInfo(get.getAccessPoint().getValue()));
1760                         } else if (usetype.equalsIgnoreCase(AccessPointType.HOSTING_REDIRECTOR.toString())) {
1761                                 //this one is a bit strange. the value should be a binding template
1762 
1763                                 items.addAll(GetBindingInfo(get.getAccessPoint().getValue()));
1764 
1765                         } else if (usetype.equalsIgnoreCase(AccessPointType.WSDL_DEPLOYMENT.toString())) {
1766                                 //fetch wsdl and parse
1767                                 items.addAll(FetchWSDL(get.getAccessPoint().getValue()));
1768                         } else if (usetype.equalsIgnoreCase(AccessPointType.END_POINT.toString())) {
1769                                 items.add(get.getAccessPoint().getValue());
1770                         } else {
1771                                 //treat it has an extension or whatever
1772                                 log.info("Unable to figure out the useType for " + get.getAccessPoint().getValue());
1773                                 items.add(get.getAccessPoint().getValue());
1774                         }
1775 
1776                 }
1777                 return items;
1778         }
1779 
1780         /**
1781          * fetches a wsdl endpoint and parses for execution urls
1782          *
1783          * @param value
1784          * @return a list of endpoints from a WSDL provided it is reachable and parsable 
1785          */
1786         private List<String> FetchWSDL(String value) {
1787                 List<String> items = new ArrayList<String>();
1788 
1789                 if (value.startsWith("http://") || value.startsWith("https://")) {
1790                         //here, we need an HTTP Get for WSDLs
1791                         org.apache.juddi.v3.client.mapping.wsdl.ReadWSDL r = new ReadWSDL();
1792                         r.setIgnoreSSLErrors(true);
1793                         try {
1794                                 Definition wsdlDefinition = r.readWSDL(new URL(value));
1795                                 Properties properties = new Properties();
1796 
1797                                 properties.put("keyDomain", "domain");
1798                                 properties.put("businessName", "biz");
1799                                 properties.put("serverName", "localhost");
1800                                 properties.put("serverPort", "80");
1801 
1802                                 WSDL2UDDI wsdl2UDDI = new WSDL2UDDI(null, new URLLocalizerDefaultImpl(), properties);
1803                                 BusinessServices businessServices = wsdl2UDDI.createBusinessServices(wsdlDefinition);
1804                                 for (int i = 0; i < businessServices.getBusinessService().size(); i++) {
1805                                         if (businessServices.getBusinessService().get(i).getBindingTemplates() != null) {
1806                                                 for (int k = 0; k < businessServices.getBusinessService().get(i).getBindingTemplates().getBindingTemplate().size(); k++) {
1807                                                         items.addAll(ParseBinding(businessServices.getBusinessService().get(i).getBindingTemplates().getBindingTemplate().get(k)));
1808                                                 }
1809                                         }
1810                                 }
1811                         } catch (Exception ex) {
1812                                 log.error(ex);
1813                         }
1814 
1815                 }
1816                 return items;
1817         }
1818 
1819         /**
1820          * Gets service details or NULL if it doesn't exist or an error occurred
1821          *
1822          * @param getDetail
1823          * @return null if not found
1824          * @throws RemoteException
1825          * @throws ConfigurationException
1826          * @throws TransportException
1827          */
1828         public ServiceDetail getServiceDetail(GetServiceDetail getDetail) throws RemoteException, ConfigurationException, TransportException {
1829                 return getServiceDetail(getDetail, this.getUDDINode().getApiNode());
1830         }
1831 
1832         /**
1833          * Gets service details or NULL if it doesn't exist or an error occurred
1834          *
1835          * @param getDetail
1836          * @param node
1837          * @return null if not found
1838          * @throws RemoteException
1839          * @throws TransportException
1840          * @throws ConfigurationException
1841          */
1842         public ServiceDetail getServiceDetail(GetServiceDetail getDetail, Node node) throws RemoteException,
1843                 TransportException, ConfigurationException {
1844 
1845                 getDetail.setAuthInfo(getAuthToken(node.getSecurityUrl()));
1846                 try {
1847                         ServiceDetail tModelDetail = getUDDINode(node).getTransport().getUDDIInquiryService(node.getInquiryUrl()).getServiceDetail(getDetail);
1848                         return tModelDetail;
1849                 } catch (DispositionReportFaultMessage dr) {
1850                         DispositionReport report = DispositionReportFaultMessage.getDispositionReport(dr);
1851                         checkForErrorInDispositionReport(report, null, null);
1852                 } catch (SOAPFaultException sfe) {
1853                         DispositionReport report = DispositionReportFaultMessage.getDispositionReport(sfe);
1854                         checkForErrorInDispositionReport(report, null, null);
1855                 } catch (UndeclaredThrowableException ute) {
1856                         DispositionReport report = DispositionReportFaultMessage.getDispositionReport(ute);
1857                         checkForErrorInDispositionReport(report, null, null);
1858                 } catch (Throwable t){
1859                      throw new RemoteException("Unhandled exception", t);
1860                 }
1861                 return null;
1862 
1863         }
1864 
1865 }