This project has retired. For details please refer to its Attic page.
ScoutUddiJaxrHelper xref
View Javadoc
1   /**
2    *
3    * Copyright 2004 The Apache Software Foundation
4    *
5    *  Licensed under the Apache License, Version 2.0 (the "License");
6    *  you may not use this file except in compliance with the License.
7    *  You may obtain a copy of the License at
8    *
9    *     http://www.apache.org/licenses/LICENSE-2.0
10   *
11   *  Unless required by applicable law or agreed to in writing, software
12   *  distributed under the License is distributed on an "AS IS" BASIS,
13   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   *  See the License for the specific language governing permissions and
15   *  limitations under the License.
16   */
17  package org.apache.ws.scout.util;
18  
19  import java.util.ArrayList;
20  import java.util.Collection;
21  import java.util.HashMap;
22  import java.util.List;
23  import java.util.Locale;
24  
25  import javax.xml.registry.JAXRException;
26  import javax.xml.registry.LifeCycleManager;
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.Organization;
36  import javax.xml.registry.infomodel.PostalAddress;
37  import javax.xml.registry.infomodel.RegistryObject;
38  import javax.xml.registry.infomodel.Service;
39  import javax.xml.registry.infomodel.ServiceBinding;
40  import javax.xml.registry.infomodel.SpecificationLink;
41  import javax.xml.registry.infomodel.TelephoneNumber;
42  import javax.xml.registry.infomodel.User;
43  
44  import org.apache.ws.scout.model.uddi.v2.AccessPoint;
45  import org.apache.ws.scout.model.uddi.v2.Address;
46  import org.apache.ws.scout.model.uddi.v2.AddressLine;
47  import org.apache.ws.scout.model.uddi.v2.BindingTemplate;
48  import org.apache.ws.scout.model.uddi.v2.BindingTemplates;
49  import org.apache.ws.scout.model.uddi.v2.BusinessDetail;
50  import org.apache.ws.scout.model.uddi.v2.BusinessEntity;
51  import org.apache.ws.scout.model.uddi.v2.BusinessService;
52  import org.apache.ws.scout.model.uddi.v2.BusinessServices;
53  import org.apache.ws.scout.model.uddi.v2.CategoryBag;
54  import org.apache.ws.scout.model.uddi.v2.Contact;
55  import org.apache.ws.scout.model.uddi.v2.Contacts;
56  import org.apache.ws.scout.model.uddi.v2.Description;
57  import org.apache.ws.scout.model.uddi.v2.DiscoveryURL;
58  import org.apache.ws.scout.model.uddi.v2.DiscoveryURLs;
59  import org.apache.ws.scout.model.uddi.v2.Email;
60  import org.apache.ws.scout.model.uddi.v2.HostingRedirector;
61  import org.apache.ws.scout.model.uddi.v2.IdentifierBag;
62  import org.apache.ws.scout.model.uddi.v2.InstanceDetails;
63  import org.apache.ws.scout.model.uddi.v2.KeyedReference;
64  import org.apache.ws.scout.model.uddi.v2.Name;
65  import org.apache.ws.scout.model.uddi.v2.OverviewDoc;
66  import org.apache.ws.scout.model.uddi.v2.Phone;
67  import org.apache.ws.scout.model.uddi.v2.ServiceInfo;
68  import org.apache.ws.scout.model.uddi.v2.TModel;
69  import org.apache.ws.scout.model.uddi.v2.TModelDetail;
70  import org.apache.ws.scout.model.uddi.v2.TModelInfo;
71  import org.apache.ws.scout.model.uddi.v2.TModelInstanceDetails;
72  import org.apache.ws.scout.model.uddi.v2.TModelInstanceInfo;
73  import org.apache.ws.scout.registry.infomodel.AssociationImpl;
74  import org.apache.ws.scout.registry.infomodel.ClassificationImpl;
75  import org.apache.ws.scout.registry.infomodel.ClassificationSchemeImpl;
76  import org.apache.ws.scout.registry.infomodel.ConceptImpl;
77  import org.apache.ws.scout.registry.infomodel.EmailAddressImpl;
78  import org.apache.ws.scout.registry.infomodel.ExternalIdentifierImpl;
79  import org.apache.ws.scout.registry.infomodel.ExternalLinkImpl;
80  import org.apache.ws.scout.registry.infomodel.InternationalStringImpl;
81  import org.apache.ws.scout.registry.infomodel.KeyImpl;
82  import org.apache.ws.scout.registry.infomodel.OrganizationImpl;
83  import org.apache.ws.scout.registry.infomodel.PersonNameImpl;
84  import org.apache.ws.scout.registry.infomodel.PostalAddressImpl;
85  import org.apache.ws.scout.registry.infomodel.ServiceBindingImpl;
86  import org.apache.ws.scout.registry.infomodel.ServiceImpl;
87  import org.apache.ws.scout.registry.infomodel.SpecificationLinkImpl;
88  import org.apache.ws.scout.registry.infomodel.TelephoneNumberImpl;
89  import org.apache.ws.scout.registry.infomodel.UserImpl;
90  
91  /**
92   * Helper class that does UDDI->Jaxr Mapping
93   *
94   * @author <a href="mailto:anil@apache.org">Anil Saldhana</a>
95   * @author <a href="mailto:geirm@apache.org">Geir Magnusson Jr.</a>
96   */
97  public class ScoutUddiJaxrHelper
98  {
99  	public static Association getAssociation(Collection orgs,
100 			LifeCycleManager lcm)
101 	throws JAXRException
102 	{
103 		Association asso = new AssociationImpl(lcm);
104 		Object[] arr = orgs.toArray();
105 		asso.setSourceObject((RegistryObject)arr[0]);
106 		asso.setTargetObject((RegistryObject)arr[1]);
107 		return asso;
108 	}
109 
110 	public static Organization getOrganization(BusinessEntity businessEntity,
111 			LifeCycleManager lifeCycleManager)
112 	throws JAXRException
113 	{
114 		List<Name> namesList = businessEntity.getName();
115 		List<Description> descriptionList = businessEntity.getDescription();
116 
117 		Organization org = new OrganizationImpl(lifeCycleManager);
118 		if ((namesList != null) && (namesList.size() > 0)) {
119 			InternationalString is = null;
120 			for (Name n : namesList)  {
121 				if (is == null) {
122 					is = getIString(n.getLang(), n.getValue(), lifeCycleManager);
123 				} else {
124 					is.setValue(getLocale(n.getLang()), n.getValue());
125 				}
126 			}
127 			org.setName(is);
128 		}
129 		if ((descriptionList != null) && (descriptionList.size() > 0)) {
130 			InternationalString is = null;
131 			for (Description desc : descriptionList)  {
132 				if (is == null) {
133 					is = getIString(desc.getLang(), desc.getValue(), lifeCycleManager);
134 				} else {
135 					is.setValue(getLocale(desc.getLang()), desc.getValue());
136 				}
137 			}
138 			org.setDescription(is);
139 		}
140 		org.setKey(lifeCycleManager.createKey(businessEntity.getBusinessKey()));
141 
142 		//Set Services also
143 		BusinessServices services = businessEntity.getBusinessServices();
144 		if(services != null)
145 		{
146 			List<BusinessService> bizServiceList = services.getBusinessService();
147 			for (BusinessService businessService : bizServiceList) {
148 				org.addService(getService(businessService, lifeCycleManager));
149 			}
150 		}
151 
152 		/*
153 		 *  Users
154 		 *
155 		 *  we need to take the first contact and designate as the
156 		 *  'primary contact'.  Currently, the OrganizationImpl
157 		 *  class does that automatically as a safety in case
158 		 *  user forgets to set - lets be explicit here as to not
159 		 *  depend on that behavior
160 		 */
161 
162 		Contacts contacts = businessEntity.getContacts();
163 		if(contacts != null)
164 		{
165 			List<Contact> contactList = contacts.getContact();
166 			if (contactList!=null) {
167 				boolean isFirst=true;
168 				for (Contact contact : contactList) {
169 					User user = new UserImpl(null);
170 					String pname = contact.getPersonName();
171 					user.setPersonName(new PersonNameImpl(pname));
172 					if (isFirst) {
173 						isFirst=false;
174 						org.setPrimaryContact(user);
175 					} else {
176 						org.addUser(user);
177 					}
178 				}
179 			}
180 		}
181 
182 		//External Links
183 		DiscoveryURLs durls = businessEntity.getDiscoveryURLs();
184 		if (durls != null)
185 		{
186 			List<DiscoveryURL> discoveryURL_List = durls.getDiscoveryURL();
187 			for (DiscoveryURL discoveryURL : discoveryURL_List) {
188 				ExternalLink link = new ExternalLinkImpl(lifeCycleManager);
189 				link.setExternalURI(discoveryURL.getValue());
190 				org.addExternalLink(link);
191 			}
192 		}
193 
194 		org.addExternalIdentifiers(getExternalIdentifiers(businessEntity.getIdentifierBag(), lifeCycleManager));
195 		org.addClassifications(getClassifications(businessEntity.getCategoryBag(), lifeCycleManager));
196 
197 		return org;
198 	}
199 
200 
201 	public static Organization getOrganization(BusinessDetail bizdetail,
202 			LifeCycleManager lifeCycleManager)
203 	throws JAXRException
204 	{
205 		List<BusinessEntity> bizEntityList = bizdetail.getBusinessEntity();
206 		if (bizEntityList.size() != 1) {
207 			throw new JAXRException("Unexpected count of organizations in BusinessDetail: " + bizEntityList.size());
208 		}
209 		BusinessEntity entity = bizEntityList.get(0);
210 		List<Name> namesList = entity.getName();
211 		List<Description> descriptionList = entity.getDescription();
212 
213 		Organization org = new OrganizationImpl(lifeCycleManager);
214 		if ((namesList != null) && (namesList.size() > 0)) {
215 			InternationalString is = null;
216 			for (Name n : namesList)  {
217 				if (is == null) {
218 					is = getIString(n.getLang(), n.getValue(), lifeCycleManager);
219 				} else {
220 					is.setValue(getLocale(n.getLang()), n.getValue());
221 				}
222 			}
223 			org.setName(is);
224 		}
225 		if ((descriptionList != null) && (descriptionList.size() > 0)) {
226 			InternationalString is = null;
227 			for (Description desc : descriptionList)  {
228 				if (is == null) {
229 					is = getIString(desc.getLang(), desc.getValue(), lifeCycleManager);
230 				} else {
231 					is.setValue(getLocale(desc.getLang()), desc.getValue());
232 				}
233 			}
234 			org.setDescription(is);
235 		}
236 
237 		org.setKey(lifeCycleManager.createKey(entity.getBusinessKey()));
238 
239 		//Set Services also
240 		BusinessServices services = entity.getBusinessServices();
241 		List<BusinessService> bizServiceList = services.getBusinessService();
242 		for (BusinessService businessService : bizServiceList) {
243 			org.addService(getService(businessService, lifeCycleManager));
244 		}
245 
246 		/*
247 		 *  Users
248 		 *
249 		 *  we need to take the first contact and designate as the
250 		 *  'primary contact'.  Currently, the OrganizationImpl
251 		 *  class does that automatically as a safety in case
252 		 *  user forgets to set - lets be explicit here as to not
253 		 *  depend on that behavior
254 		 */
255 		Contacts contacts = entity.getContacts();
256 		List<Contact> contactList = contacts.getContact();
257 		boolean isFirst=true;
258 		for (Contact contact : contactList) {
259 			User user = new UserImpl(null);
260 			String pname = contact.getPersonName();
261 			user.setType(contact.getUseType());
262 			user.setPersonName(new PersonNameImpl(pname));
263 
264 			List<Email> emailList = contact.getEmail();
265 			ArrayList<EmailAddress> tempEmails = new ArrayList<EmailAddress>();
266 			for (Email email : emailList) {
267 				tempEmails.add(new EmailAddressImpl(email.getValue(), null));
268 			}
269 			user.setEmailAddresses(tempEmails);
270 
271 			List<Address> addressList = contact.getAddress();
272 			ArrayList<PostalAddress> tempAddresses = new ArrayList<PostalAddress>();
273 			for (Address address : addressList) {
274 				ArrayList<AddressLine> addressLineList = new ArrayList<AddressLine>(address.getAddressLine());
275 				AddressLine[] alines = new AddressLine[addressLineList.size()];
276 				addressLineList.toArray(alines);
277 
278 				PostalAddress pa = getPostalAddress(alines);
279 				tempAddresses.add(pa);
280 			}
281 			user.setPostalAddresses(tempAddresses);
282 
283 			List<Phone> phoneList = contact.getPhone();
284 			ArrayList<TelephoneNumber> tempPhones = new ArrayList<TelephoneNumber>();
285 			for (Phone phone : phoneList) {
286 				TelephoneNumberImpl tni = new TelephoneNumberImpl();
287 				tni.setType(phone.getUseType());
288 				tni.setNumber(phone.getValue());
289 				tempPhones.add(tni);
290 			}
291 			user.setTelephoneNumbers(tempPhones);
292 			if (isFirst) {
293 				isFirst=false;
294 				org.setPrimaryContact(user);
295 			} else {
296 				org.addUser(user);
297 			}
298 		}
299 
300 		//External Links
301 		DiscoveryURLs durls = entity.getDiscoveryURLs();
302 		if (durls != null)
303 		{
304 			List<DiscoveryURL> discoveryURL_List = durls.getDiscoveryURL();
305 			for (DiscoveryURL discoveryURL : discoveryURL_List) {
306 				ExternalLink link = new ExternalLinkImpl(lifeCycleManager);
307 				link.setExternalURI(discoveryURL.getValue());
308 				org.addExternalLink(link);
309 			}
310 		}
311 
312 		org.addExternalIdentifiers(getExternalIdentifiers(entity.getIdentifierBag(), lifeCycleManager));
313 		org.addClassifications(getClassifications(entity.getCategoryBag(), lifeCycleManager));
314 
315 		return org;
316 	}
317 
318 	private static PostalAddress getPostalAddress(AddressLine[] addressLineArr) throws JAXRException {
319 		PostalAddress pa = new PostalAddressImpl();
320 		HashMap<String, String> hm = new HashMap<String, String>();
321 		for (AddressLine anAddressLineArr : addressLineArr) {
322 			hm.put(anAddressLineArr.getKeyValue(), anAddressLineArr.getValue());
323 		}
324 
325 		if (hm.containsKey("STREET_NUMBER")) {
326 			pa.setStreetNumber(hm.get("STREET_NUMBER"));
327 		}
328 
329 		if (hm.containsKey("STREET")) {
330 			pa.setStreet(hm.get("STREET"));
331 		}
332 
333 		if (hm.containsKey("CITY")) {
334 			pa.setCity(hm.get("CITY"));
335 		}
336 
337 		if (hm.containsKey("COUNTRY")) {
338 			pa.setCountry(hm.get("COUNTRY"));
339 		}
340 
341 		if (hm.containsKey("POSTALCODE")) {
342 			pa.setPostalCode(hm.get("POSTALCODE"));
343 		}
344 
345 		if (hm.containsKey("STATE")) {
346 			pa.setStateOrProvince(hm.get("STATE"));
347 		}
348 
349 		return pa;
350 	}
351 
352 	private static InternationalString getIString(String lang, String str, LifeCycleManager lifeCycleManager)
353 	throws JAXRException
354 	{
355 		if (str!=null) {
356 			return lifeCycleManager.createInternationalString(getLocale(lang), str);
357 		} else {
358 			return null;
359 		}
360 	}
361 
362 	public static InternationalString getIString(String str, LifeCycleManager lifeCycleManager)
363 	throws JAXRException
364 	{
365 		return lifeCycleManager.createInternationalString(str);
366 	}
367 
368 	public static Service getService(BusinessService businessService, LifeCycleManager lifeCycleManager)
369 	throws JAXRException
370 	{
371 		Service serve = new ServiceImpl(lifeCycleManager);
372 
373 		String keystr = businessService.getServiceKey();
374 
375 		if (keystr != null)
376 		{
377 			serve.setKey(lifeCycleManager.createKey(keystr));
378 		}
379 
380 		List<Name> namesList = businessService.getName();
381 		List<Description> descriptionList = businessService.getDescription();
382 
383 		InternationalString is = null;
384 		for (Name n : namesList) {
385 			if (is == null) {
386 				is = lifeCycleManager.createInternationalString(getLocale(n.getLang()), n.getValue());
387 			} else {
388 				is.setValue(getLocale(n.getLang()), n.getValue());
389 			}
390 		}
391 		serve.setName(is);
392 		
393 		InternationalString dis = null;
394 		for (Description desc : descriptionList) {
395             if (dis == null) {
396                 dis = lifeCycleManager.createInternationalString(getLocale(desc.getLang()), desc.getValue());
397             } else {
398                 dis.setValue(getLocale(desc.getLang()), desc.getValue());
399             }
400         }
401 		for (int i = 0; i < namesList.size(); i++) {
402 			
403 		}
404 		serve.setDescription(dis);
405 		
406 		//Populate the ServiceBindings for this Service
407 		BindingTemplates bts = businessService.getBindingTemplates();
408 		List<BindingTemplate> bindingTemplateList = bts.getBindingTemplate();
409 		for (BindingTemplate bindingTemplate : bindingTemplateList) {
410 			serve.addServiceBinding(getServiceBinding(bindingTemplate, lifeCycleManager));
411 		}
412 		serve.addClassifications(getClassifications(businessService.getCategoryBag(), lifeCycleManager));
413 
414 		return serve;
415 	}
416 
417 	public static Service getService(ServiceInfo serviceInfo, LifeCycleManager lifeCycleManager)
418 	throws JAXRException
419 	{
420 		Service service = new ServiceImpl(lifeCycleManager);
421 
422 		String keystr = serviceInfo.getServiceKey();
423 
424 		if (keystr != null)
425 		{
426 			service.setKey(lifeCycleManager.createKey(keystr));
427 		}
428 
429 		List<Name> namesList = serviceInfo.getName();
430 		InternationalString is = null;
431 		for (Name n : namesList) {
432 			if (is == null) {
433 				is = lifeCycleManager.createInternationalString(getLocale(n.getLang()), n.getValue());
434 			} else {
435 				is.setValue(getLocale(n.getLang()), n.getValue());
436 			}
437 		}
438 		service.setName(is);
439 
440 		return service;
441 	}
442 
443 	public static ServiceBinding getServiceBinding(BindingTemplate businessTemplate, LifeCycleManager lifeCycleManager)
444 	throws JAXRException
445 	{
446 		ServiceBinding serviceBinding = new ServiceBindingImpl(lifeCycleManager);
447 
448 		String keystr = businessTemplate.getServiceKey();
449 		if (keystr != null)
450 		{
451 			Service svc = new ServiceImpl(lifeCycleManager);
452 			svc.setKey(lifeCycleManager.createKey(keystr));
453 			((ServiceBindingImpl)serviceBinding).setService(svc);
454 		}
455 		String bindingKey = businessTemplate.getBindingKey();
456 		if(bindingKey != null) serviceBinding.setKey(new KeyImpl(bindingKey));
457 
458 		//Access URI
459 		AccessPoint access = businessTemplate.getAccessPoint();
460 		if (access != null) serviceBinding.setAccessURI(access.getValue());
461 
462 		//Description
463 		Description desc = null;
464 		if (businessTemplate.getDescription().size()>0) desc = businessTemplate.getDescription().get(0);
465 		if (desc!=null) {
466 			serviceBinding.setDescription(new InternationalStringImpl(desc.getValue()));
467 		}
468 		/**Section D.10 of JAXR 1.0 Specification */
469 
470 		TModelInstanceDetails details = businessTemplate.getTModelInstanceDetails();
471 		List<TModelInstanceInfo> tmodelInstanceInfoList = details.getTModelInstanceInfo();
472 
473 		for (TModelInstanceInfo info: tmodelInstanceInfoList)
474 		{
475 			if (info!=null && info.getInstanceDetails()!=null) {
476 				InstanceDetails idetails = info.getInstanceDetails();
477 				Collection<ExternalLink> elinks = getExternalLinks(idetails.getOverviewDoc(),lifeCycleManager);
478 				SpecificationLink slink = new SpecificationLinkImpl(lifeCycleManager);
479 				slink.addExternalLinks(elinks);
480 				serviceBinding.addSpecificationLink(slink); 
481 
482 				ConceptImpl c = new ConceptImpl(lifeCycleManager);
483 				c.setExternalLinks(elinks);
484 				c.setKey(lifeCycleManager.createKey(info.getTModelKey())); 
485 				c.setName(lifeCycleManager.createInternationalString(idetails.getInstanceParms()));
486 				c.setValue(idetails.getInstanceParms());
487 
488 				slink.setSpecificationObject(c);
489 			}
490 		}
491 
492 		HostingRedirector hr = businessTemplate.getHostingRedirector();
493 		if(hr != null)
494 		{
495 			ServiceBinding sb = lifeCycleManager.createServiceBinding();
496 			sb.setKey(new KeyImpl(hr.getBindingKey()));
497 			serviceBinding.setTargetBinding(sb);
498 		}
499 
500 		return serviceBinding;
501 	}
502 
503 	public static Concept getConcept(TModelDetail tModelDetail, LifeCycleManager lifeCycleManager)
504 	throws JAXRException
505 	{
506 		Concept concept = new ConceptImpl(lifeCycleManager);
507 		List<TModel> tmodelList = tModelDetail.getTModel();
508 		for (TModel tmodel : tmodelList) {
509 			concept.setKey(lifeCycleManager.createKey(tmodel.getTModelKey()));
510 			concept.setName(lifeCycleManager.createInternationalString(getLocale(tmodel.getName().getLang()),
511 					tmodel.getName().getValue()));
512 
513 			Description desc = getDescription(tmodel);
514 			if( desc != null ) {
515 				concept.setDescription(lifeCycleManager.createInternationalString(getLocale(desc.getLang()), 
516 						desc.getValue()));
517 			}
518 
519 			concept.addExternalIdentifiers(getExternalIdentifiers(tmodel.getIdentifierBag(), lifeCycleManager));
520 			concept.addClassifications(getClassifications(tmodel.getCategoryBag(), lifeCycleManager));
521 		}
522 		return concept;
523 	}
524 
525 	public static Concept getConcept(TModel tmodel, LifeCycleManager lifeCycleManager)
526 	throws JAXRException
527 	{
528 		Concept concept = new ConceptImpl(lifeCycleManager);
529 		concept.setKey(lifeCycleManager.createKey(tmodel.getTModelKey()));
530 		concept.setName(lifeCycleManager.createInternationalString(getLocale(tmodel.getName().getLang()),
531 				tmodel.getName().getValue()));
532 
533 		Description desc = getDescription(tmodel);
534 		if (desc != null) {
535 			concept.setDescription(lifeCycleManager.createInternationalString(getLocale(desc.getLang()), 
536 					desc.getValue()));
537 		}
538 
539 		concept.addExternalIdentifiers(getExternalIdentifiers(tmodel.getIdentifierBag(), lifeCycleManager));
540 		concept.addClassifications(getClassifications(tmodel.getCategoryBag(), lifeCycleManager));
541 
542 		return concept;
543 	}
544 
545 	public static Concept getConcept(TModelInfo tModelInfo, LifeCycleManager lifeCycleManager)
546 	throws JAXRException
547 	{
548 		Concept concept = new ConceptImpl(lifeCycleManager);
549 		concept.setKey(lifeCycleManager.createKey(tModelInfo.getTModelKey()));
550 		concept.setName(lifeCycleManager.createInternationalString(getLocale(tModelInfo.getName().getLang()), 
551 				tModelInfo.getName().getValue()));
552 
553 		return concept;
554 	}
555 
556 	private static Description getDescription( TModel tmodel )
557 	{
558 		Description desc = null;
559 		if (tmodel.getDescription().size()>0) desc=tmodel.getDescription().get(0);
560 		return desc;
561 	}
562 
563 	/**
564 	 * Classifications - going to assume all are external since UDDI does not use "Concepts".
565 	 * @param categoryBag categories
566 	 * @param lifeCycleManager lifecycleManager
567 	 * @return Collection Classifications
568 	 * @throws JAXRException on error
569 	 */
570 	public static Collection getClassifications(CategoryBag categoryBag, LifeCycleManager lifeCycleManager) 
571 	throws JAXRException {
572 		Collection<Classification> classifications = null;
573 		if (categoryBag != null) {
574 			classifications = new ArrayList<Classification>();
575 			List<KeyedReference> keyedReferenceList = categoryBag.getKeyedReference();
576 			for (KeyedReference keyedReference : keyedReferenceList) {
577 				Classification classification = new ClassificationImpl(lifeCycleManager);
578 				classification.setValue(keyedReference.getKeyValue());
579 				classification.setName(new InternationalStringImpl(keyedReference.getKeyName()));
580 				String tmodelKey = keyedReference.getTModelKey();
581 				if (tmodelKey != null) {
582 					ClassificationScheme scheme = new ClassificationSchemeImpl(lifeCycleManager);
583 					scheme.setKey(new KeyImpl(tmodelKey));
584 					classification.setClassificationScheme(scheme);
585 				}
586 				classifications.add(classification);
587 			}
588 		}
589 		return classifications;
590 	}
591 
592 	public static Collection<ExternalLink> getExternalLinks(OverviewDoc overviewDoc , LifeCycleManager lifeCycleManager)
593 	throws JAXRException
594 	{
595 		ArrayList<ExternalLink> alist = new ArrayList<ExternalLink>(1);
596 		if(overviewDoc != null)
597 		{
598 			String descStr = "";
599 			Description desc = null;
600 			if (overviewDoc.getDescription().size()>0) desc = overviewDoc.getDescription().get(0);
601 			if (desc !=null) descStr = desc.getValue();
602 			alist.add(lifeCycleManager.createExternalLink(overviewDoc.getOverviewURL(),descStr));
603 		}
604 
605 		return alist;
606 	}
607 
608 	/**
609 	 * External Identifiers
610 	 * @param identifierBag identifiers
611 	 * @param lifeCycleManager lifecycleManager
612 	 * @return Collection ExternalIdentifier
613 	 * @throws JAXRException on error
614 	 */
615 
616 	public static Collection getExternalIdentifiers(IdentifierBag identifierBag, LifeCycleManager lifeCycleManager) 
617 	throws JAXRException {
618 		Collection<ExternalIdentifier> extidentifiers = null;
619 		if (identifierBag != null) {
620 			extidentifiers = new ArrayList<ExternalIdentifier>();
621 
622 			List<KeyedReference> keyedReferenceList = identifierBag.getKeyedReference();
623 			for (KeyedReference keyedReference : keyedReferenceList) {
624 				ExternalIdentifier extId = new ExternalIdentifierImpl(lifeCycleManager);
625 				extId.setValue(keyedReference.getKeyValue());
626 				extId.setName(new InternationalStringImpl(keyedReference.getKeyName()));
627 
628 				String tmodelKey = keyedReference.getTModelKey();
629 				if (tmodelKey != null) {
630 					ClassificationScheme scheme = new ClassificationSchemeImpl(lifeCycleManager);
631 					scheme.setKey(new KeyImpl(tmodelKey));
632 					extId.setIdentificationScheme(scheme);
633 				}
634 				extidentifiers.add(extId);
635 			}
636 		}
637 		return extidentifiers;
638 	}
639 
640 	private static Locale getLocale(String lang) {
641 		if (lang == null || lang.trim().length() == 0) {
642 			return Locale.getDefault();
643 		} else if (lang.equalsIgnoreCase(Locale.getDefault().getLanguage())) {
644 			return Locale.getDefault();
645 		} else {
646 			return new Locale(lang);
647 		} 
648 	}
649 
650 }