This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository 
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-mongodb.git

commit 6536b754f6384d6d2713f150f157673f9c1af248
Author: Carsten Ziegeler <[email protected]>
AuthorDate: Thu Aug 2 06:17:18 2012 +0000

    New MongoDB resource provider
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1368356 
13f79535-47bb-0310-9956-ffa450edef68
---
 .../mongodb/impl/MongoDBResourceProvider.java      | 50 ++++++++++++++--------
 1 file changed, 31 insertions(+), 19 deletions(-)

diff --git 
a/src/main/java/org/apache/sling/mongodb/impl/MongoDBResourceProvider.java 
b/src/main/java/org/apache/sling/mongodb/impl/MongoDBResourceProvider.java
index 8bea67a..c35a8f1 100644
--- a/src/main/java/org/apache/sling/mongodb/impl/MongoDBResourceProvider.java
+++ b/src/main/java/org/apache/sling/mongodb/impl/MongoDBResourceProvider.java
@@ -118,27 +118,39 @@ public class MongoDBResourceProvider implements 
ResourceProvider, ModifyingResou
      */
     public void delete(final ResourceResolver resolver, final String path)
     throws PersistenceException {
-        if ( deletedResources.contains(path) ) {
-            return;
-        }
-
         final String[] info = this.extractResourceInfo(path);
         if ( info != null ) {
-            final Resource rsrc = this.getResource(resolver, path, info);
-            if ( rsrc instanceof MongoDBResource ) {
-                this.deletedResources.add(path);
-                this.changedResources.remove(path);
-
-                final DBCollection col = this.getCollection(info[0]);
-                final String pattern = "^" + Pattern.quote(info[1]) + "/";
-
-                final DBObject query = 
QueryBuilder.start(PROP_PATH).regex(Pattern.compile(pattern)).get();
-                final DBCursor cur = col.find(query);
-                while ( cur.hasNext() ) {
-                    final DBObject dbObj = cur.next();
-                    final String childPath = info[0] + '/' + 
dbObj.get(PROP_PATH);
-                    this.deletedResources.add(childPath);
-                    this.changedResources.remove(childPath);
+            boolean deletedResource = false;
+            if ( !deletedResources.contains(path) ) {
+                final Resource rsrc = this.getResource(resolver, path, info);
+                if ( rsrc instanceof MongoDBResource ) {
+                    this.deletedResources.add(path);
+                    this.changedResources.remove(path);
+
+                    final DBCollection col = this.getCollection(info[0]);
+                    final String pattern = "^" + Pattern.quote(info[1]) + "/";
+
+                    final DBObject query = 
QueryBuilder.start(PROP_PATH).regex(Pattern.compile(pattern)).get();
+                    final DBCursor cur = col.find(query);
+                    while ( cur.hasNext() ) {
+                        final DBObject dbObj = cur.next();
+                        final String childPath = info[0] + '/' + 
dbObj.get(PROP_PATH);
+                        this.deletedResources.add(childPath);
+                        this.changedResources.remove(childPath);
+                    }
+                    deletedResource = true;
+                }
+            } else {
+                deletedResource = true;
+            }
+            if ( deletedResource ) {
+                final String prefix = path + "/";
+                final Iterator<Map.Entry<String, MongoDBResource>> i = 
this.changedResources.entrySet().iterator();
+                while ( i.hasNext() ) {
+                    final Map.Entry<String, MongoDBResource> entry = i.next();
+                    if ( entry.getKey().startsWith(prefix) ) {
+                        i.remove();
+                    }
                 }
                 return;
             }

-- 
To stop receiving notification emails like this one, please contact
"[email protected]" <[email protected]>.

Reply via email to