Examples of DAVIFHeader


Examples of org.tmatesoft.svn.core.internal.server.dav.DAVIFHeader

    protected List getLockTokensList() throws DAVException {
        List ifHeaders = DAVServletUtil.processIfHeader(getRequestHeader(HTTPHeader.IF_HEADER));
        LinkedList lockTokens = null;
        if (ifHeaders != null) {
            for (Iterator ifHeadersIter = ifHeaders.iterator(); ifHeadersIter.hasNext();) {
                DAVIFHeader ifHeader = (DAVIFHeader) ifHeadersIter.next();
                List ifStateList = ifHeader.getStateList();
                if (ifStateList != null) {
                    for (Iterator ifStateIter = ifStateList.iterator(); ifStateIter.hasNext();) {
                        DAVIFState ifState = (DAVIFState) ifStateIter.next();
                        if (ifState.getCondition() == DAVIFState.IF_CONDITION_NORMAL && ifState.getType() == DAVIFStateType.IF_OPAQUE_LOCK) {
                            if (lockTokens == null) {
View Full Code Here

Examples of org.tmatesoft.svn.core.internal.server.dav.DAVIFHeader

      
        LinkedList ifHeaders = DAVServletUtil.processIfHeader(getRequestHeader(HTTPHeader.IF_HEADER));
       
        if (lockToken != null) {
            DAVIFState ifState = new DAVIFState(DAVIFState.IF_CONDITION_NORMAL, null, lockToken, DAVIFStateType.IF_OPAQUE_LOCK);
            DAVIFHeader ifHeader = new DAVIFHeader(resource.getResourceURI().getRequestURI(), true);
            ifHeader.addIFState(ifState);
            if (ifHeaders == null) {
                ifHeaders = new LinkedList();
            }
            ifHeaders.addFirst(ifHeader);
        }
View Full Code Here

Examples of org.tmatesoft.svn.core.internal.server.dav.DAVIFHeader

           
            throw new DAVException("This resource is locked and an \"If:\" header was not supplied to allow access to the resource.",
                    ServletDAVHandler.SC_HTTP_LOCKED, 0);
        }
       
        DAVIFHeader ifHeader = (DAVIFHeader) ifHeaders.getFirst();
        if (lock == null && ifHeader.isDummyHeader()) {
            if ((flags & ServletDAVHandler.DAV_VALIDATE_IS_PARENT) != 0) {
                return;
            }
            throw new DAVException("The locktoken specified in the \"Lock-Token:\" header is invalid because this resource has no outstanding locks.",
                    HttpServletResponse.SC_BAD_REQUEST, 0);
        }

        String eTag = resource.getETag();
        String uri = DAVPathUtil.dropTraillingSlash(resource.getResourceURI().getRequestURI());
       
        int numThatAppy = 0;
        String reason = null;
        Iterator ifHeadersIter = ifHeaders.iterator();
        for (;ifHeadersIter.hasNext();) {
            ifHeader = (DAVIFHeader) ifHeadersIter.next();
            if (ifHeader.getURI() != null && !uri.equals(ifHeader.getURI())) {
                continue;
            }
           
            ++numThatAppy;
            LinkedList stateList = ifHeader.getStateList();
            boolean doContinue = false;
            for (Iterator stateListIter = stateList.iterator(); stateListIter.hasNext();) {
                DAVIFState state = (DAVIFState) stateListIter.next();
                if (state.getType() == DAVIFStateType.IF_ETAG) {
                    String currentETag = null;
                    String givenETag = null;
                    String stateETag = state.getETag();
                    if (stateETag.startsWith("W/")) {
                        givenETag = stateETag.substring(2);
                    } else {
                        givenETag = stateETag;
                    }
                   
                    if (eTag.startsWith("W/")) {
                        currentETag = eTag.substring(2);
                    } else {
                        currentETag = eTag;
                    }
                   
                    boolean eTagsDoNotMatch = !givenETag.equals(currentETag);
                   
                    if (state.getCondition() == DAVIFState.IF_CONDITION_NORMAL && eTagsDoNotMatch) {
                        reason = "an entity-tag was specified, but the resource's actual ETag does not match.";
                        doContinue = true;
                        break;
                    } else if (state.getCondition() == DAVIFState.IF_CONDITION_NOT && !eTagsDoNotMatch) {
                        reason = "an entity-tag was specified using the \"Not\" form, but the resource's actual ETag matches the provided entity-tag.";
                        doContinue = true;
                        break;
                    }
                } else if (state.getType() == DAVIFStateType.IF_OPAQUE_LOCK) {
                    if (provider == null) {
                        if (state.getCondition() == DAVIFState.IF_CONDITION_NOT) {
                            continue;
                        }
                       
                        reason = "a State-token was supplied, but a lock database is not available for to provide the required lock.";
                        doContinue = true;
                        break;
                    }
                   
                    boolean matched = false;
                    if (lock != null) {
                        if (!lock.getLockToken().equals(state.getLockToken())) {
                            continue;
                        }
                       
                        seenLockToken = true;
                       
                        if (state.getCondition() == DAVIFState.IF_CONDITION_NOT) {
                            reason = "a State-token was supplied, which used a \"Not\" condition. The State-token was found in the locks on this resource";
                            doContinue = true;
                            break;
                        }
                       
                        String lockAuthUser = lock.getAuthUser();
                        String requestUser = resource.getUserName();
                        if (lockAuthUser != null && (requestUser == null || !lockAuthUser.equals(requestUser))) {
                            throw new DAVException("User \"{0}\" submitted a locktoken created by user \"{1}\".",
                                    new Object[] { requestUser, lockAuthUser }, HttpServletResponse.SC_FORBIDDEN, 0);
                        }
                       
                        matched = true;
                    }
                   
                    if (!matched && state.getCondition() == DAVIFState.IF_CONDITION_NORMAL) {
                        reason = "a State-token was supplied, but it was not found in the locks on this resource.";
                        doContinue = true;
                        break;
                    }
                } else if (state.getType() == DAVIFStateType.IF_UNKNOWN) {
                    if (state.getCondition() == DAVIFState.IF_CONDITION_NORMAL) {
                        reason = "an unknown state token was supplied";
                        doContinue = true;
                        break;
                    }
                }
            }
           
            if (doContinue) {
                continue;
            }
           
            if (seenLockToken) {
                return;
            }
           
            break;
        }
       
        if (!ifHeadersIter.hasNext()) {
            if (numThatAppy == 0) {
                if (seenLockToken) {
                    return;
                }
               
                if (findSubmittedLockToken(ifHeaders, lock)) {
                    return;
                }
               
                throw new DAVException("This resource is locked and the \"If:\" header did not specify one of the locktokens for this resource's lock(s).",
                        ServletDAVHandler.SC_HTTP_LOCKED, 0);
            }
           
            ifHeader = (DAVIFHeader) ifHeaders.getFirst();
            if (ifHeader.isDummyHeader()) {
                throw new DAVException("The locktoken specified in the \"Lock-Token:\" header did not specify one of this resource's locktoken(s).",
                        HttpServletResponse.SC_BAD_REQUEST, 0);
            }
           
            if (reason == null) {
                throw new DAVException("The preconditions specified by the \"If:\" header did not match this resource.",
                        HttpServletResponse.SC_PRECONDITION_FAILED, 0);
            }

            throw new DAVException("The precondition(s) specified by the \"If:\" header did not match this resource. At least one failure is because: {0}",
                    new Object[] { reason }, HttpServletResponse.SC_PRECONDITION_FAILED, 0);
        }
       
        if (findSubmittedLockToken(ifHeaders, lock)) {
            return;
        }
       
        if (ifHeader.isDummyHeader()) {
            throw new DAVException("The locktoken specified in the \"Lock-Token:\" header did not specify one of this resource's locktoken(s).",
                    HttpServletResponse.SC_BAD_REQUEST, 0);
        }
       
        throw new DAVException("This resource is locked and the \"If:\" header did not specify one of the locktokens for this resource's lock(s).",
View Full Code Here

Examples of org.tmatesoft.svn.core.internal.server.dav.DAVIFHeader

                ServletDAVHandler.SC_HTTP_LOCKED, 1);
    }
   
    private boolean findSubmittedLockToken(LinkedList ifHeaders, DAVLock lock) {
        for (Iterator ifHeadersIter = ifHeaders.iterator(); ifHeadersIter.hasNext();) {
            DAVIFHeader ifHeader = (DAVIFHeader) ifHeadersIter.next();
            LinkedList ifStates = ifHeader.getStateList();
            for (Iterator ifStatesIter = ifStates.iterator(); ifStatesIter.hasNext();) {
                DAVIFState ifState = (DAVIFState) ifStatesIter.next();
                if (ifState.getType() == DAVIFStateType.IF_OPAQUE_LOCK) {
                    String lockToken = lock.getLockToken();
                    String stateLockToken = ifState.getLockToken();
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.