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 ju...@apache.org on 2002/04/08 14:47:48 UTC

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

juergen     02/04/08 05:47:48

  Modified:    src/webdav/server/org/apache/slide/webdav/method
                        PutMethod.java
  Log:
  Added support for the remaining auto-versioning modes.
  (ralf)
  
  Revision  Changes    Path
  1.37      +45 -54    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.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- PutMethod.java	3 Apr 2002 11:55:07 -0000	1.36
  +++ PutMethod.java	8 Apr 2002 12:47:48 -0000	1.37
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PutMethod.java,v 1.36 2002/04/03 11:55:07 juergen Exp $
  - * $Revision: 1.36 $
  - * $Date: 2002/04/03 11:55:07 $
  + * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PutMethod.java,v 1.37 2002/04/08 12:47:48 juergen Exp $
  + * $Revision: 1.37 $
  + * $Date: 2002/04/08 12:47:48 $
    *
    * ====================================================================
    *
  @@ -93,7 +93,7 @@
   import org.apache.slide.webdav.util.UriHandler;
   import org.apache.slide.webdav.util.resourcekind.ResourceKind;
   import org.apache.slide.webdav.util.resourcekind.AbstractResourceKind;
  -import org.apache.slide.webdav.util.resourcekind.CheckedOutVersionControlled;
  +import org.apache.slide.webdav.util.resourcekind.CheckedInVersionControlled;
   import org.apache.slide.util.Configuration;
   
   /**
  @@ -107,16 +107,18 @@
       
       // -------------------------------------------------------------- Constants
       
  -    
       // ----------------------------------------------------- Instance Variables
       
  +    /**
  +     * The VersioningHelper used by this instance.
  +     */
  +    protected VersioningHelper versioningHelper = null;
       
       /**
        * Resource to be written.
        */
       private String resourcePath;
       
  -    
       // ----------------------------------------------------------- Constructors
       
       
  @@ -130,6 +132,11 @@
       public PutMethod(NamespaceAccessToken token, HttpServletRequest req,
                        HttpServletResponse resp, WebdavServletConfig config) {
           super(token, req, resp, config);
  +        versioningHelper = VersioningHelper.getVersioningHelper(slideToken,
  +                                                                token,
  +                                                                req,
  +                                                                resp,
  +                                                                config);
       }
       
       
  @@ -215,25 +222,28 @@
                   
                   ResourceKind resourceKind = AbstractResourceKind.determineResourceKind(revisionDescriptor);
                   
  +                versioningHelper.isWriteLocked(slideToken, revisionDescriptors);
  +                
                   // check preconditions
  -                ViolatedPrecondition violatedPrecondition = getPreconditionViolation(revisionDescriptor);
  +                ViolatedPrecondition violatedPrecondition = getPreconditionViolation(revisionDescriptors, revisionDescriptor);
                   if (violatedPrecondition != null) {
                       throw new PreconditionViolationException(violatedPrecondition, resourcePath);
                   }
                   
                   // Changed for DeltaV --start--
  -                boolean mustCheckIn = false;
  -                if( Configuration.useVersionControl() && !(resourceKind instanceof CheckedOutVersionControlled) ) {
  -                    NodeProperty avProp =
  -                        revisionDescriptor.getProperty( P_AUTO_VERSION );
  +                boolean isCheckedOut = false;
  +                if( Configuration.useVersionControl() &&
  +                       (resourceKind instanceof CheckedInVersionControlled) &&
  +                   versioningHelper.mustCheckoutAutoVersionedVCR(revisionDescriptors, revisionDescriptor) ) {
                       
  -                    if( avProp != null && avProp.getValue() != null
  -                    && ((String)avProp.getValue()).indexOf(E_CHECKOUT_CHECKIN) >= 0 ) {
  -                        
  -                        vHelp.checkout(
  -                            revisionDescriptors, revisionDescriptor, false, false ); //forkOk=false, applyToVersion=false
  -                        mustCheckIn = true;
  +                    vHelp.checkout(revisionDescriptors, revisionDescriptor, false, false ); //forkOk=false, applyToVersion=false
  +                    if ( ! versioningHelper.mustCheckinAutoVersionedVCR(slideToken, revisionDescriptors, revisionDescriptor) ) {
  +                        NodeLock writeLock = versioningHelper.getWriteLock(slideToken, revisionDescriptors);
  +                        if (writeLock != null) {
  +                            revisionDescriptor.setProperty(new NodeProperty(VersioningHelper.P_CHECKIN_LOCKTOKEN, writeLock.getLockId(), true));
  +                        }
                       }
  +                    isCheckedOut = true;
                   }
                   // Changed for DeltaV --end--
                   
  @@ -283,16 +293,9 @@
                   resp.setStatus(WebdavStatus.SC_NO_CONTENT);
                   
                   // Changed for DeltaV --start--
  -                if( Configuration.useVersionControl() && mustCheckIn) {
  -                    NodeProperty avProp =
  -                        revisionDescriptor.getProperty( P_AUTO_VERSION );
  -                    
  -                    if( avProp != null && avProp.getValue() != null
  -                    && ((String)avProp.getValue()).indexOf(E_CHECKOUT_CHECKIN) >= 0 ) {
  -                        
  -                        vHelp.checkin(
  -                            revisionDescriptors, revisionDescriptor, false, false ); //forkOk=false, keepCheckedOut=false
  -                    }
  +                if( Configuration.useVersionControl() && isCheckedOut && versioningHelper.mustCheckinAutoVersionedVCR(slideToken, revisionDescriptors, revisionDescriptor)) {
  +                    revisionDescriptor.removeProperty(new NodeProperty(VersioningHelper.P_CHECKIN_LOCKTOKEN, null, true));
  +                    vHelp.checkin(revisionDescriptors, revisionDescriptor, false, false ); //forkOk=false, keepCheckedOut=false
                   }
                   // Changed for DeltaV --end--
                   
  @@ -398,7 +401,7 @@
               }
           }
           catch (PreconditionViolationException e) {
  -            sendPreconditionViolation(e.getViolatedPrecondition());
  +            sendPreconditionViolation(e);
               throw e;
           }
           catch (Exception e) {
  @@ -415,28 +418,35 @@
        * <li>&lt;code&gt;DAV:cannot-modify-version&lt;/code&gt;</li>
        * </ul>
        *
  +     * @param      revisionDescriptors  the NodeRevisionDescriptors of the resource
  +     *                                  to perform the <code>PUT</code> on.
        * @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) {
  +    private ViolatedPrecondition getPreconditionViolation(NodeRevisionDescriptors revisionDescriptors, 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) ) {
  +            String autoVersion = versioningHelper.getAutoVersionValue(revisionDescriptor);
  +            if (autoVersion != null) {
                   
  -                NodeProperty autoVersionProperty = revisionDescriptor.getProperty(P_AUTO_VERSION);
  -                if ( (autoVersionProperty == null) ||
  -                        (autoVersionProperty.getValue() == null) ||
  -                        (autoVersionProperty.getValue().toString().indexOf(E_CHECKOUT_CHECKIN) < 0) ) {
  +                if ( (autoVersion.indexOf(E_CHECKOUT_CHECKIN) < 0) &&
  +                        (autoVersion.indexOf(E_CHECKOUT_UNLOCKED_CHECKIN) < 0) &&
  +                        (autoVersion.indexOf(E_CHECKOUT) < 0) ) {
  +                    violatedPrecondition = 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,
                                                                       WebdavStatus.SC_FORBIDDEN);
                   }
               }
  +            }
               
               // check precondition DAV:cannot-modify-version
               UriHandler uriHandler = UriHandler.getUriHandler(token, resourcePath);
  @@ -446,25 +456,6 @@
               }
           }
           return violatedPrecondition;
  -    }
  -    
  -    /**
  -     * Sends a precondition vilolation response.
  -     *
  -     * @param     violatedPrecondition  the precondition that has been violated.
  -     */
  -    protected void sendPreconditionViolation(ViolatedPrecondition violatedPrecondition) throws IOException {
  -        
  -        if (violatedPrecondition != null) {
  -        
  -            resp.setStatus(violatedPrecondition.getStatusCode());
  -            resp.setContentType(TEXT_XML);
  -        
  -            Element errorElement = new Element(E_ERROR, Namespace.getNamespace(DEFAULT_NAMESPACE));
  -            Element preconditionElement = new Element(violatedPrecondition.getPrecondition(),  Namespace.getNamespace(DEFAULT_NAMESPACE));
  -            errorElement.addContent(preconditionElement);
  -            new XMLOutputter().output(errorElement, resp.getWriter());
  -    }
       }
       
       
  
  
  

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