Difference between revisions of "Registry-Publisher"
(→Bulked Publications) |
(→ScopedPublisher interface) |
||
(48 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
− | = | + | {| align="right" |
+ | || __TOC__ | ||
+ | |} | ||
+ | In conjunction with the IC-Client, the Registry-Publisher represents the mediation layer gCube Services, based on FWS, will rely on to interact with the Information Service as a whole. | ||
− | == | + | = Design = |
+ | The Registry-Publisher is a Java library providing the implementation of two interfaces (RegistryPublisher and ScopedPublisher) that allow services to publish GCUBEResource as well as their state in the IS. | ||
− | + | More specifically: | |
+ | * by implementing the <code>org.gcube.common.core.informationsystem.publisher.RegistryPublisher</code> interface, the library allows gCube services to publish GCUBEResources and instances' states as of the gCube Resource Model defined in [[Common-gcore-resources]]; | ||
+ | * by implementing the <code>org.gcube.informationsystem.publisher.ScopedPublisher</code> interface, the library allows gCube services to publish GCUBEResources and instances' states as of the gCube Resource Model defined in [[Common-gcore-resources]] in multi scope way; | ||
+ | = Maven coordinates = | ||
+ | The coordinates of the maven artifact are: | ||
+ | <source lang="xml"> | ||
+ | <dependency> | ||
+ | <groupId>org.gcube.resources</groupId> | ||
+ | <artifactId>registry-publisher</artifactId> | ||
+ | <version>...</version> | ||
+ | </dependency> | ||
+ | </source> | ||
+ | Check on [http://maven.research-infrastructures.eu/nexus/index.html#nexus-search;gav~org.gcube.resources~registry-publisher Nexus] for the latest version. | ||
− | + | = Publishing a resource = | |
− | + | In order to publish a Resource the Registry-Publisher contacts the IS-Registry service of the current scope by invoking its appropriate operations. | |
+ | == Interfaces == | ||
− | ==== | + | The only difference between RegistryPublisher interface and ScopedPublisher interface is: |
+ | *RegistryPublisher interface publish resources on the current scope specified by ScopeProvider; | ||
+ | *ScopedPublisher interface publish resources on a List of scopes, calling for every scope the RegistryPublisher interface | ||
+ | |||
+ | ====RegistryPublisher interface==== | ||
− | + | The following operation can be used to manage profiles on the IS: | |
+ | *create() – takes as input parameter a resource (gCUBEResource), and returns the resource updated and filled of the current scope. The resource is created in the current scope and it is updated in the other scopes that are presents in the resource. If the current scope, set by ScopeProvider, is a VRE scope then in the resource will be added also the VO and INFRA scope if they are not present. If is a VO scope then, in the resource, will be added also the INFRA scope if it is not present; | ||
+ | *update() – takes as input parameter a message containing a resource and updates a resource previously registered in the IS. The resource will be updated on all the scopes that are defined in the resource. If an updating operation fail. It will be repeated with best-effort delivery approach | ||
+ | *remove() – takes as input parameter a resource and removes, from the current scope, the corresponding resource previously registered in the IS. It returns the resource without the scope removed; | ||
− | === | + | ====ScopedPublisher interface==== |
− | + | The following operation can be used to manage profiles on the IS: | |
− | + | *create() – takes as input parameters a resource (gCUBEResource), a list of String that identify operational scope and returns the resource updated and filled of the scope list. The resource will be updated on all the scopes specified in the input list calling, for every scope, the update() method of RegistryPublisher interface;; | |
+ | *update() – takes as input parameters a resource and updates a resource previously registered in the IS.The resource will be updated on all the scopes that are defined in the resource. If an updating operation fail. It will be repeated with best-effort delivery approach. | ||
+ | *remove() – takes as input parameters a resource, a list of String that identify operational scope (GCUBEScope) and removes the corresponding resource previously registered in the IS from the scopes specified in the input list calling for every scope the remove() method of RegistryPublisher interface; | ||
− | == Sample | + | == Sample usages== |
− | + | Here it is an example of GenericResource registration by RegistryPublisher interface: | |
− | = | + | <source lang="Java"> |
+ | import org.gcube.common.resources.gcore.GenericResource; | ||
+ | import org.gcube.common.resources.gcore.Resource; | ||
+ | import org.gcube.common.resources.gcore.Resource.Type; | ||
+ | import org.gcube.common.resources.gcore.Resources; | ||
+ | import org.gcube.common.scope.api.ScopeProvider; | ||
− | + | public void create(){ | |
+ | ScopeProvider.instance.set("/gcube/devsec"); | ||
+ | GenericResource generic = Resources.unmarshal(GenericResource.class, PublisherTest.class.getClassLoader().getResourceAsStream("generic2.xml")); | ||
+ | RegistryPublisher rp=RegistryPublisherFactory.create(); | ||
+ | Resource r=rp.create(generic); | ||
+ | } | ||
+ | </source> | ||
− | |||
− | + | Here it is an example of GenericResource registration by ScopedPublisher interface: | |
− | = | + | <source lang="Java"> |
+ | import org.gcube.common.resources.gcore.GenericResource; | ||
+ | import org.gcube.common.resources.gcore.Resource; | ||
+ | import org.gcube.common.resources.gcore.Resource.Type; | ||
+ | import org.gcube.common.resources.gcore.Resources; | ||
+ | import org.gcube.common.scope.api.ScopeProvider; | ||
− | + | public void create(){ | |
− | ==== | + | ScopeProvider.instance.set("/gcube/devsec"); |
+ | GenericResource generic = Resources.unmarshal(GenericResource.class, PublisherTest.class.getClassLoader().getResourceAsStream("generic2.xml")); | ||
+ | List<String> scopes=new ArrayList<String>(); | ||
+ | scopes.add("/gcube/devsec"); | ||
+ | scopes.add("/gcube"); | ||
+ | ScopedPublisher sp=RegistryPublisherFactory.scopedPublisher(); | ||
+ | Resource r=sp.create(generic, scopes); | ||
+ | </source> | ||
− | + | Here it is an example of GenericResource update by RegistryPublisher interface: | |
− | = | + | <source lang="Java"> |
+ | import org.gcube.common.resources.gcore.GenericResource; | ||
+ | import org.gcube.common.resources.gcore.Resource; | ||
+ | import org.gcube.common.resources.gcore.Resource.Type; | ||
+ | import org.gcube.common.resources.gcore.Resources; | ||
+ | import org.gcube.common.scope.api.ScopeProvider; | ||
− | + | public void update(){ | |
+ | ScopeProvider.instance.set("/gcube/devsec"); | ||
+ | GenericResource generic = Resources.unmarshal(GenericResource.class, PublisherTest.class.getClassLoader().getResourceAsStream("generic2.xml")); | ||
+ | RegistryPublisher rp=RegistryPublisherFactory.create(); | ||
+ | Resource r=rp.update(generic); | ||
+ | } | ||
+ | </source> | ||
− | |||
− | + | Here it is an example of GenericResource remove by RegistryPublisher interface: | |
− | = | + | <source lang="Java"> |
+ | import org.gcube.common.resources.gcore.GenericResource; | ||
+ | import org.gcube.common.resources.gcore.Resource; | ||
+ | import org.gcube.common.resources.gcore.Resource.Type; | ||
+ | import org.gcube.common.resources.gcore.Resources; | ||
+ | import org.gcube.common.scope.api.ScopeProvider; | ||
− | + | public void create(){ | |
+ | ScopeProvider.instance.set("/gcube/devsec"); | ||
+ | GenericResource generic = Resources.unmarshal(GenericResource.class, PublisherTest.class.getClassLoader().getResourceAsStream("generic2.xml")); | ||
+ | RegistryPublisher rp=RegistryPublisherFactory.create(); | ||
+ | Resource r=rp.remove(generic); | ||
+ | } | ||
+ | </source> |
Latest revision as of 15:16, 6 November 2013
In conjunction with the IC-Client, the Registry-Publisher represents the mediation layer gCube Services, based on FWS, will rely on to interact with the Information Service as a whole.
Design
The Registry-Publisher is a Java library providing the implementation of two interfaces (RegistryPublisher and ScopedPublisher) that allow services to publish GCUBEResource as well as their state in the IS.
More specifically:
- by implementing the
org.gcube.common.core.informationsystem.publisher.RegistryPublisher
interface, the library allows gCube services to publish GCUBEResources and instances' states as of the gCube Resource Model defined in Common-gcore-resources; - by implementing the
org.gcube.informationsystem.publisher.ScopedPublisher
interface, the library allows gCube services to publish GCUBEResources and instances' states as of the gCube Resource Model defined in Common-gcore-resources in multi scope way;
Maven coordinates
The coordinates of the maven artifact are:
<dependency> <groupId>org.gcube.resources</groupId> <artifactId>registry-publisher</artifactId> <version>...</version> </dependency>
Check on Nexus for the latest version.
Publishing a resource
In order to publish a Resource the Registry-Publisher contacts the IS-Registry service of the current scope by invoking its appropriate operations.
Interfaces
The only difference between RegistryPublisher interface and ScopedPublisher interface is:
- RegistryPublisher interface publish resources on the current scope specified by ScopeProvider;
- ScopedPublisher interface publish resources on a List of scopes, calling for every scope the RegistryPublisher interface
RegistryPublisher interface
The following operation can be used to manage profiles on the IS:
- create() – takes as input parameter a resource (gCUBEResource), and returns the resource updated and filled of the current scope. The resource is created in the current scope and it is updated in the other scopes that are presents in the resource. If the current scope, set by ScopeProvider, is a VRE scope then in the resource will be added also the VO and INFRA scope if they are not present. If is a VO scope then, in the resource, will be added also the INFRA scope if it is not present;
- update() – takes as input parameter a message containing a resource and updates a resource previously registered in the IS. The resource will be updated on all the scopes that are defined in the resource. If an updating operation fail. It will be repeated with best-effort delivery approach
- remove() – takes as input parameter a resource and removes, from the current scope, the corresponding resource previously registered in the IS. It returns the resource without the scope removed;
ScopedPublisher interface
The following operation can be used to manage profiles on the IS:
- create() – takes as input parameters a resource (gCUBEResource), a list of String that identify operational scope and returns the resource updated and filled of the scope list. The resource will be updated on all the scopes specified in the input list calling, for every scope, the update() method of RegistryPublisher interface;;
- update() – takes as input parameters a resource and updates a resource previously registered in the IS.The resource will be updated on all the scopes that are defined in the resource. If an updating operation fail. It will be repeated with best-effort delivery approach.
- remove() – takes as input parameters a resource, a list of String that identify operational scope (GCUBEScope) and removes the corresponding resource previously registered in the IS from the scopes specified in the input list calling for every scope the remove() method of RegistryPublisher interface;
Sample usages
Here it is an example of GenericResource registration by RegistryPublisher interface:
import org.gcube.common.resources.gcore.GenericResource; import org.gcube.common.resources.gcore.Resource; import org.gcube.common.resources.gcore.Resource.Type; import org.gcube.common.resources.gcore.Resources; import org.gcube.common.scope.api.ScopeProvider; public void create(){ ScopeProvider.instance.set("/gcube/devsec"); GenericResource generic = Resources.unmarshal(GenericResource.class, PublisherTest.class.getClassLoader().getResourceAsStream("generic2.xml")); RegistryPublisher rp=RegistryPublisherFactory.create(); Resource r=rp.create(generic); }
Here it is an example of GenericResource registration by ScopedPublisher interface:
import org.gcube.common.resources.gcore.GenericResource; import org.gcube.common.resources.gcore.Resource; import org.gcube.common.resources.gcore.Resource.Type; import org.gcube.common.resources.gcore.Resources; import org.gcube.common.scope.api.ScopeProvider; public void create(){ ScopeProvider.instance.set("/gcube/devsec"); GenericResource generic = Resources.unmarshal(GenericResource.class, PublisherTest.class.getClassLoader().getResourceAsStream("generic2.xml")); List<String> scopes=new ArrayList<String>(); scopes.add("/gcube/devsec"); scopes.add("/gcube"); ScopedPublisher sp=RegistryPublisherFactory.scopedPublisher(); Resource r=sp.create(generic, scopes);
Here it is an example of GenericResource update by RegistryPublisher interface:
import org.gcube.common.resources.gcore.GenericResource; import org.gcube.common.resources.gcore.Resource; import org.gcube.common.resources.gcore.Resource.Type; import org.gcube.common.resources.gcore.Resources; import org.gcube.common.scope.api.ScopeProvider; public void update(){ ScopeProvider.instance.set("/gcube/devsec"); GenericResource generic = Resources.unmarshal(GenericResource.class, PublisherTest.class.getClassLoader().getResourceAsStream("generic2.xml")); RegistryPublisher rp=RegistryPublisherFactory.create(); Resource r=rp.update(generic); }
Here it is an example of GenericResource remove by RegistryPublisher interface:
import org.gcube.common.resources.gcore.GenericResource; import org.gcube.common.resources.gcore.Resource; import org.gcube.common.resources.gcore.Resource.Type; import org.gcube.common.resources.gcore.Resources; import org.gcube.common.scope.api.ScopeProvider; public void create(){ ScopeProvider.instance.set("/gcube/devsec"); GenericResource generic = Resources.unmarshal(GenericResource.class, PublisherTest.class.getClassLoader().getResourceAsStream("generic2.xml")); RegistryPublisher rp=RegistryPublisherFactory.create(); Resource r=rp.remove(generic); }