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 pn...@apache.org on 2002/08/14 12:56:06 UTC

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

pnever      2002/08/14 03:56:06

  Modified:    src/webdav/server/org/apache/slide/webdav/util
                        VersioningHelper.java
               src/share/org/apache/slide/util/resources
                        messages.properties
               src/webdav/server/org/apache/slide/webdav/method
                        AbstractWebdavMethod.java
  Added:       src/webdav/server/org/apache/slide/webdav/method
                        MethodNotAllowedException.java
  Log:
  Introduced or.apache.slide.webdav.method.MethodNotAllowedException
  
  Revision  Changes    Path
  1.73      +12 -16    jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/VersioningHelper.java
  
  Index: VersioningHelper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/VersioningHelper.java,v
  retrieving revision 1.72
  retrieving revision 1.73
  diff -u -r1.72 -r1.73
  --- VersioningHelper.java	12 Aug 2002 16:04:21 -0000	1.72
  +++ VersioningHelper.java	14 Aug 2002 10:56:05 -0000	1.73
  @@ -121,6 +121,8 @@
   import org.apache.slide.webdav.WebdavServletConfig;
   import org.apache.slide.webdav.WebdavException;
   
  +import org.apache.slide.webdav.method.MethodNotAllowedException;
  +
   import org.apache.slide.webdav.util.PropertyHelper;
   import org.apache.slide.webdav.util.UriHandler;
   import org.apache.slide.webdav.util.DeltavConstants;
  @@ -265,8 +267,7 @@
           NodeRevisionDescriptor rNrd = content.retrieve( sToken, rNrds );
           ResourceKind rRk = AbstractResourceKind.determineResourceKind( nsaToken, resourcePath, rNrd );
           if( !rRk.isSupportedMethod(req.getMethod()) ) {
  -            resp.setStatus(WebdavStatus.SC_FORBIDDEN);
  -            throw new WebdavException( WebdavStatus.SC_FORBIDDEN);
  +            throw new MethodNotAllowedException( rRk );
           }
           
           // Check for rRk = K_VERSION_CONTROLLED*
  @@ -624,8 +625,7 @@
                   new ViolatedPrecondition(C_WORKSPACE_LOCATION_OK, WebdavStatus.SC_FORBIDDEN), resourcePath);
           }
           if( !rRk.isSupportedMethod(req.getMethod()) ) {
  -            resp.setStatus( WebdavStatus.SC_BAD_REQUEST );
  -            throw new WebdavException( WebdavStatus.SC_BAD_REQUEST );
  +            throw new MethodNotAllowedException( rRk );
           }
           
           // Set initial ws properties
  @@ -743,8 +743,7 @@
               if( rRk instanceof CheckedOut ) {
                   throw new PreconditionViolationException(new ViolatedPrecondition(C_MUST_BE_CHECKED_IN, WebdavStatus.SC_CONFLICT), rNrds.getUri());
               }
  -            resp.setStatus(WebdavStatus.SC_FORBIDDEN);
  -            throw new WebdavException(WebdavStatus.SC_FORBIDDEN);
  +            throw new MethodNotAllowedException( rRk );
           }
           
           if( rRk instanceof CheckedInVersionControlled ) {
  @@ -837,8 +836,7 @@
               if( rRk instanceof CheckedOut ) {
                   throw new PreconditionViolationException(new ViolatedPrecondition(C_MUST_BE_CHECKED_IN, WebdavStatus.SC_CONFLICT), rNrds.getUri());
               }
  -            resp.setStatus(WebdavStatus.SC_FORBIDDEN);
  -            throw new WebdavException(WebdavStatus.SC_FORBIDDEN);
  +            throw new MethodNotAllowedException( rRk );
           }
           
           if( rRk instanceof Version ) {
  @@ -1006,8 +1004,7 @@
           }
           
           if( !rRk.isSupportedMethod(req.getMethod()) ) {
  -            resp.setStatus(WebdavStatus.SC_BAD_REQUEST);
  -            return;
  +            throw new MethodNotAllowedException( rRk );
           }
           
           // get checked-out VR
  @@ -1075,12 +1072,11 @@
           
           if( !rRk.isSupportedMethod(req.getMethod()) ) {
               // check precondition C_MUST_BE_CHECKED_OUT
  -            if( !(rRk instanceof CheckedOut) ) {
  +            if( (rRk instanceof CheckedInVersionControlled) ) {
                   throw new PreconditionViolationException(
                       new ViolatedPrecondition(C_MUST_BE_CHECKED_OUT, WebdavStatus.SC_CONFLICT), rUri);
               }
  -            resp.setStatus(WebdavStatus.SC_FORBIDDEN);
  -            throw new WebdavException(WebdavStatus.SC_FORBIDDEN);
  +            throw new MethodNotAllowedException( rRk );
           }
           
           if( rRk instanceof CheckedOutVersionControlled || rRk instanceof Working ) {
  
  
  
  1.18      +4 -2      jakarta-slide/src/share/org/apache/slide/util/resources/messages.properties
  
  Index: messages.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/share/org/apache/slide/util/resources/messages.properties,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- messages.properties	12 Aug 2002 12:55:03 -0000	1.17
  +++ messages.properties	14 Aug 2002 10:56:05 -0000	1.18
  @@ -269,6 +269,8 @@
   #
   # Messages produced by WebDAV
   #
  +org.apache.slide.webdav.method.MethodNotAllowedException=\
  +    Method not allowed on {0}
   org.apache.slide.webdav.method.AbstractWebdavMethod.preconditionViolation=\
       Precondition violation
   org.apache.slide.webdav.method.PropFindMethod.missingRootElement=\
  
  
  
  1.4       +10 -6     jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/AbstractWebdavMethod.java
  
  Index: AbstractWebdavMethod.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/AbstractWebdavMethod.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- AbstractWebdavMethod.java	12 Aug 2002 12:55:02 -0000	1.3
  +++ AbstractWebdavMethod.java	14 Aug 2002 10:56:06 -0000	1.4
  @@ -708,6 +708,8 @@
               return WebdavStatus.SC_LOCKED;
           } catch(WebdavException e) {
               return e.getStatusCode();
  +        } catch(MethodNotAllowedException e) {
  +            return WebdavStatus.SC_FORBIDDEN;
           } catch(SlideException e) {
   //            e.printStackTrace();
               return WebdavStatus.SC_INTERNAL_SERVER_ERROR;
  @@ -785,10 +787,12 @@
        */
       protected void sendError( int statusCode, Throwable t ) {
           printStackTrace( t, statusCode );
  +        String explanation = (t == null || t.getMessage() == null || "".equals(t.getMessage())
  +            ? Messages.format(t.getClass().getName(), (Object)null)
  +            : t.getMessage()
  +            );
           String statusText =
  -            WebdavStatus.getStatusText(statusCode)+": "+
  -            Messages.format( t.getClass().getName(), (Object)null )+" - "+
  -            t.getMessage();
  +            WebdavStatus.getStatusText(statusCode)+": "+explanation;
           try { resp.sendError( statusCode, statusText ); } catch( Throwable x ) {};
       }
       
  
  
  
  1.1                  jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/MethodNotAllowedException.java
  
  Index: MethodNotAllowedException.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/MethodNotAllowedException.java,v 1.1 2002/08/14 10:56:06 pnever Exp $
   * $Revision: 1.1 $
   * $Date: 2002/08/14 10:56:06 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Slide", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * [Additional notices, if required by prior licensing conditions]
   *
   */
  
  package org.apache.slide.webdav.method;
  
  import org.apache.slide.common.SlideException;
  import org.apache.slide.util.Messages;
  
  public class MethodNotAllowedException extends SlideException {
      
      /**
       * Default contructor.
       */
      public MethodNotAllowedException( Object rt ) {
          super( Messages.format(MethodNotAllowedException.class.getName(),rt), false ); // showTrace=false
      }
  }
  
  
  
  

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