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/09/12 19:27:41 UTC

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

luetzkendorf    2004/09/12 10:27:41

  Modified:    src/webdav/server/org/apache/slide/webdav/method Tag:
                        SLIDE_2_1_RELEASE_BRANCH AbstractWebdavMethod.java
                        LockMethod.java PutMethod.java
  Log:
  fixes for If-Match header handling
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.43.2.4  +20 -5     jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/AbstractWebdavMethod.java
  
  Index: AbstractWebdavMethod.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/AbstractWebdavMethod.java,v
  retrieving revision 1.43.2.3
  retrieving revision 1.43.2.4
  diff -u -r1.43.2.3 -r1.43.2.4
  --- AbstractWebdavMethod.java	3 Sep 2004 17:17:55 -0000	1.43.2.3
  +++ AbstractWebdavMethod.java	12 Sep 2004 17:27:41 -0000	1.43.2.4
  @@ -424,7 +424,8 @@
                       // TODO Auto-generated catch block
                       e.printStackTrace();
                   }
  -            } else {
  +            }
  +            else {
                   releaseGlobalLock();
               }
           }
  @@ -1124,6 +1125,8 @@
                   }
               } else {
                   if (!resourceInfo.exists()) {
  +                    response.sendError(
  +                            HttpServletResponse.SC_PRECONDITION_FAILED);
                       return false;
                   }
               }
  @@ -1174,6 +1177,8 @@
                   }
               } else {
                   if (resourceInfo.exists()) {
  +                    response.sendError(
  +                            HttpServletResponse.SC_PRECONDITION_FAILED);
                       return false;
                   }
               }
  @@ -1257,7 +1262,7 @@
           /**
            * Constructor.
            *
  -         * @param pathname Path name of the file
  +         * @param path Path name of the resource
            */
           public ResourceInfo(String path, NodeRevisionDescriptor properties) {
               
  @@ -1269,6 +1274,16 @@
               this.length = properties.getContentLength();
               this.etag = properties.getETag();
               
  +        }
  +        /**
  +         * Creates a ResourceInfo for a non existing resource.
  +         * @param path Path of the resource
  +         */
  +        public ResourceInfo(String path) {
  +            this.path = path;
  +            this.exists = false;
  +            this.length = 0;
  +            this.date = System.currentTimeMillis();
           }
           
           
  
  
  
  1.69.2.3  +35 -3     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.69.2.2
  retrieving revision 1.69.2.3
  diff -u -r1.69.2.2 -r1.69.2.3
  --- LockMethod.java	12 Aug 2004 14:06:52 -0000	1.69.2.2
  +++ LockMethod.java	12 Sep 2004 17:27:41 -0000	1.69.2.3
  @@ -38,7 +38,9 @@
   import org.apache.slide.common.ServiceAccessException;
   import org.apache.slide.common.SlideException;
   import org.apache.slide.content.NodeRevisionDescriptor;
  +import org.apache.slide.content.NodeRevisionDescriptors;
   import org.apache.slide.content.RevisionAlreadyExistException;
  +import org.apache.slide.content.RevisionDescriptorNotFoundException;
   import org.apache.slide.event.VetoException;
   import org.apache.slide.lock.NodeLock;
   import org.apache.slide.lock.ObjectIsAlreadyLockedException;
  @@ -330,6 +332,7 @@
   		boolean inheritance = false;
   		Date lockDate = null;
   
  +        
   		switch (lockType) {
   
   		case LOCK_CREATION:
  @@ -359,6 +362,11 @@
   				}
   			} else if (lockInfo_lockType.equals(E_WRITE)) {
   				try {
  +                    
  +                if (!checkIfHeaders()) {
  +                    return;
  +                }
  +                      
   					NamespaceConfig namespaceConfig = token
   							.getNamespaceConfig();
                       toLockSubject = getToLockSubject();
  @@ -536,5 +544,29 @@
   		}
   
   	}
  +    
  +   private boolean checkIfHeaders() throws AccessDeniedException, LinkedObjectNotFoundException, ServiceAccessException, ObjectLockedException, VetoException, IOException
  +   {
  +       try {
  +           NodeRevisionDescriptors revisionDescriptors =
  +                      content.retrieve(slideToken, this.requestUri);
  +           // Retrieve latest revision descriptor
  +           NodeRevisionDescriptor revisionDescriptor =
  +                      content.retrieve(slideToken, revisionDescriptors);
  +           if (revisionDescriptor != null) {
  +               ResourceInfo resourceInfo =
  +                     new ResourceInfo(this.requestUri, revisionDescriptor);
  +               return checkIfHeaders(req, resp, resourceInfo);
  +           } else {
  +               return checkIfHeaders(req, resp, new ResourceInfo(this.requestUri));
  +           }
  +       } 
  +       catch (RevisionDescriptorNotFoundException e) {
  +           return checkIfHeaders(req, resp, new ResourceInfo(this.requestUri));
  +       }
  +       catch (ObjectNotFoundException e) {
  +           return checkIfHeaders(req, resp, new ResourceInfo(this.requestUri));
  +       }
  +   }
   }
   
  
  
  
  1.81.2.2  +4 -6      jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PutMethod.java
  
  Index: PutMethod.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PutMethod.java,v
  retrieving revision 1.81.2.1
  retrieving revision 1.81.2.2
  diff -u -r1.81.2.1 -r1.81.2.2
  --- PutMethod.java	10 Aug 2004 19:37:04 -0000	1.81.2.1
  +++ PutMethod.java	12 Sep 2004 17:27:41 -0000	1.81.2.2
  @@ -185,9 +185,7 @@
                   
                   // Checking If headers
                   if (!checkIfHeaders(req, resp, resourceInfo)) {
  -                    int statusCode = WebdavStatus.SC_PRECONDITION_FAILED;
  -                    sendError( statusCode, "Check If Header failed" );
  -                    throw new WebdavException( statusCode );
  +                    return;
                   }
                   
                   ResourceKind resourceKind = AbstractResourceKind.determineResourceKind(token, resourcePath, revisionDescriptor);
  
  
  

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