Coverage Report - org.apache.ws.scout.registry.BusinessQueryManagerV3Impl
 
Classes in this File Line Coverage Branch Coverage Complexity
BusinessQueryManagerV3Impl
0%
0/493
0%
0/172
0
 
 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.registry;
 18  
 
 19  
 import java.net.PasswordAuthentication;
 20  
 import java.util.ArrayList;
 21  
 import java.util.Collection;
 22  
 import java.util.Iterator;
 23  
 import java.util.LinkedHashSet;
 24  
 import java.util.List;
 25  
 import java.util.Set;
 26  
 
 27  
 import javax.xml.registry.BulkResponse;
 28  
 import javax.xml.registry.BusinessLifeCycleManager;
 29  
 import javax.xml.registry.BusinessQueryManager;
 30  
 import javax.xml.registry.InvalidRequestException;
 31  
 import javax.xml.registry.JAXRException;
 32  
 import javax.xml.registry.LifeCycleManager;
 33  
 import javax.xml.registry.RegistryService;
 34  
 import javax.xml.registry.UnsupportedCapabilityException;
 35  
 import javax.xml.registry.infomodel.Association;
 36  
 import javax.xml.registry.infomodel.ClassificationScheme;
 37  
 import javax.xml.registry.infomodel.Concept;
 38  
 import javax.xml.registry.infomodel.Key;
 39  
 import javax.xml.registry.infomodel.LocalizedString;
 40  
 import javax.xml.registry.infomodel.Organization;
 41  
 import javax.xml.registry.infomodel.RegistryObject;
 42  
 import javax.xml.registry.infomodel.Service;
 43  
 import javax.xml.registry.infomodel.ServiceBinding;
 44  
 
 45  
 import org.apache.commons.logging.Log;
 46  
 import org.apache.commons.logging.LogFactory;
 47  
 
 48  
 import org.uddi.api_v3.*;
 49  
 import org.apache.ws.scout.registry.infomodel.AssociationImpl;
 50  
 import org.apache.ws.scout.registry.infomodel.ClassificationSchemeImpl;
 51  
 import org.apache.ws.scout.registry.infomodel.ConceptImpl;
 52  
 import org.apache.ws.scout.registry.infomodel.InternationalStringImpl;
 53  
 import org.apache.ws.scout.registry.infomodel.KeyImpl;
 54  
 import org.apache.ws.scout.registry.infomodel.ServiceBindingImpl;
 55  
 import org.apache.ws.scout.registry.infomodel.ServiceImpl;
 56  
 import org.apache.ws.scout.util.EnumerationHelper;
 57  
 import org.apache.ws.scout.util.ScoutJaxrUddiV3Helper;
 58  
 import org.apache.ws.scout.util.ScoutUddiV3JaxrHelper;
 59  
 
 60  
 /**
 61  
  * Implements the JAXR BusinessQueryManager Interface
 62  
  * For futher details, look into the JAXR API Javadoc.
 63  
  *
 64  
  * @author <a href="mailto:tcunning@apache.org">Tom Cunningham</a>
 65  
  * @author <a href="mailto:anil@apache.org">Anil Saldhana</a>
 66  
  * @author <a href="mailto:jboynes@apache.org">Jeremy Boynes</a>
 67  
  * @author <a href="mailto:geirm@apache.org">Geir Magnusson Jr.</a>
 68  
  */
 69  
 public class BusinessQueryManagerV3Impl implements BusinessQueryManager
 70  
 {
 71  
     private final RegistryServiceImpl registryService;
 72  0
     private Log log = LogFactory.getLog(this.getClass());
 73  
 
 74  0
     private static ObjectFactory objectFactory = new ObjectFactory();
 75  
 
 76  
     public BusinessQueryManagerV3Impl(RegistryServiceImpl registry)
 77  0
     {
 78  0
         this.registryService = registry;
 79  0
     }
 80  
 
 81  
     public RegistryService getRegistryService()
 82  
     {
 83  0
         return registryService;
 84  
     }
 85  
 
 86  
     /**
 87  
      * Finds organizations in the registry that match the specified parameters
 88  
      *
 89  
      * @param findQualifiers
 90  
      * @param namePatterns
 91  
      * @param classifications
 92  
      * @param specifications
 93  
      * @param externalIdentifiers
 94  
      * @param externalLinks
 95  
      * @return BulkResponse
 96  
      * @throws JAXRException
 97  
      */
 98  
     public BulkResponse findOrganizations(Collection findQualifiers,
 99  
                                           Collection namePatterns,
 100  
                                           Collection classifications,
 101  
                                           Collection specifications,
 102  
                                           Collection externalIdentifiers,
 103  
                                           Collection externalLinks) throws JAXRException
 104  
     {
 105  0
         IRegistryV3 registry = (IRegistryV3) registryService.getRegistry();
 106  
         try
 107  
         {
 108  0
             FindQualifiers juddiFindQualifiers = mapFindQualifiers(findQualifiers);
 109  0
             Name[] nameArray = mapNamePatterns(namePatterns);
 110  0
             BusinessList result = registry.findBusiness(nameArray,
 111  
                     null, 
 112  
                     ScoutJaxrUddiV3Helper.getIdentifierBagFromExternalIdentifiers(externalIdentifiers), 
 113  
                     ScoutJaxrUddiV3Helper.getCategoryBagFromClassifications(classifications), 
 114  
                     ScoutJaxrUddiV3Helper.getTModelBagFromSpecifications(specifications),
 115  
                     juddiFindQualifiers,
 116  
                     registryService.getMaxRows());
 117  
             
 118  0
             BusinessInfo[] bizInfoArr =null;
 119  0
             BusinessInfos bizInfos = result.getBusinessInfos();
 120  0
             LinkedHashSet<Organization> orgs = new LinkedHashSet<Organization>();
 121  0
             if(bizInfos != null)
 122  
             {
 123  0
                     List<BusinessInfo> bizInfoList = bizInfos.getBusinessInfo();
 124  0
                     for (BusinessInfo businessInfo : bizInfoList) {
 125  
                     //Now get the details on the individual biz
 126  0
                     BusinessDetail detail = registry.getBusinessDetail(businessInfo.getBusinessKey());
 127  0
                     BusinessLifeCycleManagerV3Impl blcm = (BusinessLifeCycleManagerV3Impl)registryService.getLifeCycleManagerImpl();
 128  0
                     orgs.add(blcm.createOrganization(detail));
 129  0
                                 }
 130  0
                     bizInfoArr = new BusinessInfo[bizInfoList.size()];
 131  0
                     bizInfoList.toArray(bizInfoArr);
 132  
             }
 133  0
             return new BulkResponseImpl(orgs);
 134  0
         } catch (RegistryV3Exception e)
 135  
         {
 136  0
             throw new JAXRException(e);
 137  
         }
 138  
     }
 139  
 
 140  
     public BulkResponse findAssociations(Collection findQualifiers,
 141  
                                          String sourceObjectId,
 142  
                                          String targetObjectId,
 143  
                                          Collection associationTypes) throws JAXRException
 144  
     {
 145  
         //TODO: Currently we just return all the Association objects owned by the caller
 146  0
         IRegistryV3 registry = (IRegistryV3) registryService.getRegistry();
 147  
         try
 148  
         {
 149  0
             ConnectionImpl con = ((RegistryServiceImpl)getRegistryService()).getConnection();
 150  0
             AuthToken auth = this.getAuthToken(con,registry);
 151  0
             PublisherAssertions result = null;
 152  
             try {
 153  0
                     result = registry.getPublisherAssertions(auth.getAuthInfo());
 154  0
                 } catch (RegistryV3Exception rve) {
 155  0
                         String username = getUsernameFromCredentials(con.getCredentials());
 156  0
                         if (AuthTokenV3Singleton.getToken(username) != null) {
 157  0
                                 AuthTokenV3Singleton.deleteAuthToken(username);
 158  
                         }
 159  0
                         auth = getAuthToken(con, registry);
 160  0
                 result = registry.getPublisherAssertions(auth.getAuthInfo());
 161  0
                 }
 162  
 
 163  0
             List<PublisherAssertion> publisherAssertionList = result.getPublisherAssertion();
 164  0
             LinkedHashSet<Association> col = new LinkedHashSet<Association>();
 165  0
             for (PublisherAssertion pas : publisherAssertionList) {
 166  0
                 String sourceKey = pas.getFromKey();
 167  0
                 String targetKey = pas.getToKey();
 168  0
                 Collection<Key> orgcol = new ArrayList<Key>();
 169  0
                 orgcol.add(new KeyImpl(sourceKey));
 170  0
                 orgcol.add(new KeyImpl(targetKey));
 171  0
                 BulkResponse bl = getRegistryObjects(orgcol, LifeCycleManager.ORGANIZATION);
 172  0
                 Association asso = ScoutUddiV3JaxrHelper.getAssociation(bl.getCollection(),
 173  
                                              registryService.getBusinessLifeCycleManager());
 174  0
                 KeyedReference keyr = pas.getKeyedReference();
 175  0
                 Concept c = new ConceptImpl(getRegistryService().getBusinessLifeCycleManager());
 176  0
                 c.setName(new InternationalStringImpl(keyr.getKeyName()));
 177  0
                 c.setKey( new KeyImpl(keyr.getTModelKey()) );
 178  0
                 c.setValue(keyr.getKeyValue());
 179  0
                 asso.setAssociationType(c);
 180  0
                 col.add(asso);
 181  0
             }
 182  0
             return new BulkResponseImpl(col);
 183  0
         } catch (RegistryV3Exception e)
 184  
         {
 185  0
             throw new JAXRException(e);
 186  
         }
 187  
     }
 188  
 
 189  
     public BulkResponse findCallerAssociations(Collection findQualifiers,
 190  
                                                Boolean confirmedByCaller,
 191  
                                                Boolean confirmedByOtherParty,
 192  
                                                Collection associationTypes) throws JAXRException
 193  
     {
 194  
         //TODO: Currently we just return all the Association objects owned by the caller
 195  0
         IRegistryV3 registry = (IRegistryV3) registryService.getRegistry();
 196  
         try
 197  
         {
 198  0
             ConnectionImpl con = ((RegistryServiceImpl)getRegistryService()).getConnection();
 199  0
             AuthToken auth = this.getAuthToken(con,registry);
 200  
            
 201  0
             AssertionStatusReport report = null;
 202  0
             String confirm = "";
 203  0
             boolean caller = confirmedByCaller.booleanValue();
 204  0
             boolean other = confirmedByOtherParty.booleanValue();
 205  
 
 206  0
             if(caller  && other   )
 207  0
                         confirm = Constants.COMPLETION_STATUS_COMPLETE;
 208  
             else
 209  0
               if(!caller  && other  )
 210  0
                         confirm = Constants.COMPLETION_STATUS_FROMKEY_INCOMPLETE;
 211  
             else
 212  0
                  if(caller  && !other   )
 213  0
                         confirm = Constants.COMPLETION_STATUS_TOKEY_INCOMPLETE;
 214  
 
 215  
             try { 
 216  0
                     report = registry.getAssertionStatusReport(auth.getAuthInfo(),confirm);
 217  0
                 } catch (RegistryV3Exception rve) {
 218  0
                         String username = getUsernameFromCredentials(con.getCredentials());
 219  0
                         if (AuthTokenV3Singleton.getToken(username) != null) {
 220  0
                                 AuthTokenV3Singleton.deleteAuthToken(username);
 221  
                         }
 222  0
                         auth = getAuthToken(con, registry);
 223  0
                     report = registry.getAssertionStatusReport(auth.getAuthInfo(),confirm);
 224  0
                 }
 225  
 
 226  
             
 227  0
             List<AssertionStatusItem> assertionStatusItemList = report.getAssertionStatusItem();
 228  0
             LinkedHashSet<Association> col = new LinkedHashSet<Association>();
 229  0
             for (AssertionStatusItem asi : assertionStatusItemList) {
 230  0
                 String sourceKey = asi.getFromKey();
 231  0
                 String targetKey = asi.getToKey();
 232  0
                 Collection<Key> orgcol = new ArrayList<Key>();
 233  0
                 orgcol.add(new KeyImpl(sourceKey));
 234  0
                 orgcol.add(new KeyImpl(targetKey));
 235  0
                 BulkResponse bl = getRegistryObjects(orgcol, LifeCycleManager.ORGANIZATION);
 236  0
                 Association asso = ScoutUddiV3JaxrHelper.getAssociation(bl.getCollection(),
 237  
                                              registryService.getBusinessLifeCycleManager());
 238  
                 //Set Confirmation
 239  0
                 ((AssociationImpl)asso).setConfirmedBySourceOwner(caller);
 240  0
                 ((AssociationImpl)asso).setConfirmedByTargetOwner(other);
 241  
 
 242  0
                 if(confirm != Constants.COMPLETION_STATUS_COMPLETE)
 243  0
                      ((AssociationImpl)asso).setConfirmed(false);
 244  
 
 245  0
                 Concept c = new ConceptImpl(getRegistryService().getBusinessLifeCycleManager());
 246  0
                 KeyedReference keyr = asi.getKeyedReference();
 247  0
                 c.setKey(new KeyImpl(keyr.getTModelKey()));
 248  0
                 c.setName(new InternationalStringImpl(keyr.getKeyName()));
 249  0
                 c.setValue(keyr.getKeyValue());
 250  0
                 asso.setKey(new KeyImpl(keyr.getTModelKey())); //TODO:Validate this
 251  0
                 asso.setAssociationType(c);
 252  0
                 col.add(asso);
 253  0
             }
 254  
 
 255  
 
 256  0
             return new BulkResponseImpl(col);
 257  0
         } catch (RegistryV3Exception e)
 258  
         {
 259  0
             throw new JAXRException(e);
 260  
         }
 261  
     }
 262  
 
 263  
     /**
 264  
      *  TODO - need to support the qualifiers
 265  
      *
 266  
      * @param findQualifiers
 267  
      * @param namePatterns
 268  
      * @return ClassificationScheme
 269  
      * @throws JAXRException
 270  
      */
 271  
     public ClassificationScheme findClassificationSchemeByName(Collection findQualifiers,
 272  
                                                                String namePatterns) throws JAXRException
 273  
     {
 274  0
         ClassificationScheme scheme = null;
 275  
 
 276  0
         if (namePatterns.indexOf("uddi-org:types") != -1) {
 277  
 
 278  0
             scheme = new ClassificationSchemeImpl(registryService.getLifeCycleManagerImpl());
 279  0
             scheme.setName(new InternationalStringImpl(namePatterns));
 280  0
             scheme.setKey(new KeyImpl(Constants.TMODEL_TYPES_TMODEL_KEY));
 281  
         }
 282  0
         else if (namePatterns.indexOf("dnb-com:D-U-N-S") != -1) {
 283  
 
 284  0
             scheme = new ClassificationSchemeImpl(registryService.getLifeCycleManagerImpl());
 285  0
             scheme.setName(new InternationalStringImpl(namePatterns));
 286  0
             scheme.setKey(new KeyImpl(Constants.TMODEL_D_U_N_S_TMODEL_KEY));
 287  
         }
 288  0
         else if (namePatterns.indexOf("uddi-org:iso-ch:3166:1999") != -1)
 289  
         {
 290  0
             scheme = new ClassificationSchemeImpl(registryService.getLifeCycleManagerImpl());
 291  0
             scheme.setName(new InternationalStringImpl(namePatterns));
 292  0
             scheme.setKey(new KeyImpl(Constants.TMODEL_ISO_CH_TMODEL_KEY));
 293  
         }
 294  0
         else if (namePatterns.indexOf("uddi-org:iso-ch:3166-1999") != -1)
 295  
         {
 296  0
             scheme = new ClassificationSchemeImpl(registryService.getLifeCycleManagerImpl());
 297  0
             scheme.setName(new InternationalStringImpl(namePatterns));
 298  0
             scheme.setKey(new KeyImpl(Constants.TMODEL_ISO_CH_TMODEL_KEY));
 299  
         }
 300  0
         else if (namePatterns.indexOf("iso-ch:3166:1999") != -1)
 301  
         {
 302  0
             scheme = new ClassificationSchemeImpl(registryService.getLifeCycleManagerImpl());
 303  0
             scheme.setName(new InternationalStringImpl(namePatterns));
 304  0
             scheme.setKey(new KeyImpl(Constants.TMODEL_ISO_CH_TMODEL_KEY));
 305  
         }
 306  0
         else if (namePatterns.indexOf("iso-ch:3166-1999") != -1)
 307  
         {
 308  0
             scheme = new ClassificationSchemeImpl(registryService.getLifeCycleManagerImpl());
 309  0
             scheme.setName(new InternationalStringImpl(namePatterns));
 310  0
             scheme.setKey(new KeyImpl(Constants.TMODEL_ISO_CH_TMODEL_KEY));
 311  
         }
 312  0
         else if (namePatterns.indexOf("unspsc-org:unspsc") != -1) {
 313  
 
 314  0
             scheme = new ClassificationSchemeImpl(registryService.getLifeCycleManagerImpl());
 315  0
             scheme.setName(new InternationalStringImpl(namePatterns));
 316  0
             scheme.setKey(new KeyImpl(Constants.TMODEL_UNSPSC_TMODEL_KEY));
 317  
         }
 318  0
         else if (namePatterns.indexOf("ntis-gov:naics") != -1) {
 319  
 
 320  0
             scheme = new ClassificationSchemeImpl(registryService.getLifeCycleManagerImpl());
 321  0
             scheme.setName(new InternationalStringImpl(namePatterns));
 322  0
             scheme.setKey(new KeyImpl(Constants.TMODEL_NAICS_TMODEL_KEY));
 323  
         }
 324  
         else
 325  
         {   //TODO:Before going to the registry, check if it a predefined Enumeration
 326  
 
 327  
             /*
 328  
              * predefined Enumerations
 329  
              */
 330  
 
 331  0
             if ("AssociationType".equals(namePatterns)) {
 332  0
                 scheme = new ClassificationSchemeImpl(registryService.getLifeCycleManagerImpl());
 333  
 
 334  0
                 scheme.setName(new InternationalStringImpl(namePatterns));
 335  
 
 336  0
                 scheme.setKey(new KeyImpl(Constants.TMODEL_UNSPSC_TMODEL_KEY));
 337  
 
 338  0
                 addChildConcept((ClassificationSchemeImpl)scheme, "RelatedTo");
 339  0
                 addChildConcept((ClassificationSchemeImpl)scheme, "HasChild");
 340  0
                 addChildConcept((ClassificationSchemeImpl)scheme, "HasMember");
 341  0
                 addChildConcept((ClassificationSchemeImpl)scheme, "HasParent");
 342  0
                 addChildConcept((ClassificationSchemeImpl)scheme, "ExternallyLinks");
 343  0
                 addChildConcept((ClassificationSchemeImpl)scheme, "Contains");
 344  0
                 addChildConcept((ClassificationSchemeImpl)scheme, "EquivalentTo");
 345  0
                 addChildConcept((ClassificationSchemeImpl)scheme, "Extends");
 346  0
                 addChildConcept((ClassificationSchemeImpl)scheme, "Implements");
 347  0
                 addChildConcept((ClassificationSchemeImpl)scheme, "InstanceOf");
 348  0
                 addChildConcept((ClassificationSchemeImpl)scheme, "Supersedes");
 349  0
                 addChildConcept((ClassificationSchemeImpl)scheme, "Uses");
 350  0
                 addChildConcept((ClassificationSchemeImpl)scheme, "Replaces");
 351  0
                 addChildConcept((ClassificationSchemeImpl)scheme, "ResponsibleFor");
 352  0
                 addChildConcept((ClassificationSchemeImpl)scheme, "SubmitterOf");
 353  
             }
 354  0
             else if ("ObjectType".equals(namePatterns)) {
 355  0
                 scheme = new ClassificationSchemeImpl(registryService.getLifeCycleManagerImpl());
 356  
 
 357  0
                 scheme.setName(new InternationalStringImpl(namePatterns));
 358  
 
 359  0
                 scheme.setKey(new KeyImpl(Constants.TMODEL_UNSPSC_TMODEL_KEY));
 360  
 
 361  0
                 addChildConcept((ClassificationSchemeImpl)scheme, "CPP");
 362  0
                 addChildConcept((ClassificationSchemeImpl)scheme, "CPA");
 363  0
                 addChildConcept((ClassificationSchemeImpl)scheme, "Process");
 364  0
                 addChildConcept((ClassificationSchemeImpl)scheme, "WSDL");
 365  0
                 addChildConcept((ClassificationSchemeImpl)scheme, "Association");
 366  0
                 addChildConcept((ClassificationSchemeImpl)scheme, "AuditableEvent");
 367  0
                 addChildConcept((ClassificationSchemeImpl)scheme, "Classification");
 368  0
                 addChildConcept((ClassificationSchemeImpl)scheme, "Concept");
 369  0
                 addChildConcept((ClassificationSchemeImpl)scheme, "ExternalIdentifier");
 370  0
                 addChildConcept((ClassificationSchemeImpl)scheme, "ExternalLink");
 371  0
                 addChildConcept((ClassificationSchemeImpl)scheme, "ExtrinsicObject");
 372  0
                 addChildConcept((ClassificationSchemeImpl)scheme, "Organization");
 373  0
                 addChildConcept((ClassificationSchemeImpl)scheme, "Package");
 374  0
                 addChildConcept((ClassificationSchemeImpl)scheme, "Service");
 375  0
                 addChildConcept((ClassificationSchemeImpl)scheme, "ServiceBinding");
 376  0
                 addChildConcept((ClassificationSchemeImpl)scheme, "User");
 377  
             }
 378  0
             else if ("PhoneType".equals(namePatterns)) {
 379  0
                 scheme = new ClassificationSchemeImpl(registryService.getLifeCycleManagerImpl());
 380  
 
 381  0
                 scheme.setName(new InternationalStringImpl(namePatterns));
 382  
 
 383  0
                 scheme.setKey(new KeyImpl(Constants.TMODEL_UNSPSC_TMODEL_KEY));
 384  
 
 385  0
                 addChildConcept((ClassificationSchemeImpl)scheme, "OfficePhone");
 386  0
                 addChildConcept((ClassificationSchemeImpl)scheme, "HomePhone");
 387  0
                 addChildConcept((ClassificationSchemeImpl)scheme, "MobilePhone");
 388  0
                 addChildConcept((ClassificationSchemeImpl)scheme, "Beeper");
 389  0
                 addChildConcept((ClassificationSchemeImpl)scheme, "FAX");
 390  
             }
 391  0
             else if ("URLType".equals(namePatterns)) {
 392  0
                 scheme = new ClassificationSchemeImpl(registryService.getLifeCycleManagerImpl());
 393  
 
 394  0
                 scheme.setName(new InternationalStringImpl(namePatterns));
 395  
 
 396  0
                 scheme.setKey(new KeyImpl(Constants.TMODEL_UNSPSC_TMODEL_KEY));
 397  
 
 398  0
                 addChildConcept((ClassificationSchemeImpl)scheme, "HTTP");
 399  0
                 addChildConcept((ClassificationSchemeImpl)scheme, "HTTPS");
 400  0
                 addChildConcept((ClassificationSchemeImpl)scheme, "SMTP");
 401  0
                 addChildConcept((ClassificationSchemeImpl)scheme, "PHONE");
 402  0
                 addChildConcept((ClassificationSchemeImpl)scheme, "FAX");
 403  0
                 addChildConcept((ClassificationSchemeImpl)scheme, "OTHER");
 404  
             }
 405  0
             else if ("PostalAddressAttributes".equals(namePatterns)) {
 406  0
                 scheme = new ClassificationSchemeImpl(registryService.getLifeCycleManagerImpl());
 407  
 
 408  0
                 scheme.setName(new InternationalStringImpl(namePatterns));
 409  
 
 410  0
                 scheme.setKey(new KeyImpl(Constants.TMODEL_UNSPSC_TMODEL_KEY));
 411  
 
 412  0
                 addChildConcept((ClassificationSchemeImpl)scheme, "StreetNumber");
 413  0
                 addChildConcept((ClassificationSchemeImpl)scheme, "Street");
 414  0
                 addChildConcept((ClassificationSchemeImpl)scheme, "City");
 415  0
                 addChildConcept((ClassificationSchemeImpl)scheme, "State");
 416  0
                 addChildConcept((ClassificationSchemeImpl)scheme, "PostalCode");
 417  0
                 addChildConcept((ClassificationSchemeImpl)scheme, "Country");
 418  
             }
 419  
             else {
 420  
 
 421  
                 //Lets ask the uddi registry if it has the TModels
 422  0
                 IRegistryV3 registry = (IRegistryV3) registryService.getRegistry();
 423  0
                 FindQualifiers juddiFindQualifiers = mapFindQualifiers(findQualifiers);
 424  
                 try
 425  
                 {
 426  
                     //We are looking for one exact match, so getting upto 3 records is fine
 427  0
                     TModelList list = registry.findTModel(namePatterns, null, null, juddiFindQualifiers, 3);
 428  0
                     if (list != null) {
 429  0
                         TModelInfos infos = list.getTModelInfos();
 430  0
                         if (infos != null) {
 431  0
                             List<TModelInfo> tmodelInfoList = infos.getTModelInfo();
 432  0
                             if (tmodelInfoList.size() > 1) {
 433  0
                                 throw new InvalidRequestException("Multiple matches found:" + tmodelInfoList.size());
 434  
                             }
 435  0
                             if (tmodelInfoList.size() ==1) {
 436  0
                                 TModelInfo info = tmodelInfoList.get(0);
 437  0
                                 scheme = new ClassificationSchemeImpl(registryService.getLifeCycleManagerImpl());
 438  0
                                 scheme.setName(new InternationalStringImpl(info.getName().getValue()));
 439  0
                                 scheme.setKey(new KeyImpl(info.getTModelKey()));
 440  
                             }
 441  
                         }
 442  
                     }
 443  
 
 444  0
                 } catch (RegistryV3Exception e)
 445  
                 { 
 446  0
                     throw new JAXRException(e.getLocalizedMessage());
 447  0
                 }
 448  
             }
 449  
         }
 450  0
         return scheme;
 451  
     }
 452  
 
 453  
     /**
 454  
      * Creates a new Concept, associates w/ parent scheme, and then
 455  
      * adds as decendent.
 456  
      * @param scheme
 457  
      * @param name
 458  
      * @throws JAXRException
 459  
      */
 460  
     private void addChildConcept(ClassificationSchemeImpl scheme, String name)
 461  
         throws JAXRException {
 462  0
         Concept c = new ConceptImpl(registryService.getLifeCycleManagerImpl());
 463  
 
 464  0
         c.setName(new InternationalStringImpl(name));
 465  0
         c.setValue(name);
 466  0
         ((ConceptImpl)c).setScheme((ClassificationSchemeImpl)scheme);
 467  
 
 468  0
         scheme.addChildConcept(c);
 469  0
     }
 470  
 
 471  
     public BulkResponse findClassificationSchemes(Collection findQualifiers, 
 472  
                                                                                               Collection namePatterns, 
 473  
                                                                                               Collection classifications, 
 474  
                                                                                               Collection externalLinks) throws JAXRException
 475  
         {
 476  
                 //TODO: Handle this better
 477  0
         LinkedHashSet<ClassificationScheme> col = new LinkedHashSet<ClassificationScheme>();
 478  0
                 Iterator iter = namePatterns.iterator();
 479  0
                 String name = "";
 480  0
                 while(iter.hasNext())
 481  
                 {
 482  0
                         name = (String)iter.next();
 483  
                         break;
 484  
                 }
 485  
                 
 486  0
         ClassificationScheme classificationScheme = findClassificationSchemeByName(findQualifiers,name);
 487  0
         if (classificationScheme!=null) {
 488  0
             col.add(classificationScheme);
 489  
         }
 490  0
                 return new BulkResponseImpl(col);
 491  
         }
 492  
 
 493  
     public Concept findConceptByPath(String path) throws JAXRException
 494  
     {
 495  
         //We will store the enumerations datastructure in the util package
 496  
         /**
 497  
          * I am not clear about how this association type enumerations
 498  
          * are to be implemented.
 499  
          */
 500  0
         return EnumerationHelper.getConceptByPath(path);
 501  
     }
 502  
 
 503  
     public BulkResponse findConcepts(Collection findQualifiers,
 504  
                                      Collection namePatterns,
 505  
                                      Collection classifications,
 506  
                                      Collection externalIdentifiers,
 507  
                                      Collection externalLinks) throws JAXRException
 508  
     {
 509  0
         LinkedHashSet<Concept> col = new LinkedHashSet<Concept>();
 510  
 
 511  
         //Lets ask the uddi registry if it has the TModels
 512  0
         IRegistryV3 registry = (IRegistryV3) registryService.getRegistry();
 513  0
         FindQualifiers juddiFindQualifiers = mapFindQualifiers(findQualifiers);
 514  0
         Iterator iter = null;
 515  0
         if (namePatterns != null) iter = namePatterns.iterator();
 516  0
         while (iter.hasNext())
 517  
         {
 518  0
             String namestr = (String) iter.next();
 519  
             try
 520  
             {
 521  0
                 TModelList list = registry.findTModel(namestr, 
 522  
                         ScoutJaxrUddiV3Helper.getCategoryBagFromClassifications(classifications), 
 523  
                         ScoutJaxrUddiV3Helper.getIdentifierBagFromExternalIdentifiers(externalIdentifiers), 
 524  
                                 juddiFindQualifiers, 10);
 525  
                
 526  0
                 if (list != null && list.getTModelInfos()!=null) {
 527  0
                         List<TModelInfo> tmodelInfoList = list.getTModelInfos().getTModelInfo();
 528  0
                         if (tmodelInfoList!=null) {
 529  0
                                 for (TModelInfo info: tmodelInfoList) {
 530  0
                             col.add(ScoutUddiV3JaxrHelper.getConcept(info, this.registryService.getBusinessLifeCycleManager()));
 531  
                                                 }
 532  
                         }
 533  
                 }
 534  0
             } catch (RegistryV3Exception e) { 
 535  0
                 throw new JAXRException(e.getLocalizedMessage());
 536  0
             }
 537  0
         }
 538  
 
 539  0
         return new BulkResponseImpl(col);
 540  
     }
 541  
 
 542  
     public BulkResponse findRegistryPackages(Collection findQualifiers,
 543  
                                              Collection namePatterns,
 544  
                                              Collection classifications,
 545  
                                              Collection externalLinks) throws JAXRException
 546  
     {
 547  0
         throw new UnsupportedCapabilityException();
 548  
     }
 549  
 
 550  
     public BulkResponse findServiceBindings(Key serviceKey,
 551  
                                             Collection findQualifiers,
 552  
                                             Collection classifications,
 553  
                                             Collection specifications) throws JAXRException
 554  
     {
 555  0
         BulkResponseImpl blkRes = new BulkResponseImpl();
 556  
 
 557  0
         IRegistryV3 iRegistry = (IRegistryV3) registryService.getRegistry();
 558  0
         FindQualifiers juddiFindQualifiers = mapFindQualifiers(findQualifiers);
 559  
 
 560  
         try
 561  
         {
 562  
  
 563  0
             BindingDetail bindingDetail = iRegistry.findBinding(serviceKey.getId(),
 564  
                     ScoutJaxrUddiV3Helper.getCategoryBagFromClassifications(classifications), 
 565  
                             ScoutJaxrUddiV3Helper.getTModelBagFromSpecifications(specifications),
 566  
                             juddiFindQualifiers,registryService.getMaxRows());
 567  
 
 568  
             /*
 569  
              * now convert  from jUDDI ServiceInfo objects to JAXR Services
 570  
              */
 571  0
             if (bindingDetail != null) {
 572  
 
 573  0
                     List<BindingTemplate> bindingTemplateList = bindingDetail.getBindingTemplate();
 574  0
                 BindingTemplate[] bindarr = new BindingTemplate[bindingTemplateList.size()];
 575  0
                 bindingTemplateList.toArray(bindarr);
 576  
                 
 577  0
                 LinkedHashSet<ServiceBinding> col = new LinkedHashSet<ServiceBinding>();
 578  
 
 579  0
                 for (int i=0; bindarr != null && i < bindarr.length; i++) {
 580  0
                     BindingTemplate si = bindarr[i];
 581  0
                     ServiceBinding sb =  ScoutUddiV3JaxrHelper.getServiceBinding(si,
 582  
                             registryService.getBusinessLifeCycleManager());
 583  0
                     col.add(sb);
 584  
                    //Fill the Service object by making a call to registry
 585  0
                    Service s = (Service)getRegistryObject(serviceKey.getId(), LifeCycleManager.SERVICE);
 586  0
                    ((ServiceBindingImpl)sb).setService(s);
 587  
                 }
 588  
 
 589  0
                 blkRes.setCollection(col);
 590  
             }
 591  
         }
 592  0
         catch (RegistryV3Exception e) {
 593  0
             throw new JAXRException(e.getLocalizedMessage());
 594  0
         }
 595  
 
 596  0
         return blkRes;
 597  
     }
 598  
 
 599  
 
 600  
     /**
 601  
      * Finds all Service objects that match all of the criteria specified by
 602  
      * the parameters of this call.  This is a logical AND operation between
 603  
      * all non-null parameters
 604  
      *
 605  
      * TODO - support findQualifiers, classifications and specifications
 606  
      *
 607  
      * @param orgKey
 608  
      * @param findQualifiers
 609  
      * @param namePatterns
 610  
      * @param classifications
 611  
      * @param specificationa
 612  
      * @return BulkResponse
 613  
      * @throws JAXRException
 614  
      */
 615  
     public BulkResponse findServices(Key orgKey, Collection findQualifiers,
 616  
                                      Collection namePatterns,
 617  
                                      Collection classifications,
 618  
                                      Collection specificationa) throws JAXRException
 619  
     {
 620  0
         BulkResponseImpl blkRes = new BulkResponseImpl();
 621  
 
 622  0
         IRegistryV3 iRegistry = (IRegistryV3) registryService.getRegistry();
 623  0
         FindQualifiers juddiFindQualifiers = mapFindQualifiers(findQualifiers);
 624  0
         Name[] juddiNames = mapNamePatterns(namePatterns);
 625  
 
 626  
         try
 627  
         {
 628  
             /*
 629  
              * hit the registry.  The key is not required for UDDI2
 630  
              */
 631  
 
 632  0
             String id = null;
 633  
 
 634  0
             if (orgKey != null) {
 635  0
                 id = orgKey.getId();
 636  
             }
 637  
 
 638  0
             ServiceList serviceList = iRegistry.findService(id, 
 639  
                             juddiNames,
 640  
                     ScoutJaxrUddiV3Helper.getCategoryBagFromClassifications(classifications), 
 641  
                     null, 
 642  
                     juddiFindQualifiers, registryService.getMaxRows());
 643  
 
 644  
             /*
 645  
              * now convert  from jUDDI ServiceInfo objects to JAXR Services
 646  
              */
 647  0
             if (serviceList != null) {
 648  
 
 649  0
                 ServiceInfos serviceInfos = serviceList.getServiceInfos();
 650  0
                 LinkedHashSet<Service> col = new LinkedHashSet<Service>();
 651  
                 
 652  0
                 if(serviceInfos != null && serviceInfos.getServiceInfo()!=null) {
 653  0
                         for (ServiceInfo si : serviceInfos.getServiceInfo()) {
 654  0
                                 Service srv = (Service) getRegistryObject(si.getServiceKey(), LifeCycleManager.SERVICE);
 655  0
                         col.add(srv);
 656  0
                                         }
 657  
                         
 658  
                 }
 659  0
                 blkRes.setCollection(col);
 660  
             }
 661  
         }
 662  0
         catch (RegistryV3Exception e) {
 663  0
             throw new JAXRException(e.getLocalizedMessage());
 664  0
         }
 665  
 
 666  0
         return blkRes;
 667  
     }
 668  
 
 669  
     public RegistryObject getRegistryObject(String id) throws JAXRException
 670  
     {
 671  0
         throw new UnsupportedCapabilityException();
 672  
     }
 673  
 
 674  
     public RegistryObject getRegistryObject(String id, String objectType) throws JAXRException
 675  
     {
 676  0
         IRegistryV3 registry = (IRegistryV3) registryService.getRegistry();
 677  0
         BusinessLifeCycleManager lcm = registryService.getBusinessLifeCycleManager();
 678  
 
 679  0
         if (LifeCycleManager.CLASSIFICATION_SCHEME.equalsIgnoreCase(objectType)) {
 680  
 
 681  
             try {
 682  
 
 683  0
                 TModelDetail tmodeldetail = registry.getTModelDetail(id);
 684  0
                 Concept c = ScoutUddiV3JaxrHelper.getConcept(tmodeldetail, lcm);
 685  
 
 686  
                 /*
 687  
                  * now turn into a concrete ClassificationScheme
 688  
                  */
 689  
 
 690  0
                 ClassificationScheme scheme = new ClassificationSchemeImpl(lcm);
 691  
 
 692  0
                 scheme.setName(c.getName());
 693  0
                 scheme.setDescription(c.getDescription());
 694  0
                 scheme.setKey(c.getKey());
 695  
 
 696  0
                 return scheme;
 697  
             }
 698  0
             catch (RegistryV3Exception e) {
 699  0
                 throw new JAXRException(e.getLocalizedMessage());
 700  
             }
 701  
         }
 702  0
         else if (LifeCycleManager.ORGANIZATION.equalsIgnoreCase(objectType)) {                
 703  
             try
 704  
             {
 705  0
                 BusinessDetail orgdetail = registry.getBusinessDetail(id);
 706  0
                 return ScoutUddiV3JaxrHelper.getOrganization(orgdetail, lcm);
 707  
             }
 708  0
             catch (RegistryV3Exception e) {
 709  0
                 throw new JAXRException(e.getLocalizedMessage());
 710  
             }
 711  
 
 712  
         }
 713  0
         else if (LifeCycleManager.CONCEPT.equalsIgnoreCase(objectType)) {
 714  
 
 715  
             try
 716  
             {
 717  0
                 TModelDetail tmodeldetail = registry.getTModelDetail(id);
 718  0
                 return ScoutUddiV3JaxrHelper.getConcept(tmodeldetail, lcm);
 719  
             }
 720  0
             catch (RegistryV3Exception e) { 
 721  0
                 throw new JAXRException(e.getLocalizedMessage());
 722  
             }
 723  
         }
 724  0
         else if (LifeCycleManager.SERVICE.equalsIgnoreCase(objectType)) {
 725  
 
 726  
             try {
 727  0
                 ServiceDetail sd = registry.getServiceDetail(id);
 728  0
                 if (sd != null && sd.getBusinessService()!=null) {
 729  0
                     for (BusinessService businessService : sd.getBusinessService()) {
 730  0
                             Service service = getServiceFromBusinessService(businessService, lcm);
 731  0
                             return service;
 732  
                                         }
 733  
                 }
 734  
             }
 735  0
             catch (RegistryV3Exception e) {
 736  0
                 throw new RuntimeException(e);
 737  0
             }
 738  
         }
 739  
 
 740  0
         return null;
 741  
     }
 742  
 
 743  
     /**
 744  
      *  Helper routine to take a jUDDI business service and turn into a useful
 745  
      *  Service.  Needs to go back to the registry to get the organization to
 746  
      *  properly hydrate the Service
 747  
      *
 748  
      * @param bs  BusinessService object to turn in to a Service
 749  
      * @param lcm manager to use
 750  
      * @return new Service object
 751  
      * @throws JAXRException
 752  
      */
 753  
     protected Service getServiceFromBusinessService(BusinessService bs, LifeCycleManager lcm)
 754  
         throws JAXRException {
 755  
 
 756  0
         ServiceImpl service  = (ServiceImpl) ScoutUddiV3JaxrHelper.getService(bs, lcm);
 757  0
         service.setSubmittingOrganizationKey(bs.getBusinessKey());
 758  
 
 759  0
         return service;
 760  
     }
 761  
 
 762  
     /**
 763  
      * Gets the RegistryObjects owned by the caller. The objects
 764  
      * are returned as their concrete type (e.g. Organization, User etc.)
 765  
      *
 766  
      *  TODO - need to figure out what the set are.  This is just to get some
 767  
      *  basic functionality
 768  
      *
 769  
      * @return BulkResponse
 770  
      * @throws JAXRException
 771  
      */
 772  
     public BulkResponse getRegistryObjects() throws JAXRException
 773  
     {
 774  0
         String types[] = {
 775  
             LifeCycleManager.ORGANIZATION,
 776  
             LifeCycleManager.SERVICE};
 777  
 
 778  0
         LinkedHashSet<Object> c = new LinkedHashSet<Object>();
 779  
 
 780  0
         for (int i = 0; i < types.length; i++) {
 781  
             try {
 782  0
                 BulkResponse bk = getRegistryObjects(types[i]);
 783  
 
 784  0
                 if (bk.getCollection() != null) {
 785  0
                     c.addAll(bk.getCollection());
 786  
                 }
 787  0
             } catch(JAXRException e) {
 788  0
                     log.debug("ignore - just a problem with that type? " + e.getMessage(), e);
 789  0
             }
 790  
         }
 791  
 
 792  0
         return new BulkResponseImpl(c);
 793  
     }
 794  
 
 795  
     public BulkResponse getRegistryObjects(Collection objectKeys) throws JAXRException
 796  
     {
 797  0
         throw new UnsupportedCapabilityException();
 798  
     }
 799  
 
 800  
     public BulkResponse getRegistryObjects(Collection objectKeys, String objectType) throws JAXRException
 801  
     {
 802  0
         IRegistryV3 registry = (IRegistryV3) registryService.getRegistry();
 803  
         //Convert into a vector of strings
 804  0
         String[] keys = new String[objectKeys.size()];
 805  0
         int currLoc = 0;
 806  0
         for (Key key : (Collection<Key>) objectKeys) {
 807  0
                 String keyString = key.getId();
 808  0
             keys[currLoc++]=keyString;
 809  0
         }
 810  0
         LinkedHashSet<RegistryObject> col = new LinkedHashSet<RegistryObject>();
 811  0
         LifeCycleManager lcm = registryService.getLifeCycleManagerImpl();
 812  
 
 813  0
         if (LifeCycleManager.CLASSIFICATION_SCHEME.equalsIgnoreCase(objectType))
 814  
         {
 815  
             try
 816  
             {
 817  0
                 TModelDetail tmodeldetail = registry.getTModelDetail(keys);
 818  0
                 List<TModel> tmodelList = tmodeldetail.getTModel();
 819  
 
 820  0
                 for (TModel tModel: tmodelList)
 821  
                 {
 822  0
                     col.add(ScoutUddiV3JaxrHelper.getConcept(tModel, lcm));
 823  
                 }
 824  
 
 825  0
             } catch (RegistryV3Exception e)
 826  
             { 
 827  0
                 throw new JAXRException(e.getLocalizedMessage());
 828  0
             }
 829  
         }
 830  0
         else if (LifeCycleManager.ORGANIZATION.equalsIgnoreCase(objectType))
 831  
         {
 832  0
                 ConnectionImpl con = ((RegistryServiceImpl)getRegistryService()).getConnection();
 833  0
             AuthToken auth = this.getAuthToken(con,registry);
 834  
                 
 835  
             try
 836  
             {
 837  0
                     RegisteredInfo ri = null;
 838  
                     try {
 839  0
                             ri = registry.getRegisteredInfo(auth.getAuthInfo());
 840  0
                     } catch (RegistryV3Exception rve) {
 841  0
                             String username = getUsernameFromCredentials(con.getCredentials());
 842  0
                             if (AuthTokenV3Singleton.getToken(username) != null) {
 843  0
                                     AuthTokenV3Singleton.deleteAuthToken(username);
 844  
                             }
 845  0
                             auth = getAuthToken(con, registry);
 846  0
                             ri = registry.getRegisteredInfo(auth.getAuthInfo());
 847  0
                     }
 848  
 
 849  0
                 if (ri != null) {
 850  0
                     BusinessInfos infos = ri.getBusinessInfos();
 851  0
                     if (infos != null) {
 852  0
                         for (String key: keys) {
 853  0
                                 BusinessDetail detail = registry.getBusinessDetail(key);
 854  0
                                     col.add(((BusinessLifeCycleManagerV3Impl)registryService.getLifeCycleManagerImpl()).createOrganization(detail));
 855  
                                                 }
 856  
                     }
 857  
                 }
 858  0
             } catch (RegistryV3Exception e) {
 859  0
                     throw new JAXRException(e.getLocalizedMessage());
 860  0
             }
 861  0
         }
 862  0
         else if (LifeCycleManager.CONCEPT.equalsIgnoreCase(objectType))
 863  
         {
 864  
             try {
 865  0
                 TModelDetail tmodeldetail = registry.getTModelDetail(keys);
 866  0
                 List<TModel> tmodelList = tmodeldetail.getTModel();
 867  
 
 868  0
                 for (TModel tmodel: tmodelList)
 869  
                 {
 870  0
                     col.add(ScoutUddiV3JaxrHelper.getConcept(tmodel, lcm));
 871  
                 }
 872  
 
 873  
             }
 874  0
             catch (RegistryV3Exception e)
 875  
             { 
 876  0
                 throw new JAXRException(e.getLocalizedMessage());
 877  0
             }
 878  
         }
 879  0
         else if (LifeCycleManager.SERVICE.equalsIgnoreCase(objectType)) {
 880  
 
 881  
             try {
 882  0
                 ServiceDetail serviceDetail = registry.getServiceDetail(keys);
 883  
 
 884  0
                 if (serviceDetail != null) {
 885  0
                     List<BusinessService> bizServiceList = serviceDetail.getBusinessService();
 886  
 
 887  0
                     for (BusinessService businessService: bizServiceList) {
 888  
 
 889  0
                         Service service = getServiceFromBusinessService(businessService, lcm);
 890  
                         
 891  0
                         col.add(service);
 892  0
                     }
 893  
                 }
 894  
             }
 895  0
             catch (RegistryV3Exception e) {
 896  0
                 throw new JAXRException(e);
 897  0
             }
 898  
         }
 899  
         else {
 900  0
             throw new JAXRException("Unsupported type " + objectType +
 901  
                     " for getRegistryObjects() in Apache Scout");
 902  
         }
 903  
 
 904  0
         return new BulkResponseImpl(col);
 905  
 
 906  
     }
 907  
 
 908  
     public BulkResponse getRegistryObjects(String id) throws JAXRException
 909  
     {
 910  0
         if (LifeCycleManager.ORGANIZATION.equalsIgnoreCase(id)) {
 911  0
             IRegistryV3 registry = (IRegistryV3) registryService.getRegistry();
 912  0
                 ConnectionImpl con = ((RegistryServiceImpl)getRegistryService()).getConnection();
 913  0
             AuthToken auth = this.getAuthToken(con,registry);
 914  0
                     LinkedHashSet<Organization> orgs = null;
 915  
             try
 916  
             {
 917  0
                     RegisteredInfo ri = null;
 918  
                     try {
 919  0
                             ri = registry.getRegisteredInfo(auth.getAuthInfo());
 920  0
                     } catch (RegistryV3Exception rve) {
 921  0
                             String username = getUsernameFromCredentials(con.getCredentials());
 922  0
                             if (AuthTokenV3Singleton.getToken(username) != null) {
 923  0
                                     AuthTokenV3Singleton.deleteAuthToken(username);
 924  
                             }
 925  0
                             auth = getAuthToken(con, registry);
 926  0
                             ri = registry.getRegisteredInfo(auth.getAuthInfo());
 927  0
                     }
 928  
 
 929  0
                     if (ri != null && ri.getBusinessInfos()!=null) {
 930  0
                             List<BusinessInfo> bizInfoList = ri.getBusinessInfos().getBusinessInfo();
 931  0
                             orgs = new LinkedHashSet<Organization>();
 932  0
                             for (BusinessInfo businessInfo : bizInfoList) {
 933  0
                                     BusinessDetail detail = registry.getBusinessDetail(businessInfo.getBusinessKey());
 934  0
                         orgs.add(((BusinessLifeCycleManagerV3Impl)registryService.getLifeCycleManagerImpl()).createOrganization(detail));
 935  0
                                         }
 936  
                     }
 937  
                     
 938  0
             } catch (RegistryV3Exception re) {
 939  0
                     throw new JAXRException(re);
 940  0
             }
 941  0
             return new BulkResponseImpl(orgs);
 942  
         }
 943  0
         else if (LifeCycleManager.SERVICE.equalsIgnoreCase(id)) {
 944  0
             List<String> a = new ArrayList<String>();
 945  0
             a.add("%");
 946  
 
 947  0
             BulkResponse br = this.findServices(null,null, a, null, null);
 948  
 
 949  0
             return br;
 950  
         }
 951  
         else
 952  
         {
 953  0
             throw new JAXRException("Unsupported type for getRegistryObjects() :" + id);
 954  
         }
 955  
 
 956  
     }
 957  
 
 958  
     static FindQualifiers mapFindQualifiers(Collection jaxrQualifiers) throws UnsupportedCapabilityException
 959  
     {
 960  0
         if (jaxrQualifiers == null)
 961  
         {
 962  0
             return null;
 963  
         }
 964  0
         FindQualifiers result = objectFactory.createFindQualifiers();
 965  0
         for (Iterator i = jaxrQualifiers.iterator(); i.hasNext();)
 966  
         {
 967  0
             String jaxrQualifier = (String) i.next();
 968  0
             String juddiQualifier = jaxrQualifier;
 969  
            
 970  
             // SCOUT-111 
 971  
             // If the JAXR qualifier is exactNameMatch, then 
 972  
             // set the UDDI v3 qualifier to exactMatch 
 973  0
             if ("exactNameMatch".equals(jaxrQualifier)) {
 974  0
                 juddiQualifier = "exactMatch";
 975  
             }
 976  
             
 977  0
             if (juddiQualifier == null)
 978  
             {
 979  0
                 throw new UnsupportedCapabilityException("jUDDI does not support FindQualifer: " + jaxrQualifier);
 980  
             }
 981  0
             result.getFindQualifier().add(juddiQualifier);
 982  0
         }
 983  0
         return result;
 984  
     }
 985  
 
 986  
     static Name[] mapNamePatterns(Collection namePatterns)
 987  
         throws JAXRException
 988  
     {
 989  0
         if (namePatterns == null)
 990  0
             return null;
 991  0
         Name[] result = new Name[namePatterns.size()];
 992  0
         int currLoc = 0;
 993  0
         for (Iterator i = namePatterns.iterator(); i.hasNext();)
 994  
         {
 995  0
             Object obj = i.next();
 996  0
             Name name = objectFactory.createName();
 997  0
             if (obj instanceof String) {
 998  0
                 name.setValue((String)obj);
 999  0
             } else if (obj instanceof LocalizedString) {
 1000  0
                 LocalizedString ls = (LocalizedString)obj;
 1001  0
                 name.setValue(ls.getValue());
 1002  0
                 name.setLang(ls.getLocale().getLanguage());
 1003  
             }
 1004  0
             result[currLoc] = name;
 1005  0
             currLoc++;
 1006  0
         }
 1007  0
         return result;
 1008  
     }
 1009  
 
 1010  
    /**
 1011  
      * Get the Auth Token from the registry
 1012  
      *
 1013  
      * @param connection
 1014  
      * @param ireg
 1015  
      * @return auth token
 1016  
      * @throws JAXRException
 1017  
      */
 1018  
     private AuthToken getAuthToken(ConnectionImpl connection, IRegistryV3 ireg)
 1019  
             throws JAXRException {
 1020  0
         Set creds = connection.getCredentials();
 1021  0
         Iterator it = creds.iterator();
 1022  0
         String username = "", pwd = "";
 1023  0
         while (it.hasNext()) {
 1024  0
             PasswordAuthentication pass = (PasswordAuthentication) it.next();
 1025  0
             username = pass.getUserName();
 1026  0
             pwd = new String(pass.getPassword());
 1027  0
         }
 1028  
 
 1029  0
         if (AuthTokenV3Singleton.getToken(username) != null) {
 1030  0
                 return (AuthToken) AuthTokenV3Singleton.getToken(username);
 1031  
         }
 1032  
         
 1033  0
         AuthToken token = null;
 1034  
         try {
 1035  0
             token = ireg.getAuthToken(username, pwd);
 1036  
         }
 1037  0
         catch (Exception e) {
 1038  0
             throw new JAXRException(e);
 1039  0
         }
 1040  0
         AuthTokenV3Singleton.addAuthToken(username, token);
 1041  
 
 1042  0
         return token;
 1043  
     }
 1044  
     
 1045  
     private String getUsernameFromCredentials(Set credentials) {
 1046  0
         String username = "", pwd = "";
 1047  
                 
 1048  0
         if (credentials != null) {
 1049  0
                 Iterator it = credentials.iterator();
 1050  0
                 while (it.hasNext()) {
 1051  0
                         PasswordAuthentication pass = (PasswordAuthentication) it.next();
 1052  0
                         username = pass.getUserName();
 1053  0
                 }
 1054  
         }
 1055  0
         return username;
 1056  
     }
 1057  
 
 1058  
 }