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 2001/07/17 15:47:21 UTC

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

juergen     01/07/17 06:47:21

  Modified:    src/webdav/server/org/apache/slide/webdav/method
                        MoveMethod.java
  Log:
  1) added more response code handling
  2) in case of an error throw an exception to rollback the transaction in the calling layer
  
  Revision  Changes    Path
  1.13      +22 -18    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.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- MoveMethod.java	2001/07/06 04:29:32	1.12
  +++ MoveMethod.java	2001/07/17 13:47:20	1.13
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/MoveMethod.java,v 1.12 2001/07/06 04:29:32 msmith Exp $
  - * $Revision: 1.12 $
  - * $Date: 2001/07/06 04:29:32 $
  + * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/MoveMethod.java,v 1.13 2001/07/17 13:47:20 juergen Exp $
  + * $Revision: 1.13 $
  + * $Date: 2001/07/17 13:47:20 $
    *
    * ====================================================================
    *
  @@ -206,7 +206,7 @@
           throws WebdavException {
           
           MacroParameters macroParameters = null;
  -        boolean isCollection = isCollection(sourceUri); 
  +        boolean isCollection = isCollection(sourceUri);
           
           if (overwrite) {
               macroParameters = Macro.RECURSIVE_OVERWRITE_PARAMETERS;
  @@ -222,7 +222,7 @@
                   resp.setStatus(WebdavStatus.SC_CREATED);
               }
           } catch (MacroException e) {
  -	        if(isCollection) {
  +            if(isCollection) {
                   String errorMessage = generateErrorMessage(e);
                   // Write it on the servlet writer
                   resp.setStatus(WebdavStatus.SC_MULTI_STATUS);
  @@ -231,17 +231,19 @@
                   } catch(IOException ex) {
                       // Critical error ... Servlet container is dead or something
                       ex.printStackTrace();
  -                    throw new WebdavException
  -                        (WebdavStatus.SC_INTERNAL_SERVER_ERROR);
  +                    throw new WebdavException(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
                   }
               } else {
                   // Returning 207 on non-collection requests is generally
  -                // considered bad. So let's not do it, since this way 
  +                // considered bad. So let's not do it, since this way
                   // makes clients generally behave better.
  -                Enumeration nestedExceptions =
  -                    e.enumerateExceptions();
  -				setErrorCode(resp, 
  -						(SlideException)nestedExceptions.nextElement());
  +                Enumeration nestedExceptions = e.enumerateExceptions();
  +                setErrorCode(resp, (SlideException)nestedExceptions.nextElement());
  +            //
  +            // make sure the transaction is aborted
  +            // throw any WebDAV exception to indicate the transaction wants to be aborted
  +            //
  +            throw new WebdavException(WebdavStatus.SC_ACCEPTED, false);
               }
           }
       }
  @@ -347,11 +349,11 @@
       protected boolean methodNeedsTransactionSupport() {
           return true;
       }
  -	
  -	/**
  -	 * Set return status based on exception type.
  -	 */
  -	private void setErrorCode(HttpServletResponse resp, SlideException ex) {
  +    
  +    /**
  +     * Set return status based on exception type.
  +     */
  +    private void setErrorCode(HttpServletResponse resp, SlideException ex) {
           try {
               throw ex;
           } catch(ObjectNotFoundException e) {
  @@ -368,10 +370,12 @@
               resp.setStatus(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
           } catch(ObjectLockedException e) {
               resp.setStatus(WebdavStatus.SC_LOCKED);
  +        } catch(ForbiddenException e) {
  +            resp.setStatus(WebdavStatus.SC_FORBIDDEN);
           } catch(SlideException e) {
               resp.setStatus(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
           }
  -	}
  +    }
      
   }