This is an automated email from the ASF dual-hosted git repository.
cziegeler pushed a commit to branch master
in repository
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-rewriter.git
The following commit(s) were added to refs/heads/master by this push:
new 24ee302 SLING-12299 : Support global transformers in error pipelines
24ee302 is described below
commit 24ee302deaee25fe87b27db5549e627b56535b3d
Author: Carsten Ziegeler <[email protected]>
AuthorDate: Thu Apr 18 18:11:46 2024 +0200
SLING-12299 : Support global transformers in error pipelines
---
.../apache/sling/rewriter/impl/FactoryCache.java | 9 +++++++--
.../rewriter/impl/ProcessorConfigurationImpl.java | 23 +++++++++++-----------
2 files changed, 19 insertions(+), 13 deletions(-)
diff --git a/src/main/java/org/apache/sling/rewriter/impl/FactoryCache.java
b/src/main/java/org/apache/sling/rewriter/impl/FactoryCache.java
index a8f2b46..de4b8c6 100644
--- a/src/main/java/org/apache/sling/rewriter/impl/FactoryCache.java
+++ b/src/main/java/org/apache/sling/rewriter/impl/FactoryCache.java
@@ -64,6 +64,9 @@ public class FactoryCache {
/** The optional property for the resource types the component should
apply to */
private static final String PROPERTY_RESOURCE_TYPES =
"pipeline.resourceTypes";
+ /** The optional property if the component also processes error responses
(default is no) */
+ private static final String PROPERTY_PROCESS_ERROR =
"pipeline.processError";
+
/** The logger. */
static final Logger LOGGER = LoggerFactory.getLogger(FactoryCache.class);
@@ -236,13 +239,15 @@ public class FactoryCache {
final String[] contentTypes =
c.convert(ref.getProperty(PROPERTY_CONTENT_TYPES)).to(String[].class);
final String[] resourceTypes =
c.convert(ref.getProperty(PROPERTY_RESOURCE_TYPES)).to(String[].class);
final String[] selectors =
c.convert(ref.getProperty(PROPERTY_SELECTORS)).to(String[].class);
+ final boolean processError =
c.convert(ref.getProperty(PROPERTY_PROCESS_ERROR)).defaultValue(false).to(Boolean.class);
final boolean noCheckRequired = (paths == null || paths.length ==
0) &&
(extensions == null || extensions.length ==
0) &&
(contentTypes == null ||
contentTypes.length == 0) &&
(resourceTypes == null ||
resourceTypes.length == 0) &&
- (selectors == null || selectors.length ==
0);
+ (selectors == null || selectors.length ==
0) &&
+ !processError;
if ( !noCheckRequired ) {
- this.configuration = new
ProcessorConfigurationImpl(contentTypes, paths, extensions, resourceTypes,
selectors);
+ this.configuration = new
ProcessorConfigurationImpl(contentTypes, paths, extensions, resourceTypes,
selectors, processError);
} else {
this.configuration = null;
}
diff --git
a/src/main/java/org/apache/sling/rewriter/impl/ProcessorConfigurationImpl.java
b/src/main/java/org/apache/sling/rewriter/impl/ProcessorConfigurationImpl.java
index f60622d..d0845c6 100644
---
a/src/main/java/org/apache/sling/rewriter/impl/ProcessorConfigurationImpl.java
+++
b/src/main/java/org/apache/sling/rewriter/impl/ProcessorConfigurationImpl.java
@@ -119,11 +119,12 @@ public class ProcessorConfigurationImpl implements
PipelineConfiguration {
/**
* This is the constructor for a pipeline
*/
- public ProcessorConfigurationImpl(String[] contentTypes,
- String[] paths,
- String[] extensions,
- String[] resourceTypes,
- String[] selectors) {
+ public ProcessorConfigurationImpl(final String[] contentTypes,
+ final String[] paths,
+ final String[] extensions,
+ final String[] resourceTypes,
+ final String[] selectors,
+ final boolean processError) {
this.name = null;
this.contentTypes = contentTypes != null && contentTypes.length == 0 ?
null : contentTypes;
this.resourceTypes = resourceTypes != null && resourceTypes.length ==
0 ? null : resourceTypes;
@@ -139,7 +140,7 @@ public class ProcessorConfigurationImpl implements
PipelineConfiguration {
this.isActive = true;
this.isValid = true;
this.isPipeline = true;
- this.processErrorResponse = false;
+ this.processErrorResponse = processError;
this.descString = this.buildDescString();
}
@@ -211,6 +212,8 @@ public class ProcessorConfigurationImpl implements
PipelineConfiguration {
pw.print("Extensions : ");
pw.println(Arrays.toString(this.extensions));
}
+ pw.print("Process Error Response : ");
+ pw.println(this.processErrorResponse);
if (this.name != null) {
pw.print("Order : ");
pw.println(this.order);
@@ -218,8 +221,6 @@ public class ProcessorConfigurationImpl implements
PipelineConfiguration {
pw.println(this.isActive);
pw.print("Valid : ");
pw.println(this.isValid);
- pw.print("Process Error Response : ");
- pw.println(this.processErrorResponse);
if ( this.isPipeline ) {
pw.println("Pipeline : ");
pw.println(" Generator : ");
@@ -276,8 +277,10 @@ public class ProcessorConfigurationImpl implements
PipelineConfiguration {
if ( this.extensions != null ) {
sb.append("extensions=");
sb.append(Arrays.toString(this.extensions));
- sb.append(", ");
}
+ sb.append("processErrorResponse=");
+ sb.append(this.processErrorResponse);
+ sb.append(", ");
if (this.name != null) {
sb.append("order=");
sb.append(this.order);
@@ -285,8 +288,6 @@ public class ProcessorConfigurationImpl implements
PipelineConfiguration {
sb.append(this.isActive);
sb.append(", valid=");
sb.append(this.isValid);
- sb.append(", processErrorResponse=");
- sb.append(this.processErrorResponse);
if ( this.isPipeline ) {
sb.append(", pipeline=(generator=");
sb.append(this.generatorConfiguration);