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:
ActivityFactory
,AmetysObjectCollectionFactory
,CatalogFactory
,ContentBackupAmetysObjectFactory
,ContentConsistencyResultFactory
,DefaultAliasFactory
,DefaultAmetysObjectFactory
,DefaultDefinitionFactory
,DefaultThemeFactory
,DefaultTraversableAmetysObjectFactory
,DefaultZoneItemFactory
,FormEntryFactory
,FormPageRuleFactory
,VersionFactory
public class SimpleAmetysObjectFactory
extends AbstractLogEnabled
implements JCRAmetysObjectFactory<SimpleAmetysObject>, Configurable, Serviceable
Default implementation of an
This implementation takes its scheme and nodetype through a configuration:
JCRAmetysObjectFactory
,
handling SimpleAmetysObject
.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
Modifier and TypeFieldDescriptionprotected AmetysObjectFactoryExtensionPoint
protected ServiceManager
The AvalonServiceManager
protected String
The configured nodetypeprotected javax.jcr.Repository
JCR Repositoryprotected AmetysObjectResolver
The applicationAmetysObjectResolver
protected String
The configured scheme -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
configure
(Configuration configuration) getAmetysObject
(javax.jcr.Node node, String parentPath) Creates aAmetysObject
from a persistent JCR node.getAmetysObjectById
(String id, javax.jcr.Session session) Retrieves anAmetysObject
with the provided JCR Session, given its id.
Id are like<protocol>://<protocol-specific-part>
.protected javax.jcr.Node
Returns the JCR Node associated with the given object id.
This implementation assumes that the id is like<scheme>://<uuid>
Returns the nodetypes of theNode
associated with this factory.getParent
(SimpleAmetysObject object) Returns the parent of the givenSimpleAmetysObject
.Returns the protocol of this factory, used to construct unique ids.protected javax.jcr.Node
getWorkspaceNode
(SimpleAmetysObject object) Returns the JCR node backing thisSimpleAmetysObject
in the JCR workspace.boolean
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 Details
-
_resolver
The applicationAmetysObjectResolver
-
_ametysFactoryExtensionPoint
-
_scheme
The configured scheme -
_nodetype
The configured nodetype -
_repository
JCR Repository -
_manager
The AvalonServiceManager
-
-
Constructor Details
-
SimpleAmetysObjectFactory
public SimpleAmetysObjectFactory()
-
-
Method Details
-
service
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
configure
- Specified by:
configure
in interfaceConfigurable
- Throws:
ConfigurationException
-
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
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(javax.jcr.Node node, String parentPath) throws AmetysRepositoryException, javax.jcr.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.javax.jcr.RepositoryException
- if a JCR error occurs.
-
getAmetysObjectById
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, javax.jcr.Session session) throws AmetysRepositoryException, javax.jcr.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.javax.jcr.RepositoryException
- if a JCR error occurs.
-
hasAmetysObjectForId
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
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
Returns the parent of the givenSimpleAmetysObject
.- Parameters:
object
- aSimpleAmetysObject
.- Returns:
- the parent of the given
SimpleAmetysObject
. - Throws:
AmetysRepositoryException
- if an error occurs.
-
getWorkspaceNode
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
.
-