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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classAmetysObjectCollectionFactory.WrapperNodeIterator
-
Field Summary
Fields Modifier and Type Field Description static StringCOLLECTION_ELEMENT_NODETYPEJCR nodetype for collection elements (ie.static StringCOLLECTION_NODETYPEJCR 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 private void_addFirstLevelChildren(String parentPath, List<AmetysObjectIterable> iterators, NodeIterator it, Session session)private void_addNextLevelChildren(String parentPath, List<AmetysObjectIterable> iterators, NodeIterator it, Session session)voidconfigure(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.AmetysObjectCollectiongetAmetysObject(Node node, String parentPath)Creates aAmetysObjectfrom a persistent JCR node.AmetysObjectIterablegetChildren(String parentPath, Node collectionNode)Returns theAmetysObjects 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 theNodeassociated with this factory.<A extends AmetysObject>
AgetObject(String parentPath, Node node, String subPath)Returns a singleAmetysObjectgiven its path and JCR Node.
This method should never been called by clients.AmetysObjectgetParent(AmetysObjectCollection object)Returns the parent of the givenAmetysObjectCollectionStringgetScheme()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:
configurein interfaceConfigurable- Overrides:
configurein classSimpleAmetysObjectFactory- 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>- Overrides:
getSchemein classSimpleAmetysObjectFactory- 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>- Overrides:
getNodetypesin classSimpleAmetysObjectFactory- Returns:
- the nodetypes of the
Node.
-
getAmetysObject
public AmetysObjectCollection getAmetysObject(Node node, String parentPath) throws AmetysRepositoryException, RepositoryException
Description copied from interface:JCRAmetysObjectFactoryCreates aAmetysObjectfrom a persistent JCR node.- Specified by:
getAmetysObjectin interfaceJCRAmetysObjectFactory<SimpleAmetysObject>- Overrides:
getAmetysObjectin classSimpleAmetysObjectFactory- 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.
-
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 singleAmetysObjectgiven 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 theAmetysObjects 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 allAmetysObjectbeing returned.collectionNode- the JCR Node backing theAmetysObjectCollection.- Returns:
- the
AmetysObjects children.
-
_addFirstLevelChildren
private void _addFirstLevelChildren(String parentPath, List<AmetysObjectIterable> iterators, NodeIterator it, Session session) throws RepositoryException
- Throws:
RepositoryException
-
_addNextLevelChildren
private void _addNextLevelChildren(String parentPath, List<AmetysObjectIterable> iterators, NodeIterator it, Session session) throws RepositoryException
- Throws:
RepositoryException
-
-