Search in sources :

Example 6 with UnsupportedRepositoryOperationException

use of javax.jcr.UnsupportedRepositoryOperationException in project jackrabbit by apache.

the class WorkspaceTest method testCreateWorkspaceFromSource.

public void testCreateWorkspaceFromSource() throws Exception {
    Session s = null;
    try {
        Workspace wsp = superuser.getWorkspace();
        String name = getNewWorkspaceName(wsp);
        wsp.createWorkspace(name, wsp.getName());
        List<String> wsps = Arrays.asList(wsp.getAccessibleWorkspaceNames());
        assertTrue(wsps.contains(name));
        s = getHelper().getSuperuserSession(name);
        Workspace newW = s.getWorkspace();
        assertEquals(name, newW.getName());
    } catch (UnsupportedRepositoryOperationException e) {
        throw new NotExecutableException();
    } catch (UnsupportedOperationException e) {
        throw new NotExecutableException();
    } finally {
        if (s != null) {
            s.logout();
        }
    }
}
Also used : UnsupportedRepositoryOperationException(javax.jcr.UnsupportedRepositoryOperationException) NotExecutableException(org.apache.jackrabbit.test.NotExecutableException) Session(javax.jcr.Session) Workspace(javax.jcr.Workspace)

Example 7 with UnsupportedRepositoryOperationException

use of javax.jcr.UnsupportedRepositoryOperationException in project jackrabbit by apache.

the class VersionManagerImpl method merge.

/**
     * {@inheritDoc}
     */
public NodeIterator merge(Node activityNode) throws RepositoryException {
    NodeImpl actNode = (NodeImpl) activityNode;
    if (!actNode.isNodeType(NameConstants.NT_ACTIVITY)) {
        String msg = "Given node is not an activity: " + actNode.safeGetJCRPath();
        log.error(msg);
        throw new UnsupportedRepositoryOperationException(msg);
    }
    InternalActivity activity = vMgr.getActivity(actNode.getNodeId());
    if (activity == null) {
        String msg = "Given activity not found in version storage.";
        log.error(msg);
        throw new UnsupportedRepositoryOperationException(msg);
    }
    List<ItemId> failedIds = new ArrayList<ItemId>();
    merge(activity, failedIds);
    return new LazyItemIterator(context, failedIds);
}
Also used : UnsupportedRepositoryOperationException(javax.jcr.UnsupportedRepositoryOperationException) InternalActivity(org.apache.jackrabbit.core.version.InternalActivity) ArrayList(java.util.ArrayList) ItemId(org.apache.jackrabbit.core.id.ItemId)

Example 8 with UnsupportedRepositoryOperationException

use of javax.jcr.UnsupportedRepositoryOperationException in project jackrabbit by apache.

the class LifecycleTest method testGetAllowedLifecycleTransitions.

public void testGetAllowedLifecycleTransitions() throws RepositoryException, NotExecutableException {
    Node node = superuser.getNode(path);
    try {
        String[] transitions = node.getAllowedLifecycleTransistions();
        assertNotNull("Return value of getAllowedLifecycleTransitions is null", transitions);
        for (int i = 0; i < transitions.length; i++) {
            if (transition.equals(transitions[i])) {
                return;
            }
        }
        fail("Configured lifecycle transition \"" + transition + "\" is not among the allowed transitions from node " + path);
    } catch (UnsupportedRepositoryOperationException e) {
        fail("Unable to get allowed lifecycle transitions for node " + path + ": " + e.getMessage());
    }
}
Also used : UnsupportedRepositoryOperationException(javax.jcr.UnsupportedRepositoryOperationException) Node(javax.jcr.Node)

Example 9 with UnsupportedRepositoryOperationException

use of javax.jcr.UnsupportedRepositoryOperationException in project jackrabbit by apache.

the class NodeReadMethodsTest method testGetUUIDOfNonReferenceableNode.

/**
     * Test if getUUID() throws a UnsupportedRepositoryOperationException if
     * Node is not referenceable
     */
public void testGetUUIDOfNonReferenceableNode() throws NotExecutableException, RepositoryException {
    // find a node NOT of type mix:referenceable
    Node node = locateNonReferenceableNode(testRootNode);
    if (node == null) {
        throw new NotExecutableException("Workspace does not contain a non referenceable node");
    }
    try {
        node.getUUID();
        fail("UnsupportedRepositoryOperationException expected");
    } catch (UnsupportedRepositoryOperationException e) {
    // success
    }
}
Also used : UnsupportedRepositoryOperationException(javax.jcr.UnsupportedRepositoryOperationException) NotExecutableException(org.apache.jackrabbit.test.NotExecutableException) Node(javax.jcr.Node)

Example 10 with UnsupportedRepositoryOperationException

use of javax.jcr.UnsupportedRepositoryOperationException in project jackrabbit by apache.

the class NodeImpl method orderBefore.

/**
     * @see Node#orderBefore(String, String)
     */
public synchronized void orderBefore(String srcChildRelPath, String destChildRelPath) throws UnsupportedRepositoryOperationException, VersionException, ConstraintViolationException, ItemNotFoundException, LockException, RepositoryException {
    checkIsWritable();
    if (!getPrimaryNodeType().hasOrderableChildNodes()) {
        throw new UnsupportedRepositoryOperationException("Child node ordering not supported on node " + safeGetJCRPath());
    }
    // check arguments
    if (srcChildRelPath.equals(destChildRelPath)) {
        // there's nothing to do
        return;
    }
    // check existence
    if (!hasNode(srcChildRelPath)) {
        throw new ItemNotFoundException("Node " + safeGetJCRPath() + " has no child node with name " + srcChildRelPath);
    }
    if (destChildRelPath != null && !hasNode(destChildRelPath)) {
        throw new ItemNotFoundException("Node " + safeGetJCRPath() + " has no child node with name " + destChildRelPath);
    }
    Path srcPath = getReorderPath(srcChildRelPath);
    Path beforePath = null;
    if (destChildRelPath != null) {
        beforePath = getReorderPath(destChildRelPath);
    }
    Operation op = ReorderNodes.create(getNodeState(), srcPath, beforePath);
    session.getSessionItemStateManager().execute(op);
}
Also used : Path(org.apache.jackrabbit.spi.Path) UnsupportedRepositoryOperationException(javax.jcr.UnsupportedRepositoryOperationException) Operation(org.apache.jackrabbit.jcr2spi.operation.Operation) ItemNotFoundException(javax.jcr.ItemNotFoundException)

Aggregations

UnsupportedRepositoryOperationException (javax.jcr.UnsupportedRepositoryOperationException)57 RepositoryException (javax.jcr.RepositoryException)17 Node (javax.jcr.Node)14 NotExecutableException (org.apache.jackrabbit.test.NotExecutableException)12 NodeId (org.apache.jackrabbit.core.id.NodeId)8 ArrayList (java.util.ArrayList)7 Workspace (javax.jcr.Workspace)5 ConstraintViolationException (javax.jcr.nodetype.ConstraintViolationException)5 Session (javax.jcr.Session)4 VersionManager (javax.jcr.version.VersionManager)4 NodeState (org.apache.jackrabbit.core.state.NodeState)4 Name (org.apache.jackrabbit.spi.Name)4 Path (org.apache.jackrabbit.spi.Path)4 IOException (java.io.IOException)3 ItemExistsException (javax.jcr.ItemExistsException)3 ItemNotFoundException (javax.jcr.ItemNotFoundException)3 NodeType (javax.jcr.nodetype.NodeType)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 AccessDeniedException (javax.jcr.AccessDeniedException)2