Search in sources :

Example 46 with ItemExistsException

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

the class RestoreTest method testRestoreWithUUIDConflictJcr2.

/**
     * Tests if restoring the <code>Version</code> of an existing node throws an
     * <code>ItemExistsException</code> if removeExisting is set to FALSE.
     */
public void testRestoreWithUUIDConflictJcr2() throws RepositoryException, NotExecutableException {
    try {
        Node naa = createVersionableNode(versionableNode, nodeName4, versionableNodeType);
        // Verify that nodes used for the test have proper opv behaviour
        NodeDefinition nd = naa.getDefinition();
        if (nd.getOnParentVersion() != OnParentVersionAction.COPY && nd.getOnParentVersion() != OnParentVersionAction.VERSION) {
            throw new NotExecutableException("Child nodes must have OPV COPY or VERSION in order to be able to test Node.restore with uuid conflict.");
        }
        Version v = versionManager.checkin(versionableNode.getPath());
        versionManager.checkout(versionableNode.getPath());
        superuser.move(naa.getPath(), versionableNode2.getPath() + "/" + naa.getName());
        superuser.save();
        versionManager.restore(v, false);
        fail("Node.restore( Version, boolean ): An ItemExistsException must be thrown if the node to be restored already exsits and removeExisting was set to false.");
    } catch (ItemExistsException e) {
    // success
    }
}
Also used : NotExecutableException(org.apache.jackrabbit.test.NotExecutableException) Version(javax.jcr.version.Version) ItemExistsException(javax.jcr.ItemExistsException) Node(javax.jcr.Node) NodeDefinition(javax.jcr.nodetype.NodeDefinition)

Example 47 with ItemExistsException

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

the class RestoreTest method testRestoreWithUUIDConflictJcr2_4.

/**
     * Tests if restoring the <code>Version</code> of an existing node throws an
     * <code>ItemExistsException</code> if removeExisting is set to FALSE.
     */
public void testRestoreWithUUIDConflictJcr2_4() throws RepositoryException, NotExecutableException {
    try {
        Node naa = createVersionableNode(versionableNode, nodeName4, versionableNodeType);
        // Verify that nodes used for the test have proper opv behaviour
        NodeDefinition nd = naa.getDefinition();
        if (nd.getOnParentVersion() != OnParentVersionAction.COPY && nd.getOnParentVersion() != OnParentVersionAction.VERSION) {
            throw new NotExecutableException("Child nodes must have OPV COPY or VERSION in order to be able to test Node.restore with uuid conflict.");
        }
        Version v = versionManager.checkin(versionableNode.getPath());
        versionManager.checkout(versionableNode.getPath());
        superuser.move(naa.getPath(), versionableNode2.getPath() + "/" + naa.getName());
        superuser.save();
        versionManager.restore(new Version[] { v }, false);
        fail("Node.restore( Version, boolean ): An ItemExistsException must be thrown if the node to be restored already exsits and removeExisting was set to false.");
    } catch (ItemExistsException e) {
    // success
    }
}
Also used : NotExecutableException(org.apache.jackrabbit.test.NotExecutableException) Version(javax.jcr.version.Version) ItemExistsException(javax.jcr.ItemExistsException) Node(javax.jcr.Node) NodeDefinition(javax.jcr.nodetype.NodeDefinition)

Example 48 with ItemExistsException

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

the class RestoreTest method testRestoreWithUUIDConflict.

/**
     * Tests if restoring the <code>Version</code> of an existing node throws an
     * <code>ItemExistsException</code> if removeExisting is set to FALSE.
     */
@SuppressWarnings("deprecation")
public void testRestoreWithUUIDConflict() throws RepositoryException, NotExecutableException {
    try {
        Node naa = createVersionableNode(versionableNode, nodeName4, versionableNodeType);
        // Verify that nodes used for the test have proper opv behaviour
        NodeDefinition nd = naa.getDefinition();
        if (nd.getOnParentVersion() != OnParentVersionAction.COPY && nd.getOnParentVersion() != OnParentVersionAction.VERSION) {
            throw new NotExecutableException("Child nodes must have OPV COPY or VERSION in order to be able to test Node.restore with uuid conflict.");
        }
        Version v = versionableNode.checkin();
        versionableNode.checkout();
        superuser.move(naa.getPath(), versionableNode2.getPath() + "/" + naa.getName());
        superuser.save();
        versionableNode.restore(v, false);
        fail("Node.restore( Version, boolean ): An ItemExistsException must be thrown if the node to be restored already exsits and removeExisting was set to false.");
    } catch (ItemExistsException e) {
    // success
    }
}
Also used : NotExecutableException(org.apache.jackrabbit.test.NotExecutableException) Version(javax.jcr.version.Version) ItemExistsException(javax.jcr.ItemExistsException) Node(javax.jcr.Node) NodeDefinition(javax.jcr.nodetype.NodeDefinition)

