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