Managing Objects in the Registry
- Once you have published objects to the Registry, you can perform operations on them. This chapter describes these operations.Creating Relationships Between Objects: Associations
Creating Relationships Between Objects: Associations
You can create an
Association
object and use it to specify a relationship between any two objects. The ebXML specification specifies anAssociationType
classification scheme that contains a number of canonical concepts you can use when you create anAssociation
. You can also create your own concepts within theAssociationType
classification scheme, if none of the canonical ones are suitable.The canonical association types are as follows:
AccessControlPolicyFor
AffiliatedWith
(which has the subconceptsEmployeeOf
andMemberOf
)Contains
ContentManagementServiceFor
EquivalentTo
Extends
ExternallyLinks
HasFederationMember
HasMember
Implements
InstanceOf
InvocationControlFileFor
(which has the subconceptsCatalogingControlFileFor
andValidationControlFileFor
)OffersService
OwnerOf
RelatedTo
Replaces
ResponsibleFor
SubmitterOf
Supersedes
Uses
The Registry uses some of these association types automatically. For example, when you add a
Service
to anOrganization
, the Registry creates anOffersService
association with theOrganization
as the source and theService
as the target.Associations are directional: each
Association
has a source object and a target object. Establishing an association between two objects is a three-step process:
- Find the
AssociationType
concept you wish to use (or create one).- Use the
LifeCycleManager.createAssociation
method to create the association. This method takes two arguments, the target object and the concept that identifies the relationship.- Use the
RegistryObject.addAssociation
method to add the association to the source object.For example, suppose you have two objects,
obj1
andobj2
, and you want to establish aRelatedTo
relationship between them. (In this relationship, which object is the source and which is the target is arbitrary.) First, locate the concept namedRelatedTo
:// Find RelatedTo concept for Association Collection namePatterns = new ArrayList(); namePatterns.add("RelatedTo"); BulkResponse br = bqm.findObjects("Concept", null, namePatterns, null, null, null, null); Collection concepts = br.getCollection();Iterate through the concepts (there should only be one) to find the right one.
Create the association, specifying
obj2
as the target:Add the association to the source object,
obj1
:Finally, save the association:
Collection associations = new ArrayList(); associations.add(relAssoc1); BulkResponse response = blcm.saveObjects(associations);Associations can be of two types, intramural and extramural. You create an intramural association when both the source and target object are owned by you. You create an extramural association when at least one of these objects is not owned by you. The owner of an object can use an access control policy to restrict the right to create an extramural association with that object as a source or target.
Creating Associations: Example
For an example of creating an association, see
<
INSTALL
>/registry/samples/publish-association/src/JAXRPublishAssociation.java
. This example creates aRelatedTo
association between any two objects whose unique identifiers you specify. For example, you could specify the identifiers of the two child organizations created in Creating and Retrieving an Organization Hierarchy: Example. To run the example, follow these steps:Whether the association is intramural or extramural depends upon who owns the two objects.
Storing Items in the Repository
As About Registries and Repositories explains, the Registry includes a repository in which you can store electronic content. For every item you store in the repository, you must first create a type of
RegistryObject
called anExtrinsicObject
. When you save theExtrinsicObject
to the Registry, the associated repository item is also saved.Creating an Extrinsic Object
To create an
ExtrinsicObject
, you first need to create ajavax.activation.DataHandler
object for the repository item. TheLifeCycleManager.createExtrinsicObject
method takes aDataHandler
argument.To store a file in the repository, for example, first create a
java.io.File
object. From theFile
object, create ajavax.activation.FileDataSource
object, which you use to instantiate theDataHandler
object.String filename = "./MyFile.xml"; File repositoryItemFile = new File(filename); DataHandler repositoryItem = new DataHandler(new FileDataSource(repositoryItemFile));Next, call
createExtrinsicObject
with theDataHandler
as argument:Set the MIME type of the object to make it accessible. The default MIME type is
application/octet-stream
. If the file is an XML file, set it as follows:Finally, call the implementation-specific
ExtrinsicObjectImpl.setObjectType
method to store theExtrinsicObject
in an appropriate area of the Registry. This method has the following signature:The easiest way to find the appropriate concept for a file is to use the Explore feature of the Web Console. Look under the
ObjectType
classification scheme for the various types ofExtrinsicObject
concepts. Specify the ID for the concept as the argument togetRegistryObject
, then specify the concept as the argument tosetObjectType
.String conceptId = "urn:oasis:names:tc:ebxml- regrep:ObjectType:RegistryObject:ExtrinsicObject:XML"; Concept objectTypeConcept = (Concept) bqm.getRegistryObject(conceptId); ((ExtrinsicObjectImpl)eo).setObjectType(objectTypeConcept);Finally, you save the
ExtrinsicObject
to the Registry.Collection extobjs = new ArrayList(); extobjs.add(eo); BulkResponse response = blcm.saveObjects(extobjs);The
ExtrinsicObject
contains the metadata, and a copy of the file is stored in the repository.If the Registry does not have a concept for the kind of file you want to store there, you can create and save the concept yourself.
Creating an Extrinsic Object: Example
For an example of creating an extrinsic object, see
<
INSTALL
>/registry/samples/publish-extrinsic/src/JAXRPublishExtrinsicObject.java
. This example publishes an XML file to the Registry. To run the example, follow these steps:Using an Extrinsic Object as a Specification Link
You can publish an
ExtrinsicObject
by itself, but it is also very common to create anExtrinsicObject
to use as theSpecificationLink
object for aServiceBinding
object (see Creating Services and Service Bindings). TheExtrinsicObject
typically refers to a WSDL file.
- Create a
SpecificationLink
object.- Store the WSDL document in the repository and create an
ExtrinsicObject
that refers to it. Set the extrinsic object's type toWSDL
and its mime type totext/xml
.- Specify the extrinsic object as the
specificationObject
attribute of theSpecificationLink
object.- Add the
SpecificationLink
object to theServiceBinding
object.- Add the
ServiceBinding
object to theService
object.- Save the
Service
object.After you create a
Service
andServiceBinding
, create aSpecificationLink
:SpecificationLink specLink = blcm.createSpecificationLink(); specLink.setName("Spec Link Name"); specLink.setDescription("Spec Link Description");Create an
ExtrinsicObject
as described in Creating an Extrinsic Object. Use the ID for the WSDL concept and thetext/xml
MIME type.String conceptId = "urn:oasis:names:tc:ebxml- regrep:ObjectType:RegistryObject:ExtrinsicObject:WSDL"; Concept objectTypeConcept = (Concept) bqm.getRegistryObject(conceptId); ((ExtrinsicObjectImpl)eo).setObjectType(objectTypeConcept); eo.setMimeType("text/xml");Set the
ExtrinsicObject
as the specification object for theSpecificationLink
:Add the
SpecificationLink
to theServiceBinding
, then add the objects to their collections and save the services.When you remove a service from the Registry, the service bindings and specification links are also removed. However, the extrinsic objects associated with the specification links are not removed.
Creating an Extrinsic Object as a Specification Link: Example
For an example of creating an extrinsic object as a specification link, see
<
INSTALL
>/registry/samples/publish-service/src/JAXRPublishService.java
. This example publishes a WSDL file to the Registry. To run the example, follow these steps:Organizing Objects Within Registry Packages
Registry packages allow you to group a number of logically related registry objects, even if the individual member objects belong to different owners. For example, you could create a
RegistryPackage
object and add to it all objects in the Registry whose names shared a particular unique string or that all contained aSlot
with the same name and value.To create a
RegistryPackage
object, call theLifeCycleManager.createRegistryPackage
method, which takes aString
orInternationalString
argument. Then call theRegistryPackage.addRegistryObject
orRegistryPackage.addRegistryObjects
method to add objects to the package.For example, you could create a
RegistryPackage
object named "SunPackage":Then, after finding all objects with the string
"Sun"
in their names, you could iterate through the results and add each object to the package:A common use of packages is to organize a set of extrinsic objects. A registry administrator can load a file system into the Registry, storing the directories as registry packages and the files as the package contents. See the Administration Guide for more information.
Organizing Objects Within Registry Packages: Examples
For examples of using registry packages, see the two examples in
<
INSTALL
>/registry/samples/packages/src
:JAXRPublishPackage.java
andJAXRQueryPackage.java
. The first example publishes aRegistryPackage
object that includes all objects in the Registry whose names contain the string"free"
. The second example searches for this package and displays its contents. To run the examples, follow these steps:Changing the State of Objects in the Registry
You add an
AuditableEvent
object to the audit trail of an object when you publish it to the Registry or when you modify it in any way. See Retrieving the Audit Trail of an Object for details on these events and on how to obtain information about them. Table 8-5 on page 33 describes the events and how they are created.Many events are created as a side effect of some other action:
- Saving an object to the Registry creates an
EVENT_TYPE_CREATED
event.- The following actions create an
EVENT_TYPE_VERSIONED
event:
- Changing an object's name or description
- Adding, modifying, or removing a
Classification
,ExternalIdentifier
,ExternalLink
, orSlot
- For an
Organization
orUser
, adding, modifying, or removing aPostalAddress
orTelephoneNumber
You can retrieve version information for an object. See Retrieving the Version of an Object for details.
Note: At this release, versioning of objects is disabled. All objects have a version of 1.1.
You can also change the state of objects explicitly. This feature may be useful in a production environment where different versions of objects exist and you wish to use some form of version control. For example, you can approve a version of an object for general use and deprecate an obsolete version before you remove it. If you change your mind after deprecating an object, you can undeprecate it. You can perform these actions only on objects you own.
The
LifeCycleManagerImpl.approveObjects
method has the following signature:It is possible to restrict access to these actions to specific users, such as registry administrators.
No
AuditableEvent
is created for actions that do not alter the state of aRegistryObject
. For example, queries do not generate anAuditableEvent
, and noAuditableEvent
is generated for aRegistryObject
when it is added to aRegistryPackage
or when you create anAssociation
with the object as the source or target.Changing the State of Objects in the Registry: Examples
For examples of approving, deprecating, undeprecating objects, see the examples in
<
INSTALL
>/registry/samples/auditable-events/src
:JAXRApproveObject.java
,JAXRDeprecateObject.java
, andJAXRUndeprecateObject.java
. Each example performs an action on an object whose unique identifier you specify, then displays the object's audit trail so that you can see the effect of the example. To run the examples, follow these steps:The object you specify should be one that you created.
Removing Objects From the Registry and Repository
A registry allows you to remove from it any objects that you have submitted to it. You use the object's ID as an argument to the
LifeCycleManager.deleteObjects
method.The following code fragment deletes the object that corresponds to a specified key string and then displays the key again so that the user can confirm that it has deleted the correct one.
String id = key.getId(); Collection keys = new ArrayList(); keys.add(key); BulkResponse response = blcm.deleteObjects(keys); Collection exceptions = response.getException(); if (exceptions == null) { System.out.println("Objects deleted"); Collection retKeys = response.getCollection(); Iterator keyIter = retKeys.iterator(); javax.xml.registry.infomodel.Key orgKey = null; if (keyIter.hasNext()) { orgKey = (javax.xml.registry.infomodel.Key) keyIter.next(); id = orgKey.getId(); System.out.println("Object key was " + id); } }Deleting an
Organization
does not delete theService
andUser
objects that belong to theOrganization
. You must delete them separately.Deleting a
Service
object deletes theServiceBinding
objects that belong to it, and also theSpecificationLink
objects that belong to theServiceBinding
objects. Deleting theSpecificationLink
objects, however, does not delete the associatedExtrinsicObject
instances and their associated repository items. You must delete the extrinsic objects separately.
AuditableEvent
andAssociation
objects are not always deleted when the objects associated with them are deleted. You may find that as you use the Registry, a large number of these objects accumulates.Removing Objects from the Registry: Example
For an example of deleting an object from the Registry, see
<
INSTALL
>/registry/samples/delete-object/src/JAXRDelete.java
. This example deletes the object whose unique identifier you specify. To run the example, follow these steps: