Examples of DAVLock


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

        DAVInsertPropAction inserted = DAVInsertPropAction.NOT_DEF;
        DAVElement livePropElement = livePropSpec.getPropertyName();
        String value = null;
        if (livePropElement == DAVElement.LOCK_DISCOVERY) {
            if (myLocksProvider != null) {
                DAVLock lock = null;
                try {
                    lock = myLocksProvider.getLock(resource);
                } catch (DAVException dave) {
                    throw new DAVException("DAV:lockdiscovery could not be determined due to a problem fetching the locks for this resource.",
                            dave.getResponseCode(), dave, 0);
View Full Code Here

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

        return info;
    }
   
    protected boolean canAutoCheckOut(DAVResource resource, DAVLockInfoProvider[] lockProvider, DAVAutoVersion autoVersion) throws DAVException {
        boolean autoCheckOut = false;
        DAVLock lock = null;
        if (autoVersion == DAVAutoVersion.ALWAYS) {
            autoCheckOut = true;
        } else if (autoVersion == DAVAutoVersion.LOCKED) {
            if (lockProvider[0] == null) {
                try {
View Full Code Here

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

        } catch (SVNException svne) {
            throw DAVException.convertError(svne.getErrorMessage(), HttpServletResponse.SC_INTERNAL_SERVER_ERROR, null, null);
        }
           
        boolean isNewLockRequest = false;
        DAVLock lock = null;

        if (readLength > 0) {
            lock = getLockRequest().parseLockInfo(this, resource, getNamespaces());
            isNewLockRequest = true;
        }
           
        DAVResourceState resourceState = getResourceState(resource);
        try {
            int flags = resourceState == DAVResourceState.NULL ? DAV_VALIDATE_PARENT : DAV_VALIDATE_RESOURCE;
            flags |= DAV_VALIDATE_ADD_LD;
            validateRequest(resource, depth, flags, isNewLockRequest ? lock.getScope() : null, null, lockProvider);
        } catch (DAVException dave) {
            DAVException next = new DAVException("Could not LOCK {0} due to a failed precondition (e.g. other locks).",
                    new Object[] { SVNEncodingUtil.xmlEncodeCDATA(resource.getResourceURI().getRequestURI(), true) }, dave.getResponseCode(), dave, 0);
            throw next;
        }
           
        if (!isNewLockRequest) {
            List lockTokens = null;
            try {
                lockTokens = getLockTokensList();
            } catch (DAVException dave) {
                DAVException next = new DAVException("The lock refresh for {0} failed because no lock tokens were specified in an \"If:\" header.",
                        new Object[] { SVNEncodingUtil.xmlEncodeCDATA(resource.getResourceURI().getRequestURI(), true) }, dave.getResponseCode(), dave, 0);
                throw next;
            }
               
            String lockToken = (String) lockTokens.get(0);
            lock = lockProvider.refreshLock(resource, lockToken, getTimeout());
        } else {
            if (lock.getTimeOutDate() != null) {
                //TODO: add expiration date renewal
                //Date timeoutDate = lock.getTimeOutDate();
            }
           
            lockProvider.addLock(lock, resource);
            setResponseHeader(HTTPHeader.LOCK_TOKEN_HEADER, "<" + lock.getLockToken() + ">");
        }
       
        HttpServletResponse servletResponse = getHttpServletResponse();
        servletResponse.setContentType(DEFAULT_XML_CONTENT_TYPE);
        servletResponse.setStatus(HttpServletResponse.SC_OK);
View Full Code Here

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

        DAVResponse resp = new DAVResponse(null, resource.getResourceURI().getRequestURI(), response, null, exception.getResponseCode());       
        return resp;
    }

    public void validateResourceState(LinkedList ifHeaders, DAVResource resource, DAVLockInfoProvider provider, DAVLockScope lockScope, int flags) throws DAVException {
        DAVLock lock = null;
        if (provider != null) {
            try {
                lock = provider.getLock(resource);
            } catch (DAVException dave) {
                throw new DAVException("The locks could not be queried for verification against a possible \"If:\" header.", null,
                        HttpServletResponse.SC_INTERNAL_SERVER_ERROR, null, SVNLogType.NETWORK, Level.FINE, dave, null, null, 0, null);
            }
        }
   
        boolean seenLockToken = false;
        if (lockScope == DAVLockScope.EXCLUSIVE) {
            if (lock != null) {
                throw new DAVException("Existing lock(s) on the requested resource prevent an exclusive lock.", ServletDAVHandler.SC_HTTP_LOCKED, 0);
            }
            seenLockToken = true;
        } else if (lockScope == DAVLockScope.SHARED) {
            if (lock.getScope() == DAVLockScope.EXCLUSIVE) {
                throw new DAVException("The requested resource is already locked exclusively.", ServletDAVHandler.SC_HTTP_LOCKED, 0);
            }
            seenLockToken = true;
        } else {
            seenLockToken = lock == null;
        }
       
        if (ifHeaders == null || ifHeaders.isEmpty()) {
            if (seenLockToken) {
                return;
            }
           
            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);
                        }
View Full Code Here

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

                        HttpServletResponse.SC_INTERNAL_SERVER_ERROR, 0);
            }
            whichResource = parentResource;
        }
       
        DAVLock lock = getLock(whichResource);
        if (lock == null) {
            return;
        }
       
        DAVInheritWalker inheritHandler = new DAVInheritWalker(resource, lock, !useParent);
View Full Code Here

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

            return null;
        }
       
        //TODO: add authz check here later

        DAVLock davLock = null;
        FSLock lock = null;
        try {
            lock = (FSLock) resource.getLock();
        } catch (SVNException svne) {
            throw DAVException.convertError(svne.getErrorMessage(), HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
View Full Code Here

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

    }
   
    public DAVLock findLock(DAVResource resource, String lockToken) throws DAVException {
        //TODO: add here authz check later
       
        DAVLock davLock = null;
        FSLock lock = null;
        try {
            lock = (FSLock) resource.getLock();
        } catch (SVNException svne) {
            throw DAVException.convertError(svne.getErrorMessage(), HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
View Full Code Here

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

       
        if (!hideAuthUser) {
            authUser = lock.getOwner();
        }
       
        return new DAVLock(authUser, DAVDepth.DEPTH_ZERO, exists, lock.getID(), owner != null ? owner.toString() : null, DAVLockRecType.DIRECT,
                DAVLockScope.EXCLUSIVE, DAVLockType.WRITE, lock.getExpirationDate());
    }
View Full Code Here

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

           
            throw new DAVException("The server cannot satisfy the LOCK request due to an unknown XML element (\"{0}\") within the DAV:lockinfo element.",
                    new Object[] { childElementName.getName() }, HttpServletResponse.SC_PRECONDITION_FAILED, 0);
        }
       
        return new DAVLock(resource.getUserName(), depth, resource.exists(), lockToken, owner, DAVLockRecType.DIRECT, lockScope, lockType, timeout);

    }
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.