Examples of ViolatedPrecondition


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

     * @throws   PreconditionViolationException
     */
    public void init(String resourcePath, Element aclPrincipalPropSetElm) throws PreconditionViolationException {
        if (aclPrincipalPropSetElm.getChildren().size() == 0) {
            throw new PreconditionViolationException(
                new ViolatedPrecondition("at-least-one-child-element",
                                         WebdavStatus.SC_BAD_REQUEST,
                                         "DAV:acl-principal-prop-set element must have at least one child"),
                resourcePath
            );
        }
        List propElmL = aclPrincipalPropSetElm.getChildren(E_PROP, DNSP);
        if (propElmL.size() > 1) {
            throw new PreconditionViolationException(
                new ViolatedPrecondition("at-most-one-prop-element",
                                         WebdavStatus.SC_BAD_REQUEST,
                                         "DAV:acl-principal-prop-set element must have at most one DAV:prop child"),
                resourcePath
            );
        }
       
        if (propElmL.size() == 1) {
            Element propElm = (Element)propElmL.get(0);
            try {
                this.requestedProperties = new RequestedPropertiesImpl(propElm);
            }
            catch (PropertyParseException e) {
                throw new PreconditionViolationException(
                    new ViolatedPrecondition("invalid-prop",
                                             WebdavStatus.SC_BAD_REQUEST,
                                             e.getMessage()),
                    resourcePath
                );
            }
View Full Code Here

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

     * @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

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

     * @throws   PreconditionViolationException
     */
    public void init(String resourcePath, Element principalSearchPropertySetElm) throws PreconditionViolationException {
        if (principalSearchPropertySetElm.getChildren().size() > 0) {
            throw new PreconditionViolationException(
                new ViolatedPrecondition("empty-principal-search-property-set-element",
                                         WebdavStatus.SC_BAD_REQUEST,
                                         "DAV:principal-search-property-set element must be empty"),
                resourcePath
            );
        }
View Full Code Here

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

     * @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
            );
        }
        UriPath resourcepath = new UriPath(resourcePath);
        NamespaceConfig namespaceConfig = token.getNamespaceConfig();
        UriPath userspath = namespaceConfig.getUsersPath() != null
            ? new UriPath(namespaceConfig.getUsersPath())
            : null;
        UriPath groupspath = namespaceConfig.getGroupsPath() != null
            ? new UriPath(namespaceConfig.getGroupsPath())
            : null;
        UriPath rolespath = namespaceConfig.getRolesPath() != null
            ? new UriPath(namespaceConfig.getRolesPath())
            : null;
        if (!resourcepath.equals(userspath) &&
            !resourcepath.equals(groupspath) &&
            !resourcepath.equals(rolespath)) {
            throw new PreconditionViolationException(
                new ViolatedPrecondition("valid-request-uri",
                                         WebdavStatus.SC_BAD_REQUEST,
                                         "This report is only defined for one of the collections identified in the value of the DAV:principal-collection-set property."),
                resourcePath
            );
        }
View Full Code Here

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

     * @throws   PreconditionViolationException
     */
    public void init(String resourcePath, Element principalMatchElm) throws PreconditionViolationException {
        if (principalMatchElm.getChildren().size() == 0) {
            throw new PreconditionViolationException(
                new ViolatedPrecondition("at-least-one-child-element",
                                         WebdavStatus.SC_BAD_REQUEST,
                                         "DAV:principal-match element must have at least one child"),
                resourcePath
            );
        }
        List principalPropertyElmL = principalMatchElm.getChildren(E_PRINCIPAL_PROPERTY, DNSP);
        List selfElmL = principalMatchElm.getChildren(E_SELF, DNSP);
        if (principalPropertyElmL.size()+selfElmL.size() != 1) {
            throw new PreconditionViolationException(
                new ViolatedPrecondition("either-one-principal-property-or-one-self-element",
                                         WebdavStatus.SC_BAD_REQUEST,
                                         "DAV:principal-match element must contain either a DAV:principal-property or a DAV:self element"),
                resourcePath
            );
        }
        if (principalPropertyElmL.size() == 1) {
            Element principalPropertyElm = (Element)principalPropertyElmL.get(0);
            if (principalPropertyElm.getChildren(E_OWNER, DNSP).size() > 0) {
                matchSubjectNode = SubjectNode.OWNER;
            }
            else {
                // TODO: support other properties
            }
        }
        else {
            matchSubjectNode = SubjectNode.SELF;
        }
        List propElmL = principalMatchElm.getChildren(E_PROP, DNSP);
        if (propElmL.size() > 1) {
            throw new PreconditionViolationException(
                new ViolatedPrecondition("at-most-one-prop-element",
                                         WebdavStatus.SC_BAD_REQUEST,
                                         "DAV:principal-match element must have at most one DAV:prop child"),
                resourcePath
            );
        }
       
        if (propElmL.size() == 1) {
            Element propElm = (Element)propElmL.get(0);
            try {
                this.requestedProperties = new RequestedPropertiesImpl(propElm);
            }
            catch (PropertyParseException e) {
                throw new PreconditionViolationException(
                    new ViolatedPrecondition("invalid-prop",
                                             WebdavStatus.SC_BAD_REQUEST,
                                             e.getMessage()),
                    resourcePath
                );
            }
View Full Code Here

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

     * @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

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()) {
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

                ResourceKind resourceKind = AbstractResourceKind.determineResourceKind(token, resourcePath, revisionDescriptor);
               
                versioningHelper.isWriteLocked(slideToken, revisionDescriptors);
               
                // check preconditions
                ViolatedPrecondition violatedPrecondition = getPreconditionViolation(revisionDescriptors, revisionDescriptor, resourceKind);
                if (violatedPrecondition != null) {
                    throw new PreconditionViolationException(violatedPrecondition, resourcePath);
                }
               
                // Changed for DeltaV --start--
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.