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