sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1649839 - in /sling/trunk/contrib/extensions/resourcemerger/src/main/java/org/apache/sling/resourcemerger/impl: MergedResource.java MergedValueMap.java
Date Tue, 06 Jan 2015 15:41:25 GMT
Author: cziegeler
Date: Tue Jan  6 15:41:24 2015
New Revision: 1649839

URL: http://svn.apache.org/r1649839
Log:
SLING-4247 : Reconsider resource type handling

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/MergedValueMap.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=1649839&r1=1649838&r2=1649839&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
Tue Jan  6 15:41:24 2015
@@ -63,7 +63,15 @@ public class MergedResource extends Abst
         this.resolver = resolver;
         this.path = (relativePath.length() == 0 ? mergeRootPath : mergeRootPath + "/" + relativePath);
         this.properties = new DeepReadValueMapDecorator(this, new MergedValueMap(valueMaps));
-        this.resourceType = this.properties.get(ResourceResolver.PROPERTY_RESOURCE_TYPE,
(relativePath.length() == 0 ? "/" : relativePath));
+        // get resource type
+        String rt = (relativePath.length() == 0 ? "/" : relativePath);
+        for(final Resource rsrc : mappedResources) {
+            final String value = rsrc.getResourceType();
+            if ( value != null ) {
+                rt = value;
+            }
+        }
+        this.resourceType = rt;
         metadata.put(MergedResourceConstants.METADATA_FLAG, true);
         final String[] resourcePaths = new String[mappedResources.size()];
         int i = 0;

Modified: sling/trunk/contrib/extensions/resourcemerger/src/main/java/org/apache/sling/resourcemerger/impl/MergedValueMap.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/resourcemerger/src/main/java/org/apache/sling/resourcemerger/impl/MergedValueMap.java?rev=1649839&r1=1649838&r2=1649839&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/resourcemerger/src/main/java/org/apache/sling/resourcemerger/impl/MergedValueMap.java
(original)
+++ sling/trunk/contrib/extensions/resourcemerger/src/main/java/org/apache/sling/resourcemerger/impl/MergedValueMap.java
Tue Jan  6 15:41:24 2015
@@ -53,38 +53,26 @@ public class MergedValueMap extends Valu
         super(new HashMap<String, Object>());
         // Iterate over value maps
         for (final ValueMap vm : valueMaps) {
-            if (this.isEmpty()) {
-                // Add all properties
-                this.putAll(vm);
-            } else {
-                // Get properties to add or override
-                for (final String key : vm.keySet()) {
-                    if (!isExcludedProperty(key)) {
-                        this.put(key, vm.get(key));
-                    }
-                }
+            // Add all properties
+            this.putAll(vm);
 
-                // Get properties to hide
-                final String[] propertiesToHide = vm.get(MergedResourceConstants.PN_HIDE_PROPERTIES,
String[].class);
-                if ( propertiesToHide != null ) {
-                    for (final String propName : propertiesToHide) {
-                        if (propName.equals("*")) {
-                            this.clear();
-                            break;
-                        } else {
-                            this.remove(propName);
-                        }
+            // Get properties to hide
+            final String[] propertiesToHide = vm.get(MergedResourceConstants.PN_HIDE_PROPERTIES,
String[].class);
+            if ( propertiesToHide != null ) {
+                for (final String propName : propertiesToHide) {
+                    if (propName.equals("*")) {
+                        this.clear();
+                        break;
+                    } else {
+                        this.remove(propName);
                     }
                 }
             }
         }
+
         // Hide excluded properties
         for (final String excludedProperty : EXCLUDED_PROPERTIES) {
             this.remove(excludedProperty);
         }
     }
-
-    private boolean isExcludedProperty(String key) {
-        return EXCLUDED_PROPERTIES.contains(key);
-    }
 }



Mime
View raw message