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/12 16:23:19 UTC

cvs commit: jakarta-slide/src/webdav/server/org/apache/slide/webdav/method CheckinMethod.java CheckoutMethod.java DeleteMethod.java MkworkspaceMethod.java MoveMethod.java ReportMethod.java UncheckoutMethod.java

juergen     02/04/12 07:23:19

  Modified:    src/webdav/server/org/apache/slide/webdav/method
                        CheckinMethod.java CheckoutMethod.java
                        DeleteMethod.java MkworkspaceMethod.java
                        MoveMethod.java ReportMethod.java
                        UncheckoutMethod.java
  Log:
  Code clean up:
  Use sendPreconditionViolation() method of super class WebdavMethod.
  (ralf)
  
  Revision  Changes    Path
  1.5       +4 -25     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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- CheckinMethod.java	12 Apr 2002 12:27:50 -0000	1.4
  +++ CheckinMethod.java	12 Apr 2002 14:23:18 -0000	1.5
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/CheckinMethod.java,v 1.4 2002/04/12 12:27:50 juergen Exp $
  - * $Revision: 1.4 $
  - * $Date: 2002/04/12 12:27:50 $
  + * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/CheckinMethod.java,v 1.5 2002/04/12 14:23:18 juergen Exp $
  + * $Revision: 1.5 $
  + * $Date: 2002/04/12 14:23:18 $
    *
    * ====================================================================
    *
  @@ -162,7 +162,7 @@
               resp.setHeader(H_LOCATION, getAbsoluteURL(vh.getUriOfAssociatedVR(resourcePath)));
           }
           catch (PreconditionViolationException e) {
  -            sendPreconditionViolation(e.getViolatedPrecondition());
  +            sendPreconditionViolation(e);
               throw e;
           }
           catch (Exception e) {
  @@ -174,27 +174,6 @@
               resp.setHeader(H_CACHE_CONTROL, NO_CACHE);
           }
           
  -    }
  -    
  -    /**
  -     * Sends a precondition vilolation response.
  -     *
  -     * @param     violatedPrecondition  the precondition that has been violated.
  -     *
  -     * @throws IOException if writing of the response fails.
  -     */
  -    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());
  -        }
       }
       
       
  
  
  
  1.4       +4 -25     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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- CheckoutMethod.java	5 Apr 2002 05:43:14 -0000	1.3
  +++ CheckoutMethod.java	12 Apr 2002 14:23:18 -0000	1.4
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/CheckoutMethod.java,v 1.3 2002/04/05 05:43:14 juergen Exp $
  - * $Revision: 1.3 $
  - * $Date: 2002/04/05 05:43:14 $
  + * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/CheckoutMethod.java,v 1.4 2002/04/12 14:23:18 juergen Exp $
  + * $Revision: 1.4 $
  + * $Date: 2002/04/12 14:23:18 $
    *
    * ====================================================================
    *
  @@ -159,7 +159,7 @@
               vh.checkout( resourcePath , false, false);
           }
           catch (PreconditionViolationException e) {
  -            sendPreconditionViolation(e.getViolatedPrecondition());
  +            sendPreconditionViolation(e);
               throw e;
           }
           catch (Exception e) {
  @@ -171,27 +171,6 @@
               resp.setHeader(H_CACHE_CONTROL, NO_CACHE);
           }
           
  -    }
  -    
  -    /**
  -     * Sends a precondition vilolation response.
  -     *
  -     * @param     violatedPrecondition  the precondition that has been violated.
  -     *
  -     * @throws IOException if writing of the response fails.
  -     */
  -    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());
  -        }
       }
       
       
  
  
  
  1.18      +7 -9      jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/DeleteMethod.java
  
  Index: DeleteMethod.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/DeleteMethod.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- DeleteMethod.java	12 Apr 2002 02:29:26 -0000	1.17
  +++ DeleteMethod.java	12 Apr 2002 14:23:18 -0000	1.18
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/DeleteMethod.java,v 1.17 2002/04/12 02:29:26 msmith Exp $
  - * $Revision: 1.17 $
  - * $Date: 2002/04/12 02:29:26 $
  + * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/DeleteMethod.java,v 1.18 2002/04/12 14:23:18 juergen Exp $
  + * $Revision: 1.18 $
  + * $Date: 2002/04/12 14:23:18 $
    *
    * ====================================================================
    *
  @@ -214,10 +214,7 @@
                   resp.setStatus(getErrorCode(exception));
                   if (exception instanceof PreconditionViolationException) {
                       try {
  -                        StringWriter stringWriter = new StringWriter();
  -                        new XMLOutputter().output(getPreconditionViolationError((PreconditionViolationException)exception), stringWriter);
  -                        resp.setContentType(TEXT_XML_UTF_8);
  -                        resp.getWriter().write(stringWriter.toString());
  +                        sendPreconditionViolation((PreconditionViolationException)exception);
                       } catch(IOException ex) {
                           // Critical error ... Servlet container is dead or something
                           ex.printStackTrace();
  @@ -254,8 +251,9 @@
               uriHandler = UriHandler.getUriHandler(token, targetUri);
               if (uriHandler.isVersionUri() && !isCollection) {
                   // delete of version is only allowed if the history collection is deleted
  -                throw new PreconditionViolationException(
  -                        new ViolatedPrecondition(C_NO_VERSION_DELETE, WebdavStatus.SC_FORBIDDEN), targetUri);
  +            throw new PreconditionViolationException(new ViolatedPrecondition(C_NO_VERSION_DELETE,
  +                                                                              WebdavStatus.SC_FORBIDDEN),
  +                                                     targetUri);
               }
           
               uriOfAssociatedVR = versioningHelper.getUriOfAssociatedVR(targetUri);
  
  
  
  1.2       +3 -21     jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/MkworkspaceMethod.java
  
  Index: MkworkspaceMethod.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/MkworkspaceMethod.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MkworkspaceMethod.java	5 Apr 2002 16:10:49 -0000	1.1
  +++ MkworkspaceMethod.java	12 Apr 2002 14:23:18 -0000	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/MkworkspaceMethod.java,v 1.1 2002/04/05 16:10:49 pnever Exp $
  - * $Revision: 1.1 $
  - * $Date: 2002/04/05 16:10:49 $
  + * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/MkworkspaceMethod.java,v 1.2 2002/04/12 14:23:18 juergen Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/04/12 14:23:18 $
    *
    * ====================================================================
    *
  @@ -158,7 +158,7 @@
               vh.mkworkspace( resourcePath );
           }
           catch (PreconditionViolationException e) {
  -            sendPreconditionViolation(e.getViolatedPrecondition());
  +            sendPreconditionViolation(e);
               throw e;
           }
           catch (Exception e) {
  @@ -169,23 +169,5 @@
           
       }
       
  -    /**
  -     * 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());
  -        }
  -    }
   }
   
  
  
  
  1.25      +4 -7      jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/MoveMethod.java
  
  Index: MoveMethod.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/MoveMethod.java,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- MoveMethod.java	12 Apr 2002 12:29:46 -0000	1.24
  +++ MoveMethod.java	12 Apr 2002 14:23:18 -0000	1.25
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/MoveMethod.java,v 1.24 2002/04/12 12:29:46 juergen Exp $
  - * $Revision: 1.24 $
  - * $Date: 2002/04/12 12:29:46 $
  + * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/MoveMethod.java,v 1.25 2002/04/12 14:23:18 juergen Exp $
  + * $Revision: 1.25 $
  + * $Date: 2002/04/12 14:23:18 $
    *
    * ====================================================================
    *
  @@ -219,10 +219,7 @@
                   resp.setStatus(getErrorCode(exception));
                   if (exception instanceof PreconditionViolationException) {
                       try {
  -                        StringWriter stringWriter = new StringWriter();
  -                        new XMLOutputter().output(getPreconditionViolationError((PreconditionViolationException)exception), stringWriter);
  -                        resp.setContentType(TEXT_XML_UTF_8);
  -                        resp.getWriter().write(stringWriter.toString());
  +                        sendPreconditionViolation((PreconditionViolationException)exception);
                       } catch(IOException ex) {
                           // Critical error ... Servlet container is dead or something
                           ex.printStackTrace();
  
  
  
  1.16      +5 -24     jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/ReportMethod.java
  
  Index: ReportMethod.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/ReportMethod.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- ReportMethod.java	8 Apr 2002 12:41:33 -0000	1.15
  +++ ReportMethod.java	12 Apr 2002 14:23:18 -0000	1.16
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/ReportMethod.java,v 1.15 2002/04/08 12:41:33 juergen Exp $
  - * $Revision: 1.15 $
  - * $Date: 2002/04/08 12:41:33 $
  + * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/ReportMethod.java,v 1.16 2002/04/12 14:23:18 juergen Exp $
  + * $Revision: 1.16 $
  + * $Date: 2002/04/12 14:23:18 $
    *
    * ====================================================================
    *
  @@ -164,7 +164,7 @@
   /**
    * An implementation of the DeltaV <code>REPORT</code> method.
    *
  - * @version $Revision: 1.15 $
  + * @version $Revision: 1.16 $
    *
    * @author <a href="mailto:ralf.stuckert@softwareag.com">Ralf Stuckert</a>
    */
  @@ -544,7 +544,7 @@
               new XMLOutputter().output(multistatusElement, getResponse().getWriter());
           }
           catch (PreconditionViolationException e) {
  -            sendPreconditionViolation(e.getViolatedPrecondition());
  +            sendPreconditionViolation(e);
               throw e;
           }
           catch (Exception e) {
  @@ -1479,25 +1479,6 @@
           }
           
           return status;
  -    }
  -    
  -    /**
  -     * 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());
  -        }
       }
       
       
  
  
  
  1.4       +4 -25     jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/UncheckoutMethod.java
  
  Index: UncheckoutMethod.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/UncheckoutMethod.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- UncheckoutMethod.java	5 Apr 2002 05:45:10 -0000	1.3
  +++ UncheckoutMethod.java	12 Apr 2002 14:23:18 -0000	1.4
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/UncheckoutMethod.java,v 1.3 2002/04/05 05:45:10 juergen Exp $
  - * $Revision: 1.3 $
  - * $Date: 2002/04/05 05:45:10 $
  + * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/UncheckoutMethod.java,v 1.4 2002/04/12 14:23:18 juergen Exp $
  + * $Revision: 1.4 $
  + * $Date: 2002/04/12 14:23:18 $
    *
    * ====================================================================
    *
  @@ -159,7 +159,7 @@
               vh.uncheckout(resourcePath);
           }
           catch (PreconditionViolationException e) {
  -            sendPreconditionViolation(e.getViolatedPrecondition());
  +            sendPreconditionViolation(e);
               throw e;
           }
           catch (Exception e) {
  @@ -171,27 +171,6 @@
               resp.setHeader(H_CACHE_CONTROL, NO_CACHE);
           }
           
  -    }
  -    
  -    /**
  -     * Sends a precondition vilolation response.
  -     *
  -     * @param     violatedPrecondition  the precondition that has been violated.
  -     *
  -     * @throws IOException if writing of the response fails.
  -     */
  -    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>