public class JcrResourceUtil extends Object
JcrResourceUtil
class provides helper methods used
throughout this bundle.Constructor and Description |
---|
JcrResourceUtil() |
Modifier and Type | Method and Description |
---|---|
static Node |
createPath(Node parentNode,
String relativePath,
String intermediateNodeType,
String nodeType,
boolean autoSave)
Creates or gets the
Node at the given Path. |
static Node |
createPath(String path,
String intermediateNodeType,
String nodeType,
Session session,
boolean autoSave)
Creates or gets the
Node at the given Path. |
static Value |
createValue(Object value,
Session session)
Creates a
JCR Value for the given object with
the given Session. |
static String |
getResourceSuperType(Resource resource)
Deprecated.
Call
ResourceUtil#findResourceSuperType(Resource) |
static String |
getResourceSuperType(ResourceResolver resourceResolver,
String resourceType)
Deprecated.
Use
ResourceUtil#getResourceSuperType(ResourceResolver, String) |
static QueryResult |
query(Session session,
String query,
String language)
Helper method to execute a JCR query
|
static String |
resourceTypeToPath(String type)
Deprecated.
Use
ResourceUtil#resourceTypeToPath(String) |
static void |
setProperty(Node node,
String propertyName,
Object propertyValue)
Sets the value of the property.
|
static Object |
toJavaObject(Property property)
Converts the value(s) of a JCR Property to a corresponding Java Object.
|
static Object |
toJavaObject(Value value)
Converts a JCR Value to a corresponding Java Object
|
public static QueryResult query(Session session, String query, String language) throws RepositoryException
RepositoryException
public static Object toJavaObject(Value value) throws RepositoryException
RepositoryException
public static Object toJavaObject(Property property) throws RepositoryException
RepositoryException
public static Value createValue(Object value, Session session) throws RepositoryException
JCR Value
for the given object with
the given Session.
Selects the the PropertyType
according
the instance of the object's Classvalue
- objectsession
- to create value forRepositoryException
- in case of error, accessing the Repositorypublic static void setProperty(Node node, String propertyName, Object propertyValue) throws RepositoryException
PropertyType
according
to the instance of the object's class.node
- The node where the property will be set on.propertyName
- The name of the property.propertyValue
- The value for the property.RepositoryException
@Deprecated public static String resourceTypeToPath(String type)
ResourceUtil#resourceTypeToPath(String)
Resource
as a
relative path.type
- The resource type to be converted into a path@Deprecated public static String getResourceSuperType(ResourceResolver resourceResolver, String resourceType)
ResourceUtil#getResourceSuperType(ResourceResolver, String)
JcrResourceConstants.SLING_RESOURCE_SUPER_TYPE_PROPERTY
of the
Resource
addressed by the resourceType
to a
string. If no such child resource exists or if the resource does not
adapt to a string, this method returns null
.resourceResolver
- The ResourceResolver
used to
access the resource whose path (relative or absolute) is given
by the resourceType
parameter.resourceType
- The resource type whose super type is to be returned.
This type is turned into a path by calling the
resourceTypeToPath(String)
method before trying to
get the resource through the resourceResolver
.resourceType
or
null
if the resource type does not have a child
resource
JcrResourceConstants.SLING_RESOURCE_SUPER_TYPE_PROPERTY
adapting to a string.@Deprecated public static String getResourceSuperType(Resource resource)
ResourceUtil#findResourceSuperType(Resource)
JcrResourceConstants.SLING_RESOURCE_SUPER_TYPE_PROPERTY
if the
given resource
adapted to a string or the result of
calling the getResourceSuperType(ResourceResolver, String)
method on the resource type of the resource
.
This mechanism allows to specifically set the resource super type on a per-resource level overwriting any resource super type hierarchy pre-defined by the actual resource type of the resource.
resource
- The Resource
whose resource super type is
requested.null
if the algorithm
described above does not yield a resource super type.public static Node createPath(String path, String intermediateNodeType, 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 create with the given intermediate node type and the returned node
will be created with the given nodeTypepath
- to createintermediateNodeType
- to use for creation of intermediate nodes (or null)nodeType
- to use for creation of the final node (or null)session
- to useautoSave
- Should save be called when a new node is created?RepositoryException
- in case of exception accessing the Repositorypublic static Node createPath(Node parentNode, String relativePath, String intermediateNodeType, String nodeType, 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 create with the given intermediate node type and the returned node
will be created with the given nodeTypeparentNode
- starting noderelativePath
- to createintermediateNodeType
- to use for creation of intermediate nodes (or null)nodeType
- to use for creation of the final node (or null)autoSave
- Should save be called when a new node is created?RepositoryException
- in case of exception accessing the Repository"Copyright © 2006 - 2015 Adobe Systems Incorporated. All Rights Reserved"