Examples of ViolatedPrecondition


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

        if(Configuration.useVersionControl()) {
           
            UriHandler sourceUh = UriHandler.getUriHandler(sourceUri);
            if (sourceUh.isHistoryUri()) {
                throw new PreconditionViolationException(
                    new ViolatedPrecondition(DeltavConstants.C_CANNOT_COPY_HISTORY, WebdavStatus.SC_FORBIDDEN), sourceUri);
            }
           
            if (!macroParameters.isDeleteCreate()) {
                beforeUpdateOrDelete( destinationUri );
            }
View Full Code Here

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

                    }
                    if ( !E_CHECKOUT_CHECKIN.equals(autoVersion) &&
                        !E_CHECKOUT_UNLOCKED_CHECKIN.equals(autoVersion) &&
                        !E_CHECKOUT.equals(autoVersion) &&
                        !E_LOCKED_CHECKOUT.equals(autoVersion) ) {
                        throw new PreconditionViolationException(new ViolatedPrecondition(C_CANNOT_MODIFY_VERSION_CONTROLLED_CONTENT,
                                                                                          WebdavStatus.SC_FORBIDDEN), destinationUri);
                    }
                    if ( E_LOCKED_CHECKOUT.equals(autoVersion) &&
                            ( !versioningHelper.isWriteLocked(slideToken, destinationNrds) ) ) {
                        throw new PreconditionViolationException(new ViolatedPrecondition(C_CANNOT_MODIFY_VERSION_CONTROLLED_CONTENT,
                                                                                          WebdavStatus.SC_FORBIDDEN), destinationUri);
                    }
                }
               
                // check precondition DAV:cannot-modify-version
                UriHandler uriHandler = UriHandler.getUriHandler(destinationUri);
                if (uriHandler.isVersionUri()) {
                    throw new PreconditionViolationException(new ViolatedPrecondition(C_CANNOT_MODIFY_VERSION,
                                                                                      WebdavStatus.SC_FORBIDDEN), destinationUri);
                }
               
                // checkout if necessary
                if( Configuration.useVersionControl() &&
View Full Code Here

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

        }
        catch (SlideException e) {} // ignore silently
       
        if (collectionNode == null || !isCollection(collectionUri)) {
            throw new PreconditionViolationException(
                new ViolatedPrecondition(C_UNBIND_FROM_COLLECTION, WebdavStatus.SC_CONFLICT), collectionUri);
        }
        if (!collectionNode.hasBinding(segment)) {
            throw new PreconditionViolationException(
                new ViolatedPrecondition(C_UNBIND_SOURCE_EXISTS, WebdavStatus.SC_CONFLICT), collectionUri);
        }
    }
View Full Code Here

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

        try {
            checkPreconditions();
            structure.removeBinding( slideToken, collectionNode, segment );
        }
        catch (ObjectLockedException e) {
            ViolatedPrecondition violatedPrecondition;
            if (collectionUri.equals(e.getObjectUri())) {
                violatedPrecondition =
                    new ViolatedPrecondition(C_LOCKED_UPDATE_ALLOWED, WebdavStatus.SC_LOCKED);
            }
            else {
                violatedPrecondition =
                    new ViolatedPrecondition(C_PROTECTED_URL_DELETION_ALLOWED, WebdavStatus.SC_CONFLICT);
            }
            sendPreconditionViolation(
                new PreconditionViolationException(violatedPrecondition, collectionNode.getUri())
            );
        }
