Package javax.jcr.version

Examples of javax.jcr.version.VersionIterator


     * Tests if restore on simple versioning creates a new version that is
     * in the correct linear order.
     */
    public void testLinearVersionsJcr2_2() throws Exception {
        // first get all linear versions
        VersionIterator iter = versionManager.getVersionHistory(versionableNode.getPath()).getAllLinearVersions();
        StringBuffer expected = new StringBuffer();
        while (iter.hasNext()) {
            expected.append(iter.nextVersion().getName()).append(",");
        }
        // restore version
        versionManager.restore(version, true);
        // append new base version
        expected.append(versionManager.getBaseVersion(versionableNode.getPath()).getName()).append(",");

        // get the version names again
        iter = versionManager.getVersionHistory(versionableNode.getPath()).getAllLinearVersions();
        StringBuffer actual = new StringBuffer();
        while (iter.hasNext()) {
            actual.append(iter.nextVersion().getName()).append(",");
        }
        assertEquals("Node.restore() on simple versioning must create a new version.",
                expected.toString(), actual.toString());
    }
View Full Code Here


     * Tests if restore on simple versioning creates a new version that is
     * in the correct linear order.
     */
    public void testLinearVersionsJcr2_3() throws Exception {
        // first get all linear versions
        VersionIterator iter = versionManager.getVersionHistory(versionableNode.getPath()).getAllLinearVersions();
        StringBuffer expected = new StringBuffer();
        while (iter.hasNext()) {
            expected.append(iter.nextVersion().getName()).append(",");
        }
        // restore version
        versionManager.restore(versionableNode.getPath(), version.getName(), true);
        // append new base version
        expected.append(versionManager.getBaseVersion(versionableNode.getPath()).getName()).append(",");

        // get the version names again
        iter = versionManager.getVersionHistory(versionableNode.getPath()).getAllLinearVersions();
        StringBuffer actual = new StringBuffer();
        while (iter.hasNext()) {
            actual.append(iter.nextVersion().getName()).append(",");
        }
        assertEquals("Node.restore() on simple versioning must create a new version.",
                expected.toString(), actual.toString());
    }
View Full Code Here

     * Tests if restore on simple versioning creates a new version that is
     * in the correct linear order.
     */
    public void testLinearVersionsJcr2_4() throws Exception {
        // first get all linear versions
        VersionIterator iter = versionManager.getVersionHistory(versionableNode.getPath()).getAllLinearVersions();
        StringBuffer expected = new StringBuffer();
        while (iter.hasNext()) {
            expected.append(iter.nextVersion().getName()).append(",");
        }
        // restore version
        versionManager.restore(new Version[] {version}, true);
        // append new base version
        expected.append(versionManager.getBaseVersion(versionableNode.getPath()).getName()).append(",");

        // get the version names again
        iter = versionManager.getVersionHistory(versionableNode.getPath()).getAllLinearVersions();
        StringBuffer actual = new StringBuffer();
        while (iter.hasNext()) {
            actual.append(iter.nextVersion().getName()).append(",");
        }
        assertEquals("Node.restore() on simple versioning must create a new version.",
                expected.toString(), actual.toString());
    }
View Full Code Here

                if (ROOT_VERSION.equals(name)) {
                    // required root-version property for version-history resource
                    String rootVersionHref = getLocatorFromItem(((VersionHistory)item).getRootVersion()).getHref(true);
                    prop = new HrefProperty(ROOT_VERSION, rootVersionHref, true);
                } else if (VERSION_SET.equals(name)) {
                    VersionIterator vIter = ((VersionHistory) item).getAllVersions();
                    prop = getHrefProperty(VERSION_SET, vIter, true);
                }
            } catch (RepositoryException e) {
                log.error(e.getMessage());
            }
View Full Code Here

     * @throws DavException
     * @see org.apache.jackrabbit.webdav.version.VersionHistoryResource#getVersions()
     */
    public VersionResource[] getVersions() throws DavException {
        try {
            VersionIterator vIter = ((VersionHistory)item).getAllVersions();
            ArrayList<VersionResource> l = new ArrayList<VersionResource>();
            while (vIter.hasNext()) {
                DavResourceLocator versionLoc = getLocatorFromItem(vIter.nextVersion());
                VersionResource vr = (VersionResource) createResourceFromLocator(versionLoc);
                l.add(vr);
            }
            return l.toArray(new VersionResource[l.size()]);
        } catch (RepositoryException e) {
View Full Code Here

     * Checks if all versions but the base and root one can be removed.
     */
    public void testRemoveAllBut2() throws RepositoryException {
        String baseVersion = versionableNode.getBaseVersion().getName();
        VersionHistory vh = versionableNode.getVersionHistory();
        VersionIterator vi = vh.getAllVersions();
        while (vi.hasNext()) {
            Version currenVersion = vi.nextVersion();
            String versionName = currenVersion.getName();
            if (!versionName.equals("jcr:rootVersion") && !versionName.equals(baseVersion)) {
                vh.removeVersion(versionName);
            }
        }
View Full Code Here

            v = versionableNode.checkin();
            versions.put(v.getUUID(), v);
            versionableNode.checkout();
        }

        VersionIterator it = vHistory.getAllVersions();
        while (it.hasNext()) {
            v = it.nextVersion();
            if (!versions.containsKey(v.getUUID())) {
                fail("VersionHistory.getAllVersions() must only contain the root version and versions, that have been created by a Node.checkin() call.");
            }
            versions.remove(v.getUUID());
        }
View Full Code Here

            vnames.add(v.getIdentifier());
            versions.put(v.getIdentifier(), v);
            versionManager.checkout(versionableNode.getPath());
        }

        VersionIterator it = vHistory.getAllVersions();
        while (it.hasNext()) {
            v = it.nextVersion();
            if (!versions.containsKey(v.getIdentifier())) {
                fail("VersionHistory.getAllVersions() must only contain the root version and versions, that have been created by a Node.checkin() call.");
            }
            versions.remove(v.getIdentifier());
            // check order of linear version history (see JCR 2.0, 15.1.1.2)
View Full Code Here

     * See CMIS 1.0 section 2.2.7.6 getAllVersions
     */
    public Iterator<JcrVersion> getVersions() {
        try {
            VersionHistory versionHistory = getVersionHistory(getNode());
            final VersionIterator versions = versionHistory.getAllLinearVersions();

            return new Iterator<JcrVersion>() {
                public boolean hasNext() {
                    return versions.hasNext();
                }

                public JcrVersion next() {
                    return new JcrVersion(getNode(), versions.nextVersion(), typeManager, pathManager, nodeFactory);
                }

                public void remove() {
                    throw new UnsupportedOperationException();
                }
View Full Code Here

        n.remove();
        superuser.save();

        // get the names of the versions
        List<String> names = new LinkedList<String>();
        VersionIterator vit = vh.getAllVersions();
        while (vit.hasNext()) {
            Version v = vit.nextVersion();
            if (!v.getName().equals("jcr:rootVersion")) {
                names.add(v.getName());
            }
        }
        assertEquals("Number of versions", 3, names.size());
View Full Code Here

TOP

Related Classes of javax.jcr.version.VersionIterator

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.