kwin commented on a change in pull request #4:
URL: 
https://github.com/apache/sling-org-apache-sling-resourcemerger/pull/4#discussion_r589669155



##########
File path: 
src/main/java/org/apache/sling/resourcemerger/impl/HideItemPredicate.java
##########
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.resourcemerger.impl;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Item may be either a {@link Resource} or a property which should be hidden 
(depending on its name).
+ * 
+ *
+ */
+public class HideItemPredicate {
+
+    private Boolean isAllowList = null; // true in case the names list items 
to hide, otherwise false
+    private boolean isWildcard = false;
+    private final Set<String> names;
+
+    private static final Logger LOGGER = 
LoggerFactory.getLogger(HideItemPredicate.class);
+
+    public HideItemPredicate(String[] settings, String propertyPath) {
+        names = new HashSet<>();
+        // negated and non-negated values must not be mixed
+        for (String setting : settings) {
+            if (setting.equals("*")) {
+                isWildcard = true;
+            } else {
+                boolean isNegated = setting.startsWith("!") && 
!setting.startsWith("!!");

Review comment:
       Fixed in 
https://github.com/apache/sling-org-apache-sling-resourcemerger/pull/4/commits/32cf5745f8dce1246209396d631a96445d49adbb

##########
File path: 
src/main/java/org/apache/sling/resourcemerger/impl/MergingResourceProvider.java
##########
@@ -51,86 +51,55 @@
         this.traverseHierarchie = traverseHierarchie;
     }
 
-    protected static final class ExcludeEntry {
-
-        public final String name;
-        public final boolean exclude;
-        public final boolean onlyUnderlying; // if only underlying resources 
should be affected (and not the local ones)
-
-        public ExcludeEntry(final String value, boolean onlyUnderlying) {
-            this.onlyUnderlying = onlyUnderlying;
-            if ( value.startsWith("!!") ) {
-                this.name = value.substring(1);
-                this.exclude = false;
-            } else if ( value.startsWith("!") ) {
-                this.name = value.substring(1);
-                this.exclude = true;
-            } else {
-                this.name = value;
-                this.exclude = false;
-            }
-        }
-    }
-
     /**
      * Class to check whether a child resource must be hidden. It should not 
be instantiated for the underlying resource
      * tree (which is /libs by default) because this check is expensive.
      */
-    protected static final class ParentHidingHandler {
+    protected static final class ResourceHidingHandler {
 
-        private List<ExcludeEntry> entries = new ArrayList<ExcludeEntry>();
+        private boolean isParentHiddenFully;
+        private boolean isParentHiddenForUnderlay;
+        private final HideItemPredicate hidePredicate;
 
         /**
          *
-         * @param parent the underlying resource
+         * @param resource the underlying resource
          * @param traverseParent if true will also continue with the parent's 
parent recursively
          */
-        public ParentHidingHandler(final Resource parent, final boolean 
traverseParent) {
+        public ResourceHidingHandler(final Resource resource, final boolean 
traverseParent) {
+            isParentHiddenFully = false;
+            isParentHiddenForUnderlay = false;
             // evaluate the sling:hideChildren property on the current resource
-            final ValueMap parentProps = parent.getValueMap();
-            final String[] childrenToHideArray = 
parentProps.get(MergedResourceConstants.PN_HIDE_CHILDREN, String[].class);
+            final ValueMap properties = resource.getValueMap();
+            final String[] childrenToHideArray = 
properties.get(MergedResourceConstants.PN_HIDE_CHILDREN, String[].class);

Review comment:
       Fixed in 
https://github.com/apache/sling-org-apache-sling-resourcemerger/pull/4/commits/32cf5745f8dce1246209396d631a96445d49adbb




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to