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:50 UTC

[sling-org-apache-sling-resourcemerger] 09/31: SLING-4340 - getting the resource type property *first* and then falling back to the first non-null getResourceType() result.

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.10
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-resourcemerger.git

commit 1ba1bb453b0c918d5c44ec3afb733c97538d75b8
Author: Justin Edelson <ju...@apache.org>
AuthorDate: Wed Jan 21 17:05:14 2015 +0000

    SLING-4340 - getting the resource type property *first* and then falling back to the first non-null getResourceType() result.
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/resourcemerger@1653604 13f79535-47bb-0310-9956-ffa450edef68
---
 .../apache/sling/resourcemerger/impl/MergedResource.java    | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 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 2a76ae7..118f44e 100644
--- a/src/main/java/org/apache/sling/resourcemerger/impl/MergedResource.java
+++ b/src/main/java/org/apache/sling/resourcemerger/impl/MergedResource.java
@@ -64,11 +64,14 @@ public class MergedResource extends AbstractResource {
         this.path = (relativePath.length() == 0 ? mergeRootPath : mergeRootPath + "/" + relativePath);
         this.properties = new DeepReadValueMapDecorator(this, new MergedValueMap(valueMaps));
         // get resource type
-        String rt = (relativePath.length() == 0 ? "/" : relativePath);
-        for(final Resource rsrc : mappedResources) {
-            final String value = rsrc.getResourceType();
-            if ( value != null ) {
-                rt = value;
+        String rt = this.properties.get(ResourceResolver.PROPERTY_RESOURCE_TYPE, String.class);
+        if (rt == null) {
+            rt = relativePath.length() == 0 ? "/" : relativePath;
+            for(final Resource rsrc : mappedResources) {
+                final String value = rsrc.getResourceType();
+                if ( value != null ) {
+                    rt = value;
+                }
             }
         }
         this.resourceType = rt;

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.