|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.modeshape.jcr.JcrTools
public class JcrTools
Utility methods for working with JCR nodes.
Constructor Summary | |
---|---|
JcrTools()
|
Method Summary | |
---|---|
String |
detectMimeType(Session session,
File file,
boolean useContent)
Detect the MIME type for the named filename. |
String |
detectMimeType(Session session,
String fileName)
Detect the MIME type for the named filename. |
String |
detectMimeType(Session session,
URL url,
boolean useContent)
Detect the MIME type for the named filename. |
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. |
MimeTypeDetector |
mimeTypeDetector(Session session)
|
int |
removeAllChildren(Node node)
Remove all children from the specified node |
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public JcrTools()
Method Detail |
---|
public int removeAllChildren(Node node) throws RepositoryException
node
-
RepositoryException
IllegalArgumentException
- if the node argument is nullpublic 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 null
public MimeTypeDetector mimeTypeDetector(Session session)
public String detectMimeType(Session session, String fileName)
session
- the JCR sessionfileName
- the file name
public String detectMimeType(Session session, File file, boolean useContent) throws IOException
session
- the JCR sessionfile
- the fileuseContent
- true if the content of the file at the URL should also be used to determine the MIME type, or false if
only the URL itself should be used
IOException
- if there is an error reading the filepublic String detectMimeType(Session session, URL url, boolean useContent) throws IOException
session
- the JCR sessionurl
- the URLuseContent
- true if the content of the file at the URL should also be used to determine the MIME type, or false if
only the URL itself should be used
IOException
- if there is an error reading the filepublic 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 uploaded
RepositoryException
- if there is a problem uploading the file
IOException
- if there is a problem using the streampublic 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 found
RepositoryException
- if there is a problem uploading the file
IOException
- if there is a problem using the streampublic 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 uploaded
RepositoryException
- if there is a problem uploading the file
IOException
- if there is a problem using the stream
IllegalArgumentException
- if the file does not exist or is not readablepublic 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 null
RepositoryException
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 null
RepositoryException
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 null
RepositoryException
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 null
RepositoryException
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 null
RepositoryException
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 null
RepositoryException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |