incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r815008 - /sling/trunk/contrib/extensions/rewriter/src/main/java/org/apache/sling/rewriter/impl/ProcessorConfigurationImpl.java
Date Tue, 15 Sep 2009 05:47:07 GMT
Author: cziegeler
Date: Tue Sep 15 05:47:07 2009
New Revision: 815008

URL: http://svn.apache.org/viewvc?rev=815008&view=rev
Log:
Give an alternative configuration possibility if the same transformer is used more than once
in a pipeline.

Modified:
    sling/trunk/contrib/extensions/rewriter/src/main/java/org/apache/sling/rewriter/impl/ProcessorConfigurationImpl.java

Modified: sling/trunk/contrib/extensions/rewriter/src/main/java/org/apache/sling/rewriter/impl/ProcessorConfigurationImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/rewriter/src/main/java/org/apache/sling/rewriter/impl/ProcessorConfigurationImpl.java?rev=815008&r1=815007&r2=815008&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/rewriter/src/main/java/org/apache/sling/rewriter/impl/ProcessorConfigurationImpl.java
(original)
+++ sling/trunk/contrib/extensions/rewriter/src/main/java/org/apache/sling/rewriter/impl/ProcessorConfigurationImpl.java
Tue Sep 15 05:47:07 2009
@@ -179,8 +179,17 @@
         if ( types != null && types.length > 0 ) {
             final ProcessingComponentConfiguration[] configs = new ProcessingComponentConfiguration[types.length];
             for(int i=0; i<types.length; i++) {
+                // there are two possible ways for a component configuration:
+                // 1. {prefix}-{type}, like generator-html
+                // 2. {prefix}-{index}, like generator-1 (with the index starting at 1)
+                // while usually the first way is sufficient, the second one is required
if the
+                // same transformer is used more than once in a pipeline.
                 final String resourceName = prefix + '-' + types[i];
-                final Resource childResource = configResource.getResourceResolver().getResource(configResource,
resourceName);
+                Resource childResource = configResource.getResourceResolver().getResource(configResource,
resourceName);
+                if ( childResource == null ) {
+                    final String secondResourceName = prefix + '-' + (i+1);
+                    childResource = configResource.getResourceResolver().getResource(configResource,
secondResourceName);
+                }
                 final Map<String, Object> config;
                 if ( childResource != null ) {
                     final ValueMap childProps = ResourceUtil.getValueMap(childResource);



Mime
View raw message