use of javax.jcr.RepositoryException in project jackrabbit by apache.
the class ServerNode method getVersionByUUID.
//---------- Implementation helper -----------------------------------------
/**
* Returns the {@link Version} instance for the given UUID.
*
* @param versionUUID The UUID of the version.
*
* @return The version node.
*
* @throws RepositoryException if an error occurrs accessing the version
* node or if the UUID does not denote a version.
*/
protected Version getVersionByUUID(String versionUUID) throws RepositoryException {
// get the version node by its UUID from the version history's session
Session session = node.getSession();
Node versionNode = session.getNodeByUUID(versionUUID);
// the correct type).
if (versionNode instanceof Version) {
return (Version) versionNode;
}
// otherwise fail
throw new RepositoryException("Cannot find version " + versionUUID);
}
use of javax.jcr.RepositoryException in project jackrabbit by apache.
the class ServerSession method exportSystemView.
/** {@inheritDoc} */
public byte[] exportSystemView(String path, boolean binaryAsLink, boolean noRecurse) throws IOException, RepositoryException, RemoteException {
try {
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
session.exportSystemView(path, buffer, binaryAsLink, noRecurse);
return buffer.toByteArray();
} catch (RepositoryException ex) {
throw getRepositoryException(ex);
}
}
use of javax.jcr.RepositoryException in project jackrabbit by apache.
the class ServerVersionManager method restore.
@Override
public void restore(String[] versionIdentifiers, boolean removeExisting) throws RepositoryException, RemoteException {
try {
Version[] versions = new Version[versionIdentifiers.length];
for (int i = 0; i < versions.length; i++) {
Version version = (Version) session.getNodeByIdentifier(versionIdentifiers[i]);
versions[i] = version;
}
manager.restore(versions, removeExisting);
} catch (RepositoryException e) {
throw getRepositoryException(e);
}
}
use of javax.jcr.RepositoryException in project jackrabbit by apache.
the class ServerVersionManager method restoreVI.
@Override
public void restoreVI(String absPath, String versionIdentifier, boolean removeExisting) throws RepositoryException, RemoteException {
try {
Version version = (Version) session.getNodeByIdentifier(versionIdentifier);
manager.restore(absPath, version, removeExisting);
} catch (RepositoryException e) {
throw getRepositoryException(e);
}
}
use of javax.jcr.RepositoryException in project jackrabbit by apache.
the class RepositoryDescriptorTest method testGetDescriptorValues.
/**
* Tests whether {@link Repository#getDescriptorValues(String)} returns an
* Value[] of size 1 for single valued descriptors.
*/
public void testGetDescriptorValues() {
Repository rep = session.getRepository();
// "option.node.type.management.supported" denotes a single-valued BOOLEAN descriptor
String descName = Repository.OPTION_NODE_TYPE_MANAGEMENT_SUPPORTED;
assertTrue(rep.isSingleValueDescriptor(descName));
Value[] vals = rep.getDescriptorValues(descName);
assertNotNull("Required descriptor is missing: " + descName, vals);
assertEquals(1, vals.length);
assertEquals(PropertyType.BOOLEAN, vals[0].getType());
try {
// getDescriptorValue(key).getString() is equivalent to getDescriptor(key)
assertEquals(vals[0].getString(), rep.getDescriptor(descName));
} catch (RepositoryException e) {
fail(e.getMessage());
}
// "option.node.type.management.supported" denotes a single-valued BOOLEAN descriptor
descName = Repository.QUERY_LANGUAGES;
assertFalse(rep.isSingleValueDescriptor(descName));
Value val = rep.getDescriptorValue(descName);
assertNull(descName + " is a multi-value descriptor, getDescriptorValue() should return null", val);
}
Aggregations