juergen     02/04/09 01:11:06

  Modified:    src/webdav/server/org/apache/slide/webdav/method
                        PutMethod.java
  Log:
  Fixed bug in precondition check and auto-versioning.
  (ralf)
  
  Revision  Changes    Path
  1.39      +20 -17    
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.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- PutMethod.java    8 Apr 2002 12:57:10 -0000       1.38
  +++ PutMethod.java    9 Apr 2002 08:11:06 -0000       1.39
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PutMethod.java,v
 1.38 2002/04/08 12:57:10 juergen Exp $
  - * $Revision: 1.38 $
  - * $Date: 2002/04/08 12:57:10 $
  + * $Header: 
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PutMethod.java,v
 1.39 2002/04/09 08:11:06 juergen Exp $
  + * $Revision: 1.39 $
  + * $Date: 2002/04/09 08:11:06 $
    *
    * ====================================================================
    *
  @@ -225,13 +225,13 @@
                   versioningHelper.isWriteLocked(slideToken, revisionDescriptors);
                   
                   // check preconditions
  -                ViolatedPrecondition violatedPrecondition = 
getPreconditionViolation(revisionDescriptors, revisionDescriptor);
  +                ViolatedPrecondition violatedPrecondition = 
getPreconditionViolation(revisionDescriptors, revisionDescriptor, resourceKind);
                   if (violatedPrecondition != null) {
                       throw new PreconditionViolationException(violatedPrecondition, 
resourcePath);
                   }
                   
                   // Changed for DeltaV --start--
  -                boolean isCheckedOut = false;
  +                boolean mustCheckIn = false;
                   if( Configuration.useVersionControl() &&
                          (resourceKind instanceof CheckedInVersionControlled) &&
                      
versioningHelper.mustCheckoutAutoVersionedVCR(revisionDescriptors, revisionDescriptor) 
) {
  @@ -243,7 +243,7 @@
                               revisionDescriptor.setProperty(new 
NodeProperty(VersioningHelper.P_CHECKIN_LOCKTOKEN, writeLock.getLockId(), true));
                           }
                       }
  -                    isCheckedOut = true;
  +                    mustCheckIn = 
versioningHelper.mustCheckinAutoVersionedVCR(slideToken, revisionDescriptors, 
revisionDescriptor);
                   }
                   // Changed for DeltaV --end--
                   
  @@ -293,7 +293,7 @@
                   resp.setStatus(WebdavStatus.SC_NO_CONTENT);
                   
                   // Changed for DeltaV --start--
  -                if( Configuration.useVersionControl() && isCheckedOut && 
versioningHelper.mustCheckinAutoVersionedVCR(slideToken, revisionDescriptors, 
revisionDescriptor)) {
  +                if( Configuration.useVersionControl() && mustCheckIn) {
                       revisionDescriptor.removeProperty(new 
NodeProperty(VersioningHelper.P_CHECKIN_LOCKTOKEN, null, true));
                       vHelp.checkin(revisionDescriptors, revisionDescriptor, false, 
false ); //forkOk=false, keepCheckedOut=false
                   }
  @@ -422,41 +422,44 @@
        *                                  to perform the <code>PUT</code> on.
        * @param      revisionDescriptor  the NodeRevisionDescriptor of the resource
        *                                 to perform the <code>PUT</code> on.
  +     * @param      resourceKind         the ResourceKind of the resource.
        *
        * @return     the precondition that has been violated (if any).
        */
  -    private ViolatedPrecondition getPreconditionViolation(NodeRevisionDescriptors 
revisionDescriptors, NodeRevisionDescriptor revisionDescriptor) {
  +    private ViolatedPrecondition getPreconditionViolation(NodeRevisionDescriptors 
revisionDescriptors, NodeRevisionDescriptor revisionDescriptor, ResourceKind 
resourceKind) {
   
  -        ViolatedPrecondition violatedPrecondition = null;
           if( Configuration.useVersionControl() ) {
               
  +            if (resourceKind instanceof CheckedInVersionControlled) {
  +                
               // check precondition DAV:cannot-modify-version-controlled-content
               String autoVersion = 
versioningHelper.getAutoVersionValue(revisionDescriptor);
  -            if (autoVersion != null) {
  +                if (autoVersion == null) {
  +                    autoVersion = "";
  +                }
                   
                   if ( (autoVersion.indexOf(E_CHECKOUT_CHECKIN) < 0) &&
                           (autoVersion.indexOf(E_CHECKOUT_UNLOCKED_CHECKIN) < 0) &&
                           (autoVersion.indexOf(E_CHECKOUT) < 0) &&
                           (autoVersion.indexOf(E_LOCKED_CHECKOUT) < 0) ) {
  -                    violatedPrecondition = new 
ViolatedPrecondition(C_CANNOT_MODIFY_VERSION_CONTROLLED_CONTENT,
  +                    return new 
ViolatedPrecondition(C_CANNOT_MODIFY_VERSION_CONTROLLED_CONTENT,
                                                                       
WebdavStatus.SC_FORBIDDEN);
                   }
  -                if (autoVersion.indexOf(E_LOCKED_CHECKOUT) > 0) {
  -                    if ( !versioningHelper.isWriteLocked(slideToken, 
revisionDescriptors) ) {
  -                    violatedPrecondition = new 
ViolatedPrecondition(C_CANNOT_MODIFY_VERSION_CONTROLLED_CONTENT,
  +                if ( (autoVersion.indexOf(E_LOCKED_CHECKOUT) > 0) &&
  +                        ( !versioningHelper.isWriteLocked(slideToken, 
revisionDescriptors) ) ) {
  +                    return 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,
  +                return new ViolatedPrecondition(C_CANNOT_MODIFY_VERSION,
                                                                   
WebdavStatus.SC_FORBIDDEN);
               }
           }
  -        return violatedPrecondition;
  +        return null;
       }
       
       
  
  
  

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

Reply via email to