View Full Code Here

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

                applyToVersion = (labelHeader != null);
                resourcePath = versioningHelper.getLabeledResourceUri(resourcePath,
                                                                      labelHeader);
            }
            catch (LabeledRevisionNotFoundException e) {
                ViolatedPrecondition violatedPrecondition =
                    new ViolatedPrecondition(DeltavConstants.C_MUST_SELECT_VERSION_IN_HISTORY,
                                             WebdavStatus.SC_CONFLICT);
                try {
                    sendPreconditionViolation(new PreconditionViolationException(violatedPrecondition,
                                                                                 resourcePath));
                } catch (IOException ioe) {}
                throw new WebdavException(getErrorCode((Exception)e));
            }
            catch (SlideException e) {
                int statusCode = getErrorCode( e );
                sendError( statusCode, e );
                throw new WebdavException( statusCode );
            }
        }


        if( req.getContentLength() > 0 ) {
//            readRequestContent();
            try{
                Iterator i = parseRequestContent(E_CHECKOUT).getChildren().iterator();
                while( i.hasNext() ) {
                    Element e = (Element)i.next();
                    if ( e.getName().equals(E_APPLY_TO_VERSION) ) {

                        String labelHeader = WebdavUtils.fixTomcatHeader(requestHeaders.getLabel(), "UTF-8");

                        if (labelHeader != null) {
                            ViolatedPrecondition violatedPrecondition =
                                new ViolatedPrecondition(DeltavConstants.C_MUST_NOT_HAVE_LABEL_AND_APPLY_TO_VERSION,
                                                         WebdavStatus.SC_CONFLICT);
                            sendPreconditionViolation(new PreconditionViolationException(violatedPrecondition,
                                                                                         resourcePath));
                            throw new WebdavException(WebdavStatus.SC_CONFLICT);
                        }
View Full Code Here

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

    protected void labelResource(String resourcePath, int depth, NestedSlideException nestedSlideException) {
       
        try {
           
            if ( ! isCollection(resourcePath) ) {
                ViolatedPrecondition violatedPrecondition = getPreconditionViolation(resourcePath);
                if (violatedPrecondition != null) {
                    throw new PreconditionViolationException(violatedPrecondition, resourcePath);
                }
               
                performLabelOperation(resourcePath);
View Full Code Here

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

     */
    protected ViolatedPrecondition getPreconditionViolation(String resourcePath) throws SlideException {
        // use a non-blocking slide token.
        SlideToken stoken = readonlySlideToken();
       
        ViolatedPrecondition violatedPrecondition = null;
        NodeRevisionDescriptors revisionDescriptors =
            content.retrieve( stoken, resourcePath);
        NodeRevisionDescriptor revisionDescriptor =
            content.retrieve( stoken, revisionDescriptors);
        ResourceKind resourceKind = AbstractResourceKind.determineResourceKind(token, revisionDescriptors, revisionDescriptor);
       
        // check <DAV:must-be-checked-in>
        if ( (resourceKind instanceof VersionControlled) &&
            !(resourceKind instanceof CheckedInVersionControlled) ) {
            return new ViolatedPrecondition(DeltavConstants.C_MUST_BE_CHECKED_IN,
                                            WebdavStatus.SC_CONFLICT);
        }
       
        // check <DAV:must-select-version-in-history>
        if ( (resourceKind instanceof VersionControlled) &&
                (labelHeader != null) ) {
            try {
                versioningHelper.getLabeledResourceUri(resourcePath, labelHeader);
            }
            catch (LabeledRevisionNotFoundException e) {
                return new ViolatedPrecondition(DeltavConstants.C_MUST_SELECT_VERSION_IN_HISTORY,
                                                WebdavStatus.SC_CONFLICT);
            }
        }
       
        try {
            String slideResourceUri = getResourceUri(resourcePath, labelHeader);
            revisionDescriptors =
                content.retrieve( stoken, slideResourceUri);
            revisionDescriptor =
                content.retrieve( stoken, revisionDescriptors);
            resourceKind = AbstractResourceKind.determineResourceKind(token, revisionDescriptors, revisionDescriptor);
            if (resourceKind instanceof Version) {
               
                // check <DAV:label-must-exist>
                if (DeltavConstants.E_REMOVE.equals(operation)) {
                    if ( ! hasLabel(revisionDescriptor, label) ) {
                        return new ViolatedPrecondition(DeltavConstants.C_LABEL_MUST_EXIST,
                                                        WebdavStatus.SC_CONFLICT);
                    }
                }
               
                try {
                    versioningHelper.retrieveLabeledRevision(revisionDescriptors.getUri(), label);
                    // check <DAV:must-be-new-label>
                    if (DeltavConstants.E_ADD.equals(operation)) {
                        return new ViolatedPrecondition(DeltavConstants.C_MUST_BE_NEW_LABEL,
                                                        WebdavStatus.SC_CONFLICT);
                    }
                }
                catch (LabeledRevisionNotFoundException e) {}
            }
        }
        catch (LabeledRevisionNotFoundException e) {
            // check <DAV:label-must-exist>
            if (DeltavConstants.E_REMOVE.equals(operation)) {
                return new ViolatedPrecondition(DeltavConstants.C_LABEL_MUST_EXIST,
                                                WebdavStatus.SC_CONFLICT);
            }
        }
       
        return violatedPrecondition;
View Full Code Here

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

        UriHandler sourceUriHandler = UriHandler.getUriHandler(sourceUri);
        isRequestSourceWorkspace = sourceUriHandler.isWorkspaceUri();

        try {
            // check preconditions
            ViolatedPrecondition violatedPrecondition = getPreconditionViolation(sourceUri, destinationUri);
            if (violatedPrecondition != null) {
                PreconditionViolationException e =
                    new PreconditionViolationException(violatedPrecondition, sourceUri);
                sendPreconditionViolation(e);
                throw e;
View Full Code Here

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

     */
    private ViolatedPrecondition getPreconditionViolation(String sourceUri, String destinationUri) throws SlideException {
        // use a non-blocking slide token.
        SlideToken stoken = readonlySlideToken();

        ViolatedPrecondition violatedPrecondition = null;
        if( Configuration.useVersionControl() ) {

            if (isRequestSourceWorkspace) {

                UriHandler destinationUriHandler = UriHandler.getUriHandler(destinationUri);
                NodeRevisionDescriptors destinationRevisionDescriptors = null;
                NodeRevisionDescriptor destinationRevisionDescriptor = null;
                try {
                    destinationRevisionDescriptors = content.retrieve( stoken, destinationUri);
                    destinationRevisionDescriptor = content.retrieve( stoken, destinationRevisionDescriptors);
                }
                catch( ObjectNotFoundException e ) {}; // can be ignored here!

                ResourceKind destinationResourceKind =
                    AbstractResourceKind.determineResourceKind( token, destinationUri, destinationRevisionDescriptor );

                if( !(destinationResourceKind instanceof DeltavCompliantUnmappedUrl) ) {
                    return new ViolatedPrecondition(C_RESOURCE_MUST_BE_NULL,
                                                    WebdavStatus.SC_CONFLICT);
                }
                if( !destinationUriHandler.isWorkspaceUri() ) {
                    return new ViolatedPrecondition(C_WORKSPACE_LOCATION_OK,
                                                    WebdavStatus.SC_CONFLICT);
                }
            }
        }
        if (isCollection(sourceUri)) {
            UriHandler destinationUriHandler = UriHandler.getUriHandler(destinationUri);
            ObjectNode destinationParentNode =
                structure.retrieve(stoken, destinationUriHandler.getParentUriHandler().toString());
            ObjectNode sourceNode =
                structure.retrieve(stoken, sourceUri);
            if (isDescendant(destinationParentNode, sourceNode)) {
                return new ViolatedPrecondition(C_CYCLE_ALLOWED, WebdavStatus.SC_FORBIDDEN);
            }
        }

        return violatedPrecondition;
    }
View Full Code Here

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

        if( Configuration.useVersionControl() ) {

            UriHandler uriHandler = UriHandler.getUriHandler(sourceUri);
            if (uriHandler.isVersionUri()) {
                throw new PreconditionViolationException(new ViolatedPrecondition(DeltavConstants.C_CANNOT_RENAME_VERSION,
                                                                                  WebdavStatus.SC_FORBIDDEN),
                                                         sourceUri);
            }
            if (uriHandler.isHistoryUri()) {
                throw new PreconditionViolationException(new ViolatedPrecondition(DeltavConstants.C_CANNOT_RENAME_HISTORY,
                                                                                  WebdavStatus.SC_FORBIDDEN),
                                                         sourceUri);
            }
            if (uriHandler.isWorkingresourceUri()) {
                throw new PreconditionViolationException(new ViolatedPrecondition(DeltavConstants.C_CANNOT_RENAME_WORKING_RESOURCE,
                                                                                  WebdavStatus.SC_FORBIDDEN),
                                                         sourceUri);
            }

            NodeRevisionDescriptors sourceRevisionDescriptors =
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.