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
Factory for
AmetysObjectCollection
.-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
JCR nodetype for collection elements (ie.static final String
JCR nodetype for the collection itselfFields inherited from class org.ametys.plugins.repository.jcr.SimpleAmetysObjectFactory
_ametysFactoryExtensionPoint, _manager, _nodetype, _repository, _resolver, _scheme
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
configure
(Configuration configuration) <A extends AmetysObject>
AcreateChild
(String parentPath, javax.jcr.Node parentNode, String name, String type) Creates a child object in the collection and resolve it to anAmetysObject
.getAmetysObject
(javax.jcr.Node node, String parentPath) Creates aAmetysObject
from a persistent JCR node.getChildren
(String parentPath, javax.jcr.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.Returns the nodetypes of theNode
associated with this factory.<A extends AmetysObject>
AReturns a singleAmetysObject
given its path and JCR Node.
This method should never been called by clients.getParent
(AmetysObjectCollection object) Returns the parent of the givenAmetysObjectCollection
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 Details
-
COLLECTION_NODETYPE
JCR nodetype for the collection itself- See Also:
-
COLLECTION_ELEMENT_NODETYPE
JCR nodetype for collection elements (ie. nodes "between" the collection and contained contents)- See Also:
-
-
Constructor Details
-
AmetysObjectCollectionFactory
public AmetysObjectCollectionFactory()
-
-
Method Details
-
configure
- Specified by:
configure
in interfaceConfigurable
- Overrides:
configure
in classSimpleAmetysObjectFactory
- 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>
- Overrides:
getScheme
in classSimpleAmetysObjectFactory
- 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>
- Overrides:
getNodetypes
in classSimpleAmetysObjectFactory
- Returns:
- the nodetypes of the
Node
.
-
getAmetysObject
public AmetysObjectCollection 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>
- 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.javax.jcr.RepositoryException
- if a JCR error occurs.
-
getHashedPath
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
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, javax.jcr.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, javax.jcr.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
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.
-