Examples of ViolatedPrecondition


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_CHECKOUT_IGNORE_UNLOCK.equals(autoVersion) &&
                    !E_LOCKED_CHECKOUT.equals(autoVersion) ) {
                    return new ViolatedPrecondition(C_CANNOT_MODIFY_VERSION_CONTROLLED_CONTENT,
                                                    WebdavStatus.SC_FORBIDDEN);
                }
                if ( E_LOCKED_CHECKOUT.equals(autoVersion) &&
                        ( !versioningHelper.isWriteLocked(slideToken, revisionDescriptors) ) ) {
                    return new ViolatedPrecondition(C_CANNOT_MODIFY_VERSION_CONTROLLED_CONTENT,
                                                    WebdavStatus.SC_FORBIDDEN);
                }
            }
           
            // check precondition DAV:cannot-modify-version
            UriHandler uriHandler = UriHandler.getUriHandler(resourcePath);
            if (uriHandler.isVersionUri()) {
                return new ViolatedPrecondition(C_CANNOT_MODIFY_VERSION,
                                                WebdavStatus.SC_FORBIDDEN);
            }
        }
        return null;
    }
View Full Code Here

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

     * @throws     SlideException
     * @throws     PreconditionViolationException  if any precondition has been violated.
     */
    private void checkPreconditions(String updateSourcePath, String updateLabelName, String resourcePath) throws SlideException, PreconditionViolationException {

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

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

     *
     * @throws     SlideException
     */
    protected ViolatedPrecondition getPreconditionViolation(String updateSourcePath, String updateSourceLabel, String resourcePath) throws SlideException {

        ViolatedPrecondition violatedPrecondition = null;

        NodeRevisionDescriptors revisionDescriptors =
            content.retrieve(slideToken, resourcePath);
        NodeRevisionDescriptor revisionDescriptor =
            content.retrieve(slideToken, revisionDescriptors);
        ResourceKind resourceKind = AbstractResourceKind.determineResourceKind(token,
                                                                               revisionDescriptors,
                                                                               revisionDescriptor);
        if ( ! (resourceKind instanceof CheckedInVersionControlled) ) {
            return new ViolatedPrecondition(DeltavConstants.C_MUST_BE_CHECKED_IN_VERSION_CONTROLLED_RESOURCE,
                                            WebdavStatus.SC_CONFLICT);
        }

        if (updateSourceLabel != null) {
            try {
                updateSourcePath = versioningHelper.getLabeledResourceUri(resourcePath, updateLabelName);
            }
            catch (LabeledRevisionNotFoundException e) {
                return new ViolatedPrecondition(DeltavConstants.C_MUST_SELECT_VERSION_IN_HISTORY,
                                                WebdavStatus.SC_CONFLICT);
            }
        }

        String associatedVrUri = versioningHelper.getUriOfAssociatedVR(resourcePath);
        String vcrHistoryUri = UriHandler.getUriHandler(associatedVrUri).getAssociatedHistoryUri();
        UriHandler vrUriHandler = UriHandler.getUriHandler(updateSourcePath);
        boolean isVersionOfVcrHistory = false;
        if (vrUriHandler.isVersionUri() &&
            vcrHistoryUri.equals(vrUriHandler.getAssociatedHistoryUri()) ) {

            NodeRevisionDescriptors vrDescriptors =
                content.retrieve(slideToken, updateSourcePath);
            try {
                content.retrieve(slideToken, vrDescriptors);
                isVersionOfVcrHistory = true;
            }
            catch (RevisionDescriptorNotFoundException e) {
            }
        }

        if ( ! isVersionOfVcrHistory ) {
            return new ViolatedPrecondition(DeltavConstants.C_MUST_SELECT_VERSION_IN_HISTORY,
                                            WebdavStatus.SC_CONFLICT);
        }

        return violatedPrecondition;
    }
View Full Code Here

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

        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);
                np.setInvert(invert);
View Full Code Here

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

            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

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

    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

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

            }
           
            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--
View Full Code Here

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

     * @param resourceKind  the kind of the resource to patch.
     */
    private boolean checkPropertyModification(PropPatchProperty property, NodeRevisionDescriptor rd, ResourceKind resourceKind) {
       
        boolean result = false;
        ViolatedPrecondition violatedPrecondition = getPropertySpecificPreconditionViolation(property);
        if (violatedPrecondition != null) {
            property.setViolatedPrecondition(violatedPrecondition);
        }
        else {
            NodeProperty originalProperty = rd.getProperty(property.getName(), property.getNamespace());
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_CHECKOUT_IGNORE_UNLOCK.equals(autoVersion) &&
                    !E_LOCKED_CHECKOUT.equals(autoVersion) ) {
                    return new ViolatedPrecondition(C_CANNOT_MODIFY_VERSION_CONTROLLED_PROPERTY,
                                                    WebdavStatus.SC_FORBIDDEN);
                }
                if (E_LOCKED_CHECKOUT.equals(autoVersion)) {
                    if ( !versioningHelper.isWriteLocked(slideToken, revisionDescriptors) ) {
                        return new ViolatedPrecondition(C_CANNOT_MODIFY_VERSION_CONTROLLED_PROPERTY,
                                                        WebdavStatus.SC_FORBIDDEN);
                    }
                }
            }
           
            // check precondition DAV:cannot-modify-version
            UriHandler uriHandler = UriHandler.getUriHandler(resourcePath);
            if (uriHandler.isVersionUri()) {
                return new ViolatedPrecondition(C_CANNOT_MODIFY_VERSION,
                                                WebdavStatus.SC_FORBIDDEN);
            }
        }
       
        return null;
View Full Code Here

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

    private ViolatedPrecondition getPropertySpecificPreconditionViolation(PropPatchProperty property) {
       
        // check precondition DAV:cannot-modify-protected-property
        if ( AbstractResourceKind.isProtectedProperty(property.getName()) &&
            DeltavConstants.DELTAV_PROPERTY_LIST.contains(property.getName()) ) {
            return new ViolatedPrecondition(C_CANNOT_MODIFY_PROTECTED_PROPERTY,
                                            WebdavStatus.SC_CONFLICT);
        }
       
        // check precondition DAV:supported-live-property
        // ...is there any property to check here yet ?
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.