Search in sources :

Example 46 with RepositoryException

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);
}
Also used : Version(javax.jcr.version.Version) RemoteVersion(org.apache.jackrabbit.rmi.remote.RemoteVersion) RemoteNode(org.apache.jackrabbit.rmi.remote.RemoteNode) Node(javax.jcr.Node) RepositoryException(javax.jcr.RepositoryException) Session(javax.jcr.Session)

Example 47 with RepositoryException

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);
    }
}
Also used : RepositoryException(javax.jcr.RepositoryException) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Example 48 with RepositoryException

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);
    }
}
Also used : Version(javax.jcr.version.Version) RemoteVersion(org.apache.jackrabbit.rmi.remote.RemoteVersion) RepositoryException(javax.jcr.RepositoryException)

Example 49 with RepositoryException

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);
    }
}
Also used : Version(javax.jcr.version.Version) RemoteVersion(org.apache.jackrabbit.rmi.remote.RemoteVersion) RepositoryException(javax.jcr.RepositoryException)

Example 50 with RepositoryException

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);
}
Also used : Repository(javax.jcr.Repository) Value(javax.jcr.Value) RepositoryException(javax.jcr.RepositoryException)

Aggregations

RepositoryException (javax.jcr.RepositoryException)1236 Node (javax.jcr.Node)289 Session (javax.jcr.Session)182 IOException (java.io.IOException)156 ArrayList (java.util.ArrayList)106 Name (org.apache.jackrabbit.spi.Name)94 DavException (org.apache.jackrabbit.webdav.DavException)90 Test (org.junit.Test)87 Value (javax.jcr.Value)80 NotExecutableException (org.apache.jackrabbit.test.NotExecutableException)76 ItemStateException (org.apache.jackrabbit.core.state.ItemStateException)72 Path (org.apache.jackrabbit.spi.Path)67 ItemNotFoundException (javax.jcr.ItemNotFoundException)65 PathNotFoundException (javax.jcr.PathNotFoundException)65 NodeId (org.apache.jackrabbit.core.id.NodeId)64 Property (javax.jcr.Property)61 HashMap (java.util.HashMap)53 Authorizable (org.apache.jackrabbit.api.security.user.Authorizable)53 ConstraintViolationException (javax.jcr.nodetype.ConstraintViolationException)52 InvalidItemStateException (javax.jcr.InvalidItemStateException)50