This project has retired. For details please refer to its
        
        Attic page.
      
 
UDDIClerk xref
1   
2   
3   
4   
5   
6   
7   
8   
9   
10  
11  
12  
13  
14  
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  
97  
98  
99  
100 
101 
102 
103 
104 
105 
106 
107 
108 
109 
110 
111 
112 
113 
114 
115 
116 
117 
118 
119 
120 
121 
122 
123 
124 
125 
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 
148 
149 
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 
165 
166 
167 
168 
169 
170 
171 
172         public String[] getClassWithAnnotations() {
173                 return classWithAnnotations;
174         }
175 
176         
177 
178 
179 
180 
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 
198 
199 
200 
201 
202 
203 
204         public void setClassWithAnnotations(String[] classWithAnnotations) {
205                 this.classWithAnnotations = classWithAnnotations;
206         }
207 
208         
209 
210 
211 
212 
213 
214         @Deprecated
215         public Map<String, Properties> getServices() {
216                 return services;
217         }
218 
219         
220 
221 
222 
223 
224         @Deprecated
225         public void setServices(Map<String, Properties> services) {
226                 this.services = services;
227         }
228 
229         
230 
231 
232 
233 
234         public String getManagerName() {
235                 return managerName;
236         }
237 
238         
239 
240 
241 
242 
243         public void setManagerName(String managerName) {
244                 this.managerName = managerName;
245         }
246 
247         
248 
249 
250 
251 
252         public void registerWsdls() {
253                 registerWsdls(null);
254         }
255 
256         
257 
258 
259 
260 
261 
262 
263 
264 
265 
266 
267 
268 
269 
270 
271 
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 
303 
304 
305 
306 
307 
308 
309 
310 
311 
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 
337 
338 
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 
370 
371 
372 
373 
374 
375 
376 
377         public Subscription register(Subscription subscription) {
378                 return register(subscription, this.getUDDINode().getApiNode());
379         }
380 
381         
382 
383 
384 
385 
386 
387 
388 
389 
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 
417 
418 
419 
420 
421 
422         public TModelDetail register(TModel tModel) {
423                 return register(tModel, this.getUDDINode().getApiNode());
424         }
425 
426         
427 
428 
429 
430 
431 
432 
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 
457 
458 
459 
460 
461 
462         public BindingTemplate register(BindingTemplate binding) {
463                 return register(binding, this.getUDDINode().getApiNode());
464         }
465 
466         
467 
468 
469 
470 
471 
472 
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 
499 
500 
501 
502 
503 
504         public BusinessService register(BusinessService service) {
505                 return register(service, this.getUDDINode().getApiNode());
506         }
507 
508         
509 
510 
511 
512 
513 
514 
515 
516 
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 
548 
549 
550 
551 
552         public BusinessEntity register(BusinessEntity business) {
553                 return register(business, this.getUDDINode().getApiNode());
554         }
555 
556         
557 
558 
559 
560 
561 
562 
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 
594 
595 
596 
597 
598         public void unRegisterBusiness(String businessKey) {
599                 unRegisterBusiness(businessKey, this.getUDDINode().getApiNode());
600         }
601 
602         
603 
604 
605 
606 
607 
608 
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 
625 
626 
627 
628 
629         public void unRegisterService(String serviceKey) {
630                 unRegisterService(serviceKey, this.getUDDINode().getApiNode());
631         }
632 
633         
634 
635 
636 
637 
638 
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 
655 
656 
657 
658 
659         public void unRegisterBinding(String bindingKey) {
660                 unRegisterBinding(bindingKey, this.getUDDINode().getApiNode());
661         }
662 
663         
664 
665 
666 
667 
668 
669 
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 
686 
687 
688 
689 
690 
691 
692         public void unRegisterTModel(String tModelKey) {
693                 unRegisterTModel(tModelKey, this.getUDDINode().getApiNode());
694         }
695 
696         
697 
698 
699 
700 
701 
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 
719 
720 
721 
722 
723         public void unRegisterSubscription(String subscriptionKey) {
724                 unRegisterSubscription(subscriptionKey, this.getUDDINode().getApiNode());
725         }
726 
727         
728 
729 
730 
731 
732 
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 
750 
751 
752 
753 
754 
755 
756 
757         public TModelList findTModel(FindTModel findTModel) throws RemoteException, ConfigurationException, TransportException {
758                 return findTModel(findTModel, this.getUDDINode().getApiNode());
759         }
760 
761         
762 
763 
764 
765 
766 
767 
768 
769 
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 
795 
796 
797 
798 
799 
800 
801 
802 
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 
812 
813 
814 
815 
816 
817 
818 
819 
820         public TModelDetail getTModelDetail(GetTModelDetail getTModelDetail) throws RemoteException, ConfigurationException, TransportException {
821                 return getTModelDetail(getTModelDetail, this.getUDDINode().getApiNode());
822         }
823 
824         
825 
826 
827 
828 
829 
830 
831 
832 
833 
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 
859 
860 
861 
862 
863 
864 
865 
866         public BusinessService getServiceDetail(String serviceKey) throws RemoteException,
867                 TransportException, ConfigurationException {
868                 return getServiceDetail(serviceKey, this.getUDDINode().getApiNode());
869         }
870 
871         
872 
873 
874 
875 
876 
877 
878 
879 
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 
889 
890 
891 
892 
893 
894 
895 
896 
897 
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 
907 
908 
909 
910 
911 
912 
913 
914 
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 
946 
947 
948 
949 
950 
951 
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 
961 
962 
963 
964 
965 
966 
967 
968 
969         public BindingTemplate getServiceBindingDetail(String bindingKey) throws DispositionReportFaultMessage, RemoteException,
970                 TransportException, ConfigurationException {
971                 return getServiceBindingDetail(bindingKey, this.getUDDINode().getApiNode());
972         }
973 
974         
975 
976 
977 
978 
979 
980 
981 
982 
983 
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 
994 
995 
996 
997 
998 
999 
1000 
1001 
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 
1032 
1033 
1034 
1035 
1036 
1037 
1038 
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 
1048 
1049 
1050 
1051 
1052 
1053 
1054 
1055 
1056 
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 
1066 
1067 
1068 
1069 
1070 
1071 
1072 
1073 
1074         public BusinessEntity getBusinessDetail(String businessKey) throws RemoteException,
1075                 TransportException, ConfigurationException {
1076                 return getBusinessDetail(businessKey, this.getUDDINode().getApiNode());
1077         }
1078 
1079         
1080 
1081 
1082 
1083 
1084 
1085 
1086 
1087 
1088 
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 
1115 
1116 
1117 
1118 
1119 
1120 
1121 
1122 
1123 
1124 
1125 
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 
1167 
1168         public void discardAuthToken() {
1169                 discardAuthToken(authToken);
1170         }
1171 
1172         
1173 
1174 
1175 
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 
1193 
1194 
1195 
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 
1213 
1214 
1215 
1216 
1217 
1218 
1219 
1220 
1221 
1222 
1223         public String getAuthToken() throws TransportException, DispositionReportFaultMessage, RemoteException {
1224                 return getAuthToken(getUDDINode().getSecurityUrl());
1225         }
1226         
1227 
1228 
1229 
1230 
1231 
1232 
1233 
1234 
1235 
1236 
1237 
1238 
1239 
1240         public String getAuthToken(String endpointURL) throws TransportException, DispositionReportFaultMessage, RemoteException {
1241                 
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 
1278 
1279 
1280 
1281 
1282 
1283 
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 
1305 
1306 
1307 
1308 
1309 
1310 
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 
1332 
1333 
1334 
1335 
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 
1348 
1349 
1350 
1351         public String getName() {
1352                 return name;
1353         }
1354 
1355         
1356 
1357 
1358 
1359 
1360         public void setName(String name) {
1361                 this.name = name;
1362         }
1363 
1364         
1365 
1366 
1367 
1368 
1369         public void setUDDINode(UDDINode uddiNode) {
1370                 this.uddiNode = uddiNode;
1371         }
1372 
1373         
1374 
1375 
1376 
1377 
1378         public String getPublisher() {
1379                 return publisher;
1380         }
1381 
1382         
1383 
1384 
1385 
1386 
1387         public void setPublisher(String publisher) {
1388                 this.publisher = publisher;
1389         }
1390 
1391         
1392 
1393 
1394 
1395 
1396 
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 
1411 
1412 
1413 
1414 
1415 
1416         public String getRawPassword() {
1417                 return password;
1418         }
1419 
1420         
1421 
1422 
1423 
1424 
1425 
1426         public void setPassword(String password) {
1427                 this.password = password;
1428         }
1429 
1430         
1431 
1432 
1433 
1434 
1435 
1436 
1437         public WSDL[] getWsdls() {
1438                 return wsdls;
1439         }
1440 
1441         
1442 
1443 
1444 
1445 
1446 
1447 
1448         public void setWsdls(WSDL[] wsdls) {
1449                 this.wsdls = wsdls;
1450         }
1451 
1452         
1453 
1454 
1455 
1456 
1457         public void setCryptoProvider(String clazz) {
1458                 this.cryptoProvider = clazz;
1459         }
1460 
1461         
1462 
1463 
1464 
1465 
1466         public void setIsPasswordEncrypted(boolean option) {
1467                 this.isencrypted = option;
1468         }
1469 
1470         
1471 
1472 
1473 
1474 
1475         public String getCryptoProvider() {
1476                 return this.cryptoProvider;
1477         }
1478 
1479         
1480 
1481 
1482 
1483 
1484         public boolean getIsPasswordEncrypted() {
1485                 return this.isencrypted;
1486 
1487         }
1488 
1489         
1490 
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 
1525 
1526 
1527 
1528 
1529 
1530 
1531 
1532 
1533 
1534 
1535 
1536 
1537 
1538 
1539 
1540 
1541 
1542 
1543 
1544 
1545 
1546 
1547 
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                         
1559                         partitionName = "uddi:" + partitionName;
1560 
1561                 }
1562                 if (!partitionName.endsWith(":keygenerator")) {
1563                         
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 
1588 
1589 
1590 
1591 
1592 
1593 
1594 
1595 
1596 
1597 
1598 
1599 
1600 
1601 
1602 
1603 
1604 
1605 
1606 
1607 
1608 
1609 
1610 
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 
1632 
1633 
1634 
1635 
1636 
1637 
1638 
1639 
1640 
1641 
1642 
1643 
1644 
1645 
1646 
1647 
1648 
1649 
1650 
1651 
1652 
1653 
1654 
1655 
1656 
1657 
1658 
1659 
1660 
1661 
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 
1692 
1693 
1694 
1695 
1696 
1697 
1698 
1699 
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                         
1749                         
1750                         items.addAll(GetBindingInfo(get.getHostingRedirector().getBindingKey()));
1751                 }
1752                 if (get.getAccessPoint() != null) {
1753                         String usetype = get.getAccessPoint().getUseType();
1754                         if (usetype == null) {
1755                                 
1756                                 items.add(get.getAccessPoint().getValue());
1757                         } else if (usetype.equalsIgnoreCase(AccessPointType.BINDING_TEMPLATE.toString())) {
1758                                 
1759                                 items.addAll(GetBindingInfo(get.getAccessPoint().getValue()));
1760                         } else if (usetype.equalsIgnoreCase(AccessPointType.HOSTING_REDIRECTOR.toString())) {
1761                                 
1762 
1763                                 items.addAll(GetBindingInfo(get.getAccessPoint().getValue()));
1764 
1765                         } else if (usetype.equalsIgnoreCase(AccessPointType.WSDL_DEPLOYMENT.toString())) {
1766                                 
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                                 
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 
1782 
1783 
1784 
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                         
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 
1821 
1822 
1823 
1824 
1825 
1826 
1827 
1828         public ServiceDetail getServiceDetail(GetServiceDetail getDetail) throws RemoteException, ConfigurationException, TransportException {
1829                 return getServiceDetail(getDetail, this.getUDDINode().getApiNode());
1830         }
1831 
1832         
1833 
1834 
1835 
1836 
1837 
1838 
1839 
1840 
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 }