juergen     02/03/15 04:47:34

  Modified:    src/webdav/server/org/apache/slide/webdav/method
                        VersionControlMethod.java
  Log:
  Send appropriate error response and abort transaction if 
PreconditionViolationException has been thrown by VersioningHelper.
  (ralf)
  
  Revision  Changes    Path
  1.7       +34 -6     
jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/VersionControlMethod.java
  
  Index: VersionControlMethod.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/VersionControlMethod.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- VersionControlMethod.java 15 Mar 2002 10:09:10 -0000      1.6
  +++ VersionControlMethod.java 15 Mar 2002 12:47:34 -0000      1.7
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/VersionControlMethod.java,v
 1.6 2002/03/15 10:09:10 juergen Exp $
  - * $Revision: 1.6 $
  - * $Date: 2002/03/15 10:09:10 $
  + * $Header: 
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/VersionControlMethod.java,v
 1.7 2002/03/15 12:47:34 juergen Exp $
  + * $Revision: 1.7 $
  + * $Date: 2002/03/15 12:47:34 $
    *
    * ====================================================================
    *
  @@ -71,8 +71,11 @@
   
   import javax.xml.parsers.ParserConfigurationException ;
   import org.xml.sax.SAXException;
  +import org.jdom.Element;
   import org.jdom.Document;
  -import org.jdom.input.DOMBuilder;
  +import org.jdom.Namespace;
  +import org.jdom.JDOMException;
  +import org.jdom.output.XMLOutputter;
   
   import org.apache.slide.common.Uri;
   import org.apache.slide.common.Domain;
  @@ -88,9 +91,10 @@
   import org.apache.slide.webdav.util.VersioningHelper;
   import org.apache.slide.webdav.util.UriHandler;
   import org.apache.slide.webdav.util.DeltavConstants;
  +import org.apache.slide.webdav.util.ViolatedPrecondition;
  +import org.apache.slide.webdav.util.PreconditionViolationException;
   import org.apache.util.WebdavStatus;
   
  -
   /**
    * VERSION-CONTROL method.
    *
  @@ -149,7 +153,7 @@
        *
        * @exception WebdavException
        */
  -    protected void executeRequest() throws WebdavException {
  +    protected void executeRequest() throws WebdavException, IOException {
           
           // Prevent dirty reads
           slideToken.setForceStoreEnlistment(true);
  @@ -159,6 +163,10 @@
                   slideToken, token, req, resp, getConfig() );
               vh.versionControl( resourcePath );
           }
  +        catch (PreconditionViolationException e) {
  +            sendPreconditionViolation(e.getViolatedPrecondition());
  +            throw e;
  +        }
           catch (Exception e) {
               e.printStackTrace();
               resp.setStatus( getErrorCode(e) );  // special handling needed
  @@ -166,6 +174,26 @@
           }
           
       }
  +    
  +    /**
  +     * 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());
  +            
  +            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:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to