This project has retired. For details please refer to its
Attic page.
ScoutJaxrUddiV3Helper xref
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.ws.scout.util;
18
19 import java.util.Arrays;
20 import java.util.Collection;
21 import java.util.Iterator;
22 import java.util.LinkedList;
23 import java.util.List;
24 import java.util.StringTokenizer;
25
26 import javax.xml.registry.JAXRException;
27 import javax.xml.registry.infomodel.Association;
28 import javax.xml.registry.infomodel.Classification;
29 import javax.xml.registry.infomodel.ClassificationScheme;
30 import javax.xml.registry.infomodel.Concept;
31 import javax.xml.registry.infomodel.EmailAddress;
32 import javax.xml.registry.infomodel.ExternalIdentifier;
33 import javax.xml.registry.infomodel.ExternalLink;
34 import javax.xml.registry.infomodel.InternationalString;
35 import javax.xml.registry.infomodel.Key;
36 import javax.xml.registry.infomodel.LocalizedString;
37 import javax.xml.registry.infomodel.Organization;
38 import javax.xml.registry.infomodel.PostalAddress;
39 import javax.xml.registry.infomodel.RegistryObject;
40 import javax.xml.registry.infomodel.Service;
41 import javax.xml.registry.infomodel.ServiceBinding;
42 import javax.xml.registry.infomodel.Slot;
43 import javax.xml.registry.infomodel.SpecificationLink;
44 import javax.xml.registry.infomodel.TelephoneNumber;
45 import javax.xml.registry.infomodel.User;
46
47 import org.apache.commons.logging.Log;
48 import org.apache.commons.logging.LogFactory;
49 import org.uddi.api_v3.*;
50 import org.apache.ws.scout.registry.infomodel.InternationalStringImpl;
51
52
53
54
55
56
57
58
59
60 public class ScoutJaxrUddiV3Helper {
61
62 private static final String UDDI_ORG_TYPES = "uuid:C1ACF26D-9672-4404-9D70-39B756E62AB4";
63 private static Log log = LogFactory.getLog(ScoutJaxrUddiV3Helper.class);
64 private static ObjectFactory objectFactory = new ObjectFactory();
65
66
67
68
69 public static Address getAddress(PostalAddress postalAddress) throws JAXRException {
70 Address address = objectFactory.createAddress();
71 List<AddressLine> list = new LinkedList<AddressLine>();
72
73 String stnum = postalAddress.getStreetNumber();
74 String st = postalAddress.getStreet();
75 String city = postalAddress.getCity();
76 String country = postalAddress.getCountry();
77 String code = postalAddress.getPostalCode();
78 String state = postalAddress.getStateOrProvince();
79 String type = postalAddress.getType();
80
81 AddressLine stnumAL = null;
82
83 if (stnum != null && stnum.length() > 0) {
84 stnumAL = objectFactory.createAddressLine();
85 stnumAL.setKeyName("uddi:uddi.org:ubr:postaladdress");
86 stnumAL.setKeyValue("STREET_NUMBER");
87 stnumAL.setValue(stnum);
88 list.add(stnumAL);
89 }
90
91 AddressLine stAL = null;
92
93 if (st != null && st.length() > 0) {
94 stAL = objectFactory.createAddressLine();
95 stAL.setKeyName("uddi:uddi.org:ubr:postaladdress");
96 stAL.setKeyValue("STREET");
97 stAL.setValue(st);
98 list.add(stAL);
99 }
100
101 AddressLine cityAL = null;
102
103 if (city != null && city.length() > 0) {
104 cityAL = objectFactory.createAddressLine();
105 cityAL.setKeyName("uddi:uddi.org:ubr:postaladdress");
106 cityAL.setKeyValue("CITY");
107 cityAL.setValue(city);
108 list.add(cityAL);
109 }
110
111 AddressLine countryAL = null;
112
113 if (country != null && country.length() > 0) {
114 countryAL = objectFactory.createAddressLine();
115 countryAL.setKeyName("uddi:uddi.org:ubr:postaladdress");
116 countryAL.setKeyValue("COUNTRY");
117 countryAL.setValue(country);
118 list.add(countryAL);
119
120 }
121
122 AddressLine codeAL = null;
123
124 if (code != null&& code.length() > 0) {
125 codeAL = objectFactory.createAddressLine();
126 codeAL.setKeyName("uddi:uddi.org:ubr:postaladdress");
127 codeAL.setKeyValue("POSTALCODE");
128 codeAL.setValue(code);
129 list.add(codeAL);
130 }
131
132 AddressLine stateAL = null;
133 if (state != null && state.length()>0) {
134 stateAL = objectFactory.createAddressLine();
135 stateAL.setKeyName("uddi:uddi.org:ubr:postaladdress");
136 stateAL.setKeyValue("STATE");
137 stateAL.setValue(state);
138 list.add(stateAL);
139
140 }
141
142 AddressLine typeAL = null;
143 if (type != null && type.length()>0) {
144 typeAL = objectFactory.createAddressLine();
145 typeAL.setKeyName("uddi:uddi.org:ubr:postaladdress");
146
147 typeAL.setValue(type);
148 typeAL.setKeyValue("TYPE");
149 list.add(typeAL);
150 }
151
152
153 address.setTModelKey("uddi:uddi.org:ubr:postaladdress");
154 address.getAddressLine().addAll(list);
155
156 return address;
157 }
158
159 public static BindingTemplate getBindingTemplateFromJAXRSB(
160 ServiceBinding serviceBinding) throws JAXRException {
161 BindingTemplate bt = objectFactory.createBindingTemplate();
162 if (serviceBinding.getKey() != null && serviceBinding.getKey().getId() != null) {
163 bt.setBindingKey(serviceBinding.getKey().getId());
164 } else {
165 bt.setBindingKey("");
166 }
167
168 try {
169
170 String accessuri = serviceBinding.getAccessURI();
171 if (accessuri != null) {
172 AccessPoint accessPoint = objectFactory.createAccessPoint();
173 accessPoint.setUseType(getUseType(accessuri));
174 accessPoint.setValue(accessuri);
175 bt.setAccessPoint(accessPoint);
176 }
177 ServiceBinding sb = serviceBinding.getTargetBinding();
178 if (sb != null) {
179 HostingRedirector red = objectFactory.createHostingRedirector();
180 Key key = sb.getKey();
181 if (key != null && key.getId() != null) {
182 red.setBindingKey(key.getId());
183 } else {
184 red.setBindingKey("");
185 }
186 bt.setHostingRedirector(red);
187 } else {
188 if (bt.getAccessPoint() == null) {
189 bt.setAccessPoint(objectFactory.createAccessPoint());
190 }
191 }
192
193
194
195 CategoryBag catBag = getCategoryBagFromClassifications(serviceBinding.getClassifications());
196 if (catBag != null) {
197 bt.setCategoryBag(catBag);
198 }
199
200
201 Service svc = serviceBinding.getService();
202 if (svc != null && svc.getKey() != null && svc.getKey().getId() != null) {
203 bt.setServiceKey(svc.getKey().getId());
204 }
205
206 InternationalString idesc = serviceBinding.getDescription();
207
208 addDescriptions(bt.getDescription(), idesc);
209
210
211 Collection<SpecificationLink> slcol = serviceBinding.getSpecificationLinks();
212 TModelInstanceDetails tid = objectFactory.createTModelInstanceDetails();
213 if (slcol != null && !slcol.isEmpty()) {
214 Iterator<SpecificationLink> iter = slcol.iterator();
215 while (iter.hasNext()) {
216 SpecificationLink slink = (SpecificationLink) iter.next();
217
218 TModelInstanceInfo emptyTInfo = objectFactory.createTModelInstanceInfo();
219 tid.getTModelInstanceInfo().add(emptyTInfo);
220
221 RegistryObject specificationObject = slink.getSpecificationObject();
222 if (specificationObject.getKey() != null && specificationObject.getKey().getId() != null) {
223 emptyTInfo.setTModelKey(specificationObject.getKey().getId());
224 if (specificationObject.getDescription() != null) {
225 for (Object o : specificationObject.getDescription().getLocalizedStrings()) {
226 LocalizedString locDesc = (LocalizedString) o;
227 Description description = objectFactory.createDescription();
228 emptyTInfo.getDescription().add(description);
229 description.setValue(locDesc.getValue());
230 description.setLang(locDesc.getLocale().getLanguage());
231 }
232 }
233 Collection<ExternalLink> externalLinks = slink.getExternalLinks();
234 if (externalLinks != null && externalLinks.size() > 0) {
235 for (ExternalLink link : externalLinks) {
236 InstanceDetails ids = objectFactory.createInstanceDetails();
237 emptyTInfo.setInstanceDetails(ids);
238 if (link.getDescription() != null) {
239 Description description = objectFactory.createDescription();
240 ids.getDescription().add(description);
241 description.setValue(link.getDescription().getValue());
242 }
243 if (link.getExternalURI() != null) {
244 OverviewDoc overviewDoc = objectFactory.createOverviewDoc();
245 ids.getOverviewDoc().add(overviewDoc);
246 org.uddi.api_v3.OverviewURL ourl = new org.uddi.api_v3.OverviewURL();
247 ourl.setValue(link.getExternalURI());
248 overviewDoc.setOverviewURL(ourl);
249 }
250 if (slink.getUsageParameters() != null) {
251 StringBuffer buffer = new StringBuffer();
252 for (Object o : slink.getUsageParameters()) {
253 String s = (String) o;
254 buffer.append(s + " ");
255 }
256 ids.setInstanceParms(buffer.toString().trim());
257 }
258 }
259 }
260 }
261 }
262 }
263 if (tid.getTModelInstanceInfo().size() != 0) {
264 bt.setTModelInstanceDetails(tid);
265 }
266 log.debug("BindingTemplate=" + bt.toString());
267 } catch (Exception ud) {
268 throw new JAXRException("Apache JAXR Impl:", ud);
269 }
270 return bt;
271 }
272
273 public static PublisherAssertion getPubAssertionFromJAXRAssociation(
274 Association association) throws JAXRException {
275 PublisherAssertion pa = objectFactory.createPublisherAssertion();
276 try {
277 if (association.getSourceObject().getKey() != null
278 && association.getSourceObject().getKey().getId() != null) {
279 pa.setFromKey(association.getSourceObject().getKey().getId());
280 }
281
282 if (association.getTargetObject().getKey() != null
283 && association.getTargetObject().getKey().getId() != null) {
284 pa.setToKey(association.getTargetObject().getKey().getId());
285 }
286 Concept c = association.getAssociationType();
287 String v = c.getValue();
288 KeyedReference kr = objectFactory.createKeyedReference();
289 Key key = c.getKey();
290 if (key == null) {
291
292
293 key = c.getClassificationScheme().getKey();
294 }
295 if (key != null && key.getId() != null) {
296 kr.setTModelKey(key.getId());
297 }
298 kr.setKeyName("Concept");
299
300 if (v != null) {
301 kr.setKeyValue(v);
302 }
303
304 pa.setKeyedReference(kr);
305 } catch (Exception ud) {
306 throw new JAXRException("Apache JAXR Impl:", ud);
307 }
308 return pa;
309 }
310
311 public static PublisherAssertion getPubAssertionFromJAXRAssociationKey(
312 String key) throws JAXRException {
313 PublisherAssertion pa = objectFactory.createPublisherAssertion();
314 try {
315 StringTokenizer token = new StringTokenizer(key, "|");
316 if (token.hasMoreTokens()) {
317 pa.setFromKey(getToken(token.nextToken()));
318 pa.setToKey(getToken(token.nextToken()));
319 KeyedReference kr = objectFactory.createKeyedReference();
320
321 String str = getToken(token.nextToken());
322 if ("UUID".equalsIgnoreCase(str)) {
323 str += ":" + getToken(token.nextToken());
324 }
325 kr.setTModelKey(str);
326 kr.setKeyName(getToken(token.nextToken()));
327 kr.setKeyValue(getToken(token.nextToken()));
328 pa.setKeyedReference(kr);
329 }
330
331 } catch (Exception ud) {
332 throw new JAXRException("Apache JAXR Impl:", ud);
333 }
334 return pa;
335 }
336
337 public static BusinessService getBusinessServiceFromJAXRService(
338 Service service) throws JAXRException {
339 BusinessService bs = objectFactory.createBusinessService();
340 try {
341 InternationalString iname = service.getName();
342
343 addNames(bs.getName(), iname);
344
345 InternationalString idesc = service.getDescription();
346
347 addDescriptions(bs.getDescription(), idesc);
348
349 Organization o = service.getProvidingOrganization();
350
351
352
353
354 if (o != null) {
355 Key k = o.getKey();
356
357 if (k != null && k.getId() != null) {
358 bs.setBusinessKey(k.getId());
359 }
360
361 } else {
362
363
364
365 throw new JAXRException(
366 "Service has no associated organization");
367 }
368
369 if (service.getKey() != null && service.getKey().getId() != null) {
370 bs.setServiceKey(service.getKey().getId());
371 } else {
372 bs.setServiceKey("");
373 }
374
375 CategoryBag catBag = getCategoryBagFromClassifications(service.getClassifications());
376 if (catBag != null) {
377 bs.setCategoryBag(catBag);
378 }
379
380
381 BindingTemplates bt = getBindingTemplates(service.getServiceBindings());
382 if (bt != null) {
383 bs.setBindingTemplates(bt);
384 }
385
386 log.debug("BusinessService=" + bs.toString());
387 } catch (Exception ud) {
388 throw new JAXRException("Apache JAXR Impl:", ud);
389 }
390 return bs;
391 }
392
393 public static TModel getTModelFromJAXRClassificationScheme(
394 ClassificationScheme classificationScheme) throws JAXRException {
395 TModel tm = objectFactory.createTModel();
396 try {
397
398
399
400
401 Key k = classificationScheme.getKey();
402
403 if (k != null && k.getId() != null) {
404 tm.setTModelKey(k.getId());
405 } else {
406 tm.setTModelKey("");
407 }
408
409
410
411
412 Slot s = classificationScheme.getSlot("authorizedName");
413
414
415
416
417
418 s = classificationScheme.getSlot("operator");
419
420
421
422
423
424 InternationalString iname = classificationScheme.getName();
425
426 tm.setName(getFirstName(iname));
427
428 InternationalString idesc = classificationScheme.getDescription();
429
430 addDescriptions(tm.getDescription(), idesc);
431
432 IdentifierBag idBag = getIdentifierBagFromExternalIdentifiers(classificationScheme.getExternalIdentifiers());
433 if (idBag != null) {
434 tm.setIdentifierBag(idBag);
435 }
436 CategoryBag catBag = getCategoryBagFromClassifications(classificationScheme.getClassifications());
437 if (catBag != null) {
438 tm.setCategoryBag(catBag);
439 }
440
441
442 } catch (Exception ud) {
443 throw new JAXRException("Apache JAXR Impl:", ud);
444 }
445 return tm;
446 }
447
448 public static TModel getTModelFromJAXRConcept(Concept concept)
449 throws JAXRException {
450 TModel tm = objectFactory.createTModel();
451 if (concept == null) {
452 return null;
453 }
454 try {
455 Key key = concept.getKey();
456 if (key != null && key.getId() != null) {
457 tm.setTModelKey(key.getId());
458 }
459 Slot sl1 = concept.getSlot("authorizedName");
460
461
462
463
464
465
466
467
468 InternationalString iname = concept.getName();
469
470 tm.setName(getFirstName(iname));
471
472 InternationalString idesc = concept.getDescription();
473
474 addDescriptions(tm.getDescription(), idesc);
475
476
477 Collection<ExternalLink> externalLinks = concept.getExternalLinks();
478 if (externalLinks != null && externalLinks.size() > 0) {
479 tm.getOverviewDoc().add(getOverviewDocFromExternalLink((ExternalLink) externalLinks.iterator().next()));
480 }
481
482 IdentifierBag idBag = getIdentifierBagFromExternalIdentifiers(concept.getExternalIdentifiers());
483 if (idBag != null) {
484 tm.setIdentifierBag(idBag);
485 }
486 CategoryBag catBag = getCategoryBagFromClassifications(concept.getClassifications());
487 if (catBag != null) {
488 tm.setCategoryBag(catBag);
489 }
490
491 } catch (Exception ud) {
492 throw new JAXRException("Apache JAXR Impl:", ud);
493 }
494 return tm;
495 }
496
497 private static void addDescriptions(List<Description> descripions, InternationalString idesc) throws JAXRException {
498 if (idesc != null) {
499 for (Object o : idesc.getLocalizedStrings()) {
500 LocalizedString locName = (LocalizedString) o;
501 Description desc = objectFactory.createDescription();
502 descripions.add(desc);
503 desc.setValue(locName.getValue());
504 desc.setLang(locName.getLocale().getLanguage());
505 }
506 }
507 }
508
509 private static Name getFirstName(InternationalString iname) throws JAXRException {
510 for (Object o : iname.getLocalizedStrings()) {
511 LocalizedString locName = (LocalizedString) o;
512 Name name = objectFactory.createName();
513 name.setValue(locName.getValue());
514 name.setLang(locName.getLocale().getLanguage());
515 return name;
516 }
517 return null;
518 }
519
520 private static void addNames(List<Name> names, InternationalString iname) throws JAXRException {
521 for (Object o : iname.getLocalizedStrings()) {
522 LocalizedString locName = (LocalizedString) o;
523 Name name = objectFactory.createName();
524 name.setValue(locName.getValue());
525 name.setLang(locName.getLocale().getLanguage());
526 names.add(name);
527 }
528 }
529
530 public static BusinessEntity getBusinessEntityFromJAXROrg(Organization organization)
531 throws JAXRException {
532 BusinessEntity biz = objectFactory.createBusinessEntity();
533 BusinessServices bss = objectFactory.createBusinessServices();
534 BusinessService[] barr = new BusinessService[0];
535
536 try {
537
538 Key key = organization.getKey();
539 if (key != null && key.getId() != null) {
540 biz.setBusinessKey(key.getId());
541 } else {
542 biz.setBusinessKey("");
543 }
544
545
546 InternationalString iname = organization.getName();
547
548 if (iname != null) {
549 addNames(biz.getName(), iname);
550 }
551
552 InternationalString idesc = organization.getDescription();
553
554 addDescriptions(biz.getDescription(), idesc);
555
556 if (organization.getPrimaryContact() != null
557 && organization.getPrimaryContact().getPersonName() != null
558 && organization.getPrimaryContact().getPersonName().getFullName() != null) {
559
560
561
562 }
563
564 Collection<Service> s = organization.getServices();
565 log.debug("?Org has services=" + s.isEmpty());
566
567 barr = new BusinessService[s.size()];
568
569 Iterator<Service> iter = s.iterator();
570 int barrPos = 0;
571 while (iter.hasNext()) {
572 BusinessService bs = ScoutJaxrUddiV3Helper
573 .getBusinessServiceFromJAXRService((Service) iter
574 .next());
575 barr[barrPos] = bs;
576 barrPos++;
577 }
578
579
580
581
582
583
584 Contacts cts = objectFactory.createContacts();
585 Contact[] carr = new Contact[0];
586
587 User primaryContact = organization.getPrimaryContact();
588 Collection<User> users = organization.getUsers();
589
590
591
592 int carrSize = 0;
593
594 if (primaryContact != null) {
595 carrSize += 1;
596 }
597
598
599 Iterator<User> it = users.iterator();
600 while (it.hasNext()) {
601 User u = (User) it.next();
602 if (u != primaryContact) {
603 carrSize++;
604 }
605 }
606
607 carr = new Contact[carrSize];
608
609
610
611
612 if (primaryContact != null) {
613 Contact ct = getContactFromJAXRUser(primaryContact);
614 carr[0] = ct;
615 }
616
617 it = users.iterator();
618 int carrPos = 1;
619 while (it.hasNext()) {
620 User u = (User) it.next();
621
622 if (u != primaryContact) {
623 Contact ct = getContactFromJAXRUser(u);
624 carr[carrPos] = ct;
625 carrPos++;
626 }
627 }
628
629 bss.getBusinessService().addAll(Arrays.asList(barr));
630 if (carr.length > 0) {
631 cts.getContact().addAll(Arrays.asList(carr));
632 biz.setContacts(cts);
633 }
634 biz.setBusinessServices(bss);
635
636
637 Iterator<ExternalLink> exiter = organization.getExternalLinks().iterator();
638 DiscoveryURLs emptyDUs = null;
639 boolean first = true;
640 while (exiter.hasNext()) {
641 ExternalLink link = (ExternalLink) exiter.next();
642
643
644
645 if (first) {
646 emptyDUs = objectFactory.createDiscoveryURLs();
647 biz.setDiscoveryURLs(emptyDUs);
648 first = false;
649 }
650 DiscoveryURL emptyDU = objectFactory.createDiscoveryURL();
651 emptyDUs.getDiscoveryURL().add(emptyDU);
652 emptyDU.setUseType("businessEntityExt");
653
654 if (link.getExternalURI() != null) {
655 emptyDU.setValue(link.getExternalURI());
656 }
657 }
658
659 IdentifierBag idBag = getIdentifierBagFromExternalIdentifiers(organization.getExternalIdentifiers());
660 if (idBag != null) {
661 biz.setIdentifierBag(idBag);
662 }
663 CategoryBag catBag = getCategoryBagFromClassifications(organization.getClassifications());
664 if (catBag != null) {
665 biz.setCategoryBag(catBag);
666 }
667
668 } catch (Exception ud) {
669 throw new JAXRException("Apache JAXR Impl:", ud);
670 }
671 return biz;
672 }
673
674
675
676
677
678 public static Contact getContactFromJAXRUser(User user)
679 throws JAXRException {
680 Contact ct = objectFactory.createContact();
681 if (user == null) {
682 return null;
683 }
684
685 Address[] addarr = new Address[0];
686 Phone[] phonearr = new Phone[0];
687 Email[] emailarr = new Email[0];
688 try {
689
690 if (user.getPersonName() != null && user.getPersonName().getFullName() != null) {
691 org.uddi.api_v3.PersonName pn = new org.uddi.api_v3.PersonName();
692 pn.setValue(user.getPersonName().getFullName());
693 ct.getPersonName().add(pn);
694 }
695
696 if (user.getType() != null) {
697 ct.setUseType(user.getType());
698 }
699
700 Collection<PostalAddress> postc = user.getPostalAddresses();
701
702 addarr = new Address[postc.size()];
703
704 Iterator<PostalAddress> iterator = postc.iterator();
705 int addarrPos = 0;
706 while (iterator.hasNext()) {
707 PostalAddress post = (PostalAddress) iterator.next();
708 addarr[addarrPos] = ScoutJaxrUddiV3Helper.getAddress(post);
709 addarrPos++;
710 }
711
712 Collection ph = user.getTelephoneNumbers(null);
713
714 phonearr = new Phone[ph.size()];
715
716 Iterator it = ph.iterator();
717 int phonearrPos = 0;
718 while (it.hasNext()) {
719 TelephoneNumber t = (TelephoneNumber) it.next();
720 Phone phone = objectFactory.createPhone();
721 String str = t.getNumber();
722 log.debug("Telephone=" + str);
723
724
725
726 if (str != null) {
727 phone.setValue(str);
728 } else {
729 phone.setValue("");
730 }
731
732 phonearr[phonearrPos] = phone;
733 phonearrPos++;
734 }
735
736
737 Collection ec = user.getEmailAddresses();
738
739 emailarr = new Email[ec.size()];
740
741 Iterator iter = ec.iterator();
742 int emailarrPos = 0;
743 while (iter.hasNext()) {
744 EmailAddress ea = (EmailAddress) iter.next();
745 Email email = objectFactory.createEmail();
746
747 if (ea.getAddress() != null) {
748 email.setValue(ea.getAddress());
749 }
750
751
752 if (ea.getType() != null) {
753 email.setUseType(ea.getType());
754 }
755
756 emailarr[emailarrPos] = email;
757 emailarrPos++;
758 }
759 ct.getAddress().addAll(Arrays.asList(addarr));
760 ct.getPhone().addAll(Arrays.asList(phonearr));
761 ct.getEmail().addAll(Arrays.asList(emailarr));
762 } catch (Exception ud) {
763 throw new JAXRException("Apache JAXR Impl:", ud);
764 }
765 return ct;
766 }
767
768 private static String getToken(String tokenstr) {
769
770 if (tokenstr.equals("NULL")) {
771 tokenstr = "";
772 }
773 return tokenstr;
774 }
775
776 private static String getUseType(String accessuri) {
777 String acc = accessuri.toLowerCase();
778 String uri = "other";
779 if (acc.startsWith("http:")) {
780 uri = "http:";
781 } else if (acc.startsWith("https:")) {
782 uri = "https:";
783 } else if (acc.startsWith("ftp:")) {
784 uri = "ftp:";
785 } else if (acc.startsWith("phone:")) {
786 uri = "phone:";
787 }
788
789 return uri;
790 }
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810 public static CategoryBag getCategoryBagFromClassifications(Collection classifications) throws JAXRException {
811 try {
812 if (classifications == null || classifications.size() == 0) {
813 return null;
814 }
815
816
817 CategoryBag cbag = objectFactory.createCategoryBag();
818 Iterator classiter = classifications.iterator();
819 while (classiter.hasNext()) {
820 Classification classification = (Classification) classiter.next();
821 if (classification != null) {
822 KeyedReference keyr = objectFactory.createKeyedReference();
823 cbag.getKeyedReference().add(keyr);
824
825 InternationalStringImpl iname = null;
826 String value = null;
827 ClassificationScheme scheme = classification.getClassificationScheme();
828 if (scheme == null || (classification.isExternal() && classification.getConcept() == null)) {
829
830
831
832
833
834
835
836 keyr.setTModelKey(UDDI_ORG_TYPES);
837 keyr.setKeyValue("specification");
838 } else {
839 if (classification.isExternal()) {
840 iname = (InternationalStringImpl) ((RegistryObject) classification).getName();
841 value = classification.getValue();
842 } else {
843 Concept concept = classification.getConcept();
844 if (concept != null) {
845 iname = (InternationalStringImpl) ((RegistryObject) concept).getName();
846 value = concept.getValue();
847 scheme = concept.getClassificationScheme();
848 }
849 }
850
851 String name = iname.getValue();
852 if (name != null) {
853 keyr.setKeyName(name);
854 }
855
856 if (value != null) {
857 keyr.setKeyValue(value);
858 }
859
860 if (scheme != null) {
861 Key key = scheme.getKey();
862 if (key != null && key.getId() != null) {
863 keyr.setTModelKey(key.getId());
864 }
865 }
866 }
867 }
868 }
869 if (cbag.getKeyedReference().isEmpty()) {
870 return null;
871 } else {
872 return cbag;
873 }
874 } catch (Exception ud) {
875 throw new JAXRException("Apache JAXR Impl:", ud);
876 }
877 }
878
879 public static TModelBag getTModelBagFromSpecifications(Collection specifications) throws JAXRException {
880 try {
881 if (specifications == null || specifications.size() == 0) {
882 return null;
883 }
884
885
886 TModelBag tbag = objectFactory.createTModelBag();
887 Iterator speciter = specifications.iterator();
888 while (speciter.hasNext()) {
889 RegistryObject registryobject = (RegistryObject) speciter.next();
890 if (registryobject instanceof Concept) {
891 Concept concept = (Concept) registryobject;
892 if (concept.getKey() != null) {
893 tbag.getTModelKey().add(concept.getKey().toString());
894 }
895
896
897
898
899
900
901
902
903 } else {
904 log.info("ebXML case - the RegistryObject is an ExtrinsicObject, Not implemented");
905 }
906 }
907 if (tbag.getTModelKey().isEmpty()) {
908 return null;
909 } else {
910 return tbag;
911 }
912 } catch (Exception ud) {
913 throw new JAXRException("Apache JAXR Impl:", ud);
914 }
915 }
916
917
918
919
920
921
922
923 public static IdentifierBag getIdentifierBagFromExternalIdentifiers(Collection identifiers) throws JAXRException {
924 try {
925 if (identifiers == null || identifiers.size() == 0) {
926 return null;
927 }
928
929
930 IdentifierBag ibag = objectFactory.createIdentifierBag();
931 Iterator iditer = identifiers.iterator();
932 while (iditer.hasNext()) {
933 ExternalIdentifier extid = (ExternalIdentifier) iditer.next();
934 if (extid != null) {
935 KeyedReference keyr = objectFactory.createKeyedReference();
936 ibag.getKeyedReference().add(keyr);
937
938 InternationalStringImplrg/apache/ws/scout/registry/infomodel/InternationalStringImpl.html#InternationalStringImpl">InternationalStringImpl iname = (InternationalStringImpl) ((RegistryObject) extid).getName();
939 String value = extid.getValue();
940 ClassificationScheme scheme = extid.getIdentificationScheme();
941
942 String name = iname.getValue();
943 if (name != null) {
944 keyr.setKeyName(name);
945 }
946
947 if (value != null) {
948 keyr.setKeyValue(value);
949 }
950
951 if (scheme != null) {
952 Key key = scheme.getKey();
953 if (key != null && key.getId() != null) {
954 keyr.setTModelKey(key.getId());
955 }
956 }
957 }
958 }
959 return ibag;
960 } catch (Exception ud) {
961 throw new JAXRException("Apache JAXR Impl:", ud);
962 }
963 }
964
965 private static OverviewDoc getOverviewDocFromExternalLink(ExternalLink link)
966 throws JAXRException {
967 OverviewDoc od = objectFactory.createOverviewDoc();
968 String url = link.getExternalURI();
969 if (url != null) {
970 org.uddi.api_v3.OverviewURL ourl = new org.uddi.api_v3.OverviewURL();
971 ourl.setValue(url.toString());
972 od.setOverviewURL(ourl);
973 }
974 InternationalString extDesc = link.getDescription();
975 if (extDesc != null) {
976 Description description = objectFactory.createDescription();
977 od.getDescription().add(description);
978 description.setValue(extDesc.getValue());
979 }
980 return od;
981 }
982
983 private static BindingTemplates getBindingTemplates(Collection serviceBindings)
984 throws JAXRException {
985 BindingTemplates bt = null;
986 if (serviceBindings != null && serviceBindings.size() > 0) {
987 bt = objectFactory.createBindingTemplates();
988 Iterator iter = serviceBindings.iterator();
989 int currLoc = 0;
990 BindingTemplate[] bindingTemplateArray = new BindingTemplate[serviceBindings.size()];
991 while (iter.hasNext()) {
992 ServiceBinding sb = (ServiceBinding) iter.next();
993 bindingTemplateArray[currLoc] = getBindingTemplateFromJAXRSB(sb);
994 currLoc++;
995 }
996 if (bindingTemplateArray != null) {
997 bt.getBindingTemplate().addAll(Arrays.asList(bindingTemplateArray));
998 }
999 }
1000 return bt;
1001 }
1002 }