Class SimpleAmetysObjectFactory
- java.lang.Object
-
- org.apache.avalon.framework.logger.AbstractLogEnabled
-
- org.ametys.plugins.repository.jcr.SimpleAmetysObjectFactory
-
- All Implemented Interfaces:
AmetysObjectFactory<SimpleAmetysObject>
,JCRAmetysObjectFactory<SimpleAmetysObject>
,Component
,Configurable
,LogEnabled
,Serviceable
- Direct Known Subclasses:
AmetysObjectCollectionFactory
,CatalogFactory
,ContentBackupAmetysObjectFactory
,DefaultAliasFactory
,DefaultAmetysObjectFactory
,DefaultDefinitionFactory
,DefaultThemeFactory
,DefaultTraversableAmetysObjectFactory
,DefaultZoneItemFactory
,VersionFactory
public class SimpleAmetysObjectFactory extends AbstractLogEnabled implements JCRAmetysObjectFactory<SimpleAmetysObject>, Configurable, Serviceable
Default implementation of anJCRAmetysObjectFactory
, handlingSimpleAmetysObject
.
This implementation takes its scheme and nodetype through a configuration:
<extension point="org.ametys.plugins.repository.AmetysObjectFactoryExtensionPoint"
id="XXXX" class="org.ametys.plugins.repository.DefaultAmetysObjectFactory">
<scheme>your_scheme</scheme>
<nodetype>your:nodetype</nodetype>
[<nodetype>your:nodetype2</nodetype>]
[...]
</extension>
This implementation manages only one nodetype.
-
-
Field Summary
Fields Modifier and Type Field Description protected AmetysObjectFactoryExtensionPoint
_ametysFactoryExtensionPoint
protected ServiceManager
_manager
The AvalonServiceManager
protected String
_nodetype
The configured nodetypeprotected Repository
_repository
JCR Repositoryprotected AmetysObjectResolver
_resolver
The applicationAmetysObjectResolver
protected String
_scheme
The configured scheme
-
Constructor Summary
Constructors Constructor Description SimpleAmetysObjectFactory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
configure(Configuration configuration)
SimpleAmetysObject
getAmetysObject(Node node, String parentPath)
Creates aAmetysObject
from a persistent JCR node.SimpleAmetysObject
getAmetysObjectById(String id)
SimpleAmetysObject
getAmetysObjectById(String id, Session session)
Retrieves anAmetysObject
with the provided JCR Session, given its id.
Id are like<protocol>://<protocol-specific-part>
.protected Node
getNode(String id, Session session)
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(SimpleAmetysObject object)
Returns the parent of the givenSimpleAmetysObject
.String
getScheme()
Returns the protocol of this factory, used to construct unique ids.protected Node
getWorkspaceNode(SimpleAmetysObject object)
Returns the JCR node backing thisSimpleAmetysObject
in the JCR workspace.boolean
hasAmetysObjectForId(String id)
Return true if the specified id correspond to an existingAmetysObject
.void
service(ServiceManager manager)
-
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
-
-
-
Field Detail
-
_resolver
protected AmetysObjectResolver _resolver
The applicationAmetysObjectResolver
-
_ametysFactoryExtensionPoint
protected AmetysObjectFactoryExtensionPoint _ametysFactoryExtensionPoint
-
_repository
protected Repository _repository
JCR Repository
-
_manager
protected ServiceManager _manager
The AvalonServiceManager
-
-
Constructor Detail
-
SimpleAmetysObjectFactory
public SimpleAmetysObjectFactory()
-
-
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
-
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<SimpleAmetysObject>
- 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<SimpleAmetysObject>
- Returns:
- the nodetypes of the
Node
.
-
getAmetysObject
public SimpleAmetysObject 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<SimpleAmetysObject>
- 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 SimpleAmetysObject getAmetysObjectById(String id) throws AmetysRepositoryException
Description copied from interface:AmetysObjectFactory
- Specified by:
getAmetysObjectById
in interfaceAmetysObjectFactory<SimpleAmetysObject>
- Parameters:
id
- the identifier.- Returns:
- the corresponding
AmetysObject
. - Throws:
AmetysRepositoryException
- if an error occurs.
-
getAmetysObjectById
public SimpleAmetysObject 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<SimpleAmetysObject>
- 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.
-
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<SimpleAmetysObject>
- Parameters:
id
- the identifier.- Returns:
- true if the specified id correspond to an existing
AmetysObject
. - Throws:
AmetysRepositoryException
- if an error occurs.
-
getNode
protected Node getNode(String id, Session session)
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 objectsession
- the JCR Session to use to retrieve the Node.- Returns:
- the JCR Node associated with the given id
-
getParent
public AmetysObject getParent(SimpleAmetysObject object) throws AmetysRepositoryException
Returns the parent of the givenSimpleAmetysObject
.- Parameters:
object
- aSimpleAmetysObject
.- Returns:
- the parent of the given
SimpleAmetysObject
. - Throws:
AmetysRepositoryException
- if an error occurs.
-
getWorkspaceNode
protected Node getWorkspaceNode(SimpleAmetysObject object)
Returns the JCR node backing thisSimpleAmetysObject
in the JCR workspace. May be overridden to deal with e.g. versionning- Parameters:
object
- aSimpleAmetysObject
.- Returns:
- the JCR node backing this
SimpleAmetysObject
.
-
-