Search in sources :

Example 61 with VersionException

use of javax.jcr.version.VersionException in project jackrabbit by apache.

the class RestoreTest method testRestoreWithInvalidVersionJcr2.

/**
     * Test if restoring a node with an invalid Version throws a VersionException
     *
     * @throws RepositoryException
     */
public void testRestoreWithInvalidVersionJcr2() throws RepositoryException {
    Version invalidVersion = versionManager.checkin(versionableNode2.getPath());
    try {
        versionManager.restore(versionableNode.getPath(), invalidVersion, true);
        fail("Node.restore(Version, boolean): A VersionException must be thrown if the specified version does not exists in this node's version history.");
    } catch (VersionException e) {
    // success
    }
}
Also used : Version(javax.jcr.version.Version) VersionException(javax.jcr.version.VersionException)

Example 62 with VersionException

use of javax.jcr.version.VersionException in project jackrabbit by apache.

the class VersionLabelTest method testMoveLabelJcr2.

/**
     * Test if the 'moveLabel' flag moves an existing version label.
     *
     * @throws RepositoryException
     * @see VersionHistory#addVersionLabel(String, String, boolean)  with boolan flag equals true.
     */
public void testMoveLabelJcr2() throws RepositoryException {
    vHistory.addVersionLabel(version.getName(), versionLabel, false);
    try {
        VersionManager versionManager = versionableNode.getSession().getWorkspace().getVersionManager();
        String path = versionableNode.getPath();
        versionManager.checkout(path);
        Version v = versionManager.checkin(path);
        vHistory.addVersionLabel(v.getName(), versionLabel, true);
        if (!vHistory.hasVersionLabel(v, versionLabel)) {
            fail("If 'moveLabel' is true, an existing version label must be moved to the indicated version.");
        }
    } catch (VersionException e) {
        fail("If 'moveLabel' is true, an existing version label must be moved to the indicated version.");
    }
}
Also used : Version(javax.jcr.version.Version) VersionManager(javax.jcr.version.VersionManager) VersionException(javax.jcr.version.VersionException)

Example 63 with VersionException

use of javax.jcr.version.VersionException in project jackrabbit by apache.

the class VersionLabelTest method testMoveLabel.

/**
     * Test if the 'moveLabel' flag moves an existing version label.
     *
     * @throws RepositoryException
     * @see VersionHistory#addVersionLabel(String, String, boolean)  with boolan flag equals true.
     */
@SuppressWarnings("deprecation")
public void testMoveLabel() throws RepositoryException {
    vHistory.addVersionLabel(version.getName(), versionLabel, false);
    try {
        versionableNode.checkout();
        Version v = versionableNode.checkin();
        vHistory.addVersionLabel(v.getName(), versionLabel, true);
        if (!vHistory.hasVersionLabel(v, versionLabel)) {
            fail("If 'moveLabel' is true, an existing version label must be moved to the indicated version.");
        }
    } catch (VersionException e) {
        fail("If 'moveLabel' is true, an existing version label must be moved to the indicated version.");
    }
}
Also used : Version(javax.jcr.version.Version) VersionException(javax.jcr.version.VersionException)

Example 64 with VersionException

use of javax.jcr.version.VersionException in project jackrabbit by apache.

the class SessionMoveVersionExceptionTest method testSessionMoveSourceCheckedInVersionException.

/**
     * Tries to move a node using {@link javax.jcr.Session#move(String, String)}
     * where the source parent is checked in. This should throw an {@link
     * javax.jcr.version.VersionException}.
     */
public void testSessionMoveSourceCheckedInVersionException() throws RepositoryException {
    // add a node under a versionable node
    Node movingNode = versionableNode.addNode(nodeName1, nonVersionableNodeType.getName());
    versionableNode.save();
    // check the parent node in
    versionableNode.checkin();
    try {
        // try to move the sub node this should throw an VersionException
        // either instantly or upon save()
        superuser.move(movingNode.getPath(), nonVersionableNode.getPath() + "/" + nodeName1);
        superuser.save();
        fail("Moving a node using Session.move() where parent node is " + "versionable and checked in should throw a VersionException!");
    } catch (VersionException e) {
    // ok, works as expected
    }
}
Also used : Node(javax.jcr.Node) VersionException(javax.jcr.version.VersionException)

Example 65 with VersionException

use of javax.jcr.version.VersionException in project jackrabbit by apache.

the class VersionLabelTest method testAddDuplicateVersionLabelJcr2.

/**
     * Test if VersionHistory.addVersionLabel(versionName, label, moveLabel)
     * throws VersionException the label already exists and if moveLabel is false)
     *
     * @throws RepositoryException
     */
public void testAddDuplicateVersionLabelJcr2() throws RepositoryException {
    vHistory.addVersionLabel(version.getName(), versionLabel, false);
    try {
        VersionManager versionManager = versionableNode.getSession().getWorkspace().getVersionManager();
        String path = versionableNode.getPath();
        versionManager.checkout(path);
        Version v = versionManager.checkin(path);
        vHistory.addVersionLabel(v.getName(), versionLabel, false);
        fail("Adding a version label that already exist in the version history must throw a VersionException.");
    } catch (VersionException e) {
    //success
    }
}
Also used : Version(javax.jcr.version.Version) VersionManager(javax.jcr.version.VersionManager) VersionException(javax.jcr.version.VersionException)

Aggregations

VersionException (javax.jcr.version.VersionException)78 Node (javax.jcr.Node)25 Version (javax.jcr.version.Version)25 RepositoryException (javax.jcr.RepositoryException)19 Name (org.apache.jackrabbit.spi.Name)8 NotExecutableException (org.apache.jackrabbit.test.NotExecutableException)7 Property (javax.jcr.Property)6 Session (javax.jcr.Session)6 NameException (org.apache.jackrabbit.spi.commons.conversion.NameException)6 VersionIterator (javax.jcr.version.VersionIterator)5 VersionManager (javax.jcr.version.VersionManager)5 NodeId (org.apache.jackrabbit.core.id.NodeId)5 Nonnull (javax.annotation.Nonnull)4 ItemExistsException (javax.jcr.ItemExistsException)4 UnsupportedRepositoryOperationException (javax.jcr.UnsupportedRepositoryOperationException)4 ConstraintViolationException (javax.jcr.nodetype.ConstraintViolationException)4 RetentionManager (javax.jcr.retention.RetentionManager)4 LabelExistsVersionException (javax.jcr.version.LabelExistsVersionException)4 ItemStateException (org.apache.jackrabbit.core.state.ItemStateException)4 CommitFailedException (org.apache.jackrabbit.oak.api.CommitFailedException)4