Class AmetysObjectCollectionFactory
- java.lang.Object
-
- org.apache.avalon.framework.logger.AbstractLogEnabled
-
- org.ametys.plugins.repository.jcr.SimpleAmetysObjectFactory
-
- org.ametys.plugins.repository.collection.AmetysObjectCollectionFactory
-
- All Implemented Interfaces:
AmetysObjectFactory<SimpleAmetysObject>
,JCRAmetysObjectFactory<SimpleAmetysObject>
,Component
,Configurable
,LogEnabled
,Serviceable
public class AmetysObjectCollectionFactory extends SimpleAmetysObjectFactory
Factory forAmetysObjectCollection
.
-
-
Field Summary
Fields Modifier and Type Field Description static String
COLLECTION_ELEMENT_NODETYPE
JCR nodetype for collection elements (ie.static String
COLLECTION_NODETYPE
JCR nodetype for the collection itself-
Fields inherited from class org.ametys.plugins.repository.jcr.SimpleAmetysObjectFactory
_ametysFactoryExtensionPoint, _manager, _nodetype, _repository, _resolver, _scheme
-
-
Constructor Summary
Constructors Constructor Description AmetysObjectCollectionFactory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
configure(Configuration configuration)
<A extends AmetysObject>
AcreateChild(String parentPath, Node parentNode, String name, String type)
Creates a child object in the collection and resolve it to anAmetysObject
.AmetysObjectCollection
getAmetysObject(Node node, String parentPath)
Creates aAmetysObject
from a persistent JCR node.AmetysObjectIterable
getChildren(String parentPath, Node collectionNode)
Returns theAmetysObject
s children of the JCR Node backing anAmetysObjectCollection
.
This method should never been called by clients.protected String[]
getHashedPath(String name)
Computes a hashed path in the JCR tree from the name of the child object.
Subclasses may override this method to provide a more suitable hash function.
This implementation relies on the buzhash algorithm.Collection<String>
getNodetypes()
Returns the nodetypes of theNode
associated with this factory.<A extends AmetysObject>
AgetObject(String parentPath, Node node, String subPath)
Returns a singleAmetysObject
given its path and JCR Node.
This method should never been called by clients.AmetysObject
getParent(AmetysObjectCollection object)
Returns the parent of the givenAmetysObjectCollection
String
getScheme()
Returns the protocol of this factory, used to construct unique ids.-
Methods inherited from class org.ametys.plugins.repository.jcr.SimpleAmetysObjectFactory
getAmetysObjectById, getAmetysObjectById, getNode, getParent, getWorkspaceNode, hasAmetysObjectForId, service
-
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
-
-
-
Field Detail
-
COLLECTION_NODETYPE
public static final String COLLECTION_NODETYPE
JCR nodetype for the collection itself- See Also:
- Constant Field Values
-
COLLECTION_ELEMENT_NODETYPE
public static final String COLLECTION_ELEMENT_NODETYPE
JCR nodetype for collection elements (ie. nodes "between" the collection and contained contents)- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AmetysObjectCollectionFactory
public AmetysObjectCollectionFactory()
-
-
Method Detail
-
configure
public void configure(Configuration configuration) throws ConfigurationException
- Specified by:
configure
in interfaceConfigurable
- Overrides:
configure
in classSimpleAmetysObjectFactory
- 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>
- Overrides:
getScheme
in classSimpleAmetysObjectFactory
- 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>
- Overrides:
getNodetypes
in classSimpleAmetysObjectFactory
- Returns:
- the nodetypes of the
Node
.
-
getAmetysObject
public AmetysObjectCollection 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>
- Overrides:
getAmetysObject
in classSimpleAmetysObjectFactory
- 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.
-
getHashedPath
protected String[] getHashedPath(String name)
Computes a hashed path in the JCR tree from the name of the child object.
Subclasses may override this method to provide a more suitable hash function.
This implementation relies on the buzhash algorithm. This method MUST return an array of the same length for each name.- Parameters:
name
- the name of the child object- Returns:
- a hashed path of the name.
-
getParent
public AmetysObject getParent(AmetysObjectCollection object) throws AmetysRepositoryException
Returns the parent of the givenAmetysObjectCollection
- Parameters:
object
- anAmetysObjectCollection
- Returns:
- the parent of the given
AmetysObjectCollection
- Throws:
AmetysRepositoryException
- if an error occurs
-
getObject
public <A extends AmetysObject> A getObject(String parentPath, Node node, String subPath) throws AmetysRepositoryException
Returns a singleAmetysObject
given its path and JCR Node.
This method should never been called by clients.- Type Parameters:
A
- the type of the compositeAmetysObject
.- Parameters:
parentPath
- the path of the collectionnode
- the node of the childsubPath
- the subpath in the Ametys hierarchy- Returns:
- an
AmetysObject
- Throws:
AmetysRepositoryException
- if an error occurs.
-
createChild
public <A extends AmetysObject> A createChild(String parentPath, Node parentNode, String name, String type) throws AmetysRepositoryException
Creates a child object in the collection and resolve it to anAmetysObject
.- Type Parameters:
A
- the type of the compositeAmetysObject
.- Parameters:
parentPath
- the parentPath of the new object.parentNode
- the parent JCR Node of the new object, corresponding to a collection element.name
- the name of the new object.type
- the type of the Node backing the new object.- Returns:
- the newly created
AmetysObject
. - Throws:
AmetysRepositoryException
- if an error occurs.
-
getChildren
public AmetysObjectIterable getChildren(String parentPath, Node collectionNode)
Returns theAmetysObject
s children of the JCR Node backing anAmetysObjectCollection
.
This method should never been called by clients.- Parameters:
parentPath
- the parent path in the Ametys hierarchy of allAmetysObject
being returned.collectionNode
- the JCR Node backing theAmetysObjectCollection
.- Returns:
- the
AmetysObject
s children.
-
-