Search in sources :

Example 46 with UnsupportedRepositoryOperationException

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

the class ItemSaveOperation method processShareableNodes.

/**
     * Process all items given in iterator and check whether <code>mix:shareable</code>
     * or (some derived node type) has been added or removed:
     * <ul>
     * <li>If the mixin <code>mix:shareable</code> (or some derived node type),
     * then initialize the shared set inside the state.</li>
     * <li>If the mixin <code>mix:shareable</code> (or some derived node type)
     * has been removed, throw.</li>
     * </ul>
     */
private void processShareableNodes(NodeTypeRegistry registry, Iterable<ItemState> states) throws RepositoryException {
    for (ItemState is : states) {
        if (is.isNode()) {
            NodeState ns = (NodeState) is;
            boolean wasShareable = false;
            if (ns.hasOverlayedState()) {
                NodeState old = (NodeState) ns.getOverlayedState();
                EffectiveNodeType ntOld = getEffectiveNodeType(registry, old);
                wasShareable = ntOld.includesNodeType(NameConstants.MIX_SHAREABLE);
            }
            EffectiveNodeType ntNew = getEffectiveNodeType(registry, ns);
            boolean isShareable = ntNew.includesNodeType(NameConstants.MIX_SHAREABLE);
            if (!wasShareable && isShareable) {
                // mix:shareable has been added
                ns.addShare(ns.getParentId());
            } else if (wasShareable && !isShareable) {
                // mix:shareable has been removed: not supported
                String msg = "Removing mix:shareable is not supported.";
                log.debug(msg);
                throw new UnsupportedRepositoryOperationException(msg);
            }
        }
    }
}
Also used : UnsupportedRepositoryOperationException(javax.jcr.UnsupportedRepositoryOperationException) EffectiveNodeType(org.apache.jackrabbit.core.nodetype.EffectiveNodeType) NodeState(org.apache.jackrabbit.core.state.NodeState) ItemState(org.apache.jackrabbit.core.state.ItemState)

Example 47 with UnsupportedRepositoryOperationException

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

the class RemoveVersionTest method setUp.

protected void setUp() throws Exception {
    super.setUp();
    // create 1.0
    Version testV = versionableNode.checkin();
    versionableNode.checkout();
    // create 1.1
    versionableNode.checkin();
    versionableNode.checkout();
    // create 1.2
    versionableNode.checkin();
    try {
        versionableNode.getVersionHistory().removeVersion(testV.getName());
    } catch (UnsupportedRepositoryOperationException e) {
        throw new NotExecutableException("Removing version is not supported: " + e.getMessage());
    }
    versionableNode.checkout();
    version = versionableNode.checkin();
    // create a second version
    versionableNode.checkout();
    version2 = versionableNode.checkin();
    vHistory = versionableNode.getVersionHistory();
    // build a second versionable node below the testroot
    try {
        versionableNode2 = createVersionableNode(testRootNode, nodeName2, versionableNodeType);
    } catch (RepositoryException e) {
        fail("Failed to create a second versionable node: " + e.getMessage());
    }
}
Also used : UnsupportedRepositoryOperationException(javax.jcr.UnsupportedRepositoryOperationException) NotExecutableException(org.apache.jackrabbit.test.NotExecutableException) Version(javax.jcr.version.Version) RepositoryException(javax.jcr.RepositoryException)

Example 48 with UnsupportedRepositoryOperationException

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

the class WorkspaceTest method testDeleteWorkspace.

public void testDeleteWorkspace() throws Exception {
    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));
        wsp.deleteWorkspace(name);
        wsps = Arrays.asList(wsp.getAccessibleWorkspaceNames());
        assertFalse(wsps.contains(name));
        Session s = null;
        try {
            s = getHelper().getSuperuserSession(name);
            fail(name + " has been deleted.");
        } catch (NoSuchWorkspaceException e) {
        // success
        } finally {
            if (s != null) {
                s.logout();
            }
        }
    } catch (UnsupportedRepositoryOperationException e) {
        throw new NotExecutableException();
    } catch (UnsupportedOperationException e) {
        throw new NotExecutableException();
    }
}
Also used : NoSuchWorkspaceException(javax.jcr.NoSuchWorkspaceException) UnsupportedRepositoryOperationException(javax.jcr.UnsupportedRepositoryOperationException) NotExecutableException(org.apache.jackrabbit.test.NotExecutableException) Workspace(javax.jcr.Workspace) Session(javax.jcr.Session)

Example 49 with UnsupportedRepositoryOperationException

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

the class ConfigurationsTest method testCheckinConfigFailsWithUnversionedChild.

public void testCheckinConfigFailsWithUnversionedChild() throws Exception {
    Node config = vm.createConfiguration(versionableNode.getPath());
    try {
        vm.checkin(config.getPath());
        fail("Checkin configuration must fail one of the recorded versions is not versioned.");
    } catch (UnsupportedRepositoryOperationException e) {
    // ignore
    }
}
Also used : UnsupportedRepositoryOperationException(javax.jcr.UnsupportedRepositoryOperationException) Node(javax.jcr.Node)

Example 50 with UnsupportedRepositoryOperationException

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

the class CheckinTest method testCheckinNonVersionableNodeJcr2.

/**
     * Test calling VersionManager.checkin(P) with the path P resolving to
     * a non-versionable node.
     *
     * @throws RepositoryException
     */
public void testCheckinNonVersionableNodeJcr2() throws RepositoryException {
    try {
        VersionManager versionManager = nonVersionableNode.getSession().getWorkspace().getVersionManager();
        String path = nonVersionableNode.getPath();
        versionManager.checkin(path);
        fail("VersionManager.checkin(P) must throw UnsupportedRepositoryOperationException if the path P resolves to a non-versionable node.");
    } catch (UnsupportedRepositoryOperationException e) {
    //success
    }
}
Also used : UnsupportedRepositoryOperationException(javax.jcr.UnsupportedRepositoryOperationException) VersionManager(javax.jcr.version.VersionManager)

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