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 cm...@apache.org on 2002/03/02 18:13:21 UTC

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

cmlenz      02/03/02 09:13:21

  Modified:    src/webdav/server/org/apache/slide/webdav/method Tag:
                        SLIDE_1_0 PropPatchMethod.java
  Log:
  Porting bugfixes/enhancements from the HEAD branch:
  - Committed by juergen, 01/11/21 03:35:58
    "return a mime type in the response headers similar to propFind"
  - Committed by juergen, 01/12/07 05:50:56
    "1) BUG: PropPatch did not rollback, if one action could not be executed
     2) The property itself decides, if it is read-only or can be modified by
        propPatch
     3) all live properties have get/set methods, they are now used."
  - Committed by juergen, 02/01/09 10:24:54
    "removed a println"
  - Committed by juergem, 02/01/17 10:11:25
    "the virtual live properties "lockdiscovery" and "supportedlock" may not
     be modified by a proppatch command."
  - Committed by juergen, 02/01/24 09:28:56
    "remove a property without a namespace does work now."
  - Committed by juergen, 02/01/25 04:30:45
    "'DAV:' is spelled with a colon. Bug and solution reported by
     Joe.Mudd@sas.com"
  - Committed by juergen, 02/01/28 08:41:37
    "the href element within proppatch returns now the full path (similar to
     mod_dav)"
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.21.2.1  +49 -45    jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PropPatchMethod.java
  
  Index: PropPatchMethod.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PropPatchMethod.java,v
  retrieving revision 1.21
  retrieving revision 1.21.2.1
  diff -u -r1.21 -r1.21.2.1
  --- PropPatchMethod.java	6 Nov 2001 19:40:55 -0000	1.21
  +++ PropPatchMethod.java	2 Mar 2002 17:13:21 -0000	1.21.2.1
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PropPatchMethod.java,v 1.21 2001/11/06 19:40:55 remm Exp $
  - * $Revision: 1.21 $
  - * $Date: 2001/11/06 19:40:55 $
  + * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PropPatchMethod.java,v 1.21.2.1 2002/03/02 17:13:21 cmlenz Exp $
  + * $Revision: 1.21.2.1 $
  + * $Date: 2002/03/02 17:13:21 $
    *
    * ====================================================================
    *
  @@ -216,6 +216,7 @@
                   }
                   
               } catch (SAXException e) {
  +                e.printStackTrace();
                   resp.setStatus(WebdavStatus.SC_BAD_REQUEST);
                   throw new WebdavException(WebdavStatus.SC_BAD_REQUEST);
               } catch (ParserConfigurationException e) {
  @@ -251,6 +252,8 @@
       protected void executeRequest()
           throws WebdavException {
           
  +        boolean allOperationsExcecuted = true;
  +        
           // Prevent dirty reads
           slideToken.setForceStoreEnlistment(true);
           
  @@ -279,8 +282,7 @@
                   Property currentProperty =
                       (Property) propertyList.nextElement();
                   
  -                if (checkProperty(currentProperty, SET)) {
  -                    
  +                if (checkPropertyModification(currentProperty, revisionDescriptor)) {
                       NodeProperty newProperty =
                           new NodeProperty(currentProperty.name,
                                            currentProperty.value,
  @@ -288,6 +290,9 @@
                       revisionDescriptor.setProperty(newProperty);
                       
                   }
  +                else {
  +                    allOperationsExcecuted = false;
  +                }
               }
               
               propertyList = propertiesToRemove.elements();
  @@ -297,19 +302,27 @@
                   Property currentProperty =
                       (Property) propertyList.nextElement();
                   
  -                if (checkProperty(currentProperty, REMOVE)) {
  -                    
  -                    revisionDescriptor.removeProperty(currentProperty.name);
  -                    
  +                if (checkPropertyModification(currentProperty, revisionDescriptor)) {
  +                    revisionDescriptor.removeProperty(
  +                        currentProperty.name,
  +                        currentProperty.namespace);
  +                }
  +                else {
  +                    allOperationsExcecuted = false;
                   }
                   
               }
               
  -            content.store(slideToken, resourcePath, revisionDescriptor, null);
  +            if (allOperationsExcecuted)
  +                content.store(slideToken, resourcePath, revisionDescriptor, null);
  +            
  +            
  +            resp.setContentType("text/xml; charset=UTF-8");
               
               resp.setStatus(WebdavStatus.SC_MULTI_STATUS);
               
           } catch (Exception e) {
  +//          e.printStackTrace();
               resp.setStatus(getErrorCode(e));  // special handling needed
               throw new WebdavException(WebdavStatus.SC_ACCEPTED, false); // abort the TA
           }
  @@ -317,12 +330,16 @@
           
           // No serious errors. Printing the XML report.
           writeReport();
  +            
  +        if (!allOperationsExcecuted) {
  +            throw new WebdavException(WebdavStatus.SC_ACCEPTED, false); // abort the TA
  +        }
           
       }
       
  -        
  -        
  -        
  +    
  +    
  +    
       /**
        * Get return status based on exception type.
        */
  @@ -335,9 +352,9 @@
               return super.getErrorCode(e);
           }
       }
  -
  -
  -        
  +    
  +    
  +    
       // -------------------------------------------------------- Private Methods
       
       
  @@ -423,45 +440,32 @@
       }
       
       
  +    
       /**
        * Check if the property is a live property which should have its value
        * enforced by the server.
        *
        * @param property The property object
  -     * @param actionType Can be either SET or REMOVE
  +     * @param rd the revision descriptor containing all properties
        */
  -    private boolean checkProperty(Property property, int actionType) {
  -        
  -        // Checking the standard DAV properties which can't be modified using
  -        // a propatch.
  -        if (
  -               (property.name.equalsIgnoreCase("creationdate")) ||
  -               (property.name.equalsIgnoreCase("getcontentlength")) ||
  -               (property.name.equalsIgnoreCase("getetag")) ||
  -               (property.name.equalsIgnoreCase("getlastmodified")) ||
  -               (property.name.equalsIgnoreCase("lockdiscovery"))
  -        ) {
  -            property.status = WebdavStatus.SC_CONFLICT;
  -            return false;
  +    private boolean checkPropertyModification(Property property, NodeRevisionDescriptor rd) {
  +        NodeProperty originalProperty = rd.getProperty(property.name, property.namespace);
  +        boolean result;
  +        if (originalProperty == null) {
  +            // those virtual live properties can not be modified
  +            result = (!property.name.equals("lockdiscovery")) &&
  +                     (!property.name.equals("supportedlock"));
           }
  -        
  -        switch (actionType) {
  -            
  -            case SET:
  -                
  -                break;
  -                
  -            case REMOVE:
  -                
  -                break;
  -                
  +        else {
  +            result = !originalProperty.isProtected();
           }
  -        
  -        return true;
  +        if (!result) property.status = WebdavStatus.SC_CONFLICT;
  +        return result;
           
       }
       
       
  +    
       /**
        * Write the report.
        */
  @@ -472,12 +476,12 @@
           XMLPrinter generatedXML = new XMLPrinter();
           
           generatedXML.writeXMLHeader();
  -        generatedXML.writeElement("d", "DAV", "multistatus",
  +        generatedXML.writeElement("d", "DAV:", "multistatus",
                                     XMLPrinter.OPENING);
           
           generatedXML.writeElement("d", null, "response", XMLPrinter.OPENING);
           generatedXML.writeProperty("d", null, "href",
  -                                   WebdavUtils.encodeURL(requestUri));
  +                                   getFullPath(requestUri));
           
           
           
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>