Package org.ametys.plugins.explorer.cmis
Class CMISTreeFactory
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.plugins.explorer.cmis.CMISTreeFactory
-
- All Implemented Interfaces:
Observer,AmetysObjectFactory<AmetysObject>,JCRAmetysObjectFactory<AmetysObject>,LogEnabled,Initializable,Component,Configurable,Serviceable
public class CMISTreeFactory extends AbstractLogEnabled implements JCRAmetysObjectFactory<AmetysObject>, Configurable, Serviceable, Initializable, Observer
Create the Root of CMIS Resources Collections
-
-
Field Summary
Fields Modifier and Type Field Description protected String_nodetypeThe configured nodetypeprotected Repository_repositoryJCR Repositoryprotected AmetysObjectResolver_resolverThe applicationAmetysObjectResolverprotected String_schemeThe configured schemestatic StringCMIS_ROOT_COLLECTION_NODETYPENodetype for resources collection-
Fields inherited from interface org.ametys.core.observation.Observer
MAX_PRIORITY, MIN_PRIORITY
-
-
Constructor Summary
Constructors Constructor Description CMISTreeFactory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidconfigure(Configuration configuration)CMISRootResourcesCollectiongetAmetysObject(Node node, String parentPath)Creates aAmetysObjectfrom a persistent JCR node.AmetysObjectgetAmetysObjectById(String id)AmetysObjectgetAmetysObjectById(String id, Session session)Retrieves anAmetysObjectwith the provided JCR Session, given its id.
Id are like<protocol>://<protocol-specific-part>.SessiongetAtomPubSession(CMISRootResourcesCollection root)Opening a Atom Pub Connectionprotected CMISRootResourcesCollectiongetCMISRootResourceCollection(String id)Retrieves anCMISRootResourcesCollection, given its id.protected NodegetNode(String id)Returns the JCR Node associated with the given object id.
This implementation assumes that the id is like<scheme>://<uuid>Collection<String>getNodetypes()Returns the nodetypes of theNodeassociated with this factory.AmetysObjectgetParent(CMISRootResourcesCollection object)Returns the parent of the givenAmetysObject.intgetPriority(Event event)Retrieves the priority to observe this event.
This can be used to process a supported event before others observers.StringgetScheme()Returns the protocol of this factory, used to construct unique ids.booleanhasAmetysObjectForId(String id)Return true if the specified id correspond to an existingAmetysObject.voidinitialize()voidobserve(Event event, Map<String,Object> transientVars)Observes an event.voidservice(ServiceManager manager)booleansupports(Event event)Checks if the event is supported.-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Field Detail
-
CMIS_ROOT_COLLECTION_NODETYPE
public static final String CMIS_ROOT_COLLECTION_NODETYPE
Nodetype for resources collection- See Also:
- Constant Field Values
-
_resolver
protected AmetysObjectResolver _resolver
The applicationAmetysObjectResolver
-
_repository
protected Repository _repository
JCR Repository
-
-
Constructor Detail
-
CMISTreeFactory
public CMISTreeFactory()
-
-
Method Detail
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
servicein interfaceServiceable- Throws:
ServiceException
-
configure
public void configure(Configuration configuration) throws ConfigurationException
- Specified by:
configurein interfaceConfigurable- Throws:
ConfigurationException
-
initialize
public void initialize() throws Exception
- Specified by:
initializein interfaceInitializable- Throws:
Exception
-
getAmetysObject
public CMISRootResourcesCollection getAmetysObject(Node node, String parentPath) throws AmetysRepositoryException, RepositoryException
Description copied from interface:JCRAmetysObjectFactoryCreates aAmetysObjectfrom a persistent JCR node.- Specified by:
getAmetysObjectin interfaceJCRAmetysObjectFactory<AmetysObject>- Parameters:
node- the JCR node to use.parentPath- the parent Path in the Ametys hierarchy, may benullif not known yet.- Returns:
- the object.
- Throws:
AmetysRepositoryException- if an error occurs.RepositoryException- if a JCR error occurs.
-
getAmetysObjectById
public AmetysObject getAmetysObjectById(String id) throws AmetysRepositoryException
Description copied from interface:AmetysObjectFactory- Specified by:
getAmetysObjectByIdin interfaceAmetysObjectFactory<AmetysObject>- Parameters:
id- the identifier.- Returns:
- the corresponding
AmetysObject. - Throws:
AmetysRepositoryException- if an error occurs.
-
getAmetysObjectById
public AmetysObject getAmetysObjectById(String id, Session session) throws AmetysRepositoryException, RepositoryException
Description copied from interface:JCRAmetysObjectFactoryRetrieves anAmetysObjectwith the provided JCR Session, given its id.
Id are like<protocol>://<protocol-specific-part>.- Specified by:
getAmetysObjectByIdin interfaceJCRAmetysObjectFactory<AmetysObject>- Parameters:
id- the identifier.session- the JCR Session to use to retrieve theAmetysObject.- Returns:
- the corresponding
AmetysObject. - Throws:
AmetysRepositoryException- if an error occurs.RepositoryException- if a JCR error occurs.
-
getCMISRootResourceCollection
protected CMISRootResourcesCollection getCMISRootResourceCollection(String id) throws AmetysRepositoryException
Retrieves anCMISRootResourcesCollection, given its id.- Parameters:
id- the identifier.- Returns:
- the corresponding
CMISRootResourcesCollection. - Throws:
AmetysRepositoryException- if an error occurs.
-
hasAmetysObjectForId
public boolean hasAmetysObjectForId(String id) throws AmetysRepositoryException
Description copied from interface:AmetysObjectFactoryReturn true if the specified id correspond to an existingAmetysObject. Id are like<protocol>://<protocol-specific-part>.- Specified by:
hasAmetysObjectForIdin interfaceAmetysObjectFactory<AmetysObject>- Parameters:
id- the identifier.- Returns:
- true if the specified id correspond to an existing
AmetysObject. - Throws:
AmetysRepositoryException- if an error occurs.
-
getScheme
public String getScheme()
Description copied from interface:AmetysObjectFactoryReturns the protocol of this factory, used to construct unique ids.- Specified by:
getSchemein interfaceAmetysObjectFactory<AmetysObject>- Returns:
- the protocol of this factory.
-
getNodetypes
public Collection<String> getNodetypes()
Description copied from interface:JCRAmetysObjectFactoryReturns the nodetypes of theNodeassociated with this factory.- Specified by:
getNodetypesin interfaceJCRAmetysObjectFactory<AmetysObject>- Returns:
- the nodetypes of the
Node.
-
getParent
public AmetysObject getParent(CMISRootResourcesCollection object) throws AmetysRepositoryException
Returns the parent of the givenAmetysObject.- Parameters:
object- aAmetysObject.- Returns:
- the parent of the given
AmetysObject. - Throws:
AmetysRepositoryException- if an error occurs.
-
getNode
protected Node getNode(String id)
Returns the JCR Node associated with the given object id.
This implementation assumes that the id is like<scheme>://<uuid>- Parameters:
id- the unique id of the object- Returns:
- the JCR Node associated with the given id
-
getAtomPubSession
public Session getAtomPubSession(CMISRootResourcesCollection root)
Opening a Atom Pub Connection- Parameters:
root- the JCR root folder- Returns:
- The created session or
nullif connection to CMIS server failed
-
getPriority
public int getPriority(Event event)
Description copied from interface:ObserverRetrieves the priority to observe this event.
This can be used to process a supported event before others observers.- Specified by:
getPriorityin interfaceObserver- Parameters:
event- the event.- Returns:
- the priority where 0 the max priority and Integer.MAX_VALUE the min priority.
-
supports
public boolean supports(Event event)
Description copied from interface:ObserverChecks if the event is supported. If true, the observe(Event) method will be called.
-
observe
public void observe(Event event, Map<String,Object> transientVars) throws Exception
Description copied from interface:ObserverObserves an event.- Specified by:
observein interfaceObserver- Parameters:
event- the event.transientVars- transientVars passed from one Observer to another when processing a single Event. This may allow optimizations between observers.- Throws:
Exception- if an error occurs. All exceptions will be logged but not propagated, as the observation mechanism should never fail.
-
-