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 2009/09/15 07:43:18 UTC

svn commit: r815005 - in /sling/trunk/contrib/extensions/rewriter/src/main/java/org/apache/sling/rewriter/impl: ProcessorConfigurationImpl.java ProcessorManagerImpl.java

Author: cziegeler
Date: Tue Sep 15 05:43:17 2009
New Revision: 815005

URL: http://svn.apache.org/viewvc?rev=815005&view=rev
Log:
Add support for pipelines matching configured resource types.

Modified:
    sling/trunk/contrib/extensions/rewriter/src/main/java/org/apache/sling/rewriter/impl/ProcessorConfigurationImpl.java
    sling/trunk/contrib/extensions/rewriter/src/main/java/org/apache/sling/rewriter/impl/ProcessorManagerImpl.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=815005&r1=815004&r2=815005&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:43:17 2009
@@ -42,9 +42,11 @@
 
     private static final String PROPERTY_PROCESSOR_TYPE = "processorType";
 
-    private static final String PROPERTY_CONTENT_TYPE = "contentTypes";
+    private static final String PROPERTY_CONTENT_TYPES = "contentTypes";
 
-    private static final String PROPERTY_TRANFORMER = "transformerTypes";
+    private static final String PROPERTY_RESOURCE_TYPES = "resourceTypes";
+
+    private static final String PROPERTY_TRANFORMERS = "transformerTypes";
 
     private static final String PROPERTY_GENERATOR = "generatorType";
 
@@ -64,6 +66,9 @@
     /** For which extensions should this processor be applied. */
     private final String[] extensions;
 
+    /** For which resource types should this processor be applied. */
+    private final String[] resourceTypes;
+
     /** The order of this processor */
     private final int order;
 
@@ -96,12 +101,14 @@
     public ProcessorConfigurationImpl(String[] contentTypes,
                                       String[] paths,
                                       String[] extensions,
+                                      String[] resourceTypes,
                                       int      order,
                                       ProcessingComponentConfiguration generatorConfig,
                                       ProcessingComponentConfiguration[] transformerConfigs,
                                       ProcessingComponentConfiguration serializerConfig,
                                       boolean processErrorResponse) {
         this.contentTypes = contentTypes;
+        this.resourceTypes = resourceTypes;
         this.paths = paths;
         this.extensions = extensions;
         this.order = order;
@@ -121,13 +128,14 @@
      */
     public ProcessorConfigurationImpl(final Resource resource) {
         final ValueMap properties = ResourceUtil.getValueMap(resource);
-        this.contentTypes = properties.get(PROPERTY_CONTENT_TYPE, String[].class);
+        this.contentTypes = properties.get(PROPERTY_CONTENT_TYPES, String[].class);
+        this.resourceTypes = properties.get(PROPERTY_RESOURCE_TYPES, String[].class);
         this.paths = properties.get(PROPERTY_PATHS, String[].class);
         this.extensions = properties.get(PROPERTY_EXTENSIONS, String[].class);
 
         this.processorConfig = this.getComponentConfig(resource, PROPERTY_PROCESSOR_TYPE, "processor");
         this.generatorConfiguration = this.getComponentConfig(resource, PROPERTY_GENERATOR, "generator");
-        this.transformerConfigurations = this.getComponentConfigs(resource, PROPERTY_TRANFORMER, "transformer");
+        this.transformerConfigurations = this.getComponentConfigs(resource, PROPERTY_TRANFORMERS, "transformer");
         this.serializerConfiguration = this.getComponentConfig(resource, PROPERTY_SERIALIZER, "serializer");
 
         this.order = properties.get(PROPERTY_ORDER, 0);
@@ -244,6 +252,21 @@
                  return false;
              }
         }
+        // check resource types
+        if ( this.resourceTypes != null && this.resourceTypes.length > 0 ) {
+            final Resource resource = processContext.getRequest().getResource();
+            boolean found = false;
+            int index = 0;
+            while ( !found && index < this.resourceTypes.length ) {
+                if ( ResourceUtil.isA(resource, resourceTypes[index]) ) {
+                    found = true;
+                }
+                index++;
+            }
+            if ( !found ) {
+                return false;
+            }
+        }
 
         // now check for path
         // if no path is configured, we apply to all paths

Modified: sling/trunk/contrib/extensions/rewriter/src/main/java/org/apache/sling/rewriter/impl/ProcessorManagerImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/rewriter/src/main/java/org/apache/sling/rewriter/impl/ProcessorManagerImpl.java?rev=815005&r1=815004&r2=815005&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/rewriter/src/main/java/org/apache/sling/rewriter/impl/ProcessorManagerImpl.java (original)
+++ sling/trunk/contrib/extensions/rewriter/src/main/java/org/apache/sling/rewriter/impl/ProcessorManagerImpl.java Tue Sep 15 05:43:17 2009
@@ -150,7 +150,8 @@
         this.addProcessor("*", "", new ProcessorConfigurationImpl(
                 new String[] {MIME_TYPE_HTML}, // content types
                 null, // paths,
-                new String[] {"html"}, // extension
+                new String[] {"html"}, // extensions
+                null, // resource types
                 -1,   // order
                 new ProcessingComponentConfigurationImpl("html-generator", null), // generator config
                 null, // transformer config