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_ametysFactoryExtensionPointprotected ServiceManager_managerThe AvalonServiceManagerprotected String_nodetypeThe configured nodetypeprotected Repository_repositoryJCR Repositoryprotected AmetysObjectResolver_resolverThe applicationAmetysObjectResolverprotected String_schemeThe configured scheme
-
Constructor Summary
Constructors Constructor Description SimpleAmetysObjectFactory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidconfigure(Configuration configuration)SimpleAmetysObjectgetAmetysObject(Node node, String parentPath)Creates aAmetysObjectfrom a persistent JCR node.SimpleAmetysObjectgetAmetysObjectById(String id)SimpleAmetysObjectgetAmetysObjectById(String id, Session session)Retrieves anAmetysObjectwith the provided JCR Session, given its id.
Id are like<protocol>://<protocol-specific-part>.protected NodegetNode(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 theNodeassociated with this factory.AmetysObjectgetParent(SimpleAmetysObject object)Returns the parent of the givenSimpleAmetysObject.StringgetScheme()Returns the protocol of this factory, used to construct unique ids.protected NodegetWorkspaceNode(SimpleAmetysObject object)Returns the JCR node backing thisSimpleAmetysObjectin the JCR workspace.booleanhasAmetysObjectForId(String id)Return true if the specified id correspond to an existingAmetysObject.voidservice(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:
servicein interfaceServiceable- Throws:
ServiceException
-
configure
public void configure(Configuration configuration) throws ConfigurationException
- Specified by:
configurein interfaceConfigurable- Throws:
ConfigurationException
-
getScheme
public String getScheme()
Description copied from interface:AmetysObjectFactoryReturns the protocol of this factory, used to construct unique ids.- Specified by:
getSchemein interfaceAmetysObjectFactory<SimpleAmetysObject>- 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<SimpleAmetysObject>- Returns:
- the nodetypes of the
Node.
-
getAmetysObject
public SimpleAmetysObject getAmetysObject(Node node, String parentPath) throws AmetysRepositoryException, RepositoryException
Description copied from interface:JCRAmetysObjectFactoryCreates aAmetysObjectfrom a persistent JCR node.- Specified by:
getAmetysObjectin interfaceJCRAmetysObjectFactory<SimpleAmetysObject>- 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 SimpleAmetysObject getAmetysObjectById(String id) throws AmetysRepositoryException
Description copied from interface:AmetysObjectFactory- Specified by:
getAmetysObjectByIdin 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:JCRAmetysObjectFactoryRetrieves anAmetysObjectwith the provided JCR Session, given its id.
Id are like<protocol>://<protocol-specific-part>.- Specified by:
getAmetysObjectByIdin 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:AmetysObjectFactoryReturn true if the specified id correspond to an existingAmetysObject. Id are like<protocol>://<protocol-specific-part>.- Specified by:
hasAmetysObjectForIdin 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 thisSimpleAmetysObjectin the JCR workspace. May be overridden to deal with e.g. versionning- Parameters:
object- aSimpleAmetysObject.- Returns:
- the JCR node backing this
SimpleAmetysObject.
-
-