Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 64B2D200BEF for ; Wed, 4 Jan 2017 17:14:56 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 631A7160B3A; Wed, 4 Jan 2017 16:14:56 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id ADB3B160B39 for ; Wed, 4 Jan 2017 17:14:55 +0100 (CET) Received: (qmail 92750 invoked by uid 500); 4 Jan 2017 16:14:54 -0000 Mailing-List: contact commits-help@sling.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@sling.apache.org Delivered-To: mailing list commits@sling.apache.org Received: (qmail 92741 invoked by uid 99); 4 Jan 2017 16:14:54 -0000 Received: from Unknown (HELO svn01-us-west.apache.org) (209.188.14.144) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 Jan 2017 16:14:54 +0000 Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id 2A6F23A211C for ; Wed, 4 Jan 2017 16:14:54 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1777332 - in /sling/trunk/contrib/extensions/rewriter/src: main/java/org/apache/sling/rewriter/impl/ProcessorConfigurationImpl.java test/java/org/apache/sling/rewriter/impl/ProcessorConfigurationImplTest.java Date: Wed, 04 Jan 2017 16:14:53 -0000 To: commits@sling.apache.org From: justin@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20170104161454.2A6F23A211C@svn01-us-west.apache.org> archived-at: Wed, 04 Jan 2017 16:14:56 -0000 Author: justin Date: Wed Jan 4 16:14:53 2017 New Revision: 1777332 URL: http://svn.apache.org/viewvc?rev=1777332&view=rev Log: Merge branch 'issue/force-rewriter-pipeline' Modified: sling/trunk/contrib/extensions/rewriter/src/main/java/org/apache/sling/rewriter/impl/ProcessorConfigurationImpl.java sling/trunk/contrib/extensions/rewriter/src/test/java/org/apache/sling/rewriter/impl/ProcessorConfigurationImplTest.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=1777332&r1=1777331&r2=1777332&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 Wed Jan 4 16:14:53 2017 @@ -65,6 +65,8 @@ public class ProcessorConfigurationImpl static final String PROPERTY_PROCESS_ERROR = "processError"; + static final String ATTR_PIPELINE = "org.apache.sling.rewriter.pipeline"; + /** For which content types should this processor be applied. */ private final String[] contentTypes; @@ -112,6 +114,8 @@ public class ProcessorConfigurationImpl private final String descString; + private final String name; + /** * This is the constructor for a pipeline */ @@ -126,6 +130,7 @@ public class ProcessorConfigurationImpl ProcessingComponentConfiguration[] transformerConfigs, ProcessingComponentConfiguration serializerConfig, boolean processErrorResponse) { + this.name = null; this.contentTypes = contentTypes; this.resourceTypes = resourceTypes; this.unwrapResources = unwrapResources; @@ -160,6 +165,7 @@ public class ProcessorConfigurationImpl * This constructor reads the configuration from the specified resource. */ public ProcessorConfigurationImpl(final Resource resource) { + this.name = resource.getName(); final ValueMap properties = ResourceUtil.getValueMap(resource); this.contentTypes = properties.get(PROPERTY_CONTENT_TYPES, String[].class); this.resourceTypes = properties.get(PROPERTY_RESOURCE_TYPES, String[].class); @@ -198,6 +204,10 @@ public class ProcessorConfigurationImpl } void printConfiguration(final PrintWriter pw) { + if ( this.name != null ) { + pw.print("Name : "); + pw.println(this.name); + } if ( this.contentTypes != null ) { pw.print("Content Types : "); pw.println(Arrays.toString(this.contentTypes)); @@ -370,6 +380,12 @@ public class ProcessorConfigurationImpl if ( !this.processErrorResponse && processContext.getRequest().getAttribute("javax.servlet.error.status_code") != null ) { return false; } + + final Object pipelineName = processContext.getRequest().getAttribute(ATTR_PIPELINE); + if (pipelineName != null && !pipelineName.equals(this.name)) { + return false; + } + String contentType = processContext.getContentType(); // if no content type is supplied, we assume html if ( contentType == null ) { Modified: sling/trunk/contrib/extensions/rewriter/src/test/java/org/apache/sling/rewriter/impl/ProcessorConfigurationImplTest.java URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/rewriter/src/test/java/org/apache/sling/rewriter/impl/ProcessorConfigurationImplTest.java?rev=1777332&r1=1777331&r2=1777332&view=diff ============================================================================== --- sling/trunk/contrib/extensions/rewriter/src/test/java/org/apache/sling/rewriter/impl/ProcessorConfigurationImplTest.java (original) +++ sling/trunk/contrib/extensions/rewriter/src/test/java/org/apache/sling/rewriter/impl/ProcessorConfigurationImplTest.java Wed Jan 4 16:14:53 2017 @@ -175,4 +175,18 @@ public class ProcessorConfigurationImplT assertMatch(ImmutableMap.of(PROPERTY_SELECTORS, new String[] {"sel1"})); } + @Test + public void testNoMatchRequestAttribute() { + context.request().setAttribute(ProcessorConfigurationImpl.ATTR_PIPELINE, "config2"); + context.requestPathInfo().setResourcePath("/content/test"); + assertNoMatch(ImmutableMap.of(PROPERTY_PATHS, new String[] {"/apps","/content"})); + } + + @Test + public void testNoMatchRequestAttributeIfConditionsDoNotMatch() { + context.request().setAttribute(ProcessorConfigurationImpl.ATTR_PIPELINE, "config"); + context.requestPathInfo().setResourcePath("/content/test"); + assertNoMatch(ImmutableMap.of(PROPERTY_PATHS, new String[] {"/apps"})); + } + }