Package javax.jcr.version

Examples of javax.jcr.version.Version


     *
     * @throws RepositoryException
     * @throws NotExecutableException
     */
    public void testRemoveInvalidVersion() throws RepositoryException, NotExecutableException {
        Version invalidV = versionableNode2.checkin();
        String invalidName = invalidV.getName();

        // build a version name that is not present in the current history
        boolean found = false;
        for (int i = 0; i < 10 && !found; i++) {
            try {
View Full Code Here


    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

                // 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)) {
View Full Code Here

        }
        if (!isVersionControlled()) {
            throw new DavException(DavServletResponse.SC_METHOD_NOT_ALLOWED);
        }
        try {
            Version v = getVersionManager().checkin(item.getPath());
            String versionHref = getLocatorFromItem(v).getHref(true);
            return versionHref;
        } catch (RepositoryException e) {
            // UnsupportedRepositoryException should not occur
            throw new JcrDavException(e);
View Full Code Here

                String relPath = DomUtil.getChildText(udElem, XML_RELPATH, NAMESPACE);
                if (relPath == null) {
                    // restore version by name
                    node.restore(versionName, removeExisting);
                } else if (node.hasNode(relPath)) {
                    Version v = node.getNode(relPath).getVersionHistory().getVersion(versionName);
                    node.restore(v, relPath, removeExisting);
                } else {
                    Version v = (Version) getRepositorySession().getNode(versionPath);
                    node.restore(v, relPath, removeExisting);
                }

            } else if (updateInfo.getLabelName() != null) {
                String[] labels = updateInfo.getLabelName();
View Full Code Here

            LockException, InvalidItemStateException, RepositoryException {
        if (versions.length > 1) {
            // TODO: implement restore of multiple versions
            TODO.unimplemented().doNothing(); // TODO: RETURN
        }
        final Version version = versions[0];
        VersionHistory history = (VersionHistory) version.getParent();
        final String versionableId = history.getVersionableIdentifier();
        if (history.getRootVersion().isSame(version)) {
            throw new VersionException("Restore of root version not possible");
        }
        final SessionDelegate sessionDelegate = sessionContext.getSessionDelegate();
        sessionDelegate.perform(new SessionOperation<Void>(true) {
            @Override
            public Void perform() throws RepositoryException {
                // check for pending changes
                checkPendingChangesForRestore(sessionDelegate);
                NodeDelegate n = sessionDelegate.getNodeByIdentifier(versionableId);
                if (n == null) {
                    throw new VersionException("Unable to restore version. " +
                            "No versionable node with identifier: " + versionableId);
                }
                // check lock status
                checkNotLocked(n.getPath());
                // check for existing nodes
                List<NodeDelegate> existing = getExisting(version,
                        Collections.singleton(n.getPath()));
                boolean success = false;
                try {
                    if (!existing.isEmpty()) {
                        if (removeExisting) {
                            removeExistingNodes(existing);
                        } else {
                            List<String> paths = new ArrayList<String>();
                            for (NodeDelegate nd : existing) {
                                paths.add(nd.getPath());
                            }
                            throw new ItemExistsException("Unable to restore with " +
                                    "removeExisting=false. Existing nodes in " +
                                    "workspace: " + paths);
                        }
                    }
                    // ready for restore
                    VersionDelegate vd = versionManagerDelegate.getVersionByIdentifier(
                            version.getIdentifier());
                    versionManagerDelegate.restore(
                            n.getParent(), n.getName(), vd);
                    sessionDelegate.getRoot().commit();
                    success = true;
                } catch (CommitFailedException e) {
View Full Code Here

    }

    @Override
    public Version checkpoint(String absPath) throws RepositoryException {
        // FIXME: atomic?
        Version v = checkin(absPath);
        checkout(absPath);
        return v;
    }
View Full Code Here

        }

        // check lock status
        checkLock();

        Version v = session.getVersionManager().checkin(this);
        Property prop = internalSetProperty(QName.JCR_ISCHECKEDOUT, InternalValue.create(false));
        prop.save();
        prop = internalSetProperty(QName.JCR_BASEVERSION, InternalValue.create(new UUID(v.getUUID())));
        prop.save();
        prop = internalSetProperty(QName.JCR_PREDECESSORS, InternalValue.EMPTY_ARRAY, PropertyType.REFERENCE);
        prop.save();
        return v;
    }
View Full Code Here

        // checks
        sanityCheck();
        checkSessionHasPending();
        checkLock();

        Version v = getVersionHistory().getVersion(versionName);
        DateVersionSelector gvs = new DateVersionSelector(v.getCreated());
        internalRestore(v, gvs, removeExisting);
        // session.save/revert is done in internal restore
    }
View Full Code Here

        // do checks
        sanityCheck();
        checkSessionHasPending();
        checkLock();

        Version v = getVersionHistory().getVersionByLabel(versionLabel);
        if (v == null) {
            throw new VersionException("No version for label " + versionLabel + " found.");
        }
        internalRestore(v, new LabelVersionSelector(versionLabel), removeExisting);
        // session.save/revert is done in internal restore
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.