Package org.apache.webdav.lib.methods

Examples of org.apache.webdav.lib.methods.LockMethod


        throws HttpException, IOException {

        setClient();
        // default lock type setting
        short lockType = LockMethod.SCOPE_EXCLUSIVE;
        LockMethod method = new LockMethod(URIUtil.encodePath(path), owner,
                                           lockType, timeout);
        generateIfHeader(method);
        int statusCode = client.executeMethod(method);
        String lock = method.getLockToken();
        WebdavState state = (WebdavState) client.getState();
        if (state != null) {
            state.addLock(path, lock);
        }
        this.owner = method.getOwner();

        // Possbile LOCK Status Codes => SC_OK
        // WebdavStatus.SC_SC_PRECONDITION_FAILED, SC_LOCKED
        setStatusCode(statusCode, lock);
View Full Code Here


   public static String lockResource(HttpClient client, HttpURL url,
                                     String ownerInfo, int depth, int timeout)
      throws IOException, HttpException
   {
      LockMethod lock = new LockMethod(url.getURI());
      lock.setDepth(depth);
      lock.setTimeout(timeout);
      lock.setOwner(ownerInfo);
      //lock.setDebug(1);
      lock.setFollowRedirects(true);
      int status = client.executeMethod(lock);
      if (status == WebdavStatus.SC_OK) {
         Header header = lock.getResponseHeader("Lock-Token");
         if (header != null) {
            String l = header.getValue();
            return l.substring(1, l.length()-1);
         } else {
            String l = lock.getLockToken();
            if (l != null) {
               return l;
            }
            throw new WebdavException("LOCK does not provide a lock token.");
         }
      } else if (status == WebdavStatus.SC_MULTI_STATUS) {
         throw Utils.makeBuildException("Can't lock", lock.getResponses());
      } else {
         throw Utils.makeBuildException("Can't lock", status, lock.getStatusText());
      }
   }
View Full Code Here

        throws HttpException, IOException {

        setClient();
        // default lock type setting
        short lockType = LockMethod.SCOPE_EXCLUSIVE;
        LockMethod method = new LockMethod(URIUtil.encodePath(path), owner,
                                           lockType, timeout);
        generateIfHeader(method);
        int statusCode = client.executeMethod(method);
        String lock = method.getLockToken();
        WebdavState state = (WebdavState) client.getState();
        if (state != null) {
            state.addLock(path, lock);
        }
        this.owner = method.getOwner();

        // Possbile LOCK Status Codes => SC_OK
        // WebdavStatus.SC_SC_PRECONDITION_FAILED, SC_LOCKED
        setStatusCode(statusCode, lock);
View Full Code Here

TOP

Related Classes of org.apache.webdav.lib.methods.LockMethod

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.