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/04/04 17:44:36 UTC
cvs commit: jakarta-slide/src/share/org/apache/slide/macro ForbiddenException.java MacroImpl.java
juergen 01/04/04 08:44:36
Modified: src/webdav/server/org/apache/slide/webdav/method
CopyMethod.java MoveMethod.java
src/share/org/apache/slide/macro MacroImpl.java
Added: src/share/org/apache/slide/macro ForbiddenException.java
Log:
if a move or copy is executed with destination uri equals to source uri a response code of 403 is generated.
Revision Changes Path
1.9 +11 -8 jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/CopyMethod.java
Index: CopyMethod.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/CopyMethod.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- CopyMethod.java 2001/03/23 05:08:29 1.8
+++ CopyMethod.java 2001/04/04 15:44:32 1.9
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/CopyMethod.java,v 1.8 2001/03/23 05:08:29 remm Exp $
- * $Revision: 1.8 $
- * $Date: 2001/03/23 05:08:29 $
+ * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/CopyMethod.java,v 1.9 2001/04/04 15:44:32 juergen Exp $
+ * $Revision: 1.9 $
+ * $Date: 2001/04/04 15:44:32 $
*
* ====================================================================
*
@@ -121,7 +121,7 @@
*/
public CopyMethod(GenericServlet servlet, NamespaceAccessToken token,
HttpServletRequest req, HttpServletResponse resp) {
- super(servlet, token, req, resp);
+ super(servlet, token, req, resp);
}
@@ -276,6 +276,9 @@
} catch(AccessDeniedException e) {
generateStatusText(errorMessage, e.getObjectUri(),
WebdavStatus.SC_FORBIDDEN);
+ } catch(ForbiddenException e) {
+ generateStatusText(errorMessage, e.getObjectUri(),
+ WebdavStatus.SC_FORBIDDEN);
} catch(ObjectAlreadyExistsException e) {
generateStatusText(errorMessage, e.getObjectUri(),
WebdavStatus.SC_INTERNAL_SERVER_ERROR);
@@ -327,13 +330,13 @@
printer.writeElement("d", "status", XMLPrinter.CLOSING);
}
-
-
+
+
/**
* Returns true
*/
- protected boolean methodNeedsTransactionSupport() {
- return true;
+ protected boolean methodNeedsTransactionSupport() {
+ return true;
}
1.9 +6 -3 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.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- MoveMethod.java 2001/03/23 05:08:30 1.8
+++ MoveMethod.java 2001/04/04 15:44:32 1.9
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/MoveMethod.java,v 1.8 2001/03/23 05:08:30 remm Exp $
- * $Revision: 1.8 $
- * $Date: 2001/03/23 05:08:30 $
+ * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/MoveMethod.java,v 1.9 2001/04/04 15:44:32 juergen Exp $
+ * $Revision: 1.9 $
+ * $Date: 2001/04/04 15:44:32 $
*
* ====================================================================
*
@@ -276,6 +276,9 @@
generateStatusText(errorMessage, e.getObjectUri(),
WebdavStatus.SC_INTERNAL_SERVER_ERROR);
} catch(AccessDeniedException e) {
+ generateStatusText(errorMessage, e.getObjectUri(),
+ WebdavStatus.SC_FORBIDDEN);
+ } catch(ForbiddenException e) {
generateStatusText(errorMessage, e.getObjectUri(),
WebdavStatus.SC_FORBIDDEN);
} catch(ObjectAlreadyExistsException e) {
1.13 +12 -4 jakarta-slide/src/share/org/apache/slide/macro/MacroImpl.java
Index: MacroImpl.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/share/org/apache/slide/macro/MacroImpl.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- MacroImpl.java 2001/04/04 13:56:33 1.12
+++ MacroImpl.java 2001/04/04 15:44:35 1.13
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/macro/MacroImpl.java,v 1.12 2001/04/04 13:56:33 juergen Exp $
- * $Revision: 1.12 $
- * $Date: 2001/04/04 13:56:33 $
+ * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/macro/MacroImpl.java,v 1.13 2001/04/04 15:44:35 juergen Exp $
+ * $Revision: 1.13 $
+ * $Date: 2001/04/04 15:44:35 $
*
* ====================================================================
*
@@ -77,7 +77,7 @@
* Macro helper class.
*
* @author <a href="mailto:remm@apache.org">Remy Maucherat</a>
- * @version $Revision: 1.12 $
+ * @version $Revision: 1.13 $
*/
public final class MacroImpl implements Macro {
@@ -179,6 +179,14 @@
Domain.debug("Copy " + sourceUri + " to " + destinationUri);
+ // handle the case that source and destination are identical
+ if (sourceUri.equals(destinationUri)) {
+ CopyMacroException e = new CopyMacroException("Copy failed");
+ e.addException(new ForbiddenException(sourceUri));
+ throw e;
+ }
+
+
if (parameters.isOverwrite()) {
try {
// We make sure the object we want to overwrite exists
@@ -298,7 +306,7 @@
CopyMacroException e) {
Domain.debug("Copy object : from " + sourceUri + " to "
- + destinationUri);
+ + destinationUri);
try {
@@ -408,7 +416,7 @@
*/
private void deleteObject(SlideToken token, String targetUri,
MacroException e) {
-
+
Domain.debug("Delete object : " + targetUri);
try {
@@ -448,10 +456,10 @@
contentHelper.remove(token, targetUri,
revisionDescriptors.getInitialRevision());
}
-
+
// remove the NodeRevisionDescriptors object
contentHelper.remove(token, revisionDescriptors);
-
+
}
// Removing object.
1.1 jakarta-slide/src/share/org/apache/slide/macro/ForbiddenException.java
Index: ForbiddenException.java
===================================================================
/*
* $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/macro/ForbiddenException.java,v 1.1 2001/04/04 15:44:35 juergen Exp $
* $Revision: 1.1 $
* $Date: 2001/04/04 15:44:35 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 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", "Tomcat", 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.macro;
import org.apache.slide.util.Messages;
import org.apache.slide.common.SlideException;
/**
* The copy/move operation is forbidden, e.g. source and destination uri are identical.
*
* @author <a href="mailto:remm@apache.org">Remy Maucherat</a>
* @version $Revision: 1.1 $
*/
public class ForbiddenException extends SlideException {
// ----------------------------------------------------------- Constructors
/**
* Constructor.
*
* @param objectUri Uri of the forbidden operation
*/
public ForbiddenException(String objectUri) {
super(Messages.format(ForbiddenException.class.getName(), objectUri), false);
this.objectUri = objectUri;
}
// ----------------------------------------------------- Instance Variables
/**
* Object uri.
*/
private String objectUri;
// ------------------------------------------------------------- Properties
/**
* Object Uri accessor.
*
* @return String object uri
*/
public String getObjectUri() {
return objectUri;
}
}