You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2017/10/06 06:26:50 UTC

svn commit: r1811286 - in /sling/trunk/bundles/extensions/bundleresource/src/main/java/org/apache/sling/bundleresource/impl: BundleResourceIterator.java BundleResourceProvider.java

Author: cziegeler
Date: Fri Oct  6 06:26:50 2017
New Revision: 1811286

URL: http://svn.apache.org/viewvc?rev=1811286&view=rev
Log:
Minor code cleanup

Modified:
    sling/trunk/bundles/extensions/bundleresource/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceIterator.java
    sling/trunk/bundles/extensions/bundleresource/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceProvider.java

Modified: sling/trunk/bundles/extensions/bundleresource/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceIterator.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/bundleresource/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceIterator.java?rev=1811286&r1=1811285&r2=1811286&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/bundleresource/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceIterator.java (original)
+++ sling/trunk/bundles/extensions/bundleresource/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceIterator.java Fri Oct  6 06:26:50 2017
@@ -65,33 +65,26 @@ class BundleResourceIterator implements
      * Creates an instance using the given parent bundle resource.
      */
     BundleResourceIterator(final BundleResource parent) {
-        // trailing slash to enumerate children
-        final String parentEntryPath = parent.getMappedPath().getEntryPath(parent.getPath().concat("/"));
-        this.prefixLength = parentEntryPath.length();
-
-        this.resourceResolver = parent.getResourceResolver();
-        this.cache = parent.getBundle();
-        this.subResources = parent.getSubResources() != null ? new HashMap<>(parent.getSubResources()) : null;
-        this.mappedPath = parent.getMappedPath();
-
-        this.entries = getFilteredEntries(parentEntryPath);
-
-        this.nextResult = (entries != null) ? seek() : null;
+        this(parent.getResourceResolver(),
+                parent.getBundle(),
+                parent.getMappedPath(),
+                parent.getPath(),
+                parent.getSubResources());
     }
 
-    BundleResourceIterator(ResourceResolver resourceResolver, BundleResourceCache bundle,
-            PathMapping mappedPath, String parentPath) {
+    BundleResourceIterator(final ResourceResolver resourceResolver,
+            final BundleResourceCache bundle,
+            final PathMapping mappedPath,
+            final String parentPath,
+            final Map<String, Map<String, Object>> subResources) {
 
         // trailing slash to enumerate children
-        if (!parentPath.endsWith("/")) {
-            parentPath = parentPath.concat("/");
-        }
-        final String parentEntryPath = mappedPath.getEntryPath(parentPath);
+        final String parentEntryPath = mappedPath.getEntryPath(parentPath.concat("/"));
         this.prefixLength = parentEntryPath.length();
 
         this.resourceResolver = resourceResolver;
         this.cache = bundle;
-        this.subResources = null;
+        this.subResources = subResources != null ? new HashMap<>(subResources) : null;
         this.mappedPath = mappedPath;
         this.entries = getFilteredEntries(parentEntryPath);
 

Modified: sling/trunk/bundles/extensions/bundleresource/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceProvider.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/bundleresource/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceProvider.java?rev=1811286&r1=1811285&r2=1811286&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/bundleresource/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceProvider.java (original)
+++ sling/trunk/bundles/extensions/bundleresource/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceProvider.java Fri Oct  6 06:26:50 2017
@@ -166,7 +166,7 @@ public class BundleResourceProvider exte
         PathMapping mappedPath = getMappedPath(parentPath);
         if (mappedPath != null) {
             return new BundleResourceIterator(parent.getResourceResolver(),
-                cache, mappedPath, parentPath);
+                cache, mappedPath, parentPath, null);
         }
 
         // the parent resource cannot have children in this provider,