Package javax.jcr.version

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


    /**
     * {@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

     * {@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

     * <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

        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

* <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

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

        WorkspaceImpl wsp = sessionContext.getWorkspace();
        VersionManager vMgr = wsp.getVersionManager();
        if (!vMgr.isCheckedOut(absPath)) {
            throw new VersionException("Target node is checked in.");
        }
        if (importTargetTree.getStatus() != Tree.Status.NEW && wsp.getLockManager().isLocked(absPath)) {
            throw new LockException("Target node is locked.");
        }
View Full Code Here

        if (!exists()) {
            throw new DavException(DavServletResponse.SC_NOT_FOUND);
        }
        try {
            Node n = (Node) item;
            VersionManager vMgr = getVersionManager();
            String path = item.getPath();

            DavProperty<?> autoMergeSet = null;
            DavProperty<?> predecessorSet = null;
            /* find DAV:auto-merge-set entries. If none exists no attempt is made
               to resolve merge conflict > return silently */
            for (int i = 0; i < changeList.size(); i++) {
                PropEntry propEntry = changeList.get(i);
                // If DAV:auto-merge-set is DavPropertyName all remaining merge
                // conflicts are resolved with 'cancel'
                if (propEntry instanceof DavPropertyName && AUTO_MERGE_SET.equals(propEntry)) {
                    // retrieve the current jcr:mergeFailed property values
                    if (!n.hasProperty(JcrConstants.JCR_MERGEFAILED)) {
                        throw new DavException(DavServletResponse.SC_CONFLICT, "Attempt to resolve non-existing merge conflicts.");
                    }
                    Value[] mergeFailed = n.getProperty(JcrConstants.JCR_MERGEFAILED).getValues();
                    for (Value value : mergeFailed) {
                        vMgr.cancelMerge(path, (Version) getRepositorySession().getNodeByIdentifier(value.getString()));
                    }
                    // remove this entry from the changeList
                    changeList.remove(propEntry);
                } else if (propEntry instanceof DavProperty) {
                    if (AUTO_MERGE_SET.equals(((DavProperty<?>)propEntry).getName())) {
                        autoMergeSet = (DavProperty<?>) propEntry;
                    } else if (PREDECESSOR_SET.equals(((DavProperty<?>)propEntry).getName())) {
                        predecessorSet = (DavProperty<?>) propEntry;
                    }
                }
            }

            // If DAV:auto-merge-set is a DavProperty merge conflicts need to be
            // resolved individually according to the DAV:predecessor-set property.
            if (autoMergeSet != null) {
                // retrieve the current jcr:mergeFailed property values
                if (!n.hasProperty(JcrConstants.JCR_MERGEFAILED)) {
                    throw new DavException(DavServletResponse.SC_CONFLICT, "Attempt to resolve non-existing merge conflicts.");
                }

                List<String> mergeset = new HrefProperty(autoMergeSet).getHrefs();
                List<String> predecL;
                if (predecessorSet == null) {
                    predecL = Collections.emptyList();
                } else {
                    predecL = new HrefProperty(predecessorSet).getHrefs();
                }

                Session session = getRepositorySession();
                // loop over the mergeFailed values (versions) and test whether they are
                // removed from the DAV:auto-merge-set thus indicating resolution.
                Value[] mergeFailed = n.getProperty(JcrConstants.JCR_MERGEFAILED).getValues();
                for (Value value : mergeFailed) {
                    // build version-href from each entry in the jcr:mergeFailed property
                    // in order to be able to compare to the entries in the HrefProperty.
                    Version version = (Version) session.getNodeByIdentifier(value.getString());
                    String href = getLocatorFromItem(version).getHref(true);

                    // Test if that version has been removed from the merge-set.
                    // thus indicating that this merge conflict needs to be resolved.
                    if (!mergeset.contains(href)) {
                        // If the conflict value has been moved over from DAV:auto-merge-set
                        // to the predecessor-set, resolution with 'doneMerge' is
                        // appropriate. If the value has been removed from the
                        // merge-set but not added to the predecessors 'cancelMerge'
                        // must be called.
                        if (predecL.contains(href)) {
                            vMgr.doneMerge(path, version);
                        } else {
                            vMgr.cancelMerge(path, version);
                        }
                    }
                }
                // after successful resolution of merge-conflicts according to
                // DAV:auto-merge-set and DAV:predecessor-set remove these entries
View Full Code Here

    public void testGetTypeOfPredecessors() throws RepositoryException {
        Node node = testRootNode.addNode(nodeName1, testNodeType);
        node.addMixin(mixVersionable);
        superuser.save();
        VersionManager vMgr = superuser.getWorkspace().getVersionManager();
        vMgr.checkin(node.getPath());
        assertEquals(PropertyType.nameFromValue(PropertyType.REFERENCE),
                PropertyType.nameFromValue(node.getProperty(jcrPredecessors).getType()));
    }
View Full Code Here

    public void testReadOnlyAfterCheckin() throws RepositoryException {
        Node node = testRootNode.addNode(nodeName1, testNodeType);
        node.addMixin(mixVersionable);
        superuser.save();
        VersionManager vMgr = superuser.getWorkspace().getVersionManager();
        vMgr.checkin(node.getPath());
        try {
            node.setProperty(propertyName1, "value");
            fail("setProperty() must fail on a checked-in node");
        } catch (VersionException e) {
            // expected
View Full Code Here

TOP

Related Classes of javax.jcr.version.VersionManager

Copyright © 2018 www.massapicom. 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.