This is an automated email from the ASF dual-hosted git repository. rombert pushed a commit to annotated tag org.apache.sling.resourcemerger-1.0.0 in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-resourcemerger.git
commit 652751213576c769143c139fb5f7b1cbd1a18488 Author: Carsten Ziegeler <cziege...@apache.org> AuthorDate: Wed Jan 29 21:55:43 2014 +0000 SLING-2986 : Check if resource is hidden through properties (own or parent) git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/resourcemerger@1562604 13f79535-47bb-0310-9956-ffa450edef68 --- .../sling/resourcemerger/impl/MergedResource.java | 2 +- .../impl/MergedResourceProvider.java | 31 ++++++++++++++++++---- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/apache/sling/resourcemerger/impl/MergedResource.java b/src/main/java/org/apache/sling/resourcemerger/impl/MergedResource.java index 2e6ddec..6974dc7 100644 --- a/src/main/java/org/apache/sling/resourcemerger/impl/MergedResource.java +++ b/src/main/java/org/apache/sling/resourcemerger/impl/MergedResource.java @@ -171,7 +171,7 @@ public class MergedResource extends AbstractResource { return false; } - Resource r = (Resource) o; + final Resource r = (Resource) o; return r.getPath().equals(getPath()); } diff --git a/src/main/java/org/apache/sling/resourcemerger/impl/MergedResourceProvider.java b/src/main/java/org/apache/sling/resourcemerger/impl/MergedResourceProvider.java index d722512..71502f9 100644 --- a/src/main/java/org/apache/sling/resourcemerger/impl/MergedResourceProvider.java +++ b/src/main/java/org/apache/sling/resourcemerger/impl/MergedResourceProvider.java @@ -63,10 +63,31 @@ public class MergedResourceProvider implements ResourceProvider { // Loop over provided base paths for (final String basePath : resolver.getSearchPath()) { // Try to get the corresponding physical resource for this base path - final Resource baseRes = resolver.getResource(ResourceUtil.normalize(basePath + "/" + relativePath)); + final Resource baseRes = resolver.getResource(basePath + "/" + relativePath); if (baseRes != null) { - // Physical resource exists, add it to the list of mapped resources - mappedResources.add(0, baseRes.getPath()); + // check if resource is hidden + boolean hidden = false; + final ValueMap props = ResourceUtil.getValueMap(baseRes); + if ( props.get(MergedResourceConstants.PN_HIDE_RESOURCE, Boolean.FALSE) ) { + hidden = true; + } + if ( !hidden ) { + // check parent + final ValueMap parentProps = ResourceUtil.getValueMap(baseRes.getParent()); + final String[] childrenToHideArray = parentProps.get(MergedResourceConstants.PN_HIDE_CHILDREN, String[].class); + if ( childrenToHideArray != null ) { + for(final String name : childrenToHideArray ) { + if ( name.equals(baseRes.getName()) ) { + hidden = true; + break; + } + } + } + } + if ( !hidden ) { + // Physical resource exists, add it to the list of mapped resources + mappedResources.add(0, baseRes.getPath()); + } } } @@ -119,9 +140,9 @@ public class MergedResourceProvider implements ResourceProvider { // Browse children of current physical resource for (final Resource child : mappedResource.getChildren()) { - final String childRelativePath = ResourceUtil.normalize(mergedResource.getRelativePath() + "/" + child.getName()); + final String childRelativePath = mergedResource.getRelativePath() + "/" + child.getName(); - if (child.adaptTo(ValueMap.class).get(MergedResourceConstants.PN_HIDE_RESOURCE, Boolean.FALSE)) { + if (ResourceUtil.getValueMap(child).get(MergedResourceConstants.PN_HIDE_RESOURCE, Boolean.FALSE)) { // Child resource has to be hidden children.remove(new MergedResource(resolver, mergeRootPath, childRelativePath)); -- To stop receiving notification emails like this one, please contact "commits@sling.apache.org" <commits@sling.apache.org>.