public class AmetysObjectResolver extends AbstractLogEnabled implements Serviceable, Initializable, Component
AmetysObject
s.Modifier and Type | Field and Description |
---|---|
private AmetysObjectFactoryExtensionPoint |
_ametysFactoryExtensionPoint |
private NodeTypeDefinitionsExtensionPoint |
_nodetypeDefsExtensionPoint |
private Repository |
_repository |
private SourceResolver |
_resolver |
static String |
OBJECT_TYPE
JCR mixin type for objects.
|
static String |
ROLE
Avalon ROLE.
|
static String |
ROOT_REPO
JCR Relative Path to root.
|
static String |
ROOT_TYPE
JCR type for root node.
|
static String |
VIRTUAL_PROPERTY
JCR property name for virtual objects.
|
Constructor and Description |
---|
AmetysObjectResolver() |
Modifier and Type | Method and Description |
---|---|
private JCRAmetysObjectFactory |
_getJCRFactory(String nodeType,
boolean allowUnknownNode,
String parentPath,
String childPath) |
private AmetysObject |
_getVirtualChild(JCRAmetysObject parent,
String childName,
Value[] values) |
private void |
_initNamespaces(Session session) |
private void |
_initNodetypes(Session session) |
private <T extends AmetysObject> |
_resolve(String parentPath,
Node node,
String childPath,
boolean allowUnknownNode) |
<A extends AmetysObject> |
createAndResolve(String parentPath,
Node parentNode,
String childName,
String nodetype)
Expert.
|
boolean |
hasAmetysObjectForId(String id)
Return true if the specified id correspond to an existing
AmetysObject . |
void |
initialize() |
<A extends AmetysObject> |
query(String jcrQuery)
Executes the given JCR XPath query and resolves results as
AmetysObject s.The resulting AmetysObjectIterable supports lazy loading, but
will also fail lazily if one if the result nodes does not correspond to
an AmetysObject . |
<A extends AmetysObject> |
query(String jcrQuery,
Session session)
Expert.
|
<A extends AmetysObject> |
resolve(Node node,
boolean allowUnknownNode)
Expert.
|
<A extends AmetysObject> |
resolve(String absolutePath)
Deprecated.
Use resolveByPath instead
|
<A extends AmetysObject> |
resolve(String parentPath,
Node node,
String childPath,
boolean allowUnknownNode)
Expert.
|
<A extends AmetysObject> |
resolveById(String id)
Retrieves an
AmetysObject by its unique id. |
<A extends AmetysObject> |
resolveById(String id,
Session session)
Expert.
|
<A extends AmetysObject> |
resolveByPath(String absolutePath)
Retrieves an
AmetysObject from an absolute path. |
AmetysObject |
resolveVirtualChild(JCRAmetysObject parent,
String childPath)
Expert.
|
<A extends AmetysObject> |
resolveVirtualChildren(JCRAmetysObject parent)
Expert.
|
void |
service(ServiceManager manager) |
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
public static final String ROOT_REPO
public static final String ROOT_TYPE
public static final String OBJECT_TYPE
public static final String VIRTUAL_PROPERTY
private AmetysObjectFactoryExtensionPoint _ametysFactoryExtensionPoint
private NodeTypeDefinitionsExtensionPoint _nodetypeDefsExtensionPoint
private Repository _repository
private SourceResolver _resolver
public AmetysObjectResolver()
public void service(ServiceManager manager) throws ServiceException
service
in interface Serviceable
ServiceException
public void initialize() throws Exception
initialize
in interface Initializable
Exception
private void _initNamespaces(Session session) throws RepositoryException
RepositoryException
private void _initNodetypes(Session session) throws RepositoryException, InvalidNodeTypeDefException, IOException
@Deprecated public <A extends AmetysObject> A resolve(String absolutePath) throws AmetysRepositoryException, UnknownAmetysObjectException
AmetysObject
from an absolute path.
The given path is absolute in the Ametys tree.'/'
, but the path
is always considered absolute, null
path is forbidden.A
- the actual type of AmetysObject
.absolutePath
- the path to use.AmetysRepositoryException
- if an error occurs.UnknownAmetysObjectException
- if no such object exists for the given path.public <A extends AmetysObject> A resolveByPath(String absolutePath) throws AmetysRepositoryException, UnknownAmetysObjectException
AmetysObject
from an absolute path.
The given path is absolute in the Ametys tree.'/'
, but the path
is always considered absolute, null
path is forbidden.A
- the actual type of AmetysObject
.absolutePath
- the path to use.AmetysRepositoryException
- if an error occurs.UnknownAmetysObjectException
- if no such object exists for the given path.public <A extends AmetysObject> A resolveById(String id) throws AmetysRepositoryException, UnknownAmetysObjectException
AmetysObject
by its unique id.A
- the actual type of AmetysObject
.id
- the identifier representing the wanted AmetysObject
is the Ametys repository.AmetysObject
.AmetysRepositoryException
- if an error occurs.UnknownAmetysObjectException
- if no such object exists for the given id.public <A extends AmetysObject> A resolveById(String id, Session session) throws AmetysRepositoryException, UnknownAmetysObjectException, RepositoryException
AmetysObject
by its unique id and the provided JCR Session.JCRAmetysObjectFactory
.A
- the actual type of AmetysObject
.id
- the identifier representing the wanted AmetysObject
is the Ametys repository.session
- the JCR Session to use to retrieve the AmetysObject
.AmetysObject
.AmetysRepositoryException
- if an error occurs.UnknownAmetysObjectException
- if no such object exists for the given id.RepositoryException
- if a JCR error occurs.public boolean hasAmetysObjectForId(String id) throws AmetysRepositoryException
AmetysObject
.id
- the identifier.AmetysObject
.AmetysRepositoryException
- if an error occurs.public <A extends AmetysObject> A resolve(Node node, boolean allowUnknownNode) throws AmetysRepositoryException, RepositoryException
AmetysObject
corresponding to a given JCR Node.resolve(null, node, null, allowUnknownNode)
A
- the actual type of AmetysObject
snode
- an existing node in the underlying JCR repository.allowUnknownNode
- if true
, returns null
if the node type
does not correspond to a factory. If false
and no factory
corresponds, an AmetysRepositoryException
is thrown.AmetysObject
corresponding to a given JCR node.AmetysRepositoryException
- if an error occurs.RepositoryException
- if a JCR error occurs.public <A extends AmetysObject> A resolve(String parentPath, Node node, String childPath, boolean allowUnknownNode) throws AmetysRepositoryException, UnknownAmetysObjectException, RepositoryException
AmetysObject
, given a JCR Node, a relative path
and the parentPath in the Ametys hierarchy.'/'
,
null
path or empty path are equivalent.A
- the actual type of AmetysObject
.parentPath
- the parentPath of the returned AmetysObject, in the Ametys hierarchy.node
- the context JCR node.childPath
- the path relative to the JCR node.allowUnknownNode
- if true
, returns null
if the node type
does not correspond to a factory. If false
and no factory
corresponds, an AmetysRepositoryException
is thrown.AmetysRepositoryException
- if an error occurs.UnknownAmetysObjectException
- if no such object exists for the given path.RepositoryException
- if a JCR error occurs.private <T extends AmetysObject> T _resolve(String parentPath, Node node, String childPath, boolean allowUnknownNode) throws AmetysRepositoryException, UnknownAmetysObjectException, RepositoryException
private JCRAmetysObjectFactory _getJCRFactory(String nodeType, boolean allowUnknownNode, String parentPath, String childPath)
public <A extends AmetysObject> AmetysObjectIterable<A> resolveVirtualChildren(JCRAmetysObject parent) throws AmetysRepositoryException, RepositoryException
A
- the actual type of AmetysObject
s.parent
- the JCRAmetysObject
"hosting" the VirtualAmetysObjectFactory
reference.AmetysRepositoryException
- if an error occurs.RepositoryException
- if a JCR error occurs.public AmetysObject resolveVirtualChild(JCRAmetysObject parent, String childPath) throws AmetysRepositoryException, RepositoryException, UnknownAmetysObjectException
parent
- the JCRAmetysObject
"hosting" the VirtualAmetysObjectFactory
reference.childPath
- the name of the virtual child.AmetysRepositoryException
- if an error occurs.RepositoryException
- if a JCR error occurs.UnknownAmetysObjectException
- if the named child does not existpublic <A extends AmetysObject> AmetysObjectIterable<A> query(String jcrQuery)
AmetysObject
s.AmetysObjectIterable
supports lazy loading, but
will also fail lazily if one if the result nodes does not correspond to
an AmetysObject
.A
- the actual type of the results.jcrQuery
- a JCR XPath query.AmetysObject
.public <A extends AmetysObject> AmetysObjectIterable<A> query(String jcrQuery, Session session) throws RepositoryException
AmetysObject
s.AmetysObjectIterable
supports lazy loading, but
will also fail lazily if one if the result nodes does not correspond to
an AmetysObject
.A
- the actual type of the results.jcrQuery
- a JCR XPath query.session
- the JCR Session to use to execute the request.AmetysObject
.RepositoryException
- if a JCR error occurs.private AmetysObject _getVirtualChild(JCRAmetysObject parent, String childName, Value[] values) throws RepositoryException
RepositoryException
public <A extends AmetysObject> A createAndResolve(String parentPath, Node parentNode, String childName, String nodetype) throws AmetysRepositoryException, RepositoryIntegrityViolationException, RepositoryException
AmetysObject
.A
- the actual type of AmetysObject
sparentPath
- the parentPath of the new object.parentNode
- the parent JCR Node of the new object.childName
- the name of the new object.nodetype
- the type of the Node backing the new object.AmetysObject
.AmetysRepositoryException
- if an error occurs.RepositoryIntegrityViolationException
- if an object with the same name already
exists and same name siblings is not allowed.RepositoryException
- if a JCR error occurs.