Examples of VersionManager


Examples of javax.jcr.version.VersionManager

     * {@inheritDoc}
     */
    public NodeId checkpoint(SessionInfo sessionInfo, final NodeId nodeId, final NodeId activityId) throws UnsupportedRepositoryOperationException, RepositoryException {
        final SessionInfoImpl sInfo = getSessionInfoImpl(sessionInfo);
        Node activity = (activityId == null) ? null : getNode(activityId, sInfo);
        VersionManager vMgr = sInfo.getSession().getWorkspace().getVersionManager();
        vMgr.setActivity(activity);
        try {
            Version newVersion = (Version) executeWithLocalEvents(new Callable() {
                public Object run() throws RepositoryException {
                    VersionManager vMgr = sInfo.getSession().getWorkspace().getVersionManager();
                    return vMgr.checkpoint(getNodePath(nodeId, sInfo));
                }
            }, sInfo);
            return idFactory.createNodeId(newVersion);
        } finally {
            vMgr.setActivity(null);
        }
    }
View Full Code Here

Examples of javax.jcr.version.VersionManager

    /**
     * {@inheritDoc}
     */
    public NodeId createActivity(SessionInfo sessionInfo, final String title) throws UnsupportedRepositoryOperationException, RepositoryException {
        final SessionInfoImpl sInfo = getSessionInfoImpl(sessionInfo);
        final VersionManager vMgr = getVersionManager(sInfo);
        Node activity = (Node) executeWithLocalEvents(new Callable() {
            public Object run() throws RepositoryException {
                return vMgr.createActivity(title);
            }
        }, getSessionInfoImpl(sessionInfo));
        return idFactory.createNodeId(activity);
    }
View Full Code Here

Examples of javax.jcr.version.VersionManager

    /**
     * {@inheritDoc}
     */
    public void removeActivity(SessionInfo sessionInfo, final NodeId activityId) throws UnsupportedRepositoryOperationException, RepositoryException {
        final SessionInfoImpl sInfo = getSessionInfoImpl(sessionInfo);
        final VersionManager vMgr = getVersionManager(sInfo);
        executeWithLocalEvents(new Callable() {
            public Object run() throws RepositoryException {
                vMgr.removeActivity(getNode(activityId, sInfo));
                return null;
            }
        }, getSessionInfoImpl(sessionInfo));
    }
View Full Code Here

Examples of javax.jcr.version.VersionManager

     * {@inheritDoc}
     */
    public NodeId createConfiguration(SessionInfo sessionInfo, final NodeId nodeId)
            throws UnsupportedRepositoryOperationException, RepositoryException {
        final SessionInfoImpl sInfo = getSessionInfoImpl(sessionInfo);
        final VersionManager vMgr = getVersionManager(sInfo);
        Node configuration = (Node) executeWithLocalEvents(new Callable() {
            public Object run() throws RepositoryException {
                return vMgr.createConfiguration(getNodePath(nodeId, sInfo));
            }
        }, getSessionInfoImpl(sessionInfo));
        return idFactory.createNodeId(configuration);
    }
View Full Code Here

