ozeigermann 2004/10/19 22:29:51
Modified: src/share/org/apache/slide/macro MacroImpl.java
src/share/org/apache/slide/common Namespace.java
Log:
Added real inexpensive check if move/copy/delete is inside a single store.
Idea is attributed to Stefan...
Revision Changes Path
1.46 +7 -7 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.45
retrieving revision 1.46
diff -u -r1.45 -r1.46
--- MacroImpl.java 19 Oct 2004 21:42:46 -0000 1.45
+++ MacroImpl.java 20 Oct 2004 05:29:51 -0000 1.46
@@ -210,7 +210,7 @@
Store store = source.getStore();
if (store.isMacroCopySupported() && source.getStore() ==
destination.getStore()
- && namespace.canUseMacroStore(source) &&
namespace.canUseMacroStore(destination)) {
+ && namespace.isTreeInSingleStore(source) &&
namespace.isTreeInSingleStore(destination)) {
try {
if (Configuration.useIntegratedSecurity()) {
recursiveAccessCheck(source,
namespaceConfig.getReadObjectAction());
@@ -512,7 +512,7 @@
Store store = source.getStore();
if (store.isMacroMoveSupported() && source.getStore() ==
destination.getStore()
- && namespace.canUseMacroStore(source) &&
namespace.canUseMacroStore(destination)) {
+ && namespace.isTreeInSingleStore(source) &&
namespace.isTreeInSingleStore(destination)) {
try {
if (Configuration.useIntegratedSecurity()) {
recursiveAccessCheck(source,
namespaceConfig.getRemoveObjectAction());
@@ -641,7 +641,7 @@
Uri destination = namespace.getUri(token, targetUri);
Store store = destination.getStore();
- if (store.isMacroDeleteSupported() &&
namespace.canUseMacroStore(destination)) {
+ if (store.isMacroDeleteSupported() &&
namespace.isTreeInSingleStore(destination)) {
try {
if (Configuration.useIntegratedSecurity()) {
recursiveAccessCheck(destination,
namespaceConfig.getRemoveObjectAction());
1.71 +47 -19 jakarta-slide/src/share/org/apache/slide/common/Namespace.java
Index: Namespace.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/share/org/apache/slide/common/Namespace.java,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -r1.70 -r1.71
--- Namespace.java 19 Oct 2004 11:47:06 -0000 1.70
+++ Namespace.java 20 Oct 2004 05:29:51 -0000 1.71
@@ -27,6 +27,8 @@
import java.lang.reflect.Method;
import java.util.Enumeration;
import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Map;
import java.util.Vector;
import javax.transaction.Status;
@@ -341,25 +343,51 @@
// --------------------------------------------------------- Public Methods
- public boolean canUseMacroStore(Uri source) {
- // TODO check if all children of this uri are in the same store
+ /**
+ * Checks if all descendants of the given URI are stored in the same store.
+ *
+ * @param source
+ * root URI of the tree to check
+ * @return <code>true</code> if the whole tree is in a single store,
+ * <code>false</code> otherwise
+ */
+ public boolean isTreeInSingleStore(Uri source) {
+ Store sourceStore = source.getStore();
+ String evilPrefix = source.toString();
+
+ for (Iterator it = stores.entrySet().iterator(); it.hasNext();) {
+ Map.Entry entry = (Map.Entry) it.next();
+ Scope scope = (Scope) entry.getKey();
+ Store store = (Store) entry.getValue();
+
+ // there is a store that is not the one of the root, but still stores
+ // part of our tree, which means the tree is not in a single store
+ if (store != sourceStore && scope.toString().startsWith(evilPrefix)) {
+ return false;
+ }
+ }
return true;
}
/**
- * Used to register a Store in the namespace for the specified scope.
- * First, the function instantiate the Store, then gives it
- * its init parameters. It is then stored in the stores
- * Hashtable, associated with the given scope.
- *
- * @param storeClass Class of the Data Source
- * @param parameters Init parameters for the Data Source
- * @param scope Scope for which the Data Source is registered
- * @param childStores Instances of the typed stores
- * @exception ServiceRegistrationFailed An error occured during
- * instantiation of the service
- * @exception ServiceParameterErrorException Incorrect service parameter
- * @exception ServiceParameterMissingException Service parameter missing
+ * Used to register a Store in the namespace for the specified scope. First,
+ * the function instantiate the Store, then gives it its init parameters. It
+ * is then stored in the stores Hashtable, associated with the given scope.
+ *
+ * @param storeClass
+ * Class of the Data Source
+ * @param parameters
+ * Init parameters for the Data Source
+ * @param scope
+ * Scope for which the Data Source is registered
+ * @param childStores
+ * Instances of the typed stores
+ * @exception ServiceRegistrationFailed
+ * An error occured during instantiation of the service
+ * @exception ServiceParameterErrorException
+ * Incorrect service parameter
+ * @exception ServiceParameterMissingException
+ * Service parameter missing
*/
public void registerStore(String storeName, Class storeClass,
Hashtable parameters, Scope scope,
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]