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/05/07 09:31:03 UTC
cvs commit: jakarta-slide/src/share/org/apache/slide/macro Macro.java MacroImpl.java
juergen 02/05/07 00:31:02
Modified: src/share/org/apache/slide/macro Macro.java MacroImpl.java
Log:
Now also a DeleteTargetRedirector and/or a CopyRouteRedirector may be passed to the Macro helper which can be used to redirect the source or target URI. This was needed to implement the Label feature in the WebDAV layer.
(ralf)
Revision Changes Path
1.11 +50 -11 jakarta-slide/src/share/org/apache/slide/macro/Macro.java
Index: Macro.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/share/org/apache/slide/macro/Macro.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- Macro.java 25 Apr 2002 21:30:14 -0000 1.10
+++ Macro.java 7 May 2002 07:31:02 -0000 1.11
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/macro/Macro.java,v 1.10 2002/04/25 21:30:14 jericho Exp $
- * $Revision: 1.10 $
- * $Date: 2002/04/25 21:30:14 $
+ * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/macro/Macro.java,v 1.11 2002/05/07 07:31:02 juergen Exp $
+ * $Revision: 1.11 $
+ * $Date: 2002/05/07 07:31:02 $
*
* ====================================================================
*
@@ -76,7 +76,7 @@
* Macro helper class.
*
* @author <a href="mailto:remm@apache.org">Remy Maucherat</a>
- * @version $Revision: 1.10 $
+ * @version $Revision: 1.11 $
*/
public interface Macro {
@@ -119,9 +119,16 @@
* @param token Credentials token
* @param sourceUri Uri of the source
* @param destinationUri Uri of the destination
+ * @param copyRedirector the CopyRoutRedirector may be used to redirect
+ * the source and/or destination URI of the
+ * <code>copy</code> operation.
+ * (May be <code>null</code>.)
* @param copyListener the CopyListener that will be notified
* before and after copying a resource.
* (May be <code>null</code>)
+ * @param deleteRedirector the DeleteTargetRedirector may be used to redirect
+ * the <code>delete</code> operation to a different
+ * target. (May be <code>null</code>.)
* @param deleteListener the DeleteListener that will be notified
* before and after deleting a destination
* that will be overwritten by the copy.
@@ -129,7 +136,8 @@
* @exception CopyMacroException Generic Slide exception
*/
void copy(SlideToken token, String sourceUri,
- String destinationUri, CopyListener copyListener, DeleteListener deleteListener)
+ String destinationUri, CopyRouteRedirector copyRedirector, CopyListener copyListener,
+ DeleteTargetRedirector deleteRedirector, DeleteListener deleteListener)
throws CopyMacroException, DeleteMacroException;
@@ -153,9 +161,16 @@
* @param sourceUri Uri of the source
* @param destinationUri Uri of the destination
* @param parameters Macro parameters
+ * @param copyRedirector the CopyRoutRedirector may be used to redirect
+ * the source and/or destination URI of the
+ * <code>copy</code> operation.
+ * (May be <code>null</code>.)
* @param copyListener the CopyListener that will be notified
* before and after copying a resource.
* (May be <code>null</code>)
+ * @param deleteRedirector the DeleteTargetRedirector may be used to redirect
+ * the <code>delete</code> operation to a different
+ * target. (May be <code>null</code>.)
* @param deleteListener the DeleteListener that will be notified
* before and after deleting a destination
* that will be overwritten by the copy.
@@ -164,7 +179,8 @@
*/
void copy(SlideToken token, String sourceUri,
String destinationUri, MacroParameters parameters,
- CopyListener copyListener, DeleteListener deleteListener)
+ CopyRouteRedirector copyRedirector, CopyListener copyListener,
+ DeleteTargetRedirector deleteRedirector, DeleteListener deleteListener)
throws CopyMacroException, DeleteMacroException;
@@ -187,9 +203,16 @@
* @param token Credentials token
* @param sourceUri Uri of the source
* @param destinationUri Uri of the destination
+ * @param copyRedirector the CopyRoutRedirector may be used to redirect
+ * the source and/or destination URI of the
+ * <code>copy</code> operation.
+ * (May be <code>null</code>.)
* @param copyListener the CopyListener that will be notified
* before and after copying a resource.
* (May be <code>null</code>)
+ * @param deleteRedirector the DeleteTargetRedirector may be used to redirect
+ * the <code>delete</code> operation to a different
+ * target. (May be <code>null</code>.)
* @param deleteListener the DeleteListener that will be notified
* before and after deleting a resource.
* (May be <code>null</code>)
@@ -197,7 +220,8 @@
* @exception DeleteMacroException Exception occured during deletion
*/
void move(SlideToken token, String sourceUri,
- String destinationUri, CopyListener copyListener, DeleteListener deleteListener)
+ String destinationUri, CopyRouteRedirector copyRedirector, CopyListener copyListener,
+ DeleteTargetRedirector deleteRedirector, DeleteListener deleteListener)
throws CopyMacroException, DeleteMacroException;
@@ -222,9 +246,16 @@
* @param sourceUri Uri of the source
* @param destinationUri Uri of the destination
* @param parameters Macro parameters
+ * @param copyRedirector the CopyRoutRedirector may be used to redirect
+ * the source and/or destination URI of the
+ * <code>copy</code> operation.
+ * (May be <code>null</code>.)
* @param copyListener the CopyListener that will be notified
* before and after copying a resource.
* (May be <code>null</code>)
+ * @param deleteRedirector the DeleteTargetRedirector may be used to redirect
+ * the <code>delete</code> operation to a different
+ * target. (May be <code>null</code>.)
* @param deleteListener the DeleteListener that will be notified
* before and after deleting a resource.
* (May be <code>null</code>)
@@ -233,7 +264,8 @@
*/
void move(SlideToken token, String sourceUri,
String destinationUri, MacroParameters parameters,
- CopyListener copyListener, DeleteListener deleteListener)
+ CopyRouteRedirector copyRedirector, CopyListener copyListener,
+ DeleteTargetRedirector deleteRedirector, DeleteListener deleteListener)
throws CopyMacroException, DeleteMacroException;
@@ -252,12 +284,16 @@
*
* @param token Credentials token
* @param targetUri Uri of the object to delete
+ * @param deleteRedirector the DeleteTargetRedirector may be used to redirect
+ * the <code>delete</code> operation to a different
+ * target. (May be <code>null</code>.)
* @param deleteListener the DeleteListener that will be notified
* before and after deleting a resource.
* (May be <code>null</code>)
* @exception DeleteMacroException Generic Slide exception
*/
- void delete(SlideToken token, String targetUri, DeleteListener deleteListener)
+ void delete(SlideToken token, String targetUri,
+ DeleteTargetRedirector deleteRedirector, DeleteListener deleteListener)
throws DeleteMacroException;
@@ -282,13 +318,16 @@
* @param targetUri Uri of the source
* @param parameters Macro parameters, not used right now,
* so it can be null
+ * @param deleteRedirector the DeleteTargetRedirector may be used to redirect
+ * the <code>delete</code> operation to a different
+ * target. (May be <code>null</code>.)
* @param deleteListener the DeleteListener that will be notified
* before and after deleting a resource.
* (May be <code>null</code>)
* @exception DeleteMacroException Generic Slide exception
*/
- void delete(SlideToken token, String targetUri,
- MacroParameters parameters, DeleteListener deleteListener)
+ void delete(SlideToken token, String targetUri, MacroParameters parameters,
+ DeleteTargetRedirector deleteRedirector, DeleteListener deleteListener)
throws DeleteMacroException;
}
1.27 +108 -42 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.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- MacroImpl.java 25 Apr 2002 21:30:14 -0000 1.26
+++ MacroImpl.java 7 May 2002 07:31:02 -0000 1.27
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/macro/MacroImpl.java,v 1.26 2002/04/25 21:30:14 jericho Exp $
- * $Revision: 1.26 $
- * $Date: 2002/04/25 21:30:14 $
+ * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/macro/MacroImpl.java,v 1.27 2002/05/07 07:31:02 juergen Exp $
+ * $Revision: 1.27 $
+ * $Date: 2002/05/07 07:31:02 $
*
* ====================================================================
*
@@ -72,12 +72,13 @@
import org.apache.slide.security.*;
import org.apache.slide.content.*;
import org.apache.slide.lock.*;
+import org.apache.slide.macro.CopyRouteRedirector.CopyRoute;
/**
* Macro helper class.
*
* @author <a href="mailto:remm@apache.org">Remy Maucherat</a>
- * @version $Revision: 1.26 $
+ * @version $Revision: 1.27 $
*/
public final class MacroImpl implements Macro {
@@ -159,7 +160,9 @@
public void copy(SlideToken token, String sourceUri,
String destinationUri)
throws CopyMacroException, DeleteMacroException {
- copy(token, sourceUri, destinationUri, (CopyListener)null, (DeleteListener)null);
+ copy(token, sourceUri, destinationUri,
+ (CopyRouteRedirector)null, (CopyListener)null,
+ (DeleteTargetRedirector)null, (DeleteListener)null);
}
/**
@@ -168,9 +171,16 @@
* @param token Credentials token
* @param sourceUri Uri of the source
* @param destinationUri Uri of the destination
+ * @param copyRedirector the CopyRoutRedirector may be used to redirect
+ * the source and/or destination URI of the
+ * <code>copy</code> operation.
+ * (May be <code>null</code>.)
* @param copyListener the CopyListener that will be notified
* before and after copying a resource.
* (May be <code>null</code>)
+ * @param deleteRedirector the DeleteTargetRedirector may be used to redirect
+ * the <code>delete</code> operation to a different
+ * target. (May be <code>null</code>.)
* @param deleteListener the DeleteListener that will be notified
* before and after deleting a destination
* that will be overwritten by the copy.
@@ -178,12 +188,13 @@
* @exception CopyMacroException Generic Slide exception
*/
public void copy(SlideToken token, String sourceUri,
- String destinationUri,
- CopyListener copyListener, DeleteListener deleteListener)
+ String destinationUri, CopyRouteRedirector copyRedirector, CopyListener copyListener,
+ DeleteTargetRedirector deleteRedirector, DeleteListener deleteListener)
throws CopyMacroException, DeleteMacroException {
this.copy(token, sourceUri, destinationUri,
- RECURSIVE_OVERWRITE_PARAMETERS, copyListener, deleteListener);
+ RECURSIVE_OVERWRITE_PARAMETERS, copyRedirector, copyListener,
+ deleteRedirector, deleteListener);
}
@@ -199,7 +210,7 @@
public void copy(SlideToken token, String sourceUri,
String destinationUri, MacroParameters parameters)
throws CopyMacroException, DeleteMacroException {
- copy(token, sourceUri, destinationUri, parameters, null, null);
+ copy(token, sourceUri, destinationUri, parameters, null, null, null, null);
}
/**
@@ -209,9 +220,16 @@
* @param sourceUri Uri of the source
* @param destinationUri Uri of the destination
* @param parameters Macro parameters
+ * @param copyRedirector the CopyRoutRedirector may be used to redirect
+ * the source and/or destination URI of the
+ * <code>copy</code> operation.
+ * (May be <code>null</code>.)
* @param copyListener the CopyListener that will be notified
* before and after copying a resource.
* (May be <code>null</code>)
+ * @param deleteRedirector the DeleteTargetRedirector may be used to redirect
+ * the <code>delete</code> operation to a different
+ * target. (May be <code>null</code>.)
* @param deleteListener the DeleteListener that will be notified
* before and after deleting a destination
* that will be overwritten by the copy.
@@ -220,7 +238,8 @@
*/
public void copy(SlideToken token, String sourceUri,
String destinationUri, MacroParameters parameters,
- CopyListener copyListener, DeleteListener deleteListener)
+ CopyRouteRedirector copyRedirector, CopyListener copyListener,
+ DeleteTargetRedirector deleteRedirector, DeleteListener deleteListener)
throws CopyMacroException, DeleteMacroException {
Domain.debug("Copy " + sourceUri + " to " + destinationUri);
@@ -237,7 +256,7 @@
try {
// We make sure the object we want to overwrite exists
structureHelper.retrieve(token, destinationUri);
- delete(token, destinationUri, deleteListener);
+ delete(token, destinationUri, deleteRedirector, deleteListener);
} catch(ObjectNotFoundException e) {
// Silent catch, the target doesn't exist
} catch(DeleteMacroException s) {
@@ -252,7 +271,7 @@
// Now performing the actual copy
CopyMacroException e = new CopyMacroException("Copy failed");
- copyObject(token, sourceUri, destinationUri, parameters, e, copyListener);
+ copyObject(token, sourceUri, destinationUri, parameters, e, copyRedirector, copyListener);
// If there were errors, we throw the nested exception
if (!e.isEmpty()) {
@@ -274,7 +293,9 @@
public void move(SlideToken token, String sourceUri,
String destinationUri)
throws CopyMacroException, DeleteMacroException {
- move(token, sourceUri, destinationUri, (CopyListener)null, (DeleteListener)null);
+ move(token, sourceUri, destinationUri,
+ (CopyRouteRedirector)null, (CopyListener)null,
+ (DeleteTargetRedirector)null, (DeleteListener)null);
}
/**
@@ -283,9 +304,16 @@
* @param token Credentials token
* @param sourceUri Uri of the source
* @param destinationUri Uri of the destination
+ * @param copyRedirector the CopyRoutRedirector may be used to redirect
+ * the source and/or destination URI of the
+ * <code>copy</code> operation.
+ * (May be <code>null</code>.)
* @param copyListener the CopyListener that will be notified
* before and after copying a resource.
* (May be <code>null</code>)
+ * @param deleteRedirector the DeleteTargetRedirector may be used to redirect
+ * the <code>delete</code> operation to a different
+ * target. (May be <code>null</code>.)
* @param deleteListener the DeleteListener that will be notified
* before and after deleting a resource.
* (May be <code>null</code>)
@@ -293,11 +321,13 @@
* @exception DeleteMacroException Exception occured during deletion
*/
public void move(SlideToken token, String sourceUri,
- String destinationUri, CopyListener copyListener, DeleteListener deleteListener)
+ String destinationUri, CopyRouteRedirector copyRedirector, CopyListener copyListener,
+ DeleteTargetRedirector deleteRedirector, DeleteListener deleteListener)
throws CopyMacroException, DeleteMacroException {
move(token, sourceUri, destinationUri,
- RECURSIVE_OVERWRITE_PARAMETERS, copyListener, deleteListener);
+ RECURSIVE_OVERWRITE_PARAMETERS,
+ copyRedirector, copyListener, deleteRedirector, deleteListener);
}
@@ -314,7 +344,7 @@
public void move(SlideToken token, String sourceUri,
String destinationUri, MacroParameters parameters)
throws CopyMacroException, DeleteMacroException {
- move(token, sourceUri, destinationUri, parameters, null, null);
+ move(token, sourceUri, destinationUri, parameters, null, null, null, null);
}
/**
@@ -324,9 +354,16 @@
* @param sourceUri Uri of the source
* @param destinationUri Uri of the destination
* @param parameters Macro parameters
+ * @param copyRedirector the CopyRoutRedirector may be used to redirect
+ * the source and/or destination URI of the
+ * <code>copy</code> operation.
+ * (May be <code>null</code>.)
* @param copyListener the CopyListener that will be notified
* before and after copying a resource.
* (May be <code>null</code>)
+ * @param deleteRedirector the DeleteTargetRedirector may be used to redirect
+ * the <code>delete</code> operation to a different
+ * target. (May be <code>null</code>.)
* @param deleteListener the DeleteListener that will be notified
* before and after deleting a resource.
* (May be <code>null</code>)
@@ -335,11 +372,13 @@
*/
public void move(SlideToken token, String sourceUri,
String destinationUri, MacroParameters parameters,
- CopyListener copyListener, DeleteListener deleteListener)
+ CopyRouteRedirector copyRedirector, CopyListener copyListener,
+ DeleteTargetRedirector deleteRedirector, DeleteListener deleteListener)
throws CopyMacroException, DeleteMacroException {
- copy(token, sourceUri, destinationUri, parameters, copyListener, deleteListener);
- delete(token, sourceUri, parameters, deleteListener);
+ copy(token, sourceUri, destinationUri, parameters,
+ copyRedirector, copyListener, deleteRedirector, deleteListener);
+ delete(token, sourceUri, parameters, deleteRedirector, deleteListener);
}
@@ -352,7 +391,7 @@
*/
public void delete(SlideToken token, String targetUri)
throws DeleteMacroException {
- delete(token, targetUri, (DeleteListener)null);
+ delete(token, targetUri, (DeleteTargetRedirector)null, (DeleteListener)null);
}
/**
@@ -360,14 +399,18 @@
*
* @param token Credentials token
* @param targetUri Uri of the object to delete
+ * @param deleteRedirector the DeleteTargetRedirector may be used to redirect
+ * the <code>delete</code> operation to a different
+ * target. (May be <code>null</code>.)
* @param deleteListener the DeleteListener that will be notified
* before and after deleting a resource.
* (May be <code>null</code>)
* @exception DeleteMacroException Generic Slide exception
*/
- public void delete(SlideToken token, String targetUri, DeleteListener deleteListener)
+ public void delete(SlideToken token, String targetUri,
+ DeleteTargetRedirector deleteRedirector, DeleteListener deleteListener)
throws DeleteMacroException {
- delete(token, targetUri, RECURSIVE_OVERWRITE_PARAMETERS, deleteListener);
+ delete(token, targetUri, RECURSIVE_OVERWRITE_PARAMETERS, deleteRedirector, deleteListener);
}
@@ -383,7 +426,7 @@
public void delete(SlideToken token, String targetUri,
MacroParameters parameters)
throws DeleteMacroException {
- delete(token, targetUri, parameters, null);
+ delete(token, targetUri, parameters, null, null);
}
/**
@@ -393,20 +436,23 @@
* @param targetUri Uri of the source
* @param parameters Macro parameters, not used right now,
* so it can be null
+ * @param deleteRedirector the DeleteTargetRedirector may be used to redirect
+ * the <code>delete</code> operation to a different
+ * target. (May be <code>null</code>.)
* @param deleteListener the DeleteListener that will be notified
* before and after deleting a resource.
* (May be <code>null</code>)
* @exception DeleteMacroException Generic Slide exception
*/
- public void delete(SlideToken token, String targetUri,
- MacroParameters parameters, DeleteListener deleteListener)
+ public void delete(SlideToken token, String targetUri, MacroParameters parameters,
+ DeleteTargetRedirector deleteRedirector, DeleteListener deleteListener)
throws DeleteMacroException {
Domain.debug("Delete " + targetUri);
DeleteMacroException e = new DeleteMacroException("Delete failed");
- deleteObject(token, targetUri, e, deleteListener);
+ deleteObject(token, targetUri, e, deleteRedirector, deleteListener);
// If there were errors, we throw the nested exception
if (!e.isEmpty()) {
@@ -426,25 +472,37 @@
* @param sourceUri Uri of the source
* @param destinationUri Uri of the destination
* @param parameters Macro parameters
+ * @param copyRedirector the CopyRoutRedirector may be used to redirect
+ * the source and/or destination URI of the
+ * <code>copy</code> operation.
+ * (May be <code>null</code>.)
* @param copyListener the CopyListener that will be notified
* before and after copying a resource.
* (May be <code>null</code>)
* @param CopyMacroException Exception occured during copy
*/
private void copyObject(SlideToken token, String sourceUri,
- String destinationUri, MacroParameters parameters,
- CopyMacroException e, CopyListener copyListener) {
+ String destinationUri, MacroParameters parameters, CopyMacroException e,
+ CopyRouteRedirector copyRedirector, CopyListener copyListener) {
Domain.debug("Copy object : from " + sourceUri + " to "
+ destinationUri);
try {
- Vector childrenListVector = new Vector();
-
- // Copying structure
+ // Remember children of orginal source
ObjectNode object =
structureHelper.retrieve(token, sourceUri, false);
+ Enumeration childrenList = object.enumerateChildren();
+
+ // now let the client redirect
+ if (copyRedirector != null) {
+ CopyRoute copyRoute = new CopyRoute(sourceUri, destinationUri);
+ copyRoute = copyRedirector.getRedirectedCopyRoute(copyRoute);
+ sourceUri = copyRoute.getSourceUri();
+ destinationUri = copyRoute.getDestinationUri();
+ object = structureHelper.retrieve(token, sourceUri, false);
+ }
// notify CopyListener
if (copyListener != null) {
@@ -517,12 +575,6 @@
}
-
- // notify CopyListener
- if (copyListener != null) {
- copyListener.afterCopy(sourceUri, destinationUri);
- }
-
// TODO : Parse stack
// Algorithm :
// - While Stack is not empty
@@ -531,15 +583,20 @@
// based of the old revision
// - Add the successor to the stack
+
+ // notify CopyListener
+ if (copyListener != null) {
+ copyListener.afterCopy(sourceUri, destinationUri);
+ }
+
// We copy each of this object's children
- Enumeration childrenList = object.enumerateChildren();
while(childrenList.hasMoreElements()) {
String childUri = (String) childrenList.nextElement();
String childDestinationUri = destinationUri + childUri
.substring(object.getUri().length());
copyObject(token, childUri, childDestinationUri,
- parameters, e, copyListener);
+ parameters, e, copyRedirector, copyListener);
}
} catch(SlideException ex) {
@@ -559,12 +616,15 @@
* @param parameters Macro parameters, not used right now, so it can
* be null
* @param e Nested exception
+ * @param deleteRedirector the DeleteTargetRedirector may be used to redirect
+ * the <code>delete</code> operation to a different
+ * target. (May be <code>null</code>.)
* @param deleteListener the DeleteListener that will be notified
* before and after deleting a resource.
* (May be <code>null</code>)
*/
- private void deleteObject(SlideToken token, String targetUri,
- MacroException e, DeleteListener deleteListener) {
+ private void deleteObject(SlideToken token, String targetUri, MacroException e,
+ DeleteTargetRedirector deleteRedirector, DeleteListener deleteListener) {
Domain.debug("Delete object : " + targetUri);
@@ -577,8 +637,14 @@
if (currentObject.hasChildren()) {
Enumeration children = currentObject.enumerateChildren();
while (children.hasMoreElements()) {
- deleteObject(token, (String) children.nextElement(), e, deleteListener);
+ deleteObject(token, (String) children.nextElement(), e, deleteRedirector, deleteListener);
}
+ }
+
+ // now let the client redirect
+ if (deleteRedirector != null) {
+ targetUri = deleteRedirector.getRedirectedTargetUri(targetUri);
+ currentObject = structureHelper.retrieve(token, targetUri, false);
}
// notify DeleteListener
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>