View Javadoc
1 /* 2 * $Header: /cvsroot/ebxmlrr/jaxr/src/com/sun/xml/registry/ebxml/LifeCycleManagerImpl.java,v 1.53 2003/08/21 23:15:36 farrukh_najmi Exp $ 3 * 4 * 5 */ 6 7 package com.sun.xml.registry.ebxml; 8 9 import java.util.*; 10 import java.io.*; 11 import java.lang.reflect.*; 12 import javax.activation.*; 13 import javax.xml.registry.*; 14 import javax.xml.registry.infomodel.*; 15 16 import com.sun.xml.registry.ebxml.RegistryServiceImpl; 17 import com.sun.xml.registry.ebxml.infomodel.*; 18 import com.sun.xml.registry.ebxml.util.*; 19 20 import org.oasis.ebxml.registry.bindings.rim.LeafRegistryObjectList; 21 import org.oasis.ebxml.registry.bindings.rim.LeafRegistryObjectListTypeItem; 22 import org.oasis.ebxml.registry.bindings.rim.ObjectRef; 23 import org.oasis.ebxml.registry.bindings.rim.ObjectRefList; 24 import org.oasis.ebxml.registry.bindings.rim.ObjectRefListItem; 25 import org.oasis.ebxml.registry.bindings.rs.DeprecateObjectsRequest; 26 import org.oasis.ebxml.registry.bindings.rs.RemoveObjectsRequest; 27 import org.oasis.ebxml.registry.bindings.rs.SubmitObjectsRequest; 28 import org.oasis.ebxml.registry.bindings.rs.UpdateObjectsRequest; 29 30 import com.sun.ebxml.registry.util.BindingUtility; 31 import com.sun.ebxml.registry.RegistryException; 32 33 import org.apache.commons.logging.Log; 34 35 /*** 36 * Class Declaration for Class1 37 * 38 */ 39 public abstract class LifeCycleManagerImpl implements LifeCycleManager { 40 41 RegistryServiceImpl regService = null; 42 HashSet modifiedObjects = null; 43 private HashMap objectTypesMap = null; 44 private Log log; 45 46 47 LifeCycleManagerImpl(RegistryServiceImpl regService) { 48 this.regService = regService; 49 modifiedObjects = new HashSet(); 50 51 log = regService.getConnection().getConnectionFactory().getLog(); 52 } 53 54 /*** 55 * Creates instances of information model 56 * interfaces (factory method). To create an Organization, use this 57 * method as follows: 58 * <pre> 59 * Organization org = (Organization) 60 * lifeCycleMgr.createObject(LifeCycleManager.ORGANIZATION); 61 * </pre> 62 * <p><DL><DT><B>Capability Level: 0 </B></DL> 63 * 64 * @param interfaceName the unqualified name of an interface in the 65 * javax.xml.registry.infomodel package 66 * 67 * @return an Object that can then be cast to an instance of the interface 68 * 69 * @throws JAXRException if the JAXR provider encounters an internal error 70 * 71 * @throws InvalidRequestException if the interface is not an interface in 72 * the javax.xml.registry.infomodel package 73 * 74 * @throws UnsupportedCapabilityException if the client attempts to 75 * create an instance of an infomodel interface that is not supported 76 * by the capability level of the JAXR provider 77 */ 78 public Object createObject(String className) 79 throws JAXRException, InvalidRequestException, 80 UnsupportedCapabilityException 81 { 82 Object obj = null; 83 84 try { 85 className = "com.sun.xml.registry.ebxml.infomodel." + regService.mapEbXMLNameToJAXRName(className) + "Impl"; 86 87 Class cls = this.getClass().getClassLoader().loadClass(className); 88 Class lcmCls = this.getClass().getClassLoader().loadClass("com.sun.xml.registry.ebxml.LifeCycleManagerImpl"); 89 Class[] parmTypes = { 90 lcmCls 91 }; 92 Constructor cons = cls.getDeclaredConstructor(parmTypes); 93 94 Object[] args = { 95 this 96 }; 97 obj = cons.newInstance(args); 98 } 99 catch (ClassNotFoundException e) { 100 throw new InvalidRequestException("Invalid className '" + className + "' argument."); 101 } 102 catch (NoSuchMethodException e) { 103 throw new JAXRException(e); 104 } 105 catch (InvocationTargetException e) { 106 throw new JAXRException(e.getCause()); 107 } 108 catch (IllegalAccessException e) { 109 throw new JAXRException(e); 110 } 111 catch (InstantiationException e) { 112 throw new JAXRException(e); 113 } 114 catch (ExceptionInInitializerError e) { 115 throw new JAXRException(e); 116 } 117 catch (SecurityException e) { 118 throw new JAXRException(e); 119 } 120 121 return obj; 122 } 123 124 /*** 125 * Create an Association instance using the specified 126 * parameters. The sourceObject is left null and will be set 127 * when the Association is added to a RegistryObject. 128 * <p> 129 * Note that for a UDDI provider an Association may only be created 130 * between Organizations. 131 * 132 * <p><DL><DT><B>Capability Level: 0 </B></DL> 133 * 134 */ 135 public Association createAssociation( 136 RegistryObject targetObject, 137 Concept associationType 138 ) throws JAXRException{ 139 140 AssociationImpl ass = new AssociationImpl(this); 141 ass.setTargetObject(targetObject); 142 ass.setAssociationType(associationType); 143 return ass; 144 } 145 146 /*** 147 * Create a Classification instance for an external 148 * Classification using the specified name and value that identifies 149 * a taxonomy element within specified ClassificationScheme. 150 * 151 * 152 * <p><DL><DT><B>Capability Level: 0 </B></DL> 153 * 154 */ 155 public Classification createClassification( 156 ClassificationScheme scheme, 157 String name, 158 String value 159 ) throws JAXRException{ 160 161 InternationalString is = createInternationalString(name); 162 Classification cl = createClassification(scheme, is, value); 163 164 return cl; 165 } 166 167 /*** 168 * Create a Classification instance for an external 169 * Classification using the specified name and value that identifies 170 * a taxonomy element within specified ClassificationScheme. 171 * 172 * 173 * <p><DL><DT><B>Capability Level: 0 </B></DL> 174 * 175 */ 176 public Classification createClassification( 177 ClassificationScheme scheme, 178 InternationalString name, 179 String value 180 ) throws JAXRException{ 181 182 ClassificationImpl cl = new ClassificationImpl(this); 183 cl.setClassificationScheme(scheme); 184 cl.setName(name); 185 cl.setValue(value); 186 return cl; 187 } 188 189 190 /*** 191 * Create a Classification instance for an internal 192 * Classification using the specified Concept which identifies 193 * a taxonomy element within an internal ClassificationScheme. 194 * <p> 195 * Throws InvalidRequestException if the Concept is not under 196 * a ClassificationScheme. 197 * 198 * <p><DL><DT><B>Capability Level: 0 </B></DL> 199 * 200 */ 201 public Classification createClassification( 202 Concept concept 203 ) throws JAXRException, InvalidRequestException{ 204 205 ClassificationImpl cl = new ClassificationImpl(this); 206 cl.setConcept(concept); 207 return cl; 208 } 209 210 /*** 211 * Create a scheme given specified parameters. 212 * This is the method to use to create a scheme 213 * in most situations. 214 * 215 * <p><DL><DT><B>Capability Level: 0 </B></DL> 216 * 217 */ 218 public ClassificationScheme createClassificationScheme( 219 String name, String description 220 ) throws JAXRException, InvalidRequestException{ 221 222 InternationalString isName = createInternationalString(name); 223 InternationalString isDesc = createInternationalString(description); 224 225 ClassificationScheme scheme = createClassificationScheme(isName, isDesc); 226 227 return scheme; 228 } 229 230 /*** 231 * Create a scheme given specified parameters. 232 * This is the method to use to create a scheme 233 * in most situations. 234 * 235 * <p><DL><DT><B>Capability Level: 0 </B></DL> 236 * 237 */ 238 public ClassificationScheme createClassificationScheme( 239 InternationalString name, InternationalString description 240 ) throws JAXRException, InvalidRequestException{ 241 242 243 ClassificationSchemeImpl scheme = new ClassificationSchemeImpl(this); 244 scheme.setName(name); 245 scheme.setDescription(description); 246 247 return scheme; 248 } 249 250 /*** 251 * Creates a ClassificationScheme from a Concept that has no 252 * ClassificationScheme or parent Concept. 253 * <p> 254 * This method is a special case method to do a type safe conversion 255 * from Concept to ClassificationScheme. 256 * <p> 257 * This method is 258 * provided to allow for Concepts returned by the BusinessQueryManager 259 * findConcepts call to be safely cast to ClassificationScheme. It 260 * is up to the programer to make sure that the Concept is indeed 261 * semantically a ClassificationScheme. 262 * <p> 263 * This method is necessary because in UDDI a tModel may serve 264 * multiple purposes and there is no way to know when a tModel 265 * maps to a Concept and when it maps to a ClassificationScheme. 266 * UDDI leaves the determination to the programmer and consequently so does this 267 * method. 268 * <p> 269 * Throws InvalidRequestException if the Concept has a parent Concept 270 * or is under a ClassificationScheme. 271 * 272 * <p><DL><DT><B>Capability Level: 0 </B></DL> 273 * 274 * 275 */ 276 public ClassificationScheme createClassificationScheme( 277 Concept concept 278 ) throws JAXRException, InvalidRequestException{ 279 280 ClassificationSchemeImpl scheme = new ClassificationSchemeImpl(this, concept); 281 return scheme; 282 } 283 284 /*** 285 * Create a Concept instance using the specified 286 * parameters. 287 * 288 * 289 * <p><DL><DT><B>Capability Level: 0 </B></DL> 290 * 291 * @param parent Is either a reference to a parent ClassificationScheme or Concept 292 */ 293 public Concept createConcept( 294 RegistryObject parent, 295 String name, 296 String value 297 ) throws JAXRException{ 298 299 InternationalString isName = createInternationalString(name); 300 return createConcept(parent, isName, value); 301 } 302 303 /*** 304 * Create a Concept instance using the specified 305 * parameters. 306 * 307 * 308 * <p><DL><DT><B>Capability Level: 0 </B></DL> 309 * 310 * @param parent Is either a reference to a parent ClassificationScheme or Concept 311 */ 312 public Concept createConcept( 313 RegistryObject parent, 314 InternationalString name, 315 String value 316 ) throws JAXRException{ 317 318 ConceptImpl concept = new ConceptImpl(this); 319 320 if (parent instanceof ClassificationScheme) { 321 concept.setClassificationScheme((ClassificationScheme)parent); 322 } 323 else if (parent instanceof Concept) { 324 concept.setParentConcept((Concept)parent); 325 } 326 concept.setName(name); 327 concept.setValue(value); 328 329 return concept; 330 } 331 332 /*** 333 * Creates an EmailAddress instance using an address as the 334 * parameter. 335 * 336 * <p><DL><DT><B>Capability Level: 0 </B></DL> 337 * 338 * @param address the email address 339 * 340 * @return the EmailAddress instance created 341 * 342 * @throws JAXRException if the JAXR provider encounters an internal error 343 */ 344 public EmailAddress createEmailAddress(String address) 345 throws JAXRException 346 { 347 EmailAddressImpl email = new EmailAddressImpl(this); 348 email.setAddress(address); 349 return email; 350 } 351 352 /*** 353 * Creates an EmailAddress instance using both an address and a type as 354 * parameters. 355 * 356 * 357 * <p><DL><DT><B>Capability Level: 0 </B></DL> 358 * 359 * @param address the email address 360 * @param type the type of the address 361 * 362 * @return the EmailAddress instance created 363 * 364 * @throws JAXRException if the JAXR provider encounters an internal error 365 */ 366 public EmailAddress createEmailAddress(String address, String type) 367 throws JAXRException 368 { 369 EmailAddressImpl email = new EmailAddressImpl(this); 370 email.setAddress(address); 371 email.setType(type); 372 return email; 373 } 374 375 /*** 376 * Create an ExternalIdentifier instance using the specified 377 * parameters. 378 * 379 * 380 * <p><DL><DT><B>Capability Level: 0 </B></DL> 381 * 382 */ 383 public ExternalIdentifier createExternalIdentifier( 384 ClassificationScheme scheme, 385 String name, 386 String value 387 ) throws JAXRException{ 388 389 390 InternationalString is = createInternationalString(name); 391 ExternalIdentifier extId = createExternalIdentifier(scheme, is, value); 392 393 return extId; 394 } 395 396 /*** 397 * Create an ExternalIdentifier instance using the specified 398 * parameters. 399 * 400 * 401 * <p><DL><DT><B>Capability Level: 0 </B></DL> 402 * 403 */ 404 public ExternalIdentifier createExternalIdentifier( 405 ClassificationScheme scheme, 406 InternationalString name, 407 String value 408 ) throws JAXRException{ 409 410 ExternalIdentifierImpl extId = new ExternalIdentifierImpl(this); 411 extId.setIdentificationScheme(scheme); 412 extId.setName(name); 413 extId.setValue(value); 414 return extId; 415 416 } 417 418 /*** 419 * Create an ExternalLink instance using the specified 420 * parameters. 421 * 422 * <p><DL><DT><B>Capability Level: 0 </B></DL> 423 * 424 * 425 */ 426 public ExternalLink createExternalLink( 427 String externalURI, 428 String description 429 ) throws JAXRException{ 430 431 InternationalString isDesc = createInternationalString(description); 432 ExternalLink link = createExternalLink(externalURI, isDesc); 433 return link; 434 } 435 436 /*** 437 * Create an ExternalLink instance using the specified 438 * parameters. 439 * 440 * <p><DL><DT><B>Capability Level: 0 </B></DL> 441 * 442 * 443 */ 444 public ExternalLink createExternalLink( 445 String externalURI, 446 InternationalString description 447 ) throws JAXRException{ 448 449 ExternalLink link = new ExternalLinkImpl(this); 450 link.setDescription(description); 451 link.setExternalURI(externalURI); 452 453 return link; 454 } 455 456 /*** 457 * Creates an ExtrinsicObject instance using the specified parameters. 458 * 459 * 460 * <p><DL><DT><B>Capability Level: 1 </B></DL> 461 * 462 * @param repositoryItem the DataHandler for the repository item. Must 463 * not be null. 464 * 465 * @return the ExtrinsicObject instance created 466 * 467 * @throws JAXRException if the JAXR provider encounters an internal error 468 * 469 */ 470 public ExtrinsicObject createExtrinsicObject(javax.activation.DataHandler 471 repositoryItem) 472 throws javax.xml.registry.JAXRException 473 { 474 ExtrinsicObject eo = new ExtrinsicObjectImpl(this); 475 if (repositoryItem != null) { 476 eo.setRepositoryItem(repositoryItem); 477 } 478 return eo; 479 } 480 481 /*** 482 * Creates an ExtrinsicObject instance using the specified parameters. 483 * JAXR 2.0?? 484 * 485 * <p><DL><DT><B>Capability Level: 1 </B></DL> 486 * 487 * 488 * @return the ExtrinsicObject instance created 489 * 490 * @throws JAXRException if the JAXR provider encounters an internal error 491 * 492 */ 493 public ExtrinsicObject createExtrinsicObject() 494 throws javax.xml.registry.JAXRException 495 { 496 return createExtrinsicObject(null); 497 } 498 499 /*** 500 * Create a InternationalString instance using the specified 501 * parameters. 502 * 503 * 504 * <p><DL><DT><B>Capability Level: 0 </B></DL> 505 * 506 */ 507 public javax.xml.registry.infomodel.InternationalString createInternationalString() throws javax.xml.registry.JAXRException{ 508 509 return createInternationalString(Locale.getDefault(), ""); 510 } 511 512 /*** 513 * Create a InternationalString instance using the specified 514 * parameters and the default Locale. 515 * 516 * 517 * <p><DL><DT><B>Capability Level: 0 </B></DL> 518 * 519 */ 520 public InternationalString createInternationalString( 521 String s 522 ) throws JAXRException{ 523 524 return createInternationalString(Locale.getDefault(), s); 525 } 526 527 /*** 528 * Create a InternationalString instance using the specified 529 * parameters. 530 * 531 * 532 * <p><DL><DT><B>Capability Level: 0 </B></DL> 533 * 534 */ 535 public InternationalString createInternationalString( 536 Locale l, 537 String s 538 ) throws JAXRException{ 539 540 LocalizedString ls = new LocalizedStringImpl(this); 541 ls.setLocale(l); 542 ls.setValue(s); 543 544 InternationalString is = new InternationalStringImpl(this); 545 is.addLocalizedString(ls); 546 return is; 547 } 548 549 /*** 550 * Creates a Key instance from an ID. 551 * 552 * <p><DL><DT><B>Capability Level: 0 </B></DL> 553 * 554 * @param id the ID string from which to create the Key 555 * 556 * @return the Key instance created 557 * 558 * @throws JAXRException if the JAXR provider encounters an internal error 559 */ 560 public Key createKey(String id) throws JAXRException { 561 KeyImpl key = new KeyImpl(this); 562 key.setId(id); 563 return key; 564 } 565 566 //??Add to level 1 API for JAXR 2.0 567 public Key createKey() throws JAXRException { 568 String id = createId(); 569 return createKey(id); 570 } 571 572 //??Add to level 1 API for JAXR 2.0 573 public String createId() throws JAXRException { 574 String id = "urn:uuid:" 575 + UUIDFactory.getInstance().newUUID().toString(); 576 return id; 577 } 578 579 /*** 580 * Creates a LocalizedString instance using the specified Locale and 581 * String parameters. 582 * 583 * <p><DL><DT><B>Capability Level: 0 </B></DL> 584 * 585 * @param l the Locale in which to create the LocalizedString 586 * @param s the String from which to create the LocalizedString 587 * 588 * @return the LocalizedString instance created 589 * 590 * @throws JAXRException if the JAXR provider encounters an internal error 591 */ 592 public LocalizedString createLocalizedString(Locale l, String s) 593 throws JAXRException 594 { 595 LocalizedStringImpl lString = new LocalizedStringImpl(this); 596 lString.setLocale(l); 597 lString.setValue(s); 598 return lString; 599 } 600 601 /*** 602 * Creates a LocalizedString instance using the specified 603 * Locale, String, and character set parameters. 604 * 605 * 606 * <p><DL><DT><B>Capability Level: 0 </B></DL> 607 * 608 * @param l the Locale in which to create the LocalizedString 609 * @param s the String from which to create the LocalizedString 610 * @param charSetName the name of the character set to use 611 * 612 * @return the LocalizedString instance created 613 * 614 * @throws JAXRException if the JAXR provider encounters an internal error 615 */ 616 public LocalizedString createLocalizedString(Locale l, String s, 617 String charSetName) 618 throws JAXRException 619 { 620 LocalizedString lString = createLocalizedString(l, s); 621 lString.setCharsetName(charSetName); 622 return lString; 623 } 624 625 /*** 626 * Create an Organization instance using the specified 627 * parameters. 628 * 629 * 630 * <p><DL><DT><B>Capability Level: 0 </B></DL> 631 * 632 */ 633 public Organization createOrganization( 634 String name 635 ) throws JAXRException{ 636 637 InternationalString is = createInternationalString(name); 638 Organization org = createOrganization(is); 639 640 return org; 641 } 642 643 /*** 644 * Create an Organization instance using the specified 645 * parameters. 646 * 647 * 648 * <p><DL><DT><B>Capability Level: 0 </B></DL> 649 * 650 */ 651 public Organization createOrganization( 652 InternationalString name 653 ) throws JAXRException{ 654 655 Organization org = new OrganizationImpl(this); 656 org.setName(name); 657 658 return org; 659 } 660 661 /*** 662 * Create a PersonName instance using the specified 663 * parameters. 664 * 665 * 666 * <p><DL><DT><B>Capability Level: 1 </B></DL> 667 * 668 */ 669 public PersonName createPersonName( 670 String firstName, 671 String middleName, 672 String lastName 673 ) throws JAXRException{ 674 675 PersonNameImpl personName = new PersonNameImpl(this); 676 personName.setFirstName(firstName); 677 personName.setMiddleName(middleName); 678 personName.setLastName(lastName); 679 680 return personName; 681 } 682 683 /*** 684 * Create a PersonName instance using the specified 685 * parameters. 686 * 687 * 688 * <p><DL><DT><B>Capability Level: 0 </B></DL> 689 * 690 */ 691 public PersonName createPersonName( 692 String fullName 693 ) throws JAXRException{ 694 PersonNameImpl personName = new PersonNameImpl(this); 695 personName.setFullName(fullName); 696 697 return personName; 698 } 699 700 /*** 701 * Create a PostalAddress instance using the specified 702 * parameters. 703 * 704 * 705 * <p><DL><DT><B>Capability Level: 0 </B></DL> 706 * 707 */ 708 public PostalAddress createPostalAddress( 709 String streetNumber, 710 String street, 711 String city, 712 String stateOrProvince, 713 String country, 714 String postalCode, 715 String type 716 ) throws JAXRException{ 717 718 PostalAddress addr = new PostalAddressImpl(this); 719 addr.setStreetNumber(streetNumber); 720 addr.setStreet(street); 721 addr.setCity(city); 722 addr.setStateOrProvince(stateOrProvince); 723 addr.setCountry(country); 724 addr.setPostalCode(postalCode); 725 addr.setType(type); 726 727 return addr; 728 } 729 730 /*** 731 * Create a RegistryPackage instance using the specified 732 * parameters. 733 * 734 * 735 * <p><DL><DT><B>Capability Level: 1 </B></DL> 736 * 737 */ 738 public RegistryPackage createRegistryPackage( 739 String name 740 ) throws JAXRException{ 741 InternationalString is = createInternationalString(name); 742 return createRegistryPackage(is); 743 } 744 745 /*** 746 * Create a RegistryPackage instance using the specified 747 * parameters. 748 * 749 * 750 * <p><DL><DT><B>Capability Level: 1 </B></DL> 751 * 752 */ 753 public RegistryPackage createRegistryPackage( 754 InternationalString name 755 ) throws JAXRException{ 756 RegistryPackageImpl pkg = new RegistryPackageImpl(this); 757 pkg.setName(name); 758 return pkg; 759 } 760 761 /*** 762 * Create an Service instance using the specified 763 * parameters. 764 * 765 * 766 * <p><DL><DT><B>Capability Level: 0 </B></DL> 767 * 768 */ 769 public Service createService( 770 String name 771 ) throws JAXRException{ 772 773 InternationalString is = createInternationalString(name); 774 775 return createService(is); 776 } 777 778 /*** 779 * Create an Service instance using the specified 780 * parameters. 781 * 782 * 783 * <p><DL><DT><B>Capability Level: 0 </B></DL> 784 * 785 */ 786 public Service createService( 787 InternationalString name 788 ) throws JAXRException{ 789 790 Service service = new ServiceImpl(this); 791 service.setName(name); 792 793 return service; 794 } 795 796 /*** 797 * Create an ServiceBinding instance using the specified 798 * parameters. 799 * 800 * 801 * <p><DL><DT><B>Capability Level: 0 </B></DL> 802 * 803 */ 804 public javax.xml.registry.infomodel.ServiceBinding createServiceBinding() throws javax.xml.registry.JAXRException{ 805 806 ServiceBinding serviceBinding = new ServiceBindingImpl(this); 807 return serviceBinding; 808 } 809 810 /*** 811 * Creates a Slot instance using the specified 812 * parameters, where the value is a String. 813 * 814 * 815 * <p><DL><DT><B>Capability Level: 0 </B></DL> 816 * 817 * @param name the name of the Slot 818 * @param value the value (a String) 819 * @param slotType the slot type 820 * 821 * @return the Slot instance created 822 * 823 * @throws JAXRException if the JAXR provider encounters an internal error 824 */ 825 public Slot createSlot(String name, String value, String slotType) 826 throws JAXRException 827 { 828 ArrayList al = new ArrayList(); 829 al.add(value); 830 return createSlot(name, al, slotType); 831 } 832 833 /*** 834 * Creates a Slot instance using the specified 835 * parameters, where the value is a Collection of Strings. 836 * 837 * <p><DL><DT><B>Capability Level: 0 </B></DL> 838 * 839 * @param name the name of the Slot 840 * @param value the value (a Collection of Strings) 841 * @param slotType the slot type 842 * 843 * @return the Slot instance created 844 * 845 * @throws JAXRException if the JAXR provider encounters an internal error 846 */ 847 public Slot createSlot(String name, Collection values, String slotType) 848 throws JAXRException 849 { 850 SlotImpl slot = new SlotImpl(this); 851 slot.setName(name); 852 slot.setValues(values); 853 slot.setSlotType(slotType); 854 return slot; 855 } 856 857 /*** 858 * Creates an empty SpecificationLink instance. 859 * 860 * <p><DL><DT><B>Capability Level: 0 </B></DL> 861 * 862 * @return the SpecificationLink instance created 863 * 864 * @throws JAXRException if the JAXR provider encounters an internal error 865 */ 866 public SpecificationLink createSpecificationLink() 867 throws JAXRException 868 { 869 SpecificationLinkImpl specLink = new SpecificationLinkImpl(this); 870 return specLink; 871 } 872 873 /*** 874 * Create a TelephoneNumber instance using the specified 875 * parameters. 876 * 877 * 878 * <p><DL><DT><B>Capability Level: 0 </B></DL> 879 * 880 */ 881 public javax.xml.registry.infomodel.TelephoneNumber createTelephoneNumber() throws javax.xml.registry.JAXRException{ 882 883 TelephoneNumber ph = new TelephoneNumberImpl(this); 884 return ph; 885 } 886 887 /*** 888 * Create a User instance using the specified 889 * parameters. 890 * 891 * 892 * <p><DL><DT><B>Capability Level: 0 </B></DL> 893 * 894 */ 895 public javax.xml.registry.infomodel.User createUser() throws javax.xml.registry.JAXRException{ 896 UserImpl user = new UserImpl(this); 897 898 return user; 899 } 900 901 //??Add to JAXRAPI 2.0 902 public BulkResponse saveAllObjects() throws JAXRException { 903 HashSet _modifiedObjects = null; 904 synchronized(modifiedObjects) { 905 _modifiedObjects = (HashSet)(modifiedObjects.clone()); 906 } 907 908 return saveObjects(_modifiedObjects); 909 } 910 911 /*** 912 * Add an object to list set of modified objects 913 */ 914 public void addModifiedObject(RegistryObject ro) { 915 synchronized(modifiedObjects) { 916 modifiedObjects.add(ro); 917 } 918 } 919 920 /*** 921 * Remove an object from list set of modified objects 922 */ 923 public void removeModifiedObject(RegistryObject ro) { 924 synchronized(modifiedObjects) { 925 modifiedObjects.remove(ro); 926 } 927 } 928 929 930 /*** 931 * Saves one or more Objects to the registry. An object may be a 932 * RegistryObject sub-class or a CataloguedObject. If an object is not 933 * in the registry, then it is created in the registry. If it already 934 * exists in the registry and has been modified, then its state is 935 * updated (replaced) in the registry. 936 * 937 * <p><DL><DT><B>Capability Level: 0 </B></DL> 938 * 939 * @return BulkResponse containing the Collection of keys for those 940 * objects that were saved successfully and any SaveException that was 941 * encountered in case of partial commit. 942 */ 943 public BulkResponse saveObjects(Collection objects) throws JAXRException 944 { 945 if (objects == null || objects.size() == 0) { 946 return new BulkResponseImpl(); 947 } 948 949 HashSet submitObjects = new HashSet(); 950 HashSet processedObjects = new HashSet(); 951 HashSet composedObjects = new HashSet(); 952 String pad = ""; 953 954 for (Iterator it = objects.iterator(); it.hasNext(); ) { 955 Object obj = it.next(); 956 processObject(obj, submitObjects, processedObjects, composedObjects, pad); 957 } 958 959 log.debug("submitObjects = " + submitObjects); 960 log.debug("processedObjects = " + processedObjects); 961 962 // Return value for this method 963 BulkResponse response = null; 964 965 // Send SubmitObjectsRequest for new objects 966 HashMap attachMap = new HashMap(); 967 LeafRegistryObjectList list = 968 makeLeafRegistryObjectList(submitObjects, processedObjects, composedObjects, attachMap); 969 970 if (list != null) { 971 response = doSubmitObjectsRequest(list, attachMap); 972 if (response.getStatus() == BulkResponse.STATUS_SUCCESS) { 973 // ROs are no longer new 974 markRegistryObjectsClean(submitObjects); 975 } 976 } 977 978 return response; 979 } 980 981 /*** 982 * Process an Object that may be a RegistryObject, RegistryObjectRef or something else (e.g. Slot). 983 * 984 * Rules: 985 * -Do nothing for objects that are niether RegistryObjectImpl nor RegistryObjectRef (e.g. Slots) 986 * -Don't process the same object more than once 987 */ 988 public void processObject(Object obj, HashSet submitObjects, HashSet processedObjects, HashSet composedObjects, String pad) throws JAXRException 989 { 990 log.debug(pad + "processObject entered: obj = " + obj); 991 992 //Rule: Do nothing for objects that are niether RegistryObjectImpl nor RegistryObjectRef (e.g. Slots) 993 if (!((obj instanceof RegistryObjectImpl) || (obj instanceof RegistryObjectRef))) { 994 log.debug(pad + "processObject: skipping obj = " + obj); 995 return; 996 } 997 998 //Rule: Don't process the same object more than once 999 if (processedObjects.contains(obj)) { 1000 log.debug(pad + "processObject: returning on already processed obj = " + obj); 1001 return; 1002 } 1003 else { 1004 log.debug(pad + "processObject: processedObject.add on obj = " + obj + " processedObjects.contains = " + processedObjects.contains(obj)); 1005 processedObjects.add(obj); 1006 } 1007 1008 if (obj instanceof RegistryObjectRef) { 1009 processRegistryObjectRef((RegistryObjectRef)obj, submitObjects, processedObjects, composedObjects, pad); 1010 } 1011 else if (obj instanceof RegistryObjectImpl) { 1012 processRegistryObject((RegistryObjectImpl)obj, submitObjects, processedObjects, composedObjects, pad); 1013 } 1014 1015 } 1016 1017 /*** 1018 * Process a RegistryObjectRef. 1019 * 1020 * Rules: 1021 * -Submit ObjectRef for references to clean objects 1022 * -Call processObject for references to dirty objects 1023 * 1024 * The ReferencedObject may be: 1025 * a) A new or modified object 1026 * b) An ObjectRef to an object in the registry 1027 */ 1028 public void processRegistryObjectRef(RegistryObjectRef ref, HashSet submitObjects, HashSet processedObjects, HashSet composedObjects, String pad) throws JAXRException 1029 { 1030 log.debug(pad + "processRegistryObjectRef entered: ref = " + ref); 1031 1032 //Get RegistryObject from the ref 1033 //Potential for optimization here?? 1034 RegistryObjectImpl ro = (RegistryObjectImpl)ref.getRegistryObject("RegistryObject"); 1035 log.debug(pad + "processRegistryObjectRef: ro = " + ro); 1036 1037 if (ro != null) { 1038 if (!(ro.isNew() || ro.isModified())) { 1039 //Rule: Submit ObjectRef for references to clean objects 1040 log.debug(pad + "processRegistryObjectRef: submitObject.add for clean ref = " + ro); 1041 submitObjects.add(ref); 1042 } 1043 else { 1044 //Rule: Call processRegistryObject for references to dirty objects 1045 //log.debug(pad + "processRegistryObjectRef: recursing for dirty ref = " + ro); 1046 processObject(ro, submitObjects, processedObjects, composedObjects, pad); 1047 } 1048 } 1049 } 1050 1051 /*** 1052 * Process a RegistryObject. 1053 * 1054 * Potential cases: 1055 * 1) Composed object is submitted as a composed object 1056 * 2) Composed object is submitted as a top level object 1057 * (e.g. create Classification, call setClassifiedObject on it and save it.) 1058 * 1059 */ 1060 public void processRegistryObject(RegistryObjectImpl ro, HashSet submitObjects, HashSet processedObjects, HashSet composedObjects, String pad) throws JAXRException 1061 { 1062 //log.debug(pad + "processRegistryObject entered: ro = " + ro); 1063 1064 log.debug(pad + "processRegistryObject: entered submitObject.add on ro = " + ro); 1065 submitObjects.add(ro); 1066 1067 //Get and process Associations and Association targets implicitly for RegistryObjects being saved 1068 //as required by JAXR 1.0 specification. 1069 HashSet assObjects = ro.getAssociationsAndAssociatedObjects(); 1070 for (Iterator it = assObjects.iterator(); it.hasNext(); ) { 1071 RegistryObjectImpl assObj = (RegistryObjectImpl)it.next(); 1072 1073 if (assObj.isNew() || assObj.isModified()) { 1074 //log.debug(pad + "processRegistryObject: recursing on assObj = " + assObj); 1075 processObject(assObj, submitObjects, processedObjects, composedObjects, pad.concat(" ")); 1076 } 1077 } 1078 1079 //Get and process ExternalLinks implicitly for RegistryObjects being saved 1080 //as required by JAXR 1.0 specification. 1081 Collection elObjects = ro.getExternalLinks(); 1082 for (Iterator it = elObjects.iterator(); it.hasNext(); ) { 1083 Object elObj = it.next(); 1084 //log.debug(pad + "processRegistryObject: recursing on elObj = " + elObj); 1085 processObject(elObj, submitObjects, processedObjects, composedObjects, pad.concat(" ")); 1086 } 1087 1088 //Rule: Don't process composed or referenced objects if object is unmodified 1089 if (ro.isNew() || ro.isModified()) { 1090 //Get and process composed objects implicitly for RegistryObjects being saved 1091 HashSet _composedObjects = new HashSet(); 1092 ro.getComposedObjects(_composedObjects); 1093 composedObjects.addAll(_composedObjects); 1094 for (Iterator composedIter = _composedObjects.iterator(); composedIter.hasNext(); ) { 1095 Object composedObj = composedIter.next(); 1096 //log.debug(pad + "processRegistryObject: recursing on composedObj = " + composedObj); 1097 processObject(composedObj, submitObjects, processedObjects, composedObjects, pad.concat(" ")); 1098 } 1099 1100 //Get and process objects referenced by RegistryObject 1101 HashSet refObjects = ro.getRegistryObjectRefs(); 1102 if (refObjects != null) { 1103 for (Iterator refIter = refObjects.iterator(); refIter.hasNext(); ) { 1104 Object refObj = refIter.next(); 1105 //log.debug(pad + "processRegistryObject: recursing on refObj = " + refObj); 1106 processObject(refObj, submitObjects, processedObjects, composedObjects, pad.concat(" ")); 1107 } 1108 } 1109 } 1110 } 1111 1112 private LeafRegistryObjectList makeLeafRegistryObjectList( 1113 HashSet objects, HashSet processedObjects, HashSet composedObjects, HashMap attachMap) 1114 throws JAXRException 1115 { 1116 HashSet roIds = new HashSet(); 1117 HashSet refIds = new HashSet(); 1118 1119 if (objects == null || objects.size() == 0) { 1120 return null; 1121 } 1122 1123 LeafRegistryObjectList list = new LeafRegistryObjectList(); 1124 for (Iterator it = objects.iterator(); it.hasNext(); ) { 1125 LeafRegistryObjectListTypeItem item = 1126 new LeafRegistryObjectListTypeItem(); 1127 1128 Object obj = it.next(); 1129 RegistryObjectImpl ro = null; 1130 1131 if (obj instanceof RegistryObjectImpl) { 1132 ro = (RegistryObjectImpl)obj; 1133 String id = ro.getId(); 1134 1135 if (!composedObjects.contains(ro)) { 1136 1137 log.debug("makeLeafRegistryObjectList: ro=" + ro + " modified=" + ro.isModified() + " new=" + ro.isNew()); 1138 if ((ro.isModified()) || (ro.isNew())) { 1139 1140 log.debug("makeLeafRegistryObjectList: submitting " + obj); 1141 if (obj instanceof Association) { 1142 item.setAssociation(((AssociationImpl)obj).toBindingObject()); 1143 } 1144 else if (obj instanceof AuditableEvent) { 1145 item.setAuditableEvent(((AuditableEventImpl)obj).toBindingObject()); 1146 } 1147 else if (obj instanceof Classification) { 1148 item.setClassification(((ClassificationImpl)obj).toBindingObject()); 1149 } 1150 else if (obj instanceof Concept) { 1151 item.setClassificationNode(((ConceptImpl)obj).toBindingObject()); 1152 } 1153 else if (obj instanceof ClassificationScheme) { 1154 log.debug("makeLeafRegistryObjectList: setting item to scheme " + obj); 1155 item.setClassificationScheme(((ClassificationSchemeImpl)obj).toBindingObject()); 1156 } 1157 else if (obj instanceof ExternalIdentifier) { 1158 item.setExternalIdentifier(((ExternalIdentifierImpl)obj).toBindingObject()); 1159 } 1160 else if (obj instanceof ExternalLink) { 1161 item.setExternalLink(((ExternalLinkImpl)obj).toBindingObject()); 1162 } 1163 else if (obj instanceof ExtrinsicObject) { 1164 ExtrinsicObjectImpl eo = (ExtrinsicObjectImpl)obj; 1165 item.setExtrinsicObject(eo.toBindingObject()); 1166 1167 DataHandler ri = eo.getRepositoryItem(); 1168 // ebXML RS spec 2.0 allows ExtrinsicObject to exist 1169 // w/o RepositoryItem, but not JAXR 1.0 1170 if (ri != null) { 1171 attachMap.put(id, ri); 1172 } 1173 } 1174 else if (obj instanceof Organization) { 1175 item.setOrganization(((OrganizationImpl)obj).toBindingObject()); 1176 } 1177 else if (obj instanceof RegistryPackage) { 1178 item.setRegistryPackage(((RegistryPackageImpl)obj).toBindingObject()); 1179 } 1180 else if (obj instanceof Service) { 1181 item.setService(((ServiceImpl)obj).toBindingObject()); 1182 } 1183 else if (obj instanceof ServiceBinding) { 1184 item.setServiceBinding(((ServiceBindingImpl)obj).toBindingObject()); 1185 } 1186 else if (obj instanceof SpecificationLink) { 1187 item.setSpecificationLink(((SpecificationLinkImpl)obj).toBindingObject()); 1188 } 1189 else if (obj instanceof User) { 1190 item.setUser(((UserImpl)obj).toBindingObject()); 1191 } 1192 1193 if (!(roIds.contains(id))) { 1194 roIds.add(id); 1195 list.addLeafRegistryObjectListTypeItem(item); 1196 } 1197 } 1198 else { 1199 //Not modified or new. Create an ObjectRef if one has no being marshalled already 1200 if (!(refIds.contains(id))) { 1201 refIds.add(id); 1202 1203 org.oasis.ebxml.registry.bindings.rim.ObjectRef ebRef = new org.oasis.ebxml.registry.bindings.rim.ObjectRef(); 1204 ebRef.setId(id); 1205 item.setObjectRef(ebRef); 1206 log.debug("makeLeafRegistryObjectList: submitting ref to unmodified ro=" + ro); 1207 list.addLeafRegistryObjectListTypeItem(item); 1208 } 1209 } 1210 } 1211 else { 1212 //This is a composed object. SKip it as it will be marshalled as part of its composite 1213 log.debug("makeLeafRegistryObjectList: skipping composedObject ro=" + ro + " modified=" + ro.isModified() + " new=" + ro.isNew()); 1214 } 1215 } 1216 else if (obj instanceof RegistryObjectRef) { 1217 //There may be multiple refs to same object. 1218 //Only add ObjectRef if it has not been added already 1219 String id = ((RegistryObjectRef)obj).getId(); 1220 1221 if (!(refIds.contains(id))) { 1222 refIds.add(id); 1223 org.oasis.ebxml.registry.bindings.rim.ObjectRef ebRef = new org.oasis.ebxml.registry.bindings.rim.ObjectRef(); 1224 ebRef.setId(id); 1225 item.setObjectRef(ebRef); 1226 log.debug("makeLeafRegistryObjectList: submitting ref=" + obj); 1227 list.addLeafRegistryObjectListTypeItem(item); 1228 } 1229 } 1230 else { 1231 throw new JAXRException("Unexpected ebXML object to save" + obj); 1232 } 1233 1234 } 1235 log.debug("makeLeafRegistryObjectList: returning item count = " + list.getLeafRegistryObjectListTypeItemCount()); 1236 return list; 1237 } 1238 1239 private BulkResponse doSubmitObjectsRequest(LeafRegistryObjectList list, 1240 HashMap attachMap) 1241 throws JAXRException 1242 { 1243 BulkResponseImpl response = null; 1244 SubmitObjectsRequest req = new SubmitObjectsRequest(); 1245 req.setLeafRegistryObjectList(list); 1246 StringWriter sw = new StringWriter(); 1247 try { 1248 req.marshal(sw); 1249 } catch (org.exolab.castor.xml.MarshalException x) { 1250 throw new JAXRException(x); 1251 } catch (org.exolab.castor.xml.ValidationException x) { 1252 log.debug(x); 1253 throw new JAXRException(x); 1254 } 1255 response = regService.getSoapMessenger().sendSoapRequest( 1256 sw.toString(), attachMap, true); 1257 1258 //Now setCollection with ids of objects saved 1259 setKeysOnBulkResponse(req, response); 1260 return response; 1261 } 1262 1263 private BulkResponse doUpdateObjectsRequest(LeafRegistryObjectList list, 1264 HashMap attachMap) 1265 throws JAXRException 1266 { 1267 BulkResponseImpl response = null; 1268 UpdateObjectsRequest req = new UpdateObjectsRequest(); 1269 req.setLeafRegistryObjectList(list); 1270 StringWriter sw = new StringWriter(); 1271 try { 1272 req.marshal(sw); 1273 } catch (org.exolab.castor.xml.MarshalException x) { 1274 throw new JAXRException(x); 1275 } catch (org.exolab.castor.xml.ValidationException x) { 1276 throw new JAXRException(x); 1277 } 1278 response = regService.getSoapMessenger().sendSoapRequest( 1279 sw.toString(), attachMap, true); 1280 1281 setKeysOnBulkResponse(req, response); 1282 1283 return response; 1284 } 1285 1286 private void setKeysOnBulkResponse(Object req, BulkResponseImpl response) throws JAXRException { 1287 ArrayList idList = null; 1288 try { 1289 idList = BindingUtility.getInstance().getIdsFromRequest(req); 1290 } 1291 catch (RegistryException e) { 1292 throw new JAXRException(e); 1293 } 1294 1295 ArrayList keyList = new ArrayList(); 1296 Iterator iter = idList.iterator(); 1297 while (iter.hasNext()) { 1298 String id = (String)iter.next(); 1299 Key key = createKey(id); 1300 keyList.add(key); 1301 } 1302 response.setCollection(keyList); 1303 } 1304 1305 /*** 1306 * Marks all RegistryObjectImpl-s as clean, ie. not new nor modified. 1307 * 1308 * @param objects Collection of RegistryObjectImpl-s 1309 */ 1310 private void markRegistryObjectsClean(Collection objects) { 1311 for (Iterator it = objects.iterator(); it.hasNext(); ) { 1312 Object obj = it.next(); 1313 1314 if (obj instanceof RegistryObjectImpl) { 1315 RegistryObjectImpl ro = (RegistryObjectImpl)obj; 1316 ro.setNew(false); 1317 ro.setModified(false); 1318 } 1319 } 1320 } 1321 1322 /*** 1323 * Deprecates one or more previously submitted objects. Deprecation 1324 * marks an object as "soon to be deleted". Once an object is 1325 * deprecated, the JAXR provider must not allow any new references 1326 * (e.g. new Associations, Classifications and ExternalLinks) to that 1327 * object to be submitted. If a client makes an API call that results 1328 * in a new reference to a deprecated object, the JAXR provider must 1329 * throw a java.lang.IllegalStateException within a 1330 * JAXRException. However, existing references to a deprecated object 1331 * continue to function normally. 1332 * 1333 * <p><DL><DT><B>Capability Level: 1 </B></DL> 1334 * 1335 * @param keys a Collection of keys for the objects to be deprecated 1336 * 1337 * @return a BulkResponse containing the Collection of keys for those 1338 * objects that were deprecated successfully and any JAXRException that 1339 * was encountered in case of partial commit 1340 * 1341 * @throws JAXRException if the JAXR provider encounters an internal error 1342 */ 1343 public BulkResponse deprecateObjects(Collection keys) throws JAXRException 1344 { 1345 ObjectRefList orl = createObjectRefList(keys); 1346 1347 DeprecateObjectsRequest dor = new DeprecateObjectsRequest(); 1348 dor.setObjectRefList(orl); 1349 StringWriter sw = new StringWriter(); 1350 try { 1351 dor.marshal(sw); 1352 } catch (org.exolab.castor.xml.MarshalException x) { 1353 throw new JAXRException(x); 1354 } catch (org.exolab.castor.xml.ValidationException x) { 1355 throw new JAXRException(x); 1356 } 1357 return regService.getSoapMessenger().sendSoapRequest( 1358 sw.toString(), null, true); 1359 } 1360 1361 /*** 1362 * Undeprecates one or more previously deprecated objects. If an object 1363 * was not previously deprecated, it is not an error, and no exception 1364 * is thrown. Once an object is undeprecated, the JAXR provider must 1365 * again allow new references (e.g. new Associations, Classifications 1366 * and ExternalLinks) to that object to be submitted. 1367 * 1368 * <p><DL><DT><B>Capability Level: 1 </B></DL> 1369 * 1370 * @param keys a Collection of keys for the objects to be undeprecated 1371 * 1372 * @return a BulkResponse containing the Collection of keys for those 1373 * objects that were deprecated successfully and any JAXRException that 1374 * was encountered in case of partial commit 1375 * 1376 * @throws JAXRException if the JAXR provider encounters an internal error 1377 */ 1378 public BulkResponse unDeprecateObjects(Collection keys) 1379 throws JAXRException 1380 { 1381 // ??eeg ebXML RS 2.0 does not have an undeprecateObjectsRequest. 1382 // Also, I think the method name needs to be changed to 1383 // "undeprecateObjects" to follow normal Java camel case rules 1384 // since "un" and "deprecate" are not two separate words. 1385 return null; 1386 } 1387 1388 /*** 1389 * Deletes one or more previously submitted objects from the registry. 1390 * 1391 * 1392 * <p><DL><DT><B>Capability Level: 0 </B></DL> 1393 * 1394 * @return BulkResponse containing the Collection of keys for those 1395 * objects that were deleted successfully and any DeleteException that 1396 * was encountered in case of partial commit. 1397 */ 1398 public BulkResponse deleteObjects(Collection keys) throws JAXRException 1399 { 1400 BulkResponseImpl response = null; 1401 ObjectRefList orl = createObjectRefList(keys); 1402 1403 RemoveObjectsRequest ror = new RemoveObjectsRequest(); 1404 ror.setObjectRefList(orl); 1405 StringWriter sw = new StringWriter(); 1406 try { 1407 ror.marshal(sw); 1408 } catch (org.exolab.castor.xml.MarshalException x) { 1409 throw new JAXRException(x); 1410 } catch (org.exolab.castor.xml.ValidationException x) { 1411 throw new JAXRException(x); 1412 } 1413 response = regService.getSoapMessenger().sendSoapRequest( 1414 sw.toString(), null, true); 1415 1416 response.setCollection(keys); 1417 1418 return response; 1419 } 1420 1421 /*** 1422 * Create a semantic equivalence between the two specified Concepts. 1423 * This is a convenience method to create an Association with 1424 * sourceObject as concept1 and targetObject as concept2 and 1425 * associationType as EquivalentTo. 1426 * 1427 * <p><DL><DT><B>Capability Level: 0 </B></DL> 1428 * 1429 */ 1430 public void createConceptEquivalence(Concept concept1, Concept concept2) 1431 throws JAXRException 1432 { 1433 BusinessQueryManagerImpl bqm = (BusinessQueryManagerImpl)regService.getBusinessQueryManager(); 1434 Concept eqConcept = 1435 bqm.findConceptByPath("/urn:uuid:6902675f-2f18-44b8-888b-c91db8b96b4d/" + "EquivalentTo"); 1436 Association assoc = createAssociation(concept2, eqConcept); 1437 concept1.addAssociation(assoc); 1438 //??eeg save assoc to Registry or is an attribute of the Connection?? 1439 } 1440 1441 /*** 1442 * Removes the semantic equivalence, if any, between the specified two 1443 * Concepts. This is a convenience method to to delete any Association 1444 * sourceObject as concept1 and targetObject as concept2 and 1445 * associationType as EquivalentTo. 1446 * 1447 * <p><DL><DT><B>Capability Level: 0 </B></DL> 1448 * 1449 */ 1450 public void deleteConceptEquivalence(Concept concept1, Concept concept2) throws JAXRException{ 1451 // Write your code here 1452 } 1453 1454 /*** 1455 * Deletes one or more previously submitted objects from the registry 1456 * using the object keys and a specified objectType attribute. 1457 * 1458 * <p><DL><DT><B>Capability Level: 0 </B></DL> 1459 * 1460 * @param keys a Collection of keys for the objects to be deleted 1461 * @param objectType the objectType attribute for the objects to be deleted 1462 * 1463 * @return a BulkResponse containing the Collection of keys for those 1464 * objects that were deleted successfully and any DeleteException that 1465 * was encountered in case of partial commit 1466 * 1467 * @throws JAXRException if the JAXR provider encounters an internal error 1468 */ 1469 public BulkResponse deleteObjects(Collection keys, String objectType) 1470 throws JAXRException 1471 { 1472 return deleteObjects(keys); 1473 } 1474 1475 /*** 1476 * Returns the parent RegistryService that created this object. 1477 * 1478 * <p><DL><DT><B>Capability Level: 0 </B></DL> 1479 * 1480 * @return the parent RegistryService 1481 * 1482 * @throws JAXRException if the JAXR provider encounters an internal error 1483 * 1484 * @associates <{javax.xml.registry.RegistryService}> 1485 */ 1486 public RegistryService getRegistryService() throws JAXRException { 1487 return regService; 1488 } 1489 1490 /*** 1491 * @param keys Collection of objects which are typically Key-s. Non 1492 * Key objects are ignored. 1493 * 1494 * @return an ObjectRefList binding object representing the list of 1495 * unique Keys 1496 */ 1497 private ObjectRefList createObjectRefList(Collection keys) 1498 throws JAXRException 1499 { 1500 // Used to prevent duplicate keys from being sent 1501 HashSet processedIds = new HashSet(); 1502 processedIds.add(null); 1503 1504 ObjectRefList orl = new ObjectRefList(); 1505 for (Iterator it = keys.iterator(); it.hasNext(); ) { 1506 Object obj = it.next(); 1507 if (obj instanceof KeyImpl) { 1508 KeyImpl key = (KeyImpl)obj; 1509 String id = key.getId(); 1510 if (!processedIds.contains(id)) { 1511 processedIds.add(id); 1512 ObjectRef ebObjRef = new ObjectRef(); 1513 ebObjRef.setId(id); 1514 ObjectRefListItem orli = new ObjectRefListItem(); 1515 orli.setObjectRef(ebObjRef); 1516 orl.addObjectRefListItem(orli); 1517 } 1518 } 1519 } 1520 return orl; 1521 } 1522 1523 private void initializeObjectTypesMap() { 1524 try { 1525 DeclarativeQueryManager dqm = getRegistryService().getDeclarativeQueryManager(); 1526 String queryStr = "SELECT * FROM ClassificationNode children, ClassificationNode parent where (parent.path LIKE '/urn:uuid:3188a449-18ac-41fb-be9f-99a1adca02cb/RegistryObject%') AND (parent.path NOT LIKE '/urn:uuid:3188a449-18ac-41fb-be9f-99a1adca02cb/RegistryObject/RegistryEntry/ExtrinsicObject/%') AND parent.id = children.parent"; 1527 Query query = dqm.createQuery(Query.QUERY_TYPE_SQL, queryStr); 1528 BulkResponse resp = dqm.executeQuery(query); 1529 1530 if ((resp!=null) &&(!(resp.getStatus() == JAXRResponse.STATUS_SUCCESS))) { 1531 Collection exceptions = resp.getExceptions(); 1532 Iterator iter = exceptions.iterator(); 1533 while (iter.hasNext()) { 1534 Exception e = (Exception)iter.next(); 1535 e.printStackTrace(); 1536 } 1537 1538 return; 1539 } 1540 1541 objectTypesMap = new HashMap(); 1542 1543 Collection concepts = resp.getCollection(); 1544 Iterator iter = concepts.iterator(); 1545 while (iter.hasNext()) { 1546 Concept concept = (Concept)iter.next(); 1547 String value = concept.getValue(); 1548 if (value.equals("ClassificationNode")) { 1549 value = "Concept"; 1550 } 1551 1552 objectTypesMap.put(value, concept); 1553 } 1554 } 1555 catch (JAXRException e) { 1556 e.printStackTrace(); 1557 } 1558 } 1559 1560 public HashMap getObjectTypesMap() { 1561 if (objectTypesMap == null) { 1562 initializeObjectTypesMap(); 1563 } 1564 return objectTypesMap; 1565 } 1566 }

This page was automatically generated by Maven