Difference between revisions of "IS-Registry"
Manuele.simi (Talk | contribs) (→Registering a new GCUBE Resource) |
Manuele.simi (Talk | contribs) (→Registering a new GCUBE Resource) |
||
Line 119: | Line 119: | ||
− | === | + | === Updating an existing GCUBE Resource === |
The following test method show how to update an existing GCUBE Resource: | The following test method show how to update an existing GCUBE Resource: | ||
<source lang="java"> | <source lang="java"> |
Revision as of 03:56, 9 April 2011
Contents
Role
The IS-Registry is the gateway to entering in a gCube infrastructure for gCube resources by means of registering/unregistering their profiles.
The IS-Registry performs three fundamental tasks:
- decide if accept or not a new resource
- validate a resource before its registration
- execute post-deletion actions to keep consistent the IS content
Design
The design of the service is distributed across two port-types: the ResourceRegistration
and the Factory
.
ResourceRegistration
The ResourceRegistration
port-type manages the registration/update/removal of GCUBE Resources. It is directly contacted only by the IS-Publisher in order to perform such operations.
It exposes three operations:
- ...
- ...
- ...
Factory
From the functional point of view, the Factory port-type is practically a wrapper around the ResourceRegistration
port-type to provide backwards compatibility to previous IS-Publisher and testers implementation. Therefore, it exposes the following operations:
-
createResource
– which takes as input parameter a message containing a resource profile and a set of registration directives (e.g. VO membership and VRE membership) and returns a string containing the whole profile of the new resource including the automatically assigned ID; -
updateResource
– which takes as input parameter a message containing the new profile that is supposed to replace an existing one. The key to identify the old profile to be replaced is contained in the profile itself, it is the resource ID. By relying on the internal mapping between IDs and EPRs it identifies the WS-Resource it has to interact with in order to implement such update operation; -
removeResource
– which takes as input parameters a message containing the resource ID identifying the resource to be removed and its type;
FactoryResource
At start up time, the Factory
port-type is in charge of creating the singleton FactoryResource
. This resource (whose name is derived from previous versions of the service) exposes a set of WS-ResourceProperties registered as Topics in the IS-Notifier, making possible for interested clients to subscribe on events representing the changes of status of Infrastructure constituents (e.g. the disappearance of a Running Instance).
This is the list of RPs exposed:
<xsd:element name="RegistryFactoryResourceProperties"> <xsd:complexType> <xsd:sequence> <xsd:element ref="tns:RunningInstance" minOccurs="1" maxOccurs="1"/> <xsd:element ref="tns:ExternalRunningInstance" minOccurs="1" maxOccurs="1"/> <xsd:element ref="tns:Service" minOccurs="1" maxOccurs="1"/> <xsd:element ref="tns:Collection" minOccurs="1" maxOccurs="1"/> <xsd:element ref="tns:GHN" minOccurs="1" maxOccurs="1"/> <xsd:element ref="tns:MetadataCollection" minOccurs="1" maxOccurs="1"/> <xsd:element ref="tns:GenericResource" minOccurs="1" maxOccurs="1"/> </xsd:sequence> </xsd:complexType> </xsd:element>
where the each resource type is defined as ResourceProperty
:
<xsd:complexType name="RegistryProperty"> <xsd:sequence> <xsd:element name="uniqueID" type="xsd:string" nillable="true"/> <xsd:element name="profile" type="xsd:string" nillable="true"/> <xsd:element name="operationType" type="xsd:string" nillable="true"/> <xsd:element name="changeTime" type="xsd:dateTime" nillable="true"/> </xsd:sequence> </xsd:complexType>
Note that:
- uniqueID is the identifier of the resource
- profile is the entire profile of the resource
- operationType is the type of operation performed on the resource (allowed values are: create, update, destroy)
- changeTime is the time stamp of the operation
Sample Usage
This section provides sample usage of the ResourceRegistration port-type. The Factory port-type is obsolete and should not be used anymore.
Note that:
- due to the behavior of the IS-Publisher, any request is executed asynchronously (at the next scheduled bulk execution)
- if the operation is performed inside a service, the ServiceContext has to be used as GCUBESecurityManager (instead of the ad hoc manager created here below).
Registering a new GCUBE Resource
The following test method show how to register a new GCUBE Resource:
import org.gcube.informationsystem.registry.stubs.resourceregistration.CreateMessage; import org.gcube.informationsystem.registry.stubs.resourceregistration.ResourceRegistrationPortType; import org.gcube.informationsystem.registry.stubs.resourceregistration.service.ResourceRegistrationServiceAddressingLocator; //... protected void registerResource(GCUBEResource resource, GCUBEScope scope) throws Exception { int timeout = 20000; StringWriter profile = new StringWriter(); resource.store(profile); GCUBESecurityManagerImpl manager = new GCUBESecurityManagerImpl() { public boolean isSecurityEnabled() { return false;} }; ResourceRegistrationServiceAddressingLocator locator = new ResourceRegistrationServiceAddressingLocator(); ResourceRegistrationPortType registration = locator.getResourceRegistrationPortTypePort(epr); registration = GCUBERemotePortTypeContext.getProxy(registration, scope, timeout, manager); try { CreateMessage message = new CreateMessage(); message.setProfile(profile.toString()); message.setType(resource.getType()); registration.create(message); } catch(Exception e) { logger.error("Failed to publish the GCUBE Resource ",e); } }
Updating an existing GCUBE Resource
The following test method show how to update an existing GCUBE Resource:
import org.gcube.informationsystem.registry.stubs.resourceregistration.UpdateMessage; import org.gcube.informationsystem.registry.stubs.resourceregistration.ResourceRegistrationPortType; import org.gcube.informationsystem.registry.stubs.resourceregistration.service.ResourceRegistrationServiceAddressingLocator; //... protected void updateResource(GCUBEResource resource, GCUBEScope scope) throws Exception { int timeout = 20000; StringWriter profile = new StringWriter(); resource.store(profile); GCUBESecurityManagerImpl manager = new GCUBESecurityManagerImpl() { public boolean isSecurityEnabled() { return false;} }; ResourceRegistrationServiceAddressingLocator locator = new ResourceRegistrationServiceAddressingLocator(); ResourceRegistrationPortType registration = locator.getResourceRegistrationPortTypePort(epr); registration = GCUBERemotePortTypeContext.getProxy(registration, scope, timeout, manager); try { UpdateMessage message = new UpdateMessage(); message.setUniqueID(profile.getID()); message.setXmlProfile(profile.toString()); message.setType(resource.getType()); registration.update(message); } catch(Exception e) { logger.error("Failed to update the GCUBE Resource ",e); } }
Removing a GCUBE resource
The following test method show how to remove a GCUBE Resource:
import org.gcube.informationsystem.registry.stubs.resourceregistration.RemoveMessage; import org.gcube.informationsystem.registry.stubs.resourceregistration.ResourceRegistrationPortType; import org.gcube.informationsystem.registry.stubs.resourceregistration.service.ResourceRegistrationServiceAddressingLocator; //... protected void unregisterResource(GCUBEResource resource, GCUBEScope scope) throws Exception { int timeout = 20000; GCUBESecurityManagerImpl manager = new GCUBESecurityManagerImpl() { public boolean isSecurityEnabled() { return false;} }; ResourceRegistrationServiceAddressingLocator locator = new ResourceRegistrationServiceAddressingLocator(); ResourceRegistrationPortType registration = locator.getResourceRegistrationPortTypePort(epr); registration = GCUBERemotePortTypeContext.getProxy(registration, scope, timeout, manager); try { RemoveMessage message = new RemoveMessage(); message.setUniqueID(this.getResourceID()); message.setType(resource.getType()); registration.remove(message); } catch(Exception e) { logger.error("Failed to remove the GCUBE Resource ",e); } }