juergen     02/03/18 02:13:35

  Modified:    src/webdav/server/org/apache/slide/webdav/method
                        PutMethod.java
  Log:
  Added checking of (DeltaV) preconditions.
  (ralf)
  
  Revision  Changes    Path
  1.31      +48 -3     
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.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- PutMethod.java    15 Mar 2002 12:48:22 -0000      1.30
  +++ PutMethod.java    18 Mar 2002 10:13:35 -0000      1.31
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PutMethod.java,v
 1.30 2002/03/15 12:48:22 juergen Exp $
  - * $Revision: 1.30 $
  - * $Date: 2002/03/15 12:48:22 $
  + * $Header: 
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PutMethod.java,v
 1.31 2002/03/18 10:13:35 juergen Exp $
  + * $Revision: 1.31 $
  + * $Date: 2002/03/18 10:13:35 $
    *
    * ====================================================================
    *
  @@ -90,6 +90,7 @@
   import org.apache.slide.webdav.util.VersioningHelper;
   import org.apache.slide.webdav.util.PreconditionViolationException;
   import org.apache.slide.webdav.util.ViolatedPrecondition;
  +import org.apache.slide.webdav.util.UriHandler;
   import org.apache.slide.util.Configuration;
   
   /**
  @@ -221,6 +222,12 @@
                       revisionDescriptor.setContentLength(-1);
                   }
                   
  +                // check preconditions
  +                ViolatedPrecondition violatedPrecondition = 
getPreconditionViolation(revisionDescriptor);
  +                if (violatedPrecondition != null) {
  +                    throw new PreconditionViolationException(violatedPrecondition);
  +                }
  +                
                   // Changed for DeltaV --start--
                   if( Configuration.useVersionControl() ) {
                       NodeProperty avProp =
  @@ -404,6 +411,44 @@
               resp.setStatus(getErrorCode(e));  // special handling needed
               throw new WebdavException(WebdavStatus.SC_ACCEPTED, false); // abort 
the TA
           }
  +    }
  +    
  +    /**
  +     * Checks the (DeltaV) preconditions
  +     * <code>DAV:cannot-modify-version-controlled-content</code> and
  +     * <code>DAV:cannot-modify-version</code>
  +     *
  +     * @param      revisionDescriptor  the NodeRevisionDescriptor of the resource
  +     *                                 to perform the <code>PUT</code> on.
  +     *
  +     * @return     the precondition that has been violated (if any).
  +     */
  +    private ViolatedPrecondition getPreconditionViolation(NodeRevisionDescriptor 
revisionDescriptor) {
  +
  +        ViolatedPrecondition violatedPrecondition = null;
  +        if( Configuration.useVersionControl() ) {
  +            
  +            // check precondition DAV:cannot-modify-version-controlled-content
  +            NodeProperty checkedInProperty = 
revisionDescriptor.getProperty(P_CHECKED_IN);
  +            if ( (checkedInProperty != null) && (checkedInProperty.getValue() != 
null) ) {
  +                
  +                NodeProperty autoVersionProperty = 
revisionDescriptor.getProperty(P_AUTO_VERSION);
  +                if ( (autoVersionProperty == null) ||
  +                        (autoVersionProperty.getValue() == null) ||
  +                        
(autoVersionProperty.getValue().toString().indexOf(E_CHECKOUT_CHECKIN) < 0) ) {
  +                    violatedPrecondition = new 
ViolatedPrecondition(C_CANNOT_MODIFY_VERSION_CONTROLLED_CONTENT,
  +                                                                    
WebdavStatus.SC_FORBIDDEN);
  +                }
  +            }
  +            
  +            // check precondition DAV:cannot-modify-version
  +            UriHandler uriHandler = UriHandler.getUriHandler(token, resourcePath);
  +            if (uriHandler.isVersionUri()) {
  +                violatedPrecondition = new 
ViolatedPrecondition(C_CANNOT_MODIFY_VERSION,
  +                                                                
WebdavStatus.SC_FORBIDDEN);
  +            }
  +        }
  +        return violatedPrecondition;
       }
       
       /**
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to