Search in sources :

Example 46 with VersionHistory

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

the class CopyTest method testCopy.

public void testCopy() throws RepositoryException {
    Workspace wsp = superuser.getWorkspace();
    VersionManager vMgr = wsp.getVersionManager();
    String srcPath = versionableNode.getPath();
    String dstPath = getProperty("destination");
    wsp.copy(srcPath, dstPath);
    // check versionable
    Node v = superuser.getNode(dstPath);
    assertTrue("Copied Node.isNodeType(mix:cersionable) must return true.", v.isNodeType(mixVersionable));
    // check different version history
    VersionHistory vh1 = vMgr.getVersionHistory(srcPath);
    VersionHistory vh2 = vMgr.getVersionHistory(dstPath);
    assertFalse("Copied node needs a new version history.", vh1.isSame(vh2));
    // check if 1 version
    assertEquals("Copied node must have 1 version.", 1, getNumberOfVersions(vh2));
    // check if jcr:copiedFrom is set correctly
    assertTrue("Version history of desination must have a jcr:copiedFrom property", vh2.hasProperty(jcrCopiedFrom));
    Node ref = vh2.getProperty(jcrCopiedFrom).getNode();
    Version base = vMgr.getBaseVersion(srcPath);
    assertTrue("jcr:copiedFrom must point to the base version of the original.", ref.isSame(base));
}
Also used : Version(javax.jcr.version.Version) Node(javax.jcr.Node) VersionManager(javax.jcr.version.VersionManager) VersionHistory(javax.jcr.version.VersionHistory) Workspace(javax.jcr.Workspace)

Example 47 with VersionHistory

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

the class RemoveVersionByLabel method execute.

/**
     * {@inheritDoc}
     */
public boolean execute(Context ctx) throws Exception {
    String path = (String) ctx.get(this.pathKey);
    String label = (String) ctx.get(this.labelKey);
    if (log.isDebugEnabled()) {
        log.debug("Remove version with label " + label + " from node " + path);
    }
    VersionHistory vh = CommandHelper.getNode(ctx, path).getVersionHistory();
    Version v = vh.getVersionByLabel(label);
    vh.removeVersion(v.getName());
    return false;
}
Also used : Version(javax.jcr.version.Version) VersionHistory(javax.jcr.version.VersionHistory)

Example 48 with VersionHistory

use of javax.jcr.version.VersionHistory in project jackrabbit-oak by apache.

the class L5_SpecialPermissionsTest method testReadVersionInformation.

@Test
public void testReadVersionInformation() throws RepositoryException {
    Node childNode = superuser.getNode(childPath);
    childNode.addMixin(JcrConstants.MIX_VERSIONABLE);
    superuser.save();
    childNode.checkin();
    childNode.checkout();
    // EXERCISE: uncomment the following permission setup and test the impact it has!
    // EXERCISE: discuss and explain your findings
    //        AccessControlUtils.addAccessControlEntry(superuser, "/jcr:system", testGroupPrincipal, new String[] {Privilege.JCR_READ}, false);
    //        paths.add("/jcr:system");
    //        superuser.save();
    //
    Session s = createTestSession();
    // EXERCISE: uncomment to verify the permission setup is as expected
    //assertFalse(s.nodeExists(VersionConstants.VERSION_STORE_PATH));
    VersionManager versionManager = s.getWorkspace().getVersionManager();
    VersionHistory vh = versionManager.getVersionHistory(childPath);
    Version rootVersion = vh.getRootVersion();
    Version baseVersion = versionManager.getBaseVersion(childPath);
}
Also used : Version(javax.jcr.version.Version) Node(javax.jcr.Node) VersionManager(javax.jcr.version.VersionManager) VersionHistory(javax.jcr.version.VersionHistory) Session(javax.jcr.Session) JackrabbitSession(org.apache.jackrabbit.api.JackrabbitSession) L3_BuiltInPrivilegesTest(org.apache.jackrabbit.oak.exercise.security.privilege.L3_BuiltInPrivilegesTest) AbstractJCRTest(org.apache.jackrabbit.test.AbstractJCRTest) Test(org.junit.Test)

Example 49 with VersionHistory

use of javax.jcr.version.VersionHistory in project jackrabbit-oak by apache.

the class VersionManagerImpl method restore.

@Override
public void restore(final String absPath, final String versionName, final boolean removeExisting) throws RepositoryException {
    VersionHistory history = getVersionHistory(absPath);
    restore(new Version[] { history.getVersion(versionName) }, removeExisting);
}
Also used : VersionHistory(javax.jcr.version.VersionHistory)

Example 50 with VersionHistory

use of javax.jcr.version.VersionHistory in project jackrabbit-oak by apache.

the class ReadVersionContentTest method testVersionHistoryGetIdentifier.

/**
     * @since oak
     */
@Test
public void testVersionHistoryGetIdentifier() throws Exception {
    VersionHistory testVh = testSession.getNode(versionablePath).getVersionHistory();
    testVh.getIdentifier();
}
Also used : VersionHistory(javax.jcr.version.VersionHistory) Test(org.junit.Test)

Aggregations

VersionHistory (javax.jcr.version.VersionHistory)73 Node (javax.jcr.Node)45 Version (javax.jcr.version.Version)29 Test (org.junit.Test)25 RepositoryException (javax.jcr.RepositoryException)17 VersionManager (javax.jcr.version.VersionManager)17 Session (javax.jcr.Session)12 VersionIterator (javax.jcr.version.VersionIterator)12 Property (javax.jcr.Property)7 DavException (org.apache.jackrabbit.webdav.DavException)7 DavResourceLocator (org.apache.jackrabbit.webdav.DavResourceLocator)7 JcrDavException (org.apache.jackrabbit.webdav.jcr.JcrDavException)7 ArrayList (java.util.ArrayList)6 DavResource (org.apache.jackrabbit.webdav.DavResource)6 ItemNotFoundException (javax.jcr.ItemNotFoundException)5 VersionHistoryResource (org.apache.jackrabbit.webdav.version.VersionHistoryResource)4 Workspace (javax.jcr.Workspace)3 VersionException (javax.jcr.version.VersionException)3 JackrabbitSession (org.apache.jackrabbit.api.JackrabbitSession)3 PathNotFoundException (javax.jcr.PathNotFoundException)2