| 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.io.Serializable; |
| 20 | |
import java.net.PasswordAuthentication; |
| 21 | |
import java.util.ArrayList; |
| 22 | |
import java.util.Collection; |
| 23 | |
import java.util.HashSet; |
| 24 | |
import java.util.Hashtable; |
| 25 | |
import java.util.Iterator; |
| 26 | |
import java.util.LinkedHashSet; |
| 27 | |
import java.util.List; |
| 28 | |
import java.util.Set; |
| 29 | |
import java.util.Vector; |
| 30 | |
|
| 31 | |
import javax.xml.registry.BulkResponse; |
| 32 | |
import javax.xml.registry.BusinessLifeCycleManager; |
| 33 | |
import javax.xml.registry.DeleteException; |
| 34 | |
import javax.xml.registry.InvalidRequestException; |
| 35 | |
import javax.xml.registry.JAXRException; |
| 36 | |
import javax.xml.registry.JAXRResponse; |
| 37 | |
import javax.xml.registry.LifeCycleManager; |
| 38 | |
import javax.xml.registry.RegistryService; |
| 39 | |
import javax.xml.registry.SaveException; |
| 40 | |
import javax.xml.registry.UnexpectedObjectException; |
| 41 | |
import javax.xml.registry.infomodel.Association; |
| 42 | |
import javax.xml.registry.infomodel.ClassificationScheme; |
| 43 | |
import javax.xml.registry.infomodel.Concept; |
| 44 | |
import javax.xml.registry.infomodel.Key; |
| 45 | |
import javax.xml.registry.infomodel.Organization; |
| 46 | |
import javax.xml.registry.infomodel.RegistryObject; |
| 47 | |
import javax.xml.registry.infomodel.Service; |
| 48 | |
import javax.xml.registry.infomodel.ServiceBinding; |
| 49 | |
|
| 50 | |
import org.apache.commons.logging.Log; |
| 51 | |
import org.apache.commons.logging.LogFactory; |
| 52 | |
import org.apache.ws.scout.registry.infomodel.ConceptImpl; |
| 53 | |
import org.apache.ws.scout.registry.infomodel.InternationalStringImpl; |
| 54 | |
import org.apache.ws.scout.registry.infomodel.KeyImpl; |
| 55 | |
import org.apache.ws.scout.registry.infomodel.OrganizationImpl; |
| 56 | |
import org.apache.ws.scout.registry.infomodel.ServiceImpl; |
| 57 | |
import org.apache.ws.scout.util.ScoutJaxrUddiV3Helper; |
| 58 | |
import org.apache.ws.scout.util.ScoutUddiV3JaxrHelper; |
| 59 | |
import org.uddi.api_v3.AssertionStatusItem; |
| 60 | |
import org.uddi.api_v3.AssertionStatusReport; |
| 61 | |
import org.uddi.api_v3.AuthToken; |
| 62 | |
import org.uddi.api_v3.BindingDetail; |
| 63 | |
import org.uddi.api_v3.BindingTemplate; |
| 64 | |
import org.uddi.api_v3.BusinessDetail; |
| 65 | |
import org.uddi.api_v3.BusinessEntity; |
| 66 | |
import org.uddi.api_v3.BusinessInfo; |
| 67 | |
import org.uddi.api_v3.BusinessService; |
| 68 | |
import org.uddi.api_v3.Description; |
| 69 | |
import org.uddi.api_v3.DispositionReport; |
| 70 | |
import org.uddi.api_v3.ErrInfo; |
| 71 | |
import org.uddi.api_v3.KeyedReference; |
| 72 | |
import org.uddi.api_v3.Name; |
| 73 | |
import org.uddi.api_v3.ObjectFactory; |
| 74 | |
import org.uddi.api_v3.PublisherAssertion; |
| 75 | |
import org.uddi.api_v3.PublisherAssertions; |
| 76 | |
import org.uddi.api_v3.Result; |
| 77 | |
import org.uddi.api_v3.ServiceDetail; |
| 78 | |
import org.uddi.api_v3.ServiceInfo; |
| 79 | |
import org.uddi.api_v3.TModel; |
| 80 | |
import org.uddi.api_v3.TModelDetail; |
| 81 | |
|
| 82 | |
|
| 83 | |
|
| 84 | |
|
| 85 | |
|
| 86 | |
|
| 87 | |
|
| 88 | |
|
| 89 | |
|
| 90 | |
public class BusinessLifeCycleManagerV3Impl extends LifeCycleManagerImpl |
| 91 | |
implements BusinessLifeCycleManager, Serializable { |
| 92 | |
|
| 93 | |
private static final long serialVersionUID = -1145007155334678356L; |
| 94 | |
|
| 95 | 58 | private Log log = LogFactory.getLog(this.getClass()); |
| 96 | |
|
| 97 | 58 | private transient ObjectFactory objectFactory = new ObjectFactory(); |
| 98 | |
|
| 99 | |
public BusinessLifeCycleManagerV3Impl(RegistryService registry) { |
| 100 | 58 | super(registry); |
| 101 | 58 | if(objectFactory == null) |
| 102 | 0 | objectFactory = new ObjectFactory(); |
| 103 | 58 | } |
| 104 | |
|
| 105 | |
|
| 106 | |
|
| 107 | |
|
| 108 | |
|
| 109 | |
|
| 110 | |
|
| 111 | |
|
| 112 | |
|
| 113 | |
|
| 114 | |
public BulkResponse deleteObjects(Collection keys, String objectType) throws JAXRException { |
| 115 | 0 | BulkResponse bulk = null; |
| 116 | |
|
| 117 | 0 | if (objectType == LifeCycleManager.ASSOCIATION) { |
| 118 | 0 | bulk = this.deleteAssociations(keys); |
| 119 | |
} |
| 120 | 0 | else if (objectType == LifeCycleManager.CLASSIFICATION_SCHEME) { |
| 121 | 0 | bulk = this.deleteClassificationSchemes(keys); |
| 122 | |
} |
| 123 | 0 | else if (objectType == LifeCycleManager.CONCEPT) { |
| 124 | 0 | bulk = this.deleteConcepts(keys); |
| 125 | |
} |
| 126 | 0 | else if (objectType == LifeCycleManager.ORGANIZATION) { |
| 127 | 0 | bulk = this.deleteOrganizations(keys); |
| 128 | |
} |
| 129 | 0 | else if (objectType == LifeCycleManager.SERVICE) { |
| 130 | 0 | bulk = this.deleteServices(keys); |
| 131 | |
} |
| 132 | 0 | else if (objectType == LifeCycleManager.SERVICE_BINDING) { |
| 133 | 0 | bulk = this.deleteServiceBindings(keys); |
| 134 | |
} |
| 135 | |
else { |
| 136 | 0 | throw new JAXRException("Delete Operation for " + objectType + " not implemented by Scout"); |
| 137 | |
} |
| 138 | |
|
| 139 | 0 | return bulk; |
| 140 | |
} |
| 141 | |
|
| 142 | |
public BulkResponse deleteAssociations(Collection associationKeys) throws JAXRException { |
| 143 | 0 | return this.deleteOperation(associationKeys, "DELETE_ASSOCIATION"); |
| 144 | |
} |
| 145 | |
|
| 146 | |
public BulkResponse deleteClassificationSchemes(Collection schemeKeys) throws JAXRException { |
| 147 | 0 | return this.deleteOperation(schemeKeys, "DELETE_CLASSIFICATIONSCHEME"); |
| 148 | |
} |
| 149 | |
|
| 150 | |
public BulkResponse deleteConcepts(Collection conceptKeys) throws JAXRException { |
| 151 | 0 | return this.deleteOperation(conceptKeys, "DELETE_CONCEPT"); |
| 152 | |
} |
| 153 | |
|
| 154 | |
public BulkResponse deleteOrganizations(Collection orgkeys) throws JAXRException { |
| 155 | 0 | return this.deleteOperation(orgkeys, "DELETE_ORG"); |
| 156 | |
} |
| 157 | |
|
| 158 | |
public BulkResponse deleteServiceBindings(Collection bindingKeys) throws JAXRException { |
| 159 | 0 | return this.deleteOperation(bindingKeys, "DELETE_SERVICEBINDING"); |
| 160 | |
} |
| 161 | |
|
| 162 | |
public BulkResponse deleteServices(Collection serviceKeys) throws JAXRException { |
| 163 | 0 | return this.deleteOperation(serviceKeys, "DELETE_SERVICE"); |
| 164 | |
} |
| 165 | |
|
| 166 | |
|
| 167 | |
|
| 168 | |
|
| 169 | |
|
| 170 | |
|
| 171 | |
|
| 172 | |
|
| 173 | |
|
| 174 | |
|
| 175 | |
|
| 176 | |
|
| 177 | |
|
| 178 | |
|
| 179 | |
|
| 180 | |
|
| 181 | |
|
| 182 | |
|
| 183 | |
|
| 184 | |
|
| 185 | |
|
| 186 | |
public BulkResponse saveObjects(Collection col) throws JAXRException { |
| 187 | |
|
| 188 | 0 | Iterator iter = col.iterator(); |
| 189 | |
|
| 190 | 0 | LinkedHashSet<Object> suc = new LinkedHashSet<Object>(); |
| 191 | 0 | Collection<Exception> exc = new ArrayList<Exception>(); |
| 192 | |
|
| 193 | 0 | while (iter.hasNext()) { |
| 194 | 0 | RegistryObject reg = (RegistryObject) iter.next(); |
| 195 | |
|
| 196 | 0 | BulkResponse br = null; |
| 197 | |
|
| 198 | 0 | Collection<RegistryObject> c = new ArrayList<RegistryObject>(); |
| 199 | 0 | c.add(reg); |
| 200 | |
|
| 201 | 0 | if (reg instanceof javax.xml.registry.infomodel.Association) { |
| 202 | 0 | br = saveAssociations(c, true); |
| 203 | |
} |
| 204 | 0 | else if (reg instanceof javax.xml.registry.infomodel.ClassificationScheme) { |
| 205 | 0 | br = saveClassificationSchemes(c); |
| 206 | |
} |
| 207 | 0 | else if (reg instanceof javax.xml.registry.infomodel.Concept) { |
| 208 | 0 | br = saveConcepts(c); |
| 209 | |
} |
| 210 | 0 | else if (reg instanceof javax.xml.registry.infomodel.Organization) { |
| 211 | 0 | br = saveOrganizations(c); |
| 212 | |
} |
| 213 | 0 | else if (reg instanceof javax.xml.registry.infomodel.Service) { |
| 214 | 0 | br = saveServices(c); |
| 215 | |
} |
| 216 | 0 | else if (reg instanceof javax.xml.registry.infomodel.ServiceBinding) { |
| 217 | 0 | br = saveServiceBindings(c); |
| 218 | |
} |
| 219 | |
else { |
| 220 | 0 | throw new JAXRException("Delete Operation for " + reg.getClass() |
| 221 | |
+ " not implemented by Scout"); |
| 222 | |
} |
| 223 | |
|
| 224 | 0 | if (br.getCollection() != null) { |
| 225 | 0 | suc.addAll(br.getCollection()); |
| 226 | |
} |
| 227 | |
|
| 228 | 0 | if (br.getExceptions() != null) { |
| 229 | 0 | exc.addAll(br.getExceptions()); |
| 230 | |
} |
| 231 | 0 | } |
| 232 | |
|
| 233 | 0 | BulkResponseImpl bulk = new BulkResponseImpl(); |
| 234 | |
|
| 235 | |
|
| 236 | |
|
| 237 | |
|
| 238 | 0 | bulk.setStatus(JAXRResponse.STATUS_SUCCESS); |
| 239 | |
|
| 240 | 0 | bulk.setCollection(suc); |
| 241 | 0 | bulk.setExceptions(exc); |
| 242 | |
|
| 243 | 0 | return bulk; |
| 244 | |
} |
| 245 | |
|
| 246 | |
|
| 247 | |
public BulkResponse saveAssociations(Collection associations, boolean replace) throws JAXRException { |
| 248 | 0 | BulkResponseImpl bulk = new BulkResponseImpl(); |
| 249 | 0 | PublisherAssertion[] sarr = new PublisherAssertion[associations.size()]; |
| 250 | |
|
| 251 | 0 | Collection<Key> coll = new ArrayList<Key>(); |
| 252 | 0 | Collection<Exception> exceptions = new ArrayList<Exception>(); |
| 253 | |
|
| 254 | 0 | Iterator iter = associations.iterator(); |
| 255 | 0 | int currLoc = 0; |
| 256 | 0 | while (iter.hasNext()) { |
| 257 | |
|
| 258 | 0 | Association association = (Association) iter.next(); |
| 259 | 0 | association.getSourceObject(); |
| 260 | 0 | PublisherAssertion pa = ScoutJaxrUddiV3Helper.getPubAssertionFromJAXRAssociation(association); |
| 261 | 0 | sarr[currLoc] = pa; |
| 262 | 0 | currLoc++; |
| 263 | |
|
| 264 | |
|
| 265 | 0 | PublisherAssertions bd = null; |
| 266 | |
try { |
| 267 | 0 | bd = (PublisherAssertions) executeOperation(sarr, "SAVE_ASSOCIATION"); |
| 268 | |
} |
| 269 | 0 | catch (RegistryV3Exception e) { |
| 270 | 0 | exceptions.add(new SaveException(e)); |
| 271 | 0 | bulk.setExceptions(exceptions); |
| 272 | 0 | bulk.setStatus(JAXRResponse.STATUS_FAILURE); |
| 273 | 0 | return bulk; |
| 274 | 0 | } |
| 275 | 0 | if(bd != null) |
| 276 | |
{ |
| 277 | 0 | List<PublisherAssertion> publisherAssertionList = bd.getPublisherAssertion(); |
| 278 | 0 | PublisherAssertion[] keyarr = new PublisherAssertion[publisherAssertionList.size()]; |
| 279 | 0 | publisherAssertionList.toArray(keyarr); |
| 280 | |
|
| 281 | 0 | for (int i = 0; keyarr != null && i < keyarr.length; i++) { |
| 282 | 0 | PublisherAssertion result = (PublisherAssertion) keyarr[i]; |
| 283 | 0 | KeyedReference keyr = result.getKeyedReference(); |
| 284 | 0 | Concept c = new ConceptImpl(getRegistryService().getBusinessLifeCycleManager()); |
| 285 | 0 | c.setName(new InternationalStringImpl(keyr.getKeyName())); |
| 286 | 0 | c.setKey( new KeyImpl(keyr.getTModelKey()) ); |
| 287 | 0 | c.setValue(keyr.getKeyValue()); |
| 288 | 0 | association.setAssociationType(c); |
| 289 | 0 | coll.add(association.getKey()); |
| 290 | |
} |
| 291 | |
} |
| 292 | 0 | } |
| 293 | 0 | bulk.setCollection(coll); |
| 294 | 0 | bulk.setExceptions(exceptions); |
| 295 | |
|
| 296 | 0 | return bulk; |
| 297 | |
} |
| 298 | |
|
| 299 | |
public BulkResponse saveClassificationSchemes(Collection schemes) throws JAXRException { |
| 300 | |
|
| 301 | 0 | BulkResponseImpl bulk = new BulkResponseImpl(); |
| 302 | 0 | TModel[] entityarr = new TModel[schemes.size()]; |
| 303 | |
|
| 304 | 0 | LinkedHashSet<Key> coll = new LinkedHashSet<Key>(); |
| 305 | 0 | Collection<Exception> exceptions = new ArrayList<Exception>(); |
| 306 | |
|
| 307 | 0 | Iterator iter = schemes.iterator(); |
| 308 | 0 | int currLoc = 0; |
| 309 | 0 | while (iter.hasNext()) { |
| 310 | |
try { |
| 311 | 0 | TModel en = |
| 312 | 0 | ScoutJaxrUddiV3Helper.getTModelFromJAXRClassificationScheme((ClassificationScheme) iter.next()); |
| 313 | 0 | entityarr[currLoc] = en; |
| 314 | 0 | currLoc++; |
| 315 | |
} |
| 316 | 0 | catch (ClassCastException ce) { |
| 317 | 0 | throw new UnexpectedObjectException(); |
| 318 | 0 | } |
| 319 | |
} |
| 320 | 0 | log.debug("Method:save_classificationscheme: ENlength=" + entityarr.length); |
| 321 | |
|
| 322 | 0 | TModelDetail td = null; |
| 323 | |
try { |
| 324 | 0 | td = (TModelDetail) executeOperation(entityarr, "SAVE_TMODEL"); |
| 325 | |
} |
| 326 | 0 | catch (RegistryV3Exception e) { |
| 327 | 0 | exceptions.add(new SaveException(e.getLocalizedMessage())); |
| 328 | 0 | bulk.setStatus(JAXRResponse.STATUS_FAILURE); |
| 329 | 0 | return bulk; |
| 330 | 0 | } |
| 331 | |
|
| 332 | 0 | List<TModel> tmodelList = td.getTModel(); |
| 333 | 0 | entityarr = new TModel[tmodelList.size()]; |
| 334 | 0 | tmodelList.toArray(entityarr); |
| 335 | 0 | log.debug("After Saving TModel. Obtained vector size:" + ((entityarr != null) ? entityarr.length : 0)); |
| 336 | 0 | for (int i = 0; entityarr != null && i < entityarr.length; i++) { |
| 337 | 0 | TModel tm = (TModel) entityarr[i]; |
| 338 | 0 | coll.add(new KeyImpl(tm.getTModelKey())); |
| 339 | |
} |
| 340 | |
|
| 341 | 0 | bulk.setCollection(coll); |
| 342 | 0 | bulk.setExceptions(exceptions); |
| 343 | |
|
| 344 | 0 | return bulk; |
| 345 | |
} |
| 346 | |
|
| 347 | |
public BulkResponse saveConcepts(Collection concepts) throws JAXRException { |
| 348 | |
|
| 349 | 0 | BulkResponseImpl bulk = new BulkResponseImpl(); |
| 350 | 0 | TModel[] entityarr = new TModel[concepts.size()]; |
| 351 | |
|
| 352 | 0 | LinkedHashSet<Key> coll = new LinkedHashSet<Key>(); |
| 353 | 0 | Collection<Exception> exceptions = new ArrayList<Exception>(); |
| 354 | |
|
| 355 | 0 | Iterator iter = concepts.iterator(); |
| 356 | 0 | int currLoc = 0; |
| 357 | 0 | while (iter.hasNext()) { |
| 358 | |
try { |
| 359 | 0 | TModel en = |
| 360 | 0 | ScoutJaxrUddiV3Helper.getTModelFromJAXRConcept((Concept) iter.next()); |
| 361 | 0 | entityarr[currLoc] = en; |
| 362 | 0 | currLoc++; |
| 363 | |
} |
| 364 | 0 | catch (ClassCastException ce) { |
| 365 | 0 | throw new UnexpectedObjectException(); |
| 366 | 0 | } |
| 367 | |
} |
| 368 | 0 | log.debug("Method:save_concept: ENlength=" + entityarr.length); |
| 369 | |
|
| 370 | 0 | TModelDetail td = null; |
| 371 | |
try { |
| 372 | 0 | td = (TModelDetail) executeOperation(entityarr, "SAVE_TMODEL"); |
| 373 | |
} |
| 374 | 0 | catch (RegistryV3Exception e) { |
| 375 | 0 | exceptions.add(new SaveException(e.getLocalizedMessage())); |
| 376 | 0 | bulk.setStatus(JAXRResponse.STATUS_FAILURE); |
| 377 | 0 | return bulk; |
| 378 | 0 | } |
| 379 | |
|
| 380 | 0 | List<TModel> tmodelList = td.getTModel(); |
| 381 | 0 | entityarr = new TModel[tmodelList.size()]; |
| 382 | 0 | tmodelList.toArray(entityarr); |
| 383 | |
|
| 384 | 0 | log.debug("After Saving TModel. Obtained vector size:" + ((entityarr != null) ? entityarr.length : 0)); |
| 385 | 0 | for (int i = 0; entityarr != null && i < entityarr.length; i++) { |
| 386 | 0 | TModel tm = (TModel) entityarr[i]; |
| 387 | 0 | coll.add(new KeyImpl(tm.getTModelKey())); |
| 388 | |
} |
| 389 | |
|
| 390 | 0 | bulk.setCollection(coll); |
| 391 | 0 | bulk.setExceptions(exceptions); |
| 392 | |
|
| 393 | 0 | return bulk; |
| 394 | |
} |
| 395 | |
|
| 396 | |
public BulkResponse saveOrganizations(Collection organizations) throws JAXRException { |
| 397 | |
|
| 398 | 0 | BulkResponseImpl bulk = new BulkResponseImpl(); |
| 399 | 0 | BusinessEntity[] entityarr = new BusinessEntity[organizations.size()]; |
| 400 | |
|
| 401 | 0 | LinkedHashSet<Key> coll = new LinkedHashSet<Key>(); |
| 402 | 0 | Collection<Exception> exceptions = new ArrayList<Exception>(); |
| 403 | |
|
| 404 | 0 | Iterator iter = organizations.iterator(); |
| 405 | 0 | int currLoc = 0; |
| 406 | 0 | while (iter.hasNext()) { |
| 407 | |
try { |
| 408 | 0 | BusinessEntity en = |
| 409 | 0 | ScoutJaxrUddiV3Helper.getBusinessEntityFromJAXROrg((Organization) iter.next()); |
| 410 | 0 | entityarr[currLoc] = en; |
| 411 | 0 | currLoc++; |
| 412 | |
} |
| 413 | 0 | catch (ClassCastException ce) { |
| 414 | 0 | throw new UnexpectedObjectException(); |
| 415 | 0 | } |
| 416 | |
} |
| 417 | 0 | log.debug("Method:save_business: ENlength=" + entityarr.length); |
| 418 | |
|
| 419 | 0 | BusinessDetail bd = null; |
| 420 | |
try { |
| 421 | 0 | bd = (BusinessDetail) executeOperation(entityarr, "SAVE_ORG"); |
| 422 | |
} |
| 423 | 0 | catch (RegistryV3Exception e) { |
| 424 | 0 | exceptions.add(new SaveException(e.getLocalizedMessage())); |
| 425 | 0 | bulk.setStatus(JAXRResponse.STATUS_FAILURE); |
| 426 | 0 | return bulk; |
| 427 | 0 | } |
| 428 | |
|
| 429 | 0 | List<BusinessEntity> bizEntityList = bd.getBusinessEntity(); |
| 430 | |
|
| 431 | 0 | entityarr = new BusinessEntity[bizEntityList.size()]; |
| 432 | 0 | bizEntityList.toArray(entityarr); |
| 433 | |
|
| 434 | 0 | log.debug("After Saving Business. Obtained vector size:" + ((entityarr != null) ? entityarr.length : 0)); |
| 435 | 0 | for (int i = 0; entityarr != null && i < entityarr.length; i++) { |
| 436 | 0 | BusinessEntity entity = (BusinessEntity) entityarr[i]; |
| 437 | 0 | coll.add(new KeyImpl(entity.getBusinessKey())); |
| 438 | |
} |
| 439 | |
|
| 440 | 0 | bulk.setCollection(coll); |
| 441 | 0 | bulk.setExceptions(exceptions); |
| 442 | |
|
| 443 | 0 | return bulk; |
| 444 | |
} |
| 445 | |
|
| 446 | |
public BulkResponse saveServiceBindings(Collection bindings) throws JAXRException { |
| 447 | 0 | BulkResponseImpl bulk = new BulkResponseImpl(); |
| 448 | 0 | BindingTemplate[] sbarr = new BindingTemplate[bindings.size()]; |
| 449 | |
|
| 450 | 0 | LinkedHashSet<Key> coll = new LinkedHashSet<Key>(); |
| 451 | 0 | Collection<Exception> exceptions = new ArrayList<Exception>(); |
| 452 | |
|
| 453 | 0 | Iterator iter = bindings.iterator(); |
| 454 | 0 | int currLoc = 0; |
| 455 | 0 | while (iter.hasNext()) { |
| 456 | |
try { |
| 457 | 0 | BindingTemplate bs = ScoutJaxrUddiV3Helper.getBindingTemplateFromJAXRSB((ServiceBinding) iter.next()); |
| 458 | 0 | sbarr[currLoc] = bs; |
| 459 | 0 | currLoc++; |
| 460 | |
} |
| 461 | 0 | catch (ClassCastException ce) { |
| 462 | 0 | throw new UnexpectedObjectException(); |
| 463 | 0 | } |
| 464 | |
} |
| 465 | |
|
| 466 | 0 | BindingDetail bd = null; |
| 467 | |
try { |
| 468 | 0 | bd = (BindingDetail) executeOperation(sbarr, "SAVE_SERVICE_BINDING"); |
| 469 | |
} |
| 470 | 0 | catch (RegistryV3Exception e) { |
| 471 | 0 | exceptions.add(new SaveException(e.getLocalizedMessage())); |
| 472 | 0 | bulk.setStatus(JAXRResponse.STATUS_FAILURE); |
| 473 | 0 | return bulk; |
| 474 | 0 | } |
| 475 | |
|
| 476 | 0 | List<BindingTemplate> bindingTemplateList = bd.getBindingTemplate(); |
| 477 | 0 | sbarr = new BindingTemplate[bindingTemplateList.size()]; |
| 478 | 0 | bindingTemplateList.toArray(sbarr); |
| 479 | |
|
| 480 | 0 | for (int i = 0; sbarr != null && i < sbarr.length; i++) { |
| 481 | 0 | BindingTemplate bt = (BindingTemplate) sbarr[i]; |
| 482 | 0 | coll.add(new KeyImpl(bt.getBindingKey())); |
| 483 | |
} |
| 484 | 0 | if (coll.size()>0) { |
| 485 | 0 | bulk.setCollection(coll); |
| 486 | |
} |
| 487 | 0 | bulk.setExceptions(exceptions); |
| 488 | |
|
| 489 | 0 | return bulk; |
| 490 | |
} |
| 491 | |
|
| 492 | |
public BulkResponse saveServices(Collection services) throws JAXRException { |
| 493 | 0 | BulkResponseImpl bulk = new BulkResponseImpl(); |
| 494 | 0 | BusinessService[] sarr = new BusinessService[services.size()]; |
| 495 | |
|
| 496 | 0 | LinkedHashSet<Key> coll = new LinkedHashSet<Key>(); |
| 497 | 0 | Collection<Exception> exceptions = new ArrayList<Exception>(); |
| 498 | |
|
| 499 | |
|
| 500 | 0 | Iterator iter = services.iterator(); |
| 501 | 0 | int currLoc = 0; |
| 502 | 0 | while (iter.hasNext()) { |
| 503 | |
try { |
| 504 | 0 | BusinessService bs = ScoutJaxrUddiV3Helper.getBusinessServiceFromJAXRService((Service) iter.next()); |
| 505 | 0 | sarr[currLoc] = bs; |
| 506 | 0 | currLoc++; |
| 507 | |
} |
| 508 | 0 | catch (ClassCastException ce) { |
| 509 | 0 | throw new UnexpectedObjectException(); |
| 510 | 0 | } |
| 511 | |
} |
| 512 | |
|
| 513 | 0 | ServiceDetail sd = null; |
| 514 | |
try { |
| 515 | 0 | sd = (ServiceDetail) executeOperation(sarr, "SAVE_SERVICE"); |
| 516 | |
} |
| 517 | 0 | catch (RegistryV3Exception e) { |
| 518 | 0 | exceptions.add(new SaveException(e.getLocalizedMessage())); |
| 519 | 0 | bulk.setStatus(JAXRResponse.STATUS_FAILURE); |
| 520 | 0 | return bulk; |
| 521 | 0 | } |
| 522 | |
|
| 523 | 0 | List<BusinessService> bizServiceList = sd.getBusinessService(); |
| 524 | 0 | sarr = new BusinessService[bizServiceList.size()]; |
| 525 | 0 | bizServiceList.toArray(sarr); |
| 526 | |
|
| 527 | 0 | for (int i = 0; sarr != null && i < sarr.length; i++) { |
| 528 | 0 | BusinessService entity = (BusinessService) sarr[i]; |
| 529 | 0 | coll.add(new KeyImpl(entity.getServiceKey())); |
| 530 | |
} |
| 531 | 0 | bulk.setCollection(coll); |
| 532 | 0 | bulk.setExceptions(exceptions); |
| 533 | |
|
| 534 | 0 | return bulk; |
| 535 | |
} |
| 536 | |
|
| 537 | |
public void confirmAssociation(Association assoc) throws JAXRException, InvalidRequestException { |
| 538 | |
|
| 539 | 0 | HashSet<Association> col = new HashSet<Association>(); |
| 540 | 0 | col.add(assoc); |
| 541 | 0 | BulkResponse br = this.saveAssociations(col, true); |
| 542 | 0 | if(br.getExceptions()!= null) |
| 543 | 0 | throw new JAXRException("Confiming the Association Failed"); |
| 544 | 0 | } |
| 545 | |
|
| 546 | |
public void unConfirmAssociation(Association assoc) throws JAXRException, InvalidRequestException { |
| 547 | |
|
| 548 | |
|
| 549 | 0 | Collection<Key> col = new ArrayList<Key>(); |
| 550 | 0 | col.add(assoc.getKey()); |
| 551 | 0 | BulkResponse br = this.deleteAssociations(col); |
| 552 | 0 | if(br.getExceptions()!= null) |
| 553 | 0 | throw new JAXRException("UnConfiming the Association Failed"); |
| 554 | 0 | } |
| 555 | |
|
| 556 | |
|
| 557 | |
protected Object executeOperation(Object dataarray, String op) |
| 558 | |
throws RegistryV3Exception, JAXRException { |
| 559 | 0 | if (registry == null) { |
| 560 | 0 | throw new IllegalStateException("No registry"); |
| 561 | |
} |
| 562 | |
|
| 563 | 0 | IRegistryV3 ireg = (IRegistryV3) registry.getRegistry(); |
| 564 | |
|
| 565 | 0 | ConnectionImpl connection = registry.getConnection(); |
| 566 | 0 | AuthToken token = getAuthToken(connection, ireg); |
| 567 | 0 | if (token == null) { |
| 568 | 0 | throw new IllegalStateException("No auth token returned"); |
| 569 | |
} |
| 570 | |
|
| 571 | |
Object regobj; |
| 572 | 0 | if(op.equalsIgnoreCase("SAVE_ASSOCIATION")) |
| 573 | |
{ |
| 574 | |
try { |
| 575 | 0 | regobj = ireg.setPublisherAssertions(token.getAuthInfo(), (PublisherAssertion[]) dataarray); |
| 576 | 0 | } catch (RegistryV3Exception rve) { |
| 577 | 0 | String username = getUsernameFromCredentials(connection.getCredentials()); |
| 578 | 0 | if (AuthTokenV3Singleton.getToken(username) != null) { |
| 579 | 0 | AuthTokenV3Singleton.deleteAuthToken(username); |
| 580 | |
} |
| 581 | 0 | token = getAuthToken(connection, ireg); |
| 582 | 0 | regobj = ireg.setPublisherAssertions(token.getAuthInfo(), (PublisherAssertion[]) dataarray); |
| 583 | 0 | } |
| 584 | 0 | } else if (op.equalsIgnoreCase("SAVE_SERVICE")) { |
| 585 | |
try { |
| 586 | 0 | regobj = ireg.saveService(token.getAuthInfo(), (BusinessService[])dataarray); |
| 587 | 0 | } catch (RegistryV3Exception rve) { |
| 588 | 0 | String username = getUsernameFromCredentials(connection.getCredentials()); |
| 589 | 0 | if (AuthTokenV3Singleton.getToken(username) != null) { |
| 590 | 0 | AuthTokenV3Singleton.deleteAuthToken(username); |
| 591 | |
} |
| 592 | 0 | token = getAuthToken(connection, ireg); |
| 593 | 0 | regobj = ireg.saveService(token.getAuthInfo(), (BusinessService[])dataarray); |
| 594 | 0 | } |
| 595 | |
} |
| 596 | 0 | else if (op.equalsIgnoreCase("SAVE_SERVICE_BINDING")) { |
| 597 | |
try { |
| 598 | 0 | regobj = ireg.saveBinding(token.getAuthInfo(), (BindingTemplate[]) dataarray); |
| 599 | 0 | } catch (RegistryV3Exception rve) { |
| 600 | 0 | String username = getUsernameFromCredentials(connection.getCredentials()); |
| 601 | 0 | if (AuthTokenV3Singleton.getToken(username) != null) { |
| 602 | 0 | AuthTokenV3Singleton.deleteAuthToken(username); |
| 603 | |
} |
| 604 | 0 | token = getAuthToken(connection, ireg); |
| 605 | 0 | regobj = ireg.saveBinding(token.getAuthInfo(), (BindingTemplate[]) dataarray); |
| 606 | 0 | } |
| 607 | |
} |
| 608 | 0 | else if (op.equalsIgnoreCase("SAVE_ORG")) { |
| 609 | |
try { |
| 610 | 0 | regobj = ireg.saveBusiness(token.getAuthInfo(), (BusinessEntity[]) dataarray); |
| 611 | 0 | } catch (RegistryV3Exception rve) { |
| 612 | 0 | String username = getUsernameFromCredentials(connection.getCredentials()); |
| 613 | 0 | if (AuthTokenV3Singleton.getToken(username) != null) { |
| 614 | 0 | AuthTokenV3Singleton.deleteAuthToken(username); |
| 615 | |
} |
| 616 | 0 | token = getAuthToken(connection, ireg); |
| 617 | 0 | regobj = ireg.saveBusiness(token.getAuthInfo(), (BusinessEntity[]) dataarray); |
| 618 | 0 | } |
| 619 | |
} |
| 620 | 0 | else if (op.equalsIgnoreCase("SAVE_TMODEL")) { |
| 621 | |
try { |
| 622 | 0 | regobj = ireg.saveTModel(token.getAuthInfo(), (TModel[]) dataarray); |
| 623 | 0 | } catch (RegistryV3Exception rve) { |
| 624 | 0 | String username = getUsernameFromCredentials(connection.getCredentials()); |
| 625 | 0 | if (AuthTokenV3Singleton.getToken(username) != null) { |
| 626 | 0 | AuthTokenV3Singleton.deleteAuthToken(username); |
| 627 | |
} |
| 628 | 0 | token = getAuthToken(connection, ireg); |
| 629 | 0 | regobj = ireg.saveTModel(token.getAuthInfo(), (TModel[]) dataarray); |
| 630 | 0 | } |
| 631 | |
} |
| 632 | 0 | else if (op.equalsIgnoreCase("DELETE_ORG")) { |
| 633 | |
try { |
| 634 | 0 | clearPublisherAssertions(token.getAuthInfo(), ireg); |
| 635 | 0 | regobj = ireg.deleteBusiness(token.getAuthInfo(), (String[]) dataarray); |
| 636 | 0 | } catch (RegistryV3Exception rve) { |
| 637 | 0 | String username = getUsernameFromCredentials(connection.getCredentials()); |
| 638 | 0 | if (AuthTokenV3Singleton.getToken(username) != null) { |
| 639 | 0 | AuthTokenV3Singleton.deleteAuthToken(username); |
| 640 | |
} |
| 641 | 0 | token = getAuthToken(connection, ireg); |
| 642 | |
|
| 643 | 0 | regobj = ireg.deleteBusiness(token.getAuthInfo(), (String[]) dataarray); |
| 644 | 0 | } |
| 645 | |
} |
| 646 | 0 | else if (op.equalsIgnoreCase("DELETE_SERVICE")) { |
| 647 | |
try { |
| 648 | 0 | regobj = ireg.deleteService(token.getAuthInfo(), (String[]) dataarray); |
| 649 | 0 | } catch (RegistryV3Exception rve) { |
| 650 | 0 | String username = getUsernameFromCredentials(connection.getCredentials()); |
| 651 | 0 | if (AuthTokenV3Singleton.getToken(username) != null) { |
| 652 | 0 | AuthTokenV3Singleton.deleteAuthToken(username); |
| 653 | |
} |
| 654 | 0 | token = getAuthToken(connection, ireg); |
| 655 | |
|
| 656 | 0 | regobj = ireg.deleteService(token.getAuthInfo(), (String[]) dataarray); |
| 657 | 0 | } |
| 658 | |
} |
| 659 | 0 | else if (op.equalsIgnoreCase("DELETE_SERVICEBINDING")) { |
| 660 | |
try { |
| 661 | 0 | regobj = ireg.deleteBinding(token.getAuthInfo(), (String[]) dataarray); |
| 662 | 0 | } catch (RegistryV3Exception rve) { |
| 663 | 0 | String username = getUsernameFromCredentials(connection.getCredentials()); |
| 664 | 0 | if (AuthTokenV3Singleton.getToken(username) != null) { |
| 665 | 0 | AuthTokenV3Singleton.deleteAuthToken(username); |
| 666 | |
} |
| 667 | 0 | token = getAuthToken(connection, ireg); |
| 668 | |
|
| 669 | 0 | regobj = ireg.deleteBinding(token.getAuthInfo(), (String[]) dataarray); |
| 670 | 0 | } |
| 671 | |
} |
| 672 | 0 | else if (op.equalsIgnoreCase("DELETE_CONCEPT")) { |
| 673 | |
try { |
| 674 | 0 | regobj = ireg.deleteTModel(token.getAuthInfo(), (String[]) dataarray); |
| 675 | 0 | } catch (RegistryV3Exception rve) { |
| 676 | 0 | String username = getUsernameFromCredentials(connection.getCredentials()); |
| 677 | 0 | if (AuthTokenV3Singleton.getToken(username) != null) { |
| 678 | 0 | AuthTokenV3Singleton.deleteAuthToken(username); |
| 679 | |
} |
| 680 | 0 | token = getAuthToken(connection, ireg); |
| 681 | |
|
| 682 | 0 | regobj = ireg.deleteTModel(token.getAuthInfo(), (String[]) dataarray); |
| 683 | 0 | } |
| 684 | |
} |
| 685 | 0 | else if (op.equalsIgnoreCase("DELETE_ASSOCIATION")) { |
| 686 | 0 | int len = ((String[]) dataarray).length; |
| 687 | 0 | PublisherAssertion[] paarr = new PublisherAssertion[len]; |
| 688 | 0 | for(int i=0;i<len;i++) |
| 689 | |
{ |
| 690 | 0 | String keystr = ((String[])dataarray)[i]; |
| 691 | 0 | paarr[i] = ScoutJaxrUddiV3Helper.getPubAssertionFromJAXRAssociationKey(keystr); |
| 692 | |
} |
| 693 | |
try { |
| 694 | 0 | regobj = ireg.deletePublisherAssertions(token.getAuthInfo(), paarr); |
| 695 | 0 | } catch (RegistryV3Exception rve) { |
| 696 | 0 | String username = getUsernameFromCredentials(connection.getCredentials()); |
| 697 | 0 | if (AuthTokenV3Singleton.getToken(username) != null) { |
| 698 | 0 | AuthTokenV3Singleton.deleteAuthToken(username); |
| 699 | |
} |
| 700 | 0 | token = getAuthToken(connection, ireg); |
| 701 | |
|
| 702 | 0 | regobj = ireg.deletePublisherAssertions(token.getAuthInfo(), paarr); |
| 703 | 0 | } |
| 704 | 0 | } |
| 705 | 0 | else if (op.equalsIgnoreCase("DELETE_CLASSIFICATIONSCHEME")) { |
| 706 | |
try { |
| 707 | 0 | regobj = ireg.deleteTModel(token.getAuthInfo(), (String[]) dataarray); |
| 708 | 0 | } catch (RegistryV3Exception rve) { |
| 709 | 0 | String username = getUsernameFromCredentials(connection.getCredentials()); |
| 710 | 0 | if (AuthTokenV3Singleton.getToken(username) != null) { |
| 711 | 0 | AuthTokenV3Singleton.deleteAuthToken(username); |
| 712 | |
} |
| 713 | 0 | token = getAuthToken(connection, ireg); |
| 714 | |
|
| 715 | 0 | regobj = ireg.deleteTModel(token.getAuthInfo(), (String[]) dataarray); |
| 716 | 0 | } |
| 717 | |
} |
| 718 | |
else { |
| 719 | 0 | throw new JAXRException("Unsupported operation:" + op); |
| 720 | |
} |
| 721 | |
|
| 722 | 0 | return regobj; |
| 723 | |
} |
| 724 | |
|
| 725 | |
private void clearPublisherAssertions( String authinfo,IRegistryV3 ireg) |
| 726 | |
{ |
| 727 | 0 | Vector<PublisherAssertion> pasvect = null; |
| 728 | 0 | PublisherAssertion[] pasarr = null; |
| 729 | |
try |
| 730 | |
{ |
| 731 | 0 | AssertionStatusReport report = ireg.getAssertionStatusReport(authinfo,"status:complete"); |
| 732 | 0 | List<AssertionStatusItem> assertionStatusItemList = report.getAssertionStatusItem(); |
| 733 | 0 | AssertionStatusItem[] assertionStatusItemArr = |
| 734 | 0 | new AssertionStatusItem[assertionStatusItemList.size()]; |
| 735 | |
|
| 736 | 0 | int len = assertionStatusItemArr != null? assertionStatusItemArr.length : 0; |
| 737 | 0 | for (int i = 0; i < len; i++) |
| 738 | |
{ |
| 739 | 0 | AssertionStatusItem asi = assertionStatusItemArr[i]; |
| 740 | |
|
| 741 | |
|
| 742 | |
|
| 743 | |
|
| 744 | |
|
| 745 | |
|
| 746 | |
|
| 747 | |
|
| 748 | |
|
| 749 | |
|
| 750 | |
|
| 751 | |
|
| 752 | 0 | if(pasvect == null) pasvect = new Vector<PublisherAssertion>(len); |
| 753 | 0 | pasvect.add(this.getPublisherAssertion(asi)); |
| 754 | |
} |
| 755 | 0 | report = ireg.getAssertionStatusReport(authinfo,"status:toKey_incomplete"); |
| 756 | 0 | assertionStatusItemArr = report.getAssertionStatusItem().toArray(assertionStatusItemArr); |
| 757 | |
|
| 758 | 0 | len = assertionStatusItemArr != null? assertionStatusItemArr.length : 0; |
| 759 | 0 | for (int i = 0; i < len; i++) |
| 760 | |
{ |
| 761 | 0 | AssertionStatusItem asi = (AssertionStatusItem) assertionStatusItemArr[i]; |
| 762 | 0 | if(pasvect == null) pasvect = new Vector<PublisherAssertion>(len); |
| 763 | 0 | pasvect.add(this.getPublisherAssertion(asi)); |
| 764 | |
} |
| 765 | |
|
| 766 | 0 | report = ireg.getAssertionStatusReport(authinfo,"status:fromKey_incomplete"); |
| 767 | 0 | assertionStatusItemArr = report.getAssertionStatusItem().toArray(assertionStatusItemArr); |
| 768 | |
|
| 769 | 0 | len = assertionStatusItemArr != null? assertionStatusItemArr.length : 0; |
| 770 | 0 | for (int i = 0; i < len; i++) |
| 771 | |
{ |
| 772 | 0 | AssertionStatusItem asi = (AssertionStatusItem) assertionStatusItemArr[i]; |
| 773 | 0 | if(pasvect == null) pasvect = new Vector<PublisherAssertion>(len); |
| 774 | 0 | pasvect.add(this.getPublisherAssertion(asi)); |
| 775 | |
} |
| 776 | |
|
| 777 | 0 | if (pasvect != null) { |
| 778 | 0 | pasarr = new PublisherAssertion[pasvect.size()]; |
| 779 | 0 | Iterator iter = pasvect.iterator(); |
| 780 | 0 | int pasarrPos = 0; |
| 781 | 0 | while (iter.hasNext()) { |
| 782 | 0 | pasarr[pasarrPos] = ((PublisherAssertion) iter.next()); |
| 783 | 0 | pasarrPos++; |
| 784 | |
} |
| 785 | |
} |
| 786 | |
} |
| 787 | 0 | catch (RegistryV3Exception e) |
| 788 | |
{ |
| 789 | 0 | throw new RuntimeException(e); |
| 790 | 0 | } |
| 791 | |
|
| 792 | 0 | if(pasarr != null && pasarr.length > 0) |
| 793 | |
try |
| 794 | |
{ |
| 795 | 0 | ireg.deletePublisherAssertions(authinfo, pasarr); |
| 796 | |
} |
| 797 | 0 | catch (RegistryV3Exception e) |
| 798 | |
{ |
| 799 | 0 | log.debug("Ignoring exception " + e.getMessage(),e); |
| 800 | 0 | } |
| 801 | 0 | } |
| 802 | |
|
| 803 | |
|
| 804 | |
|
| 805 | |
protected BulkResponse deleteOperation(Collection<Key> keys, String op) |
| 806 | |
throws JAXRException { |
| 807 | 0 | if(keys == null) |
| 808 | 0 | throw new JAXRException("Keys provided to "+op+" are null"); |
| 809 | |
|
| 810 | |
|
| 811 | 0 | BulkResponseImpl bulk = new BulkResponseImpl(); |
| 812 | 0 | String[] keyarr = new String[keys.size()]; |
| 813 | |
Result[] keyResultArr; |
| 814 | |
|
| 815 | 0 | LinkedHashSet<Key> coll = new LinkedHashSet<Key>(); |
| 816 | 0 | Collection<Exception> exceptions = new ArrayList<Exception>(); |
| 817 | |
|
| 818 | |
try { |
| 819 | 0 | Iterator iter = keys.iterator(); |
| 820 | 0 | int currLoc = 0; |
| 821 | 0 | while (iter.hasNext()) { |
| 822 | 0 | Key key = (Key) iter.next(); |
| 823 | 0 | keyarr[currLoc] = key.getId(); |
| 824 | 0 | currLoc++; |
| 825 | 0 | } |
| 826 | |
|
| 827 | 0 | DispositionReport bd = (DispositionReport) executeOperation(keyarr, op); |
| 828 | 0 | List<Result> resultList = bd.getResult(); |
| 829 | 0 | keyResultArr = new Result[resultList.size()]; |
| 830 | 0 | resultList.toArray(keyResultArr); |
| 831 | |
|
| 832 | 0 | log.debug("After deleting Business. Obtained vector size:" + ((keyResultArr != null) ? keyResultArr.length : 0)); |
| 833 | 0 | for (int i = 0; keyResultArr != null && i < keyResultArr.length; i++) { |
| 834 | 0 | Result result = (Result) keyResultArr[i]; |
| 835 | 0 | int errno = result.getErrno(); |
| 836 | 0 | if (errno == 0) { |
| 837 | 0 | coll.addAll(keys); |
| 838 | |
} |
| 839 | |
else { |
| 840 | 0 | ErrInfo errinfo = result.getErrInfo(); |
| 841 | 0 | DeleteException de = new DeleteException(errinfo.getErrCode() + ":" + errinfo.getValue()); |
| 842 | 0 | bulk.setStatus(JAXRResponse.STATUS_FAILURE); |
| 843 | 0 | exceptions.add(de); |
| 844 | |
} |
| 845 | |
} |
| 846 | |
} |
| 847 | 0 | catch (RegistryV3Exception regExcept) { |
| 848 | |
|
| 849 | |
|
| 850 | |
|
| 851 | |
|
| 852 | |
|
| 853 | |
|
| 854 | 0 | DeleteException de = new DeleteException(regExcept.getFaultCode() |
| 855 | 0 | + ":" + regExcept.getFaultString(), regExcept); |
| 856 | |
|
| 857 | 0 | bulk.setStatus(JAXRResponse.STATUS_FAILURE); |
| 858 | 0 | exceptions.add(de); |
| 859 | |
} |
| 860 | 0 | catch (JAXRException tran) { |
| 861 | 0 | exceptions.add(new JAXRException("Apache JAXR Impl:", tran)); |
| 862 | 0 | bulk.setStatus(JAXRResponse.STATUS_FAILURE); |
| 863 | 0 | } |
| 864 | |
|
| 865 | 0 | bulk.setCollection(coll); |
| 866 | 0 | bulk.setExceptions(exceptions); |
| 867 | |
|
| 868 | 0 | return bulk; |
| 869 | |
} |
| 870 | |
|
| 871 | |
private String getUsernameFromCredentials(Set credentials) { |
| 872 | 0 | String username = "", pwd = ""; |
| 873 | |
|
| 874 | 0 | if (credentials != null) { |
| 875 | 0 | Iterator it = credentials.iterator(); |
| 876 | 0 | while (it.hasNext()) { |
| 877 | 0 | PasswordAuthentication pass = (PasswordAuthentication) it.next(); |
| 878 | 0 | username = pass.getUserName(); |
| 879 | 0 | } |
| 880 | |
} |
| 881 | 0 | return username; |
| 882 | |
} |
| 883 | |
|
| 884 | |
|
| 885 | |
|
| 886 | |
|
| 887 | |
|
| 888 | |
|
| 889 | |
|
| 890 | |
|
| 891 | |
|
| 892 | |
private AuthToken getAuthToken(ConnectionImpl connection, IRegistryV3 ireg) |
| 893 | |
throws JAXRException { |
| 894 | |
|
| 895 | 0 | Set creds = connection.getCredentials(); |
| 896 | 0 | String username = "", pwd = ""; |
| 897 | |
|
| 898 | 0 | if (creds != null) { |
| 899 | 0 | Iterator it = creds.iterator(); |
| 900 | 0 | while (it.hasNext()) { |
| 901 | 0 | PasswordAuthentication pass = (PasswordAuthentication) it.next(); |
| 902 | 0 | username = pass.getUserName(); |
| 903 | 0 | pwd = new String(pass.getPassword()); |
| 904 | 0 | } |
| 905 | |
} |
| 906 | |
|
| 907 | 0 | if (AuthTokenV3Singleton.getToken(username) != null) { |
| 908 | 0 | return (AuthToken) AuthTokenV3Singleton.getToken(username); |
| 909 | |
} |
| 910 | |
|
| 911 | |
|
| 912 | 0 | AuthToken token = null; |
| 913 | |
try { |
| 914 | 0 | token = ireg.getAuthToken(username, pwd); |
| 915 | |
} |
| 916 | 0 | catch (Exception e) |
| 917 | |
{ |
| 918 | 0 | throw new JAXRException(e); |
| 919 | 0 | } |
| 920 | 0 | AuthTokenV3Singleton.addAuthToken(username, token); |
| 921 | 0 | return token; |
| 922 | |
} |
| 923 | |
|
| 924 | |
private PublisherAssertion getPublisherAssertion(AssertionStatusItem asi) |
| 925 | |
{ |
| 926 | 0 | PublisherAssertion pa = this.objectFactory.createPublisherAssertion(); |
| 927 | |
|
| 928 | 0 | if(asi != null) |
| 929 | |
{ |
| 930 | 0 | String sourceKey = asi.getFromKey(); |
| 931 | 0 | String targetKey = asi.getToKey(); |
| 932 | |
|
| 933 | 0 | if (sourceKey != null) { |
| 934 | 0 | pa.setFromKey(sourceKey); |
| 935 | |
} |
| 936 | |
|
| 937 | 0 | if (targetKey != null) { |
| 938 | 0 | pa.setToKey(targetKey); |
| 939 | |
} |
| 940 | |
|
| 941 | 0 | KeyedReference keyr = asi.getKeyedReference(); |
| 942 | |
|
| 943 | 0 | if (keyr != null) { |
| 944 | 0 | pa.setKeyedReference(keyr); |
| 945 | |
} |
| 946 | |
|
| 947 | |
|
| 948 | |
|
| 949 | |
|
| 950 | 0 | }return pa; |
| 951 | |
} |
| 952 | |
|
| 953 | |
Organization createOrganization(BusinessDetail bizDetail) throws JAXRException { |
| 954 | 0 | return ScoutUddiV3JaxrHelper.getOrganization(bizDetail, this); |
| 955 | |
} |
| 956 | |
|
| 957 | |
Organization createOrganization(BusinessInfo bizInfo) throws JAXRException { |
| 958 | 0 | String key = bizInfo.getBusinessKey(); |
| 959 | 0 | List<Name> names = bizInfo.getName(); |
| 960 | |
|
| 961 | 0 | List<Description> descriptions = bizInfo.getDescription(); |
| 962 | 0 | List<ServiceInfo> serviceInfos = bizInfo.getServiceInfos().getServiceInfo(); |
| 963 | |
|
| 964 | 0 | OrganizationImpl org = new OrganizationImpl(this); |
| 965 | 0 | org.setKey(createKey(key)); |
| 966 | 0 | if (names != null && names.size() > 0) { |
| 967 | 0 | org.setName(createInternationalString(names.get(0).getValue())); |
| 968 | |
} |
| 969 | 0 | if (descriptions != null && descriptions.size() > 0) { |
| 970 | 0 | org.setDescription(createInternationalString(descriptions.get(0).getValue())); |
| 971 | |
} |
| 972 | 0 | if (serviceInfos != null && serviceInfos.size() > 0) { |
| 973 | 0 | List<Service> services = new ArrayList<Service>(serviceInfos.size()); |
| 974 | 0 | for (int i = 0; i < serviceInfos.size(); i++) { |
| 975 | 0 | ServiceInfo serviceInfo = serviceInfos.get(i); |
| 976 | 0 | services.add(createService(serviceInfo)); |
| 977 | |
} |
| 978 | 0 | org.addServices(services); |
| 979 | |
} |
| 980 | |
|
| 981 | 0 | return org; |
| 982 | |
} |
| 983 | |
|
| 984 | |
Service createService(ServiceInfo serviceInfo) throws JAXRException { |
| 985 | 0 | String key = serviceInfo.getServiceKey(); |
| 986 | 0 | List<Name> names = serviceInfo.getName(); |
| 987 | 0 | ServiceImpl service = new ServiceImpl(this); |
| 988 | 0 | service.setKey(createKey(key)); |
| 989 | 0 | if (names != null && names.size() > 0) { |
| 990 | 0 | service.setName(createInternationalString(names.get(0).getValue())); |
| 991 | |
} |
| 992 | 0 | return service; |
| 993 | |
} |
| 994 | |
|
| 995 | |
} |