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/30 14:59:37 UTC

cvs commit: jakarta-slide/src/webdav/server/org/apache/slide/webdav/method CheckoutMethod.java CopyMethod.java OptionsMethod.java PropFindMethod.java

juergen     02/04/30 05:59:37

  Modified:    src/webdav/server/org/apache/slide/webdav/method
                        CheckoutMethod.java CopyMethod.java
                        OptionsMethod.java PropFindMethod.java
  Log:
  Implemented "additional semantics" for Label feature.
  (ralf)
  
  Revision  Changes    Path
  1.8       +52 -8     jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/CheckoutMethod.java
  
  Index: CheckoutMethod.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/CheckoutMethod.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- CheckoutMethod.java	29 Apr 2002 16:50:02 -0000	1.7
  +++ CheckoutMethod.java	30 Apr 2002 12:59:37 -0000	1.8
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/CheckoutMethod.java,v 1.7 2002/04/29 16:50:02 pnever Exp $
  - * $Revision: 1.7 $
  - * $Date: 2002/04/29 16:50:02 $
  + * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/CheckoutMethod.java,v 1.8 2002/04/30 12:59:37 juergen Exp $
  + * $Revision: 1.8 $
  + * $Date: 2002/04/30 12:59:37 $
    *
    * ====================================================================
    *
  @@ -77,6 +77,7 @@
   import org.jdom.output.XMLOutputter;
   
   import org.apache.slide.common.Domain;
  +import org.apache.slide.common.SlideException;
   import org.apache.slide.common.NamespaceAccessToken;
   import org.apache.slide.webdav.WebdavServletConfig;
   import org.apache.slide.webdav.WebdavException;
  @@ -84,6 +85,8 @@
   import org.apache.slide.webdav.util.DeltavConstants;
   import org.apache.slide.webdav.util.ViolatedPrecondition;
   import org.apache.slide.webdav.util.PreconditionViolationException;
  +import org.apache.slide.webdav.util.LabeledRevisionNotFoundException;
  +import org.apache.slide.util.Configuration;
   import org.apache.util.WebdavStatus;
   
   /**
  @@ -101,6 +104,11 @@
       private boolean forkOk = false;
       
       /**
  +     * The VersioningHelper used by this instance.
  +     */
  +    protected VersioningHelper versioningHelper = null;
  +    
  +    /**
        * CHECKOUT method constructor.
        *
        * @param token   the Namespace access token.
  @@ -110,6 +118,11 @@
        */
       public CheckoutMethod( NamespaceAccessToken token, HttpServletRequest req, HttpServletResponse resp, WebdavServletConfig config) {
           super(token, req, resp, config);
  +        versioningHelper = VersioningHelper.getVersioningHelper(slideToken,
  +                                                                token,
  +                                                                req,
  +                                                                resp,
  +                                                                config);
           readRequestContent();
       }
       
  @@ -124,6 +137,28 @@
           if (resourcePath == null) {
               resourcePath = "/";
           }
  +        // evaluate "Label" header
  +        if (Configuration.useVersionControl()) {
  +            try {
  +                applyToVersion = (req.getHeader(DeltavConstants.H_LABEL) != null);
  +                resourcePath = versioningHelper.getLabeledResourceUri(resourcePath,
  +                                                                      req.getHeader(DeltavConstants.H_LABEL));
  +            }
  +            catch (LabeledRevisionNotFoundException e) {
  +                ViolatedPrecondition violatedPrecondition =
  +                    new ViolatedPrecondition(DeltavConstants.C_MUST_SELECT_VERSION_IN_HISTORY,
  +                                             WebdavStatus.SC_CONFLICT);
  +                sendPreconditionViolation(new PreconditionViolationException(violatedPrecondition,
  +                                                                             resourcePath));
  +                throw new WebdavException(getErrorCode((Exception)e));
  +            }
  +            catch (SlideException e) {
  +                resp.sendError(getErrorCode((Exception)e));
  +                throw new WebdavException(getErrorCode((Exception)e));
  +            }
  +        }
  +        
  +        
           if( req.getContentLength() > 0 ) {
               try{
                   retrieveRequestContent();
  @@ -136,12 +171,22 @@
                   Iterator i = coe.getChildren().iterator();
                   while( i.hasNext() ) {
                       Element e = (Element)i.next();
  -                    if( e.getName().equals(E_APPLY_TO_VERSION) )
  +                    if ( e.getName().equals(E_APPLY_TO_VERSION) ) {
  +                        if (req.getHeader(DeltavConstants.H_LABEL) != null) {
  +                            ViolatedPrecondition violatedPrecondition =
  +                                new ViolatedPrecondition(DeltavConstants.C_MUST_NOT_HAVE_LABEL_AND_APPLY_TO_VERSION,
  +                                                         WebdavStatus.SC_CONFLICT);
  +                            sendPreconditionViolation(new PreconditionViolationException(violatedPrecondition,
  +                                                                                         resourcePath));
  +                            throw new WebdavException(WebdavStatus.SC_CONFLICT);
  +                        }
                           applyToVersion = true;
  -                    if( e.getName().equals(E_FORK_OK) )
  +                    }
  +                    if ( e.getName().equals(E_FORK_OK) ) {
                           forkOk = true;
                   }
               }
  +            }
               catch (SAXException  e){
                   resp.setStatus(WebdavStatus.SC_BAD_REQUEST);
                   throw new WebdavException(WebdavStatus.SC_BAD_REQUEST);
  @@ -170,9 +215,7 @@
           slideToken.setForceStoreEnlistment(true);
           
           try {
  -            VersioningHelper vh = VersioningHelper.getVersioningHelper(
  -                slideToken, token, req, resp, getConfig() );
  -            locationValue = vh.checkout( resourcePath, forkOk, applyToVersion );
  +            locationValue = versioningHelper.checkout( resourcePath, forkOk, applyToVersion );
           }
           catch (PreconditionViolationException e) {
               sendPreconditionViolation(e);
  @@ -188,6 +231,7 @@
               if( locationValue != null && locationValue.length() > 0 )
                   resp.setHeader( H_LOCATION, locationValue );
           }
  +        
       }
       
       
  
  
  
  1.31      +33 -3     jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/CopyMethod.java
  
  Index: CopyMethod.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/CopyMethod.java,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- CopyMethod.java	30 Apr 2002 12:39:19 -0000	1.30
  +++ CopyMethod.java	30 Apr 2002 12:59:37 -0000	1.31
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/CopyMethod.java,v 1.30 2002/04/30 12:39:19 pnever Exp $
  - * $Revision: 1.30 $
  - * $Date: 2002/04/30 12:39:19 $
  + * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/CopyMethod.java,v 1.31 2002/04/30 12:59:37 juergen Exp $
  + * $Revision: 1.31 $
  + * $Date: 2002/04/30 12:59:37 $
    *
    * ====================================================================
    *
  @@ -84,6 +84,7 @@
   import org.apache.slide.webdav.util.XMLValue;
   import org.apache.slide.webdav.util.VersioningHelper;
   import org.apache.slide.webdav.util.PropertyHelper;
  +import org.apache.slide.webdav.util.LabeledRevisionNotFoundException;
   import org.apache.slide.webdav.util.resourcekind.ResourceKind;
   import org.apache.slide.webdav.util.resourcekind.AbstractResourceKind;
   import org.apache.slide.webdav.util.resourcekind.CheckedInVersionControlled;
  @@ -140,7 +141,34 @@
       
       // ------------------------------------------------------ Protected Methods
       
  +    /**
  +     * Parse request.
  +     *
  +     * @exception WebdavException Does not happen
  +     */
  +    protected void parseRequest() throws WebdavException, IOException {
  +        super.parseRequest();
       
  +        // evaluate "Label" header
  +        if (Configuration.useVersionControl()) {
  +            try {
  +                sourceUri = versioningHelper.getLabeledResourceUri(sourceUri,
  +                                                                   req.getHeader(DeltavConstants.H_LABEL));
  +            }
  +            catch (LabeledRevisionNotFoundException e) {
  +                ViolatedPrecondition violatedPrecondition =
  +                    new ViolatedPrecondition(DeltavConstants.C_MUST_SELECT_VERSION_IN_HISTORY,
  +                                             WebdavStatus.SC_CONFLICT);
  +                sendPreconditionViolation(new PreconditionViolationException(violatedPrecondition,
  +                                                                             sourceUri));
  +                throw new WebdavException(getErrorCode((Exception)e));
  +            }
  +            catch (SlideException e) {
  +                resp.sendError(getErrorCode((Exception)e));
  +                throw new WebdavException(getErrorCode((Exception)e));
  +            }
  +        }
  +    }
       
       /**
        * Execute request.
  @@ -437,6 +465,8 @@
           
       }
   }
  +
  +
   
   
   
  
  
  
  1.20      +4 -3      jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/OptionsMethod.java
  
  Index: OptionsMethod.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/OptionsMethod.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- OptionsMethod.java	25 Apr 2002 21:27:31 -0000	1.19
  +++ OptionsMethod.java	30 Apr 2002 12:59:37 -0000	1.20
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/OptionsMethod.java,v 1.19 2002/04/25 21:27:31 jericho Exp $
  - * $Revision: 1.19 $
  - * $Date: 2002/04/25 21:27:31 $
  + * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/OptionsMethod.java,v 1.20 2002/04/30 12:59:37 juergen Exp $
  + * $Revision: 1.20 $
  + * $Date: 2002/04/30 12:59:37 $
    *
    * ====================================================================
    *
  @@ -175,6 +175,7 @@
               davHeader.append( ", " ).append( F_VERSION_HISTORY );
               davHeader.append( ", " ).append( F_CHECKOUT_IN_PLACE );
               davHeader.append( ", " ).append( F_WORKSPACE );
  +            davHeader.append( ", " ).append( F_LABEL );
           }
           
           resp.addHeader( "DAV", davHeader.toString() );
  
  
  
  1.65      +49 -9     jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PropFindMethod.java
  
  Index: PropFindMethod.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PropFindMethod.java,v
  retrieving revision 1.64
  retrieving revision 1.65
  diff -u -r1.64 -r1.65
  --- PropFindMethod.java	30 Apr 2002 12:39:19 -0000	1.64
  +++ PropFindMethod.java	30 Apr 2002 12:59:37 -0000	1.65
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PropFindMethod.java,v 1.64 2002/04/30 12:39:19 pnever Exp $
  - * $Revision: 1.64 $
  - * $Date: 2002/04/30 12:39:19 $
  + * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PropFindMethod.java,v 1.65 2002/04/30 12:59:37 juergen Exp $
  + * $Revision: 1.65 $
  + * $Date: 2002/04/30 12:59:37 $
    *
    * ====================================================================
    *
  @@ -89,6 +89,9 @@
   import org.apache.slide.webdav.util.PropertyHelper;
   import org.apache.slide.webdav.util.PropertyRetriever;
   import org.apache.slide.webdav.util.PropertyRetrieverImpl;
  +import org.apache.slide.webdav.util.ViolatedPrecondition;
  +import org.apache.slide.webdav.util.PreconditionViolationException;
  +import org.apache.slide.webdav.util.LabeledRevisionNotFoundException;
   import org.apache.slide.webdav.util.resourcekind.AbstractResourceKind;
   import org.apache.slide.webdav.util.resourcekind.ResourceKind;
   import org.apache.slide.util.Configuration;
  @@ -169,6 +172,16 @@
       protected RequestedProperties requestedProperties = null;
       
       
  +    /**
  +     * Resource to be retrieved.
  +     */
  +    protected String resourcePath;
  +    
  +    /**
  +     * The VersioningHelper used by this instance.
  +     */
  +    protected VersioningHelper versioningHelper = null;
  +    
       // ----------------------------------------------------------- Constructors
       
       
  @@ -183,6 +196,8 @@
                             HttpServletResponse resp,
                             WebdavServletConfig config) {
           super(token, req, resp, config);
  +        versioningHelper =  VersioningHelper.getVersioningHelper(
  +            slideToken, token, req, resp, getConfig() );
           readRequestContent();
           
           depth = INFINITY;
  @@ -201,7 +216,32 @@
        *
        * @exception WebdavException Bad request
        */
  -    protected void parseRequest() throws WebdavException {
  +    protected void parseRequest() throws WebdavException, IOException {
  +        
  +        resourcePath = requestUri;
  +        if (resourcePath == null) {
  +            resourcePath = "/";
  +        }
  +
  +        // evaluate "Label" header
  +        if (Configuration.useVersionControl()) {
  +            try {
  +                resourcePath = versioningHelper.getLabeledResourceUri(resourcePath,
  +                                                           req.getHeader(DeltavConstants.H_LABEL));
  +            }
  +            catch (LabeledRevisionNotFoundException e) {
  +                ViolatedPrecondition violatedPrecondition =
  +                    new ViolatedPrecondition(DeltavConstants.C_MUST_SELECT_VERSION_IN_HISTORY,
  +                                             WebdavStatus.SC_CONFLICT);
  +                sendPreconditionViolation(new PreconditionViolationException(violatedPrecondition,
  +                                                                             resourcePath));
  +                throw new WebdavException(getErrorCode((Exception)e));
  +            }
  +            catch (SlideException e) {
  +                resp.sendError(getErrorCode((Exception)e));
  +                throw new WebdavException(getErrorCode((Exception)e));
  +            }
  +        }
           
           retrieveDepth();
           
  @@ -306,13 +346,12 @@
           resp.setStatus(WebdavStatus.SC_MULTI_STATUS);
           
           // Loads the associated object from the store.
  -        String resourceUri = requestUri;
           
           // Get the object from Data.
           ObjectNode resource = null;
           
           try {
  -            resource = structure.retrieve(slideToken, resourceUri);
  +            resource = structure.retrieve(slideToken, resourcePath);
           } catch (StructureException e) {
               try {
                   resp.sendError
  @@ -543,12 +582,12 @@
        * Returns the appropriate <code>&lt;response&gt;</code> due to the given
        * <code>exception</code> to the <code>generatedXML</code>
        *
  -     * @param      requestUri     the URI of the request to display in the
  +     * @param      resourcePath     the URI of the request to display in the
        *                            <code>&lt;href&gt;</code> element.
        * @param      errorCode      the HTTP error code.
        * @param      condition      the condition that has been violated.
        */
  -    private Element getErrorResponse(String requestUri, int errorCode, String condition) {
  +    private Element getErrorResponse(String resourcePath, int errorCode, String condition) {
           
           Element response = new Element(E_RESPONSE,  Namespace.getNamespace(DEFAULT_NAMESPACE));
           
  @@ -557,7 +596,7 @@
                            req.getServerName()+ ":" +
                            req.getServerPort() +
                            req.getContextPath() +
  -                         requestUri);
  +                         resourcePath);
           response.addContent(href);
           Element propStat = new Element(E_PROPSTAT,  Namespace.getNamespace(DEFAULT_NAMESPACE));
           response.addContent(propStat);
  @@ -579,6 +618,7 @@
       
       
   }
  +
   
   
   
  
  
  

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