Package org.apache.slide.webdav.util

Examples of org.apache.slide.webdav.util.VersioningHelper


        }

        try {
            if ( WebdavEvent.PROPPATCH.isEnabled() ) EventDispatcher.getInstance().fireVetoableEvent(WebdavEvent.PROPPATCH, new WebdavEvent(this));
           
            VersioningHelper vHelp =
                VersioningHelper.getVersioningHelper(slideToken, token, req, resp, getConfig() );
            NodeRevisionDescriptors revisionDescriptors =
                content.retrieve(slideToken, resourcePath);
           
            NodeRevisionNumber revisionNumber =
                revisionDescriptors.getLatestRevision();
            NodeRevisionDescriptor revisionDescriptor = null;
            if (revisionNumber != null) {
                try {
                    revisionDescriptor = content.retrieve
                        (slideToken, revisionDescriptors);
                } catch (RevisionDescriptorNotFoundException e) {
                }
            }
           
            if (revisionDescriptor == null) {
                revisionDescriptor = new NodeRevisionDescriptor(0);
            }
           
            ResourceKind resourceKind = AbstractResourceKind.determineResourceKind(token, resourcePath, revisionDescriptor);
           
            // check preconditions
            ViolatedPrecondition violatedPrecondition = getPreconditionViolation(revisionDescriptors, revisionDescriptor, resourceKind);
            if (violatedPrecondition != null) {
                throw new PreconditionViolationException(violatedPrecondition, resourcePath);
            }
           
            // Changed for DeltaV --start--
            boolean mustCheckIn = false;
            if( Configuration.useVersionControl() &&
                   (resourceKind instanceof CheckedInVersionControlled) &&
               versioningHelper.mustCheckoutAutoVersionedVCR(revisionDescriptors, revisionDescriptor) ) {
               
                vHelp.checkout(revisionDescriptors, revisionDescriptor, false, false, true );
                mustCheckIn = versioningHelper.mustCheckinAutoVersionedVCR(slideToken, revisionDescriptors, revisionDescriptor);
            }
           
            // Modifying the properties
           
            Iterator propertyIterator = null;
           
            propertyIterator = propertiesToSet.iterator();
            PropPatchProperty currentProperty = null;
            while (propertyIterator.hasNext()) {
               
                currentProperty = (PropPatchProperty)propertyIterator.next();
                if (checkPropertyModification(currentProperty, revisionDescriptor, resourceKind)) {
                    // Convert absolute URIs to relative ones, because Slide
                    // converts them to absolute ones in the result of queries.
                    String finalValue = currentProperty.getValue();
                    Element property = new Element(currentProperty.getName(), currentProperty.getNamespace());
                    String propertyValue = currentProperty.getValue();
                    if ( (propertyValue != null) && (propertyValue.toString().length() > 0)) {
                        if( propertyValue.toString().indexOf('<') >= 0 ) {
                            try {
                                XMLValue xmlValue = new XMLValue(propertyValue.toString(), Namespace.getNamespace(currentProperty.getNamespace()));
                                if (AbstractResourceKind.isLiveProperty(currentProperty.getName())) {
                                    convertHrefValueToRelativeURL (xmlValue, getSlideContextPath(), config);
                                }
                                Iterator iterator = xmlValue.iterator();
                                while (iterator.hasNext()) {
                                    Object o = iterator.next();
                                    if( o instanceof Element )
                                        property.addContent((Element)o);
                                    else if( o instanceof Text )
                                        property.addContent((Text)o);
                                    else if( o instanceof Comment )
                                        property.addContent((Comment)o);
                                    else if( o instanceof ProcessingInstruction )
                                        property.addContent((ProcessingInstruction)o);
                                    else if( o instanceof CDATA )
                                        property.addContent((CDATA)o);
                                    else if( o instanceof EntityRef )
                                        property.addContent((EntityRef)o);
                                }
                                finalValue = new XMLOutputter(Format.getRawFormat()).outputString(property.getContent());
                            }
                            catch (JDOMException e) {
                                // Fallback to original value
                            }
                        }
                    }
                    NodeProperty newProperty =
                        new NodeProperty(currentProperty.getName(),
                                         finalValue,
                                         currentProperty.getNamespace());
                    revisionDescriptor.setProperty(newProperty);
                   
                }
                else {
                    allOperationsExcecuted = false;
                }
            }
           
            propertyIterator = propertiesToRemove.iterator();
            while (propertyIterator.hasNext()) {
               
                currentProperty = (PropPatchProperty)propertyIterator.next();
                if (checkPropertyModification(currentProperty, revisionDescriptor, resourceKind)) {
                    revisionDescriptor.removeProperty(currentProperty.getName(),
                                                      currentProperty.getNamespace());
                }
                else {
                    allOperationsExcecuted = false;
                }
               
            }
           
            if (updateLastModified) {
                revisionDescriptor.setLastModified(new Date());
            }
           
            if (allOperationsExcecuted) {
                content.store(slideToken, resourcePath, revisionDescriptor, null);
            }
           
            // Changed for DeltaV --start--
            if( Configuration.useVersionControl() && mustCheckIn) {
                vHelp.checkin(revisionDescriptors, revisionDescriptor, false, false, true ); //forkOk=false, keepCheckedOut=false
            }
            // Changed for DeltaV --end--
           
            resp.setContentType(TEXT_XML_UTF_8);
           
View Full Code Here


            sendError( statusCode, e );
            throw new WebdavException( statusCode );
        }

        try {
            VersioningHelper vh = VersioningHelper.getVersioningHelper(
                slideToken, token, req, resp, getConfig() );

            if ( WebdavEvent.CHECKIN.isEnabled() ) EventDispatcher.getInstance().fireVetoableEvent(WebdavEvent.CHECKIN, new WebdavEvent(this));

            locationValue = vh.checkin( resourcePath , forkOk, keepCheckedOut, false);
        }
        catch (PreconditionViolationException e) {
            sendPreconditionViolation(e);
            throw e;
        }
View Full Code Here

            throw new WebdavException( statusCode );
        }
       
        // Added for DeltaV --start--
        if( Configuration.useVersionControl() ) {
            VersioningHelper vHelp =  VersioningHelper.getVersioningHelper(
                slideToken, token, req, resp, getConfig() );
           
            // Workspace
            vHelp.setWorkspaceProperty( colName, revisionDescriptor );
        }
        // Added for DeltaV --end--
       
        if (isMsProprietarySupport()) {
           
View Full Code Here

        }

        try {
            if ( WebdavEvent.UNCHECKOUT.isEnabled() ) EventDispatcher.getInstance().fireVetoableEvent(WebdavEvent.UNCHECKOUT, new WebdavEvent(this));

            VersioningHelper vh = VersioningHelper.getVersioningHelper(
                slideToken, token, req, resp, getConfig() );
            vh.uncheckout(resourcePath);
        }
        catch (PreconditionViolationException e) {
            sendPreconditionViolation(e);
            throw e;
        }
View Full Code Here

                    resourcePath,
                    new Exception("The resource path has been excluded from version-control") );
            }
            if ( WebdavEvent.VERSION_CONTROL.isEnabled() ) EventDispatcher.getInstance().fireVetoableEvent(WebdavEvent.VERSION_CONTROL, new WebdavEvent(this));

            VersioningHelper vh = VersioningHelper.getVersioningHelper(
                slideToken, token, req, resp, getConfig() );
            if( existingVersionPath == null )
                vh.versionControl( resourcePath );
            else
                vh.versionControl( resourcePath, existingVersionPath );
        }
        catch (PreconditionViolationException e) {
            sendPreconditionViolation(e);
            throw e;
        }
