juergen 02/04/03 22:25:45
Modified: src/share/org/apache/slide/macro Macro.java MacroImpl.java
Log:
Added copy() method signatures that allow to specify a CopyListener.
Added move() method signatures that allow to specify a Delete- and CopyListener.
(ralf)
Revision Changes Path
1.8 +76 -4 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.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- Macro.java 3 Apr 2002 12:00:07 -0000 1.7
+++ Macro.java 4 Apr 2002 06:25:45 -0000 1.8
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/macro/Macro.java,v
1.7 2002/04/03 12:00:07 juergen Exp $
- * $Revision: 1.7 $
- * $Date: 2002/04/03 12:00:07 $
+ * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/macro/Macro.java,v
1.8 2002/04/04 06:25:45 juergen Exp $
+ * $Revision: 1.8 $
+ * $Date: 2002/04/04 06:25:45 $
*
* ====================================================================
*
@@ -76,7 +76,7 @@
* Macro helper class.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Remy Maucherat</a>
- * @version $Revision: 1.7 $
+ * @version $Revision: 1.8 $
*/
public interface Macro {
@@ -113,6 +113,21 @@
String destinationUri)
throws CopyMacroException, DeleteMacroException;
+ /**
+ * Recursive copy with overwrite macro.
+ *
+ * @param token Credentials token
+ * @param sourceUri Uri of the source
+ * @param destinationUri Uri of the destination
+ * @param copyListener the CopyListener that will be notified
+ * before and after copying a resource.
+ * (May be <code>null</code>)
+ * @exception CopyMacroException Generic Slide exception
+ */
+ void copy(SlideToken token, String sourceUri,
+ String destinationUri, CopyListener copyListener)
+ throws CopyMacroException, DeleteMacroException;
+
/**
* Copy macro.
@@ -127,6 +142,23 @@
String destinationUri, MacroParameters parameters)
throws CopyMacroException, DeleteMacroException;
+ /**
+ * Copy macro.
+ *
+ * @param token Credentials token
+ * @param sourceUri Uri of the source
+ * @param destinationUri Uri of the destination
+ * @param parameters Macro parameters
+ * @param copyListener the CopyListener that will be notified
+ * before and after copying a resource.
+ * (May be <code>null</code>)
+ * @exception CopyMacroException Generic Slide exception
+ */
+ void copy(SlideToken token, String sourceUri,
+ String destinationUri, MacroParameters parameters,
+ CopyListener copyListener)
+ throws CopyMacroException, DeleteMacroException;
+
/**
* Recursive move with overwrite macro.
@@ -141,6 +173,25 @@
String destinationUri)
throws CopyMacroException, DeleteMacroException;
+ /**
+ * Recursive move with overwrite macro.
+ *
+ * @param token Credentials token
+ * @param sourceUri Uri of the source
+ * @param destinationUri Uri of the destination
+ * @param copyListener the CopyListener that will be notified
+ * before and after copying a resource.
+ * (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 CopyMacroException Exception occured during copy
+ * @exception DeleteMacroException Exception occured during deletion
+ */
+ void move(SlideToken token, String sourceUri,
+ String destinationUri, CopyListener copyListener, DeleteListener
deleteListener)
+ throws CopyMacroException, DeleteMacroException;
+
/**
* Move macro.
@@ -154,6 +205,27 @@
*/
void move(SlideToken token, String sourceUri,
String destinationUri, MacroParameters parameters)
+ throws CopyMacroException, DeleteMacroException;
+
+ /**
+ * Move macro.
+ *
+ * @param token Credentials token
+ * @param sourceUri Uri of the source
+ * @param destinationUri Uri of the destination
+ * @param parameters Macro parameters
+ * @param copyListener the CopyListener that will be notified
+ * before and after copying a resource.
+ * (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 CopyMacroException Exception occured during copy
+ * @exception DeleteMacroException Exception occured during deletion
+ */
+ void move(SlideToken token, String sourceUri,
+ String destinationUri, MacroParameters parameters,
+ CopyListener copyListener, DeleteListener deleteListener)
throws CopyMacroException, DeleteMacroException;
1.24 +109 -11 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.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- MacroImpl.java 3 Apr 2002 12:00:07 -0000 1.23
+++ MacroImpl.java 4 Apr 2002 06:25:45 -0000 1.24
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-slide/src/share/org/apache/slide/macro/MacroImpl.java,v 1.23
2002/04/03 12:00:07 juergen Exp $
- * $Revision: 1.23 $
- * $Date: 2002/04/03 12:00:07 $
+ * $Header:
/home/cvs/jakarta-slide/src/share/org/apache/slide/macro/MacroImpl.java,v 1.24
2002/04/04 06:25:45 juergen Exp $
+ * $Revision: 1.24 $
+ * $Date: 2002/04/04 06:25:45 $
*
* ====================================================================
*
@@ -77,7 +77,7 @@
* Macro helper class.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Remy Maucherat</a>
- * @version $Revision: 1.23 $
+ * @version $Revision: 1.24 $
*/
public final class MacroImpl implements Macro {
@@ -159,8 +159,26 @@
public void copy(SlideToken token, String sourceUri,
String destinationUri)
throws CopyMacroException, DeleteMacroException {
+ copy(token, sourceUri, destinationUri, (CopyListener)null);
+ }
+
+ /**
+ * Recursive copy with overwrite macro.
+ *
+ * @param token Credentials token
+ * @param sourceUri Uri of the source
+ * @param destinationUri Uri of the destination
+ * @param copyListener the CopyListener that will be notified
+ * before and after copying a resource.
+ * (May be <code>null</code>)
+ * @exception CopyMacroException Generic Slide exception
+ */
+ public void copy(SlideToken token, String sourceUri,
+ String destinationUri, CopyListener copyListener)
+ throws CopyMacroException, DeleteMacroException {
+
this.copy(token, sourceUri, destinationUri,
- RECURSIVE_OVERWRITE_PARAMETERS);
+ RECURSIVE_OVERWRITE_PARAMETERS, copyListener);
}
@@ -176,6 +194,25 @@
public void copy(SlideToken token, String sourceUri,
String destinationUri, MacroParameters parameters)
throws CopyMacroException, DeleteMacroException {
+ copy(token, sourceUri, destinationUri, parameters, null);
+ }
+
+ /**
+ * Copy macro.
+ *
+ * @param token Credentials token
+ * @param sourceUri Uri of the source
+ * @param destinationUri Uri of the destination
+ * @param parameters Macro parameters
+ * @param copyListener the CopyListener that will be notified
+ * before and after copying a resource.
+ * (May be <code>null</code>)
+ * @exception CopyMacroException Generic Slide exception
+ */
+ public void copy(SlideToken token, String sourceUri,
+ String destinationUri, MacroParameters parameters,
+ CopyListener copyListener)
+ throws CopyMacroException, DeleteMacroException {
Domain.debug("Copy " + sourceUri + " to " + destinationUri);
@@ -206,7 +243,7 @@
// Now performing the actual copy
CopyMacroException e = new CopyMacroException("Copy failed");
- copyObject(token, sourceUri, destinationUri, parameters, e);
+ copyObject(token, sourceUri, destinationUri, parameters, e, copyListener);
// If there were errors, we throw the nested exception
if (!e.isEmpty()) {
@@ -228,8 +265,30 @@
public void move(SlideToken token, String sourceUri,
String destinationUri)
throws CopyMacroException, DeleteMacroException {
+ move(token, sourceUri, destinationUri, (CopyListener)null,
(DeleteListener)null);
+ }
+
+ /**
+ * Recursive move with overwrite macro.
+ *
+ * @param token Credentials token
+ * @param sourceUri Uri of the source
+ * @param destinationUri Uri of the destination
+ * @param copyListener the CopyListener that will be notified
+ * before and after copying a resource.
+ * (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 CopyMacroException Exception occured during copy
+ * @exception DeleteMacroException Exception occured during deletion
+ */
+ public void move(SlideToken token, String sourceUri,
+ String destinationUri, CopyListener copyListener,
DeleteListener deleteListener)
+ throws CopyMacroException, DeleteMacroException {
+
move(token, sourceUri, destinationUri,
- RECURSIVE_OVERWRITE_PARAMETERS);
+ RECURSIVE_OVERWRITE_PARAMETERS, copyListener, deleteListener);
}
@@ -246,8 +305,32 @@
public void move(SlideToken token, String sourceUri,
String destinationUri, MacroParameters parameters)
throws CopyMacroException, DeleteMacroException {
- copy(token, sourceUri, destinationUri, parameters);
- delete(token, sourceUri, parameters);
+ move(token, sourceUri, destinationUri, parameters, null, null);
+ }
+
+ /**
+ * Move macro.
+ *
+ * @param token Credentials token
+ * @param sourceUri Uri of the source
+ * @param destinationUri Uri of the destination
+ * @param parameters Macro parameters
+ * @param copyListener the CopyListener that will be notified
+ * before and after copying a resource.
+ * (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 CopyMacroException Exception occured during copy
+ * @exception DeleteMacroException Exception occured during deletion
+ */
+ public void move(SlideToken token, String sourceUri,
+ String destinationUri, MacroParameters parameters,
+ CopyListener copyListener, DeleteListener deleteListener)
+ throws CopyMacroException, DeleteMacroException {
+
+ copy(token, sourceUri, destinationUri, parameters, copyListener);
+ delete(token, sourceUri, parameters, deleteListener);
}
@@ -334,11 +417,14 @@
* @param sourceUri Uri of the source
* @param destinationUri Uri of the destination
* @param parameters Macro parameters
+ * @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) {
+ CopyMacroException e, CopyListener copyListener) {
Domain.debug("Copy object : from " + sourceUri + " to "
+ destinationUri);
@@ -351,6 +437,11 @@
ObjectNode object =
structureHelper.retrieve(token, sourceUri, false);
+ // notify CopyListener
+ if (copyListener != null) {
+ copyListener.beforeCopy(sourceUri, destinationUri);
+ }
+
// Creating the copy
try {
structureHelper.create(token, object.copyObject(),
@@ -410,10 +501,17 @@
} else {
currentRevisionContent = null;
}
+
contentHelper.create(token, destinationUri,
currentRevisionDescriptor,
currentRevisionContent);
+ // notify CopyListener
+ if (copyListener != null) {
+ copyListener.afterCopy(sourceUri, destinationUri);
+ }
+
+
}
// TODO : Parse stack
@@ -432,7 +530,7 @@
String childDestinationUri = destinationUri + childUri
.substring(object.getUri().length());
copyObject(token, childUri, childDestinationUri,
- parameters, e);
+ parameters, e, copyListener);
}
} catch(SlideException ex) {
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>