Package javax.jcr.version

Examples of javax.jcr.version.Version


        Node n2 = (Node) s2.getItem(n1.getPath());

        //log.println("---------------------------------------");
        String phase="init";

        Version v1_1 = n1.getBaseVersion();
        Version v2_1 = n2.getBaseVersion();

        check(v1_1, phase, "jcr:rootVersion", 0);
        check(v2_1, phase, "jcr:rootVersion", 0);

        //log.println("--------checkout/checkin n1 (uncommitted)----------");
        phase="checkin N1 uncomitted.";

        UserTransaction tx = new UserTransactionImpl(s1);
        tx.begin();

        n1.checkout();
        n1.checkin();

        Version v1_2 = n1.getBaseVersion();

        check(v1_1, phase, "jcr:rootVersion", 1);
        check(v2_1, phase, "jcr:rootVersion", 0);
        check(v1_2, phase, "1.0", 0);

        //log.println("--------checkout/checkin n1 (comitted)----------");
        phase="checkin N1 committed.";

        tx.commit();

        check(v1_1, phase, "jcr:rootVersion", 1);
        check(v2_1, phase, "jcr:rootVersion", 1);
        check(v1_2, phase, "1.0", 0);

        //log.println("--------restore n2 (uncommitted) ----------");
        phase="restore N2 uncommitted.";

        tx = new UserTransactionImpl(s2);
        tx.begin();

        n2.restore("1.0", false);
        Version v2_2 = n2.getBaseVersion();

        check(v1_1, phase, "jcr:rootVersion", 1);
        check(v2_1, phase, "jcr:rootVersion", 1);
        check(v1_2, phase, "1.0", 0);
        check(v2_2, phase, "1.0", 0);

        //log.println("--------restore n2 (comitted) ----------");
        phase="restore N2 committed.";

        tx.commit();

        check(v1_1, phase, "jcr:rootVersion", 1);
        check(v2_1, phase, "jcr:rootVersion", 1);
        check(v1_2, phase, "1.0", 0);
        check(v2_2, phase, "1.0", 0);

        //log.println("--------checkout/checkin n2 (uncommitted) ----------");
        phase="checkin N2 uncommitted.";

        tx = new UserTransactionImpl(s2);
        tx.begin();

        n2.checkout();
        n2.checkin();

        Version v2_3 = n2.getBaseVersion();

        check(v1_1, phase, "jcr:rootVersion", 1);
        check(v2_1, phase, "jcr:rootVersion", 1);
        check(v1_2, phase, "1.0", 0);
        check(v2_2, phase, "1.0", 1);
        check(v2_3, phase, "1.1", 0);

        //log.println("--------checkout/checkin n2 (committed) ----------");
        phase="checkin N2 committed.";

        tx.commit();

        check(v1_1, phase, "jcr:rootVersion", 1);
        check(v2_1, phase, "jcr:rootVersion", 1);
        check(v1_2, phase, "1.0", 1);
        check(v2_2, phase, "1.0", 1);
        check(v2_3, phase, "1.1", 0);

        //log.println("--------checkout/checkin n1 (uncommitted) ----------");
        phase="checkin N1 uncommitted.";

        tx = new UserTransactionImpl(s1);
        tx.begin();

        n1.checkout();
        n1.checkin();

        Version v1_3 = n1.getBaseVersion();

        check(v1_1, phase, "jcr:rootVersion", 1);
        check(v2_1, phase, "jcr:rootVersion", 1);
        check(v1_2, phase, "1.0", 2);
        check(v2_2, phase, "1.0", 1);