View Full Code Here

            throw new WebdavException( statusCode );
        }

        try {
           
            VersioningHelper vHelp =
                VersioningHelper.getVersioningHelper(slideToken, token, req, resp, getConfig() );
            NodeRevisionDescriptors revisionDescriptors =
                content.retrieve(slideToken, resourcePath);
           
            NodeRevisionNumber revisionNumber =
                revisionDescriptors.getLatestRevision();
            NodeRevisionDescriptor revisionDescriptor = null;
            if (revisionNumber != null) {
                try {
                    revisionDescriptor = content.retrieve
                        (slideToken, revisionDescriptors);
                } catch (RevisionDescriptorNotFoundException e) {
                }
            }
           
            if (revisionDescriptor == null) {
                revisionDescriptor = new NodeRevisionDescriptor(0);
            }
           
            ResourceKind resourceKind = AbstractResourceKind.determineResourceKind(token, resourcePath, revisionDescriptor);
           
            // check preconditions
            ViolatedPrecondition violatedPrecondition = getPreconditionViolation(revisionDescriptors, revisionDescriptor, resourceKind);
            if (violatedPrecondition != null) {
                throw new PreconditionViolationException(violatedPrecondition, resourcePath);
            }
           
            // Changed for DeltaV --start--
            boolean mustCheckIn = false;
            if( Configuration.useVersionControl() &&
                   (resourceKind instanceof CheckedInVersionControlled) &&
               versioningHelper.mustCheckoutAutoVersionedVCR(revisionDescriptors, revisionDescriptor) ) {
               
                vHelp.checkout(revisionDescriptors, revisionDescriptor, false, false, true );
                mustCheckIn = versioningHelper.mustCheckinAutoVersionedVCR(slideToken, revisionDescriptors, revisionDescriptor);
            }
           
            // Modifying the properties
           
            Iterator propertyIterator = null;
           
            propertyIterator = propertiesToSet.iterator();
            PropPatchProperty currentProperty = null;
            while (propertyIterator.hasNext()) {
               
                currentProperty = (PropPatchProperty)propertyIterator.next();
                if (checkPropertyModification(currentProperty, revisionDescriptor, resourceKind)) {
                    NodeProperty newProperty =
                        new NodeProperty(currentProperty.getName(),
                                         currentProperty.getValue(),
                                         currentProperty.getNamespace());
                    revisionDescriptor.setProperty(newProperty);
                   
                }
                else {
                    allOperationsExcecuted = false;
                }
            }
           
            propertyIterator = propertiesToRemove.iterator();
            while (propertyIterator.hasNext()) {
               
                currentProperty = (PropPatchProperty)propertyIterator.next();
                if (checkPropertyModification(currentProperty, revisionDescriptor, resourceKind)) {
                    revisionDescriptor.removeProperty(currentProperty.getName(),
                                                      currentProperty.getNamespace());
                }
                else {
                    allOperationsExcecuted = false;
                }
               
            }
           
            if (allOperationsExcecuted)
                content.store(slideToken, resourcePath, revisionDescriptor, null);
           
            // Changed for DeltaV --start--
            if( Configuration.useVersionControl() && mustCheckIn) {
                vHelp.checkin(revisionDescriptors, revisionDescriptor, false, false, true ); //forkOk=false, keepCheckedOut=false
            }
            // Changed for DeltaV --end--
           
            resp.setContentType(TEXT_XML_UTF_8);
           
View Full Code Here

            sendError( statusCode, e );
            throw new WebdavException( statusCode );
        }

        try {
            VersioningHelper vh = VersioningHelper.getVersioningHelper(
                slideToken, token, req, resp, getConfig() );
            locationValue = vh.checkin( resourcePath , forkOk, keepCheckedOut, false);
        }
        catch (PreconditionViolationException e) {
            sendPreconditionViolation(e);
            throw e;
        }
View Full Code Here

            throw new WebdavException( statusCode );
        }
       
        // Added for DeltaV --start--
        if( Configuration.useVersionControl() ) {
            VersioningHelper vHelp =  VersioningHelper.getVersioningHelper(
                slideToken, token, req, resp, getConfig() );
           
            // Workspace
            vHelp.setWorkspaceProperty( colName, revisionDescriptor );
        }
        // Added for DeltaV --end--
       
        if (isMsProprietarySupport()) {
           
View Full Code Here

        NodeLock objectLockToken = null;
       
        try {
            Element hrefElement = new Element(E_HREF, DNSP);
           
            VersioningHelper vHelp =  VersioningHelper.getVersioningHelper(
                lightSToken, token, req, resp, getConfig() );
            String resourcePath = object.getUri();
           
            revisionDescriptors =
                content.retrieve(lightSToken, resourcePath);
View Full Code Here

            sendError( statusCode, e );
            throw new WebdavException( statusCode );
        }

        try {
            VersioningHelper vh = VersioningHelper.getVersioningHelper(
                slideToken, token, req, resp, getConfig() );
            vh.uncheckout(resourcePath);
        }
        catch (PreconditionViolationException e) {
            sendPreconditionViolation(e);
            throw e;
        }
View Full Code Here

TOP

Related Classes of org.apache.slide.webdav.util.VersioningHelper

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.