Package javax.jcr.version

Examples of javax.jcr.version.Version


                List predecSet = new HrefProperty(setProperties.get(PREDECESSOR_SET)).getHrefs();

                Session session = getRepositorySession();
                for (int i = 0; i < mergeFailed.length; i++) {
                    // build version-href from each entry in the jcr:mergeFailed property
                    Version version = (Version) session.getNodeByUUID(mergeFailed[i].getString());
                    String href = getLocatorFromItem(version).getHref(true);

                    // Test if that version has been removed from the merge-set.
                    // thus indicating that the 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 = ((Node) item).checkin();
            String versionHref = getLocatorFromItem(v).getHref(true);
            return versionHref;
        } catch (RepositoryException e) {
            // UnsupportedRepositoryException should not occur
            throw new JcrDavException(e);
View Full Code Here

                instead.*/
                if (request instanceof DeltaVServletRequest && isVersionControlled(resource)) {
                    String labelHeader = ((DeltaVServletRequest)request).getLabel();
                    if (labelHeader != null && DavMethods.isMethodAffectedByLabel(request)) {
                        Item item = getItem(session, locator);
                        Version v = ((Node)item).getVersionHistory().getVersionByLabel(labelHeader);
                        DavResourceLocator vloc = locator.getFactory().createResourceLocator(locator.getPrefix(), locator.getWorkspacePath(), v.getPath(), false);
                        resource =  new VersionItemCollection(vloc, session, this, v);
                    }
                }
            } catch (PathNotFoundException e) {
                /* item does not exist yet: create the default resources
View Full Code Here

     */
    protected void initProperties() {
        super.initProperties();

        if (exists()) {
            Version v = (Version)item;
            // created and creationDate properties
            try {
                String creationDate = DavConstants.creationDateFormat.format(v.getCreated().getTime());
                // replace dummy creation date from default collection
                properties.add(new DefaultDavProperty(DavPropertyName.CREATIONDATE, creationDate));

                // required, protected DAV:version-name property
                properties.add(new DefaultDavProperty(VERSION_NAME, v.getName(), true));

                // required, protected DAV:label-name-set property
                String[] labels = getVersionHistoryItem().getVersionLabels(v);
                properties.add(new LabelSetProperty(labels));

                // required DAV:predecessor-set (protected) and DAV:successor-set (computed) properties
                addHrefProperty(VersionResource.PREDECESSOR_SET, v.getPredecessors(), true);
                addHrefProperty(SUCCESSOR_SET, v.getSuccessors(), true);

                // required DAV:version-history (computed) property
                String vhHref = getLocatorFromItem(getVersionHistoryItem()).getHref(true);
                properties.add(new HrefProperty(VersionResource.VERSION_HISTORY, vhHref, true));

                // required DAV:checkout-set (computed) property
                PropertyIterator it = v.getReferences();
                List nodeList = new ArrayList();
                while (it.hasNext()) {
                    Property p = it.nextProperty();
                    if (JcrConstants.JCR_BASEVERSION.equals(p.getName())) {
                        Node n = p.getParent();
View Full Code Here

     *
     * @throws javax.jcr.RepositoryException
     */
    public void testRestoreSetsBaseVersion() throws RepositoryException {
        versionableNode.restore(version, true);
        Version baseV = versionableNode.getBaseVersion();
        assertTrue("Restoring a node must set node's base version in order to point to the restored version.", version.isSame(baseV));
    }
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

    public void testRestoreInvalidVersion2() throws RepositoryException {
        String invalidName;
        do {
            invalidName = createRandomString(3);
            for (VersionIterator it = versionableNode.getVersionHistory().getAllVersions(); it.hasNext();) {
                Version v = it.nextVersion();
                if (invalidName.equals(v.getName())) {
                    invalidName = null;
                    break;
                }
            }
        } while (invalidName == null);
View Full Code Here

     * Test if restoring a node with an invalid Version throws a VersionException
     *
     * @throws RepositoryException
     */
    public void testRestoreWithInvalidVersion() throws RepositoryException {
        Version invalidVersion = versionableNode2.checkin();
        try {
            versionableNode.restore(invalidVersion, true);
            fail("Node.restore(Version, boolean): A VersionException must be thrown if the specified version does not exists in this node's version history.");
        } catch (VersionException e) {
            // success
View Full Code Here

            NodeDefinition nd = naa.getDefinition();
            if (nd.getOnParentVersion() != OnParentVersionAction.COPY && nd.getOnParentVersion() != OnParentVersionAction.VERSION) {
                throw new NotExecutableException("Child nodes must have OPV COPY or VERSION in order to be able to test Node.restore with uuid conflict.");
            }

            Version v = versionableNode.checkin();
            versionableNode.checkout();
            superuser.move(naa.getPath(), versionableNode2.getPath() + "/" + naa.getName());
            superuser.save();
            versionableNode.restore(v, false);
View Full Code Here

    }

    public void testRestorChild1() throws RepositoryException {
        versionableNode.addNode("child1");
        versionableNode.save();
        Version v1 = versionableNode.checkin();
        versionableNode.checkout();
        Version v2 = versionableNode.checkin();

        versionableNode.restore(v1, true);
        assertTrue("Node.restore('1.2') must not remove child node.", versionableNode.hasNode("child1"));

        versionableNode.restore(version, true);
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.