View Full Code Here


        // reference node in other session
        Node nOther = otherSuperuser.getNodeByUUID(n.getUUID());

        // create another version
        Version v = n.checkin();

        // start transaction
        utx.begin();

        // add new version label
        n.getVersionHistory().addVersionLabel(v.getName(), versionLabel, false);

        // assert: version label unknown in other session
        try {
            nOther.getVersionHistory().getVersionByLabel(versionLabel);
            fail("Version label visible outside tx.");
View Full Code Here

    /**
     * @see javax.jcr.version.VersionHistory#removeVersionLabel(String)
     */
    public void removeVersionLabel(String label) throws RepositoryException {
        try {
            Version existing = session.getVersionManager().setVersionLabel(this,
                    null,
                    NameFormat.parse(label, session.getNamespaceResolver()),
                    true);
            if (existing == null) {
                throw new VersionException("No version with label '" + label + "' exists in this version history.");
View Full Code Here

                Node node = session.getNode(path);
                try {
                    if (opts.isDryRun()) {
                        track("V", String.format("%s (---)", path));
                    } else {
                        Version v = node.checkin();
                        track("V", String.format("%s (%s)", path, v.getName()));
                    }
                } catch (RepositoryException e) {
                    log.error("Error while checkin node {}: {}",path, e.toString());
                }
            } catch (RepositoryException e) {
View Full Code Here

        // make a2 versionable
        ensureMixinType(a2, mixVersionable);
        a2.save();

        // check in version and check out again
        Version v = a2.checkin();
        a2.checkout();

        // delete b2 and save
        a2.getNode("b2").remove();
        a2.save();
View Full Code Here

        // make a2 versionable
        ensureMixinType(a2, mixVersionable);
        a2.save();

        // check in version and check out again
        Version v = a2.checkin();
        a2.checkout();

        // delete b2 and save
        a2.getNode("b2").remove();
        a2.save();
View Full Code Here

     */
    public Version checkpoint(String absPath) throws RepositoryException {
        // this is not quite correct, since the entire checkpoint operation
        // should be atomic
        Node node = session.getNode(absPath);
        Version v = node.checkin();
        node.checkout();
        return v;
    }
View Full Code Here

        // create a version selector to the set of versions
        VersionSelector vsel = new VersionSelector() {
            public Version select(VersionHistory versionHistory) throws RepositoryException {
                // try to select version as specified
                Version v = toRestore.get(versionHistory.getUUID());
                if (v == null) {
                    // select latest one
                    v = DateVersionSelector.selectByDate(versionHistory, null);
                }
                return v;
            }
        };

        // check for pending changes
        if (session.hasPendingChanges()) {
            String msg = "Unable to restore version. Session has pending changes.";
            log.debug(msg);
            throw new InvalidItemStateException(msg);
        }
        // TODO: add checks for lock/hold...
        boolean success = false;
        try {
            // now restore all versions that have a node in the ws
            int numRestored = 0;
            while (toRestore.size() > 0) {
                Version[] restored = null;
                for (VersionImpl v : toRestore.values()) {
                    try {
                        NodeImpl node = (NodeImpl) session.getNodeById(v.getInternalFrozenNode().getFrozenId());
                        restored = node.internalRestore(v, vsel, removeExisting);
                        // remove restored versions from set
                        for (Version r : restored) {
                            toRestore.remove(r.getContainingHistory().getUUID());
                        }
View Full Code Here

     * specified version is not part of this node's version history.
     *
     * @throws RepositoryException
     */
    public void testRestoreInvalidVersion() throws RepositoryException {
        Version vNode2 = versionableNode2.checkin();
        try {
            versionableNode.restore(vNode2, true);

            fail("VersionException expected on Node.restore(Version, boolean) if the specified version is not part of this node's version history.");
        } catch (VersionException e) {
View Full Code Here

     * specified version is not part of this node's version history.
     *
     * @throws RepositoryException
     */
    public void testRestoreInvalidVersionJcr2() throws RepositoryException {
        Version vNode2 = versionManager.checkin(versionableNode2.getPath());
        try {
            versionManager.restore(versionableNode.getPath(), vNode2, true);

            fail("VersionException expected on Node.restore(Version, boolean) if the specified version is not part of this node's version history.");
        } catch (VersionException e) {
View Full Code Here

TOP

Related Classes of javax.jcr.version.Version

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.