public class JcrUtils
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static Value[] |
NO_VALUES
A pre-allocated empty array of values.
|
static java.lang.String |
REPOSITORY_URI
The repository URI parameter name used by the
getRepository(String) method. |
Modifier and Type | Method and Description |
---|---|
static Binary |
getBinaryProperty(Node baseNode,
java.lang.String relPath,
Binary defaultValue)
Returns the binary property value at
relPath from baseNode or defaultValue
if no such property exists. |
static Binary |
getBinaryProperty(Session session,
java.lang.String absPath,
Binary defaultValue)
Returns the binary property value at
absPath or defaultValue
if no such property exists. |
static boolean |
getBooleanProperty(Node baseNode,
java.lang.String relPath,
boolean defaultValue)
Returns the boolean property value at
relPath from baseNode or defaultValue
if no such property exists. |
static boolean |
getBooleanProperty(Session session,
java.lang.String absPath,
boolean defaultValue)
Returns the boolean property value at
absPath or defaultValue
if no such property exists. |
static java.lang.Iterable<Node> |
getChildNodes(Node node)
Returns an
Iterable over the children of the given node. |
static java.lang.Iterable<Node> |
getChildNodes(Node node,
java.lang.String pattern)
Returns an
Iterable over those children of the given node
that match the given name pattern. |
static java.lang.Iterable<Node> |
getChildNodes(Node node,
java.lang.String[] globs)
Returns an
Iterable over those children of the given node
that match the given name patterns. |
static java.util.Calendar |
getDateProperty(Node baseNode,
java.lang.String relPath,
java.util.Calendar defaultValue)
Returns the date property value at
relPath from baseNode or defaultValue
if no such property exists. |
static java.util.Calendar |
getDateProperty(Session session,
java.lang.String absPath,
java.util.Calendar defaultValue)
Returns the date property value at
absPath or defaultValue
if no such property exists. |
static java.math.BigDecimal |
getDecimalProperty(Node baseNode,
java.lang.String relPath,
java.math.BigDecimal defaultValue)
Returns the decimal property value at
relPath from baseNode or defaultValue
if no such property exists. |
static java.math.BigDecimal |
getDecimalProperty(Session session,
java.lang.String absPath,
java.math.BigDecimal defaultValue)
Returns the decimal property value at
absPath or defaultValue
if no such property exists. |
static double |
getDoubleProperty(Node baseNode,
java.lang.String relPath,
double defaultValue)
Returns the double property value at
relPath from baseNode or defaultValue
if no such property exists. |
static double |
getDoubleProperty(Session session,
java.lang.String absPath,
double defaultValue)
Returns the double property value at
absPath or defaultValue
if no such property exists. |
static java.util.Calendar |
getLastModified(Node node)
Returns the last modified date of the given file node.
|
static long |
getLongProperty(Node baseNode,
java.lang.String relPath,
long defaultValue)
Returns the long property value at
relPath from baseNode or defaultValue
if no such property exists. |
static long |
getLongProperty(Session session,
java.lang.String absPath,
long defaultValue)
Returns the long property value at
absPath or defaultValue
if no such property exists. |
static Node |
getNodeIfExists(Node baseNode,
java.lang.String relPath)
Get the node at
relPath from baseNode or null if no such node exists. |
static Node |
getNodeIfExists(java.lang.String absPath,
Session session)
Gets the node at
absPath or null if no such node exists. |
static java.lang.Iterable<Node> |
getNodes(QueryResult result)
Returns an
Iterable over nodes in the given query result. |
static Node |
getOrAddFolder(Node parent,
java.lang.String name)
Returns the named child of the given node, creating it as an
nt:folder node if it does not already exist.
|
static Node |
getOrAddNode(Node parent,
java.lang.String name)
Returns the named child of the given node, creating the child if
it does not already exist.
|
static Node |
getOrAddNode(Node parent,
java.lang.String name,
java.lang.String type)
Returns the named child of the given node, creating the child if
it does not already exist.
|
static Node |
getOrCreateByPath(Node baseNode,
java.lang.String path,
boolean createUniqueLeaf,
java.lang.String intermediateNodeType,
java.lang.String nodeType,
boolean autoSave)
Creates or gets the
node at the given path
relative to the baseNode. |
static Node |
getOrCreateByPath(java.lang.String absolutePath,
boolean createUniqueLeaf,
java.lang.String intermediateNodeType,
java.lang.String nodeType,
Session session,
boolean autoSave)
Creates or gets the
Node at the given Path. |
static Node |
getOrCreateByPath(java.lang.String absolutePath,
java.lang.String nodeType,
Session session)
Creates or gets the
Node at the given Path. |
static Node |
getOrCreateByPath(java.lang.String absolutePath,
java.lang.String intermediateNodeType,
java.lang.String nodeType,
Session session,
boolean autoSave)
Creates or gets the
Node at the given Path. |
static Node |
getOrCreateUniqueByPath(Node parent,
java.lang.String nodeNameHint,
java.lang.String nodeType)
Creates or gets the
node at the given path. |
static Node |
getOrCreateUniqueByPath(java.lang.String pathHint,
java.lang.String nodeType,
Session session)
Creates a
Node at the given Path. |
static java.lang.Iterable<Property> |
getProperties(Node node)
Returns an
Iterable over the properties of the given node. |
static java.lang.Iterable<Property> |
getProperties(Node node,
java.lang.String pattern)
Returns an
Iterable over those properties of the
given node that match the given name pattern. |
static java.lang.Iterable<Property> |
getProperties(Node node,
java.lang.String[] globs)
Returns an
Iterable over those properties of the
given node that match the given name patterns. |
static int |
getPropertyType(java.lang.String name)
Returns the numeric constant value of the property type with
the specified name.
|
static java.lang.String[] |
getPropertyTypeNames(boolean includeUndefined)
Return the property type names including or excluding 'undefined' depending
on the specified flag.
|
static java.lang.Iterable<Property> |
getReferences(Node node)
Returns an
Iterable over references to the given node. |
static java.lang.Iterable<Property> |
getReferences(Node node,
java.lang.String name)
Returns an
Iterable over those references to the
given node that have the given name. |
static Repository |
getRepository()
Returns the default repository of the current environment.
|
static Repository |
getRepository(java.util.Map<java.lang.String,java.lang.String> parameters)
Looks up the available
repository factories
and returns the repository that one of the factories
returns for the given settings. |
static Repository |
getRepository(java.lang.String uri)
Returns the repository identified by the given URI.
|
static java.lang.Iterable<Row> |
getRows(QueryResult result)
Returns an
Iterable over nodes in the given query result. |
static java.lang.Iterable<Node> |
getSharedSet(Node node)
Returns an
Iterable over the shared set of the given node. |
static java.lang.String |
getStringProperty(Node baseNode,
java.lang.String relPath,
java.lang.String defaultValue)
Returns the string property value at
relPath from baseNode or defaultValue
if no such property exists. |
static java.lang.String |
getStringProperty(Session session,
java.lang.String absPath,
java.lang.String defaultValue)
Returns the string property value at
absPath or defaultValue
if no such property exists. |
static java.lang.Iterable<Property> |
getWeakReferences(Node node)
Returns an
Iterable over weak references to the given node. |
static java.lang.Iterable<Property> |
getWeakReferences(Node node,
java.lang.String name)
Returns an
Iterable over those weak references to the
given node that have the given name. |
static java.lang.Iterable<AccessControlPolicyIterator> |
in(AccessControlPolicyIterator iterator)
Transform an
AccessControlPolicyIterator into an Iterable
for single use in a Java 5 for-each loop. |
static java.lang.Iterable<Event> |
in(EventIterator iterator)
Transform an
EventIterator into an Iterable
for single use in a Java 5 for-each loop. |
static java.lang.Iterable<EventListener> |
in(EventListenerIterator iterator)
Transform an
EventListenerIterator into an Iterable
for single use in a Java 5 for-each loop. |
static <I> java.lang.Iterable<I> |
in(java.util.Iterator<I> iterator)
Transform any type of
Iterator into an Iterable
for single use in a Java 5 for-each loop. |
static java.lang.Iterable<Node> |
in(NodeIterator iterator)
Transform an
NodeIterator into an Iterable
for single use in a Java 5 for-each loop. |
static java.lang.Iterable<NodeType> |
in(NodeTypeIterator iterator)
Transform an
NodeTypeIterator into an Iterable
for single use in a Java 5 for-each loop. |
static java.lang.Iterable<Property> |
in(PropertyIterator iterator)
Transform an
PropertyIterator into an Iterable
for single use in a Java 5 for-each loop. |
static java.lang.Iterable<Row> |
in(RowIterator iterator)
Transform an
RowIterator into an Iterable
for single use in a Java 5 for-each loop. |
static java.lang.Iterable<Version> |
in(VersionIterator iterator)
Transform an
VersionIterator into an Iterable
for single use in a Java 5 for-each loop. |
static Node |
putFile(Node parent,
java.lang.String name,
java.lang.String mime,
java.io.InputStream data)
Creates or updates the named child of the given node.
|
static Node |
putFile(Node parent,
java.lang.String name,
java.lang.String mime,
java.io.InputStream data,
java.util.Calendar date)
Creates or updates the named child of the given node.
|
static java.io.InputStream |
readFile(Node node)
Returns a stream for reading the contents of the file stored at the
given node.
|
static void |
readFile(Node node,
java.io.OutputStream output)
Writes the contents of file stored at the given node to the given
stream.
|
static void |
setLastModified(Node node,
java.util.Calendar date)
Sets the last modified date of the given file node.
|
static java.lang.String |
toString(Item item)
Returns a string representation of the given item.
|
public static final java.lang.String REPOSITORY_URI
getRepository(String)
method. All RepositoryFactory
implementations that want to support this repository access convention
should implement processing of this parameter.
Client applications are recommended to use the
getRepository(String)
method instead of directly referencing
this constant unless they explicitly want to pass also other
RepositoryFactory
parameters through the
getRepository(Map)
method.
public static final Value[] NO_VALUES
public static Repository getRepository() throws RepositoryException
getRepository(Map)
with a
null
parameter map.RepositoryException
- if a default repository is not available
or can not be accessedRepositoryFactory.getRepository(Map)
public static Repository getRepository(java.util.Map<java.lang.String,java.lang.String> parameters) throws RepositoryException
repository factories
and returns the repository
that one of the factories
returns for the given settings.
Note that unlike RepositoryFactory.getRepository(Map)
this
method will throw an exception instead of returning null
if the given parameters can not be interpreted.
parameters
- repository settingsRepositoryException
- if the repository can not be accessed,
or if an appropriate repository factory
is not availablepublic static Repository getRepository(java.lang.String uri) throws RepositoryException
getRepository(Map)
method
with the REPOSITORY_URI
parameter set to the given URI.
Any query parameters are moved from the URI to the parameter map.
See the documentation of the repository implementation you want to use for whether it supports this repository URI convention and for what the repository URI should look like. For example, Jackrabbit 2.0 supports the following types of repository URIs:
JndiRepositoryFactory
class for more details.
uri
- repository URIRepositoryException
- if the repository can not be accessed,
or if the given URI is unknown or invalidpublic static java.lang.Iterable<Node> getSharedSet(Node node) throws RepositoryException
Iterable
over the shared set of the given node.
The first iterator is acquired directly during this method call to
allow a possible RepositoryException
to be thrown as-is.
Further iterators are acquired lazily when needed, with possible
RepositoryException
s wrapped into RuntimeException
s.
node
- shared nodeRepositoryException
- if the Node.getSharedSet()
call failsNode.getSharedSet()
public static java.lang.Iterable<Node> getChildNodes(Node node) throws RepositoryException
Iterable
over the children of the given node.
The first iterator is acquired directly during this method call to
allow a possible RepositoryException
to be thrown as-is.
Further iterators are acquired lazily when needed, with possible
RepositoryException
s wrapped into RuntimeException
s.
node
- parent nodeRepositoryException
- if the Node.getNodes()
call failsNode.getNodes()
public static java.lang.Iterable<Node> getChildNodes(Node node, java.lang.String pattern) throws RepositoryException
Iterable
over those children of the given node
that match the given name pattern.
The first iterator is acquired directly during this method call to
allow a possible RepositoryException
to be thrown as-is.
Further iterators are acquired lazily when needed, with possible
RepositoryException
s wrapped into RuntimeException
s.
node
- parent nodepattern
- node name patternRepositoryException
- if the Node.getNodes(String)
call failsNode.getNodes(String)
public static java.lang.Iterable<Node> getChildNodes(Node node, java.lang.String[] globs) throws RepositoryException
Iterable
over those children of the given node
that match the given name patterns.
The first iterator is acquired directly during this method call to
allow a possible RepositoryException
to be thrown as-is.
Further iterators are acquired lazily when needed, with possible
RepositoryException
s wrapped into RuntimeException
s.
node
- parent nodeglobs
- node name patternRepositoryException
- if the Node.getNodes(String[])
call failsNode.getNodes(String[])
public static java.lang.Iterable<Property> getProperties(Node node) throws RepositoryException
Iterable
over the properties of the given node.
The first iterator is acquired directly during this method call to
allow a possible RepositoryException
to be thrown as-is.
Further iterators are acquired lazily when needed, with possible
RepositoryException
s wrapped into RuntimeException
s.
node
- nodeRepositoryException
- if the Node.getProperties()
call failsNode.getProperties()
public static java.lang.Iterable<Property> getProperties(Node node, java.lang.String pattern) throws RepositoryException
Iterable
over those properties of the
given node that match the given name pattern.
The first iterator is acquired directly during this method call to
allow a possible RepositoryException
to be thrown as-is.
Further iterators are acquired lazily when needed, with possible
RepositoryException
s wrapped into RuntimeException
s.
node
- nodepattern
- property name patternRepositoryException
- if the Node.getProperties(String)
call failsNode.getProperties(String)
public static java.lang.Iterable<Property> getProperties(Node node, java.lang.String[] globs) throws RepositoryException
Iterable
over those properties of the
given node that match the given name patterns.
The first iterator is acquired directly during this method call to
allow a possible RepositoryException
to be thrown as-is.
Further iterators are acquired lazily when needed, with possible
RepositoryException
s wrapped into RuntimeException
s.
node
- nodeglobs
- property name globsRepositoryException
- if the Node.getProperties(String[])
call failsNode.getProperties(String[])
public static java.lang.Iterable<Property> getReferences(Node node) throws RepositoryException
Iterable
over references to the given node.
The first iterator is acquired directly during this method call to
allow a possible RepositoryException
to be thrown as-is.
Further iterators are acquired lazily when needed, with possible
RepositoryException
s wrapped into RuntimeException
s.
node
- reference targetRepositoryException
- if the Node.getReferences()
call failsNode.getReferences()
public static java.lang.Iterable<Property> getReferences(Node node, java.lang.String name) throws RepositoryException
Iterable
over those references to the
given node that have the given name.
The first iterator is acquired directly during this method call to
allow a possible RepositoryException
to be thrown as-is.
Further iterators are acquired lazily when needed, with possible
RepositoryException
s wrapped into RuntimeException
s.
node
- reference targetname
- reference property nameRepositoryException
- if the Node.getReferences(String)
call failsNode.getReferences(String)
public static java.lang.Iterable<Property> getWeakReferences(Node node) throws RepositoryException
Iterable
over weak references to the given node.
The first iterator is acquired directly during this method call to
allow a possible RepositoryException
to be thrown as-is.
Further iterators are acquired lazily when needed, with possible
RepositoryException
s wrapped into RuntimeException
s.
node
- reference targetRepositoryException
- if the Node.getWeakReferences()
call failsNode.getWeakReferences()
public static java.lang.Iterable<Property> getWeakReferences(Node node, java.lang.String name) throws RepositoryException
Iterable
over those weak references to the
given node that have the given name.
The first iterator is acquired directly during this method call to
allow a possible RepositoryException
to be thrown as-is.
Further iterators are acquired lazily when needed, with possible
RepositoryException
s wrapped into RuntimeException
s.
node
- reference targetname
- reference property nameRepositoryException
- if the Node.getWeakReferences(String)
call failsNode.getWeakReferences(String)
public static java.lang.Iterable<Node> getNodes(QueryResult result) throws RepositoryException
Iterable
over nodes in the given query result.
The first iterator is acquired directly during this method call to
allow a possible RepositoryException
to be thrown as-is.
Further iterators are acquired lazily when needed, with possible
RepositoryException
s wrapped into RuntimeException
s.
result
- query resultRepositoryException
- if the QueryResult.getNodes()
call failsQueryResult.getNodes()
public static java.lang.Iterable<Row> getRows(QueryResult result) throws RepositoryException
Iterable
over nodes in the given query result.
The first iterator is acquired directly during this method call to
allow a possible RepositoryException
to be thrown as-is.
Further iterators are acquired lazily when needed, with possible
RepositoryException
s wrapped into RuntimeException
s.
result
- query resultRepositoryException
- if the QueryResult.getRows()
call failsQueryResult.getRows()
public static <I> java.lang.Iterable<I> in(java.util.Iterator<I> iterator)
Iterator
into an Iterable
for single use in a Java 5 for-each loop.
While general purpose Iterables
tend to be reusable,
this wrapper Iterable
consumes the argument
Iterator
, leaving it in a non-reusable state. The returned
Iterable
will throw an IllegalStateException
if
its iterator()
method is invoked a second time.
I
- typeiterator
- The input Iterator
Iterable
public static java.lang.Iterable<AccessControlPolicyIterator> in(AccessControlPolicyIterator iterator)
AccessControlPolicyIterator
into an Iterable
for single use in a Java 5 for-each loop.
While general purpose Iterables
tend to be reusable,
this wrapper Iterable
consumes the argument
Iterator
, leaving it in a non-reusable state. The returned
Iterable
will throw an IllegalStateException
if
its iterator()
method is invoked a second time.
iterator
- The input Iterator
Iterable
public static java.lang.Iterable<Event> in(EventIterator iterator)
EventIterator
into an Iterable
for single use in a Java 5 for-each loop.
While general purpose Iterables
tend to be reusable,
this wrapper Iterable
consumes the argument
Iterator
, leaving it in a non-reusable state. The returned
Iterable
will throw an IllegalStateException
if
its iterator()
method is invoked a second time.
iterator
- The input Iterator
Iterable
public static java.lang.Iterable<EventListener> in(EventListenerIterator iterator)
EventListenerIterator
into an Iterable
for single use in a Java 5 for-each loop.
While general purpose Iterables
tend to be reusable,
this wrapper Iterable
consumes the argument
Iterator
, leaving it in a non-reusable state. The returned
Iterable
will throw an IllegalStateException
if
its iterator()
method is invoked a second time.
iterator
- The input Iterator
Iterable
public static java.lang.Iterable<Node> in(NodeIterator iterator)
NodeIterator
into an Iterable
for single use in a Java 5 for-each loop.
While general purpose Iterables
tend to be reusable,
this wrapper Iterable
consumes the argument
Iterator
, leaving it in a non-reusable state. The returned
Iterable
will throw an IllegalStateException
if
its iterator()
method is invoked a second time.
iterator
- The input Iterator
Iterable
public static java.lang.Iterable<NodeType> in(NodeTypeIterator iterator)
NodeTypeIterator
into an Iterable
for single use in a Java 5 for-each loop.
While general purpose Iterables
tend to be reusable,
this wrapper Iterable
consumes the argument
Iterator
, leaving it in a non-reusable state. The returned
Iterable
will throw an IllegalStateException
if
its iterator()
method is invoked a second time.
iterator
- The input Iterator
Iterable
public static java.lang.Iterable<Property> in(PropertyIterator iterator)
PropertyIterator
into an Iterable
for single use in a Java 5 for-each loop.
While general purpose Iterables
tend to be reusable,
this wrapper Iterable
consumes the argument
Iterator
, leaving it in a non-reusable state. The returned
Iterable
will throw an IllegalStateException
if
its iterator()
method is invoked a second time.
iterator
- The input Iterator
Iterable
public static java.lang.Iterable<Row> in(RowIterator iterator)
RowIterator
into an Iterable
for single use in a Java 5 for-each loop.
While general purpose Iterables
tend to be reusable,
this wrapper Iterable
consumes the argument
Iterator
, leaving it in a non-reusable state. The returned
Iterable
will throw an IllegalStateException
if
its iterator()
method is invoked a second time.
iterator
- The input Iterator
Iterable
public static java.lang.Iterable<Version> in(VersionIterator iterator)
VersionIterator
into an Iterable
for single use in a Java 5 for-each loop.
While general purpose Iterables
tend to be reusable,
this wrapper Iterable
consumes the argument
Iterator
, leaving it in a non-reusable state. The returned
Iterable
will throw an IllegalStateException
if
its iterator()
method is invoked a second time.
iterator
- The input Iterator
Iterable
public static Node getOrAddNode(Node parent, java.lang.String name) throws RepositoryException
parent
- parent nodename
- name of the child nodeRepositoryException
- if the child node can not be
accessed or createdNode.getNode(String)
,
Node.addNode(String)
public static Node getOrAddNode(Node parent, java.lang.String name, java.lang.String type) throws RepositoryException
parent
- parent nodename
- name of the child nodetype
- type of the child node or null
,
ignored if the child already existsRepositoryException
- if the child node can not be accessed
or createdNode.getNode(String)
,
Node.addNode(String, String)
,
Node.isNodeType(String)
public static Node getOrAddFolder(Node parent, java.lang.String name) throws RepositoryException
Note that the type of the returned node is not guaranteed
to match nt:folder in case the node already existed. The caller can
use an explicit Node.isNodeType(String)
check if needed, or
simply use a data-first approach and not worry about the node type
until a constraint violation is encountered.
parent
- parent nodename
- name of the child nodeRepositoryException
- if the child node can not be accessed
or createdpublic static Node putFile(Node parent, java.lang.String name, java.lang.String mime, java.io.InputStream data) throws RepositoryException
If the file node does not already contain a jcr:content child, then one is created using the nt:resource node type. The following properties are set on the jcr:content node:
Note that the types of the returned node or the jcr:content child are
not guaranteed to match nt:file and nt:resource in case the
nodes already existed. The caller can use an explicit
Node.isNodeType(String)
check if needed, or simply use a
data-first approach and not worry about the node type until a constraint
violation is encountered.
The given binary content stream is closed by this method.
parent
- parent nodename
- name of the filemime
- media type of the filedata
- binary content of the fileRepositoryException
- if the child node can not be created
or updatedpublic static Node putFile(Node parent, java.lang.String name, java.lang.String mime, java.io.InputStream data, java.util.Calendar date) throws RepositoryException
If the file node does not already contain a jcr:content child, then one is created using the nt:resource node type. The following properties are set on the jcr:content node:
Note that the types of the returned node or the jcr:content child are
not guaranteed to match nt:file and nt:resource in case the
nodes already existed. The caller can use an explicit
Node.isNodeType(String)
check if needed, or simply use a
data-first approach and not worry about the node type until a constraint
violation is encountered.
The given binary content stream is closed by this method.
parent
- parent nodename
- name of the filemime
- media type of the filedata
- binary content of the filedate
- date of last modificationRepositoryException
- if the child node can not be created
or updatedpublic static java.io.InputStream readFile(Node node) throws RepositoryException
The returned stream contains a reference to the underlying
Binary
value instance that will be disposed when the stream
is closed. It is the responsibility of the caller to close the stream
once it is no longer needed.
node
- node to be readRepositoryException
- if the file can not be accessedpublic static void readFile(Node node, java.io.OutputStream output) throws RepositoryException, java.io.IOException
readFile(Node)
method.node
- node to be readoutput
- to which the file contents are writtenRepositoryException
- if the file can not be accessedjava.io.IOException
- if the file can not be read or writtenpublic static java.util.Calendar getLastModified(Node node) throws RepositoryException
node
- file nodenull
if not availableRepositoryException
- if the last modified date can not be accessedpublic static void setLastModified(Node node, java.util.Calendar date) throws RepositoryException
node
- file nodedate
- modified dateRepositoryException
- if the last modified date can not be setpublic static java.lang.String toString(Item item)
The returned string is not meant to be parsed and the exact contents can change in future releases. The current string representation of a node is "/path/to/node [type]" and the representation of a property is "@name = value(s)". Binary values are expressed like "<123 bytes>" and other values as their standard binary representation. Multi-valued properties have their values listed in like "[ v1, v2, v3, ... ]". No more than the three first values are included. Long string values are truncated.
item
- given node or propertypublic static int getPropertyType(java.lang.String name) throws java.lang.IllegalArgumentException
PropertyType.valueFromName(String)
, but the name lookup
is case insensitive.name
- name of the property type (case insensitive)java.lang.IllegalArgumentException
- if the given name is not a valid
property type namepublic static java.lang.String[] getPropertyTypeNames(boolean includeUndefined)
includeUndefined
- If true the returned array will contain the name
of the 'undefined' property type.public static Node getOrCreateByPath(java.lang.String absolutePath, java.lang.String nodeType, Session session) throws RepositoryException
Node
at the given Path.
In case it has to create the Node all non-existent intermediate path-elements
will be created with the given NodeType.
Changes made are not saved by this method, so session.save()
has to be called to persist them.
absolutePath
- absolute path to createnodeType
- to use for creation of nodes If null
the node type
is determined by the child node definitions of the parent node.session
- to useRepositoryException
- in case of exception accessing the Repositorypublic static Node getOrCreateByPath(java.lang.String absolutePath, java.lang.String intermediateNodeType, java.lang.String nodeType, Session session, boolean autoSave) throws RepositoryException
Node
at the given Path.
In case it has to create the Node all non-existent intermediate path-elements
will be created with the given intermediate node type and the returned node
will be created with the given nodeType.absolutePath
- absolute path to createintermediateNodeType
- to use for creation of intermediate nodes. If null
the node type
is determined by the child node definitions of the parent node.nodeType
- to use for creation of the final node. If null
the node type
is determined by the child node definitions of the parent node.session
- to useautoSave
- Should save be called when a new node is created?RepositoryException
- in case of exception accessing the Repositorypublic static Node getOrCreateUniqueByPath(java.lang.String pathHint, java.lang.String nodeType, Session session) throws RepositoryException
Node
at the given Path. In case it has
to create the Node all non-existent intermediate path-elements will be
created with the given intermediate node type and the returned node will
be created with the given nodeType.
If the path points to an existing node, the leaf node name will be
regarded as a name hint and a unique node name will be created by
appending a number to the given name (eg. /some/path/foobar2
).
Please note that the uniqueness check is not an atomic JCR operation,
so it is possible that you get a RepositoryException
(path
already exists) if another concurrent session created the same node in
the meantime.
Changes made are not saved by this method, so session.save()
has to be called to persist them.
pathHint
- path to createnodeType
- to use for creation of nodes. . If null
the node type
is determined by the child node definitions of the parent node.session
- to useRepositoryException
- in case of exception accessing the Repositorypublic static Node getOrCreateByPath(java.lang.String absolutePath, boolean createUniqueLeaf, java.lang.String intermediateNodeType, java.lang.String nodeType, Session session, boolean autoSave) throws RepositoryException
Node
at the given Path. In
case it has to create the Node all non-existent intermediate
path-elements will be created with the given intermediate node type and
the returned node will be created with the given nodeType.
If the parameter createUniqueLeaf
is set, it will not get
an existing node but rather try to create a unique node by appending a
number to the last path element (leaf node). Please note that the
uniqueness check is not an atomic JCR operation, so it is possible
that you get a RepositoryException
(path already exists) if
another concurrent session created the same node in the meantime.
absolutePath
- absolute path to createcreateUniqueLeaf
- whether the leaf of the path should be regarded as a name hint
and a unique node name should be created by appending a number
to the given name (eg. /some/path/foobar2
)intermediateNodeType
- to use for creation of intermediate nodes. If null
the node type
is determined by the child node definitions of the parent node.nodeType
- to use for creation of the final node. If null
the node type
is determined by the child node definitions of the parent node.session
- to useautoSave
- Should save be called when a new node is created?RepositoryException
- in case of exception accessing the Repositorypublic static Node getOrCreateUniqueByPath(Node parent, java.lang.String nodeNameHint, java.lang.String nodeType) throws RepositoryException
node
at the given path. In
case it has to create the node, nodes for all non-existent intermediate
path-elements will be created with the given intermediate node type and
the returned node will be created with the given nodeType.
Note: When the given path contains parent elements this method might
create multiple nodes at leaf position (e.g "a/../b" will create the
child nodes "a" and "b" on the current node).
If the node name points to an existing node, the node name will be
regarded as a name hint and a unique node name will be created by
appending a number to the given name (eg. /some/path/foobar2
).
Please note that the uniqueness check is not an atomic JCR operation,
so it is possible that you get a RepositoryException
(path
already exists) if another concurrent session created the same node in
the meantime.
Changes made are not saved by this method, so session.save()
has to be called to persist them.
parent
- existing parent node for the new nodenodeNameHint
- name hint for the new nodenodeType
- to use for creation of the node. If null
the node type
is determined by the child node definitions of the parent node.RepositoryException
- in case of exception accessing the Repositorypublic static Node getOrCreateByPath(Node baseNode, java.lang.String path, boolean createUniqueLeaf, java.lang.String intermediateNodeType, java.lang.String nodeType, boolean autoSave) throws RepositoryException
node
at the given path
relative to the baseNode. In case it has to create the node, nodes for
all non-existent intermediate path-elements will be created with the given
intermediate node type and the returned node will be created with the
given nodeType. Note: When the given path contains parent elements
this method might create multiple nodes at leaf position (e.g "a/../b"
will create the child nodes "a" and "b" on the current node).
If the parameter createUniqueLeaf
is set, it will not get
an existing node but rather try to create a unique node by appending a
number to the last path element (leaf node). Please note that the
uniqueness check is not an atomic JCR operation, so it is possible
that you get a RepositoryException
(path already exists) if
another concurrent session created the same node in the meantime.
baseNode
- existing node that should be the base for the relative pathpath
- relative path to createcreateUniqueLeaf
- whether the leaf of the path should be regarded as a name hint
and a unique node name should be created by appending a number
to the given name (eg. /some/path/foobar2
)intermediateNodeType
- to use for creation of intermediate nodes. If null
the node type
is determined by the child node definitions of the parent node.nodeType
- to use for creation of the final node. If null
the node type
is determined by the child node definitions of the parent node.autoSave
- Should save be called when a new node is created?RepositoryException
- in case of exception accessing the Repositorypublic static Node getNodeIfExists(Node baseNode, java.lang.String relPath) throws RepositoryException
relPath
from baseNode
or null
if no such node exists.baseNode
- existing node that should be the base for the relative pathrelPath
- relative path to the node to getrelPath
from baseNode
or null
if no such node exists.RepositoryException
- in case of exception accessing the Repositorypublic static Node getNodeIfExists(java.lang.String absPath, Session session) throws RepositoryException
absPath
or null
if no such node exists.absPath
- the absolute path to the node to returnsession
- to useabsPath
or null
if no such node exists.RepositoryException
- in case of exception accessing the Repositorypublic static java.lang.String getStringProperty(Node baseNode, java.lang.String relPath, java.lang.String defaultValue) throws RepositoryException
relPath
from baseNode
or defaultValue
if no such property exists.baseNode
- existing node that should be the base for the relative pathrelPath
- relative path to the property to getdefaultValue
- default value to return when the property does not existrelPath
from baseNode
or defaultValue
if no such property existsRepositoryException
- in case of exception accessing the Repositorypublic static long getLongProperty(Node baseNode, java.lang.String relPath, long defaultValue) throws RepositoryException
relPath
from baseNode
or defaultValue
if no such property exists.baseNode
- existing node that should be the base for the relative pathrelPath
- relative path to the property to getdefaultValue
- default value to return when the property does not existrelPath
from baseNode
or defaultValue
if no such property existsRepositoryException
- in case of exception accessing the Repositorypublic static double getDoubleProperty(Node baseNode, java.lang.String relPath, double defaultValue) throws RepositoryException
relPath
from baseNode
or defaultValue
if no such property exists.baseNode
- existing node that should be the base for the relative pathrelPath
- relative path to the property to getdefaultValue
- default value to return when the property does not existrelPath
from baseNode
or defaultValue
if no such property existsRepositoryException
- in case of exception accessing the Repositorypublic static boolean getBooleanProperty(Node baseNode, java.lang.String relPath, boolean defaultValue) throws RepositoryException
relPath
from baseNode
or defaultValue
if no such property exists.baseNode
- existing node that should be the base for the relative pathrelPath
- relative path to the property to getdefaultValue
- default value to return when the property does not existrelPath
from baseNode
or defaultValue
if no such property existsRepositoryException
- in case of exception accessing the Repositorypublic static java.util.Calendar getDateProperty(Node baseNode, java.lang.String relPath, java.util.Calendar defaultValue) throws RepositoryException
relPath
from baseNode
or defaultValue
if no such property exists.baseNode
- existing node that should be the base for the relative pathrelPath
- relative path to the property to getdefaultValue
- default value to return when the property does not existrelPath
from baseNode
or defaultValue
if no such property existsRepositoryException
- in case of exception accessing the Repositorypublic static java.math.BigDecimal getDecimalProperty(Node baseNode, java.lang.String relPath, java.math.BigDecimal defaultValue) throws RepositoryException
relPath
from baseNode
or defaultValue
if no such property exists.baseNode
- existing node that should be the base for the relative pathrelPath
- relative path to the property to getdefaultValue
- default value to return when the property does not existrelPath
from baseNode
or defaultValue
if no such property existsRepositoryException
- in case of exception accessing the Repositorypublic static Binary getBinaryProperty(Node baseNode, java.lang.String relPath, Binary defaultValue) throws RepositoryException
relPath
from baseNode
or defaultValue
if no such property exists.baseNode
- existing node that should be the base for the relative pathrelPath
- relative path to the property to getdefaultValue
- default value to return when the property does not existrelPath
from baseNode
or defaultValue
if no such property existsRepositoryException
- in case of exception accessing the Repositorypublic static java.lang.String getStringProperty(Session session, java.lang.String absPath, java.lang.String defaultValue) throws RepositoryException
absPath
or defaultValue
if no such property exists.session
- to useabsPath
- absolute path to the property to getdefaultValue
- default value to return when the property does not existabsPath
or defaultValue
if no such property existsRepositoryException
- in case of exception accessing the Repositorypublic static long getLongProperty(Session session, java.lang.String absPath, long defaultValue) throws RepositoryException
absPath
or defaultValue
if no such property exists.session
- to useabsPath
- absolute path to the property to getdefaultValue
- default value to return when the property does not existabsPath
or defaultValue
if no such property existsRepositoryException
- in case of exception accessing the Repositorypublic static double getDoubleProperty(Session session, java.lang.String absPath, double defaultValue) throws RepositoryException
absPath
or defaultValue
if no such property exists.session
- to useabsPath
- absolute path to the property to getdefaultValue
- default value to return when the property does not existabsPath
or defaultValue
if no such property existsRepositoryException
- in case of exception accessing the Repositorypublic static boolean getBooleanProperty(Session session, java.lang.String absPath, boolean defaultValue) throws RepositoryException
absPath
or defaultValue
if no such property exists.session
- to useabsPath
- absolute path to the property to getdefaultValue
- default value to return when the property does not existabsPath
or defaultValue
if no such property existsRepositoryException
- in case of exception accessing the Repositorypublic static java.util.Calendar getDateProperty(Session session, java.lang.String absPath, java.util.Calendar defaultValue) throws RepositoryException
absPath
or defaultValue
if no such property exists.session
- to useabsPath
- absolute path to the property to getdefaultValue
- default value to return when the property does not existabsPath
or defaultValue
if no such property existsRepositoryException
- in case of exception accessing the Repositorypublic static java.math.BigDecimal getDecimalProperty(Session session, java.lang.String absPath, java.math.BigDecimal defaultValue) throws RepositoryException
absPath
or defaultValue
if no such property exists.session
- to useabsPath
- absolute path to the property to getdefaultValue
- default value to return when the property does not existabsPath
or defaultValue
if no such property existsRepositoryException
- in case of exception accessing the Repositorypublic static Binary getBinaryProperty(Session session, java.lang.String absPath, Binary defaultValue) throws RepositoryException
absPath
or defaultValue
if no such property exists.session
- to useabsPath
- absolute path to the property to getdefaultValue
- default value to return when the property does not existabsPath
or defaultValue
if no such property existsRepositoryException
- in case of exception accessing the RepositoryCopyright © 2010 - 2020 Adobe. All Rights Reserved