sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1562604 - in /sling/trunk/contrib/extensions/resourcemerger/src/main/java/org/apache/sling/resourcemerger/impl: MergedResource.java MergedResourceProvider.java
Date Wed, 29 Jan 2014 21:55:44 GMT
Author: cziegeler
Date: Wed Jan 29 21:55:43 2014
New Revision: 1562604

URL: http://svn.apache.org/r1562604
Log:
SLING-2986 : Check if resource is hidden through properties (own or parent)

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

Modified: sling/trunk/contrib/extensions/resourcemerger/src/main/java/org/apache/sling/resourcemerger/impl/MergedResource.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/resourcemerger/src/main/java/org/apache/sling/resourcemerger/impl/MergedResource.java?rev=1562604&r1=1562603&r2=1562604&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/resourcemerger/src/main/java/org/apache/sling/resourcemerger/impl/MergedResource.java
(original)
+++ sling/trunk/contrib/extensions/resourcemerger/src/main/java/org/apache/sling/resourcemerger/impl/MergedResource.java
Wed Jan 29 21:55:43 2014
@@ -171,7 +171,7 @@ public class MergedResource extends Abst
             return false;
         }
 
-        Resource r = (Resource) o;
+        final Resource r = (Resource) o;
         return r.getPath().equals(getPath());
     }
 

Modified: sling/trunk/contrib/extensions/resourcemerger/src/main/java/org/apache/sling/resourcemerger/impl/MergedResourceProvider.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/resourcemerger/src/main/java/org/apache/sling/resourcemerger/impl/MergedResourceProvider.java?rev=1562604&r1=1562603&r2=1562604&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/resourcemerger/src/main/java/org/apache/sling/resourcemerger/impl/MergedResourceProvider.java
(original)
+++ sling/trunk/contrib/extensions/resourcemerger/src/main/java/org/apache/sling/resourcemerger/impl/MergedResourceProvider.java
Wed Jan 29 21:55:43 2014
@@ -63,10 +63,31 @@ public class MergedResourceProvider impl
                 // 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 impl
 
                 // 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));
 



Mime
View raw message