Class TraversableAmetysObjectHelper
java.lang.Object
org.ametys.plugins.repository.jcr.TraversableAmetysObjectHelper
Helper for implementing
TraversableAmetysObject
stored in JCR.-
Method Summary
Modifier and TypeMethodDescriptionstatic <A extends AmetysObject>
AcreateChild
(JCRTraversableAmetysObject object, JCRAmetysObjectFactory factory, String name, String type, AmetysObjectFactoryExtensionPoint ametysFactoryExtensionPoint, AmetysObjectResolver resolver, Logger logger) Creates a child to the given object.static <A extends AmetysObject>
AgetChild
(JCRTraversableAmetysObject object, JCRAmetysObjectFactory factory, String path, AmetysObjectResolver resolver, Logger logger) Returns theAmetysObject
at the given subPath, relative to the givenDefaultTraversableAmetysObject
.static <A extends AmetysObject>
AmetysObjectIterable<A>getChildren
(JCRTraversableAmetysObject object, JCRAmetysObjectFactory factory, AmetysObjectResolver resolver, Logger logger) Returns all children of the givenDefaultTraversableAmetysObject
.static boolean
hasChild
(JCRTraversableAmetysObject object, String name, AmetysObjectFactoryExtensionPoint ametysFactoryExtensionPoint, Logger logger) Tests if a given object has a child with a given name.
-
Method Details
-
getChild
public static <A extends AmetysObject> A getChild(JCRTraversableAmetysObject object, JCRAmetysObjectFactory factory, String path, AmetysObjectResolver resolver, Logger logger) throws AmetysRepositoryException, UnknownAmetysObjectException Returns theAmetysObject
at the given subPath, relative to the givenDefaultTraversableAmetysObject
.- Type Parameters:
A
- the actual type ofAmetysObject
.- Parameters:
object
- the contextDefaultTraversableAmetysObject
.factory
- the correspondingJCRAmetysObjectFactory
.path
- the sub path. Cannot benull
, empty or absolute.resolver
- theAmetysObjectResolver
.logger
- aLogger
for traces.- Returns:
- the
AmetysObject
at the given subPath, relative to the givenDefaultTraversableAmetysObject
. - Throws:
AmetysRepositoryException
- if an error occurs.UnknownAmetysObjectException
- if no such object exists.
-
getChildren
public static <A extends AmetysObject> AmetysObjectIterable<A> getChildren(JCRTraversableAmetysObject object, JCRAmetysObjectFactory factory, AmetysObjectResolver resolver, Logger logger) throws AmetysRepositoryException Returns all children of the givenDefaultTraversableAmetysObject
.- Type Parameters:
A
- the actual type ofAmetysObject
s- Parameters:
object
- aDefaultTraversableAmetysObject
.factory
- the correspondingJCRAmetysObjectFactory
.resolver
- theAmetysObjectResolver
.logger
- aLogger
for traces.- Returns:
- a List containing all children object in the Ametys hierarchy.
- Throws:
AmetysRepositoryException
- if an error occurs.
-
hasChild
public static boolean hasChild(JCRTraversableAmetysObject object, String name, AmetysObjectFactoryExtensionPoint ametysFactoryExtensionPoint, Logger logger) throws AmetysRepositoryException Tests if a given object has a child with a given name.- Parameters:
object
- the context object.name
- the name to test.ametysFactoryExtensionPoint
- theAmetysObjectFactoryExtensionPoint
.logger
- aLogger
for traces.- Returns:
true
is the given object has a child with the given name,false
otherwise.- Throws:
AmetysRepositoryException
- if an error occurs.
-
createChild
public static <A extends AmetysObject> A createChild(JCRTraversableAmetysObject object, JCRAmetysObjectFactory factory, String name, String type, AmetysObjectFactoryExtensionPoint ametysFactoryExtensionPoint, AmetysObjectResolver resolver, Logger logger) throws AmetysRepositoryException Creates a child to the given object.- Type Parameters:
A
- the actual type ofAmetysObject
.- Parameters:
object
- the parentAmetysObject
.factory
- the correspondingJCRAmetysObjectFactory
.name
- the new object's name.type
- the new object's type.ametysFactoryExtensionPoint
- theAmetysObjectFactoryExtensionPoint
.resolver
- theAmetysObjectResolver
.logger
- aLogger
for traces.- Returns:
- the newly created
AmetysObject
. - Throws:
AmetysRepositoryException
- if an error occurs.
-