Examples of javax.jcr.version.VersionManager

     * <a href="https://issues.apache.org/jira/browse/JCR-2796">JCR-2796</a>.
     */
    public void testRestore() throws Exception {
        Session session = getHelper().getSuperuserSession();
        try {
            VersionManager vm = session.getWorkspace().getVersionManager();

            // make sure that 'testNode' does not exist at the beginning
            // of the test
            while (session.nodeExists("/testNode")) {
                session.getNode("/testNode").remove();
                session.save();
            }

            // 1) create 'testNode' that has a child and a grandchild
            Node node = session.getRootNode().addNode("testNode");
            node.addMixin(NodeType.MIX_VERSIONABLE);
            node.addNode("child").addNode("grandchild");
            session.save();

            // 2) check in 'testNode' and give a version-label
            Version version = vm.checkin(node.getPath());
            vm.getVersionHistory(node.getPath()).addVersionLabel(
                    version.getName(), "testLabel", false);

            // 3) do restore by label
            UserTransaction utx = new UserTransactionImpl(session);
            utx.begin();
            vm.restoreByLabel(node.getPath(), "testLabel", true);
            utx.commit();

            // 4) try to get the grandchild (fails if the restoring has
            // been done within a transaction)
            assertTrue(node.hasNode("child/grandchild"));
View Full Code Here

Examples of javax.jcr.version.VersionManager

        if (!importTargetTree.exists()) {
            throw new PathNotFoundException(absPath);
        }

        // TODO: review usage of write-root and object obtained from session-context (OAK-931)
        VersionManager vMgr = sessionContext.getWorkspace().getVersionManager();
        if (!vMgr.isCheckedOut(absPath)) {
            throw new VersionException("Target node is checked in.");
        }
        if (importTargetTree.getStatus() != Tree.Status.NEW
                && sessionContext.getWorkspace().getLockManager().isLocked(absPath)) {
            throw new LockException("Target node is locked.");
View Full Code Here

Examples of javax.jcr.version.VersionManager

* <code>RestoreTest</code>...
*/
public class RestoreTest extends AbstractJCRTest {

    public void testSimpleRestore() throws RepositoryException {
        VersionManager vMgr = superuser.getWorkspace().getVersionManager();
        Node n = testRootNode.addNode(nodeName1, testNodeType);
        n.addMixin(mixVersionable);
        n.setProperty("prop", "a");
        superuser.save();
        String path = n.getPath();
        Version v = vMgr.checkpoint(path); // 1.0
        n.setProperty("prop", "b");
        superuser.save();
        vMgr.checkpoint(path); // 1.1
        n.remove();
        superuser.save();
        vMgr.restore(path, v, true);
        assertTrue(superuser.nodeExists(path));
        n = superuser.getNode(path);
        assertEquals("Property not restored", "a", n.getProperty("prop").getString());
    }
View Full Code Here

Examples of org.apache.jackrabbit.api.jsr283.version.VersionManager

        super.setUp();
    }

    public void testCopy() throws RepositoryException {
        Workspace wsp = (Workspace) superuser.getWorkspace();
        VersionManager vMgr = wsp.getVersionManager();
        String srcPath = versionableNode.getPath();
        String dstPath = getProperty("destination");
        wsp.copy(srcPath, dstPath);

        // check versionable
        Node v = (Node) ((org.apache.jackrabbit.api.jsr283.Session) superuser).getNode(dstPath);
        assertTrue("Copied Node.isNodeType(mix:simpleVersionable) must return true.",
                v.isNodeType(mixSimpleVersionable));
        assertFalse("Copied Node.isNodeType(mix:versionable) must return false.",
                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));
    }
View Full Code Here

Examples of org.apache.jackrabbit.core.version.VersionManager

            ItemState itemState = (ItemState) iter.next();
            if (itemState.isNode()) {
                NodeImpl node = (NodeImpl) itemMgr.getItem(itemState.getId());
                if (node.isNodeType(QName.MIX_VERSIONABLE)) {
                    if (!node.hasProperty(QName.JCR_VERSIONHISTORY)) {
                        VersionManager vMgr = session.getVersionManager();
                        NodeState nodeState = (NodeState) itemState;
                        /**
                         * check if there's already a version history for that
                         * node; this would e.g. be the case if a versionable
                         * node had been exported, removed and re-imported with
                         * either IMPORT_UUID_COLLISION_REMOVE_EXISTING or
                         * IMPORT_UUID_COLLISION_REPLACE_EXISTING;
                         * otherwise create a new version history
                         */
                        VersionHistory vh = vMgr.getVersionHistory(session, nodeState);
                        if (vh == null) {
                            vh = vMgr.createVersionHistory(session, nodeState);
                        }
                        node.internalSetProperty(QName.JCR_VERSIONHISTORY, InternalValue.create(new UUID(vh.getUUID())));
                        node.internalSetProperty(QName.JCR_BASEVERSION, InternalValue.create(new UUID(vh.getRootVersion().getUUID())));
                        node.internalSetProperty(QName.JCR_ISCHECKEDOUT, InternalValue.create(true));
                        node.internalSetProperty(QName.JCR_PREDECESSORS,
View Full Code Here

Examples of org.apache.jackrabbit.core.version.VersionManager

     * @return the version history of the target node state
     * @throws RepositoryException if an error occurs
     */
    private VersionHistory getOrCreateVersionHistory(NodeState node)
            throws RepositoryException {
        VersionManager vMgr = session.getVersionManager();
        VersionHistory vh = vMgr.getVersionHistory(session, node);
        if (vh == null) {
            // create a new version history
            vh = vMgr.createVersionHistory(session, node);
        }
        return vh;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.