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