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