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