Example 49 with ItemExistsException

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

the class ItemStateValidator method checkCollision.

/**
     *
     * @param parentState
     * @param propertyName
     * @throws ItemExistsException
     * @throws RepositoryException
     */
private void checkCollision(NodeState parentState, Name propertyName) throws ItemExistsException, RepositoryException {
    NodeEntry parentEntry = (NodeEntry) parentState.getHierarchyEntry();
    // NOTE: check for name collisions with existing child node has been
    // removed as with JSR 283 having same-named node and property can be
    // allowed. thus delegate the corresponding validation to the underlying
    // SPI implementation.
    // check for name collisions with an existing property
    PropertyEntry pe = parentEntry.getPropertyEntry(propertyName);
    if (pe != null) {
        try {
            pe.getPropertyState();
            throw new ItemExistsException("Property '" + pe.getName() + "' already exists.");
        } catch (ItemNotFoundException e) {
        // apparently conflicting entry does not exist any more
        // ignore and return
        }
    }
}
Also used : NodeEntry(org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry) PropertyEntry(org.apache.jackrabbit.jcr2spi.hierarchy.PropertyEntry) ItemExistsException(javax.jcr.ItemExistsException) ItemNotFoundException(javax.jcr.ItemNotFoundException)

Example 50 with ItemExistsException

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

the class RestoreTest method testRestoreWithUUIDConflictJcr2_4.

/**
     * Tests if restoring the <code>Version</code> of an existing node throws an
     * <code>ItemExistsException</code> if removeExisting is set to FALSE.
     */
public void testRestoreWithUUIDConflictJcr2_4() throws RepositoryException, NotExecutableException {
    try {
        Node naa = createVersionableNode(versionableNode, nodeName4, versionableNodeType);
        // Verify that nodes used for the test have proper opv behaviour
        NodeDefinition nd = naa.getDefinition();
        if (nd.getOnParentVersion() != OnParentVersionAction.COPY && nd.getOnParentVersion() != OnParentVersionAction.VERSION) {
            throw new NotExecutableException("Child nodes must have OPV COPY or VERSION in order to be able to test Node.restore with uuid conflict.");
        }
        Version v = versionManager.checkin(versionableNode.getPath());
        versionManager.checkout(versionableNode.getPath());
        superuser.move(naa.getPath(), versionableNode2.getPath() + "/" + naa.getName());
        superuser.save();
        versionManager.restore(new Version[] { v }, false);
        fail("Node.restore( Version, boolean ): An ItemExistsException must be thrown if the node to be restored already exsits and removeExisting was set to false.");
    } catch (ItemExistsException e) {
    // success
    }
}
Also used : NotExecutableException(org.apache.jackrabbit.test.NotExecutableException) Version(javax.jcr.version.Version) ItemExistsException(javax.jcr.ItemExistsException) Node(javax.jcr.Node) NodeDefinition(javax.jcr.nodetype.NodeDefinition)

Aggregations

ItemExistsException (javax.jcr.ItemExistsException)63 Node (javax.jcr.Node)25 RepositoryException (javax.jcr.RepositoryException)25 NotExecutableException (org.apache.jackrabbit.test.NotExecutableException)16 ConstraintViolationException (javax.jcr.nodetype.ConstraintViolationException)15 NodeDefinition (javax.jcr.nodetype.NodeDefinition)14 ItemNotFoundException (javax.jcr.ItemNotFoundException)13 Version (javax.jcr.version.Version)13 NodeId (org.apache.jackrabbit.core.id.NodeId)12 Name (org.apache.jackrabbit.spi.Name)12 NodeState (org.apache.jackrabbit.core.state.NodeState)10 ChildNodeEntry (org.apache.jackrabbit.core.state.ChildNodeEntry)9 Path (org.apache.jackrabbit.spi.Path)8 PathNotFoundException (javax.jcr.PathNotFoundException)6 EffectiveNodeType (org.apache.jackrabbit.core.nodetype.EffectiveNodeType)6 QPropertyDefinition (org.apache.jackrabbit.spi.QPropertyDefinition)6 NodeImpl (org.apache.jackrabbit.core.NodeImpl)5 QNodeDefinition (org.apache.jackrabbit.spi.QNodeDefinition)5 ArrayList (java.util.ArrayList)4 AccessDeniedException (javax.jcr.AccessDeniedException)4