You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/11/07 09:59:34 UTC
[sling-org-apache-sling-resourcemerger] 17/23: Correct delete
behaviour
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.resourcemerger-1.2.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-resourcemerger.git
commit ca4af830d769d05c69764f4775e2551780b010e8
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Thu Sep 18 12:19:21 2014 +0000
Correct delete behaviour
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/resourcemerger@1625959 13f79535-47bb-0310-9956-ffa450edef68
---
.../resourcemerger/impl/CRUDMergingResourceProvider.java | 16 +++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)
diff --git a/src/main/java/org/apache/sling/resourcemerger/impl/CRUDMergingResourceProvider.java b/src/main/java/org/apache/sling/resourcemerger/impl/CRUDMergingResourceProvider.java
index 88058d9..fa529d6 100644
--- a/src/main/java/org/apache/sling/resourcemerger/impl/CRUDMergingResourceProvider.java
+++ b/src/main/java/org/apache/sling/resourcemerger/impl/CRUDMergingResourceProvider.java
@@ -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);
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.