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
_nodetype
The configured nodetypeprivate ObservationManager
_observationManager
protected Repository
_repository
JCR Repositoryprotected AmetysObjectResolver
_resolver
The applicationAmetysObjectResolver
protected String
_scheme
The configured schemeprivate Map<String,Session>
_sessionCache
static String
CMIS_ROOT_COLLECTION_NODETYPE
Nodetype 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 void
configure(Configuration configuration)
CMISRootResourcesCollection
getAmetysObject(Node node, String parentPath)
Creates aAmetysObject
from a persistent JCR node.AmetysObject
getAmetysObjectById(String id)
AmetysObject
getAmetysObjectById(String id, Session session)
Retrieves anAmetysObject
with the provided JCR Session, given its id.
Id are like<protocol>://<protocol-specific-part>
.Session
getAtomPubSession(CMISRootResourcesCollection root)
Opening a Atom Pub Connectionprotected CMISRootResourcesCollection
getCMISRootResourceCollection(String id)
Retrieves anCMISRootResourcesCollection
, given its id.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>
Collection<String>
getNodetypes()
Returns the nodetypes of theNode
associated with this factory.AmetysObject
getParent(CMISRootResourcesCollection object)
Returns the parent of the givenAmetysObject
.int
getPriority(Event event)
Retrieves the priority to observe this event.
This can be used to process a supported event before others observers.String
getScheme()
Returns the protocol of this factory, used to construct unique ids.boolean
hasAmetysObjectForId(String id)
Return true if the specified id correspond to an existingAmetysObject
.void
initialize()
void
observe(Event event, Map<String,Object> transientVars)
Observes an event.void
service(ServiceManager manager)
boolean
supports(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
-
_observationManager
private ObservationManager _observationManager
-
_sessionCache
private Map<String,Session> _sessionCache
-
-
Constructor Detail
-
CMISTreeFactory
public CMISTreeFactory()
-
-
Method Detail
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
configure
public void configure(Configuration configuration) throws ConfigurationException
- Specified by:
configure
in interfaceConfigurable
- Throws:
ConfigurationException
-
initialize
public void initialize() throws Exception
- Specified by:
initialize
in interfaceInitializable
- Throws:
Exception
-
getAmetysObject
public CMISRootResourcesCollection getAmetysObject(Node node, String parentPath) throws AmetysRepositoryException, RepositoryException
Description copied from interface:JCRAmetysObjectFactory
Creates aAmetysObject
from a persistent JCR node.- Specified by:
getAmetysObject
in interfaceJCRAmetysObjectFactory<AmetysObject>
- Parameters:
node
- the JCR node to use.parentPath
- the parent Path in the Ametys hierarchy, may benull
if 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:
getAmetysObjectById
in 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:JCRAmetysObjectFactory
Retrieves anAmetysObject
with the provided JCR Session, given its id.
Id are like<protocol>://<protocol-specific-part>
.- Specified by:
getAmetysObjectById
in 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:AmetysObjectFactory
Return true if the specified id correspond to an existingAmetysObject
. Id are like<protocol>://<protocol-specific-part>
.- Specified by:
hasAmetysObjectForId
in 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:AmetysObjectFactory
Returns the protocol of this factory, used to construct unique ids.- Specified by:
getScheme
in interfaceAmetysObjectFactory<AmetysObject>
- Returns:
- the protocol of this factory.
-
getNodetypes
public Collection<String> getNodetypes()
Description copied from interface:JCRAmetysObjectFactory
Returns the nodetypes of theNode
associated with this factory.- Specified by:
getNodetypes
in 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
null
if connection to CMIS server failed
-
getPriority
public int getPriority(Event event)
Description copied from interface:Observer
Retrieves the priority to observe this event.
This can be used to process a supported event before others observers.- Specified by:
getPriority
in 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:Observer
Checks 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:Observer
Observes an event.- Specified by:
observe
in 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.
-
-