Package org.apache.slide.webdav.util

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


     * @throws   PreconditionViolationException
     * @throws   ServiceAccessException
     */
    public void checkPreconditions(String resourcePath, int depth) throws PreconditionViolationException, ServiceAccessException {
        if (depth != 0) {
            throw new PreconditionViolationException(
                new ViolatedPrecondition("depth-must-be-zero",
                                         WebdavStatus.SC_BAD_REQUEST,
                                         "This report is only defined for depth=0."),
                resourcePath
            );
View Full Code Here


                versioningHelper.isWriteLocked(slideToken, revisionDescriptors);
               
                // 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() &&
View Full Code Here

        ViolatedPrecondition violatedPrecondition = getPreconditionViolation(updateSourcePath,
                                                                             updateLabelName,
                                                                             resourcePath);
        if (violatedPrecondition != null) {
            throw new PreconditionViolationException(violatedPrecondition, resourcePath);
        }
    }
View Full Code Here

        }
        if (principalElm != null) {
            subjectUri = createSubjectUri(principalElm);
        }
        else {
            throw new PreconditionViolationException(
                new ViolatedPrecondition("missing-ace-principal", WebdavStatus.SC_BAD_REQUEST), resourcePath
            );
        }
       
        // ACE grant and deny
        Element grantDenyElm = null;
        Element grantElm = aceElm.getChild(E_GRANT, DNSP);
        Element denyElm = aceElm.getChild(E_DENY, DNSP);
        if (grantElm != null && denyElm == null) {
            grantDenyElm = grantElm;
        }
        else if (grantElm == null && denyElm != null) {
            negative = true;
            grantDenyElm = denyElm;
        }
        else if(grantElm != null && denyElm != null) {
            throw new PreconditionViolationException(
                new ViolatedPrecondition("only-grant-or-deny-allowed", WebdavStatus.SC_BAD_REQUEST), resourcePath
            );
        }
        else if(grantElm == null && denyElm == null) {
            throw new PreconditionViolationException(
                new ViolatedPrecondition("missing-grant-or-deny", WebdavStatus.SC_BAD_REQUEST), resourcePath
            );
        }
        Iterator privilegeIt = grantDenyElm.getChildren(E_PRIVILEGE, DNSP).iterator();
       
        while (privilegeIt.hasNext()) {
            Element privilegeElm = (Element)privilegeIt.next();
            actionUri = createActionUri(privilegeElm);
            if (actionUri == null) {
                throw new PreconditionViolationException(
                    new ViolatedPrecondition("not-supported-privilege", WebdavStatus.SC_BAD_REQUEST), resourcePath
                );
            }
            else {
                NodePermission np = new NodePermission(objectUri, subjectUri, actionUri, true, negative);
View Full Code Here

        if (elm != null) {
            if (elm.getChild(E_OWNER, DNSP) != null) {
                return SubjectNode.OWNER_URI;
            }
            else {
                throw new PreconditionViolationException(
                    new ViolatedPrecondition("only-onwer-property-supported", WebdavStatus.SC_CONFLICT), resourcePath
                );
            }
        }
       
        throw new PreconditionViolationException(
            new ViolatedPrecondition("could-not-determine-principal", WebdavStatus.SC_BAD_REQUEST), resourcePath
        );
    }
View Full Code Here

    NodeLock nodeLock = findMatchingNodeLock(false);

    if (nodeLock != null) {
      if (!lock.checkLockOwner(slideToken, nodeLock)) {
        throw new PreconditionViolationException(
            new ViolatedPrecondition(
                "lock-owner-or-unlock-privilege",
                WebdavStatus.SC_FORBIDDEN, UNLOCK_NOT_ALLOWED),
            resourcePath);
      }
    } else {
      nodeLock = findMatchingNodeLock(true);
      if (nodeLock != null) {
        throw new PreconditionViolationException(
            new ViolatedPrecondition("lock-root",
                WebdavStatus.SC_CONFLICT, IS_NOT_LOCK_ROOT
                    + getFullPath(nodeLock.getObjectUri())),
            resourcePath);
      } else {
        throw new PreconditionViolationException(
            new ViolatedPrecondition("valid-lock-token",
                WebdavStatus.SC_CONFLICT, INVALID_LOCK_TOKEN),
            resourcePath);
      }
    }
View Full Code Here

            throw e;
        }
        catch (Exception e) {} // ignore silently

        if (collectionNode == null || !isCollection(collectionUri)) {
            throw new PreconditionViolationException(
                new ViolatedPrecondition(C_BIND_INTO_COLLECTION, WebdavStatus.SC_CONFLICT), collectionUri);
        }
        if (!MethodUtil.isValidSegment(segment)) {
            throw new PreconditionViolationException(
                new ViolatedPrecondition(C_NAME_ALLOWED, WebdavStatus.SC_FORBIDDEN), segment);
        }
        if (sourceNode == null) {
            throw new PreconditionViolationException(
                new ViolatedPrecondition(C_BIND_SOURCE_EXISTS, WebdavStatus.SC_CONFLICT), sourceUri);
        }
        if (collectionNode.hasBinding(segment)) {
            if (overwrite) {
                resp.setStatus( WebdavStatus.SC_NO_CONTENT );
            }
            else {
                throw new PreconditionViolationException(
                    new ViolatedPrecondition(C_CAN_OVERWRITE, WebdavStatus.SC_FORBIDDEN), segment);
            }
        }
        if (isCollection(sourceUri)) {
            if (isDescendant(collectionNode, sourceNode)) {
                throw new PreconditionViolationException(
                    new ViolatedPrecondition(C_CYCLE_ALLOWED, WebdavStatus.SC_FORBIDDEN), sourceUri);
            }
        }
    }
View Full Code Here

            else {
                violatedPrecondition =
                    new ViolatedPrecondition(C_LOCKED_OVERWRITE_ALLOWED, WebdavStatus.SC_CONFLICT);
            }
            sendPreconditionViolation(
                new PreconditionViolationException(violatedPrecondition, collectionNode.getUri())
            );
        }
        catch (CrossServerBindingException e) {
            sendPreconditionViolation(
                new PreconditionViolationException(
                                         new ViolatedPrecondition(C_CROSS_SERVER_BINDING, WebdavStatus.SC_FORBIDDEN),
                                         collectionNode.getUri()
                                     )
            );
        }
View Full Code Here

        if(Configuration.useVersionControl()) {
           
            uriHandler = UriHandler.getUriHandler(targetUri);
            if (uriHandler.isVersionUri() && !isCollection) {
                // delete of version is only allowed if the history collection is deleted
                throw new PreconditionViolationException(new ViolatedPrecondition(C_NO_VERSION_DELETE,
                                                                                  WebdavStatus.SC_FORBIDDEN),
                                                         targetUri);
            }
           
            // if resource being removed is a checked-out VCR or a WR,
View Full Code Here

            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() &&
View Full Code Here

TOP

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

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.