sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1625959 - /sling/trunk/contrib/extensions/resourcemerger/src/main/java/org/apache/sling/resourcemerger/impl/CRUDMergingResourceProvider.java
Date Thu, 18 Sep 2014 12:19:22 GMT
Author: cziegeler
Date: Thu Sep 18 12:19:21 2014
New Revision: 1625959

URL: http://svn.apache.org/r1625959
Log:
Correct delete behaviour

Modified:
    sling/trunk/contrib/extensions/resourcemerger/src/main/java/org/apache/sling/resourcemerger/impl/CRUDMergingResourceProvider.java

Modified: sling/trunk/contrib/extensions/resourcemerger/src/main/java/org/apache/sling/resourcemerger/impl/CRUDMergingResourceProvider.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/resourcemerger/src/main/java/org/apache/sling/resourcemerger/impl/CRUDMergingResourceProvider.java?rev=1625959&r1=1625958&r2=1625959&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/resourcemerger/src/main/java/org/apache/sling/resourcemerger/impl/CRUDMergingResourceProvider.java
(original)
+++ sling/trunk/contrib/extensions/resourcemerger/src/main/java/org/apache/sling/resourcemerger/impl/CRUDMergingResourceProvider.java
Thu Sep 18 12:19:21 2014
@@ -63,9 +63,8 @@ public class CRUDMergingResourceProvider
             holder.count++;
             if ( holder.count == 1 ) {
                 holder.lowestResourcePath = rsrc.getPath();
-            } else if ( holder.count == 2 ) {
-                holder.highestResourcePath = rsrc.getPath();
             }
+            holder.highestResourcePath = rsrc.getPath();
             if ( !ResourceUtil.isNonExistingResource(rsrc) ) {
                 // check parent for hiding
                 final Resource parent = rsrc.getParent();
@@ -145,15 +144,10 @@ public class CRUDMergingResourceProvider
             throw new PersistenceException("Modifying is only supported with at least two
potentially merged resources.", null, path, null);
         }
 
-        int deleted = 0;
-        for(final Resource rsrc : holder.holder.resources) {
-            final String p = rsrc.getPath();
-            if ( !p.equals(holder.lowestResourcePath) ) {
-                resolver.delete(rsrc);
-                deleted++;
-            }
-        }
-        if ( deleted < holder.holder.resources.size() ) {
+        if ( holder.holder.resources.size() == 1 && holder.holder.resources.get(0).getPath().equals(holder.highestResourcePath)
) {
+            // delete the only resource which is the highest one
+            resolver.delete(holder.holder.resources.get(0));
+        } else {
             // create overlay resource which is hiding the other
             final String createPath = holder.highestResourcePath;
             final Resource parentResource = ResourceUtil.getOrCreateResource(resolver, ResourceUtil.getParent(createPath),
(String)null, null, false);



Mime
View raw message