You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-dev@jakarta.apache.org by lu...@apache.org on 2004/06/21 10:52:47 UTC

cvs commit: jakarta-slide/src/webdav/server/org/apache/slide/webdav/method LockMethod.java

luetzkendorf    2004/06/21 01:52:47

  Modified:    src/webdav/server/org/apache/slide/webdav/method
                        LockMethod.java
  Log:
  locktypes other than write are now requected as Bad Request
  
  Revision  Changes    Path
  1.62      +24 -38    jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/LockMethod.java
  
  Index: LockMethod.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/LockMethod.java,v
  retrieving revision 1.61
  retrieving revision 1.62
  diff -u -r1.61 -r1.62
  --- LockMethod.java	14 Jun 2004 12:38:35 -0000	1.61
  +++ LockMethod.java	21 Jun 2004 08:52:47 -0000	1.62
  @@ -56,17 +56,13 @@
   public class LockMethod extends AbstractMultistatusResponseMethod
       implements WebdavConstants {
       
  -    
       // -------------------------------------------------------------- Constants
       
  -    
  -    
       /**
        * Create a new lock.
        */
       private static final int LOCK_CREATION = 0;
       
  -    
       /**
        * Refresh lock.
        */
  @@ -91,43 +87,32 @@
        */
       private int depth;
       
  -    
       /**
  -     * Type of the LOCK method.
  +     * Type of the LOCK method ({@link #LOCK_CREATION} or {@link #LOCK_REFRESH}).
        */
       private int lockType;
       
  -    
       /**
        * Lock duration.
        */
       private int lockDuration = DEFAULT_TIMEOUT;
       
  -    
  -    /**
  -     * DAV Namespace support.
  -     */
  -    private boolean davNative;
  -    
  -    
       /**
        * Lock scope.
        */
       private String lockInfo_lockScope;
       
  -    
  -    /**
  +    /*
        * Lock type.
  +     * Never used, because currently only write locks are known.
        */
  -    private String lockInfo_lockType;
  -    
  +    //private String lockInfo_lockType;
       
       /**
        * Lock owner.
        */
       private String lockInfo_lockOwner;
       
  -    
       /**
        * Lock subject.
        */
  @@ -141,7 +126,6 @@
       
       // ----------------------------------------------------------- Constructors
       
  -    
       /**
        * Constructor.
        *
  @@ -203,27 +187,20 @@
           lockType = LOCK_CREATION;
           
           try {
  -            Element lockScopeElement = null;
  -            Element lockTypeElement = null;
  -            Element lockOwnerElement = null;
  -            Iterator childrenIterator = parseRequestContent(E_LOCKINFO).getChildren().iterator();
  -            Element currentElement = null;
  +            Iterator childrenIterator = parseRequestContent(E_LOCKINFO)
  +                                                     .getChildren().iterator();
               while (childrenIterator.hasNext()) {
  -                currentElement = (Element)childrenIterator.next();
  +                Element currentElement = (Element)childrenIterator.next();
                   if (E_LOCKSCOPE.equals(currentElement.getName())) {
  -                    lockScopeElement = currentElement;
  +                    parseLockScope(currentElement);
                   }
                   else if (E_LOCKTYPE.equals(currentElement.getName())) {
  -                    lockTypeElement = currentElement;
  +                    parseLockType(currentElement);
                   }
                   else if (E_OWNER.equals(currentElement.getName())) {
  -                    lockOwnerElement = currentElement;
  +                   parseOwner(currentElement);
                   }
               }
  -            
  -            parseLockScope(lockScopeElement);
  -            parseLockType(lockTypeElement);
  -            parseOwner(lockOwnerElement);
           }
           catch (JDOMException e) {
               int statusCode = WebdavStatus.SC_BAD_REQUEST;
  @@ -258,6 +235,12 @@
           }
           
           lockInfo_lockScope = ((Element)children.get(0)).getName();
  +        if (!(E_EXCLUSIVE.equals(lockInfo_lockScope)  
  +            || E_SHARED.equals(lockInfo_lockScope))) 
  +        {
  +           throw new JDOMException("<"+E_LOCKSCOPE+"> can only contain one of <" +
  +               E_EXCLUSIVE + "> or <" + E_SHARED + ">");
  +        }
       }
       
       /**
  @@ -280,7 +263,10 @@
               throw new JDOMException("<"+E_LOCKTYPE+"> must have exactly one child element");
           }
           
  -        lockInfo_lockType = ((Element)children.get(0)).getName();
  +        if (!((Element)children.get(0)).getName().equals(E_WRITE)) {
  +            throw new JDOMException("Only write locks are supported");
  +        }
  +        //lockInfo_lockType = ((Element)children.get(0)).getName();
       }
       
       /**
  @@ -314,7 +300,7 @@
           
           if (lockInfo_lockOwner.length() == 0) {
               lockInfo_lockOwner = DEFAULT_LOCK_OWNER;
  -            //          throw new JDOMException("<"+E_OWNER+"> element must not be empty");
  +            //throw new JDOMException("<"+E_OWNER+"> element must not be empty");
           }
       }
       
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: slide-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: slide-dev-help@jakarta.apache.org