public abstract class AbstractSession extends Object implements Session
Session
interface.ACTION_ADD_NODE, ACTION_READ, ACTION_REMOVE, ACTION_SET_PROPERTY
Constructor and Description |
---|
AbstractSession() |
Modifier and Type | Method and Description |
---|---|
void |
exportDocumentView(String path,
ContentHandler handler,
boolean skipBinary,
boolean noRecurse)
Generates a document view export using a
DocumentViewExporter
instance. |
void |
exportDocumentView(String absPath,
OutputStream out,
boolean skipBinary,
boolean noRecurse)
Calls
Session.exportDocumentView(String, ContentHandler, boolean, boolean)
with the given arguments and a ContentHandler that serializes
SAX events to the given output stream. |
void |
exportSystemView(String path,
ContentHandler handler,
boolean skipBinary,
boolean noRecurse)
Generates a system view export using a
SystemViewExporter
instance. |
void |
exportSystemView(String absPath,
OutputStream out,
boolean skipBinary,
boolean noRecurse)
Calls
Session.exportSystemView(String, ContentHandler, boolean, boolean)
with the given arguments and a ContentHandler that serializes
SAX events to the given output stream. |
Item |
getItem(String absPath)
Returns the node or property at the given path.
|
String |
getNamespacePrefix(String uri)
Returns the namespace prefix mapped to the given URI.
|
String[] |
getNamespacePrefixes()
Returns the prefixes of all known namespace mappings.
|
String |
getNamespaceURI(String prefix)
Returns the namespace URI mapped to the given prefix.
|
Node |
getNode(String absPath)
Returns the node with the given absolute path.
|
Property |
getProperty(String absPath)
Returns the property with the given absolute path.
|
Session |
impersonate(Credentials credentials)
Logs in the same workspace with the given credentials.
|
void |
importXML(String parentAbsPath,
InputStream in,
int uuidBehavior)
Parses the given input stream as an XML document and processes the
SAX events using the
ContentHandler returned by
Session.getImportContentHandler(String, int) . |
boolean |
itemExists(String absPath)
Calls
getItem(String) with the given path and returns
true if the call succeeds. |
void |
logout()
Clears the local namespace mappings.
|
boolean |
nodeExists(String absPath)
Checks whether a node with the given absolute path exists.
|
boolean |
propertyExists(String absPath)
Checks whether a property with the given absolute path exists.
|
void |
removeItem(String absPath)
Removes the identified item.
|
void |
setNamespacePrefix(String prefix,
String uri)
Modifies the session local namespace mappings to contain the given
prefix to URI mapping.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addLockToken, checkPermission, getAccessControlManager, getAttribute, getAttributeNames, getImportContentHandler, getLockTokens, getNodeByIdentifier, getNodeByUUID, getRepository, getRetentionManager, getRootNode, getUserID, getValueFactory, getWorkspace, hasCapability, hasPendingChanges, hasPermission, isLive, move, refresh, removeLockToken, save
public void logout()
super.logout()
when overriding this method to avoid
namespace mappings to be carried over to a new session.public String getNamespacePrefix(String uri) throws NamespaceException, RepositoryException
This behaviour is based on JSR 283 (JCR 2.0), but remains backwards compatible with JCR 1.0.
getNamespacePrefix
in interface Session
uri
- namespace URINamespaceException
- if the namespace is not foundRepositoryException
- if a repository error occurspublic String getNamespaceURI(String prefix) throws NamespaceException, RepositoryException
This behaviour is based on JSR 283 (JCR 2.0), but remains backwards compatible with JCR 1.0.
getNamespaceURI
in interface Session
prefix
- namespace prefixNamespaceException
- if the namespace is not foundRepositoryException
- if a repository error occurspublic String[] getNamespacePrefixes() throws RepositoryException
This behaviour is based on JSR 283 (JCR 2.0), but remains backwards compatible with JCR 1.0.
getNamespacePrefixes
in interface Session
RepositoryException
- if a repository error occurspublic void setNamespacePrefix(String prefix, String uri) throws NamespaceException, RepositoryException
This behaviour is based on JSR 283 (JCR 2.0), but remains backwards compatible with JCR 1.0.
setNamespacePrefix
in interface Session
prefix
- namespace prefixuri
- namespace URINamespaceException
- if the mapping is illegalRepositoryException
- if a repository error occurspublic void exportDocumentView(String path, ContentHandler handler, boolean skipBinary, boolean noRecurse) throws PathNotFoundException, SAXException, RepositoryException
DocumentViewExporter
instance.exportDocumentView
in interface Session
path
- of the node to be exportedhandler
- handler for the SAX events of the exportskipBinary
- whether binary values should be skippednoRecurse
- whether to export just the identified nodePathNotFoundException
- if a node at the given path does not existSAXException
- if the SAX event handler failedRepositoryException
- if another error occurspublic void exportSystemView(String path, ContentHandler handler, boolean skipBinary, boolean noRecurse) throws PathNotFoundException, SAXException, RepositoryException
SystemViewExporter
instance.exportSystemView
in interface Session
path
- of the node to be exportedhandler
- handler for the SAX events of the exportskipBinary
- whether binary values should be skippednoRecurse
- whether to export just the identified nodePathNotFoundException
- if a node at the given path does not existSAXException
- if the SAX event handler failedRepositoryException
- if another error occurspublic void exportDocumentView(String absPath, OutputStream out, boolean skipBinary, boolean noRecurse) throws IOException, RepositoryException
Session.exportDocumentView(String, ContentHandler, boolean, boolean)
with the given arguments and a ContentHandler
that serializes
SAX events to the given output stream.exportDocumentView
in interface Session
absPath
- passed throughout
- output stream to which the SAX events are serializedskipBinary
- passed throughnoRecurse
- passed throughIOException
- if the SAX serialization failedRepositoryException
- if another error occurspublic void exportSystemView(String absPath, OutputStream out, boolean skipBinary, boolean noRecurse) throws IOException, RepositoryException
Session.exportSystemView(String, ContentHandler, boolean, boolean)
with the given arguments and a ContentHandler
that serializes
SAX events to the given output stream.exportSystemView
in interface Session
absPath
- passed throughout
- output stream to which the SAX events are serializedskipBinary
- passed throughnoRecurse
- passed throughIOException
- if the SAX serialization failedRepositoryException
- if another error occurspublic void importXML(String parentAbsPath, InputStream in, int uuidBehavior) throws IOException, InvalidSerializedDataException, RepositoryException
ContentHandler
returned by
Session.getImportContentHandler(String, int)
.importXML
in interface Session
parentAbsPath
- passed throughin
- input stream to be parsed as XML and importeduuidBehavior
- passed throughIOException
- if an I/O error occursInvalidSerializedDataException
- if an XML parsing error occursRepositoryException
- if a repository error occurspublic Item getItem(String absPath) throws PathNotFoundException, RepositoryException
The default implementation:
Session.getNodeByIdentifier(String)
for identifier
paths
PathNotFoundException
if the given path does not
start with a slash.
Node.getNode(String)
on the root node with the part of
the given path after the first slash
Node.getProperty(String)
similarly in case the above
call fails with a PathNotFoundException
getItem
in interface Session
absPath
- absolute pathPathNotFoundException
- if the given path is invalid or not foundRepositoryException
- if another error occursSession.getItem(String)
public boolean itemExists(String absPath) throws RepositoryException
getItem(String)
with the given path and returns
true
if the call succeeds. Returns false
if a PathNotFoundException
was thrown. Other exceptions are
passed through.itemExists
in interface Session
absPath
- absolute pathtrue
if an item exists at the given path,
false
otherwiseRepositoryException
- if an error occursSession.itemExists(String)
public void removeItem(String absPath) throws RepositoryException
Item.remove()
on the item removed by getItem(String)
.removeItem
in interface Session
absPath
- An absolute path of the item to be removedRepositoryException
- if the item can not be removedSession.removeItem(String)
public Node getNode(String absPath) throws RepositoryException
getNode
in interface Session
absPath
- absolute pathRepositoryException
- if the node can not be accessedSession.getNode(String)
public boolean nodeExists(String absPath) throws RepositoryException
nodeExists
in interface Session
absPath
- absolute pathtrue
if a node with the given path exists,
false
otherwiseRepositoryException
- if the path is invalidSession.nodeExists(String)
public Property getProperty(String absPath) throws RepositoryException
getProperty
in interface Session
absPath
- absolute pathRepositoryException
- if the property can not be accessedSession.getProperty(String)
public boolean propertyExists(String absPath) throws RepositoryException
propertyExists
in interface Session
absPath
- absolute pathtrue
if a property with the given path exists,
false
otherwiseRepositoryException
- if the path is invalidSession.propertyExists(String)
public Session impersonate(Credentials credentials) throws RepositoryException
The default implementation:
Repository
instance using
Session.getRepository()
Session.getWorkspace()
Workspace.getName()
Repository.login(Credentials, String)
on the
retrieved repository with the given credentials and the retrieved
workspace name.
impersonate
in interface Session
credentials
- login credentialsRepositoryException
- if an error occursCopyright © 2004–2024 The Apache Software Foundation. All rights reserved.