pnever      02/04/29 09:49:44

  Modified:    src/webdav/server/org/apache/slide/webdav/method
                        CheckinMethod.java
  Log:
  Added marshalling and set Location: header
  
  Revision  Changes    Path
  1.7       +42 -30    
jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/CheckinMethod.java
  
  Index: CheckinMethod.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/CheckinMethod.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- CheckinMethod.java        25 Apr 2002 21:12:25 -0000      1.6
  +++ CheckinMethod.java        29 Apr 2002 16:49:43 -0000      1.7
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/CheckinMethod.java,v
 1.6 2002/04/25 21:12:25 jericho Exp $
  - * $Revision: 1.6 $
  - * $Date: 2002/04/25 21:12:25 $
  + * $Header: 
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/CheckinMethod.java,v
 1.7 2002/04/29 16:49:43 pnever Exp $
  + * $Revision: 1.7 $
  + * $Date: 2002/04/29 16:49:43 $
    *
    * ====================================================================
    *
  @@ -62,8 +62,8 @@
    */
   package org.apache.slide.webdav.method;
   
  -// import list
  -import java.io.IOException;
  +import java.io.*;
  +import java.util.*;
   
   import javax.servlet.http.HttpServletRequest;
   import javax.servlet.http.HttpServletResponse;
  @@ -76,6 +76,7 @@
   import org.jdom.JDOMException;
   import org.jdom.output.XMLOutputter;
   
  +import org.apache.slide.common.Domain;
   import org.apache.slide.common.NamespaceAccessToken;
   import org.apache.slide.webdav.WebdavServletConfig;
   import org.apache.slide.webdav.WebdavException;
  @@ -92,15 +93,11 @@
    */
   public class CheckinMethod extends WebdavMethod implements DeltavConstants {
       
  -    /**
  -     * String constant for <code>no-cache</code>.
  -     */
  -    protected static final String NO_CACHE = "no-cache";
  -    
  -    /**
  -     * Resource to be written.
  -     */
  +    /** Resource to be written. */
       private String resourcePath;
  +    
  +    /** Marshalling variables */
  +    private boolean forkOk = false;
           
       /**
        * CHECKIN method constructor.
  @@ -126,20 +123,34 @@
           if (resourcePath == null) {
               resourcePath = "/";
           }
  -        try{
  -            retrieveRequestContent();
  -        }
  -        catch (SAXException  e){
  -            resp.setStatus(WebdavStatus.SC_BAD_REQUEST);
  -            throw new WebdavException(WebdavStatus.SC_BAD_REQUEST);
  -        }
  -        catch (IOException  e){
  -            resp.setStatus(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
  -            throw new WebdavException(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
  -        }
  -        catch (ParserConfigurationException  e){
  -            resp.setStatus(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
  -            throw new WebdavException(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
  +        if( req.getContentLength() > 0 ) {
  +            try{
  +                retrieveRequestContent();
  +                Element cie = getRequestContent().getRootElement();
  +                if( cie == null || !cie.getName().equals(E_CHECKIN) ) {
  +                    Domain.warn( "Root element must be "+E_CHECKIN );
  +                    resp.setStatus(WebdavStatus.SC_BAD_REQUEST);
  +                    throw new WebdavException(WebdavStatus.SC_BAD_REQUEST);
  +                }
  +                Iterator i = cie.getChildren().iterator();
  +                while( i.hasNext() ) {
  +                    Element e = (Element)i.next();
  +                    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);
  +            }
  +            catch (IOException  e){
  +                resp.setStatus(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
  +                throw new WebdavException(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
  +            }
  +            catch (ParserConfigurationException  e){
  +                resp.setStatus(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
  +                throw new WebdavException(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
  +            }
           }
       }
   
  @@ -150,6 +161,7 @@
        * @throws IOException
        */
       protected void executeRequest() throws WebdavException, IOException {
  +        String locationValue = null;
           
           // Prevent dirty reads
           slideToken.setForceStoreEnlistment(true);
  @@ -157,9 +169,7 @@
           try {
               VersioningHelper vh = VersioningHelper.getVersioningHelper(
                   slideToken, token, req, resp, getConfig() );
  -            vh.checkin( resourcePath , false, false);
  -            resp.setStatus(WebdavStatus.SC_CREATED);
  -            resp.setHeader(H_LOCATION, 
getAbsoluteURL(vh.getUriOfAssociatedVR(resourcePath)));
  +            locationValue = vh.checkin( resourcePath , false, false);
           }
           catch (PreconditionViolationException e) {
               sendPreconditionViolation(e);
  @@ -172,6 +182,8 @@
           }
           finally {
               resp.setHeader(H_CACHE_CONTROL, NO_CACHE);
  +            if( locationValue != null && locationValue.length() > 0 )
  +                resp.setHeader( H_LOCATION, locationValue );
           }
           
       }
  
  
  

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

Reply via email to