incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1368356 - /sling/trunk/contrib/extensions/mongodb/src/main/java/org/apache/sling/mongodb/impl/MongoDBResourceProvider.java
Date Thu, 02 Aug 2012 06:17:18 GMT
Author: cziegeler
Date: Thu Aug  2 06:17:18 2012
New Revision: 1368356

URL: http://svn.apache.org/viewvc?rev=1368356&view=rev
Log:
New MongoDB resource provider

Modified:
    sling/trunk/contrib/extensions/mongodb/src/main/java/org/apache/sling/mongodb/impl/MongoDBResourceProvider.java

Modified: sling/trunk/contrib/extensions/mongodb/src/main/java/org/apache/sling/mongodb/impl/MongoDBResourceProvider.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/mongodb/src/main/java/org/apache/sling/mongodb/impl/MongoDBResourceProvider.java?rev=1368356&r1=1368355&r2=1368356&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/mongodb/src/main/java/org/apache/sling/mongodb/impl/MongoDBResourceProvider.java
(original)
+++ sling/trunk/contrib/extensions/mongodb/src/main/java/org/apache/sling/mongodb/impl/MongoDBResourceProvider.java
Thu Aug  2 06:17:18 2012
@@ -118,27 +118,39 @@ public class MongoDBResourceProvider imp
      */
     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;
             }



Mime
View raw message