Class AbstractResourceManager
- java.lang.Object
-
- org.gcube.resourcemanagement.support.server.managers.resources.AbstractResourceManager
-
- Direct Known Subclasses:
CollectionManager,GenericResourceManager,GHNManager,RunningInstanceManager,RuntimeResourceManager,ServiceManager
public abstract class AbstractResourceManager extends Object
The minimal interface all the resource managers must implement. Here is implemented the greatest part of the operations exposed in the official wiki.- Author:
- Daniele Strollo (ISTI-CNR), Massimiliano Assante (ISTI-CNR)
-
-
Constructor Summary
Constructors Constructor Description AbstractResourceManager(String id, String name, AllowedResourceTypes type)AbstractResourceManager(String id, String name, AllowedResourceTypes type, String subtype)AbstractResourceManager(String id, AllowedResourceTypes type)Instantiate the handler of a resource given its identifier and its type.AbstractResourceManager(AllowedResourceTypes type)Deprecated.discouraged use.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description StringaddToExistingScope(org.gcube.common.scope.impl.ScopeBean sourceScope, org.gcube.common.scope.impl.ScopeBean targetScope)Add a scope to a Resourceprotected abstract org.gcube.common.resources.gcore.ResourcebuildResource(String xmlRepresentation)Given the XML profile representation of a gcube resource, its GCUBEResource is built.StringcopyFromToVO(org.gcube.common.scope.impl.ScopeBean sourceScope, org.gcube.common.scope.impl.ScopeBean targetScope)Similar to theaddToExistingScope(org.gcube.common.scope.impl.ScopeBean, org.gcube.common.scope.impl.ScopeBean)method but involves two scopes of type VO.Stringdelete(org.gcube.common.scope.impl.ScopeBean scope)Removes a resource.voidforceDelete(org.gcube.common.scope.impl.ScopeBean scope)Deprecated.you must be sure before requiring this operation...StringgetID()All resources must be identifiable through an unique ID.StringgetName()All resources must have a valid name.org.gcube.informationsystem.publisher.RegistryPublishergetRegistryPublisher()The singleton ISPublisher instance is preferred.org.gcube.vremanagement.resourcemanager.client.RMReportingLibrarygetReportResourceManager(String scope)The report resource manager needed to handle the resource in a given scope.org.gcube.common.resources.gcore.ResourcegetResource(org.gcube.common.scope.impl.ScopeBean scope)From a resource retrieves its GCUBEResource depending on the scope in which it is published.org.gcube.vremanagement.resourcemanager.client.RMBinderLibrarygetResourceManager(String scope)The resource manager needed to handle the resource in a given scope.StringgetSubType()Resources can have a subtype (e.g.AllowedResourceTypesgetType()All resources have a type.protected StringgetXMLDescription(org.gcube.common.scope.impl.ScopeBean scope)Returns the XML profile of a resource (given its ID that is encapsulated inside the resource manager).StringremoveFromScope(org.gcube.common.scope.impl.ScopeBean scope)Removes the current resource from the scope.voidsetID(String id)protected List<org.gcube.common.scope.impl.ScopeBean>validateScopes(String[] scopes)Adds to scopes the required maps (if needed).
-
-
-
Constructor Detail
-
AbstractResourceManager
public AbstractResourceManager(AllowedResourceTypes type) throws ResourceParameterException, ResourceAccessException
Deprecated.discouraged use. With no ID some operations cannot be accessed. For internal use only.
-
AbstractResourceManager
public AbstractResourceManager(String id, AllowedResourceTypes type) throws ResourceParameterException, ResourceAccessException
Instantiate the handler of a resource given its identifier and its type. Notice that this constructor is implicitly invoked when instantiating the concrete resource manager (e.g. new GHNManager(id)).- Parameters:
id- the identifier of the resource the managetype- the type (GHN, RI, ...).- Throws:
ResourceParameterExceptionResourceAccessException
-
AbstractResourceManager
public AbstractResourceManager(String id, String name, AllowedResourceTypes type) throws ResourceParameterException, ResourceAccessException
-
AbstractResourceManager
public AbstractResourceManager(String id, String name, AllowedResourceTypes type, String subtype) throws ResourceParameterException, ResourceAccessException
-
-
Method Detail
-
getRegistryPublisher
public final org.gcube.informationsystem.publisher.RegistryPublisher getRegistryPublisher()
The singleton ISPublisher instance is preferred. All resource managers can internally access this instance to interact with ISPublisher to handle resources.- Returns:
-
getID
public final String getID()
All resources must be identifiable through an unique ID.
This field is mandatory- Returns:
-
setID
public final void setID(String id)
-
getName
public final String getName()
All resources must have a valid name. This field is mandatory- Returns:
-
getType
public final AllowedResourceTypes getType()
All resources have a type. This field is mandatory- Returns:
-
getSubType
public final String getSubType()
Resources can have a subtype (e.g. for GHNs is the domain). This field is optional- Returns:
-
getResourceManager
public final org.gcube.vremanagement.resourcemanager.client.RMBinderLibrary getResourceManager(String scope) throws AbstractResourceException
The resource manager needed to handle the resource in a given scope.- Parameters:
scope- the scope in which to operate- Returns:
- a random chosen manager from the avaiable ones
- Throws:
ResourceAccessException- if no manager can be instantiatedResourceParameterException- if the parameters are invalidAbstractResourceException
-
getReportResourceManager
public final org.gcube.vremanagement.resourcemanager.client.RMReportingLibrary getReportResourceManager(String scope) throws AbstractResourceException
The report resource manager needed to handle the resource in a given scope.- Parameters:
scope- the scope in which to operate- Returns:
- a random chosen manager from the avaiable ones
- Throws:
ResourceAccessException- if no manager can be instantiatedResourceParameterException- if the parameters are invalidAbstractResourceException
-
addToExistingScope
public final String addToExistingScope(org.gcube.common.scope.impl.ScopeBean sourceScope, org.gcube.common.scope.impl.ScopeBean targetScope) throws AbstractResourceException
Add a scope to a Resource- Parameters:
nestingPublication- true for resources different from gHN and RI.- Returns:
- the reportID generated
- Throws:
AbstractResourceException
-
copyFromToVO
public final String copyFromToVO(org.gcube.common.scope.impl.ScopeBean sourceScope, org.gcube.common.scope.impl.ScopeBean targetScope) throws AbstractResourceException
Similar to theaddToExistingScope(org.gcube.common.scope.impl.ScopeBean, org.gcube.common.scope.impl.ScopeBean)method but involves two scopes of type VO. Notice that this operation in reserved for resources different from gHN and RI. See here for further details.- Parameters:
sourceScope-targetScope-- Returns:
- Throws:
AbstractResourceException
-
buildResource
protected abstract org.gcube.common.resources.gcore.Resource buildResource(String xmlRepresentation) throws AbstractResourceException
Given the XML profile representation of a gcube resource, its GCUBEResource is built. Since it depends on the type of the resource, each concrete implementation of resource managers must implement it.- Parameters:
xmlRepresentation-- Returns:
- Throws:
AbstractResourceException
-
getResource
public final org.gcube.common.resources.gcore.Resource getResource(org.gcube.common.scope.impl.ScopeBean scope) throws AbstractResourceExceptionFrom a resource retrieves its GCUBEResource depending on the scope in which it is published.- Parameters:
scope-- Returns:
- Throws:
AbstractResourceException
-
getXMLDescription
protected final String getXMLDescription(org.gcube.common.scope.impl.ScopeBean scope) throws AbstractResourceException
Returns the XML profile of a resource (given its ID that is encapsulated inside the resource manager).- Parameters:
scope-- Returns:
- Throws:
AbstractResourceException
-
removeFromScope
public final String removeFromScope(org.gcube.common.scope.impl.ScopeBean scope) throws AbstractResourceException
Removes the current resource from the scope.- Parameters:
nestingRemoval- true for resources different from gHN and RI- Throws:
AbstractResourceException
-
validateScopes
protected List<org.gcube.common.scope.impl.ScopeBean> validateScopes(String[] scopes)
Adds to scopes the required maps (if needed). Internally used to ensure that the scopes at Infrastructure or VO level have correctly setup the maps.- Parameters:
scopes-- Returns:
-
forceDelete
public final void forceDelete(org.gcube.common.scope.impl.ScopeBean scope) throws AbstractResourceExceptionDeprecated.you must be sure before requiring this operation... take care- Parameters:
scope- where the resource is bound- Throws:
AbstractResourceException
-
delete
public final String delete(org.gcube.common.scope.impl.ScopeBean scope) throws AbstractResourceException
Removes a resource. According to the official wiki the resource is deleted only if is not bound in other scopes. Otherwise this operation simply corresponds to remove from scope.- Parameters:
scope-- Throws:
ResourceOperationExceptionAbstractResourceException
-
-