public class JcrTools extends Object
Modifier and Type | Class and Description |
---|---|
static class |
JcrTools.BasicOperation |
static class |
JcrTools.BrowseContent |
static class |
JcrTools.CountNodes |
static interface |
JcrTools.NodeOperation |
static interface |
JcrTools.Operation |
static class |
JcrTools.PrintNodes |
static class |
JcrTools.Variable |
Modifier and Type | Method and Description |
---|---|
Node |
findOrCreateChild(Node parent,
String name)
Get or create a node with the specified node under the specified parent node.
|
Node |
findOrCreateChild(Node parent,
String name,
String nodeType)
Get or create a node with the specified node and node type under the specified parent node.
|
Node |
findOrCreateNode(Node parentNode,
String path,
String defaultNodeType,
String finalNodeType)
Get or create a node at the specified path.
|
Node |
findOrCreateNode(Session session,
String path)
Get or create a node at the specified path.
|
Node |
findOrCreateNode(Session session,
String path,
String nodeType)
Get or create a node at the specified path and node type.
|
Node |
findOrCreateNode(Session session,
String path,
String defaultNodeType,
String finalNodeType)
Get or create a node at the specified path.
|
Node |
getNode(Node node,
String relativePath,
boolean required)
Get the node under a specified node at a location defined by the specified relative path.
|
String |
getReadable(Node node)
Get the readable string form for a specified node.
|
protected String |
getStringValue(Value value,
int type) |
static void |
importContent(Session session,
Class<?> testClass,
String pathToResourceFile) |
static void |
importContent(Session session,
Class<?> testClass,
String pathToResourceFile,
String jcrPathToImportUnder) |
static void |
importContent(Session session,
Class<?> testClass,
String pathToResourceFile,
String jcrPathToImportUnder,
int importBehavior) |
void |
importContent(Session session,
String pathToResourceFile) |
void |
importContent(Session session,
String pathToResourceFile,
int importBehavior) |
void |
importContent(Session session,
String pathToResourceFile,
String jcrPathToImportUnder) |
void |
importContent(Session session,
String pathToResourceFile,
String jcrPathToImportUnder,
int importBehavior) |
boolean |
isDebug() |
void |
onEachNode(Session session,
boolean includeSystemNodes,
JcrTools.NodeOperation operation)
Execute the supplied operation on each node in the workspace accessible by the supplied session.
|
protected void |
onEachNodeBelow(Node parent,
JcrTools.NodeOperation operation) |
void |
print(Object msg) |
void |
printNode(Node node)
Print this node and its properties to System.out if printing is enabled.
|
QueryResult |
printQuery(Session session,
String jcrSql2)
Execute the supplied JCR-SQL2 query and, if printing is enabled, print out the results.
|
QueryResult |
printQuery(Session session,
String jcrSql2,
long expectedNumberOfResults,
JcrTools.Variable... variables)
Execute the supplied JCR-SQL2 query and, if printing is enabled, print out the results.
|
QueryResult |
printQuery(Session session,
String jcrSql2,
long expectedNumberOfResults,
Map<String,String> variables)
Execute the supplied JCR-SQL2 query and, if printing is enabled, print out the results.
|
QueryResult |
printQuery(Session session,
String queryExpression,
String queryLanguage,
long expectedNumberOfResults,
Map<String,String> variables) |
void |
printSubgraph(Node node)
Load the subgraph below this node, and print it to System.out if printing is enabled.
|
void |
printSubgraph(Node node,
int maxDepth)
Load the subgraph below this node, and print it to System.out if printing is enabled.
|
void |
printSubgraph(Node node,
String lead,
int depthOfSubgraph,
int maxDepthOfSubgraph)
Load the subgraph below this node, and print it to System.out if printing is enabled.
|
void |
registerNodeTypes(Session session,
String pathToCndResourceFile) |
int |
removeAllChildren(Node node)
Remove all children from the specified node
|
int |
removeAllChildren(Session session,
String absPath) |
void |
repeatedlyWithSession(Repository repository,
int times,
JcrTools.Operation operation) |
protected URL |
resourceUrl(String name) |
void |
setDebug(boolean debug) |
Node |
uploadFile(Session session,
String path,
File file)
Upload the content in the supplied file into the repository at the defined path, using the given session.
|
Node |
uploadFile(Session session,
String path,
InputStream stream)
Upload the content in the supplied stream into the repository at the defined path, using the given session.
|
Node |
uploadFile(Session session,
String path,
URL contentUrl)
Upload the content at the supplied URL into the repository at the defined path, using the given session.
|
void |
uploadFileAndBlock(Session session,
String resourceFilePath,
String parentPath) |
void |
uploadFileAndBlock(Session session,
String folder,
String fileName,
String parentPath) |
void |
uploadFileAndBlock(Session session,
URL url,
String parentPath) |
void |
uploadFilesAndBlock(String destinationPath,
String... resourcePaths) |
JcrTools.Variable |
var(String key,
String value) |
Map<String,String> |
vars(String... keyValuePairs) |
double |
withSession(Repository repository,
JcrTools.Operation operation) |
public int removeAllChildren(Node node) throws RepositoryException
node
- RepositoryException
IllegalArgumentException
- if the node argument is nullpublic int removeAllChildren(Session session, String absPath) throws RepositoryException
RepositoryException
public Node getNode(Node node, String relativePath, boolean required) throws RepositoryException
node
- a parent node from which to obtain a node relative to. may not be nullrelativePath
- the path of the desired node. may not be nullrequired
- true if node is required to exist under the given node.RepositoryException
IllegalArgumentException
- if the node, relativePath or problems argument is nullpublic String getReadable(Node node)
node
- the node to obtain the readable string form. may be nullpublic Node uploadFile(Session session, String path, InputStream stream) throws RepositoryException, IOException
This method always closes the supplied stream.
session
- the JCR sessionpath
- the path to the filestream
- the stream containing the content to be uploadedRepositoryException
- if there is a problem uploading the fileIOException
- if there is a problem using the streamIllegalArgumentException
- is any of the parameters are nullpublic Node uploadFile(Session session, String path, URL contentUrl) throws RepositoryException, IOException
session
- the JCR sessionpath
- the path to the filecontentUrl
- the URL where the content can be foundRepositoryException
- if there is a problem uploading the fileIOException
- if there is a problem using the streamIllegalArgumentException
- is any of the parameters are nullpublic Node uploadFile(Session session, String path, File file) throws RepositoryException, IOException
session
- the JCR sessionpath
- the path to the filefile
- the existing and readable file to be uploadedRepositoryException
- if there is a problem uploading the fileIOException
- if there is a problem using the streamIllegalArgumentException
- if the file does not exist or is not readableIllegalArgumentException
- is any of the parameters are nullpublic void uploadFileAndBlock(Session session, String resourceFilePath, String parentPath) throws RepositoryException, IOException
RepositoryException
IOException
public void uploadFileAndBlock(Session session, String folder, String fileName, String parentPath) throws RepositoryException, IOException
RepositoryException
IOException
public void uploadFileAndBlock(Session session, URL url, String parentPath) throws RepositoryException, IOException
RepositoryException
IOException
public void uploadFilesAndBlock(String destinationPath, String... resourcePaths) throws Exception
Exception
public Node findOrCreateNode(Session session, String path) throws RepositoryException
session
- the JCR session. may not be nullpath
- the path of the desired node to be found or created. may not be nullRepositoryException
IllegalArgumentException
- if either the session or path argument is nullpublic Node findOrCreateNode(Session session, String path, String nodeType) throws RepositoryException
session
- the JCR session. may not be nullpath
- the path of the desired node to be found or created. may not be nullnodeType
- the node type. may be nullRepositoryException
IllegalArgumentException
- if either the session or path argument is nullpublic Node findOrCreateNode(Session session, String path, String defaultNodeType, String finalNodeType) throws RepositoryException
session
- the JCR session. may not be nullpath
- the path of the desired node to be found or created. may not be nulldefaultNodeType
- the default node type. may be nullfinalNodeType
- the optional final node type. may be nullRepositoryException
IllegalArgumentException
- if either the session or path argument is nullpublic Node findOrCreateNode(Node parentNode, String path, String defaultNodeType, String finalNodeType) throws RepositoryException
parentNode
- the parent node. may not be nullpath
- the path of the desired child node. may not be nulldefaultNodeType
- the default node type. may be nullfinalNodeType
- the optional final node type. may be nullRepositoryException
IllegalArgumentException
- if either the parentNode or path argument is nullpublic Node findOrCreateChild(Node parent, String name) throws RepositoryException
parent
- the parent node. may not be nullname
- the name of the child node. may not be nullRepositoryException
IllegalArgumentException
- if either the parent or name argument is nullpublic Node findOrCreateChild(Node parent, String name, String nodeType) throws RepositoryException
parent
- the parent node. may not be nullname
- the name of the child node. may not be nullnodeType
- the node type. may be nullRepositoryException
public boolean isDebug()
public void setDebug(boolean debug)
public void print(Object msg)
public void printSubgraph(Node node) throws RepositoryException
node
- the root of the subgraphRepositoryException
public void printSubgraph(Node node, int maxDepth) throws RepositoryException
node
- the root of the subgraphmaxDepth
- the maximum depth of the subgraph that should be printedRepositoryException
public void printNode(Node node) throws RepositoryException
node
- the node to be printedRepositoryException
public void printSubgraph(Node node, String lead, int depthOfSubgraph, int maxDepthOfSubgraph) throws RepositoryException
node
- the root of the subgraphlead
- the string that each line should begin with; may be null if there is no such stringdepthOfSubgraph
- the depth of this subgraph's root nodemaxDepthOfSubgraph
- the maximum depth of the subgraph that should be printedRepositoryException
public QueryResult printQuery(Session session, String jcrSql2) throws RepositoryException
session
- the sessionjcrSql2
- the JCR-SQL2 queryRepositoryException
public QueryResult printQuery(Session session, String jcrSql2, long expectedNumberOfResults, JcrTools.Variable... variables) throws RepositoryException
session
- the sessionjcrSql2
- the JCR-SQL2 queryexpectedNumberOfResults
- the expected number of rows in the results, or -1 if this is not to be checkedvariables
- the variables for the queryRepositoryException
public QueryResult printQuery(Session session, String jcrSql2, long expectedNumberOfResults, Map<String,String> variables) throws RepositoryException
session
- the sessionjcrSql2
- the JCR-SQL2 queryexpectedNumberOfResults
- the expected number of rows in the results, or -1 if this is not to be checkedvariables
- the array of variable maps for the query; all maps will be combined into a single mapRepositoryException
public QueryResult printQuery(Session session, String queryExpression, String queryLanguage, long expectedNumberOfResults, Map<String,String> variables) throws RepositoryException
RepositoryException
public JcrTools.Variable var(String key, String value)
protected String getStringValue(Value value, int type) throws RepositoryException
RepositoryException
public void importContent(Session session, String pathToResourceFile) throws Exception
Exception
public void importContent(Session session, String pathToResourceFile, int importBehavior) throws Exception
Exception
public void importContent(Session session, String pathToResourceFile, String jcrPathToImportUnder) throws Exception
Exception
public void importContent(Session session, String pathToResourceFile, String jcrPathToImportUnder, int importBehavior) throws Exception
Exception
public static void importContent(Session session, Class<?> testClass, String pathToResourceFile) throws Exception
Exception
public static void importContent(Session session, Class<?> testClass, String pathToResourceFile, String jcrPathToImportUnder) throws Exception
Exception
public static void importContent(Session session, Class<?> testClass, String pathToResourceFile, String jcrPathToImportUnder, int importBehavior) throws Exception
Exception
public void onEachNode(Session session, boolean includeSystemNodes, JcrTools.NodeOperation operation) throws Exception
session
- the sessionincludeSystemNodes
- true if all nodes under "/jcr:system" should be included, or false if the system nodes should be
excludedoperation
- the operationException
- the exception thrown by the repository or the operationprotected void onEachNodeBelow(Node parent, JcrTools.NodeOperation operation) throws Exception
Exception
public void repeatedlyWithSession(Repository repository, int times, JcrTools.Operation operation) throws Exception
Exception
public double withSession(Repository repository, JcrTools.Operation operation) throws Exception
Exception
Copyright © 2008–2016 JBoss, a division of Red Hat. All rights reserved.