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 2026/05/29 13:07:58 UTC
(sling-org-apache-sling-pipes) branch update-sling-bundle-parent-66 created (now 5aa39f2)
This is an automated email from the ASF dual-hosted git repository.
cziegeler pushed a change to branch update-sling-bundle-parent-66
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-pipes.git
at 5aa39f2 chore: Update to Sling Bundle Parent 66
This branch includes the following new commits:
new 5aa39f2 chore: Update to Sling Bundle Parent 66
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(sling-org-apache-sling-pipes) 01/01: chore: Update to Sling Bundle Parent 66
Posted by cz...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
cziegeler pushed a commit to branch update-sling-bundle-parent-66
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-pipes.git
commit 5aa39f23d7877d101cc127028d963f0b211d5051
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Fri May 29 15:07:44 2026 +0200
chore: Update to Sling Bundle Parent 66
---
pom.xml | 810 +++++++++++----------
.../sling/pipes/AbstractInputStreamPipe.java | 70 +-
src/main/java/org/apache/sling/pipes/BasePipe.java | 119 +--
.../org/apache/sling/pipes/BindingProvider.java | 32 +-
.../org/apache/sling/pipes/CommandExecutor.java | 30 +-
.../java/org/apache/sling/pipes/CommandUtil.java | 65 +-
.../org/apache/sling/pipes/ExecutionResult.java | 42 +-
.../java/org/apache/sling/pipes/OutputWriter.java | 52 +-
src/main/java/org/apache/sling/pipes/Pipe.java | 36 +-
.../java/org/apache/sling/pipes/PipeBindings.java | 94 +--
.../java/org/apache/sling/pipes/PipeBuilder.java | 32 +-
.../java/org/apache/sling/pipes/PipeExecutor.java | 29 +-
src/main/java/org/apache/sling/pipes/Plumber.java | 48 +-
.../java/org/apache/sling/pipes/PlumberMXBean.java | 27 +-
.../java/org/apache/sling/pipes/SuperPipe.java | 63 +-
.../org/apache/sling/pipes/internal/ACLPipe.java | 114 +--
.../pipes/internal/AbstractPlumberServlet.java | 32 +-
.../sling/pipes/internal/AuthorizablePipe.java | 69 +-
.../sling/pipes/internal/CommandExecutorImpl.java | 222 +++---
.../apache/sling/pipes/internal/ContainerPipe.java | 55 +-
.../org/apache/sling/pipes/internal/CsvWriter.java | 48 +-
.../apache/sling/pipes/internal/FilterPipe.java | 76 +-
.../apache/sling/pipes/internal/GogoCommands.java | 54 +-
.../org/apache/sling/pipes/internal/JsonUtil.java | 56 +-
.../apache/sling/pipes/internal/JsonWriter.java | 47 +-
.../apache/sling/pipes/internal/ManifoldPipe.java | 70 +-
.../org/apache/sling/pipes/internal/MovePipe.java | 61 +-
.../sling/pipes/internal/MultiPropertyPipe.java | 49 +-
.../org/apache/sling/pipes/internal/NopWriter.java | 36 +-
.../org/apache/sling/pipes/internal/NotPipe.java | 34 +-
.../apache/sling/pipes/internal/PackagePipe.java | 46 +-
.../org/apache/sling/pipes/internal/PathPipe.java | 44 +-
.../sling/pipes/internal/PipeBuilderImpl.java | 233 ++++--
.../apache/sling/pipes/internal/PipeMonitor.java | 49 +-
.../sling/pipes/internal/PipeMonitorMBean.java | 30 +-
.../apache/sling/pipes/internal/PlumberImpl.java | 225 +++---
.../sling/pipes/internal/PlumberServlet.java | 104 +--
.../apache/sling/pipes/internal/ReferencePipe.java | 39 +-
.../apache/sling/pipes/internal/RemovePipe.java | 62 +-
.../sling/pipes/internal/ShallowReferencePipe.java | 32 +-
.../apache/sling/pipes/internal/TraversePipe.java | 52 +-
.../org/apache/sling/pipes/internal/WritePipe.java | 93 +--
.../org/apache/sling/pipes/internal/XPathPipe.java | 35 +-
.../pipes/internal/bindings/ConfigurationMap.java | 39 +-
.../sling/pipes/internal/bindings/JxltEngine.java | 26 +-
.../sling/pipes/internal/bindings/TimeUtil.java | 28 +-
.../sling/pipes/internal/inputstream/CsvPipe.java | 54 +-
.../sling/pipes/internal/inputstream/JsonPipe.java | 94 +--
.../pipes/internal/inputstream/RegexpPipe.java | 59 +-
.../AbstractExpressionSlingQueryPipe.java | 29 +-
.../slingquery/AbstractSlingQueryPipe.java | 33 +-
.../pipes/internal/slingquery/ChildrenPipe.java | 29 +-
.../pipes/internal/slingquery/ClosestPipe.java | 26 +-
.../sling/pipes/internal/slingquery/FindPipe.java | 26 +-
.../pipes/internal/slingquery/ParentPipe.java | 28 +-
.../pipes/internal/slingquery/ParentsPipe.java | 28 +-
.../pipes/internal/slingquery/SiblingsPipe.java | 28 +-
.../org/apache/sling/pipes/models/PipeModel.java | 47 +-
.../org/apache/sling/pipes/AbstractPipeTest.java | 68 +-
.../java/org/apache/sling/pipes/BasePipeTest.java | 91 ++-
.../org/apache/sling/pipes/CommandUtilTest.java | 107 ++-
.../org/apache/sling/pipes/ContainerPipeTest.java | 79 +-
.../org/apache/sling/pipes/ManifoldPipeTest.java | 49 +-
.../org/apache/sling/pipes/OutputWriterTest.java | 62 +-
.../org/apache/sling/pipes/PipeBindingsTest.java | 114 +--
.../org/apache/sling/pipes/PipeBuilderTest.java | 125 ++--
.../pipes/PipeExternalScriptingBindingsTest.java | 57 +-
.../org/apache/sling/pipes/TestConfiguration.java | 28 +-
.../org/apache/sling/pipes/dummies/DummyNull.java | 32 +-
.../apache/sling/pipes/dummies/DummySearch.java | 43 +-
.../apache/sling/pipes/internal/ACLPipeTest.java | 126 ++--
.../pipes/internal/CommandExecutorImplTest.java | 175 +++--
.../sling/pipes/internal/FilterPipeTest.java | 76 +-
.../sling/pipes/internal/JCRWritePipeTest.java | 53 +-
.../apache/sling/pipes/internal/MovePipeTest.java | 59 +-
.../pipes/internal/MultiPropertyPipeTest.java | 50 +-
.../apache/sling/pipes/internal/NotPipeTest.java | 33 +-
.../sling/pipes/internal/PackagePipeTest.java | 32 +-
.../apache/sling/pipes/internal/PathPipeTest.java | 70 +-
.../sling/pipes/internal/PipeBuilderImplTest.java | 48 +-
.../sling/pipes/internal/PlumberImplTest.java | 55 +-
.../sling/pipes/internal/PlumberServletTest.java | 136 ++--
.../sling/pipes/internal/ReferencePipeTest.java | 85 ++-
.../sling/pipes/internal/RemovePipeTest.java | 39 +-
.../pipes/internal/ShallowReferencePipeTest.java | 49 +-
.../sling/pipes/internal/TraversePipeTest.java | 80 +-
.../apache/sling/pipes/internal/WritePipeTest.java | 115 ++-
.../pipes/internal/bindings/JxltEngineTest.java | 45 +-
.../pipes/internal/bindings/TimeUtilTest.java | 32 +-
.../pipes/internal/inputstream/CsvPipeTest.java | 59 +-
.../pipes/internal/inputstream/JsonPipeTest.java | 124 ++--
.../pipes/internal/inputstream/RegexpPipeTest.java | 110 ++-
.../internal/slingquery/ChildrenPipeTest.java | 30 +-
.../pipes/internal/slingquery/ClosestPipeTest.java | 36 +-
.../pipes/internal/slingquery/ParentPipeTest.java | 36 +-
.../pipes/internal/slingquery/ParentsPipeTest.java | 36 +-
.../internal/slingquery/SiblingsPipeTest.java | 38 +-
.../org/apache/sling/pipes/it/PipeBuilderIT.java | 37 +-
.../org/apache/sling/pipes/it/PipeModelIT.java | 33 +-
.../apache/sling/pipes/it/PipesTestSupport.java | 81 ++-
.../apache/sling/pipes/it/PlumberServletIT.java | 60 +-
.../org/apache/sling/pipes/it/PlumberTestIT.java | 7 +-
.../apache/sling/pipes/models/PipeModelTest.java | 45 +-
103 files changed, 4005 insertions(+), 3130 deletions(-)
diff --git a/pom.xml b/pom.xml
index 7a9a6dc..1da9342 100644
--- a/pom.xml
+++ b/pom.xml
@@ -19,396 +19,438 @@
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
+ <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.sling</groupId>
- <artifactId>sling-bundle-parent</artifactId>
- <version>49</version>
- <relativePath />
- </parent>
+ <parent>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>sling-bundle-parent</artifactId>
+ <version>66</version>
+ <relativePath />
+ </parent>
- <artifactId>org.apache.sling.pipes</artifactId>
- <version>4.5.3-SNAPSHOT</version>
+ <artifactId>org.apache.sling.pipes</artifactId>
+ <version>4.5.3-SNAPSHOT</version>
- <name>Apache Sling Pipes</name>
- <description>bulk content changes tool</description>
+ <name>Apache Sling Pipes</name>
+ <description>bulk content changes tool</description>
- <properties>
- <sling.java.version>8</sling.java.version>
- <org.ops4j.pax.exam.version>4.13.3</org.ops4j.pax.exam.version>
- <project.build.outputTimestamp>1771500593</project.build.outputTimestamp>
- <maven.compiler.source>8</maven.compiler.source>
- <maven.compiler.target>8</maven.compiler.target>
- </properties>
+ <scm>
+ <connection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-pipes.git</connection>
+ <developerConnection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-pipes.git</developerConnection>
+ <tag>org.apache.sling.pipes-4.5.2</tag>
+ <url>https://github.com/apache/sling-org-apache-sling-pipes.git</url>
+ </scm>
- <scm>
- <connection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-pipes.git</connection>
- <developerConnection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-pipes.git</developerConnection>
- <url>https://github.com/apache/sling-org-apache-sling-pipes.git</url>
- <tag>org.apache.sling.pipes-4.5.2</tag>
- </scm>
+ <properties>
+ <sling.java.version>8</sling.java.version>
+ <org.ops4j.pax.exam.version>4.14.0</org.ops4j.pax.exam.version>
+ <project.build.outputTimestamp>1771500593</project.build.outputTimestamp>
+ <maven.compiler.source>8</maven.compiler.source>
+ <maven.compiler.target>8</maven.compiler.target>
+ </properties>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <executions>
- <execution>
- <id>copy-dependency</id>
- <goals>
- <goal>copy-dependencies</goal>
- </goals>
- <configuration>
- <includeArtifactIds>commons-jexl3</includeArtifactIds>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>biz.aQute.bnd</groupId>
- <artifactId>bnd-maven-plugin</artifactId>
- </plugin>
- <plugin>
- <groupId>biz.aQute.bnd</groupId>
- <artifactId>bnd-baseline-maven-plugin</artifactId>
- </plugin>
- <plugin>
- <groupId>org.apache.servicemix.tooling</groupId>
- <artifactId>depends-maven-plugin</artifactId>
- </plugin>
- <plugin>
- <groupId>org.apache.rat</groupId>
- <artifactId>apache-rat-plugin</artifactId>
- <configuration>
- <excludes combine.children="append">
- <!-- test csv files can't have licenses embedded -->
- <exclude>src/test/resources/**/*.csv</exclude>
- <exclude>src/test/resources/OSGI-INF/*.xml</exclude>
- </excludes>
- </configuration>
- </plugin>
- </plugins>
- </build>
- <profiles>
- <profile>
- <id>integration-tests</id>
- <activation>
- <activeByDefault>true</activeByDefault>
- </activation>
- <build>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.jcr.contentparser</artifactId>
+ <version>1.2.2</version>
+ <scope>provided</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>*</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>javax.servlet-api</artifactId>
+ <version>3.1.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.annotation.versioning</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.service.component.annotations</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.service.metatype.annotations</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.service.event</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.service.log</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.framework</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.service.component</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.service.cm</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.jcr</groupId>
+ <artifactId>jcr</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.api</artifactId>
+ <version>2.22.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.7.36</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.query</artifactId>
+ <version>4.0.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.jackrabbit</groupId>
+ <artifactId>jackrabbit-api</artifactId>
+ <version>2.19.3</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.distribution.api</artifactId>
+ <version>0.3.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-lang3</artifactId>
+ <version>3.18.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-collections4</artifactId>
+ <version>4.1</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>2.14.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.event.api</artifactId>
+ <version>1.0.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.jcr.resource</artifactId>
+ <version>2.7.4</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-json_1.0_spec</artifactId>
+ <version>1.0-alpha-1</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.models.api</artifactId>
+ <version>1.3.8</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.jackrabbit.vault</groupId>
+ <artifactId>org.apache.jackrabbit.vault</artifactId>
+ <version>3.1.44</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.jackrabbit</groupId>
+ <artifactId>jackrabbit-jcr-commons</artifactId>
+ <version>2.22.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-jexl3</artifactId>
+ <version>3.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.caconfig.api</artifactId>
+ <version>1.1.2</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.caconfig.spi</artifactId>
+ <version>1.3.4</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jetbrains</groupId>
+ <artifactId>annotations</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <!-- testing -->
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <version>1.7.36</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <version>4.11.0</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.testing.sling-mock.junit4</artifactId>
+ <version>3.6.2</version>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.jackrabbit</groupId>
+ <artifactId>oak-jcr</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.testing.sling-mock-oak</artifactId>
+ <version>3.1.0-1.40.0</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.openjdk.nashorn</groupId>
+ <artifactId>nashorn-core</artifactId>
+ <version>15.7</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ <version>2.6</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ <version>20.0</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.auth.core</artifactId>
+ <version>1.3.22</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.models.impl</artifactId>
+ <version>1.4.16</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.resource.presence</artifactId>
+ <version>0.0.2</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam</artifactId>
+ <version>${org.ops4j.pax.exam.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam-cm</artifactId>
+ <version>${org.ops4j.pax.exam.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam-container-forked</artifactId>
+ <version>${org.ops4j.pax.exam.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam-junit4</artifactId>
+ <version>${org.ops4j.pax.exam.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam-link-mvn</artifactId>
+ <version>${org.ops4j.pax.exam.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.testing.paxexam</artifactId>
+ <version>4.1.2</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jsoup</groupId>
+ <artifactId>jsoup</artifactId>
+ <version>1.15.3</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.servicemix.bundles</groupId>
+ <artifactId>org.apache.servicemix.bundles.hamcrest</artifactId>
+ <version>1.3_1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.commons.johnzon</artifactId>
+ <version>1.0.0</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.framework</artifactId>
+ <version>7.0.5</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.google.code.gson</groupId>
+ <artifactId>gson</artifactId>
+ <version>2.8.9</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.groovy</groupId>
+ <artifactId>groovy-all</artifactId>
+ <version>2.4.21</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.github.tomakehurst</groupId>
+ <artifactId>wiremock-jre8-standalone</artifactId>
+ <version>2.35.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.testing.caconfig-mock-plugin</artifactId>
+ <version>1.4.0</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
<plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-failsafe-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>integration-test</goal>
- <goal>verify</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <redirectTestOutputToFile>true</redirectTestOutputToFile>
- <systemProperties>
- <property>
- <name>bundle.filename</name>
- <value>${basedir}/target/${project.build.finalName}.jar</value>
- </property>
- </systemProperties>
- </configuration>
- </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-dependency</id>
+ <goals>
+ <goal>copy-dependencies</goal>
+ </goals>
+ <configuration>
+ <includeArtifactIds>commons-jexl3</includeArtifactIds>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>biz.aQute.bnd</groupId>
+ <artifactId>bnd-maven-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>biz.aQute.bnd</groupId>
+ <artifactId>bnd-baseline-maven-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.servicemix.tooling</groupId>
+ <artifactId>depends-maven-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.rat</groupId>
+ <artifactId>apache-rat-plugin</artifactId>
+ <configuration>
+ <excludes combine.children="append">
+ <!-- test csv files can't have licenses embedded -->
+ <exclude>src/test/resources/**/*.csv</exclude>
+ <exclude>src/test/resources/OSGI-INF/*.xml</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
</plugins>
- </build>
- </profile>
- </profiles>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.jcr.contentparser</artifactId>
- <version>1.2.2</version>
- <scope>provided</scope>
- <exclusions>
- <exclusion>
- <groupId>*</groupId>
- <artifactId>*</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>javax.servlet-api</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.annotation.versioning</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.service.component.annotations</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.service.metatype.annotations</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>osgi.cmpn</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>osgi.core</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>javax.jcr</groupId>
- <artifactId>jcr</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.api</artifactId>
- <version>2.16.0</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.query</artifactId>
- <version>4.0.0</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.jackrabbit</groupId>
- <artifactId>jackrabbit-api</artifactId>
- <version>2.14.0</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.distribution.api</artifactId>
- <version>0.3.0</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-lang3</artifactId>
- <version>3.18.0</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-collections4</artifactId>
- <version>4.1</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- <version>2.14.0</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.event.api</artifactId>
- <version>1.0.0</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.jcr.resource</artifactId>
- <version>2.7.4</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-json_1.0_spec</artifactId>
- <version>1.0-alpha-1</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.models.api</artifactId>
- <version>1.3.2</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.jackrabbit.vault</groupId>
- <artifactId>org.apache.jackrabbit.vault</artifactId>
- <version>3.1.44</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.jackrabbit</groupId>
- <artifactId>jackrabbit-jcr-commons</artifactId>
- <version>2.14.0</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-jexl3</artifactId>
- <version>3.0</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <artifactId>org.apache.sling.caconfig.api</artifactId>
- <version>1.1.2</version>
- <groupId>org.apache.sling</groupId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <artifactId>org.apache.sling.caconfig.spi</artifactId>
- <version>1.3.4</version>
- <groupId>org.apache.sling</groupId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.jetbrains</groupId>
- <artifactId>annotations</artifactId>
- <scope>provided</scope>
- </dependency>
- <!-- testing -->
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-simple</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
- <version>1.9.5</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.testing.sling-mock.junit4</artifactId>
- <version>2.6.2</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.testing.jcr-mock</artifactId>
- <version>1.3.2</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.testing.sling-mock-oak</artifactId>
- <version>2.1.0</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.auth.core</artifactId>
- <version>1.3.22</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.resource.presence</artifactId>
- <version>0.0.2</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.exam</groupId>
- <artifactId>pax-exam</artifactId>
- <version>${org.ops4j.pax.exam.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.exam</groupId>
- <artifactId>pax-exam-cm</artifactId>
- <version>${org.ops4j.pax.exam.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.exam</groupId>
- <artifactId>pax-exam-container-forked</artifactId>
- <version>${org.ops4j.pax.exam.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.exam</groupId>
- <artifactId>pax-exam-junit4</artifactId>
- <version>${org.ops4j.pax.exam.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.exam</groupId>
- <artifactId>pax-exam-link-mvn</artifactId>
- <version>${org.ops4j.pax.exam.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.testing.paxexam</artifactId>
- <version>3.1.0</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jsoup</groupId>
- <artifactId>jsoup</artifactId>
- <version>1.15.3</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.servicemix.bundles</groupId>
- <artifactId>org.apache.servicemix.bundles.hamcrest</artifactId>
- <version>1.3_1</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.commons.johnzon</artifactId>
- <version>1.0.0</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.framework</artifactId>
- <version>6.0.3</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>com.google.code.gson</groupId>
- <artifactId>gson</artifactId>
- <version>2.8.9</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.codehaus.groovy</groupId>
- <artifactId>groovy-all</artifactId>
- <version>2.4.21</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>com.github.tomakehurst</groupId>
- <artifactId>wiremock-jre8-standalone</artifactId>
- <version>2.35.1</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.testing.caconfig-mock-plugin</artifactId>
- <scope>test</scope>
- <version>1.4.0</version>
- </dependency>
- </dependencies>
+ </build>
+ <profiles>
+ <profile>
+ <id>integration-tests</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ <configuration>
+ <redirectTestOutputToFile>true</redirectTestOutputToFile>
+ <systemProperties>
+ <property>
+ <name>bundle.filename</name>
+ <value>${basedir}/target/${project.build.finalName}.jar</value>
+ </property>
+ </systemProperties>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>integration-test</goal>
+ <goal>verify</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
</project>
diff --git a/src/main/java/org/apache/sling/pipes/AbstractInputStreamPipe.java b/src/main/java/org/apache/sling/pipes/AbstractInputStreamPipe.java
index e11a0aa..83ceef1 100644
--- a/src/main/java/org/apache/sling/pipes/AbstractInputStreamPipe.java
+++ b/src/main/java/org/apache/sling/pipes/AbstractInputStreamPipe.java
@@ -1,35 +1,28 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes;
-import static org.apache.commons.lang3.StringUtils.EMPTY;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.sling.api.resource.Resource;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.io.ByteArrayInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
-import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.nio.charset.StandardCharsets;
@@ -39,6 +32,14 @@ import java.util.Iterator;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.sling.api.resource.Resource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.apache.commons.lang3.StringUtils.EMPTY;
+
/**
* Input Stream based pipe, coming from web, from request, resource tree, web
* binding is updated by the returned iterator
@@ -63,9 +64,9 @@ public abstract class AbstractInputStreamPipe extends BasePipe {
private static final String METHOD_POST = "POST";
- private static final String HEADER_TYPE ="Content-Type";
+ private static final String HEADER_TYPE = "Content-Type";
- private static final String HEADER_LENGTH ="Content-Length";
+ private static final String HEADER_LENGTH = "Content-Length";
private static final String QUERY_CHAR = "?";
@@ -87,7 +88,7 @@ public abstract class AbstractInputStreamPipe extends BasePipe {
}
void addHeaders(URLConnection connection) {
- connection.setRequestProperty( "charset", "utf-8");
+ connection.setRequestProperty("charset", "utf-8");
Collection<String> headers = properties.keySet().stream()
.filter(k -> k.startsWith(HEADER_PREFIX))
.map(s -> StringUtils.substringAfter(s, HEADER_PREFIX))
@@ -97,7 +98,7 @@ public abstract class AbstractInputStreamPipe extends BasePipe {
String value = getBindings().instantiateExpression(properties.get(HEADER_PREFIX + k, String.class));
connection.setRequestProperty(k, value);
}
- String basicAuth = (String)getBindings().getBindings().get(BASIC_AUTH_BINDINGS);
+ String basicAuth = (String) getBindings().getBindings().get(BASIC_AUTH_BINDINGS);
if (StringUtils.isNotBlank(basicAuth)) {
if (headers.contains(AUTH_HEADER)) {
LOGGER.warn("both authentication header & basic auth are set, ignoring basic auth");
@@ -118,7 +119,7 @@ public abstract class AbstractInputStreamPipe extends BasePipe {
data = StringUtils.substringAfter(expr, QUERY_CHAR);
url = StringUtils.substringBefore(expr, QUERY_CHAR);
} else {
- //we consider POST property value to be the request body
+ // we consider POST property value to be the request body
data = getBindings().instantiateExpression(properties.get(METHOD_POST, String.class));
}
connection = (HttpURLConnection) new URL(url).openConnection();
@@ -128,12 +129,12 @@ public abstract class AbstractInputStreamPipe extends BasePipe {
if (expr.contains(QUERY_CHAR)) {
connection.setRequestProperty(HEADER_TYPE, "application/x-www-form-urlencoded");
}
- connection.setRequestProperty( HEADER_LENGTH, Integer.toString( postDataLength ));
- connection.setDoOutput( true );
- connection.setInstanceFollowRedirects( false );
+ connection.setRequestProperty(HEADER_LENGTH, Integer.toString(postDataLength));
+ connection.setDoOutput(true);
+ connection.setInstanceFollowRedirects(false);
addHeaders(connection);
- try( DataOutputStream wr = new DataOutputStream( connection.getOutputStream())) {
- wr.write( postData );
+ try (DataOutputStream wr = new DataOutputStream(connection.getOutputStream())) {
+ wr.write(postData);
}
return connection;
}
@@ -158,7 +159,8 @@ public abstract class AbstractInputStreamPipe extends BasePipe {
InputStream getInputStream() throws IOException {
String expr = getExpr();
- if (expr.startsWith(REMOTE_START) && !properties.get(PN_URL_MODE, URL_MODE_FETCH).equalsIgnoreCase(URL_MODE_AS_IS)) {
+ if (expr.startsWith(REMOTE_START)
+ && !properties.get(PN_URL_MODE, URL_MODE_FETCH).equalsIgnoreCase(URL_MODE_AS_IS)) {
if (StringUtils.isNotBlank(expr)) {
return getConnection(expr).getInputStream();
}
@@ -170,7 +172,7 @@ public abstract class AbstractInputStreamPipe extends BasePipe {
}
}
if (getBindings().getBindings().get(BINDING_IS) != null) {
- return (InputStream)getBindings().getBindings().get(BINDING_IS);
+ return (InputStream) getBindings().getBindings().get(BINDING_IS);
}
return new ByteArrayInputStream(expr.getBytes(StandardCharsets.UTF_8));
}
@@ -187,7 +189,7 @@ public abstract class AbstractInputStreamPipe extends BasePipe {
try {
is = getInputStream();
return getOutput(is);
- } catch (IOException e) {
+ } catch (IOException e) {
throw new IllegalArgumentException(e);
}
}
diff --git a/src/main/java/org/apache/sling/pipes/BasePipe.java b/src/main/java/org/apache/sling/pipes/BasePipe.java
index 2fffb48..1fa0789 100644
--- a/src/main/java/org/apache/sling/pipes/BasePipe.java
+++ b/src/main/java/org/apache/sling/pipes/BasePipe.java
@@ -1,30 +1,23 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.sling.api.resource.Resource;
-import org.apache.sling.api.resource.ResourceResolver;
-import org.apache.sling.api.resource.ValueMap;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -35,6 +28,15 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.api.resource.ValueMap;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import static org.apache.commons.lang3.StringUtils.EMPTY;
import static org.apache.sling.pipes.PipeBindings.NN_ADDITIONALBINDINGS;
import static org.apache.sling.pipes.PipeBindings.NN_PROVIDERS;
@@ -71,9 +73,18 @@ public class BasePipe implements Pipe {
protected String afterHook;
// used by pipes using complex JCR configurations
- protected static final List<String> IGNORED_PROPERTIES = Arrays.asList("jcr:lastModified", "jcr:primaryType",
- "jcr:created", "jcr:createdBy", "jcr:versionHistory", "jcr:predecessors", "jcr:baseVersion", "jcr:uuid",
- "jcr:isCheckedOut", "jcr:lockIsDeep", "jcr:lockOwner");
+ protected static final List<String> IGNORED_PROPERTIES = Arrays.asList(
+ "jcr:lastModified",
+ "jcr:primaryType",
+ "jcr:created",
+ "jcr:createdBy",
+ "jcr:versionHistory",
+ "jcr:predecessors",
+ "jcr:baseVersion",
+ "jcr:uuid",
+ "jcr:isCheckedOut",
+ "jcr:lockIsDeep",
+ "jcr:lockOwner");
protected static final List<String> IGNORED_NODES = Arrays.asList("rep:policy");
@@ -118,10 +129,10 @@ public class BasePipe implements Pipe {
private void fillInProviders(@NotNull Resource additionalBindings) {
Resource providers = additionalBindings.getChild(NN_PROVIDERS);
- if (providers != null){
+ if (providers != null) {
logger.debug("bindings provider are detected");
bindingProviders = new ArrayList<>();
- for (Resource provider : providers.getChildren()){
+ for (Resource provider : providers.getChildren()) {
Pipe pipe = plumber.getPipe(provider, bindings);
if (pipe == null) {
logger.error("pipe provided in {} is not correct", provider.getPath());
@@ -141,13 +152,13 @@ public class BasePipe implements Pipe {
*/
private void extractAdditionalBindings(@NotNull Resource resource, @Nullable PipeBindings upperBindings) {
bindings = upperBindings == null ? new PipeBindings(plumber, resource) : upperBindings;
- //additional bindings (global variables to use in child pipes expressions)
+ // additional bindings (global variables to use in child pipes expressions)
Resource additionalBindings = resource.getChild(NN_ADDITIONALBINDINGS);
if (additionalBindings != null) {
logger.debug("additional bindings are detected");
ValueMap additionalMap = additionalBindings.adaptTo(ValueMap.class);
bindings.addBindings(additionalMap);
- for (String ignoredProperty : BasePipe.IGNORED_PROPERTIES){
+ for (String ignoredProperty : BasePipe.IGNORED_PROPERTIES) {
bindings.getBindings().remove(ignoredProperty);
}
fillInProviders(additionalBindings);
@@ -156,7 +167,7 @@ public class BasePipe implements Pipe {
if (scriptsResource != null) {
String[] scripts = scriptsResource.adaptTo(String[].class);
if (scripts != null) {
- for (String script : scripts){
+ for (String script : scripts) {
bindings.addScript(resource.getResourceResolver(), script);
}
}
@@ -168,12 +179,13 @@ public class BasePipe implements Pipe {
public boolean isDryRun() {
if (dryRunObject == null) {
dryRunObject = false;
- if ( bindings.isBindingDefined(DRYRUN_KEY)) {
+ if (bindings.isBindingDefined(DRYRUN_KEY)) {
Object run = bindings.instantiateObject(DRYRUN_EXPR);
dryRunObject = true;
if (run instanceof Boolean) {
dryRunObject = (Boolean) run;
- } else if (run == null || (run instanceof String && Boolean.FALSE.toString().equals(run))) {
+ } else if (run == null
+ || (run instanceof String && Boolean.FALSE.toString().equals(run))) {
dryRunObject = false;
}
}
@@ -184,7 +196,8 @@ public class BasePipe implements Pipe {
@Override
public String toString() {
- return name + " " + "(path: " + resource.getPath() + ", dryRun: " + isDryRun() + ", modifiesContent: " + modifiesContent() + ")";
+ return name + " " + "(path: " + resource.getPath() + ", dryRun: " + isDryRun() + ", modifiesContent: "
+ + modifiesContent() + ")";
}
@Override
@@ -193,7 +206,7 @@ public class BasePipe implements Pipe {
}
@Override
- public String getName(){
+ public String getName() {
return name;
}
@@ -243,7 +256,7 @@ public class BasePipe implements Pipe {
* @param path path to be checked
* @return true if path is root (aka not relative)
*/
- protected boolean isRootPath(String path){
+ protected boolean isRootPath(String path) {
return path.startsWith(SLASH);
}
@@ -251,15 +264,15 @@ public class BasePipe implements Pipe {
* Retrieves previous pipe if contained by a parent, or referrer's
* @return pipe before this one or the referrer's can be null in case there is no parent
*/
- protected Pipe getPreviousPipe(){
+ protected Pipe getPreviousPipe() {
return parent != null ? parent.getPreviousPipe(this) : null;
}
/**
* @return previous pipe's output if in a container, null otherwise
*/
- protected Resource getPreviousResource(){
- if (parent != null){
+ protected Resource getPreviousResource() {
+ if (parent != null) {
Pipe previousPipe = getPreviousPipe();
if (previousPipe != null) {
return bindings.getExecutedResource(previousPipe.getName());
@@ -272,17 +285,18 @@ public class BasePipe implements Pipe {
public @Nullable Resource getInput() {
String path = getComputedPath();
Resource input = null;
- if (StringUtils.isNotBlank(path)){
+ if (StringUtils.isNotBlank(path)) {
input = resolver.getResource(path);
if (input == null) {
logger.warn("configured path {} for {} is not found, expect some troubles...", path, getName());
}
} else {
- //no input has been configured: we explicitly expect input to come from previous resource
+ // no input has been configured: we explicitly expect input to come from previous resource
input = getPreviousResource();
if (input == null) {
- logger.warn("no valid path has been configured for {}, and no previous resource to bind on, expect some troubles...",
- getName());
+ logger.warn(
+ "no valid path has been configured for {}, and no previous resource to bind on, expect some troubles...",
+ getName());
}
}
logger.debug("input for this pipe is {}", input != null ? input.getPath() : null);
@@ -291,7 +305,7 @@ public class BasePipe implements Pipe {
@Override
public Object getOutputBinding() {
- if (parent != null){
+ if (parent != null) {
Resource output = bindings.getExecutedResource(getName());
if (output != null) {
return output.adaptTo(ValueMap.class);
@@ -311,14 +325,15 @@ public class BasePipe implements Pipe {
* @throws ExecutionException can happen when a binding provider is executed
*/
protected void provideAdditionalBindings() throws InterruptedException, ExecutionException {
- if (bindingProviders != null && !bindingProviders.isEmpty()){
+ if (bindingProviders != null && !bindingProviders.isEmpty()) {
ExecutorService executor = Executors.newWorkStealingPool();
List<Future<ValueMap>> additionalBindings = executor.invokeAll(bindingProviders);
- for (Future<ValueMap> additionalBinding : additionalBindings){
+ for (Future<ValueMap> additionalBinding : additionalBindings) {
ValueMap binding = additionalBinding.get();
- Pipe pipe = bindingProviders.get(additionalBindings.indexOf(additionalBinding)).getPipe();
- logger.debug("adding binding " +
- "{}={}", pipe.getName(), binding);
+ Pipe pipe = bindingProviders
+ .get(additionalBindings.indexOf(additionalBinding))
+ .getPipe();
+ logger.debug("adding binding " + "{}={}", pipe.getName(), binding);
bindings.addBinding(pipe.getName(), binding);
}
}
@@ -332,11 +347,11 @@ public class BasePipe implements Pipe {
try {
provideAdditionalBindings();
return computeOutput();
- } catch (Exception e){
+ } catch (Exception e) {
String path = getRawPath();
- if (StringUtils.isBlank(path)){
+ if (StringUtils.isBlank(path)) {
Resource input = getPreviousResource();
- if (input != null){
+ if (input != null) {
path = input.getPath();
}
}
@@ -348,14 +363,14 @@ public class BasePipe implements Pipe {
@Override
public void before() {
- if (StringUtils.isNotBlank(beforeHook)){
+ if (StringUtils.isNotBlank(beforeHook)) {
plumber.newPipe(resolver).ref(beforeHook).run();
}
}
@Override
public void after() {
- if (StringUtils.isNotBlank(afterHook)){
+ if (StringUtils.isNotBlank(afterHook)) {
plumber.newPipe(resolver).ref(afterHook).run();
}
}
diff --git a/src/main/java/org/apache/sling/pipes/BindingProvider.java b/src/main/java/org/apache/sling/pipes/BindingProvider.java
index 6241ead..6464a6b 100644
--- a/src/main/java/org/apache/sling/pipes/BindingProvider.java
+++ b/src/main/java/org/apache/sling/pipes/BindingProvider.java
@@ -1,27 +1,29 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes;
-import org.apache.sling.api.resource.Resource;
-import org.apache.sling.api.resource.ValueMap;
-
import java.util.Iterator;
import java.util.concurrent.Callable;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ValueMap;
+
public class BindingProvider implements Callable<ValueMap> {
public BindingProvider(Pipe pipe) {
diff --git a/src/main/java/org/apache/sling/pipes/CommandExecutor.java b/src/main/java/org/apache/sling/pipes/CommandExecutor.java
index e8135c4..ed81e7c 100644
--- a/src/main/java/org/apache/sling/pipes/CommandExecutor.java
+++ b/src/main/java/org/apache/sling/pipes/CommandExecutor.java
@@ -1,20 +1,21 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-
package org.apache.sling.pipes;
import java.lang.reflect.InvocationTargetException;
@@ -39,7 +40,8 @@ public interface CommandExecutor {
* @throws InvocationTargetException can happen in case the mapping with PB api went wrong
* @throws IllegalAccessException can happen in case the mapping with PB api went wrong
*/
- PipeBuilder parse(ResourceResolver resolver, String... commands) throws InvocationTargetException, IllegalAccessException;
+ PipeBuilder parse(ResourceResolver resolver, String... commands)
+ throws InvocationTargetException, IllegalAccessException;
/**
* @return help string
diff --git a/src/main/java/org/apache/sling/pipes/CommandUtil.java b/src/main/java/org/apache/sling/pipes/CommandUtil.java
index 20be5c8..2af5f59 100644
--- a/src/main/java/org/apache/sling/pipes/CommandUtil.java
+++ b/src/main/java/org/apache/sling/pipes/CommandUtil.java
@@ -1,23 +1,23 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes;
-import org.jetbrains.annotations.NotNull;
-
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@@ -28,6 +28,8 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
+import org.jetbrains.annotations.NotNull;
+
import static org.apache.sling.pipes.PipeBindings.INJECTED_SCRIPT_REGEXP;
/**
@@ -42,12 +44,17 @@ public class CommandUtil {
static final String QUOTE = "\"";
static final Pattern MIXINS_ARRAY_PATTERN = Pattern.compile("^\\s*\\[(.*)\\]\\s*$");
- private static final Pattern UNEMBEDDEDSCRIPT_PATTERN = Pattern.compile("^(\\d+(\\.\\d+)?)|" + //21.42
- "\\[.*]$|" + //['one','two']
- "[\\w_\\-]+\\..+|" + //map.field...
- "[\\w_\\-]+\\['.+']|" + //map['field']
- "true$|false$|" + //boolean
- "new .*|" + //instantiation
+ private static final Pattern UNEMBEDDEDSCRIPT_PATTERN = Pattern.compile("^(\\d+(\\.\\d+)?)|" + // 21.42
+ "\\[.*]$|"
+ + // ['one','two']
+ "[\\w_\\-]+\\..+|"
+ + // map.field...
+ "[\\w_\\-]+\\['.+']|"
+ + // map['field']
+ "true$|false$|"
+ + // boolean
+ "new .*|"
+ + // instantiation
"(.*'$)"); // 'string'
static final String EXPR_TOKEN = "([^=]+|" + INJECTED_SCRIPT_REGEXP + ")+";
static final String CONFIGURATION_TOKEN = "\\s*(?<" + FIRST_KEY + ">" + EXPR_TOKEN + ")\\s*" + KEY_VALUE_SEP
@@ -55,8 +62,8 @@ public class CommandUtil {
public static final Pattern CONFIGURATION_PATTERN = Pattern.compile(CONFIGURATION_TOKEN);
private static final String ESCAPED_EQ = "_EQ_";
- private CommandUtil() {
- }
+
+ private CommandUtil() {}
/**
* Checks arguments and throws exception if there is an issue
@@ -64,7 +71,7 @@ public class CommandUtil {
* @throws IllegalArgumentException exception thrown in case arguments are wrong
*/
public static void checkArguments(Object... params) {
- if (params.length % 2 > 0){
+ if (params.length % 2 > 0) {
throw new IllegalArgumentException("there should be an even number of arguments");
}
}
@@ -89,11 +96,11 @@ public class CommandUtil {
* @param embed flag indicating wether or not we should try to embed values in script tags,
* @param params key/value pairs to write into the map
*/
- public static void writeToMap(Map<String, Object> map, boolean embed, Object... params){
+ public static void writeToMap(Map<String, Object> map, boolean embed, Object... params) {
for (int i = 0; i < params.length - 1; i += 2) {
map.put(params[i].toString(), embed ? embedIfNeeded(params[i + 1]) : params[i + 1]);
if (params[i].toString().equals(PN_JCR_MIXIN)) {
- map.put(PN_JCR_MIXIN, handleMixins((String)params[i + 1]));
+ map.put(PN_JCR_MIXIN, handleMixins((String) params[i + 1]));
}
}
}
@@ -103,9 +110,10 @@ public class CommandUtil {
if (matcher.matches()) {
return Arrays.stream(matcher.group(1).split(PAIR_SEP))
.map(String::trim)
- .collect(Collectors.toList()).toArray(new String[0]);
+ .collect(Collectors.toList())
+ .toArray(new String[0]);
}
- return new String[] { value };
+ return new String[] {value};
}
/**
@@ -115,7 +123,7 @@ public class CommandUtil {
*/
public static Map<String, Object> stringToMap(@NotNull String input, UnaryOperator<String> valueTransformer) {
Map<String, Object> map = new HashMap<>();
- for (String pair : input.split(PAIR_SEP) ){
+ for (String pair : input.split(PAIR_SEP)) {
Matcher matcher = CONFIGURATION_PATTERN.matcher(pair);
if (matcher.find()) {
map.put(matcher.group(FIRST_KEY), valueTransformer.apply(matcher.group(SECOND_KEY)));
@@ -152,5 +160,4 @@ public class CommandUtil {
}
return args.toArray(new String[args.size()]);
}
-
}
diff --git a/src/main/java/org/apache/sling/pipes/ExecutionResult.java b/src/main/java/org/apache/sling/pipes/ExecutionResult.java
index 5831131..cc56435 100644
--- a/src/main/java/org/apache/sling/pipes/ExecutionResult.java
+++ b/src/main/java/org/apache/sling/pipes/ExecutionResult.java
@@ -1,33 +1,36 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes;
-import org.apache.sling.api.resource.Resource;
-
import javax.management.openmbean.CompositeData;
import javax.management.openmbean.CompositeDataSupport;
import javax.management.openmbean.CompositeType;
import javax.management.openmbean.OpenDataException;
import javax.management.openmbean.OpenType;
import javax.management.openmbean.SimpleType;
+
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
+import org.apache.sling.api.resource.Resource;
+
/**
* holds results of the execution
*/
@@ -39,11 +42,12 @@ public class ExecutionResult {
static CompositeType getType() {
try {
- return new CompositeType(ExecutionResult.class.getName(),
+ return new CompositeType(
+ ExecutionResult.class.getName(),
"Execution of pipe, with size, and output as pipe configuration defined it",
JMX_NAMES,
new String[] {"total size", "output as string"},
- new OpenType[]{SimpleType.LONG, SimpleType.STRING});
+ new OpenType[] {SimpleType.LONG, SimpleType.STRING});
} catch (OpenDataException e) {
throw new IllegalStateException(e);
}
@@ -80,7 +84,7 @@ public class ExecutionResult {
/**
* Empty the current path set
*/
- public void emptyCurrentSet(){
+ public void emptyCurrentSet() {
currentPathSet.clear();
}
@@ -96,7 +100,7 @@ public class ExecutionResult {
* amount of changed items
* @return total size of changed items
*/
- public long size(){
+ public long size() {
return writer.size;
}
@@ -111,7 +115,7 @@ public class ExecutionResult {
*/
public CompositeData asCompositeData() throws OpenDataException {
if (data == null) {
- data = new CompositeDataSupport(COMPOSITE_TYPE, JMX_NAMES, new Object[]{size(), toString()});
+ data = new CompositeDataSupport(COMPOSITE_TYPE, JMX_NAMES, new Object[] {size(), toString()});
}
return data;
}
diff --git a/src/main/java/org/apache/sling/pipes/OutputWriter.java b/src/main/java/org/apache/sling/pipes/OutputWriter.java
index 734da70..5137fc9 100644
--- a/src/main/java/org/apache/sling/pipes/OutputWriter.java
+++ b/src/main/java/org/apache/sling/pipes/OutputWriter.java
@@ -1,28 +1,23 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.sling.api.SlingHttpServletRequest;
-import org.apache.sling.api.SlingHttpServletResponse;
-import org.apache.sling.api.resource.Resource;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.io.IOException;
import java.io.Writer;
import java.time.Instant;
@@ -35,6 +30,13 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.sling.api.SlingHttpServletRequest;
+import org.apache.sling.api.SlingHttpServletResponse;
+import org.apache.sling.api.resource.Resource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import static org.apache.commons.lang3.StringUtils.EMPTY;
import static org.apache.sling.pipes.CommandUtil.stringToMap;
@@ -96,7 +98,7 @@ public abstract class OutputWriter {
setMax(Integer.parseInt(request.getParameter(PARAM_SIZE)));
}
String writerParam = request.getParameter(PARAM_WRITER);
- if (StringUtils.isNotBlank(writerParam)){
+ if (StringUtils.isNotBlank(writerParam)) {
customOutputs = stringToMap(writerParam, PipeBindings::embedAsScript);
}
setWriter(response.getWriter());
@@ -167,11 +169,9 @@ public abstract class OutputWriter {
*/
protected abstract void writeItem(Resource resource);
-
/**
* writes the end of the output
*/
-
public abstract void ends();
/**
@@ -192,7 +192,7 @@ public abstract class OutputWriter {
public void setPipe(Pipe pipe) {
this.pipe = pipe;
Resource outputs = pipe.getResource().getChild(PARAM_WRITER);
- if (customOutputs == null && outputs != null ){
+ if (customOutputs == null && outputs != null) {
customOutputs = new HashMap<>();
customOutputs.putAll(outputs.getValueMap());
for (String ignoredKey : BasePipe.IGNORED_PROPERTIES) {
@@ -207,8 +207,10 @@ public abstract class OutputWriter {
Object o = pipe.getBindings().instantiateObject((String) customOutputs.get(key));
if (o != null) {
if (o instanceof Calendar) {
- Instant i = ((Calendar)o).toInstant();
- value = DateTimeFormatter.ISO_LOCAL_DATE_TIME.withZone(ZoneId.from(ZoneOffset.UTC)).format(i);
+ Instant i = ((Calendar) o).toInstant();
+ value = DateTimeFormatter.ISO_LOCAL_DATE_TIME
+ .withZone(ZoneId.from(ZoneOffset.UTC))
+ .format(i);
} else {
value = o.toString();
}
diff --git a/src/main/java/org/apache/sling/pipes/Pipe.java b/src/main/java/org/apache/sling/pipes/Pipe.java
index f93a5fa..2deb10f 100644
--- a/src/main/java/org/apache/sling/pipes/Pipe.java
+++ b/src/main/java/org/apache/sling/pipes/Pipe.java
@@ -1,27 +1,29 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes;
+import java.util.Iterator;
+
import org.apache.sling.api.resource.Resource;
import org.jetbrains.annotations.Nullable;
import org.osgi.annotation.versioning.ConsumerType;
-import java.util.Iterator;
-
/**
* Pipe interface
*/
@@ -86,8 +88,8 @@ public interface Pipe {
* configured resource, either previous' pipe output resource
* @return input, configured or previous pipe
*/
- @Nullable Resource getInput();
-
+ @Nullable
+ Resource getInput();
/**
* get the pipe configuration resource
@@ -128,4 +130,4 @@ public interface Pipe {
* @return configured distribution agent
*/
String getDistributionAgent();
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/sling/pipes/PipeBindings.java b/src/main/java/org/apache/sling/pipes/PipeBindings.java
index cbf4cb2..28b12e1 100644
--- a/src/main/java/org/apache/sling/pipes/PipeBindings.java
+++ b/src/main/java/org/apache/sling/pipes/PipeBindings.java
@@ -1,36 +1,30 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.jexl3.JexlException;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.sling.api.resource.Resource;
-import org.apache.sling.api.resource.ResourceResolver;
-import org.jetbrains.annotations.NotNull;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import javax.script.Bindings;
import javax.script.ScriptContext;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
import javax.script.SimpleScriptContext;
+
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
@@ -39,6 +33,15 @@ import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.jexl3.JexlException;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceResolver;
+import org.jetbrains.annotations.NotNull;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
/**
* Execution bindings of a pipe, and all expression related
*/
@@ -71,10 +74,10 @@ public class PipeBindings {
public static final String INJECTED_SCRIPT_REGEXP = "\\$\\{(([^\\{^\\}]+(\\{\\{)?(\\}\\})?(\\{[0-9,]+\\})?)+)\\}";
private static final Pattern INJECTED_SCRIPT = Pattern.compile(INJECTED_SCRIPT_REGEXP);
protected static final String IF_PREFIX = "$if";
- protected static final Pattern CONDITIONAL_STRING = Pattern.compile("^\\" + IF_PREFIX + INJECTED_SCRIPT_REGEXP);
+ protected static final Pattern CONDITIONAL_STRING = Pattern.compile("^\\" + IF_PREFIX + INJECTED_SCRIPT_REGEXP);
ScriptEngine engine;
-
+
ScriptContext scriptContext = new SimpleScriptContext();
Map<String, String> pathBindings = new HashMap<>();
@@ -111,19 +114,19 @@ public class PipeBindings {
*/
public PipeBindings(@NotNull Resource resource, boolean allowAdditionalScripts) {
this.allowAdditionalScripts = allowAdditionalScripts;
- //Setup script engines
+ // Setup script engines
String engineName = resource.getValueMap().get(PN_ENGINE, String.class);
if (StringUtils.isNotBlank(engineName)) {
initializeScriptEngine(engineName);
}
-
- //add path bindings where path.MyPipe will give MyPipe current resource path
+
+ // add path bindings where path.MyPipe will give MyPipe current resource path
getBindings().put(PATH_BINDING, pathBindings);
- //add name bindings where name.MyPipe will give MyPipe current resource name
+ // add name bindings where name.MyPipe will give MyPipe current resource name
getBindings().put(NAME_BINDING, nameBindings);
- //add caconfig bindings where caconfig.MyPipe will give MyPipe current ca configuration
+ // add caconfig bindings where caconfig.MyPipe will give MyPipe current ca configuration
getBindings().put(CACONFIG_BINDING, caconfigBindings);
}
@@ -140,7 +143,7 @@ public class PipeBindings {
* @param name binding's name
* @param value binding's value
*/
- public void addBinding(String name, Object value){
+ public void addBinding(String name, Object value) {
log.debug("Adding binding {}={}", name, value);
getBindings().put(name, value);
}
@@ -230,7 +233,7 @@ public class PipeBindings {
}
private ScriptEngine getEngine() {
- if (engine == null && getBindings().containsKey(PN_ENGINE)){
+ if (engine == null && getBindings().containsKey(PN_ENGINE)) {
initializeScriptEngine((String) getBindings().get(PN_ENGINE));
}
return engine;
@@ -245,8 +248,9 @@ public class PipeBindings {
try {
String computed = computeTemplateExpression(expr);
if (computed != null) {
- return getEngine() != null ? engine.eval(computed, scriptContext) :
- plumber.evaluate(computed, getBindings());
+ return getEngine() != null
+ ? engine.eval(computed, scriptContext)
+ : plumber.evaluate(computed, getBindings());
}
} catch (ScriptException | JexlException e) {
throw new IllegalArgumentException(e);
@@ -270,7 +274,7 @@ public class PipeBindings {
public Bindings getBindings() {
return scriptContext.getBindings(ScriptContext.ENGINE_SCOPE);
}
-
+
/**
* return Pipe <code>name</code>'s F binding
* @param name name of the pipe
@@ -287,12 +291,13 @@ public class PipeBindings {
*/
public void initializeScriptEngine(String engineName) {
engine = new ScriptEngineManager().getEngineByName(engineName);
- if(engine == null){
- //Fallback to system classloader
+ if (engine == null) {
+ // Fallback to system classloader
engine = new ScriptEngineManager(null).getEngineByName(engineName);
- //Check if engine can still not be instantiated
- if(engine == null){
- throw new IllegalArgumentException("Can not instantiate " + engineName + " scriptengine. Check JVM version & capabilities.");
+ // Check if engine can still not be instantiated
+ if (engine == null) {
+ throw new IllegalArgumentException(
+ "Can not instantiate " + engineName + " scriptengine. Check JVM version & capabilities.");
}
}
engine.setContext(scriptContext);
@@ -306,12 +311,13 @@ public class PipeBindings {
*/
public String conditionalString(String conditionalExpression) {
Matcher matcher = CONDITIONAL_STRING.matcher(conditionalExpression);
- if (matcher.find()){
+ if (matcher.find()) {
Object output = evaluate(StringUtils.substringAfter(matcher.group(0), IF_PREFIX));
- if (output != null){
+ if (output != null) {
String s = output.toString().toLowerCase().trim();
- if(StringUtils.isNotEmpty(s) && !"false".equals(s) && !"undefined".equals(s)){
- return instantiateExpression(conditionalExpression.substring(matcher.group(0).length()));
+ if (StringUtils.isNotEmpty(s) && !"false".equals(s) && !"undefined".equals(s)) {
+ return instantiateExpression(
+ conditionalExpression.substring(matcher.group(0).length()));
}
}
} else {
@@ -336,7 +342,7 @@ public class PipeBindings {
* @param name name of the binding
* @return true if <code>name</code> is registered
*/
- public boolean isBindingDefined(String name){
+ public boolean isBindingDefined(String name) {
return getBindings().containsKey(name);
}
@@ -356,7 +362,7 @@ public class PipeBindings {
* @param name name under which static bindings should be recorded
* @param resource resource from which static bindings will be built
*/
- public void updateStaticBindings(String name, Resource resource){
+ public void updateStaticBindings(String name, Resource resource) {
if (resource != null) {
pathBindings.put(name, resource.getPath());
nameBindings.put(name, resource.getName());
diff --git a/src/main/java/org/apache/sling/pipes/PipeBuilder.java b/src/main/java/org/apache/sling/pipes/PipeBuilder.java
index fc7578e..b7ea50e 100644
--- a/src/main/java/org/apache/sling/pipes/PipeBuilder.java
+++ b/src/main/java/org/apache/sling/pipes/PipeBuilder.java
@@ -1,27 +1,29 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes;
+import java.util.Map;
+
import org.apache.sling.api.resource.PersistenceException;
import org.apache.sling.event.jobs.Job;
import org.osgi.annotation.versioning.ProviderType;
-import java.util.Map;
-
/**
* Builder and Runner of a pipe, based on a fluent API, for script and java usage.
*/
@@ -278,7 +280,7 @@ public interface PipeBuilder {
* @param keys properties of the outputs resource to output
* @return current instance of PipeBuilder
*/
- PipeBuilder outputs(String ... keys);
+ PipeBuilder outputs(String... keys);
/**
* builds a configured pipe. The configuration will be placed in a balanced tree under <code>/var/pipes</code>
diff --git a/src/main/java/org/apache/sling/pipes/PipeExecutor.java b/src/main/java/org/apache/sling/pipes/PipeExecutor.java
index 7668442..91dedfb 100644
--- a/src/main/java/org/apache/sling/pipes/PipeExecutor.java
+++ b/src/main/java/org/apache/sling/pipes/PipeExecutor.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes;
@@ -25,7 +27,10 @@ import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
public @interface PipeExecutor {
String command();
+
String resourceType();
+
String description();
+
Class<? extends BasePipe> pipeClass();
}
diff --git a/src/main/java/org/apache/sling/pipes/Plumber.java b/src/main/java/org/apache/sling/pipes/Plumber.java
index 6d0eba4..87db1d1 100644
--- a/src/main/java/org/apache/sling/pipes/Plumber.java
+++ b/src/main/java/org/apache/sling/pipes/Plumber.java
@@ -1,21 +1,28 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes;
+import javax.script.Bindings;
+
+import java.io.IOException;
+import java.util.Map;
+
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
@@ -24,11 +31,6 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.osgi.annotation.versioning.ProviderType;
-import java.io.IOException;
-import java.util.Map;
-
-import javax.script.Bindings;
-
/**
* Plumber is an osgi service aiming to make pipes available to the sling system, in order to
*/
@@ -86,7 +88,8 @@ public interface Plumber {
*
* @return instance of <code>ExecutionResult</code>
*/
- ExecutionResult execute(ResourceResolver resolver, String path, Map<String, Object> bindings, OutputWriter writer, boolean save);
+ ExecutionResult execute(
+ ResourceResolver resolver, String path, Map<String, Object> bindings, OutputWriter writer, boolean save);
/**
* Executes a given pipe
@@ -99,7 +102,8 @@ public interface Plumber {
*
* @return instance of <code>ExecutionResult</code>
*/
- ExecutionResult execute(ResourceResolver resolver, Pipe pipe, Map<String, Object> bindings, OutputWriter writer, boolean save);
+ ExecutionResult execute(
+ ResourceResolver resolver, Pipe pipe, Map<String, Object> bindings, OutputWriter writer, boolean save);
/**
* Registers
@@ -152,7 +156,8 @@ public interface Plumber {
* @return map of bindings
* @throws IOException in case something turns wrong with an input stream
*/
- Map<String, Object> getBindingsFromRequest(SlingHttpServletRequest request, boolean writeAllowed) throws IOException;
+ Map<String, Object> getBindingsFromRequest(SlingHttpServletRequest request, boolean writeAllowed)
+ throws IOException;
/**
* @return service user that has been configured for executing pipes;
@@ -170,7 +175,8 @@ public interface Plumber {
* @param reference reference we are searching a resource for (assuming this is *not* a full path already)
* @return referenced resource, null otherwise
*/
- @Nullable Resource getReferencedResource(Resource referrer, String reference);
+ @Nullable
+ Resource getReferencedResource(Resource referrer, String reference);
/**
* marks a given resource as updated
diff --git a/src/main/java/org/apache/sling/pipes/PlumberMXBean.java b/src/main/java/org/apache/sling/pipes/PlumberMXBean.java
index f3b31eb..7f62ffd 100644
--- a/src/main/java/org/apache/sling/pipes/PlumberMXBean.java
+++ b/src/main/java/org/apache/sling/pipes/PlumberMXBean.java
@@ -1,23 +1,24 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes;
public interface PlumberMXBean {
void refreshMonitoredPipes();
-
}
diff --git a/src/main/java/org/apache/sling/pipes/SuperPipe.java b/src/main/java/org/apache/sling/pipes/SuperPipe.java
index 37df2c6..ae52aa5 100644
--- a/src/main/java/org/apache/sling/pipes/SuperPipe.java
+++ b/src/main/java/org/apache/sling/pipes/SuperPipe.java
@@ -1,29 +1,31 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes;
-import org.apache.sling.api.resource.Resource;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import org.apache.sling.api.resource.Resource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
/**
* Pipe that outputs a configured set of pipes output, managing for them what is their outputs, and bindings
*/
@@ -63,7 +65,7 @@ public abstract class SuperPipe extends BasePipe {
@Override
protected Iterator<Resource> computeOutput() {
- if (subpipes.isEmpty()){
+ if (subpipes.isEmpty()) {
buildChildren();
}
return computeSubpipesOutput();
@@ -90,15 +92,15 @@ public abstract class SuperPipe extends BasePipe {
* @param pipe child pipe of this parent
* @return previous pipe if any
*/
- public Pipe getPreviousPipe(Pipe pipe){
+ public Pipe getPreviousPipe(Pipe pipe) {
Pipe previousPipe = null;
- if (!subpipes.isEmpty()){
- if (subpipes.get(0).equals(pipe) && parent != null){
- //in the case this pipe has a parent, previous pipe is the one of the referrer
+ if (!subpipes.isEmpty()) {
+ if (subpipes.get(0).equals(pipe) && parent != null) {
+ // in the case this pipe has a parent, previous pipe is the one of the referrer
return parent.getPreviousPipe(this);
}
- for (Pipe candidate : subpipes){
- if (candidate.equals(pipe)){
+ for (Pipe candidate : subpipes) {
+ if (candidate.equals(pipe)) {
return previousPipe;
}
previousPipe = candidate;
@@ -113,14 +115,15 @@ public abstract class SuperPipe extends BasePipe {
if (subpipes.isEmpty()) {
buildChildren();
}
- for (Pipe pipe : subpipes){
- if (pipe.modifiesContent()){
+ for (Pipe pipe : subpipes) {
+ if (pipe.modifiesContent()) {
return true;
}
}
return false;
- } catch (Exception e){
- LOG.error("something went wrong while building this pipe, we'll consider this pipe as modifying content", e);
+ } catch (Exception e) {
+ LOG.error(
+ "something went wrong while building this pipe, we'll consider this pipe as modifying content", e);
}
return true;
}
@@ -129,10 +132,10 @@ public abstract class SuperPipe extends BasePipe {
public void before() {
LOG.debug("entering {} before", getName());
super.before();
- if (subpipes.isEmpty()){
+ if (subpipes.isEmpty()) {
buildChildren();
}
- for (Pipe pipe : subpipes){
+ for (Pipe pipe : subpipes) {
LOG.debug("calling {} before", getName());
pipe.before();
}
@@ -142,7 +145,7 @@ public abstract class SuperPipe extends BasePipe {
public void after() {
LOG.debug("entering {} after", getName());
super.after();
- for (Pipe pipe : subpipes){
+ for (Pipe pipe : subpipes) {
LOG.debug("calling {} after", pipe.getName());
pipe.after();
}
diff --git a/src/main/java/org/apache/sling/pipes/internal/ACLPipe.java b/src/main/java/org/apache/sling/pipes/internal/ACLPipe.java
index 6c2b530..6a729c0 100644
--- a/src/main/java/org/apache/sling/pipes/internal/ACLPipe.java
+++ b/src/main/java/org/apache/sling/pipes/internal/ACLPipe.java
@@ -1,22 +1,35 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-
package org.apache.sling.pipes.internal;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.security.AccessControlList;
+import javax.jcr.security.Privilege;
+import javax.json.Json;
+import javax.json.JsonArrayBuilder;
+import javax.json.JsonObjectBuilder;
+
+import java.security.Principal;
+import java.util.Arrays;
+import java.util.Iterator;
+
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.jackrabbit.api.JackrabbitSession;
@@ -33,17 +46,6 @@ import org.apache.sling.pipes.Plumber;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.security.AccessControlList;
-import javax.jcr.security.Privilege;
-import javax.json.Json;
-import javax.json.JsonArrayBuilder;
-import javax.json.JsonObjectBuilder;
-import java.security.Principal;
-import java.util.Arrays;
-import java.util.Iterator;
-
public class ACLPipe extends BasePipe {
private static Logger logger = LoggerFactory.getLogger(ACLPipe.class);
public static final String RESOURCE_TYPE = RT_PREFIX + "acl";
@@ -76,7 +78,7 @@ public class ACLPipe extends BasePipe {
@Override
public boolean modifiesContent() {
- return allow || deny ;
+ return allow || deny;
}
/**
@@ -90,7 +92,7 @@ public class ACLPipe extends BasePipe {
super(plumber, resource, upperBindings);
session = resolver.adaptTo(Session.class);
userManager = resolver.adaptTo(UserManager.class);
- privilegesInput = properties.get(JCR_PRIVILEGES_INPUT, new String[]{});
+ privilegesInput = properties.get(JCR_PRIVILEGES_INPUT, new String[] {});
allow = properties.get(PN_ALLOW, false);
deny = properties.get(PN_DENY, false);
}
@@ -98,12 +100,15 @@ public class ACLPipe extends BasePipe {
Iterator<Resource> computeAllowDenyOutput(Resource resource) throws RepositoryException {
logger.debug("Going to changing ACL for the resource at path {}", resource.getPath());
if (StringUtils.isEmpty(getExpr())) {
- throw new IllegalArgumentException("expression for the principal or authorizable Id should be provided or provided correctly for privileges to be set");
+ throw new IllegalArgumentException(
+ "expression for the principal or authorizable Id should be provided or provided correctly for privileges to be set");
}
Principal principal = getPrincipalFor(getExpr());
if (ArrayUtils.isEmpty(privilegesInput)) {
// create a privilege set with jcr:all if allow or jcr:read if deny
- privileges = allow ? AccessControlUtils.privilegesFromNames(session, Privilege.JCR_ALL) : AccessControlUtils.privilegesFromNames(session, Privilege.JCR_READ);
+ privileges = allow
+ ? AccessControlUtils.privilegesFromNames(session, Privilege.JCR_ALL)
+ : AccessControlUtils.privilegesFromNames(session, Privilege.JCR_READ);
} else {
privilegesInput = processPrivilegesInput(privilegesInput);
privileges = AccessControlUtils.privilegesFromNames(session, privilegesInput);
@@ -113,7 +118,7 @@ public class ACLPipe extends BasePipe {
}
@Override
- public Iterator<Resource> computeOutput() {
+ public Iterator<Resource> computeOutput() {
Resource resource = getInput();
try {
if (resource != null) {
@@ -135,12 +140,12 @@ public class ACLPipe extends BasePipe {
* If current Resource is an Authorizable and authorizable flag is true then ACLs of the authorizablie on repository is put in bindings
* @param resource current resource
*/
-
void bindACLs(Resource resource) {
try {
Authorizable auth = checkIsAuthorizableResource(resource);
- if ( null != auth ) {
- //get privileges for an auth on the repository , authorizable flag should be true if resource is an authorizable
+ if (null != auth) {
+ // get privileges for an auth on the repository , authorizable flag should be true if resource is an
+ // authorizable
bindAclsForAuthorizableResource(auth);
return;
}
@@ -151,10 +156,11 @@ public class ACLPipe extends BasePipe {
for (JackrabbitAccessControlEntry entry : entries) {
JsonObjectBuilder principalPrivilegesMappings = Json.createObjectBuilder();
JsonArrayBuilder privilegeSet = Json.createArrayBuilder();
- for ( Privilege privilege : entry.getPrivileges() ){
+ for (Privilege privilege : entry.getPrivileges()) {
privilegeSet.add(privilege.getName());
}
- principalPrivilegesMappings.add(PN_AUTHORIZABLE, entry.getPrincipal().getName());
+ principalPrivilegesMappings.add(
+ PN_AUTHORIZABLE, entry.getPrincipal().getName());
principalPrivilegesMappings.add(PRIVILEGES_JSON_KEY, privilegeSet);
if (entry.isAllow()) {
principalPrivilegesMappings.add(PN_ALLOW, true);
@@ -164,11 +170,10 @@ public class ACLPipe extends BasePipe {
principalPrivilegesArray.add(principalPrivilegesMappings);
}
outputBinding = JsonUtil.toString(principalPrivilegesArray);
- } catch ( Exception e ) {
+ } catch (Exception e) {
outputBinding = JsonUtil.toString(Json.createObjectBuilder());
logger.error("unable to bind acls", e);
}
-
}
/**
@@ -176,9 +181,8 @@ public class ACLPipe extends BasePipe {
* @param auth current resource as an authorizable
* @throws RepositoryException in case something goes wrong while executing xpath query
*/
-
void bindAclsForAuthorizableResource(Authorizable auth) throws RepositoryException {
- //query for searching in full repository where auth is prinicpal in access control entry.
+ // query for searching in full repository where auth is prinicpal in access control entry.
logger.info("binding acls for authorizable {} and authID {}", auth.getPath(), auth.getID());
String query = "/jcr:root//element(*, rep:ACE)[@rep:principalName = '" + auth.getID() + "']";
Iterator<Resource> resources = resolver.findResources(query, javax.jcr.query.Query.XPATH);
@@ -188,16 +192,15 @@ public class ACLPipe extends BasePipe {
resources.forEachRemaining(res -> {
String[] privilegeSet = res.adaptTo(ValueMap.class).get(PRIVILEGES_KEY, String[].class);
JsonArrayBuilder privilegesArray = Json.createArrayBuilder();
- for(String privilege: privilegeSet){
+ for (String privilege : privilegeSet) {
privilegesArray.add(privilege);
}
JsonObjectBuilder aceObj = Json.createObjectBuilder();
aceObj.add(PATH_KEY, res.getParent().getParent().getPath());
aceObj.add(PRIVILEGES_JSON_KEY, privilegesArray);
- if (res.getResourceType().equals(ACE_GRANT_KEY) ){
+ if (res.getResourceType().equals(ACE_GRANT_KEY)) {
allowArray.add(aceObj);
- }
- else if (res.getResourceType().equals(ACE_DENY_KEY)) {
+ } else if (res.getResourceType().equals(ACE_DENY_KEY)) {
denyArray.add(aceObj);
}
});
@@ -216,17 +219,16 @@ public class ACLPipe extends BasePipe {
* @param prinicipalName for which the principal has to be found
* @return Principal for the principalName
*/
-
Principal getPrincipalFor(String prinicipalName) {
Principal principal = null;
try {
if (StringUtils.isNotBlank(prinicipalName)) {
logger.debug("try to find principalId {}", prinicipalName);
- JackrabbitSession jackrabbitSession = ( JackrabbitSession )session;
+ JackrabbitSession jackrabbitSession = (JackrabbitSession) session;
PrincipalManager principalManager = jackrabbitSession.getPrincipalManager();
principal = principalManager.getPrincipal(prinicipalName);
}
- } catch (Exception e){
+ } catch (Exception e) {
logger.error("unable to get principal for principalName {} ", prinicipalName, e);
}
return principal;
@@ -234,24 +236,32 @@ public class ACLPipe extends BasePipe {
private void addAccessControlEntry(Resource resource, Principal principal) throws RepositoryException {
if (logger.isInfoEnabled()) {
- logger.info("adding privileges {} for principal {} allow {} deny {} with dryRun {} ",
- ArrayUtils.toString(privileges), principal.getName(), allow, deny, isDryRun());
+ logger.info(
+ "adding privileges {} for principal {} allow {} deny {} with dryRun {} ",
+ ArrayUtils.toString(privileges),
+ principal.getName(),
+ allow,
+ deny,
+ isDryRun());
}
if (!isDryRun()) {
if (allow) {
AccessControlUtils.addAccessControlEntry(session, resource.getPath(), principal, this.privileges, true);
} else if (deny) {
- AccessControlUtils.addAccessControlEntry(session, resource.getPath(), principal, this.privileges, false);
+ AccessControlUtils.addAccessControlEntry(
+ session, resource.getPath(), principal, this.privileges, false);
}
}
}
private String[] processPrivilegesInput(String[] privilegesInput) {
String expr = bindings.instantiateExpression(ArrayUtils.toString(privilegesInput));
- if ( expr.indexOf("[") > -1 && expr.indexOf("]") > -1) {
- return Arrays.stream(expr.substring(expr.indexOf("[") + 1, expr.indexOf("]")).split(","))
- .map(String::trim).toArray(size->new String[size]);
+ if (expr.indexOf("[") > -1 && expr.indexOf("]") > -1) {
+ return Arrays.stream(expr.substring(expr.indexOf("[") + 1, expr.indexOf("]"))
+ .split(","))
+ .map(String::trim)
+ .toArray(size -> new String[size]);
}
return privilegesInput;
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/sling/pipes/internal/AbstractPlumberServlet.java b/src/main/java/org/apache/sling/pipes/internal/AbstractPlumberServlet.java
index 0e16a10..ac7cc96 100644
--- a/src/main/java/org/apache/sling/pipes/internal/AbstractPlumberServlet.java
+++ b/src/main/java/org/apache/sling/pipes/internal/AbstractPlumberServlet.java
@@ -1,28 +1,30 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes.internal;
+import java.io.IOException;
+
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.servlets.SlingAllMethodsServlet;
import org.apache.sling.pipes.OutputWriter;
-import java.io.IOException;
-
public class AbstractPlumberServlet extends SlingAllMethodsServlet {
/**
@@ -33,7 +35,7 @@ public class AbstractPlumberServlet extends SlingAllMethodsServlet {
* @throws IOException bad handling of I/O streams,
*/
OutputWriter getWriter(SlingHttpServletRequest request, SlingHttpServletResponse response) throws IOException {
- OutputWriter[] candidates = new OutputWriter[]{new CsvWriter(), new JsonWriter()};
+ OutputWriter[] candidates = new OutputWriter[] {new CsvWriter(), new JsonWriter()};
for (OutputWriter candidate : candidates) {
if (candidate.handleRequest(request)) {
candidate.init(request, response);
diff --git a/src/main/java/org/apache/sling/pipes/internal/AuthorizablePipe.java b/src/main/java/org/apache/sling/pipes/internal/AuthorizablePipe.java
index 1107c34..4b5b16a 100644
--- a/src/main/java/org/apache/sling/pipes/internal/AuthorizablePipe.java
+++ b/src/main/java/org/apache/sling/pipes/internal/AuthorizablePipe.java
@@ -1,21 +1,31 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes.internal;
+import javax.jcr.RepositoryException;
+import javax.json.Json;
+import javax.json.JsonArray;
+import javax.json.JsonArrayBuilder;
+
+import java.util.Collections;
+import java.util.Iterator;
+
import org.apache.commons.lang3.StringUtils;
import org.apache.jackrabbit.api.security.user.Authorizable;
import org.apache.jackrabbit.api.security.user.Group;
@@ -28,13 +38,6 @@ import org.apache.sling.pipes.Plumber;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import javax.jcr.RepositoryException;
-import javax.json.Json;
-import javax.json.JsonArray;
-import javax.json.JsonArrayBuilder;
-import java.util.Collections;
-import java.util.Iterator;
-
/**
* pipe that outputs an authorizable resource based on the id set in expr
*/
@@ -123,7 +126,7 @@ public class AuthorizablePipe extends BasePipe {
auth = userManager.getAuthorizable(authId);
if (auth == null && createGroup) {
logger.info("authorizable {} does not exist, and createGroup flag is set, creating it", authId);
- if (! isDryRun()) {
+ if (!isDryRun()) {
auth = userManager.createGroup(authId);
}
}
@@ -140,19 +143,19 @@ public class AuthorizablePipe extends BasePipe {
* Add current authorizable to configured addToGroup expression (should resolve as a group id)
* @param auth authorizable to add to the group
*/
- void addAuthorizableToGroup(Authorizable auth){
+ void addAuthorizableToGroup(Authorizable auth) {
try {
- //if addToGroup is set to true, we try to find the corresponding
- //group and to add current auth to it as a member
+ // if addToGroup is set to true, we try to find the corresponding
+ // group and to add current auth to it as a member
String groupId = bindings.instantiateExpression(addToGroup);
Authorizable groupAuth = userManager.getAuthorizable(groupId);
if (groupAuth != null && groupAuth.isGroup()) {
logger.info("adding {} to {}", auth.getID(), groupId);
- if (! isDryRun()) {
+ if (!isDryRun()) {
((Group) groupAuth).addMember(auth);
}
}
- } catch (Exception e){
+ } catch (Exception e) {
logger.error("Unable to add current authorizable to group {}", addToGroup, e);
}
}
@@ -164,10 +167,10 @@ public class AuthorizablePipe extends BasePipe {
void addMembersToAuthorizable(Authorizable auth) {
try {
if (auth.isGroup()) {
- Group group = (Group)auth;
+ Group group = (Group) auth;
String uids = bindings.instantiateExpression(addMembers);
JsonArray array = JsonUtil.parseArray(uids);
- for (int index = 0; index < array.size(); index ++){
+ for (int index = 0; index < array.size(); index++) {
String uid = array.getString(index);
Authorizable member = userManager.getAuthorizable(uid);
if (member != null) {
@@ -182,7 +185,7 @@ public class AuthorizablePipe extends BasePipe {
} else {
logger.error("{} is not a group, can't add members", auth.getID());
}
- } catch (Exception e){
+ } catch (Exception e) {
logger.error("unable to add members {}", addMembers, e);
}
}
@@ -191,20 +194,20 @@ public class AuthorizablePipe extends BasePipe {
* add current group's members to the bindings
* @param auth group whose members should be bound in the pipe bindings
*/
- void bindMembersToAuthorizable(Authorizable auth){
+ void bindMembersToAuthorizable(Authorizable auth) {
try {
- if (auth.isGroup()){
- Group group = (Group)auth;
+ if (auth.isGroup()) {
+ Group group = (Group) auth;
Iterator<Authorizable> memberIterator = group.getMembers();
JsonArrayBuilder array = Json.createArrayBuilder();
- while (memberIterator.hasNext()){
+ while (memberIterator.hasNext()) {
array.add(memberIterator.next().getID());
}
outputBinding = JsonUtil.toString(array);
} else {
logger.error("{} is not a group, unable to bind members", auth.getID());
}
- } catch (Exception e){
+ } catch (Exception e) {
logger.error("unable to bind members");
}
}
diff --git a/src/main/java/org/apache/sling/pipes/internal/CommandExecutorImpl.java b/src/main/java/org/apache/sling/pipes/internal/CommandExecutorImpl.java
index 8553aac..06517b4 100644
--- a/src/main/java/org/apache/sling/pipes/internal/CommandExecutorImpl.java
+++ b/src/main/java/org/apache/sling/pipes/internal/CommandExecutorImpl.java
@@ -1,22 +1,27 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-
package org.apache.sling.pipes.internal;
+import javax.json.JsonException;
+import javax.servlet.Servlet;
+import javax.servlet.http.HttpServletResponse;
+
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
@@ -71,16 +76,14 @@ import static org.apache.commons.lang3.StringUtils.EMPTY;
import static org.apache.sling.pipes.CommandUtil.keyValuesToArray;
import static org.apache.sling.pipes.CommandUtil.writeToMap;
-import javax.json.JsonException;
-import javax.servlet.Servlet;
-import javax.servlet.http.HttpServletResponse;
-
-@Component(service = {Servlet.class, CommandExecutor.class}, property= {
- ServletResolverConstants.SLING_SERVLET_RESOURCE_TYPES + "=" + CommandExecutorImpl.RESOURCE_TYPE,
- ServletResolverConstants.SLING_SERVLET_METHODS + "=POST",
- ServletResolverConstants.SLING_SERVLET_EXTENSIONS + "=json",
- ServletResolverConstants.SLING_SERVLET_EXTENSIONS + "=csv"
-})
+@Component(
+ service = {Servlet.class, CommandExecutor.class},
+ property = {
+ ServletResolverConstants.SLING_SERVLET_RESOURCE_TYPES + "=" + CommandExecutorImpl.RESOURCE_TYPE,
+ ServletResolverConstants.SLING_SERVLET_METHODS + "=POST",
+ ServletResolverConstants.SLING_SERVLET_EXTENSIONS + "=json",
+ ServletResolverConstants.SLING_SERVLET_EXTENSIONS + "=csv"
+ })
@Designate(ocd = CommandExecutorImpl.Configuration.class)
public class CommandExecutorImpl extends AbstractPlumberServlet implements CommandExecutor {
final Logger log = LoggerFactory.getLogger(CommandExecutorImpl.class);
@@ -101,7 +104,7 @@ public class CommandExecutorImpl extends AbstractPlumberServlet implements Comma
static final List<String> JSON_EXPR_KEYS = Arrays.asList(JsonPipe.JSON_KEY);
static final String JSON_START = "\"[{";
static final String PARAMS_SEPARATOR = WHITE_SPACE_SEPARATOR + "+" + PARAMS + WHITE_SPACE_SEPARATOR + "*";
- static final Pattern SUB_TOKEN_PATTERN = Pattern.compile("\\s*(?<" + TOKEN + ">((\"[^\"]*\")|([^\\s\"]+))*)\\s*" );
+ static final Pattern SUB_TOKEN_PATTERN = Pattern.compile("\\s*(?<" + TOKEN + ">((\"[^\"]*\")|([^\\s\"]+))*)\\s*");
static final String KEY_NAME = "name";
static final String KEY_PATH = "path";
static final String KEY_EXPR = "expr";
@@ -109,19 +112,18 @@ public class CommandExecutorImpl extends AbstractPlumberServlet implements Comma
static final String DECL_BINDING_CONTENT = "declcontent";
static final Pattern DECL_BINDING_PATTERN = Pattern.compile(DECL_BINDING + WHITE_SPACE_SEPARATOR + "*"
+ "(?<" + DECL_BINDING + ">[\\w_\\-\\d]+)"
- + WHITE_SPACE_SEPARATOR + "*=" + WHITE_SPACE_SEPARATOR + "*" +
- "(?<" + DECL_BINDING_CONTENT + ">.*)");
-
- private static final String HELP_START =
- "\n a <pipe token> is <pipe> <expr|conf>? (<options>)?" +
- "\n <options> are (@ <option>)* form with <option> being either" +
- "\n\t'name pipeName' (used in bindings), " +
- "\n\t'expr pipeExpression' (when not directly as <args>)" +
- "\n\t'path pipePath' (when not directly as <args>)" +
- "\n\t'bindings key=value ...' (for setting pipe bindings) " +
- "\n\t'with key=value ...' (for setting pipe specific properties)" +
- "\n\t'outputs key=value ...' (for setting outputs)" +
- "\n and <pipe> is one of the following :\n";
+ + WHITE_SPACE_SEPARATOR + "*=" + WHITE_SPACE_SEPARATOR + "*" + "(?<"
+ + DECL_BINDING_CONTENT + ">.*)");
+
+ private static final String HELP_START = "\n a <pipe token> is <pipe> <expr|conf>? (<options>)?"
+ + "\n <options> are (@ <option>)* form with <option> being either"
+ + "\n\t'name pipeName' (used in bindings), "
+ + "\n\t'expr pipeExpression' (when not directly as <args>)"
+ + "\n\t'path pipePath' (when not directly as <args>)"
+ + "\n\t'bindings key=value ...' (for setting pipe bindings) "
+ + "\n\t'with key=value ...' (for setting pipe specific properties)"
+ + "\n\t'outputs key=value ...' (for setting outputs)"
+ + "\n and <pipe> is one of the following :\n";
Map<String, Method> methodMap;
Map<String, PipeExecutor> executorMap;
@@ -135,16 +137,16 @@ public class CommandExecutorImpl extends AbstractPlumberServlet implements Comma
@Activate
@Modified
- public void activate(Configuration configuration){
+ public void activate(Configuration configuration) {
enabled = configuration.enabled();
methodMap = null;
executorMap = null;
help = null;
}
- @ObjectClassDefinition(name="Apache Sling Pipes : Command Executor Configuration")
+ @ObjectClassDefinition(name = "Apache Sling Pipes : Command Executor Configuration")
public @interface Configuration {
- @AttributeDefinition(description="Enable command executor to be executed from servlet, if not, sends 503")
+ @AttributeDefinition(description = "Enable command executor to be executed from servlet, if not, sends 503")
boolean enabled() default true;
}
@@ -156,7 +158,8 @@ public class CommandExecutorImpl extends AbstractPlumberServlet implements Comma
return line.indexOf(DECL_BINDING) >= 0;
}
- private void handleInputEnd(StringBuilder builder, String currentBinding, List<String> cmds, Map<String, Object> bindings) {
+ private void handleInputEnd(
+ StringBuilder builder, String currentBinding, List<String> cmds, Map<String, Object> bindings) {
if (StringUtils.isBlank(currentBinding) && builder.length() > 0) {
cmds.add(builder.toString().trim());
} else if (StringUtils.isNoneBlank(currentBinding, builder)) {
@@ -183,15 +186,17 @@ public class CommandExecutorImpl extends AbstractPlumberServlet implements Comma
readerBuilder = new StringBuilder();
currentBinding = null;
}
- } else if (isJsonBinding(line)) {
+ } else if (isJsonBinding(line)) {
Matcher matcher = DECL_BINDING_PATTERN.matcher(line);
if (matcher.find()) {
currentBinding = matcher.group(DECL_BINDING);
- readerBuilder.append(matcher.group(DECL_BINDING_CONTENT).trim());
+ readerBuilder.append(
+ matcher.group(DECL_BINDING_CONTENT).trim());
}
} else {
- //depending on what we are appending, we keep lines return or not
- readerBuilder.append((StringUtils.isBlank(currentBinding) ? LINE_SEPARATOR : "\n") + line.trim());
+ // depending on what we are appending, we keep lines return or not
+ readerBuilder.append(
+ (StringUtils.isBlank(currentBinding) ? LINE_SEPARATOR : "\n") + line.trim());
}
}
handleInputEnd(readerBuilder, currentBinding, cmds, bindings);
@@ -200,7 +205,8 @@ public class CommandExecutorImpl extends AbstractPlumberServlet implements Comma
return cmds;
}
- protected void executeCommands(@NotNull SlingHttpServletRequest request, @NotNull SlingHttpServletResponse response) throws IOException {
+ protected void executeCommands(@NotNull SlingHttpServletRequest request, @NotNull SlingHttpServletResponse response)
+ throws IOException {
PrintWriter writer = response.getWriter();
String currentCommand = null;
try {
@@ -232,15 +238,14 @@ public class CommandExecutorImpl extends AbstractPlumberServlet implements Comma
}
}
pipeWriter.ends();
- } catch (IllegalAccessException | InvocationTargetException e) {
+ } catch (IllegalAccessException | InvocationTargetException e) {
writer.println("Error executing " + currentCommand);
e.printStackTrace(writer);
response.setStatus(SC_INTERNAL_SERVER_ERROR);
response.sendError(SC_INTERNAL_SERVER_ERROR);
writer.println(help());
- }
- catch (IllegalArgumentException | JsonException e) {
- writer.println("Error executing " + currentCommand);
+ } catch (IllegalArgumentException | JsonException e) {
+ writer.println("Error executing " + currentCommand);
e.printStackTrace(writer);
response.setStatus(SC_NOT_ACCEPTABLE);
response.sendError(SC_NOT_ACCEPTABLE);
@@ -249,7 +254,8 @@ public class CommandExecutorImpl extends AbstractPlumberServlet implements Comma
}
@Override
- protected void doPost(@NotNull SlingHttpServletRequest request, @NotNull SlingHttpServletResponse response) throws IOException {
+ protected void doPost(@NotNull SlingHttpServletRequest request, @NotNull SlingHttpServletResponse response)
+ throws IOException {
if (enabled) {
PrintWriter writer = response.getWriter();
try {
@@ -260,11 +266,10 @@ public class CommandExecutorImpl extends AbstractPlumberServlet implements Comma
}
writer.println("");
response.setStatus(SC_OK);
- }
- catch (AccessControlException e) {
+ } catch (AccessControlException e) {
response.setStatus(SC_FORBIDDEN);
response.sendError(SC_FORBIDDEN);
- }
+ }
} else {
response.setStatus(HttpServletResponse.SC_SERVICE_UNAVAILABLE);
response.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE, "http service has been disabled");
@@ -274,7 +279,7 @@ public class CommandExecutorImpl extends AbstractPlumberServlet implements Comma
@Override
public ExecutionResult execute(ResourceResolver resolver, String path, String... optionTokens) {
Resource resource = resolver.getResource(path);
- if (resource == null){
+ if (resource == null) {
throw new IllegalArgumentException(String.format("%s resource does not exist", path));
}
Options options = getOptions(optionTokens);
@@ -284,7 +289,7 @@ public class CommandExecutorImpl extends AbstractPlumberServlet implements Comma
writeToMap(bMap, true, options.with);
}
OutputWriter writer = new NopWriter();
- if (options.outputs != null){
+ if (options.outputs != null) {
writer = new JsonWriter();
Map<String, Object> outputs = new HashMap<>();
CommandUtil.writeToMap(outputs, true, options.outputs);
@@ -295,34 +300,34 @@ public class CommandExecutorImpl extends AbstractPlumberServlet implements Comma
}
@Override
- public PipeBuilder parse(ResourceResolver resolver, String...cmds) throws InvocationTargetException, IllegalAccessException {
+ public PipeBuilder parse(ResourceResolver resolver, String... cmds)
+ throws InvocationTargetException, IllegalAccessException {
PipeBuilder builder = plumber.newPipe(resolver);
- for (Token token : parseTokens(cmds)){
+ for (Token token : parseTokens(cmds)) {
Method method = getMethodMap().get(token.pipeKey);
- if (method == null){
+ if (method == null) {
throw new IllegalArgumentException(token.pipeKey + " is not a valid pipe");
}
- if (isExpressionExpected(method)){
+ if (isExpressionExpected(method)) {
method.invoke(builder, token.args.get(0));
- } else if (isConfExpected(method)){
- method.invoke(builder, (Object)keyValuesToArray(token.args));
- } else if (isWithoutExpectedParameter(method)){
+ } else if (isConfExpected(method)) {
+ method.invoke(builder, (Object) keyValuesToArray(token.args));
+ } else if (isWithoutExpectedParameter(method)) {
method.invoke(builder);
}
- if (token.options != null){
+ if (token.options != null) {
token.options.writeToBuilder(builder);
}
}
return builder;
-
}
/**
* @param tokens array of tokens
* @return options from array
*/
- protected Options getOptions(String[] tokens){
+ protected Options getOptions(String[] tokens) {
return getOptions(Arrays.asList(tokens));
}
@@ -330,7 +335,7 @@ public class CommandExecutorImpl extends AbstractPlumberServlet implements Comma
* @param tokens list of tokens
* @return options from token list
*/
- protected Options getOptions(List<String> tokens){
+ protected Options getOptions(List<String> tokens) {
return new Options(tokens);
}
@@ -347,14 +352,13 @@ public class CommandExecutorImpl extends AbstractPlumberServlet implements Comma
@Override
public String toString() {
- return "Options{" +
- "name='" + name + '\'' +
- ", path='" + path + '\'' +
- ", expr='" + expr + '\'' +
- ", with=" + Arrays.toString(with) +
- ", bindings=" + Arrays.toString(bindings) +
- ", outputs=" + Arrays.toString(outputs) +
- '}';
+ return "Options{" + "name='"
+ + name + '\'' + ", path='"
+ + path + '\'' + ", expr='"
+ + expr + '\'' + ", with="
+ + Arrays.toString(with) + ", bindings="
+ + Arrays.toString(bindings) + ", outputs="
+ + Arrays.toString(outputs) + '}';
}
void setOutputs(List<String> values) {
@@ -365,7 +369,7 @@ public class CommandExecutorImpl extends AbstractPlumberServlet implements Comma
* Constructor
* @param options string list from where options will be built
*/
- protected Options(List<String> options){
+ protected Options(List<String> options) {
Map<String, Object> optionMap = new HashMap<>();
for (String optionToken : options) {
String currentKey = null;
@@ -379,25 +383,25 @@ public class CommandExecutorImpl extends AbstractPlumberServlet implements Comma
}
finishOption(currentKey, currentList, optionMap);
}
- for (Map.Entry<String, Object> entry : optionMap.entrySet()){
+ for (Map.Entry<String, Object> entry : optionMap.entrySet()) {
switch (entry.getKey()) {
- case Pipe.PN_NAME :
- this.name = (String)entry.getValue();
+ case Pipe.PN_NAME:
+ this.name = (String) entry.getValue();
break;
- case Pipe.PN_PATH :
- this.path = (String)entry.getValue();
+ case Pipe.PN_PATH:
+ this.path = (String) entry.getValue();
break;
- case Pipe.PN_EXPR :
- this.expr = (String)entry.getValue();
+ case Pipe.PN_EXPR:
+ this.expr = (String) entry.getValue();
break;
- case "with" :
- this.with = keyValuesToArray((List<String>)entry.getValue());
+ case "with":
+ this.with = keyValuesToArray((List<String>) entry.getValue());
break;
- case "bindings" :
+ case "bindings":
this.bindings = keyValuesToArray((List<String>) entry.getValue());
break;
- case "outputs" :
- setOutputs((List<String>)entry.getValue());
+ case "outputs":
+ setOutputs((List<String>) entry.getValue());
break;
default:
throw new IllegalArgumentException(String.format("%s is an unknown option", entry.getKey()));
@@ -411,8 +415,8 @@ public class CommandExecutorImpl extends AbstractPlumberServlet implements Comma
* @param currentList list being processed
* @param optionMap option map
*/
- protected void finishOption(String currentKey, List<String> currentList, Map<String, Object> optionMap){
- if (currentList != null){
+ protected void finishOption(String currentKey, List<String> currentList, Map<String, Object> optionMap) {
+ if (currentList != null) {
if (currentKey.equals(KEY_NAME) || currentKey.equals(KEY_EXPR) || currentKey.equals(KEY_PATH)) {
optionMap.put(currentKey, currentList.get(0));
} else {
@@ -427,19 +431,19 @@ public class CommandExecutorImpl extends AbstractPlumberServlet implements Comma
* @throws IllegalAccessException
*/
void writeToBuilder(PipeBuilder builder) throws IllegalAccessException {
- if (StringUtils.isNotBlank(name)){
+ if (StringUtils.isNotBlank(name)) {
builder.name(name);
}
- if (StringUtils.isNotBlank(path)){
+ if (StringUtils.isNotBlank(path)) {
builder.path(path);
}
- if (StringUtils.isNotBlank(expr)){
+ if (StringUtils.isNotBlank(expr)) {
builder.expr(expr);
}
- if (with != null){
+ if (with != null) {
builder.with(with);
}
- if (bindings != null){
+ if (bindings != null) {
builder.bindings(bindings);
}
if (outputs != null) {
@@ -458,18 +462,14 @@ public class CommandExecutorImpl extends AbstractPlumberServlet implements Comma
@Override
public String toString() {
- return "Token{" +
- "pipeKey='" + pipeKey + '\'' +
- ", args=" + args +
- ", options=" + options +
- '}';
+ return "Token{" + "pipeKey='" + pipeKey + '\'' + ", args=" + args + ", options=" + options + '}';
}
}
List<String> getSpaceSeparatedTokens(String token) {
List<String> subTokens = new ArrayList<>();
Matcher matcher = SUB_TOKEN_PATTERN.matcher(token);
- while (matcher.find()){
+ while (matcher.find()) {
String subToken = matcher.group(TOKEN);
if (StringUtils.isNotBlank(subToken)) {
subTokens.add(CommandUtil.trimQuotes(subToken));
@@ -485,20 +485,20 @@ public class CommandExecutorImpl extends AbstractPlumberServlet implements Comma
protected List<CommandExecutorImpl.Token> parseTokens(String... commands) {
List<CommandExecutorImpl.Token> returnValue = new ArrayList<>();
String cat = String.join(EMPTY, commands);
- for (String token : cat.split(PIPE_SEPARATOR)){
+ for (String token : cat.split(PIPE_SEPARATOR)) {
CommandExecutorImpl.Token currentToken = new CommandExecutorImpl.Token();
String[] options = token.split(PARAMS_SEPARATOR);
if (options.length > 1) {
currentToken.options = getOptions(Arrays.copyOfRange(options, 1, options.length));
}
List<String> subTokens = getSpaceSeparatedTokens(options[0]);
- if (! subTokens.isEmpty()) {
+ if (!subTokens.isEmpty()) {
currentToken.pipeKey = subTokens.get(0);
if (subTokens.size() > 1) {
currentToken.args = subTokens.subList(1, subTokens.size());
- if (JSON_EXPR_KEYS.contains(currentToken.pipeKey) &&
- JSON_START.indexOf(currentToken.args.get(0).getBytes(StandardCharsets.UTF_8)[0]) > 0) {
- //in that case we want to concatenate all subsequent 'args' as it is a JSON expression
+ if (JSON_EXPR_KEYS.contains(currentToken.pipeKey)
+ && JSON_START.indexOf(currentToken.args.get(0).getBytes(StandardCharsets.UTF_8)[0]) > 0) {
+ // in that case we want to concatenate all subsequent 'args' as it is a JSON expression
currentToken.args = Collections.singletonList(String.join(EMPTY, currentToken.args));
}
}
@@ -512,7 +512,7 @@ public class CommandExecutorImpl extends AbstractPlumberServlet implements Comma
/**
* builds utility maps
*/
- protected void computeMaps(){
+ protected void computeMaps() {
executorMap = new HashMap<>();
methodMap = new HashMap<>();
for (Method method : PipeBuilderImpl.class.getDeclaredMethods()) {
@@ -564,23 +564,23 @@ public class CommandExecutorImpl extends AbstractPlumberServlet implements Comma
* @param method corresponding PB api
* @return true if the api does not expect parameters
*/
- protected boolean isWithoutExpectedParameter(Method method){
+ protected boolean isWithoutExpectedParameter(Method method) {
return method.getParameterCount() == 0;
}
/**
* help command handler
*/
- public String help(){
+ public String help() {
if (StringUtils.isBlank(help)) {
StringBuilder builder = new StringBuilder();
builder.append(HELP_START);
for (Map.Entry<String, PipeExecutor> entry : getExecutorMap().entrySet()) {
- builder.append(String.format("\t%s\t\t:\t%s%n", entry.getKey(), entry.getValue().description()));
+ builder.append(String.format(
+ "\t%s\t\t:\t%s%n", entry.getKey(), entry.getValue().description()));
}
help = builder.toString();
}
return help;
}
-
}
diff --git a/src/main/java/org/apache/sling/pipes/internal/ContainerPipe.java b/src/main/java/org/apache/sling/pipes/internal/ContainerPipe.java
index a2de937..538f5d0 100644
--- a/src/main/java/org/apache/sling/pipes/internal/ContainerPipe.java
+++ b/src/main/java/org/apache/sling/pipes/internal/ContainerPipe.java
@@ -1,21 +1,27 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes.internal;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
import org.apache.sling.api.resource.Resource;
import org.apache.sling.pipes.Pipe;
import org.apache.sling.pipes.PipeBindings;
@@ -24,10 +30,6 @@ import org.apache.sling.pipes.SuperPipe;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
/**
* This pipe executes the pipes it has in its configuration, chaining their result, and
* modifying each contained pipe's expression with its context
@@ -49,11 +51,14 @@ public class ContainerPipe extends SuperPipe {
@Override
public void buildChildren() {
- for (Iterator<Resource> childPipeResources = getConfiguration().listChildren(); childPipeResources.hasNext();){
+ for (Iterator<Resource> childPipeResources = getConfiguration().listChildren();
+ childPipeResources.hasNext(); ) {
Resource pipeResource = childPipeResources.next();
Pipe pipe = plumber.getPipe(pipeResource, bindings);
if (pipe == null) {
- log.error("configured pipe {} is either not registered, or not computable by the plumber", pipeResource.getPath());
+ log.error(
+ "configured pipe {} is either not registered, or not computable by the plumber",
+ pipeResource.getPath());
} else {
pipe.setParent(this);
subpipes.add(pipe);
@@ -101,7 +106,7 @@ public class ContainerPipe extends SuperPipe {
iterators = new HashMap<>();
Pipe firstPipe = container.getFirstPipe();
this.sleep = container.sleep;
- //we initialize the first iterator the only one not to be updated
+ // we initialize the first iterator the only one not to be updated
iterators.put(firstPipe, firstPipe.getOutput());
}
@@ -110,7 +115,7 @@ public class ContainerPipe extends SuperPipe {
* more resources, or at length - 1 (last pipe) with a next one
* @return true if cursor has been updated
*/
- private boolean updateCursor(){
+ private boolean updateCursor() {
Pipe currentPipe = container.subpipes.get(cursor);
Iterator<Resource> it = iterators.get(currentPipe);
do {
@@ -120,21 +125,21 @@ public class ContainerPipe extends SuperPipe {
while (it.hasNext() && cursor < container.subpipes.size() - 1) {
Resource resource = it.next();
bindings.updateBindings(currentPipe, resource);
- //now we update the following pipe output with that new context
+ // now we update the following pipe output with that new context
Pipe nextPipe = container.subpipes.get(++cursor);
iterators.put(nextPipe, nextPipe.getOutput());
currentPipe = nextPipe;
log.debug("switching to {}", currentPipe);
it = iterators.get(currentPipe);
}
- //go down (or stay) to the first pipe having a next item
+ // go down (or stay) to the first pipe having a next item
while (!it.hasNext() && cursor > 0) {
currentPipe = container.subpipes.get(--cursor);
log.debug("switching to {}", currentPipe);
it = iterators.get(currentPipe);
}
} while (it.hasNext() && cursor < container.subpipes.size() - 1);
- //2 choices here:
+ // 2 choices here:
// either cursor is at 0 with no resource left: end,
// either cursor is on last pipe with a resource left: hasNext
// the second part is for the corner case with only one item
@@ -150,7 +155,7 @@ public class ContainerPipe extends SuperPipe {
*/
@Override
public boolean hasNext() {
- if (! computedCursor) {
+ if (!computedCursor) {
hasNext = updateCursor();
}
return hasNext;
@@ -170,7 +175,7 @@ public class ContainerPipe extends SuperPipe {
}
return resource;
}
- } catch (InterruptedException e){
+ } catch (InterruptedException e) {
log.error("interrupted while sleeping", e);
Thread.currentThread().interrupt();
}
diff --git a/src/main/java/org/apache/sling/pipes/internal/CsvWriter.java b/src/main/java/org/apache/sling/pipes/internal/CsvWriter.java
index 7109366..360b291 100644
--- a/src/main/java/org/apache/sling/pipes/internal/CsvWriter.java
+++ b/src/main/java/org/apache/sling/pipes/internal/CsvWriter.java
@@ -1,21 +1,28 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes.internal;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.resource.Resource;
@@ -23,11 +30,6 @@ import org.apache.sling.pipes.OutputWriter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.stream.Collectors;
-
public class CsvWriter extends OutputWriter {
private static final Logger LOGGER = LoggerFactory.getLogger(CsvWriter.class);
@@ -52,11 +54,11 @@ public class CsvWriter extends OutputWriter {
@Override
public void starts() {
- //nothing to start with
+ // nothing to start with
}
void writeCell(Resource resource, List<String> elts, String key) {
- if (key.equals(PATH_KEY)){
+ if (key.equals(PATH_KEY)) {
elts.add(resource.getPath());
} else if (customOutputs != null) {
elts.add(computeValue(key));
@@ -79,7 +81,7 @@ public class CsvWriter extends OutputWriter {
}
try {
List<String> elts = new ArrayList<>();
- for (String key : headers){
+ for (String key : headers) {
writeCell(resource, elts, key);
}
String line = elts.stream().collect(Collectors.joining(SEPARATOR));
@@ -92,9 +94,9 @@ public class CsvWriter extends OutputWriter {
@Override
public void ends() {
try {
- if (!errors.isEmpty()){
+ if (!errors.isEmpty()) {
writer.write(HEADER_ERROR + NEW_LINE);
- for (String error : errors){
+ for (String error : errors) {
writer.write(error + NEW_LINE);
}
}
@@ -103,4 +105,4 @@ public class CsvWriter extends OutputWriter {
LOGGER.error("unable to flush", e);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/sling/pipes/internal/FilterPipe.java b/src/main/java/org/apache/sling/pipes/internal/FilterPipe.java
index 3becf9c..4863cf6 100644
--- a/src/main/java/org/apache/sling/pipes/internal/FilterPipe.java
+++ b/src/main/java/org/apache/sling/pipes/internal/FilterPipe.java
@@ -1,21 +1,32 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes.internal;
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.RepositoryException;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.regex.Pattern;
+
import org.apache.commons.collections4.IteratorUtils;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ValueMap;
@@ -25,14 +36,6 @@ import org.apache.sling.pipes.Plumber;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.RepositoryException;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.regex.Pattern;
-
/**
* intends to output the input only if configured conditions are fulfilled
*/
@@ -57,25 +60,27 @@ public class FilterPipe extends BasePipe {
}
String key = filterResource.getPath() + SLASH + propertyKey;
return propertiesPatterns.computeIfAbsent(key, x -> {
- String value = getBindings().instantiateExpression(filterResource.getValueMap().get(propertyKey, String.class));
- return value != null ? Pattern.compile(value) : null;
- });//en.wikipedia.org
+ String value = getBindings()
+ .instantiateExpression(filterResource.getValueMap().get(propertyKey, String.class));
+ return value != null ? Pattern.compile(value) : null;
+ }); // en.wikipedia.org
}
boolean propertiesPass(ValueMap current, Resource filterResource) {
ValueMap filter = filterResource.getValueMap();
- if (filter.containsKey(PN_TEST)){
+ if (filter.containsKey(PN_TEST)) {
Object test = bindings.instantiateObject(filter.get(PN_TEST, PipeBindings.FALSE_BINDING));
- if (! (test instanceof Boolean)){
+ if (!(test instanceof Boolean)) {
logger.error("instantiated test {} is not a boolean, filtering out", test);
return false;
}
return (Boolean) test;
}
- for (String key : filter.keySet()){
- if (! IGNORED_PROPERTIES.contains(key) && !key.startsWith(PREFIX_FILTER)){
+ for (String key : filter.keySet()) {
+ if (!IGNORED_PROPERTIES.contains(key) && !key.startsWith(PREFIX_FILTER)) {
Pattern pattern = getPattern(filterResource, key);
- if (!current.containsKey(key) || !pattern.matcher(current.get(key, String.class)).matches()){
+ if (!current.containsKey(key)
+ || !pattern.matcher(current.get(key, String.class)).matches()) {
return false;
}
}
@@ -97,7 +102,8 @@ public class FilterPipe extends BasePipe {
if (currentNode != null && !currentNode.hasNode(childName)) {
return false;
} else {
- returnValue &= filterPasses(currentResource.getChild(childName), filterResource.getChild(childName));
+ returnValue &=
+ filterPasses(currentResource.getChild(childName), filterResource.getChild(childName));
}
}
return returnValue;
@@ -121,11 +127,13 @@ public class FilterPipe extends BasePipe {
if (currentResource != null && filterResource != null) {
ValueMap current = currentResource.getValueMap();
ValueMap filter = filterResource.getValueMap();
- boolean injectChildrenCount = (Boolean) bindings.instantiateObject(filter.get(PN_INJECTCHILDRENCOUNT, PipeBindings.FALSE_BINDING));
+ boolean injectChildrenCount = (Boolean)
+ bindings.instantiateObject(filter.get(PN_INJECTCHILDRENCOUNT, PipeBindings.FALSE_BINDING));
if (injectChildrenCount) {
Node currentNode = currentResource.adaptTo(Node.class);
if (currentNode != null) {
- int childrenCount = IteratorUtils.toList(currentNode.getNodes()).size();
+ int childrenCount =
+ IteratorUtils.toList(currentNode.getNodes()).size();
bindings.addBinding(BINDING_CHILDREN_COUNT, childrenCount);
}
}
@@ -141,8 +149,10 @@ public class FilterPipe extends BasePipe {
Resource resource = getInput();
if (resource != null) {
try {
- boolean not = getBindings().instantiateExpression(properties.get(PN_NOT, "false")).equals(Boolean.TRUE.toString());
- //the not does a exclusive or with the filter:
+ boolean not = getBindings()
+ .instantiateExpression(properties.get(PN_NOT, "false"))
+ .equals(Boolean.TRUE.toString());
+ // the not does a exclusive or with the filter:
// - true filter with "true" not is false,
// - false filter with false not is false,
// - all the other combinations should pass
diff --git a/src/main/java/org/apache/sling/pipes/internal/GogoCommands.java b/src/main/java/org/apache/sling/pipes/internal/GogoCommands.java
index 833685f..e7896c9 100644
--- a/src/main/java/org/apache/sling/pipes/internal/GogoCommands.java
+++ b/src/main/java/org/apache/sling/pipes/internal/GogoCommands.java
@@ -1,38 +1,40 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes.internal;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.lang.reflect.InvocationTargetException;
+
import org.apache.commons.io.IOUtils;
import org.apache.sling.api.resource.LoginException;
import org.apache.sling.api.resource.PersistenceException;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.resource.ResourceResolverFactory;
-
import org.apache.sling.pipes.CommandExecutor;
import org.apache.sling.pipes.PipeBuilder;
import org.apache.sling.pipes.Plumber;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
-import java.io.IOException;
-import java.io.PrintStream;
-import java.lang.reflect.InvocationTargetException;
-
-@Component(immediate = true,
+@Component(
+ immediate = true,
service = GogoCommands.class,
property = {
"osgi.command.scope=pipe",
@@ -45,11 +47,12 @@ public class GogoCommands {
static final String INPUT = "-";
- static final String COMMAND_HELP_START = "\nSling Pipes Help\nAvailable commands are \n\n- execute <path> <options>(execute a pipe already built at a given path), if path is '-' then previous pipe token is used," +
- "\n- build (build pipe as configured in arguments)" +
- "\n- run (run pipe as configured in arguments)" +
- "\n- help (print(). this help)" +
- "\n\nfor pipe configured in argument, do 'pipe:<run|build|runAsync> <pipe token> (/ <pipe token> )*\n";
+ static final String COMMAND_HELP_START =
+ "\nSling Pipes Help\nAvailable commands are \n\n- execute <path> <options>(execute a pipe already built at a given path), if path is '-' then previous pipe token is used,"
+ + "\n- build (build pipe as configured in arguments)"
+ + "\n- run (run pipe as configured in arguments)"
+ + "\n- help (print(). this help)"
+ + "\n\nfor pipe configured in argument, do 'pipe:<run|build|runAsync> <pipe token> (/ <pipe token> )*\n";
@Reference
ResourceResolverFactory factory;
@@ -87,7 +90,8 @@ public class GogoCommands {
* @throws IllegalAccessException in case this user can't access the pipe executions
* @throws PersistenceException in case persistence of the pipe failed
*/
- public void build(String... cmds) throws LoginException, InvocationTargetException, IllegalAccessException, PersistenceException {
+ public void build(String... cmds)
+ throws LoginException, InvocationTargetException, IllegalAccessException, PersistenceException {
try (ResourceResolver resolver = factory.getServiceResourceResolver(plumber.getServiceUser())) {
PipeBuilder builder = commandExecutor.parse(resolver, cmds);
print().println(builder.build().getResource().getPath());
@@ -111,7 +115,7 @@ public class GogoCommands {
/**
* help command handler
*/
- public void help(){
+ public void help() {
print().println(COMMAND_HELP_START + commandExecutor.help());
}
}
diff --git a/src/main/java/org/apache/sling/pipes/internal/JsonUtil.java b/src/main/java/org/apache/sling/pipes/internal/JsonUtil.java
index 2008a02..573106f 100644
--- a/src/main/java/org/apache/sling/pipes/internal/JsonUtil.java
+++ b/src/main/java/org/apache/sling/pipes/internal/JsonUtil.java
@@ -1,23 +1,23 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes.internal;
-import org.apache.sling.jcr.contentparser.impl.JsonTicksConverter;
-
import javax.json.Json;
import javax.json.JsonArray;
import javax.json.JsonArrayBuilder;
@@ -39,10 +39,11 @@ import java.util.Map.Entry;
import java.util.function.Function;
import java.util.stream.Collectors;
+import org.apache.sling.jcr.contentparser.impl.JsonTicksConverter;
+
public class JsonUtil {
- private JsonUtil() {
- }
+ private JsonUtil() {}
public static JsonStructure parse(String input) {
try (JsonReader reader = Json.createReader(new StringReader(JsonTicksConverter.tickToDoubleQuote(input)))) {
@@ -81,20 +82,21 @@ public class JsonUtil {
@SuppressWarnings("unchecked")
public static <T> T unbox(JsonValue value) {
- return (T) unbox(value, json -> json.getValueType() == ValueType.ARRAY ?
- ((JsonArray) json).stream()
- .map(JsonUtil::unbox)
- .collect(Collectors.toList())
- :
- ((JsonObject) json).entrySet().stream()
- .map(entry -> new AbstractMap.SimpleEntry<>(entry.getKey(),unbox(entry.getValue())))
- .filter(entry -> entry.getValue() != null)
- .collect(Collectors.toMap(Entry::getKey, Entry::getValue)));
+ return (T) unbox(
+ value,
+ json -> json.getValueType() == ValueType.ARRAY
+ ? ((JsonArray) json).stream().map(JsonUtil::unbox).collect(Collectors.toList())
+ : ((JsonObject) json)
+ .entrySet().stream()
+ .map(entry ->
+ new AbstractMap.SimpleEntry<>(entry.getKey(), unbox(entry.getValue())))
+ .filter(entry -> entry.getValue() != null)
+ .collect(Collectors.toMap(Entry::getKey, Entry::getValue)));
}
public static String toString(JsonValue value) {
StringWriter writer = new StringWriter();
- try(JsonGenerator generator = Json.createGenerator(writer)) {
+ try (JsonGenerator generator = Json.createGenerator(writer)) {
generator.write(value);
}
return writer.toString();
@@ -103,7 +105,7 @@ public class JsonUtil {
public static String toString(JsonArrayBuilder builder) {
return toString(builder.build());
}
-
+
public static String toString(JsonObjectBuilder builder) {
return toString(builder.build());
}
diff --git a/src/main/java/org/apache/sling/pipes/internal/JsonWriter.java b/src/main/java/org/apache/sling/pipes/internal/JsonWriter.java
index fe4d779..93fa60d 100644
--- a/src/main/java/org/apache/sling/pipes/internal/JsonWriter.java
+++ b/src/main/java/org/apache/sling/pipes/internal/JsonWriter.java
@@ -1,31 +1,34 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes.internal;
-import org.apache.sling.api.SlingHttpServletRequest;
-import org.apache.sling.api.SlingHttpServletResponse;
-import org.apache.sling.api.resource.Resource;
-import org.apache.sling.pipes.OutputWriter;
-
import javax.json.Json;
import javax.json.stream.JsonGenerator;
+
import java.io.StringWriter;
import java.util.Map;
+import org.apache.sling.api.SlingHttpServletRequest;
+import org.apache.sling.api.SlingHttpServletResponse;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.pipes.OutputWriter;
+
/**
* default output writer, that outputs JSON with size and output resources' path
*/
@@ -34,7 +37,7 @@ public class JsonWriter extends OutputWriter {
public static final String JSON_EXTENSION = "json";
- JsonWriter(){
+ JsonWriter() {
setWriter(new StringWriter());
}
@@ -44,7 +47,7 @@ public class JsonWriter extends OutputWriter {
}
@Override
- protected void initResponse(SlingHttpServletResponse response){
+ protected void initResponse(SlingHttpServletResponse response) {
response.setCharacterEncoding("utf-8");
response.setContentType("application/json");
}
@@ -73,11 +76,11 @@ public class JsonWriter extends OutputWriter {
@Override
public void ends() {
jsonGenerator.writeEnd();
- jsonGenerator.write(KEY_SIZE,size);
+ jsonGenerator.write(KEY_SIZE, size);
if (nbErrors > 0) {
jsonGenerator.write(KEY_NB_ERRORS, nbErrors);
jsonGenerator.writeStartArray(KEY_ERRORS);
- for (String error : errors){
+ for (String error : errors) {
jsonGenerator.write(error);
}
jsonGenerator.writeEnd();
@@ -85,4 +88,4 @@ public class JsonWriter extends OutputWriter {
jsonGenerator.writeEnd();
jsonGenerator.flush();
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/sling/pipes/internal/ManifoldPipe.java b/src/main/java/org/apache/sling/pipes/internal/ManifoldPipe.java
index 9620e1a..4b7046f 100644
--- a/src/main/java/org/apache/sling/pipes/internal/ManifoldPipe.java
+++ b/src/main/java/org/apache/sling/pipes/internal/ManifoldPipe.java
@@ -1,21 +1,30 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes.internal;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.resource.NonExistingResource;
@@ -28,13 +37,6 @@ import org.apache.sling.pipes.SuperPipe;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-import java.util.concurrent.ArrayBlockingQueue;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-
/**
* This pipe executes the pipes it has in its configuration, in sequence or parallel;
* the output of the children pipes is merged;
@@ -51,7 +53,7 @@ public class ManifoldPipe extends SuperPipe {
public static final String PN_EXECUTION_TIMEOUT = "executionTimeout";
public static final int QUEUE_SIZE_DEFAULT = 10000;
public static final int NUM_THREADS_DEFAULT = 5;
- public static final int EXECUTION_TIMEOUT_DEFAULT = 24*60*60;
+ public static final int EXECUTION_TIMEOUT_DEFAULT = 24 * 60 * 60;
// marker to be inserted in the queue after all thread pipes are done pushing output
private static final Resource END_OF_STREAM = new NonExistingResource(null, "");
@@ -75,11 +77,14 @@ public class ManifoldPipe extends SuperPipe {
@Override
public void buildChildren() {
- for (Iterator<Resource> childPipeResources = getConfiguration().listChildren(); childPipeResources.hasNext();){
+ for (Iterator<Resource> childPipeResources = getConfiguration().listChildren();
+ childPipeResources.hasNext(); ) {
Resource pipeResource = childPipeResources.next();
Pipe pipe = plumber.getPipe(pipeResource, bindings);
if (pipe == null) {
- log.error("configured pipe {} is either not registered, or not computable by the plumber", pipeResource.getPath());
+ log.error(
+ "configured pipe {} is either not registered, or not computable by the plumber",
+ pipeResource.getPath());
} else {
pipe.setParent(this.getParent());
subpipes.add(pipe);
@@ -103,7 +108,12 @@ public class ManifoldPipe extends SuperPipe {
@Override
public void run() {
try {
- plumber.execute(pipe.getResource().getResourceResolver().clone(null), pipe, null, new ThreadOutputWriter(), true);
+ plumber.execute(
+ pipe.getResource().getResourceResolver().clone(null),
+ pipe,
+ null,
+ new ThreadOutputWriter(),
+ true);
} catch (Exception e) {
log.error("Error while running pipe %s", pipe.getName(), e);
}
@@ -127,13 +137,19 @@ public class ManifoldPipe extends SuperPipe {
}
@Override
- protected void initResponse(SlingHttpServletResponse response) {/*no handling here*/}
+ protected void initResponse(SlingHttpServletResponse response) {
+ /*no handling here*/
+ }
@Override
- public void starts() {/*no handling here*/}
+ public void starts() {
+ /*no handling here*/
+ }
@Override
- public void ends() {/*no handling here*/}
+ public void ends() {
+ /*no handling here*/
+ }
}
private class ConcurrentIterator implements Iterator<Resource> {
@@ -156,7 +172,7 @@ public class ManifoldPipe extends SuperPipe {
ConcurrentIterator(int numThreads) {
executorService = Executors.newFixedThreadPool(numThreads);
- for (Pipe pipe: subpipes) {
+ for (Pipe pipe : subpipes) {
executorService.execute(new PipeThread(pipe));
}
executorService.shutdown();
diff --git a/src/main/java/org/apache/sling/pipes/internal/MovePipe.java b/src/main/java/org/apache/sling/pipes/internal/MovePipe.java
index 46b0a76..3de0d7a 100644
--- a/src/main/java/org/apache/sling/pipes/internal/MovePipe.java
+++ b/src/main/java/org/apache/sling/pipes/internal/MovePipe.java
@@ -1,21 +1,33 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes.internal;
+import javax.jcr.Item;
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.UUID;
+
import org.apache.commons.lang3.StringUtils;
import org.apache.jackrabbit.api.JackrabbitNode;
import org.apache.sling.api.resource.PersistenceException;
@@ -27,16 +39,6 @@ import org.apache.sling.pipes.Plumber;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import javax.jcr.Item;
-import javax.jcr.Node;
-import javax.jcr.Property;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.UUID;
-
/**
* Does a JCR Move of a node, returns the resource corresponding to the moved node
*/
@@ -86,7 +88,8 @@ public class MovePipe extends BasePipe {
session.removeItem(targetPath);
session.move(input.getPath(), targetPath);
if (parent != null) {
- return Collections.singleton(parent.getChild(input.getName())).iterator();
+ return Collections.singleton(parent.getChild(input.getName()))
+ .iterator();
}
}
}
@@ -108,7 +111,7 @@ public class MovePipe extends BasePipe {
Property sourceProperty = input.adaptTo(Property.class);
if (sourceProperty != null) {
Node destNode = session.getNode(parentPath);
- if (sourceProperty.isMultiple()){
+ if (sourceProperty.isMultiple()) {
destNode.setProperty(name, sourceProperty.getValues(), sourceProperty.getType());
} else {
destNode.setProperty(name, sourceProperty.getValue(), sourceProperty.getType());
@@ -122,7 +125,8 @@ public class MovePipe extends BasePipe {
return EMPTY_ITERATOR;
}
- private Iterator<Resource> reorder(Resource input, Resource target) throws RepositoryException, PersistenceException {
+ private Iterator<Resource> reorder(Resource input, Resource target)
+ throws RepositoryException, PersistenceException {
if (target != null && !isDryRun()) {
logger.info("ordering {} before {}", input.getPath(), target != null);
Resource parent = target.getParent();
@@ -136,7 +140,8 @@ public class MovePipe extends BasePipe {
if (session != null) {
session.move(input.getPath(), targetNodePath);
targetParent.orderBefore(targetNodeName, oldNodeName);
- return Collections.singleton(parent.getChild(targetNodeName)).iterator();
+ return Collections.singleton(parent.getChild(targetNodeName))
+ .iterator();
}
} else {
logger.warn("parent resource {} doesn't support ordering", parent.getPath());
@@ -155,7 +160,7 @@ public class MovePipe extends BasePipe {
return output;
}
String targetPath = getExpr();
- if (! targetPath.startsWith(SLASH)) {
+ if (!targetPath.startsWith(SLASH)) {
logger.debug("relative path requested as target path: we'll take current path's parent");
targetPath = StringUtils.substringBeforeLast(input.getPath(), SLASH) + SLASH + targetPath;
}
@@ -176,7 +181,7 @@ public class MovePipe extends BasePipe {
logger.warn("{} already exists, nothing will be done here, nothing outputed", targetPath);
}
}
- } catch (PersistenceException | RepositoryException e){
+ } catch (PersistenceException | RepositoryException e) {
logger.error("unable to move the resource", e);
}
return output;
diff --git a/src/main/java/org/apache/sling/pipes/internal/MultiPropertyPipe.java b/src/main/java/org/apache/sling/pipes/internal/MultiPropertyPipe.java
index 68004ef..a1d0b6c 100644
--- a/src/main/java/org/apache/sling/pipes/internal/MultiPropertyPipe.java
+++ b/src/main/java/org/apache/sling/pipes/internal/MultiPropertyPipe.java
@@ -1,35 +1,38 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes.internal;
-import org.apache.sling.api.resource.Resource;
-import org.apache.sling.pipes.BasePipe;
-import org.apache.sling.pipes.PipeBindings;
-import org.apache.sling.pipes.Plumber;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import javax.jcr.Property;
import javax.jcr.PropertyType;
import javax.jcr.Value;
+
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.pipes.BasePipe;
+import org.apache.sling.pipes.PipeBindings;
+import org.apache.sling.pipes.Plumber;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
/**
* reads input MV property, outputs N times the input parent node resource, where N is the number of
* values in the property, outputs each value in the bindings
@@ -72,16 +75,18 @@ public class MultiPropertyPipe extends BasePipe {
Value currentValue;
Iterator<Value> itValue = Collections.emptyIterator();
- public MVResourceIterator(Resource resource){
+ public MVResourceIterator(Resource resource) {
this.resource = resource;
if (this.resource != null) {
try {
Property mvProperty = resource.adaptTo(Property.class);
if (mvProperty == null) {
- throw new IllegalArgumentException("input resource " + resource.getPath() + " is supposed to be a property");
+ throw new IllegalArgumentException(
+ "input resource " + resource.getPath() + " is supposed to be a property");
}
if (!mvProperty.isMultiple()) {
- throw new IllegalArgumentException("given property " + resource.getPath() + " is supposed to be multiple");
+ throw new IllegalArgumentException(
+ "given property " + resource.getPath() + " is supposed to be multiple");
}
itValue = Arrays.asList(mvProperty.getValues()).iterator();
} catch (Exception e) {
diff --git a/src/main/java/org/apache/sling/pipes/internal/NopWriter.java b/src/main/java/org/apache/sling/pipes/internal/NopWriter.java
index c955ad9..ba1c79d 100644
--- a/src/main/java/org/apache/sling/pipes/internal/NopWriter.java
+++ b/src/main/java/org/apache/sling/pipes/internal/NopWriter.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes.internal;
@@ -29,21 +31,21 @@ public class NopWriter extends OutputWriter {
@Override
protected void initResponse(SlingHttpServletResponse response) {
- //nop
+ // nop
}
@Override
public void starts() {
- //nop
+ // nop
}
@Override
- protected void writeItem(Resource resource){
- //nop
+ protected void writeItem(Resource resource) {
+ // nop
}
@Override
public void ends() {
- //nop
+ // nop
}
}
diff --git a/src/main/java/org/apache/sling/pipes/internal/NotPipe.java b/src/main/java/org/apache/sling/pipes/internal/NotPipe.java
index 36cc23e..bda7d01 100644
--- a/src/main/java/org/apache/sling/pipes/internal/NotPipe.java
+++ b/src/main/java/org/apache/sling/pipes/internal/NotPipe.java
@@ -1,28 +1,30 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes.internal;
+import java.util.Collections;
+import java.util.Iterator;
+
import org.apache.sling.api.resource.Resource;
import org.apache.sling.pipes.PipeBindings;
import org.apache.sling.pipes.Plumber;
-import java.util.Collections;
-import java.util.Iterator;
-
/**
* executes a pipe referred in the configuration, but invert output:
* nothing if the pipe has something, input if the pipe has nothing
@@ -37,7 +39,7 @@ public class NotPipe extends ReferencePipe {
@Override
protected Iterator<Resource> computeReferredOutput() {
- if (reference.getOutput().hasNext()){
+ if (reference.getOutput().hasNext()) {
return EMPTY_ITERATOR;
}
return Collections.singleton(getInput()).iterator();
diff --git a/src/main/java/org/apache/sling/pipes/internal/PackagePipe.java b/src/main/java/org/apache/sling/pipes/internal/PackagePipe.java
index c96ebba..5a23360 100644
--- a/src/main/java/org/apache/sling/pipes/internal/PackagePipe.java
+++ b/src/main/java/org/apache/sling/pipes/internal/PackagePipe.java
@@ -1,21 +1,30 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes.internal;
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import java.io.IOException;
+import java.util.Iterator;
+
import org.apache.commons.collections4.IteratorUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.jackrabbit.vault.fs.api.PathFilterSet;
@@ -33,12 +42,6 @@ import org.apache.sling.pipes.Plumber;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import java.io.IOException;
-import java.util.Iterator;
-
/**
* Package pipe, creates or read vault package
*/
@@ -91,8 +94,8 @@ public class PackagePipe extends BasePipe {
if (filters == null) {
filters = new DefaultWorkspaceFilter();
}
- //we take as a filter either computed resource, either configured path, as if resource,
- //is null, check existence has been configured to be false
+ // we take as a filter either computed resource, either configured path, as if resource,
+ // is null, check existence has been configured to be false
String filter = filterResource != null ? filterResource.getPath() : getComputedPath();
filters.add(new PathFilterSet(filter));
JcrPackageDefinition definition = jcrPackage.getDefinition();
@@ -116,7 +119,6 @@ public class PackagePipe extends BasePipe {
}
}
-
/**
* computes configured package based on expression configuration (either existing or creating it)
* @throws IOException problem with binary
@@ -124,7 +126,7 @@ public class PackagePipe extends BasePipe {
* @throws IOException problem with package build
*/
protected void init() throws IOException, RepositoryException {
- if (jcrPackage == null){
+ if (jcrPackage == null) {
String packagePath = getExpr();
Session session = resolver.adaptTo(Session.class);
if (StringUtils.isNotBlank(packagePath) && session != null) {
diff --git a/src/main/java/org/apache/sling/pipes/internal/PathPipe.java b/src/main/java/org/apache/sling/pipes/internal/PathPipe.java
index aa328c1..1ecc7a4 100644
--- a/src/main/java/org/apache/sling/pipes/internal/PathPipe.java
+++ b/src/main/java/org/apache/sling/pipes/internal/PathPipe.java
@@ -1,21 +1,29 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes.internal;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import java.util.Collections;
+import java.util.Iterator;
+
import org.apache.commons.lang3.StringUtils;
import org.apache.jackrabbit.commons.JcrUtils;
import org.apache.sling.api.resource.PersistenceException;
@@ -27,11 +35,6 @@ import org.apache.sling.pipes.Plumber;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import java.util.Collections;
-import java.util.Iterator;
-
import static org.apache.sling.jcr.resource.JcrResourceConstants.NT_SLING_FOLDER;
/**
@@ -83,8 +86,9 @@ public class PathPipe extends BasePipe {
boolean modified = resolver.getResource(path) == null;
if (!isDryRun()) {
if (StringUtils.isNotBlank(nodeType)) {
- //in that case we are in a "JCR" mode
- JcrUtils.getOrCreateByPath(path, intermediateType, nodeType, resolver.adaptTo(Session.class), autosave);
+ // in that case we are in a "JCR" mode
+ JcrUtils.getOrCreateByPath(
+ path, intermediateType, nodeType, resolver.adaptTo(Session.class), autosave);
} else {
ResourceUtil.getOrCreateResource(resolver, path, resourceType, intermediateType, autosave);
}
@@ -95,7 +99,7 @@ public class PathPipe extends BasePipe {
output = Collections.singleton(resource).iterator();
}
} catch (PersistenceException | RepositoryException e) {
- logger.error ("Not able to create path {}", expr, e);
+ logger.error("Not able to create path {}", expr, e);
}
return output;
}
diff --git a/src/main/java/org/apache/sling/pipes/internal/PipeBuilderImpl.java b/src/main/java/org/apache/sling/pipes/internal/PipeBuilderImpl.java
index 50ee9d6..f91ceaa 100644
--- a/src/main/java/org/apache/sling/pipes/internal/PipeBuilderImpl.java
+++ b/src/main/java/org/apache/sling/pipes/internal/PipeBuilderImpl.java
@@ -1,21 +1,29 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes.internal;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
import org.apache.commons.lang3.StringUtils;
import org.apache.sling.api.resource.ModifiableValueMap;
import org.apache.sling.api.resource.PersistenceException;
@@ -43,12 +51,6 @@ import org.apache.sling.pipes.internal.slingquery.SiblingsPipe;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
import static org.apache.commons.lang3.StringUtils.EMPTY;
import static org.apache.sling.jcr.resource.JcrResourceConstants.NT_SLING_FOLDER;
import static org.apache.sling.jcr.resource.JcrResourceConstants.NT_SLING_ORDERED_FOLDER;
@@ -57,13 +59,15 @@ import static org.apache.sling.pipes.BasePipe.SLASH;
import static org.apache.sling.pipes.CommandUtil.checkArguments;
import static org.apache.sling.pipes.CommandUtil.writeToMap;
import static org.apache.sling.pipes.internal.ManifoldPipe.PN_NUM_THREADS;
+
/**
* Implementation of the PipeBuilder interface
*/
public class PipeBuilderImpl implements PipeBuilder {
private static final Logger logger = LoggerFactory.getLogger(PipeBuilderImpl.class);
- private static final String[] DEFAULT_NAMES = new String[]{"one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten"};
+ private static final String[] DEFAULT_NAMES =
+ new String[] {"one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten"};
List<Step> steps;
@@ -82,17 +86,17 @@ public class PipeBuilderImpl implements PipeBuilder {
* @param resolver resolver with which the pipe will be built and executed
* @param plumber instance of the plumber
*/
- PipeBuilderImpl(ResourceResolver resolver, Plumber plumber){
+ PipeBuilderImpl(ResourceResolver resolver, Plumber plumber) {
this.plumber = plumber;
this.resolver = resolver;
}
@Override
- public PipeBuilder pipe(String type){
- if (!plumber.isTypeRegistered(type)){
+ public PipeBuilder pipe(String type) {
+ if (!plumber.isTypeRegistered(type)) {
throw new IllegalArgumentException(type + " is not a registered pipe type");
}
- if (steps == null){
+ if (steps == null) {
steps = new ArrayList<>();
}
currentStep = new Step(type);
@@ -105,24 +109,31 @@ public class PipeBuilderImpl implements PipeBuilder {
* @param type pipe type
* @return updated instance of PipeBuilder
*/
- PipeBuilder pipeWithExpr(String type, String expr){
+ PipeBuilder pipeWithExpr(String type, String expr) {
try {
pipe(type).expr(expr);
- } catch (IllegalAccessException e){
+ } catch (IllegalAccessException e) {
logger.error("exception while configuring {}", type, e);
}
return this;
}
@Override
- @PipeExecutor(command = "mv", resourceType = MovePipe.RESOURCE_TYPE, pipeClass = MovePipe.class,
- description = "move current resource to expr (more on https://sling.apache.org/documentation/bundles/sling-pipes/writers.html)")
+ @PipeExecutor(
+ command = "mv",
+ resourceType = MovePipe.RESOURCE_TYPE,
+ pipeClass = MovePipe.class,
+ description =
+ "move current resource to expr (more on https://sling.apache.org/documentation/bundles/sling-pipes/writers.html)")
public PipeBuilder mv(String expr) {
return pipeWithExpr(MovePipe.RESOURCE_TYPE, expr);
}
@Override
- @PipeExecutor(command = "write", resourceType = WritePipe.RESOURCE_TYPE, pipeClass = WritePipe.class,
+ @PipeExecutor(
+ command = "write",
+ resourceType = WritePipe.RESOURCE_TYPE,
+ pipeClass = WritePipe.class,
description = "write following key=value pairs to the current resource")
public PipeBuilder write(Object... conf) throws IllegalAccessException {
PipeBuilder instance = pipe(WritePipe.RESOURCE_TYPE);
@@ -133,146 +144,205 @@ public class PipeBuilderImpl implements PipeBuilder {
}
@Override
- @PipeExecutor(command = "grep", resourceType = FilterPipe.RESOURCE_TYPE, pipeClass = FilterPipe.class,
+ @PipeExecutor(
+ command = "grep",
+ resourceType = FilterPipe.RESOURCE_TYPE,
+ pipeClass = FilterPipe.class,
description = "filter current resources with following key=value pairs")
public PipeBuilder grep(Object... conf) throws IllegalAccessException {
return pipe(FilterPipe.RESOURCE_TYPE).conf(conf);
}
@Override
- @PipeExecutor(command = "auth", resourceType = AuthorizablePipe.RESOURCE_TYPE, pipeClass = AuthorizablePipe.class,
+ @PipeExecutor(
+ command = "auth",
+ resourceType = AuthorizablePipe.RESOURCE_TYPE,
+ pipeClass = AuthorizablePipe.class,
description = "convert current resource as authorizable")
public PipeBuilder auth(Object... conf) throws IllegalAccessException {
return pipe(AuthorizablePipe.RESOURCE_TYPE).conf(conf);
}
@Override
- @PipeExecutor(command = "xpath", resourceType = XPathPipe.RESOURCE_TYPE, pipeClass = XPathPipe.class,
+ @PipeExecutor(
+ command = "xpath",
+ resourceType = XPathPipe.RESOURCE_TYPE,
+ pipeClass = XPathPipe.class,
description = "create following xpath query's result as output resources")
public PipeBuilder xpath(String expr) {
return pipeWithExpr(XPathPipe.RESOURCE_TYPE, expr);
}
@Override
- @PipeExecutor(command = "children", resourceType = ChildrenPipe.RESOURCE_TYPE, pipeClass = ChildrenPipe.class,
+ @PipeExecutor(
+ command = "children",
+ resourceType = ChildrenPipe.RESOURCE_TYPE,
+ pipeClass = ChildrenPipe.class,
description = "list current resource's immediate children")
public PipeBuilder children(String expr) {
return pipeWithExpr(ChildrenPipe.RESOURCE_TYPE, expr);
}
@Override
- @PipeExecutor(command = "rm", resourceType = RemovePipe.RESOURCE_TYPE, pipeClass = RemovePipe.class,
+ @PipeExecutor(
+ command = "rm",
+ resourceType = RemovePipe.RESOURCE_TYPE,
+ pipeClass = RemovePipe.class,
description = "remove current resource")
public PipeBuilder rm() {
return pipe(RemovePipe.RESOURCE_TYPE);
}
@Override
- @PipeExecutor(command = "traverse", resourceType = TraversePipe.RESOURCE_TYPE, pipeClass = TraversePipe.class,
+ @PipeExecutor(
+ command = "traverse",
+ resourceType = TraversePipe.RESOURCE_TYPE,
+ pipeClass = TraversePipe.class,
description = "traverse current resource")
public PipeBuilder traverse() {
return pipe(TraversePipe.RESOURCE_TYPE);
}
-
@Override
- @PipeExecutor(command = "csv", resourceType = CsvPipe.RESOURCE_TYPE, pipeClass = CsvPipe.class,
+ @PipeExecutor(
+ command = "csv",
+ resourceType = CsvPipe.RESOURCE_TYPE,
+ pipeClass = CsvPipe.class,
description = "read expr's csv and output each line in the bindings")
public PipeBuilder csv(String expr) {
return pipeWithExpr(CsvPipe.RESOURCE_TYPE, expr);
}
@Override
- @PipeExecutor(command = "json", resourceType = JsonPipe.RESOURCE_TYPE, pipeClass = JsonPipe.class,
+ @PipeExecutor(
+ command = "json",
+ resourceType = JsonPipe.RESOURCE_TYPE,
+ pipeClass = JsonPipe.class,
description = "read expr's json array and output each object in the bindings")
public PipeBuilder json(String expr) {
return pipeWithExpr(JsonPipe.RESOURCE_TYPE, expr);
}
@Override
- @PipeExecutor(command = "egrep", resourceType = RegexpPipe.RESOURCE_TYPE, pipeClass = RegexpPipe.class,
+ @PipeExecutor(
+ command = "egrep",
+ resourceType = RegexpPipe.RESOURCE_TYPE,
+ pipeClass = RegexpPipe.class,
description = "read expr's txt and output each found pattern in the binding")
public PipeBuilder egrep(String expr) {
return pipeWithExpr(RegexpPipe.RESOURCE_TYPE, expr);
}
@Override
- @PipeExecutor(command = "mkdir", resourceType = PathPipe.RESOURCE_TYPE, pipeClass = PathPipe.class,
+ @PipeExecutor(
+ command = "mkdir",
+ resourceType = PathPipe.RESOURCE_TYPE,
+ pipeClass = PathPipe.class,
description = "create expr path")
public PipeBuilder mkdir(String expr) {
return pipeWithExpr(PathPipe.RESOURCE_TYPE, expr);
}
@Override
- @PipeExecutor(command = "echo", resourceType = BasePipe.RESOURCE_TYPE, pipeClass = BasePipe.class,
+ @PipeExecutor(
+ command = "echo",
+ resourceType = BasePipe.RESOURCE_TYPE,
+ pipeClass = BasePipe.class,
description = "output input's path")
public PipeBuilder echo(String path) {
try {
pipe(BasePipe.RESOURCE_TYPE).path(path);
- } catch(IllegalAccessException e){
+ } catch (IllegalAccessException e) {
logger.error("error when calling echo {}", path, e);
}
return this;
}
@Override
- @PipeExecutor(command = "parent", resourceType = ParentPipe.RESOURCE_TYPE, pipeClass = ParentPipe.class,
+ @PipeExecutor(
+ command = "parent",
+ resourceType = ParentPipe.RESOURCE_TYPE,
+ pipeClass = ParentPipe.class,
description = "return current's resource parent")
public PipeBuilder parent() {
return pipe(ParentPipe.RESOURCE_TYPE);
}
@Override
- @PipeExecutor(command = "parents", resourceType = ParentsPipe.RESOURCE_TYPE, pipeClass = ParentsPipe.class,
+ @PipeExecutor(
+ command = "parents",
+ resourceType = ParentsPipe.RESOURCE_TYPE,
+ pipeClass = ParentsPipe.class,
description = "return current's resource parents")
public PipeBuilder parents(String expr) {
return pipeWithExpr(ParentsPipe.RESOURCE_TYPE, expr);
}
@Override
- @PipeExecutor(command = "siblings", resourceType = SiblingsPipe.RESOURCE_TYPE, pipeClass = SiblingsPipe.class,
+ @PipeExecutor(
+ command = "siblings",
+ resourceType = SiblingsPipe.RESOURCE_TYPE,
+ pipeClass = SiblingsPipe.class,
description = "list current resource's siblings")
public PipeBuilder siblings(String expr) {
return pipeWithExpr(SiblingsPipe.RESOURCE_TYPE, expr);
}
@Override
- @PipeExecutor(command = "closest", resourceType = ClosestPipe.RESOURCE_TYPE, pipeClass = ClosestPipe.class,
+ @PipeExecutor(
+ command = "closest",
+ resourceType = ClosestPipe.RESOURCE_TYPE,
+ pipeClass = ClosestPipe.class,
description = "return closest resource of the current")
public PipeBuilder closest(String expr) {
return pipeWithExpr(ClosestPipe.RESOURCE_TYPE, expr);
}
@Override
- @PipeExecutor(command = "$", resourceType = FindPipe.RESOURCE_TYPE, pipeClass = FindPipe.class,
+ @PipeExecutor(
+ command = "$",
+ resourceType = FindPipe.RESOURCE_TYPE,
+ pipeClass = FindPipe.class,
description = "find resource from the current, with the given expression as a parameter")
public PipeBuilder $(String expr) {
return pipeWithExpr(FindPipe.RESOURCE_TYPE, expr);
}
@Override
- @PipeExecutor(command = "ref", resourceType = ReferencePipe.RESOURCE_TYPE, pipeClass = ReferencePipe.class,
+ @PipeExecutor(
+ command = "ref",
+ resourceType = ReferencePipe.RESOURCE_TYPE,
+ pipeClass = ReferencePipe.class,
description = "reference passed pipe")
public PipeBuilder ref(String expr) {
return pipeWithExpr(ReferencePipe.RESOURCE_TYPE, expr);
}
@Override
- @PipeExecutor(command = "shallowRef", resourceType = ShallowReferencePipe.RESOURCE_TYPE, pipeClass = ShallowReferencePipe.class,
+ @PipeExecutor(
+ command = "shallowRef",
+ resourceType = ShallowReferencePipe.RESOURCE_TYPE,
+ pipeClass = ShallowReferencePipe.class,
description = "shallow reference passed pipe, to be used for recursive usage")
public PipeBuilder shallowRef(String expr) {
return pipeWithExpr(ShallowReferencePipe.RESOURCE_TYPE, expr);
}
@Override
- @PipeExecutor(command = "mp", resourceType = MultiPropertyPipe.RESOURCE_TYPE, pipeClass = MultiPropertyPipe.class,
+ @PipeExecutor(
+ command = "mp",
+ resourceType = MultiPropertyPipe.RESOURCE_TYPE,
+ pipeClass = MultiPropertyPipe.class,
description = "read MULTI property, and output each value in the bindings")
public PipeBuilder mp() {
return pipe(MultiPropertyPipe.RESOURCE_TYPE);
}
@Override
- @PipeExecutor(command = "pkg", resourceType = PackagePipe.RESOURCE_TYPE, pipeClass = PackagePipe.class,
+ @PipeExecutor(
+ command = "pkg",
+ resourceType = PackagePipe.RESOURCE_TYPE,
+ pipeClass = PackagePipe.class,
description = "package up current resource in given package")
public PipeBuilder pkg(String expr) {
try {
@@ -284,7 +354,10 @@ public class PipeBuilderImpl implements PipeBuilder {
}
@Override
- @PipeExecutor(command = "not", resourceType = NotPipe.RESOURCE_TYPE, pipeClass = NotPipe.class,
+ @PipeExecutor(
+ command = "not",
+ resourceType = NotPipe.RESOURCE_TYPE,
+ pipeClass = NotPipe.class,
description = "invert output: if input, return nothing, if no input, return single resource")
public PipeBuilder not(String expr) {
return pipeWithExpr(NotPipe.RESOURCE_TYPE, expr);
@@ -296,7 +369,7 @@ public class PipeBuilderImpl implements PipeBuilder {
}
@Override
- public PipeBuilder withStrings(String... params){
+ public PipeBuilder withStrings(String... params) {
return writeToCurrentStep(null, false, params);
}
@@ -311,24 +384,33 @@ public class PipeBuilderImpl implements PipeBuilder {
}
@Override
- @PipeExecutor(command = "acls", resourceType = ACLPipe.RESOURCE_TYPE, pipeClass = ACLPipe.class,
+ @PipeExecutor(
+ command = "acls",
+ resourceType = ACLPipe.RESOURCE_TYPE,
+ pipeClass = ACLPipe.class,
description = "output each acls on the resource or acls for authorizable in repository in bindings")
public PipeBuilder acls() {
return pipe(ACLPipe.RESOURCE_TYPE);
}
@Override
- @PipeExecutor(command = "allow", resourceType = ACLPipe.RESOURCE_TYPE, pipeClass = ACLPipe.class,
+ @PipeExecutor(
+ command = "allow",
+ resourceType = ACLPipe.RESOURCE_TYPE,
+ pipeClass = ACLPipe.class,
description = "sets allow acls on the resource")
- public PipeBuilder allow(String expr) throws IllegalAccessException{
- return pipeWithExpr(ACLPipe.RESOURCE_TYPE, expr).with("allow","true");
+ public PipeBuilder allow(String expr) throws IllegalAccessException {
+ return pipeWithExpr(ACLPipe.RESOURCE_TYPE, expr).with("allow", "true");
}
@Override
- @PipeExecutor(command = "deny", resourceType = ACLPipe.RESOURCE_TYPE, pipeClass = ACLPipe.class,
+ @PipeExecutor(
+ command = "deny",
+ resourceType = ACLPipe.RESOURCE_TYPE,
+ pipeClass = ACLPipe.class,
description = "sets deny acls on the resource")
- public PipeBuilder deny(String expr) throws IllegalAccessException{
- return pipeWithExpr(ACLPipe.RESOURCE_TYPE, expr).with("deny","true");
+ public PipeBuilder deny(String expr) throws IllegalAccessException {
+ return pipeWithExpr(ACLPipe.RESOURCE_TYPE, expr).with("deny", "true");
}
/**
@@ -338,7 +420,7 @@ public class PipeBuilderImpl implements PipeBuilder {
* @param params key/value pair list of configuration
* @return updated instance of PipeBuilder
*/
- PipeBuilder writeToCurrentStep (String name, boolean embed, Object... params) {
+ PipeBuilder writeToCurrentStep(String name, boolean embed, Object... params) {
checkArguments(params);
Map<String, Object> props = name != null ? currentStep.confs.get(name) : currentStep.properties;
if (props == null) {
@@ -376,7 +458,8 @@ public class PipeBuilderImpl implements PipeBuilder {
* @throws PersistenceException in case configuration resource couldn't be persisted
* @return resource created
*/
- Resource createResource(ResourceResolver resolver, String path, String type, Map<String, Object> data) throws PersistenceException {
+ Resource createResource(ResourceResolver resolver, String path, String type, Map<String, Object> data)
+ throws PersistenceException {
if (data.keySet().stream().noneMatch(k -> k.contains(SLASH))) {
return ResourceUtil.getOrCreateResource(resolver, path, data, type, false);
}
@@ -384,8 +467,12 @@ public class PipeBuilderImpl implements PipeBuilder {
for (Map.Entry<String, Object> entry : data.entrySet()) {
if (entry.getKey().contains(SLASH)) {
String deepPath = String.join(SLASH, path, StringUtils.substringBeforeLast(entry.getKey(), SLASH));
- createResource(resolver, deepPath, type, Collections.singletonMap(
- StringUtils.substringAfterLast(entry.getKey(), SLASH), entry.getValue()));
+ createResource(
+ resolver,
+ deepPath,
+ type,
+ Collections.singletonMap(
+ StringUtils.substringAfterLast(entry.getKey(), SLASH), entry.getValue()));
if (returnPath.isEmpty() || returnPath.length() > deepPath.length()) {
returnPath = deepPath;
}
@@ -417,10 +504,10 @@ public class PipeBuilderImpl implements PipeBuilder {
Resource persistStep(String path, String parentType, Step step) throws PersistenceException {
Resource resource = createResource(resolver, path, parentType, step.properties);
ModifiableValueMap mvm = resource.adaptTo(ModifiableValueMap.class);
- if (StringUtils.isNotBlank(step.name) && mvm != null){
+ if (StringUtils.isNotBlank(step.name) && mvm != null) {
mvm.put(Pipe.PN_NAME, step.name);
}
- for (Map.Entry<String, Map<String, Object>> entry : step.confs.entrySet()){
+ for (Map.Entry<String, Map<String, Object>> entry : step.confs.entrySet()) {
createResource(resolver, path + "/" + entry.getKey(), NT_SLING_FOLDER, entry.getValue());
logger.debug("built pipe {}'s {} node", path, entry.getKey());
}
@@ -430,11 +517,12 @@ public class PipeBuilderImpl implements PipeBuilder {
@Override
public Pipe build(String path) throws PersistenceException {
Resource pipeResource = persistStep(path, NT_SLING_FOLDER, containerStep);
- if (outputs != null){
- ResourceUtil.getOrCreateResource(resolver, path + "/" + OutputWriter.PARAM_WRITER, outputs, NT_SLING_FOLDER, false);
+ if (outputs != null) {
+ ResourceUtil.getOrCreateResource(
+ resolver, path + "/" + OutputWriter.PARAM_WRITER, outputs, NT_SLING_FOLDER, false);
}
int index = 0;
- for (Step step : steps){
+ for (Step step : steps) {
String name = DEFAULT_NAMES.length > index ? DEFAULT_NAMES[index] : Integer.toString(index);
if (StringUtils.isNotBlank(step.name)) {
name = step.name;
@@ -484,7 +572,7 @@ public class PipeBuilderImpl implements PipeBuilder {
containerStep.setType(ManifoldPipe.RESOURCE_TYPE);
Map<String, Object> bindings = new HashMap<>();
bindings.put(PN_NUM_THREADS, numThreads);
- if (additionalBindings != null){
+ if (additionalBindings != null) {
bindings.putAll(additionalBindings);
}
return run(bindings);
@@ -498,13 +586,14 @@ public class PipeBuilderImpl implements PipeBuilder {
Map<String, Object> bindings;
Map<String, Object> properties;
Map<String, Map<String, Object>> confs = new HashMap<>();
- Step(String type){
+
+ Step(String type) {
properties = new HashMap<>();
setType(type);
}
- void setType(String type){
+ void setType(String type) {
properties.put(SLING_RESOURCE_TYPE_PROPERTY, type);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/sling/pipes/internal/PipeMonitor.java b/src/main/java/org/apache/sling/pipes/internal/PipeMonitor.java
index 4981420..d212dfe 100644
--- a/src/main/java/org/apache/sling/pipes/internal/PipeMonitor.java
+++ b/src/main/java/org/apache/sling/pipes/internal/PipeMonitor.java
@@ -1,21 +1,29 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes.internal;
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.OpenDataException;
+
+import java.util.HashMap;
+import java.util.Map;
+
import org.apache.sling.event.jobs.Job;
import org.apache.sling.pipes.BasePipe;
import org.apache.sling.pipes.ExecutionResult;
@@ -24,11 +32,6 @@ import org.apache.sling.pipes.Plumber;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import javax.management.openmbean.CompositeData;
-import javax.management.openmbean.OpenDataException;
-import java.util.HashMap;
-import java.util.Map;
-
public class PipeMonitor implements PipeMonitorMBean {
protected static final Logger LOGGER = LoggerFactory.getLogger(PipeMonitor.class);
@@ -54,7 +57,7 @@ public class PipeMonitor implements PipeMonitorMBean {
ExecutionResult lastResult;
- public void starts(){
+ public void starts() {
lastStarted = System.currentTimeMillis();
running = true;
status = BasePipe.STATUS_STARTED;
@@ -63,12 +66,12 @@ public class PipeMonitor implements PipeMonitorMBean {
public void ends() {
duration = System.currentTimeMillis() - lastStarted;
mean = ((mean * executions) + duration) / (executions + 1);
- executions ++;
+ executions++;
running = false;
status = BasePipe.STATUS_FINISHED;
}
- public long getFailed(){
+ public long getFailed() {
return failed;
}
@@ -78,12 +81,12 @@ public class PipeMonitor implements PipeMonitorMBean {
}
public void failed() {
- failed ++;
+ failed++;
running = false;
status = BasePipe.STATUS_FINISHED;
}
- public PipeMonitor(Plumber currentPlumber, Pipe pipe){
+ public PipeMonitor(Plumber currentPlumber, Pipe pipe) {
plumber = currentPlumber;
name = pipe.getName();
path = pipe.getResource().getPath();
@@ -116,7 +119,7 @@ public class PipeMonitor implements PipeMonitorMBean {
@Override
public CompositeData getLastResult() {
try {
- if (lastResult != null){
+ if (lastResult != null) {
return lastResult.asCompositeData();
}
} catch (OpenDataException e) {
diff --git a/src/main/java/org/apache/sling/pipes/internal/PipeMonitorMBean.java b/src/main/java/org/apache/sling/pipes/internal/PipeMonitorMBean.java
index 2187541..2a5af6e 100644
--- a/src/main/java/org/apache/sling/pipes/internal/PipeMonitorMBean.java
+++ b/src/main/java/org/apache/sling/pipes/internal/PipeMonitorMBean.java
@@ -1,25 +1,27 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes.internal;
-import org.osgi.annotation.versioning.ProviderType;
-
import javax.management.openmbean.CompositeData;
+import org.osgi.annotation.versioning.ProviderType;
+
/**
* Mbean for providing pipe related statistics and actions
*/
diff --git a/src/main/java/org/apache/sling/pipes/internal/PlumberImpl.java b/src/main/java/org/apache/sling/pipes/internal/PlumberImpl.java
index edb860e..23267c5 100644
--- a/src/main/java/org/apache/sling/pipes/internal/PlumberImpl.java
+++ b/src/main/java/org/apache/sling/pipes/internal/PlumberImpl.java
@@ -1,21 +1,49 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes.internal;
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.query.Query;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import javax.script.Bindings;
+
+import java.io.IOException;
+import java.lang.management.ManagementFactory;
+import java.lang.reflect.Method;
+import java.security.AccessControlException;
+import java.time.Instant;
+import java.time.temporal.ChronoUnit;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.sling.api.SlingConstants;
@@ -63,32 +91,6 @@ import org.osgi.service.metatype.annotations.ObjectClassDefinition;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-import javax.jcr.query.Query;
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-import javax.script.Bindings;
-
-import java.io.IOException;
-import java.lang.management.ManagementFactory;
-import java.lang.reflect.Method;
-import java.security.AccessControlException;
-import java.time.Instant;
-import java.time.temporal.ChronoUnit;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Calendar;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
import static org.apache.jackrabbit.JcrConstants.JCR_LASTMODIFIED;
import static org.apache.sling.api.resource.ResourceResolverFactory.SUBSERVICE;
import static org.apache.sling.pipes.BasePipe.PN_STATUS;
@@ -100,16 +102,17 @@ import static org.apache.sling.pipes.BasePipe.STATUS_STARTED;
/**
* implements plumber interface, registers default pipes, and provides execution facilities
*/
-@Component(service = {Plumber.class, JobConsumer.class, PlumberMXBean.class, Runnable.class}, property = {
- JobConsumer.PROPERTY_TOPICS +"="+PlumberImpl.SLING_EVENT_TOPIC
-})
+@Component(
+ service = {Plumber.class, JobConsumer.class, PlumberMXBean.class, Runnable.class},
+ property = {JobConsumer.PROPERTY_TOPICS + "=" + PlumberImpl.SLING_EVENT_TOPIC})
@Designate(ocd = PlumberImpl.Configuration.class)
public class PlumberImpl implements Plumber, JobConsumer, PlumberMXBean, Runnable {
private final Logger log = LoggerFactory.getLogger(this.getClass());
public static final int DEFAULT_BUFFER_SIZE = 1000;
static final String PN_MONITORED = "monitored";
- static final String MONITORED_PIPES_QUERY = String.format("//element(*,nt:base)[@sling:resourceType='%s' and @%s]", ContainerPipe.RESOURCE_TYPE, PN_MONITORED);
+ static final String MONITORED_PIPES_QUERY = String.format(
+ "//element(*,nt:base)[@sling:resourceType='%s' and @%s]", ContainerPipe.RESOURCE_TYPE, PN_MONITORED);
static final String MBEAN_NAME_FORMAT = "org.apache.sling.pipes:name=%s";
@@ -125,22 +128,23 @@ public class PlumberImpl implements Plumber, JobConsumer, PlumberMXBean, Runnabl
public static final String PIPES_REPOSITORY_PATH = "/var/pipes";
- @ObjectClassDefinition(name="Apache Sling Pipes : Plumber configuration")
+ @ObjectClassDefinition(name = "Apache Sling Pipes : Plumber configuration")
public @interface Configuration {
- @AttributeDefinition(description="Number of iterations after which plumber should saves a pipe execution")
+ @AttributeDefinition(description = "Number of iterations after which plumber should saves a pipe execution")
int bufferSize() default PlumberImpl.DEFAULT_BUFFER_SIZE;
- @AttributeDefinition(description="Number of milliseconds of sleep after each persistence")
+ @AttributeDefinition(description = "Number of milliseconds of sleep after each persistence")
long sleep() default 0L;
- @AttributeDefinition(description="Name of service user, with appropriate rights, that will be used for async execution")
+ @AttributeDefinition(
+ description = "Name of service user, with appropriate rights, that will be used for async execution")
String serviceUser();
- @AttributeDefinition(description="Path of the permission resource for executing pipes")
+ @AttributeDefinition(description = "Path of the permission resource for executing pipes")
String executionPermissionResource() default PERMISSION_EXECUTION;
- @AttributeDefinition(description="Users allowed to register async pipes")
- String[] authorizedUsers() default {"admin"};
+ @AttributeDefinition(description = "Users allowed to register async pipes")
+ String[] authorizedUsers() default {"admin"};
@AttributeDefinition(description = "Paths to search for references in")
String[] referencesPaths() default {};
@@ -160,7 +164,7 @@ public class PlumberImpl implements Plumber, JobConsumer, PlumberMXBean, Runnabl
String scheduler_expression() default "0 0 12 */7 * ?";
}
- @Reference(policy= ReferencePolicy.DYNAMIC, cardinality= ReferenceCardinality.OPTIONAL)
+ @Reference(policy = ReferencePolicy.DYNAMIC, cardinality = ReferenceCardinality.OPTIONAL)
volatile Distributor distributor = null;
@Reference
@@ -187,9 +191,11 @@ public class PlumberImpl implements Plumber, JobConsumer, PlumberMXBean, Runnabl
public static final String PN_NBOUTPUTRESOURCES = "nbOutputResources";
@Activate
- public void activate(Configuration configuration){
+ public void activate(Configuration configuration) {
this.configuration = configuration;
- serviceUser = configuration.serviceUser() != null ? Collections.singletonMap(SUBSERVICE, configuration.serviceUser()) : null;
+ serviceUser = configuration.serviceUser() != null
+ ? Collections.singletonMap(SUBSERVICE, configuration.serviceUser())
+ : null;
allowedUsers = Arrays.asList(configuration.authorizedUsers());
registry = new HashMap<>();
registerPipes();
@@ -200,12 +206,12 @@ public class PlumberImpl implements Plumber, JobConsumer, PlumberMXBean, Runnabl
/**
* Register all pipes declared in pipe builder
*/
- void registerPipes(){
+ void registerPipes() {
registerPipe(ContainerPipe.RESOURCE_TYPE, ContainerPipe.class);
registerPipe(ManifoldPipe.RESOURCE_TYPE, ManifoldPipe.class);
- for (Method method : PipeBuilderImpl.class.getDeclaredMethods()){
+ for (Method method : PipeBuilderImpl.class.getDeclaredMethods()) {
PipeExecutor executor = method.getAnnotation(PipeExecutor.class);
- if (executor != null){
+ if (executor != null) {
registerPipe(executor.resourceType(), executor.pipeClass());
}
}
@@ -243,10 +249,10 @@ public class PlumberImpl implements Plumber, JobConsumer, PlumberMXBean, Runnabl
}
@Deactivate
- public void deactivate(){
+ public void deactivate() {
toggleJmxRegistration(null, PlumberMXBean.class.getName(), false);
- if (monitoredPipes != null){
- for (String path : monitoredPipes.keySet()){
+ if (monitoredPipes != null) {
+ for (String path : monitoredPipes.keySet()) {
toggleJmxRegistration(null, path, false);
}
}
@@ -257,14 +263,14 @@ public class PlumberImpl implements Plumber, JobConsumer, PlumberMXBean, Runnabl
* @param name partial name that will be used for registration
* @param register true to register, false to unregister
*/
- private void toggleJmxRegistration(Object instance, String name, boolean register){
+ private void toggleJmxRegistration(Object instance, String name, boolean register) {
try {
MBeanServer server = ManagementFactory.getPlatformMBeanServer();
ObjectName oName = ObjectName.getInstance(String.format(MBEAN_NAME_FORMAT, name));
if (register && !server.isRegistered(oName)) {
server.registerMBean(instance, oName);
}
- if (!register && server.isRegistered(oName)){
+ if (!register && server.isRegistered(oName)) {
server.unregisterMBean(oName);
}
} catch (Exception e) {
@@ -284,7 +290,8 @@ public class PlumberImpl implements Plumber, JobConsumer, PlumberMXBean, Runnabl
} else {
try {
Class<? extends Pipe> pipeClass = registry.get(resource.getResourceType());
- return pipeClass.getDeclaredConstructor(Plumber.class, Resource.class, PipeBindings.class)
+ return pipeClass
+ .getDeclaredConstructor(Plumber.class, Resource.class, PipeBindings.class)
.newInstance(this, resource, upperBindings);
} catch (Exception e) {
log.error("Unable to properly instantiate the pipe configured in {}", resource.getPath(), e);
@@ -300,9 +307,11 @@ public class PlumberImpl implements Plumber, JobConsumer, PlumberMXBean, Runnabl
if (node != null) {
try {
node.setProperty(JCR_LASTMODIFIED, Calendar.getInstance());
- node.setProperty(JCR_LAST_MODIFIED_BY, resource.getResourceResolver().getUserID());
+ node.setProperty(
+ JCR_LAST_MODIFIED_BY, resource.getResourceResolver().getUserID());
if (configuration.mark_pipe_path()) {
- node.setProperty(JCR_LAST_MODIFIED_BY_PIPE, pipe.getResource().getPath());
+ node.setProperty(
+ JCR_LAST_MODIFIED_BY_PIPE, pipe.getResource().getPath());
}
} catch (RepositoryException e) {
log.debug("There is probably no way to mark that node, which we can't do much about", e);
@@ -312,22 +321,23 @@ public class PlumberImpl implements Plumber, JobConsumer, PlumberMXBean, Runnabl
}
@Override
- public Map<String, Object> getBindingsFromRequest(SlingHttpServletRequest request, boolean writeAllowed) throws IOException {
+ public Map<String, Object> getBindingsFromRequest(SlingHttpServletRequest request, boolean writeAllowed)
+ throws IOException {
Map<String, Object> bindings = new HashMap<>();
String dryRun = request.getParameter(BasePipe.DRYRUN_KEY);
if (StringUtils.isNotBlank(dryRun) && !dryRun.equals(Boolean.FALSE.toString())) {
bindings.put(BasePipe.DRYRUN_KEY, true);
}
String paramBindings = request.getParameter(PARAM_BINDINGS);
- if (StringUtils.isNotBlank(paramBindings)){
+ if (StringUtils.isNotBlank(paramBindings)) {
try {
bindings.putAll(JsonUtil.unbox(JsonUtil.parseObject(paramBindings)));
- } catch (Exception e){
+ } catch (Exception e) {
log.error("Unable to retrieve bindings information", e);
}
}
RequestParameter fileParameter = request.getRequestParameter(PARAM_FILE);
- if (fileParameter != null){
+ if (fileParameter != null) {
bindings.put(AbstractInputStreamPipe.BINDING_IS, fileParameter.getInputStream());
}
@@ -345,7 +355,7 @@ public class PlumberImpl implements Plumber, JobConsumer, PlumberMXBean, Runnabl
@Override
public Job executeAsync(String path, Map<String, Object> bindings) {
- if (StringUtils.isBlank((String)serviceUser.get(SUBSERVICE))) {
+ if (StringUtils.isBlank((String) serviceUser.get(SUBSERVICE))) {
log.error("please configure plumber service user");
}
final Map<String, Object> props = new HashMap<>();
@@ -355,7 +365,8 @@ public class PlumberImpl implements Plumber, JobConsumer, PlumberMXBean, Runnabl
}
@Override
- public ExecutionResult execute(ResourceResolver resolver, String path, Map additionalBindings, OutputWriter writer, boolean save) {
+ public ExecutionResult execute(
+ ResourceResolver resolver, String path, Map additionalBindings, OutputWriter writer, boolean save) {
Resource pipeResource = resolver.getResource(path);
Pipe pipe = getPipe(pipeResource);
if (pipe == null) {
@@ -364,9 +375,10 @@ public class PlumberImpl implements Plumber, JobConsumer, PlumberMXBean, Runnabl
return execute(resolver, pipe, additionalBindings, writer, save);
}
- private ExecutionResult internalExecute(ResourceResolver resolver, OutputWriter writer, Pipe pipe) throws InterruptedException, PersistenceException {
+ private ExecutionResult internalExecute(ResourceResolver resolver, OutputWriter writer, Pipe pipe)
+ throws InterruptedException, PersistenceException {
ExecutionResult result = new ExecutionResult(writer);
- for (Iterator<Resource> it = pipe.getOutput(); it.hasNext();){
+ for (Iterator<Resource> it = pipe.getOutput(); it.hasNext(); ) {
Resource resource = it.next();
checkError(pipe, result);
if (resource != null) {
@@ -380,7 +392,8 @@ public class PlumberImpl implements Plumber, JobConsumer, PlumberMXBean, Runnabl
}
@Override
- public ExecutionResult execute(ResourceResolver resolver, Pipe pipe, Map additionalBindings, OutputWriter writer, boolean save) {
+ public ExecutionResult execute(
+ ResourceResolver resolver, Pipe pipe, Map additionalBindings, OutputWriter writer, boolean save) {
checkPermissions(resolver, configuration.executionPermissionResource());
boolean success = false;
PipeMonitor monitor = null;
@@ -388,12 +401,12 @@ public class PlumberImpl implements Plumber, JobConsumer, PlumberMXBean, Runnabl
long start = System.currentTimeMillis();
try {
boolean readOnly = false;
- if (additionalBindings != null){
+ if (additionalBindings != null) {
pipe.getBindings().addBindings(additionalBindings);
- readOnly = (Boolean)additionalBindings.getOrDefault(BasePipe.READ_ONLY, false);
+ readOnly = (Boolean) additionalBindings.getOrDefault(BasePipe.READ_ONLY, false);
}
- if (! pipe.isDryRun() && readOnly && pipe.modifiesContent()) {
+ if (!pipe.isDryRun() && readOnly && pipe.modifiesContent()) {
throw new IllegalArgumentException("This pipe modifies content, you should use a POST request");
}
log.debug("[{}] before execution hook is called", pipe);
@@ -401,13 +414,13 @@ public class PlumberImpl implements Plumber, JobConsumer, PlumberMXBean, Runnabl
log.info("[{}] execution starts, save ({})", pipe, save);
Resource confResource = pipe.getResource();
writer.setPipe(pipe);
- if (isRunning(confResource)){
+ if (isRunning(confResource)) {
throw new IllegalStateException("Pipe is already running");
}
monitor = monitoredPipes.get(confResource.getPath());
writeStatus(pipe, STATUS_STARTED, null);
resolver.commit();
- if (monitor != null){
+ if (monitor != null) {
monitor.starts();
}
result = internalExecute(resolver, writer, pipe);
@@ -417,7 +430,7 @@ public class PlumberImpl implements Plumber, JobConsumer, PlumberMXBean, Runnabl
if (writer.autoClose()) {
writer.ends();
}
- if (monitor != null){
+ if (monitor != null) {
monitor.ends();
monitor.setLastResult(result);
}
@@ -440,11 +453,11 @@ public class PlumberImpl implements Plumber, JobConsumer, PlumberMXBean, Runnabl
log.info("[{}] done executing in {}.", pipe.getName(), time);
log.debug("[{}] after execution hook is called", pipe);
pipe.after();
- if (!success && monitor != null){
+ if (!success && monitor != null) {
monitor.failed();
}
}
- //returning void result if we get there
+ // returning void result if we get there
return new ExecutionResult(writer);
}
@@ -453,18 +466,18 @@ public class PlumberImpl implements Plumber, JobConsumer, PlumberMXBean, Runnabl
* @param pipe current pipe
* @param result current result
*/
- void checkError(Pipe pipe, ExecutionResult result){
+ void checkError(Pipe pipe, ExecutionResult result) {
String error = pipe.getBindings().popCurrentError();
- if (StringUtils.isNotBlank(error)){
+ if (StringUtils.isNotBlank(error)) {
result.addError(error);
}
}
private boolean shouldSave(ResourceResolver resolver, Pipe pipe, ExecutionResult result, Resource currentResource) {
- return pipe.modifiesContent()
- && resolver.hasChanges()
- && !pipe.isDryRun()
- && (currentResource == null || result.size() % configuration.bufferSize() == 0);
+ return pipe.modifiesContent()
+ && resolver.hasChanges()
+ && !pipe.isDryRun()
+ && (currentResource == null || result.size() % configuration.bufferSize() == 0);
}
/**
@@ -475,19 +488,24 @@ public class PlumberImpl implements Plumber, JobConsumer, PlumberMXBean, Runnabl
* @param currentResource if running, null if ended
* @throws PersistenceException in case save fails
*/
- void persist(ResourceResolver resolver, Pipe pipe, ExecutionResult result, Resource currentResource) throws PersistenceException, InterruptedException {
+ void persist(ResourceResolver resolver, Pipe pipe, ExecutionResult result, Resource currentResource)
+ throws PersistenceException, InterruptedException {
if (shouldSave(resolver, pipe, result, currentResource)) {
log.info("[{}] saving changes...", pipe.getName());
writeStatus(pipe, currentResource == null ? STATUS_FINISHED : currentResource.getPath(), result);
resolver.commit();
if (currentResource == null && distributor != null && StringUtils.isNotBlank(pipe.getDistributionAgent())) {
log.info("a distribution agent is configured, will try to distribute the changes");
- DistributionRequest request = new SimpleDistributionRequest(DistributionRequestType.ADD, true, result.getCurrentPathSet().toArray(new String[result.getCurrentPathSet().size()]));
+ DistributionRequest request = new SimpleDistributionRequest(
+ DistributionRequestType.ADD,
+ true,
+ result.getCurrentPathSet()
+ .toArray(new String[result.getCurrentPathSet().size()]));
DistributionResponse response = distributor.distribute(pipe.getDistributionAgent(), resolver, request);
log.info("distribution response : {}", response);
}
if (result.size() > configuration.bufferSize()) {
- //avoid too big foot print
+ // avoid too big foot print
result.emptyCurrentSet();
}
if (configuration.sleep() > 0) {
@@ -513,10 +531,10 @@ public class PlumberImpl implements Plumber, JobConsumer, PlumberMXBean, Runnabl
* @param status status to write
* @throws RepositoryException in case write goes wrong
*/
- void writeStatus(Pipe pipe, String status, ExecutionResult result){
- if (StringUtils.isNotBlank(status)){
+ void writeStatus(Pipe pipe, String status, ExecutionResult result) {
+ if (StringUtils.isNotBlank(status)) {
ModifiableValueMap vm = pipe.getResource().adaptTo(ModifiableValueMap.class);
- if( vm != null) {
+ if (vm != null) {
vm.put(PN_STATUS, status);
vm.put(PN_NBOUTPUTRESOURCES, result != null ? result.size() : -1);
Calendar cal = new GregorianCalendar();
@@ -529,9 +547,9 @@ public class PlumberImpl implements Plumber, JobConsumer, PlumberMXBean, Runnabl
@Override
public String getStatus(Resource pipeResource) {
Resource statusResource = pipeResource.getChild(PN_STATUS);
- if (statusResource != null){
+ if (statusResource != null) {
String status = statusResource.adaptTo(String.class);
- if (StringUtils.isNotBlank(status)){
+ if (StringUtils.isNotBlank(status)) {
return status;
}
}
@@ -550,9 +568,9 @@ public class PlumberImpl implements Plumber, JobConsumer, PlumberMXBean, Runnabl
@Override
public JobResult process(Job job) {
- try(ResourceResolver resolver = factory.getServiceResourceResolver(serviceUser)){
- String path = (String)job.getProperty(SlingConstants.PROPERTY_PATH);
- Map<String, Object> bindings = (Map)job.getProperty(PipeBindings.NN_ADDITIONALBINDINGS);
+ try (ResourceResolver resolver = factory.getServiceResourceResolver(serviceUser)) {
+ String path = (String) job.getProperty(SlingConstants.PROPERTY_PATH);
+ Map<String, Object> bindings = (Map) job.getProperty(PipeBindings.NN_ADDITIONALBINDINGS);
OutputWriter writer = new JsonWriter();
writer.starts();
execute(resolver, path, bindings, writer, true);
@@ -571,12 +589,12 @@ public class PlumberImpl implements Plumber, JobConsumer, PlumberMXBean, Runnabl
getMonitoredPipes().stream().forEach(bean -> map.put(bean.getPath(), bean));
if (monitoredPipes != null) {
Collection<String> shouldBeRemoved = CollectionUtils.subtract(monitoredPipes.keySet(), map.keySet());
- for (String path : shouldBeRemoved){
+ for (String path : shouldBeRemoved) {
toggleJmxRegistration(null, path, false);
}
}
monitoredPipes = map;
- for (Map.Entry<String, PipeMonitor> entry : monitoredPipes.entrySet()){
+ for (Map.Entry<String, PipeMonitor> entry : monitoredPipes.entrySet()) {
toggleJmxRegistration(entry.getValue(), entry.getKey(), true);
}
}
@@ -585,7 +603,8 @@ public class PlumberImpl implements Plumber, JobConsumer, PlumberMXBean, Runnabl
Collection<PipeMonitor> beans = new ArrayList<>();
if (serviceUser != null) {
try (ResourceResolver resolver = factory.getServiceResourceResolver(serviceUser)) {
- for (Iterator<Resource> resourceIterator = resolver.findResources(MONITORED_PIPES_QUERY, Query.XPATH); resourceIterator.hasNext(); ) {
+ for (Iterator<Resource> resourceIterator = resolver.findResources(MONITORED_PIPES_QUERY, Query.XPATH);
+ resourceIterator.hasNext(); ) {
beans.add(new PipeMonitor(this, getPipe(resourceIterator.next())));
}
} catch (LoginException e) {
@@ -605,8 +624,8 @@ public class PlumberImpl implements Plumber, JobConsumer, PlumberMXBean, Runnabl
*/
public String generateUniquePath() {
final Calendar now = Calendar.getInstance();
- return PIPES_REPOSITORY_PATH + '/' + now.get(Calendar.YEAR) + '/' + now.get(Calendar.MONTH) + '/' + now.get(Calendar.DAY_OF_MONTH) + "/"
- + UUID.randomUUID().toString();
+ return PIPES_REPOSITORY_PATH + '/' + now.get(Calendar.YEAR) + '/' + now.get(Calendar.MONTH) + '/'
+ + now.get(Calendar.DAY_OF_MONTH) + "/" + UUID.randomUUID().toString();
}
void cleanResourceAndEmptyParents(Resource resource) throws PersistenceException {
@@ -665,4 +684,4 @@ public class PlumberImpl implements Plumber, JobConsumer, PlumberMXBean, Runnabl
JxltEngine internalEngine = new JxltEngine(bindings);
return internalEngine.parse(expr);
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/sling/pipes/internal/PlumberServlet.java b/src/main/java/org/apache/sling/pipes/internal/PlumberServlet.java
index 575aea1..8c95f35 100644
--- a/src/main/java/org/apache/sling/pipes/internal/PlumberServlet.java
+++ b/src/main/java/org/apache/sling/pipes/internal/PlumberServlet.java
@@ -1,22 +1,31 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes.internal;
-import static org.apache.sling.pipes.internal.PlumberServlet.RESOURCE_TYPE;
+import javax.servlet.Servlet;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletResponse;
+
+import java.io.IOException;
+import java.security.AccessControlException;
+import java.util.Arrays;
+import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.apache.sling.api.SlingHttpServletRequest;
@@ -35,24 +44,19 @@ import org.osgi.service.metatype.annotations.AttributeDefinition;
import org.osgi.service.metatype.annotations.Designate;
import org.osgi.service.metatype.annotations.ObjectClassDefinition;
-import javax.servlet.Servlet;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.security.AccessControlException;
-import java.util.Arrays;
-import java.util.Map;
+import static org.apache.sling.pipes.internal.PlumberServlet.RESOURCE_TYPE;
/**
* Servlet executing plumber for a pipe path given as 'path' parameter,
* it can also be launched against a container pipe resource directly (no need for path parameter)
*/
-@Component(service = {Servlet.class},
- property= {
- ServletResolverConstants.SLING_SERVLET_METHODS + "=GET",
- ServletResolverConstants.SLING_SERVLET_METHODS + "=POST",
- ServletResolverConstants.SLING_SERVLET_EXTENSIONS + "=json",
- ServletResolverConstants.SLING_SERVLET_EXTENSIONS + "=csv"
+@Component(
+ service = {Servlet.class},
+ property = {
+ ServletResolverConstants.SLING_SERVLET_METHODS + "=GET",
+ ServletResolverConstants.SLING_SERVLET_METHODS + "=POST",
+ ServletResolverConstants.SLING_SERVLET_EXTENSIONS + "=json",
+ ServletResolverConstants.SLING_SERVLET_EXTENSIONS + "=csv"
})
@Designate(ocd = PlumberServlet.Configuration.class)
public class PlumberServlet extends AbstractPlumberServlet {
@@ -75,21 +79,27 @@ public class PlumberServlet extends AbstractPlumberServlet {
enabled = configuration.enabled();
}
- @ObjectClassDefinition(name="Apache Sling Pipes : Plumber Servlet Configuration")
+ @ObjectClassDefinition(name = "Apache Sling Pipes : Plumber Servlet Configuration")
public @interface Configuration {
- @AttributeDefinition(description="Enable servlet to execute pipe, if disabled will return 503")
+ @AttributeDefinition(description = "Enable servlet to execute pipe, if disabled will return 503")
boolean enabled() default true;
- @AttributeDefinition(description="Resource types with which that servlet can be called")
- String[] sling_servlet_resourceTypes() default { RESOURCE_TYPE, ContainerPipe.RESOURCE_TYPE,
- ManifoldPipe.RESOURCE_TYPE, AuthorizablePipe.RESOURCE_TYPE,
- WritePipe.RESOURCE_TYPE, ChildrenPipe.RESOURCE_TYPE };
+ @AttributeDefinition(description = "Resource types with which that servlet can be called")
+ String[] sling_servlet_resourceTypes() default {
+ RESOURCE_TYPE,
+ ContainerPipe.RESOURCE_TYPE,
+ ManifoldPipe.RESOURCE_TYPE,
+ AuthorizablePipe.RESOURCE_TYPE,
+ WritePipe.RESOURCE_TYPE,
+ ChildrenPipe.RESOURCE_TYPE
+ };
}
@Override
- protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException, IOException {
+ protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response)
+ throws ServletException, IOException {
if (enabled) {
- if (Arrays.asList(request.getRequestPathInfo().getSelectors()).contains(BasePipe.PN_STATUS)){
+ if (Arrays.asList(request.getRequestPathInfo().getSelectors()).contains(BasePipe.PN_STATUS)) {
response.getWriter().append(plumber.getStatus(request.getResource()));
} else {
execute(request, response, false);
@@ -101,7 +111,8 @@ public class PlumberServlet extends AbstractPlumberServlet {
}
@Override
- protected void doPost(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException, IOException {
+ protected void doPost(SlingHttpServletRequest request, SlingHttpServletResponse response)
+ throws ServletException, IOException {
if (enabled) {
execute(request, response, true);
} else {
@@ -117,32 +128,35 @@ public class PlumberServlet extends AbstractPlumberServlet {
* @param writeAllowed should we consider this execution is about to modify content
* @throws ServletException in case something is wrong...
*/
- void execute(SlingHttpServletRequest request, SlingHttpServletResponse response, boolean writeAllowed) throws ServletException {
- String path = request.getResource().getResourceType().equals(RESOURCE_TYPE) ? request.getParameter(PARAM_PATH) : request.getResource().getPath();
+ void execute(SlingHttpServletRequest request, SlingHttpServletResponse response, boolean writeAllowed)
+ throws ServletException {
+ String path = request.getResource().getResourceType().equals(RESOURCE_TYPE)
+ ? request.getParameter(PARAM_PATH)
+ : request.getResource().getPath();
try {
if (StringUtils.isBlank(path)) {
throw new IllegalArgumentException("path should be provided");
}
Map<String, Object> bindings = plumber.getBindingsFromRequest(request, writeAllowed);
String asyncParam = request.getParameter(PARAM_ASYNC);
- if (StringUtils.isNotBlank(asyncParam) && asyncParam.equals(Boolean.TRUE.toString())){
+ if (StringUtils.isNotBlank(asyncParam) && asyncParam.equals(Boolean.TRUE.toString())) {
Job job = plumber.executeAsync(request.getResourceResolver(), path, bindings);
- if (job != null){
+ if (job != null) {
response.getWriter().append("pipe execution registered as " + job.getId());
response.setStatus(HttpServletResponse.SC_CREATED);
} else {
- response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Some issue with your request, or server not being ready for async execution");
+ response.sendError(
+ HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
+ "Some issue with your request, or server not being ready for async execution");
}
} else {
OutputWriter writer = getWriter(request, response);
plumber.execute(request.getResourceResolver(), path, bindings, writer, true);
}
- }
- catch (AccessControlException e) {
+ } catch (AccessControlException e) {
response.setStatus(HttpServletResponse.SC_FORBIDDEN);
- }
- catch (Exception e) {
+ } catch (Exception e) {
throw new ServletException(e);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/sling/pipes/internal/ReferencePipe.java b/src/main/java/org/apache/sling/pipes/internal/ReferencePipe.java
index 269a197..20ecb09 100644
--- a/src/main/java/org/apache/sling/pipes/internal/ReferencePipe.java
+++ b/src/main/java/org/apache/sling/pipes/internal/ReferencePipe.java
@@ -1,21 +1,25 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes.internal;
+import java.util.Iterator;
+
import org.apache.commons.lang3.StringUtils;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.pipes.Pipe;
@@ -25,8 +29,6 @@ import org.apache.sling.pipes.SuperPipe;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.Iterator;
-
/**
* executes a pipe referred in the configuration
*/
@@ -57,7 +59,8 @@ public class ReferencePipe extends SuperPipe {
pipeResource = plumber.getReferencedResource(resource, referencePath);
}
if (pipeResource == null) {
- throw new IllegalArgumentException("Reference configuration error: There is no resource at " + referencePath);
+ throw new IllegalArgumentException(
+ "Reference configuration error: There is no resource at " + referencePath);
}
reference = plumber.getPipe(pipeResource, bindings);
if (reference == null) {
@@ -79,7 +82,7 @@ public class ReferencePipe extends SuperPipe {
if (StringUtils.isNotBlank(skip)) {
Object object = bindings.instantiateObject(skip);
if (object instanceof Boolean) {
- return (Boolean)object;
+ return (Boolean) object;
}
}
return false;
@@ -93,9 +96,9 @@ public class ReferencePipe extends SuperPipe {
@Override
protected Iterator<Resource> computeSubpipesOutput() {
- if (! shouldBeSkipped()) {
+ if (!shouldBeSkipped()) {
return computeReferredOutput();
}
return EMPTY_ITERATOR;
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/sling/pipes/internal/RemovePipe.java b/src/main/java/org/apache/sling/pipes/internal/RemovePipe.java
index 8c8f01c..2255228 100644
--- a/src/main/java/org/apache/sling/pipes/internal/RemovePipe.java
+++ b/src/main/java/org/apache/sling/pipes/internal/RemovePipe.java
@@ -1,21 +1,31 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes.internal;
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.Property;
+import javax.jcr.RepositoryException;
+
+import java.util.Collections;
+import java.util.Iterator;
+
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ValueMap;
import org.apache.sling.pipes.BasePipe;
@@ -25,14 +35,6 @@ import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.Property;
-import javax.jcr.RepositoryException;
-
-import java.util.Collections;
-import java.util.Iterator;
-
/**
* this pipe tries to remove the input resource, abstracting its type,
* returning parent of the input
@@ -66,12 +68,12 @@ public class RemovePipe extends BasePipe {
parentPath = removeTree(resource, filter);
} else {
Property property = resource.adaptTo(Property.class);
- if (property != null){
+ if (property != null) {
Node parent = property.getParent();
if (parent != null) {
parentPath = parent.getPath();
logger.info("removing property {}", property.getPath());
- if (!isDryRun()){
+ if (!isDryRun()) {
property.remove();
}
}
@@ -87,9 +89,9 @@ public class RemovePipe extends BasePipe {
}
private boolean removeProperty(@NotNull Node node, String key) throws RepositoryException {
- if (! IGNORED_PROPERTIES.contains(key) && node.hasProperty(key)){
+ if (!IGNORED_PROPERTIES.contains(key) && node.hasProperty(key)) {
logger.info("removing property {}", node.getProperty(key).getPath());
- if (!isDryRun()){
+ if (!isDryRun()) {
node.getProperty(key).remove();
return true;
}
@@ -106,9 +108,9 @@ public class RemovePipe extends BasePipe {
Node node = resource.adaptTo(Node.class);
if (node != null) {
ValueMap configuredProperties = configuration.getValueMap();
- for (String key : configuredProperties.keySet()){
+ for (String key : configuredProperties.keySet()) {
if (removeProperty(node, key)) {
- count ++;
+ count++;
}
}
}
@@ -117,10 +119,10 @@ public class RemovePipe extends BasePipe {
}
private String removeNode(Resource resource) throws RepositoryException {
- //explicit configuration to remove the node altogether
+ // explicit configuration to remove the node altogether
logger.info("removing node {}", resource.getPath());
Resource parent = resource.getParent();
- if (parent != null && !isDryRun()){
+ if (parent != null && !isDryRun()) {
Node node = resource.adaptTo(Node.class);
if (node != null) {
node.remove();
@@ -136,13 +138,13 @@ public class RemovePipe extends BasePipe {
int configuredProperties = removeProperties(resource, configuration);
Node configuredNode = configuration != null ? configuration.adaptTo(Node.class) : null;
NodeIterator childConf = configuredNode != null ? configuredNode.getNodes() : null;
- if (childConf == null || (! childConf.hasNext() && configuredProperties == 0)){
+ if (childConf == null || (!childConf.hasNext() && configuredProperties == 0)) {
remainingPath = removeNode(resource);
} else {
while (childConf.hasNext()) {
Node childToRemove = childConf.nextNode();
Resource child = resource.getChild(childToRemove.getName());
- if (child != null){
+ if (child != null) {
removeTree(child, configuration.getChild(childToRemove.getName()));
}
}
diff --git a/src/main/java/org/apache/sling/pipes/internal/ShallowReferencePipe.java b/src/main/java/org/apache/sling/pipes/internal/ShallowReferencePipe.java
index 5bb576c..f92e703 100644
--- a/src/main/java/org/apache/sling/pipes/internal/ShallowReferencePipe.java
+++ b/src/main/java/org/apache/sling/pipes/internal/ShallowReferencePipe.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes.internal;
@@ -32,17 +34,17 @@ public class ShallowReferencePipe extends ReferencePipe {
@Override
public boolean modifiesContent() {
- //we assume some other pipes will take care of that status
+ // we assume some other pipes will take care of that status
return false;
}
@Override
public void before() {
- //we don't want anything to be executed before
+ // we don't want anything to be executed before
}
@Override
public void after() {
- //we don't want anything to be executed after
+ // we don't want anything to be executed after
}
}
diff --git a/src/main/java/org/apache/sling/pipes/internal/TraversePipe.java b/src/main/java/org/apache/sling/pipes/internal/TraversePipe.java
index 7410a66..6b4a9cd 100644
--- a/src/main/java/org/apache/sling/pipes/internal/TraversePipe.java
+++ b/src/main/java/org/apache/sling/pipes/internal/TraversePipe.java
@@ -1,21 +1,32 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes.internal;
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.PropertyIterator;
+import javax.jcr.RepositoryException;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
import org.apache.commons.collections4.IteratorUtils;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ValueMap;
@@ -25,14 +36,6 @@ import org.apache.sling.pipes.Plumber;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import javax.jcr.Node;
-import javax.jcr.Property;
-import javax.jcr.PropertyIterator;
-import javax.jcr.RepositoryException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
/**
* Traverse either nodes or properties, in breadth first or depth first, for properties, they can be white listed
*/
@@ -51,7 +54,6 @@ public class TraversePipe extends BasePipe {
super(plumber, resource, upperBindings);
}
-
@Override
protected Iterator<Resource> computeOutput() {
return new TraversingIterator(getInput(), getResource().getValueMap());
@@ -60,7 +62,7 @@ public class TraversePipe extends BasePipe {
/**
* iterative DFS or BFS jcr node tree iterator, transforming each visited node in a configured set of resources
*/
- public class TraversingIterator implements Iterator<Resource>{
+ public class TraversingIterator implements Iterator<Resource> {
protected static final String PN_PROPERTIES = "properties";
protected static final String PN_NAMEGLOBS = "nameGlobs";
protected static final String PN_BREADTH = "breadthFirst";
@@ -79,7 +81,7 @@ public class TraversePipe extends BasePipe {
* @throws RepositoryException
*/
void refreshResourceIterator(Node node) throws RepositoryException {
- if (properties){
+ if (properties) {
PropertyIterator it = nameGlobs != null ? node.getProperties(nameGlobs) : node.getProperties();
currentResources = IteratorUtils.transformedIterator(it, o -> {
try {
@@ -107,14 +109,14 @@ public class TraversePipe extends BasePipe {
* @param root
* @param configuration
*/
- TraversingIterator(Resource root, ValueMap configuration){
+ TraversingIterator(Resource root, ValueMap configuration) {
properties = configuration.get(PN_PROPERTIES, false);
if (properties) {
nameGlobs = configuration.get(PN_NAMEGLOBS, String[].class);
}
breadthFirst = configuration.get(PN_BREADTH, false);
maxLevel = configuration.get(PN_DEPTH, -1);
- if (maxLevel > 0){
+ if (maxLevel > 0) {
initialLevel = getDepth(root.getPath());
maxLevel = initialLevel + maxLevel;
}
diff --git a/src/main/java/org/apache/sling/pipes/internal/WritePipe.java b/src/main/java/org/apache/sling/pipes/internal/WritePipe.java
index 11170d9..072aae4 100644
--- a/src/main/java/org/apache/sling/pipes/internal/WritePipe.java
+++ b/src/main/java/org/apache/sling/pipes/internal/WritePipe.java
@@ -1,36 +1,28 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes.internal;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.sling.api.resource.ModifiableValueMap;
-import org.apache.sling.api.resource.Resource;
-import org.apache.sling.api.resource.ValueMap;
-import org.apache.sling.pipes.BasePipe;
-import org.apache.sling.pipes.PipeBindings;
-import org.apache.sling.pipes.Plumber;
-import org.jetbrains.annotations.Nullable;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import javax.jcr.Node;
import javax.jcr.NodeIterator;
import javax.jcr.Property;
import javax.jcr.RepositoryException;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
@@ -40,6 +32,17 @@ import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.sling.api.resource.ModifiableValueMap;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ValueMap;
+import org.apache.sling.pipes.BasePipe;
+import org.apache.sling.pipes.PipeBindings;
+import org.apache.sling.pipes.Plumber;
+import org.jetbrains.annotations.Nullable;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
/**
* pipe that writes to configured resource
*/
@@ -67,13 +70,15 @@ public class WritePipe extends BasePipe {
if (getConfiguration() == null) {
String pathCandidate = getExpr();
if (StringUtils.isBlank(pathCandidate)) {
- throw new IllegalArgumentException("write pipe is mis-configured: it should have a configuration node, or an expression");
+ throw new IllegalArgumentException(
+ "write pipe is mis-configured: it should have a configuration node, or an expression");
}
Resource candidate = resolver.getResource(pathCandidate);
if (candidate != null) {
return candidate.adaptTo(Node.class);
} else {
- throw new IllegalArgumentException("write pipe expression" + pathCandidate + " does not refer to any existing resource");
+ throw new IllegalArgumentException(
+ "write pipe expression" + pathCandidate + " does not refer to any existing resource");
}
} else {
confTree = getConfiguration().adaptTo(Node.class);
@@ -82,7 +87,6 @@ public class WritePipe extends BasePipe {
return confTree;
}
-
/**
* convert the configured string value (can be an expression) in a value that can be written in a resource.
* also handles patch for multivalue properties like <code>+[value]</code> in which case <code>value</code>
@@ -95,13 +99,14 @@ public class WritePipe extends BasePipe {
protected Object computeValue(Resource resource, String key, String expression) {
Object value = bindings.instantiateObject(expression);
if (value instanceof String) {
- //in that case we treat special case like MV or patches
- String sValue = (String)value;
+ // in that case we treat special case like MV or patches
+ String sValue = (String) value;
Matcher patch = ADD_PATCH.matcher(sValue);
if (patch.matches()) {
String newValue = patch.group(1);
String[] actualValues = resource.getValueMap().get(key, String[].class);
- List<String> newValues = actualValues != null ? new LinkedList<>(Arrays.asList(actualValues)) : new ArrayList<>();
+ List<String> newValues =
+ actualValues != null ? new LinkedList<>(Arrays.asList(actualValues)) : new ArrayList<>();
if (!newValues.contains(newValue)) {
newValues.add(newValue);
}
@@ -124,13 +129,13 @@ public class WritePipe extends BasePipe {
* @param expression configured value to write
* @return actual value to write to the resource
*/
- protected Object computeValue(Resource resource, String key, Object expression) {
+ protected Object computeValue(Resource resource, String key, Object expression) {
if (expression instanceof String) {
- return computeValue(resource, key, (String)expression);
- } else if (expression instanceof String[]){
+ return computeValue(resource, key, (String) expression);
+ } else if (expression instanceof String[]) {
List<String> values = new ArrayList<>();
- for (String expr : (String[])expression){
- values.add((String)computeValue(resource, key, expr));
+ for (String expr : (String[]) expression) {
+ values.add((String) computeValue(resource, key, expr));
}
return values.toArray(new String[values.size()]);
}
@@ -144,12 +149,12 @@ public class WritePipe extends BasePipe {
private void copyProperty(ModifiableValueMap targetProperties, Resource target, String key, Object value) {
if (value == null) {
- //null value are not handled by modifiable value maps,
- //removing the property if it exists
+ // null value are not handled by modifiable value maps,
+ // removing the property if it exists
addPropertyToRemove(target.getChild(key));
} else {
logger.info("writing {}@{}={}", target.getPath(), key, value);
- if (!isDryRun()){
+ if (!isDryRun()) {
targetProperties.put(key, value);
}
}
@@ -162,12 +167,12 @@ public class WritePipe extends BasePipe {
* @param conf configured resource that holds all properties to write (and subpipes)
* @param target target resource on which configured values will be written
*/
- private void copyProperties(@Nullable Resource conf, Resource target) {
+ private void copyProperties(@Nullable Resource conf, Resource target) {
ValueMap writeMap = conf != null ? conf.adaptTo(ValueMap.class) : null;
ModifiableValueMap targetProperties = target.adaptTo(ModifiableValueMap.class);
boolean modified = false;
- //writing current node
+ // writing current node
if (properties != null && writeMap != null) {
for (Map.Entry<String, Object> entry : writeMap.entrySet()) {
if (!IGNORED_PROPERTIES.contains(entry.getKey())) {
@@ -187,7 +192,7 @@ public class WritePipe extends BasePipe {
* we store all property to remove for very last moment (in order to potentially reuse their value)
* @param property property resource that should be removed
*/
- private void addPropertyToRemove(Resource property){
+ private void addPropertyToRemove(Resource property) {
if (property != null) {
if (propertiesToRemove == null) {
propertiesToRemove = new ArrayList<>();
@@ -201,8 +206,10 @@ public class WritePipe extends BasePipe {
name = bindings.conditionalString(name);
if (name == null) {
logger.debug("name has been instantiated as null, not writing that tree");
- } else if (!isDryRun()){
- Node childTarget = targetNode.hasNode(name) ? targetNode.getNode(name) : targetNode.addNode(name, source.getPrimaryNodeType().getName());
+ } else if (!isDryRun()) {
+ Node childTarget = targetNode.hasNode(name)
+ ? targetNode.getNode(name)
+ : targetNode.addNode(name, source.getPrimaryNodeType().getName());
logger.debug("writing tree {}", childTarget.getPath());
writeTree(source, resolver.getResource(childTarget.getPath()));
}
@@ -254,7 +261,7 @@ public class WritePipe extends BasePipe {
} catch (RepositoryException e) {
throw new IllegalStateException(e);
} finally {
- if (propertiesToRemove != null){
+ if (propertiesToRemove != null) {
propertiesToRemove.clear();
}
}
diff --git a/src/main/java/org/apache/sling/pipes/internal/XPathPipe.java b/src/main/java/org/apache/sling/pipes/internal/XPathPipe.java
index 93058ba..28b1e0b 100644
--- a/src/main/java/org/apache/sling/pipes/internal/XPathPipe.java
+++ b/src/main/java/org/apache/sling/pipes/internal/XPathPipe.java
@@ -1,21 +1,27 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes.internal;
+import javax.jcr.query.Query;
+
+import java.util.Iterator;
+
import org.apache.commons.lang3.StringUtils;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.pipes.BasePipe;
@@ -24,9 +30,6 @@ import org.apache.sling.pipes.Plumber;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import javax.jcr.query.Query;
-import java.util.Iterator;
-
/**
* generates output based on an xpath query (no input is considered)
*/
@@ -42,7 +45,7 @@ public class XPathPipe extends BasePipe {
@Override
protected Iterator<Resource> computeOutput() {
String query = getExpr();
- if (StringUtils.isNotBlank(query)){
+ if (StringUtils.isNotBlank(query)) {
logger.info("Executing query: {}", query);
return resolver.findResources(query, Query.XPATH);
}
diff --git a/src/main/java/org/apache/sling/pipes/internal/bindings/ConfigurationMap.java b/src/main/java/org/apache/sling/pipes/internal/bindings/ConfigurationMap.java
index 0cddf73..c804cc0 100644
--- a/src/main/java/org/apache/sling/pipes/internal/bindings/ConfigurationMap.java
+++ b/src/main/java/org/apache/sling/pipes/internal/bindings/ConfigurationMap.java
@@ -1,31 +1,33 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes.internal.bindings;
-import org.apache.sling.api.resource.Resource;
-import org.apache.sling.caconfig.ConfigurationBuilder;
-import org.apache.sling.caconfig.spi.ConfigurationMetadataProvider;
-import org.apache.sling.caconfig.spi.metadata.ConfigurationMetadata;
-
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.caconfig.ConfigurationBuilder;
+import org.apache.sling.caconfig.spi.ConfigurationMetadataProvider;
+import org.apache.sling.caconfig.spi.metadata.ConfigurationMetadata;
+
/**
* This is a "virtual" containing configuration names as keys, and the underlying value maps/value map collections as values.
* The map accesses only the data that is really required in a lazy fashion.
@@ -78,7 +80,8 @@ public class ConfigurationMap implements Map<String, Object> {
private Object getConfigValue(String configName) {
@SuppressWarnings("null")
- ConfigurationBuilder configBuilder = resource.adaptTo(ConfigurationBuilder.class).name(configName);
+ ConfigurationBuilder configBuilder =
+ resource.adaptTo(ConfigurationBuilder.class).name(configName);
if (isCollection(configName)) {
return configBuilder.asValueMapCollection();
} else {
diff --git a/src/main/java/org/apache/sling/pipes/internal/bindings/JxltEngine.java b/src/main/java/org/apache/sling/pipes/internal/bindings/JxltEngine.java
index ffcca1a..9e6c362 100644
--- a/src/main/java/org/apache/sling/pipes/internal/bindings/JxltEngine.java
+++ b/src/main/java/org/apache/sling/pipes/internal/bindings/JxltEngine.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes.internal.bindings;
diff --git a/src/main/java/org/apache/sling/pipes/internal/bindings/TimeUtil.java b/src/main/java/org/apache/sling/pipes/internal/bindings/TimeUtil.java
index 2e4c58b..89d482b 100644
--- a/src/main/java/org/apache/sling/pipes/internal/bindings/TimeUtil.java
+++ b/src/main/java/org/apache/sling/pipes/internal/bindings/TimeUtil.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes.internal.bindings;
@@ -41,7 +43,7 @@ public class TimeUtil {
* @param time string date following <code>ISO_DATE_TIME</code>
* @return Gregorian calendar impl of that time
*/
- public Calendar of(String time){
+ public Calendar of(String time) {
OffsetDateTime dt = OffsetDateTime.parse(time);
return GregorianCalendar.from(dt.toZonedDateTime());
}
diff --git a/src/main/java/org/apache/sling/pipes/internal/inputstream/CsvPipe.java b/src/main/java/org/apache/sling/pipes/internal/inputstream/CsvPipe.java
index cf89df8..6528f3a 100644
--- a/src/main/java/org/apache/sling/pipes/internal/inputstream/CsvPipe.java
+++ b/src/main/java/org/apache/sling/pipes/internal/inputstream/CsvPipe.java
@@ -1,29 +1,23 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes.internal.inputstream;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.sling.api.resource.Resource;
-import org.apache.sling.pipes.AbstractInputStreamPipe;
-import org.apache.sling.pipes.PipeBindings;
-import org.apache.sling.pipes.Plumber;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
@@ -34,6 +28,14 @@ import java.util.Iterator;
import java.util.Map;
import java.util.NoSuchElementException;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.pipes.AbstractInputStreamPipe;
+import org.apache.sling.pipes.PipeBindings;
+import org.apache.sling.pipes.Plumber;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
/**
* Csv input stream pipe, similar at what
*/
@@ -63,7 +65,7 @@ public class CsvPipe extends AbstractInputStreamPipe {
try {
String headersLine = reader.readLine();
final String[] headers = headersLine.split(separator);
- if (headers.length > 0){
+ if (headers.length > 0) {
nextLine = reader.readLine();
final Resource inputResource = getInput();
output = new Iterator<Resource>() {
@@ -71,15 +73,17 @@ public class CsvPipe extends AbstractInputStreamPipe {
public boolean hasNext() {
return StringUtils.isNotBlank(nextLine);
}
+
@Override
public Resource next() {
try {
String[] values = nextLine.split(separator);
- if (values.length < headers.length){
- throw new IllegalArgumentException("wrong format line " + index + " should have at least the same number of columns than the headers");
+ if (values.length < headers.length) {
+ throw new IllegalArgumentException("wrong format line " + index
+ + " should have at least the same number of columns than the headers");
}
Map<String, String> map = new HashMap<>();
- for (int i = 0; i < headers.length; i ++){
+ for (int i = 0; i < headers.length; i++) {
map.put(headers[i], values[i]);
}
binding = map;
@@ -98,4 +102,4 @@ public class CsvPipe extends AbstractInputStreamPipe {
}
return output;
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/sling/pipes/internal/inputstream/JsonPipe.java b/src/main/java/org/apache/sling/pipes/internal/inputstream/JsonPipe.java
index d12e984..ac96c9f 100644
--- a/src/main/java/org/apache/sling/pipes/internal/inputstream/JsonPipe.java
+++ b/src/main/java/org/apache/sling/pipes/internal/inputstream/JsonPipe.java
@@ -1,32 +1,23 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes.internal.inputstream;
-import org.apache.commons.collections4.keyvalue.DefaultKeyValue;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.sling.api.resource.Resource;
-import org.apache.sling.pipes.AbstractInputStreamPipe;
-import org.apache.sling.pipes.PipeBindings;
-import org.apache.sling.pipes.Plumber;
-import org.apache.sling.pipes.internal.JsonUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import javax.json.JsonArray;
import javax.json.JsonObject;
import javax.json.JsonStructure;
@@ -43,6 +34,17 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
+import org.apache.commons.collections4.keyvalue.DefaultKeyValue;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.pipes.AbstractInputStreamPipe;
+import org.apache.sling.pipes.PipeBindings;
+import org.apache.sling.pipes.Plumber;
+import org.apache.sling.pipes.internal.JsonUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
/**
* Pipe outputting binding related to a json stream: either an object
*/
@@ -69,7 +71,8 @@ public class JsonPipe extends AbstractInputStreamPipe {
protected static final String INDEX_SUFFIX = "_index";
- protected static final Pattern JSONPATH_FIRSTTOKEN = Pattern.compile("^\\" + JSONPATH_ROOT + "([\\" + OBJ_START + "\\" + ARRAY_START + "])([^\\" + OBJ_START + "\\]\\" + ARRAY_START + "]+)\\]?");
+ protected static final Pattern JSONPATH_FIRSTTOKEN = Pattern.compile("^\\" + JSONPATH_ROOT + "([\\" + OBJ_START
+ + "\\" + ARRAY_START + "])([^\\" + OBJ_START + "\\]\\" + ARRAY_START + "]+)\\]?");
JsonBindingIterator internalIterator;
@@ -83,7 +86,7 @@ public class JsonPipe extends AbstractInputStreamPipe {
if (raw instanceof Boolean) {
return (Boolean) raw;
}
- return Boolean.parseBoolean((String)raw);
+ return Boolean.parseBoolean((String) raw);
}
return false;
}
@@ -96,7 +99,8 @@ public class JsonPipe extends AbstractInputStreamPipe {
@Override
public Iterator<Resource> getOutput(InputStream is) {
Iterator<Resource> output = EMPTY_ITERATOR;
- Iterator<Resource> inputSingletonIterator = Collections.singleton(getInput()).iterator();
+ Iterator<Resource> inputSingletonIterator =
+ Collections.singleton(getInput()).iterator();
try {
String jsonString = IOUtils.toString(is, StandardCharsets.UTF_8);
if (StringUtils.isNotBlank(jsonString)) {
@@ -110,7 +114,8 @@ public class JsonPipe extends AbstractInputStreamPipe {
if (StringUtils.isNotBlank(valuePath)) {
json = getValue(json, bindings.instantiateExpression(valuePath));
}
- if (isRaw() || !(json.getValueType() == ValueType.ARRAY || json.getValueType() == ValueType.OBJECT)) {
+ if (isRaw()
+ || !(json.getValueType() == ValueType.ARRAY || json.getValueType() == ValueType.OBJECT)) {
binding = JsonUtil.unbox(json);
output = inputSingletonIterator;
} else {
@@ -132,11 +137,13 @@ public class JsonPipe extends AbstractInputStreamPipe {
int index = 0;
JsonBindingIterator(JsonStructure json, Resource inputResource) {
- jsonValues = json.getValueType() == ValueType.ARRAY ?
- ((JsonArray) json).stream().map(JsonUtil::unbox).collect(Collectors.toList()):
- ((JsonObject) json).entrySet().stream()
- .map(e -> new DefaultKeyValue<String,Object>(e.getKey(),
- JsonUtil.unbox(e.getValue()))).collect(Collectors.toList());
+ jsonValues = json.getValueType() == ValueType.ARRAY
+ ? ((JsonArray) json).stream().map(JsonUtil::unbox).collect(Collectors.toList())
+ : ((JsonObject) json)
+ .entrySet().stream()
+ .map(e -> new DefaultKeyValue<String, Object>(
+ e.getKey(), JsonUtil.unbox(e.getValue())))
+ .collect(Collectors.toList());
internal = jsonValues.iterator();
this.inputResource = inputResource;
}
@@ -148,11 +155,11 @@ public class JsonPipe extends AbstractInputStreamPipe {
@Override
public Resource next() {
- if (! internal.hasNext()) {
+ if (!internal.hasNext()) {
throw new NoSuchElementException();
}
binding = internal.next();
- getBindings().addBinding(getName() + INDEX_SUFFIX, index ++);
+ getBindings().addBinding(getName() + INDEX_SUFFIX, index++);
return inputResource;
}
}
@@ -163,27 +170,26 @@ public class JsonPipe extends AbstractInputStreamPipe {
* @param valuePath path to follow
* @return value fetched after following the path
*/
- protected JsonStructure getValue(JsonStructure json, String valuePath){
+ protected JsonStructure getValue(JsonStructure json, String valuePath) {
Matcher matcher = JSONPATH_FIRSTTOKEN.matcher(valuePath);
- if (matcher.find()){
+ if (matcher.find()) {
String firstChar = matcher.group(1);
String content = matcher.group(2);
logger.trace("first char is {}, content is {}", firstChar, content);
- if (ARRAY_START.equals(firstChar)){
- JsonArray array = (JsonArray)json;
+ if (ARRAY_START.equals(firstChar)) {
+ JsonArray array = (JsonArray) json;
int index = Integer.parseInt(content);
- json = (JsonStructure)array.get(index);
- } else if (OBJ_START.equals(firstChar)){
- JsonObject object = (JsonObject)json;
- json = (JsonStructure)object.get(content);
+ json = (JsonStructure) array.get(index);
+ } else if (OBJ_START.equals(firstChar)) {
+ JsonObject object = (JsonObject) json;
+ json = (JsonStructure) object.get(content);
}
valuePath = StringUtils.removeStart(valuePath, matcher.group(0));
- if (StringUtils.isNotBlank(valuePath)){
+ if (StringUtils.isNotBlank(valuePath)) {
valuePath = JSONPATH_ROOT + valuePath;
return getValue(json, valuePath);
}
}
return json;
}
-
}
diff --git a/src/main/java/org/apache/sling/pipes/internal/inputstream/RegexpPipe.java b/src/main/java/org/apache/sling/pipes/internal/inputstream/RegexpPipe.java
index 00ec9ab..3e3a74d 100644
--- a/src/main/java/org/apache/sling/pipes/internal/inputstream/RegexpPipe.java
+++ b/src/main/java/org/apache/sling/pipes/internal/inputstream/RegexpPipe.java
@@ -1,29 +1,23 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes.internal.inputstream;
-import org.apache.commons.io.IOUtils;
-import org.apache.sling.api.resource.Resource;
-import org.apache.sling.pipes.AbstractInputStreamPipe;
-import org.apache.sling.pipes.PipeBindings;
-import org.apache.sling.pipes.Plumber;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
@@ -36,6 +30,14 @@ import java.util.NoSuchElementException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.apache.commons.io.IOUtils;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.pipes.AbstractInputStreamPipe;
+import org.apache.sling.pipes.PipeBindings;
+import org.apache.sling.pipes.Plumber;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
/**
* Pipe outputting matches of a regexp from a plain text file
*/
@@ -56,12 +58,12 @@ public class RegexpPipe extends AbstractInputStreamPipe {
Iterator<Resource> output = EMPTY_ITERATOR;
try {
String patternString = bindings.instantiateExpression(properties.get(PN_PATTERN, String.class));
- if (patternString == null){
+ if (patternString == null) {
logger.debug("pattern {} evaluates as empty.", properties.get(PN_PATTERN, String.class));
return output;
}
final Collection<String> names = getGroupNames(patternString);
- if (names.isEmpty()){
+ if (names.isEmpty()) {
logger.debug("no name defined, will take the whole match");
}
Pattern pattern = Pattern.compile(patternString);
@@ -72,6 +74,7 @@ public class RegexpPipe extends AbstractInputStreamPipe {
final Resource next = getInput();
output = new Iterator<Resource>() {
boolean hasNext = true;
+
@Override
public boolean hasNext() {
return hasNext;
@@ -79,17 +82,17 @@ public class RegexpPipe extends AbstractInputStreamPipe {
@Override
public Resource next() {
- if (! hasNext) {
+ if (!hasNext) {
throw new NoSuchElementException();
}
- if (!names.isEmpty()){
+ if (!names.isEmpty()) {
Map<String, Object> map = new HashMap<>();
for (String name : names) {
map.put(name, matcher.group(name));
}
binding = map;
} else {
- //no group names defined, we take the whole match
+ // no group names defined, we take the whole match
binding = matcher.group(0);
}
hasNext = matcher.find();
@@ -107,14 +110,12 @@ public class RegexpPipe extends AbstractInputStreamPipe {
* @param pattern configured pattern
* @return list of group names identified in a given pattern
*/
- protected Collection<String> getGroupNames(String pattern){
+ protected Collection<String> getGroupNames(String pattern) {
Collection<String> names = new ArrayList<>();
Matcher nameMatcher = PATTERN_NAME.matcher(pattern);
- while (nameMatcher.find()){
+ while (nameMatcher.find()) {
names.add(nameMatcher.group(PATTERN_IDX_NAME));
}
return names;
}
-
-
}
diff --git a/src/main/java/org/apache/sling/pipes/internal/slingquery/AbstractExpressionSlingQueryPipe.java b/src/main/java/org/apache/sling/pipes/internal/slingquery/AbstractExpressionSlingQueryPipe.java
index 15436be..112c74b 100644
--- a/src/main/java/org/apache/sling/pipes/internal/slingquery/AbstractExpressionSlingQueryPipe.java
+++ b/src/main/java/org/apache/sling/pipes/internal/slingquery/AbstractExpressionSlingQueryPipe.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes.internal.slingquery;
@@ -28,6 +30,7 @@ import org.slf4j.LoggerFactory;
*/
public abstract class AbstractExpressionSlingQueryPipe extends AbstractSlingQueryPipe {
Logger logger = LoggerFactory.getLogger(AbstractExpressionSlingQueryPipe.class);
+
protected AbstractExpressionSlingQueryPipe(Plumber plumber, Resource resource, PipeBindings upperBindings) {
super(plumber, resource, upperBindings);
}
@@ -46,7 +49,7 @@ public abstract class AbstractExpressionSlingQueryPipe extends AbstractSlingQuer
String expression = getExpr();
logger.debug("executing sling query pipe with expression {}", expression);
return getQuery(resource, expression);
- } catch (RuntimeException e){
+ } catch (RuntimeException e) {
logger.error("please check pipe expressions", e);
}
return null;
diff --git a/src/main/java/org/apache/sling/pipes/internal/slingquery/AbstractSlingQueryPipe.java b/src/main/java/org/apache/sling/pipes/internal/slingquery/AbstractSlingQueryPipe.java
index a8d9a7e..000555a 100644
--- a/src/main/java/org/apache/sling/pipes/internal/slingquery/AbstractSlingQueryPipe.java
+++ b/src/main/java/org/apache/sling/pipes/internal/slingquery/AbstractSlingQueryPipe.java
@@ -1,29 +1,31 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes.internal.slingquery;
+import java.util.Iterator;
+
import org.apache.sling.api.resource.Resource;
import org.apache.sling.pipes.BasePipe;
import org.apache.sling.pipes.PipeBindings;
import org.apache.sling.pipes.Plumber;
import org.apache.sling.query.SlingQuery;
-import java.util.Iterator;
-
/**
* deals with common sling query pipe code
*/
@@ -32,6 +34,7 @@ public abstract class AbstractSlingQueryPipe extends BasePipe {
protected AbstractSlingQueryPipe(Plumber plumber, Resource resource, PipeBindings upperBindings) {
super(plumber, resource, upperBindings);
}
+
@Override
public boolean modifiesContent() {
return false;
@@ -57,4 +60,4 @@ public abstract class AbstractSlingQueryPipe extends BasePipe {
}
return EMPTY_ITERATOR;
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/sling/pipes/internal/slingquery/ChildrenPipe.java b/src/main/java/org/apache/sling/pipes/internal/slingquery/ChildrenPipe.java
index f0d8bfa..a288ab7 100644
--- a/src/main/java/org/apache/sling/pipes/internal/slingquery/ChildrenPipe.java
+++ b/src/main/java/org/apache/sling/pipes/internal/slingquery/ChildrenPipe.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes.internal.slingquery;
@@ -22,6 +24,7 @@ import org.apache.sling.pipes.Plumber;
import org.apache.sling.query.SlingQuery;
import static org.apache.sling.query.SlingQuery.$;
+
/**
* this pipe uses SlingQuery to filters children (filter defined in expr property) of
* a resource (defined in the path property)
@@ -37,4 +40,4 @@ public class ChildrenPipe extends AbstractExpressionSlingQueryPipe {
protected SlingQuery getQuery(Resource resource, String expression) {
return $(resource).children(expression);
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/sling/pipes/internal/slingquery/ClosestPipe.java b/src/main/java/org/apache/sling/pipes/internal/slingquery/ClosestPipe.java
index b80d44a..b555fcf 100644
--- a/src/main/java/org/apache/sling/pipes/internal/slingquery/ClosestPipe.java
+++ b/src/main/java/org/apache/sling/pipes/internal/slingquery/ClosestPipe.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes.internal.slingquery;
diff --git a/src/main/java/org/apache/sling/pipes/internal/slingquery/FindPipe.java b/src/main/java/org/apache/sling/pipes/internal/slingquery/FindPipe.java
index 7c891b3..643067b 100644
--- a/src/main/java/org/apache/sling/pipes/internal/slingquery/FindPipe.java
+++ b/src/main/java/org/apache/sling/pipes/internal/slingquery/FindPipe.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes.internal.slingquery;
diff --git a/src/main/java/org/apache/sling/pipes/internal/slingquery/ParentPipe.java b/src/main/java/org/apache/sling/pipes/internal/slingquery/ParentPipe.java
index 53c2301..0c27c19 100644
--- a/src/main/java/org/apache/sling/pipes/internal/slingquery/ParentPipe.java
+++ b/src/main/java/org/apache/sling/pipes/internal/slingquery/ParentPipe.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes.internal.slingquery;
@@ -37,4 +39,4 @@ public class ParentPipe extends AbstractSlingQueryPipe {
protected SlingQuery getQuery(Resource resource) {
return $(resource).parent();
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/sling/pipes/internal/slingquery/ParentsPipe.java b/src/main/java/org/apache/sling/pipes/internal/slingquery/ParentsPipe.java
index 472a683..1e11b46 100644
--- a/src/main/java/org/apache/sling/pipes/internal/slingquery/ParentsPipe.java
+++ b/src/main/java/org/apache/sling/pipes/internal/slingquery/ParentsPipe.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes.internal.slingquery;
@@ -37,4 +39,4 @@ public class ParentsPipe extends AbstractExpressionSlingQueryPipe {
protected SlingQuery getQuery(Resource resource, String expression) {
return $(resource).parents(expression);
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/sling/pipes/internal/slingquery/SiblingsPipe.java b/src/main/java/org/apache/sling/pipes/internal/slingquery/SiblingsPipe.java
index 2a6147c..86d3af0 100644
--- a/src/main/java/org/apache/sling/pipes/internal/slingquery/SiblingsPipe.java
+++ b/src/main/java/org/apache/sling/pipes/internal/slingquery/SiblingsPipe.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes.internal.slingquery;
@@ -35,4 +37,4 @@ public class SiblingsPipe extends AbstractExpressionSlingQueryPipe {
protected SlingQuery getQuery(Resource resource, String expression) {
return $(resource).siblings(expression);
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/sling/pipes/models/PipeModel.java b/src/main/java/org/apache/sling/pipes/models/PipeModel.java
index 6891efc..068c5d1 100644
--- a/src/main/java/org/apache/sling/pipes/models/PipeModel.java
+++ b/src/main/java/org/apache/sling/pipes/models/PipeModel.java
@@ -1,21 +1,29 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes.models;
+import javax.annotation.PostConstruct;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ValueMap;
import org.apache.sling.models.annotations.Model;
@@ -25,13 +33,6 @@ import org.apache.sling.pipes.Plumber;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import javax.annotation.PostConstruct;
-
-
/**
* Check for pipes presence under <code>pipes</code> node of the given resource, and make their output available as pipes
* to the script. Note that current resource is passed as a binding to the executed pipes, as a map of properties, plus
@@ -88,11 +89,11 @@ public class PipeModel {
}
@PostConstruct
- protected void init(){
+ protected void init() {
LOG.debug("initialising Pipe Model");
- if (root != null){
+ if (root != null) {
outputs = new HashMap<>();
- for (Iterator<Resource> pipeCandidates = root.listChildren(); pipeCandidates.hasNext();){
+ for (Iterator<Resource> pipeCandidates = root.listChildren(); pipeCandidates.hasNext(); ) {
Resource candidate = pipeCandidates.next();
try {
Pipe pipe = plumber.getPipe(candidate);
@@ -100,7 +101,7 @@ public class PipeModel {
pipe.getBindings().updateStaticBindings(BINDING_CURRENTRESOURCE, currentResource);
outputs.put(pipe.getName(), pipe.getOutput());
LOG.debug("found and initialized {}", pipe.getName());
- } catch(Exception e){
+ } catch (Exception e) {
LOG.error("unable to bind {} pipe", candidate.getPath(), e);
}
}
diff --git a/src/test/java/org/apache/sling/pipes/AbstractPipeTest.java b/src/test/java/org/apache/sling/pipes/AbstractPipeTest.java
index 4134275..702de7a 100644
--- a/src/test/java/org/apache/sling/pipes/AbstractPipeTest.java
+++ b/src/test/java/org/apache/sling/pipes/AbstractPipeTest.java
@@ -1,27 +1,31 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes;
+import java.lang.reflect.InvocationTargetException;
+import java.util.Iterator;
+
import org.apache.sling.api.resource.PersistenceException;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.caconfig.spi.ConfigurationMetadataProvider;
import org.apache.sling.event.jobs.JobManager;
-
import org.apache.sling.pipes.dummies.DummyNull;
import org.apache.sling.pipes.dummies.DummySearch;
import org.apache.sling.pipes.internal.CommandExecutorImpl;
@@ -32,9 +36,6 @@ import org.apache.sling.testing.mock.sling.junit.SlingContextBuilder;
import org.junit.Before;
import org.junit.Rule;
-import java.lang.reflect.InvocationTargetException;
-import java.util.Iterator;
-
import static org.apache.sling.testing.mock.caconfig.ContextPlugins.CACONFIG;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -71,7 +72,9 @@ public class AbstractPipeTest {
protected CommandExecutor commandsExecutor;
@Rule
- public SlingContext context = new SlingContextBuilder(ResourceResolverType.JCR_MOCK).plugin(CACONFIG).build();
+ public SlingContext context = new SlingContextBuilder(ResourceResolverType.JCR_MOCK)
+ .plugin(CACONFIG)
+ .build();
@Before
public void setup() throws PersistenceException {
@@ -79,23 +82,30 @@ public class AbstractPipeTest {
plumber = new PlumberImpl();
context.registerService(mock(ConfigurationMetadataProvider.class));
context.registerService(mock(JobManager.class));
- context.registerInjectActivateService(plumber, "authorizedUsers", new String[]{},
- "bufferSize", PlumberImpl.DEFAULT_BUFFER_SIZE,
- "executionPermissionResource", PATH_FRUITS,
- "mark.pipe.path",true,
- "referencesPaths", new String [] { "/conf/global/sling/pipes", "/apps/scripts" });
+ context.registerInjectActivateService(
+ plumber,
+ "authorizedUsers",
+ new String[] {},
+ "bufferSize",
+ PlumberImpl.DEFAULT_BUFFER_SIZE,
+ "executionPermissionResource",
+ PATH_FRUITS,
+ "mark.pipe.path",
+ true,
+ "referencesPaths",
+ new String[] {"/conf/global/sling/pipes", "/apps/scripts"});
plumber.registerPipe("slingPipes/dummyNull", DummyNull.class);
plumber.registerPipe("slingPipes/dummySearch", DummySearch.class);
commandsExecutor = new CommandExecutorImpl();
context.registerInjectActivateService(commandsExecutor);
}
- protected Pipe getPipe(String path){
+ protected Pipe getPipe(String path) {
Resource resource = context.resourceResolver().getResource(path);
return plumber.getPipe(resource);
}
- protected Iterator<Resource> getOutput(String path){
+ protected Iterator<Resource> getOutput(String path) {
Pipe pipe = getPipe(path);
assertNotNull("pipe should be found", pipe);
return pipe.getOutput();
@@ -105,7 +115,8 @@ public class AbstractPipeTest {
return execute(context.resourceResolver(), command);
}
- protected ExecutionResult execute(ResourceResolver resolver, String command) throws InvocationTargetException, IllegalAccessException {
+ protected ExecutionResult execute(ResourceResolver resolver, String command)
+ throws InvocationTargetException, IllegalAccessException {
PipeBuilder builder = commandsExecutor.parse(resolver, command);
return builder.run();
}
@@ -115,9 +126,12 @@ public class AbstractPipeTest {
* @param pipePath
* @param resourcePath
*/
- protected void testOneResource(String pipePath, String resourcePath){
+ protected void testOneResource(String pipePath, String resourcePath) {
Iterator<Resource> it = getOutput(pipePath);
assertTrue("pipe should have results", it.hasNext());
- assertEquals("return result should be the one expected", resourcePath, it.next().getPath());
+ assertEquals(
+ "return result should be the one expected",
+ resourcePath,
+ it.next().getPath());
}
}
diff --git a/src/test/java/org/apache/sling/pipes/BasePipeTest.java b/src/test/java/org/apache/sling/pipes/BasePipeTest.java
index e7acf6a..b665e09 100644
--- a/src/test/java/org/apache/sling/pipes/BasePipeTest.java
+++ b/src/test/java/org/apache/sling/pipes/BasePipeTest.java
@@ -1,32 +1,35 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes;
-import org.apache.sling.api.resource.PersistenceException;
-import org.apache.sling.api.resource.ResourceResolver;
-import org.apache.sling.api.resource.ValueMap;
-import org.junit.Test;
-
import javax.json.Json;
import javax.json.JsonArray;
import javax.json.JsonObject;
+
import java.io.StringReader;
import java.util.ArrayList;
+import org.apache.sling.api.resource.PersistenceException;
+import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.api.resource.ValueMap;
+import org.junit.Test;
+
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@@ -34,25 +37,41 @@ import static org.junit.Assert.assertTrue;
public class BasePipeTest extends AbstractPipeTest {
protected BasePipe resetDryRun(Object value) throws PersistenceException {
- BasePipe basePipe = (BasePipe)plumber.newPipe(context.resourceResolver()).echo("blah").build();
+ BasePipe basePipe = (BasePipe)
+ plumber.newPipe(context.resourceResolver()).echo("blah").build();
basePipe.bindings.addBinding(BasePipe.DRYRUN_KEY, value);
return basePipe;
}
@Test
public void dryRunTest() throws Exception {
- assertFalse("Is dry run should be false with flag set to text false", resetDryRun("false").isDryRun());
- assertFalse("Is dry run should be false with flag set to boolean false", resetDryRun(false).isDryRun());
- assertFalse("Is dry run should be false with no dry run flag", resetDryRun(null).isDryRun());
- assertTrue("Is dry run should be true with flag set to boolean true", resetDryRun(true).isDryRun());
- assertTrue("Is dry run should be true with flag set to text true", resetDryRun("true").isDryRun());
- assertTrue("Is dry run should be true with flag set to something that is not false or 'false'", resetDryRun("other").isDryRun());
+ assertFalse(
+ "Is dry run should be false with flag set to text false",
+ resetDryRun("false").isDryRun());
+ assertFalse(
+ "Is dry run should be false with flag set to boolean false",
+ resetDryRun(false).isDryRun());
+ assertFalse(
+ "Is dry run should be false with no dry run flag",
+ resetDryRun(null).isDryRun());
+ assertTrue(
+ "Is dry run should be true with flag set to boolean true",
+ resetDryRun(true).isDryRun());
+ assertTrue(
+ "Is dry run should be true with flag set to text true",
+ resetDryRun("true").isDryRun());
+ assertTrue(
+ "Is dry run should be true with flag set to something that is not false or 'false'",
+ resetDryRun("other").isDryRun());
}
@Test
public void simpleErrorTest() throws Exception {
- ExecutionResult result = plumber.newPipe(context.resourceResolver()).echo("${whatever is wrong}").run();
- JsonObject response = Json.createReader(new StringReader(result.toString())).readObject();
+ ExecutionResult result = plumber.newPipe(context.resourceResolver())
+ .echo("${whatever is wrong}")
+ .run();
+ JsonObject response =
+ Json.createReader(new StringReader(result.toString())).readObject();
JsonArray array = response.getJsonArray(OutputWriter.KEY_ERRORS);
assertEquals("there should be one error", 1, array.size());
}
@@ -60,18 +79,23 @@ public class BasePipeTest extends AbstractPipeTest {
@Test
public void testRelativeInput() throws Exception {
ExecutionResult results = execute("echo /content | echo fruits");
- assertEquals("it should be fruits root", PATH_FRUITS, results.currentPathSet.iterator().next());
+ assertEquals(
+ "it should be fruits root",
+ PATH_FRUITS,
+ results.currentPathSet.iterator().next());
}
@Test
- public void testHooks() throws Exception {
+ public void testHooks() throws Exception {
ResourceResolver r = context.resourceResolver();
String beforeFlag = "before";
String afterFlag = "after";
- Pipe before = plumber.newPipe(r).echo(PATH_FRUITS).write(beforeFlag, true).build();
+ Pipe before =
+ plumber.newPipe(r).echo(PATH_FRUITS).write(beforeFlag, true).build();
Pipe after = plumber.newPipe(r).echo(PATH_FRUITS).write(afterFlag, true).build();
plumber.newPipe(r)
- .with( BasePipe.PN_BEFOREHOOK, before.getResource().getPath(),
+ .with(
+ BasePipe.PN_BEFOREHOOK, before.getResource().getPath(),
BasePipe.PN_AFTERHOOK, after.getResource().getPath())
.echo(PATH_APPLE)
.run();
@@ -83,11 +107,14 @@ public class BasePipeTest extends AbstractPipeTest {
@Test
public void testSimpleBindingProviders() throws PersistenceException, IllegalAccessException {
ResourceResolver r = context.resourceResolver();
- BasePipe pipe = (BasePipe)plumber.newPipe(r).echo(PATH_FRUITS).children("nt:unstructured[color=${test.color}]").build();
+ BasePipe pipe = (BasePipe) plumber.newPipe(r)
+ .echo(PATH_FRUITS)
+ .children("nt:unstructured[color=${test.color}]")
+ .build();
Pipe apple = plumber.newPipe(r).name("test").echo(PATH_APPLE).build();
assertEquals("name should be test", "test", apple.getName());
pipe.bindingProviders = new ArrayList<>();
pipe.bindingProviders.add(new BindingProvider(apple));
assertTrue("there should be outputs", pipe.getOutput().hasNext());
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/sling/pipes/CommandUtilTest.java b/src/test/java/org/apache/sling/pipes/CommandUtilTest.java
index 4125472..d0e9b97 100644
--- a/src/test/java/org/apache/sling/pipes/CommandUtilTest.java
+++ b/src/test/java/org/apache/sling/pipes/CommandUtilTest.java
@@ -1,42 +1,41 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes;
-import static org.apache.sling.pipes.CommandUtil.CONFIGURATION_PATTERN;
-import static org.apache.sling.pipes.CommandUtil.FIRST_KEY;
-import static org.apache.sling.pipes.CommandUtil.SECOND_KEY;
-import static org.apache.sling.pipes.CommandUtil.keyValuesToArray;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.apache.sling.pipes.AbstractPipeTest;
-import org.apache.sling.pipes.CommandUtil;
import org.junit.Assert;
import org.junit.Test;
-public class CommandUtilTest extends AbstractPipeTest {
+import static org.apache.sling.pipes.CommandUtil.CONFIGURATION_PATTERN;
+import static org.apache.sling.pipes.CommandUtil.FIRST_KEY;
+import static org.apache.sling.pipes.CommandUtil.SECOND_KEY;
+import static org.apache.sling.pipes.CommandUtil.keyValuesToArray;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+public class CommandUtilTest extends AbstractPipeTest {
private void assertMatch(Pattern pattern, String token, String first, String second) {
Matcher matcher = pattern.matcher(token);
@@ -44,6 +43,7 @@ public class CommandUtilTest extends AbstractPipeTest {
assertEquals("first token should be " + first, first, matcher.group(FIRST_KEY));
assertEquals("second token should be " + second, second, matcher.group(SECOND_KEY));
}
+
@Test
public void testTokenMatch() {
assertMatch(CONFIGURATION_PATTERN, "foo=bar", "foo", "bar");
@@ -56,6 +56,7 @@ public class CommandUtilTest extends AbstractPipeTest {
assertMatch(CONFIGURATION_PATTERN, "foo/bar=check/some", "foo/bar", "check/some");
assertMatch(CONFIGURATION_PATTERN, "foo:bar='.+'", "foo:bar", "'.+'");
}
+
@Test
public void testEmbedIfNeeded() {
assertEquals(2, CommandUtil.embedIfNeeded(2));
@@ -63,7 +64,8 @@ public class CommandUtilTest extends AbstractPipeTest {
assertEquals("/path/left/0/un-touc_hed", CommandUtil.embedIfNeeded("/path/left/0/un-touc_hed"));
assertEquals("/content/json/array/${json.test}", CommandUtil.embedIfNeeded("/content/json/array/${json.test}"));
assertEquals("${vegetables['jcr:title']}", CommandUtil.embedIfNeeded("vegetables['jcr:title']"));
- assertEquals("${new Date(\"2018-05-05T11:50:55\")}", CommandUtil.embedIfNeeded("new Date(\"2018-05-05T11:50:55\")"));
+ assertEquals(
+ "${new Date(\"2018-05-05T11:50:55\")}", CommandUtil.embedIfNeeded("new Date(\"2018-05-05T11:50:55\")"));
assertEquals("${some + wellformed + script}", CommandUtil.embedIfNeeded("${some + wellformed + script}"));
assertEquals("${true}", CommandUtil.embedIfNeeded("true"));
assertEquals("${'some string'}", CommandUtil.embedIfNeeded("'some string'"));
@@ -80,12 +82,22 @@ public class CommandUtilTest extends AbstractPipeTest {
@Test
public void testWriteToMap() {
Map<String, Object> map = new HashMap<>();
- CommandUtil.writeToMap(map, true, "p1", "'some string'", "p2", "/some/path",
- "p3","['one','two']", "jcr:mixinTypes", "[ rep:versionable, some:OtherMixin]");
+ CommandUtil.writeToMap(
+ map,
+ true,
+ "p1",
+ "'some string'",
+ "p2",
+ "/some/path",
+ "p3",
+ "['one','two']",
+ "jcr:mixinTypes",
+ "[ rep:versionable, some:OtherMixin]");
assertEquals("${'some string'}", map.get("p1"));
assertEquals("/some/path", map.get("p2"));
assertEquals("${['one','two']}", map.get("p3"));
- Assert.assertArrayEquals(new String [] {"rep:versionable", "some:OtherMixin"}, (String[])map.get("jcr:mixinTypes"));
+ Assert.assertArrayEquals(
+ new String[] {"rep:versionable", "some:OtherMixin"}, (String[]) map.get("jcr:mixinTypes"));
}
@Test
@@ -96,15 +108,34 @@ public class CommandUtilTest extends AbstractPipeTest {
@Test
public void testKeyValuesToArray() {
- assertArrayEquals(new String[] {"foo","bar","another","with spaces "}, keyValuesToArray(Arrays.asList("foo=bar","another=\"with spaces \"")));
- assertArrayEquals("1", new String[]{"one","two","three","four"}, keyValuesToArray(Arrays.asList("one=two","three=four")));
- assertArrayEquals("2", new String[]{"one","two","three","${four}"}, keyValuesToArray(Arrays.asList("one=two","three=${four}")));
- assertArrayEquals("3", new String[]{"${one == 'check'? 'three':'four'}","two"}, keyValuesToArray((Arrays.asList("${one == 'check'? 'three':'four'}=two"))));
- assertArrayEquals("4", new String[]{"a_b-c","two"}, keyValuesToArray((Arrays.asList("a_b-c=two"))));
- assertArrayEquals("5", new String[]{"one","two","three","${four == 'blah' ? 'five' : 'six'}"},
- keyValuesToArray(Arrays.asList("one=two","three=${four == 'blah' ? 'five' : 'six'}")));
- assertArrayEquals("6", new String[]{"jcr:content/singer","${'ringo' == one ? false : true}"}, keyValuesToArray(Arrays.asList("jcr:content/singer=${'ringo' == one ? false : true}")));
- assertArrayEquals("7", new String[]{"jcr:content/tag","${text.replaceAll('foo','<div class=\"foo\">foo</div>'}"}, keyValuesToArray(Arrays.asList("jcr:content/tag=\"${text.replaceAll('foo','<div class_EQ_\"foo\">foo</div>'}\"")));
+ assertArrayEquals(
+ new String[] {"foo", "bar", "another", "with spaces "},
+ keyValuesToArray(Arrays.asList("foo=bar", "another=\"with spaces \"")));
+ assertArrayEquals(
+ "1",
+ new String[] {"one", "two", "three", "four"},
+ keyValuesToArray(Arrays.asList("one=two", "three=four")));
+ assertArrayEquals(
+ "2",
+ new String[] {"one", "two", "three", "${four}"},
+ keyValuesToArray(Arrays.asList("one=two", "three=${four}")));
+ assertArrayEquals(
+ "3",
+ new String[] {"${one == 'check'? 'three':'four'}", "two"},
+ keyValuesToArray((Arrays.asList("${one == 'check'? 'three':'four'}=two"))));
+ assertArrayEquals("4", new String[] {"a_b-c", "two"}, keyValuesToArray((Arrays.asList("a_b-c=two"))));
+ assertArrayEquals(
+ "5",
+ new String[] {"one", "two", "three", "${four == 'blah' ? 'five' : 'six'}"},
+ keyValuesToArray(Arrays.asList("one=two", "three=${four == 'blah' ? 'five' : 'six'}")));
+ assertArrayEquals(
+ "6",
+ new String[] {"jcr:content/singer", "${'ringo' == one ? false : true}"},
+ keyValuesToArray(Arrays.asList("jcr:content/singer=${'ringo' == one ? false : true}")));
+ assertArrayEquals(
+ "7",
+ new String[] {"jcr:content/tag", "${text.replaceAll('foo','<div class=\"foo\">foo</div>'}"},
+ keyValuesToArray(Arrays.asList(
+ "jcr:content/tag=\"${text.replaceAll('foo','<div class_EQ_\"foo\">foo</div>'}\"")));
}
-
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/sling/pipes/ContainerPipeTest.java b/src/test/java/org/apache/sling/pipes/ContainerPipeTest.java
index f1286ac..525a731 100644
--- a/src/test/java/org/apache/sling/pipes/ContainerPipeTest.java
+++ b/src/test/java/org/apache/sling/pipes/ContainerPipeTest.java
@@ -1,21 +1,26 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes;
+import java.lang.reflect.InvocationTargetException;
+import java.util.Iterator;
+
import org.apache.sling.api.resource.ModifiableValueMap;
import org.apache.sling.api.resource.PersistenceException;
import org.apache.sling.api.resource.Resource;
@@ -23,9 +28,6 @@ import org.apache.sling.pipes.internal.ContainerPipe;
import org.junit.Before;
import org.junit.Test;
-import java.lang.reflect.InvocationTargetException;
-import java.util.Iterator;
-
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
@@ -53,25 +55,29 @@ public class ContainerPipeTest extends AbstractPipeTest {
assertTrue("There should be some results", resourceIterator.hasNext());
Resource firstResource = resourceIterator.next();
assertNotNull("First resource should not be null", firstResource);
- assertEquals("First resource should be instantiated path with apple & pea",
+ assertEquals(
+ "First resource should be instantiated path with apple & pea",
PATH_FRUITS + "/apple/isnota/pea/buttheyhavesamecolor",
firstResource.getPath());
assertTrue("There should still be another item", resourceIterator.hasNext());
Resource secondResource = resourceIterator.next();
assertNotNull("Second resource should not be null", secondResource);
- assertEquals("Second resource should be instantiated path with apple & carrot",
+ assertEquals(
+ "Second resource should be instantiated path with apple & carrot",
PATH_FRUITS + "/apple/isnota/carrot/andtheircolorisdifferent",
secondResource.getPath());
assertTrue("There should still be another item", resourceIterator.hasNext());
Resource thirdResource = resourceIterator.next();
assertNotNull("Third resource should not be null", thirdResource);
- assertEquals("Third resource should be instantiated path with banana & pea",
+ assertEquals(
+ "Third resource should be instantiated path with banana & pea",
PATH_FRUITS + "/banana/isnota/pea/andtheircolorisdifferent",
thirdResource.getPath());
assertTrue("There should still be another item", resourceIterator.hasNext());
Resource fourthResource = resourceIterator.next();
assertNotNull("Fourth resource should not be null", fourthResource);
- assertEquals("fourthResource resource should be instantiated path with banana & carrot",
+ assertEquals(
+ "fourthResource resource should be instantiated path with banana & carrot",
PATH_FRUITS + "/banana/isnota/carrot/andtheircolorisdifferent",
fourthResource.getPath());
assertFalse("There should be no more items", resourceIterator.hasNext());
@@ -83,13 +89,15 @@ public class ContainerPipeTest extends AbstractPipeTest {
assertTrue("There should be some results", resourceIterator.hasNext());
Resource firstResource = resourceIterator.next();
assertNotNull("First resource should not be null", firstResource);
- assertEquals("First resource should be instantiated path with apple & pea",
+ assertEquals(
+ "First resource should be instantiated path with apple & pea",
PATH_FRUITS + "/apple/isnota/pea/buttheyhavesamecolor",
firstResource.getPath());
assertTrue("There should still be another item", resourceIterator.hasNext());
Resource secondResource = resourceIterator.next();
assertNotNull("Second resource should not be null", secondResource);
- assertEquals("Second resource should be instantiated path with banana & pea",
+ assertEquals(
+ "Second resource should be instantiated path with banana & pea",
PATH_FRUITS + "/banana/isnota/pea/andtheircolorisdifferent",
secondResource.getPath());
assertFalse("There should be no more items", resourceIterator.hasNext());
@@ -97,12 +105,16 @@ public class ContainerPipeTest extends AbstractPipeTest {
@Test
public void testRottenTree() throws Exception {
- assertFalse("There shouldn't be any resource", getOutput(PATH_PIPE + "/" + NN_ROTTENTREE).hasNext());
+ assertFalse(
+ "There shouldn't be any resource",
+ getOutput(PATH_PIPE + "/" + NN_ROTTENTREE).hasNext());
}
@Test
public void testOnePipe() throws Exception {
- assertTrue("There should be subpipes", getOutput(PATH_PIPE + "/" + NN_ONEPIPE).hasNext());
+ assertTrue(
+ "There should be subpipes",
+ getOutput(PATH_PIPE + "/" + NN_ONEPIPE).hasNext());
}
/**
@@ -111,15 +123,18 @@ public class ContainerPipeTest extends AbstractPipeTest {
@Test
public void testContainerCut() throws PersistenceException, InvocationTargetException, IllegalAccessException {
ExecutionResult result = execute("echo /content/fruits | echo nonexisting | echo /content/fruits/apple");
- assertEquals("there should be no output to that pipe because some empty pipe is in the middle",
- 0, result.size());
+ assertEquals(
+ "there should be no output to that pipe because some empty pipe is in the middle", 0, result.size());
}
@Test
public void testSleep() throws Exception {
long interval = 30L;
String path = PATH_PIPE + "/" + NN_DUMMYTREE;
- context.resourceResolver().getResource(path).adaptTo(ModifiableValueMap.class).put(ContainerPipe.PN_SLEEP, interval + 1);
+ context.resourceResolver()
+ .getResource(path)
+ .adaptTo(ModifiableValueMap.class)
+ .put(ContainerPipe.PN_SLEEP, interval + 1);
context.resourceResolver().commit();
Iterator<Resource> outputs = getOutput(path);
long start = System.currentTimeMillis();
@@ -129,8 +144,14 @@ public class ContainerPipeTest extends AbstractPipeTest {
@Test
public void testNested() throws Exception {
- Pipe firstPipe = plumber.newPipe(context.resourceResolver()).echo(ROOT).echo(NN_FRUITS).build();
- Pipe superPipe = plumber.newPipe(context.resourceResolver()).ref(firstPipe.getResource().getPath()).echo("apple").build();
+ Pipe firstPipe = plumber.newPipe(context.resourceResolver())
+ .echo(ROOT)
+ .echo(NN_FRUITS)
+ .build();
+ Pipe superPipe = plumber.newPipe(context.resourceResolver())
+ .ref(firstPipe.getResource().getPath())
+ .echo("apple")
+ .build();
testOneResource(superPipe.getResource().getPath(), PATH_APPLE);
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/sling/pipes/ManifoldPipeTest.java b/src/test/java/org/apache/sling/pipes/ManifoldPipeTest.java
index e1fb7a2..7e66007 100644
--- a/src/test/java/org/apache/sling/pipes/ManifoldPipeTest.java
+++ b/src/test/java/org/apache/sling/pipes/ManifoldPipeTest.java
@@ -1,21 +1,26 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes;
+import java.lang.reflect.InvocationTargetException;
+import java.util.Iterator;
+
import org.apache.sling.api.resource.PersistenceException;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.testing.mock.sling.ResourceResolverType;
@@ -23,9 +28,6 @@ import org.apache.sling.testing.mock.sling.junit.SlingContext;
import org.junit.Before;
import org.junit.Test;
-import java.lang.reflect.InvocationTargetException;
-import java.util.Iterator;
-
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeNotNull;
@@ -58,16 +60,17 @@ public class ManifoldPipeTest extends AbstractPipeTest {
Iterator<Resource> tenPipes = getOutput(PATH_PIPE + "/" + NN_STRAINED);
int numResults = 0;
while (tenPipes.hasNext()) {
- assumeNotNull("The output should not have null", tenPipes.next());
- numResults++;
+ assumeNotNull("The output should not have null", tenPipes.next());
+ numResults++;
}
- assertEquals("All the sub-pipes output should be present exactly once in Executor output", 10*6, numResults);
+ assertEquals("All the sub-pipes output should be present exactly once in Executor output", 10 * 6, numResults);
}
@Test
public void testStrainedFromReference() throws InvocationTargetException, IllegalAccessException {
- ExecutionResult result = execute( "ref " + PATH_PIPE + "/" + NN_STRAINED);
- assertEquals("All the sub-pipes output should be present exactly once in Executor output", 10*6, result.size());
+ ExecutionResult result = execute("ref " + PATH_PIPE + "/" + NN_STRAINED);
+ assertEquals(
+ "All the sub-pipes output should be present exactly once in Executor output", 10 * 6, result.size());
}
@Test
@@ -77,6 +80,8 @@ public class ManifoldPipeTest extends AbstractPipeTest {
.echo(PATH_BANANA)
.runParallel(2, null);
assertEquals("There should be 2 outputs", 2, result.size());
- assertTrue("Should contain both fruits", result.toString().contains(PATH_APPLE) && result.toString().contains(PATH_BANANA));
+ assertTrue(
+ "Should contain both fruits",
+ result.toString().contains(PATH_APPLE) && result.toString().contains(PATH_BANANA));
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/sling/pipes/OutputWriterTest.java b/src/test/java/org/apache/sling/pipes/OutputWriterTest.java
index 4aabd48..fc530bd 100644
--- a/src/test/java/org/apache/sling/pipes/OutputWriterTest.java
+++ b/src/test/java/org/apache/sling/pipes/OutputWriterTest.java
@@ -1,31 +1,33 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.testing.mock.sling.servlet.MockSlingHttpServletRequest;
import org.junit.Test;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -37,46 +39,36 @@ public class OutputWriterTest extends AbstractPipeTest {
}
@Override
- protected void initResponse(SlingHttpServletResponse response) {
-
- }
+ protected void initResponse(SlingHttpServletResponse response) {}
@Override
- public void starts() {
-
- }
+ public void starts() {}
@Override
- protected void writeItem(Resource resource) {
-
- }
+ protected void writeItem(Resource resource) {}
@Override
- public void ends() {
-
- }
+ public void ends() {}
};
-
-
public void initWithParam(String key, String value) throws IOException {
MockSlingHttpServletRequest request = context.request();
- Map<String,Object> map = new HashMap<>();
- map.put(key,value);
+ Map<String, Object> map = new HashMap<>();
+ map.put(key, value);
request.setParameterMap(map);
writer.init(request, context.response());
}
@Test
public void testSize() throws IOException {
- initWithParam("size","19");
+ initWithParam("size", "19");
assertEquals(19, writer.max);
}
@Test
public void testCustomWriter() throws IOException {
- initWithParam("writer","one=1,two=2,three=3");
+ initWithParam("writer", "one=1,two=2,three=3");
assertFalse(writer.customOutputs.isEmpty());
assertEquals("${1}", writer.customOutputs.get("one"));
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/sling/pipes/PipeBindingsTest.java b/src/test/java/org/apache/sling/pipes/PipeBindingsTest.java
index c5a7acf..263420e 100644
--- a/src/test/java/org/apache/sling/pipes/PipeBindingsTest.java
+++ b/src/test/java/org/apache/sling/pipes/PipeBindingsTest.java
@@ -1,21 +1,28 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes;
+import java.lang.reflect.InvocationTargetException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
import org.apache.sling.api.resource.PersistenceException;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.pipes.internal.NopWriter;
@@ -24,11 +31,6 @@ import org.apache.sling.testing.mock.caconfig.MockContextAwareConfig;
import org.junit.Before;
import org.junit.Test;
-import java.lang.reflect.InvocationTargetException;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThrows;
@@ -39,7 +41,7 @@ import static org.junit.Assert.assertTrue;
*/
public class PipeBindingsTest extends AbstractPipeTest {
- private static final String MOREBINDINGS =PATH_PIPE + "/moreBindings";
+ private static final String MOREBINDINGS = PATH_PIPE + "/moreBindings";
@Before
public void setup() throws PersistenceException {
@@ -47,7 +49,7 @@ public class PipeBindingsTest extends AbstractPipeTest {
context.load().json("/container.json", PATH_PIPE);
}
- private PipeBindings getDummyTreeBinding() throws Exception{
+ private PipeBindings getDummyTreeBinding() throws Exception {
Resource resource = context.resourceResolver().getResource(PATH_PIPE + "/" + ContainerPipeTest.NN_DUMMYTREE);
PipeBindings bindings = new PipeBindings(resource, true);
bindings.plumber = plumber;
@@ -58,25 +60,28 @@ public class PipeBindingsTest extends AbstractPipeTest {
public void testEvaluateSimpleString() throws Exception {
PipeBindings bindings = getDummyTreeBinding();
String simple = "simple string";
- String evaluated = (String)bindings.evaluate(simple);
+ String evaluated = (String) bindings.evaluate(simple);
assertEquals("evaluated should be the same than input", evaluated, simple);
}
@Test
public void computeEcma5Expression() throws Exception {
PipeBindings bindings = getDummyTreeBinding();
- Map<String,String> expressions = new HashMap<>();
+ Map<String, String> expressions = new HashMap<>();
expressions.put("blah ${blah} blah", "'blah ' + blah + ' blah'");
expressions.put("${blah}", "blah");
expressions.put("${blah} blah", "blah + ' blah'");
expressions.put("blah ${blah}", "'blah ' + blah");
expressions.put("${blah}${blah}", "blah + '' + blah");
expressions.put("+[${blah}]", "'+[' + blah + ']'");
- expressions.put("${(new Regexp('.{3}').test(path)}","(new Regexp('.{3}').test(path)");
- expressions.put("${(new Regexp('.{3,5}').test(path)}","(new Regexp('.{3,5}').test(path)");
+ expressions.put("${(new Regexp('.{3}').test(path)}", "(new Regexp('.{3}').test(path)");
+ expressions.put("${(new Regexp('.{3,5}').test(path)}", "(new Regexp('.{3,5}').test(path)");
expressions.put("${some {{other templating}} can exist}", "some {{other templating}} can exist");
- for (Map.Entry<String,String> test : expressions.entrySet()){
- assertEquals(test.getKey() + " should be transformed in " + test.getValue(), test.getValue(), bindings.computeTemplateExpression(test.getKey()));
+ for (Map.Entry<String, String> test : expressions.entrySet()) {
+ assertEquals(
+ test.getKey() + " should be transformed in " + test.getValue(),
+ test.getValue(),
+ bindings.computeTemplateExpression(test.getKey()));
}
}
@@ -105,7 +110,7 @@ public class PipeBindingsTest extends AbstractPipeTest {
testMap.put("a", "apricots");
testMap.put("b", "bananas");
bindings.getBindings().put("test", testMap);
- String newExpression = (String)bindings.instantiateObject("${test.a} and ${test.b}");
+ String newExpression = (String) bindings.instantiateObject("${test.a} and ${test.b}");
assertEquals("expression should be correctly instantiated", "apricots and bananas", newExpression);
/*Calendar cal = (Calendar)bindings.instantiateObject("${new Date('Sat, 12 May 2012 13:30:00 GMT')}");
assertNotNull("calendar should be instantiated", cal);
@@ -117,8 +122,8 @@ public class PipeBindingsTest extends AbstractPipeTest {
@Test
public void testAdditionalBindings() throws Exception {
Resource resource = context.resourceResolver().getResource(MOREBINDINGS);
- BasePipe pipe = (BasePipe)plumber.getPipe(resource);
- String expression = pipe.bindings.instantiateExpression("${three}");
+ BasePipe pipe = (BasePipe) plumber.getPipe(resource);
+ String expression = pipe.bindings.instantiateExpression("${three}");
assertEquals("computed expression should be taking additional bindings 'three' in account", "3", expression);
}
@@ -126,8 +131,8 @@ public class PipeBindingsTest extends AbstractPipeTest {
public void testAdditionalScript() throws Exception {
context.load().binaryFile("/testSum.js", "/content/test/testSum.js");
Resource resource = context.resourceResolver().getResource(MOREBINDINGS);
- BasePipe pipe = (BasePipe)plumber.getPipe(resource);
- Number expression = (Number)pipe.bindings.instantiateObject("${testSumFunction(1,2)}");
+ BasePipe pipe = (BasePipe) plumber.getPipe(resource);
+ Number expression = (Number) pipe.bindings.instantiateObject("${testSumFunction(1,2)}");
assertEquals("computed expression have testSum script's functionavailable", 3, expression.intValue());
}
@@ -135,14 +140,22 @@ public class PipeBindingsTest extends AbstractPipeTest {
public void testDisabledAdditionalScript() throws Exception {
context.load().binaryFile("/testSum.js", "/content/test/testSum.js");
Resource resource = context.resourceResolver().getResource(MOREBINDINGS);
- context.registerInjectActivateService(plumber, "authorizedUsers", new String[]{},
- "bufferSize", PlumberImpl.DEFAULT_BUFFER_SIZE,
- "executionPermissionResource", PATH_FRUITS,
- "mark.pipe.path",true,
- "referencesPaths", new String [] { "/conf/global/sling/pipes", "/apps/scripts" },
- "allow.additional.scripts", false);
+ context.registerInjectActivateService(
+ plumber,
+ "authorizedUsers",
+ new String[] {},
+ "bufferSize",
+ PlumberImpl.DEFAULT_BUFFER_SIZE,
+ "executionPermissionResource",
+ PATH_FRUITS,
+ "mark.pipe.path",
+ true,
+ "referencesPaths",
+ new String[] {"/conf/global/sling/pipes", "/apps/scripts"},
+ "allow.additional.scripts",
+ false);
assertThrows(RuntimeException.class, () -> {
- BasePipe pipe = (BasePipe)plumber.getPipe(resource);
+ BasePipe pipe = (BasePipe) plumber.getPipe(resource);
plumber.execute(context.resourceResolver(), pipe, null, new NopWriter(), true);
});
}
@@ -153,30 +166,33 @@ public class PipeBindingsTest extends AbstractPipeTest {
Iterator<Resource> output = pipe.getOutput();
output.next();
PipeBindings bindings = pipe.getBindings();
- assertEquals("first name binding should be apple", "apple", bindings.instantiateExpression("${name.dummyParent}"));
+ assertEquals(
+ "first name binding should be apple", "apple", bindings.instantiateExpression("${name.dummyParent}"));
output.next();
- assertEquals("second name binding should be banana", "banana", bindings.instantiateExpression("${name.dummyParent}"));
+ assertEquals(
+ "second name binding should be banana",
+ "banana",
+ bindings.instantiateExpression("${name.dummyParent}"));
}
@Test
public void testCaConfigBinding() throws InvocationTargetException, IllegalAccessException {
context.build().resource("/conf/foo/sling:configs/" + TestConfiguration.class.getName(), "fruit", "apple");
MockContextAwareConfig.registerAnnotationClasses(context, TestConfiguration.class);
- ExecutionResult result = execute("echo /content/fruits | echo ${caconfig.one['org.apache.sling.pipes.TestConfiguration'].fruit}");
+ ExecutionResult result = execute(
+ "echo /content/fruits | echo ${caconfig.one['org.apache.sling.pipes.TestConfiguration'].fruit}");
assertTrue(result.size() > 0);
assertEquals("/content/fruits/apple", result.currentPathSet.iterator().next());
}
@Test
public void testContextualError() throws InvocationTargetException, IllegalAccessException {
- ExecutionResult first = execute("json {'one':{'foo':'bar'},'two':{'another':'one'},'three':{'foo':'longer'}} | " +
- "mkdir /content/context/${one.key} | " +
- "write ${one.value.foo?'foo':'blah'}=one.value.foo");
- //the following should fail for /content/context/two
- ExecutionResult result = execute("echo /content/context " +
- "| children sling:Folder @ name child " +
- "| write foo=${child.foo?child.foo:nonexistingFunction(nonexistingVariable)}");
+ ExecutionResult first = execute("json {'one':{'foo':'bar'},'two':{'another':'one'},'three':{'foo':'longer'}} | "
+ + "mkdir /content/context/${one.key} | "
+ + "write ${one.value.foo?'foo':'blah'}=one.value.foo");
+ // the following should fail for /content/context/two
+ ExecutionResult result = execute("echo /content/context " + "| children sling:Folder @ name child "
+ + "| write foo=${child.foo?child.foo:nonexistingFunction(nonexistingVariable)}");
assertEquals(2, result.size());
}
-
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/sling/pipes/PipeBuilderTest.java b/src/test/java/org/apache/sling/pipes/PipeBuilderTest.java
index 012c0d8..f1425d7 100644
--- a/src/test/java/org/apache/sling/pipes/PipeBuilderTest.java
+++ b/src/test/java/org/apache/sling/pipes/PipeBuilderTest.java
@@ -1,25 +1,23 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes;
-import org.apache.sling.api.resource.ValueMap;
-import org.apache.sling.pipes.internal.JsonUtil;
-import org.junit.Test;
-
import javax.json.JsonObject;
import java.lang.reflect.InvocationTargetException;
@@ -28,6 +26,10 @@ import java.util.HashMap;
import java.util.Map;
import java.util.stream.Collectors;
+import org.apache.sling.api.resource.ValueMap;
+import org.apache.sling.pipes.internal.JsonUtil;
+import org.junit.Test;
+
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -38,10 +40,12 @@ public class PipeBuilderTest extends AbstractPipeTest {
@Test
public void simpleBuild() throws Exception {
Pipe rmPipe = plumber.newPipe(context.resourceResolver())
- .echo(PATH_APPLE)
- .rm().build();
+ .echo(PATH_APPLE)
+ .rm()
+ .build();
assertNotNull(" a basePipe should be built", rmPipe);
- //we rebuild basePipe out of created basePipe path, execute it, and test correct output (= correct basePipe built)
+ // we rebuild basePipe out of created basePipe path, execute it, and test correct output (= correct basePipe
+ // built)
testOneResource(rmPipe.getResource().getPath(), PATH_FRUITS);
}
@@ -50,8 +54,11 @@ public class PipeBuilderTest extends AbstractPipeTest {
String lemonPath = "/content/fruits/lemon";
PipeBuilder lemonBuilder = plumber.newPipe(context.resourceResolver());
ExecutionResult result = lemonBuilder.mkdir(lemonPath).run();
- assertTrue("returned set should contain lemon path", result.getCurrentPathSet().contains(lemonPath));
- assertNotNull("there should be a lemon created", context.resourceResolver().getResource(lemonPath));
+ assertTrue(
+ "returned set should contain lemon path",
+ result.getCurrentPathSet().contains(lemonPath));
+ assertNotNull(
+ "there should be a lemon created", context.resourceResolver().getResource(lemonPath));
}
@Test
@@ -59,9 +66,13 @@ public class PipeBuilderTest extends AbstractPipeTest {
String lemonPath = "/content/fruits/lemon";
PipeBuilder lemonBuilder = plumber.newPipe(context.resourceResolver());
ExecutionResult result = lemonBuilder.mkdir(lemonPath).runWith("dryRun", true);
- assertFalse("returned set should not contain lemon path with dryRun=true(boolean)", result.getCurrentPathSet().contains(lemonPath));
+ assertFalse(
+ "returned set should not contain lemon path with dryRun=true(boolean)",
+ result.getCurrentPathSet().contains(lemonPath));
ExecutionResult textResult = lemonBuilder.mkdir(lemonPath).runWith("dryRun", "true");
- assertFalse("returned set should not contain lemon path with dryRun=true(text)", textResult.getCurrentPathSet().contains(lemonPath));
+ assertFalse(
+ "returned set should not contain lemon path with dryRun=true(text)",
+ textResult.getCurrentPathSet().contains(lemonPath));
}
@Test
@@ -69,68 +80,86 @@ public class PipeBuilderTest extends AbstractPipeTest {
PipeBuilder writeBuilder = plumber.newPipe(context.resourceResolver());
writeBuilder.echo(PATH_APPLE).write("tested", true, "working", true).run();
ValueMap properties = context.resourceResolver().getResource(PATH_APPLE).adaptTo(ValueMap.class);
- assertTrue("properties should have been written", properties.get("tested", false) && properties.get("working", false));
+ assertTrue(
+ "properties should have been written",
+ properties.get("tested", false) && properties.get("working", false));
}
@Test
public void confContainerProperties() throws Exception {
PipeBuilder containerBuilder = plumber.newPipe(context.resourceResolver());
- containerBuilder.with("test",true);
+ containerBuilder.with("test", true);
String specialPath = "/content/testedContainer";
containerBuilder.echo(PATH_APPLE).write("tested", true, "working", true).build(specialPath);
- ValueMap properties = context.resourceResolver().getResource(specialPath).adaptTo(ValueMap.class);
+ ValueMap properties =
+ context.resourceResolver().getResource(specialPath).adaptTo(ValueMap.class);
assertTrue("property should have been written", properties.get("test", false));
}
@Test
public void bindings() throws Exception {
- ExecutionResult result = execute("echo /content/fruits | children nt:unstructured " +
- "| grep slingPipesFilter_test=two.worm | children nt:unstructured#isnota " +
- "| children nt:unstructured @ name thing | write jcr:path=path.thing");
+ ExecutionResult result = execute("echo /content/fruits | children nt:unstructured "
+ + "| grep slingPipesFilter_test=two.worm | children nt:unstructured#isnota "
+ + "| children nt:unstructured @ name thing | write jcr:path=path.thing");
assertEquals("There should be 3 resources", 3, result.size());
String pea = "/content/fruits/apple/isnota/pea";
String carrot = "/content/fruits/apple/isnota/carrot";
Collection<String> paths = result.getCurrentPathSet();
assertTrue("the paths should contain " + pea, paths.contains(pea));
assertTrue("the paths should contain " + carrot, paths.contains(carrot));
- for (String path : paths){
- String writtenPath = context.resourceResolver().getResource(path).adaptTo(ValueMap.class).get("jcr:path", String.class);
+ for (String path : paths) {
+ String writtenPath = context.resourceResolver()
+ .getResource(path)
+ .adaptTo(ValueMap.class)
+ .get("jcr:path", String.class);
assertEquals("written path should be the same as actual path", path, writtenPath);
}
}
+
@Test
public void whitespaces() throws InvocationTargetException, IllegalAccessException {
execute("echo /content/fruits | write jcr:title=\"white space\"");
- assertEquals("property should have been written correctly",
- "white space", context.resourceResolver().getResource(PATH_FRUITS).getValueMap().get("jcr:title"));
+ assertEquals(
+ "property should have been written correctly",
+ "white space",
+ context.resourceResolver()
+ .getResource(PATH_FRUITS)
+ .getValueMap()
+ .get("jcr:title"));
}
@Test
public void additionalBindings() throws Exception {
Map bindings = new HashMap<>();
bindings.put("testedPath", PATH_FRUITS);
- ExecutionResult result = plumber.newPipe(context.resourceResolver()).echo("${testedPath}").run(bindings);
+ ExecutionResult result = plumber.newPipe(context.resourceResolver())
+ .echo("${testedPath}")
+ .run(bindings);
Collection<String> paths = result.getCurrentPathSet();
- assertTrue("paths should contain implemented testedPath after run(bindings) is executed", paths.contains(PATH_FRUITS));
+ assertTrue(
+ "paths should contain implemented testedPath after run(bindings) is executed",
+ paths.contains(PATH_FRUITS));
paths = plumber.newPipe(context.resourceResolver())
- .echo("${testedPath}").runWith("testedPath", PATH_FRUITS)
+ .echo("${testedPath}")
+ .runWith("testedPath", PATH_FRUITS)
.getCurrentPathSet();
- assertTrue("paths should contain implemented testedPath after runWith is executed", paths.contains(PATH_FRUITS));
+ assertTrue(
+ "paths should contain implemented testedPath after runWith is executed", paths.contains(PATH_FRUITS));
}
@Test
public void testOutputs() throws Exception {
ExecutionResult result = plumber.newPipe(context.resourceResolver())
- .echo(PATH_APPLE + "/isnota")
- .children("nt:unstructured")
- .name("vegetable")
- .outputs("name","vegetable['jcr:title']")
- .run();
+ .echo(PATH_APPLE + "/isnota")
+ .children("nt:unstructured")
+ .name("vegetable")
+ .outputs("name", "vegetable['jcr:title']")
+ .run();
JsonObject object = JsonUtil.parseObject(result.toString());
- Collection<String> names = object.getJsonArray("items").getValuesAs(JsonObject.class)
- .stream()
- .map(o -> o.getString("name"))
- .collect(Collectors.toList());
- assertArrayEquals("all transformed items should be here", new String[] {"Pea", "Plum", "Carrot"}, names.toArray());
+ Collection<String> names = object.getJsonArray("items").getValuesAs(JsonObject.class).stream()
+ .map(o -> o.getString("name"))
+ .collect(Collectors.toList());
+ assertArrayEquals(
+ "all transformed items should be here", new String[] {"Pea", "Plum", "Carrot"}, names.toArray());
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/sling/pipes/PipeExternalScriptingBindingsTest.java b/src/test/java/org/apache/sling/pipes/PipeExternalScriptingBindingsTest.java
index d4a62f5..7a35b19 100644
--- a/src/test/java/org/apache/sling/pipes/PipeExternalScriptingBindingsTest.java
+++ b/src/test/java/org/apache/sling/pipes/PipeExternalScriptingBindingsTest.java
@@ -1,26 +1,23 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-
-import java.util.Calendar;
import java.util.HashMap;
import java.util.Map;
@@ -29,12 +26,16 @@ import org.apache.sling.api.resource.Resource;
import org.junit.Before;
import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
/**
* testing binding's expressions instanciations
*/
public class PipeExternalScriptingBindingsTest extends AbstractPipeTest {
- private static final String MOREBINDINGS =PATH_PIPE + "/moreBindings";
+ private static final String MOREBINDINGS = PATH_PIPE + "/moreBindings";
private static final String JS_ENGINE = "nashorn";
private static final String GROOVY_ENGINE = "groovy";
@@ -45,7 +46,7 @@ public class PipeExternalScriptingBindingsTest extends AbstractPipeTest {
context.load().json("/container.json", PATH_PIPE);
}
- private PipeBindings getDummyTreeBinding(String scriptEngine) throws Exception{
+ private PipeBindings getDummyTreeBinding(String scriptEngine) throws Exception {
Resource resource = context.resourceResolver().getResource(PATH_PIPE + "/" + ContainerPipeTest.NN_DUMMYTREE);
PipeBindings bindings = new PipeBindings(resource, true);
bindings.initializeScriptEngine(scriptEngine);
@@ -77,7 +78,7 @@ public class PipeExternalScriptingBindingsTest extends AbstractPipeTest {
testMap.put("a", "apricots");
testMap.put("b", "bananas");
bindings.getBindings().put("test", testMap);
- String newExpression = (String)bindings.instantiateObject("${test.a} and ${test.b}");
+ String newExpression = (String) bindings.instantiateObject("${test.a} and ${test.b}");
assertEquals("expression should be correctly instantiated", "apricots and bananas", newExpression);
}
@@ -85,18 +86,20 @@ public class PipeExternalScriptingBindingsTest extends AbstractPipeTest {
public void testJSAdditionalScript() throws Exception {
context.load().binaryFile("/testSum.js", "/content/test/testSum.js");
Resource resource = context.resourceResolver().getResource(MOREBINDINGS);
- BasePipe pipe = (BasePipe)plumber.getPipe(resource);
- Number expression = (Number)pipe.bindings.instantiateObject("${testSumFunction(1,2)}");
+ BasePipe pipe = (BasePipe) plumber.getPipe(resource);
+ Number expression = (Number) pipe.bindings.instantiateObject("${testSumFunction(1,2)}");
assertEquals("computed expression have testSum script's functionavailable", 3, expression.intValue());
}
@Test
public void testGroovyPipe() throws Exception {
ExecutionResult executionResult = plumber.newPipe(context.resourceResolver())
- .echo("/content")
- .mkdir("hello/${\"$who\"}")
- .runWith("engine","groovy","who","world");
+ .echo("/content")
+ .mkdir("hello/${\"$who\"}")
+ .runWith("engine", "groovy", "who", "world");
assertNotNull(executionResult);
- assertEquals("/content/hello/world", executionResult.currentPathSet.iterator().next());
+ assertEquals(
+ "/content/hello/world",
+ executionResult.currentPathSet.iterator().next());
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/sling/pipes/TestConfiguration.java b/src/test/java/org/apache/sling/pipes/TestConfiguration.java
index 194f24e..9852562 100644
--- a/src/test/java/org/apache/sling/pipes/TestConfiguration.java
+++ b/src/test/java/org/apache/sling/pipes/TestConfiguration.java
@@ -1,24 +1,26 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes;
import org.apache.sling.caconfig.annotation.Configuration;
-@Configuration(label="Test Configuration", description = "used for testing CAConfig in pipes")
+@Configuration(label = "Test Configuration", description = "used for testing CAConfig in pipes")
public @interface TestConfiguration {
String fruit();
}
diff --git a/src/test/java/org/apache/sling/pipes/dummies/DummyNull.java b/src/test/java/org/apache/sling/pipes/dummies/DummyNull.java
index 496bb94..ac7b5dd 100644
--- a/src/test/java/org/apache/sling/pipes/dummies/DummyNull.java
+++ b/src/test/java/org/apache/sling/pipes/dummies/DummyNull.java
@@ -1,29 +1,31 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes.dummies;
+import java.util.Collections;
+import java.util.Iterator;
+
import org.apache.sling.api.resource.Resource;
import org.apache.sling.pipes.BasePipe;
import org.apache.sling.pipes.PipeBindings;
import org.apache.sling.pipes.Plumber;
-import java.util.Collections;
-import java.util.Iterator;
-
/**
* this pipe has nothing in output
*/
diff --git a/src/test/java/org/apache/sling/pipes/dummies/DummySearch.java b/src/test/java/org/apache/sling/pipes/dummies/DummySearch.java
index 176ec93..c2d497c 100644
--- a/src/test/java/org/apache/sling/pipes/dummies/DummySearch.java
+++ b/src/test/java/org/apache/sling/pipes/dummies/DummySearch.java
@@ -1,31 +1,34 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes.dummies;
-import org.apache.sling.api.resource.Resource;
-import org.apache.sling.pipes.BasePipe;
-import org.apache.sling.pipes.PipeBindings;
-import org.apache.sling.pipes.Plumber;
-
import javax.jcr.Node;
import javax.jcr.NodeIterator;
+
import java.util.Collections;
import java.util.Iterator;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.pipes.BasePipe;
+import org.apache.sling.pipes.PipeBindings;
+import org.apache.sling.pipes.Plumber;
+
/**
* dummy search reads its conf node subpipes and returns them.
*/
@@ -62,11 +65,9 @@ public class DummySearch extends BasePipe {
}
@Override
- public void remove() {
-
- }
+ public void remove() {}
};
- } catch (Exception e){
+ } catch (Exception e) {
}
return Collections.<Resource>emptyList().iterator();
diff --git a/src/test/java/org/apache/sling/pipes/internal/ACLPipeTest.java b/src/test/java/org/apache/sling/pipes/internal/ACLPipeTest.java
index e92b7e4..0ab9779 100644
--- a/src/test/java/org/apache/sling/pipes/internal/ACLPipeTest.java
+++ b/src/test/java/org/apache/sling/pipes/internal/ACLPipeTest.java
@@ -1,22 +1,33 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-
package org.apache.sling.pipes.internal;
+import javax.jcr.Session;
+import javax.jcr.security.AccessControlList;
+import javax.jcr.security.Privilege;
+import javax.json.JsonArray;
+import javax.json.JsonObject;
+import javax.json.JsonStructure;
+
+import java.security.Principal;
+import java.util.Iterator;
+
import org.apache.jackrabbit.api.JackrabbitSession;
import org.apache.jackrabbit.api.security.JackrabbitAccessControlEntry;
import org.apache.jackrabbit.api.security.principal.PrincipalManager;
@@ -32,15 +43,6 @@ import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
-import javax.jcr.Session;
-import javax.jcr.security.AccessControlList;
-import javax.jcr.security.Privilege;
-import javax.json.JsonArray;
-import javax.json.JsonObject;
-import javax.json.JsonStructure;
-import java.security.Principal;
-import java.util.Iterator;
-
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -57,65 +59,83 @@ public class ACLPipeTest extends AbstractPipeTest {
}
@Test
- public void testAllow() throws Exception{
+ public void testAllow() throws Exception {
Pipe pipe = plumber.getPipe(oak.resourceResolver().getResource(PATH_PIPE + "/allow"));
Iterator<Resource> outputs = pipe.getOutput();
JackrabbitAccessControlEntry[] entries = retrieveACLsSetOnResourceWithPipe(pipe);
assertNotNull(entries);
assertEquals("There should be only one entry", 1, entries.length);
- assertEquals("Entry prinicipal should be anonymous", "anonymous", entries[0].getPrincipal().getName());
+ assertEquals(
+ "Entry prinicipal should be anonymous",
+ "anonymous",
+ entries[0].getPrincipal().getName());
assertEquals("Entry should be allow or rep:GrantACE", true, entries[0].isAllow());
assertEquals("Entry privileges should be jcr:read", "jcr:read", entries[0].getPrivileges()[0].getName());
}
@Test
- public void testAllowDefault() throws Exception{
+ public void testAllowDefault() throws Exception {
Pipe pipe = plumber.getPipe(oak.resourceResolver().getResource(PATH_PIPE + "/allowDefault"));
Iterator<Resource> outputs = pipe.getOutput();
- JackrabbitAccessControlEntry[] entries = retrieveACLsSetOnResourceWithPipe(pipe);assertNotNull(entries);
+ JackrabbitAccessControlEntry[] entries = retrieveACLsSetOnResourceWithPipe(pipe);
+ assertNotNull(entries);
assertEquals("There should be only one entry", 1, entries.length);
- assertEquals("Entry prinicipal should be anonymous", "anonymous", entries[0].getPrincipal().getName());
+ assertEquals(
+ "Entry prinicipal should be anonymous",
+ "anonymous",
+ entries[0].getPrincipal().getName());
assertEquals("Entry should be allow or rep:GrantACE", true, entries[0].isAllow());
- assertEquals("Entry privileges should be jcr:all by default", "jcr:all", entries[0].getPrivileges()[0].getName());
+ assertEquals(
+ "Entry privileges should be jcr:all by default", "jcr:all", entries[0].getPrivileges()[0].getName());
}
@Test
- public void testDeny() throws Exception{
+ public void testDeny() throws Exception {
Pipe pipe = plumber.getPipe(oak.resourceResolver().getResource(PATH_PIPE + "/deny"));
Iterator<Resource> outputs = pipe.getOutput();
JackrabbitAccessControlEntry[] entries = retrieveACLsSetOnResourceWithPipe(pipe);
assertNotNull(entries);
assertEquals("There should be only one entry", 1, entries.length);
- assertEquals("Entry prinicipal should be anonymous", "anonymous", entries[0].getPrincipal().getName());
+ assertEquals(
+ "Entry prinicipal should be anonymous",
+ "anonymous",
+ entries[0].getPrincipal().getName());
assertEquals("Entry should be deny or rep:DenyACE", false, entries[0].isAllow());
assertEquals("Entry privileges should be jcr:write", "jcr:write", entries[0].getPrivileges()[0].getName());
}
@Test
- public void testDenyDefault() throws Exception{
+ public void testDenyDefault() throws Exception {
Pipe pipe = plumber.getPipe(oak.resourceResolver().getResource(PATH_PIPE + "/denyDefault"));
Iterator<Resource> outputs = pipe.getOutput();
JackrabbitAccessControlEntry[] entries = retrieveACLsSetOnResourceWithPipe(pipe);
assertNotNull(entries);
assertEquals("There should be only one entry", 1, entries.length);
- assertEquals("Entry prinicipal should be anonymous", "anonymous", entries[0].getPrincipal().getName());
+ assertEquals(
+ "Entry prinicipal should be anonymous",
+ "anonymous",
+ entries[0].getPrincipal().getName());
assertEquals("Entry should be deny or rep:DenyACE", false, entries[0].isAllow());
- assertEquals("Entry privileges should be jcr:read by default", "jcr:read", entries[0].getPrivileges()[0].getName());
+ assertEquals(
+ "Entry privileges should be jcr:read by default", "jcr:read", entries[0].getPrivileges()[0].getName());
}
@Test
- public void testACLs() throws Exception{
+ public void testACLs() throws Exception {
setACLsOnResourceWithPath(PATH_FRUITS);
Pipe pipe = plumber.getPipe(oak.resourceResolver().getResource(PATH_PIPE + "/acl"));
pipe.getOutput();
Object bindings = pipe.getOutputBinding();
assertNotNull(bindings);
- JsonStructure json = JsonUtil.parse((String)bindings);
+ JsonStructure json = JsonUtil.parse((String) bindings);
assertEquals(json.getValueType().name(), "ARRAY");
- JsonArray jsonValues = JsonUtil.parseArray((String)bindings);
+ JsonArray jsonValues = JsonUtil.parseArray((String) bindings);
assertEquals("size should be one", 1, jsonValues.size());
assertEquals("values should be equal", jsonValues.getJsonObject(0).getString("authorizable"), "anonymous");
- assertEquals("values should be equal", JsonUtil.toString(jsonValues.getJsonObject(0).get("privileges")), "[\"jcr:read\"]");
+ assertEquals(
+ "values should be equal",
+ JsonUtil.toString(jsonValues.getJsonObject(0).get("privileges")),
+ "[\"jcr:read\"]");
}
@Ignore
@@ -123,30 +143,40 @@ public class ACLPipeTest extends AbstractPipeTest {
/*
Ignoring the test for now since Oak mocking doesn't support resolver.adapt(Authorizable.class)
*/
- public void testACLsWithResourceAsAuthorizable() throws Exception{
+ public void testACLsWithResourceAsAuthorizable() throws Exception {
setACLsOnResourceWithPath(PATH_FRUITS);
Pipe pipe = plumber.getPipe(oak.resourceResolver().getResource(PATH_PIPE + "/aclAuthorizable"));
pipe.getOutput();
Object bindings = pipe.getOutputBinding();
- JsonStructure json = JsonUtil.parse((String)bindings);
+ JsonStructure json = JsonUtil.parse((String) bindings);
assertEquals(json.getValueType().name(), "OBJECT");
- JsonObject jsonValues = JsonUtil.parseObject((String)bindings);
+ JsonObject jsonValues = JsonUtil.parseObject((String) bindings);
assertEquals("size should be one", 1, jsonValues.size());
- assertEquals("values should be equal", jsonValues.getJsonArray("allow").getJsonObject(0).getString("path"),"/content/fruits");
- assertEquals("values should be equal", JsonUtil.toString(jsonValues.getJsonArray("allow").getJsonObject(0).getJsonArray("privileges")), "[\"jcr:read\"]");}
+ assertEquals(
+ "values should be equal",
+ jsonValues.getJsonArray("allow").getJsonObject(0).getString("path"),
+ "/content/fruits");
+ assertEquals(
+ "values should be equal",
+ JsonUtil.toString(
+ jsonValues.getJsonArray("allow").getJsonObject(0).getJsonArray("privileges")),
+ "[\"jcr:read\"]");
+ }
- private void setACLsOnResourceWithPath(String path) throws Exception{
+ private void setACLsOnResourceWithPath(String path) throws Exception {
Session session = oak.resourceResolver().adaptTo(Session.class);
- JackrabbitSession jackrabbitSession = ( JackrabbitSession ) session;
+ JackrabbitSession jackrabbitSession = (JackrabbitSession) session;
PrincipalManager principalManager = jackrabbitSession.getPrincipalManager();
Principal principal = principalManager.getPrincipal("anonymous");
Privilege[] privileges = AccessControlUtils.privilegesFromNames(session, Privilege.JCR_READ);
- AccessControlUtils.addAccessControlEntry(oak.resourceResolver().adaptTo(Session.class), path, principal, privileges, true);
+ AccessControlUtils.addAccessControlEntry(
+ oak.resourceResolver().adaptTo(Session.class), path, principal, privileges, true);
}
- private JackrabbitAccessControlEntry[] retrieveACLsSetOnResourceWithPipe(Pipe pipe) throws Exception{
- //retrieve acls on resource after setting
- AccessControlList acl = AccessControlUtils.getAccessControlList(oak.resourceResolver().adaptTo(Session.class), pipe.getInput().getPath());
+ private JackrabbitAccessControlEntry[] retrieveACLsSetOnResourceWithPipe(Pipe pipe) throws Exception {
+ // retrieve acls on resource after setting
+ AccessControlList acl = AccessControlUtils.getAccessControlList(
+ oak.resourceResolver().adaptTo(Session.class), pipe.getInput().getPath());
JackrabbitAccessControlEntry[] entries = (JackrabbitAccessControlEntry[]) acl.getAccessControlEntries();
return entries;
}
diff --git a/src/test/java/org/apache/sling/pipes/internal/CommandExecutorImplTest.java b/src/test/java/org/apache/sling/pipes/internal/CommandExecutorImplTest.java
index 6f56a0a..8d0fe9b 100644
--- a/src/test/java/org/apache/sling/pipes/internal/CommandExecutorImplTest.java
+++ b/src/test/java/org/apache/sling/pipes/internal/CommandExecutorImplTest.java
@@ -1,21 +1,37 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes.internal;
+import javax.json.JsonArray;
+import javax.json.JsonObject;
+import javax.json.JsonString;
+import javax.servlet.ServletException;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.stream.Collectors;
+
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.sling.api.resource.PersistenceException;
@@ -32,30 +48,15 @@ import org.apache.sling.testing.mock.sling.servlet.MockSlingHttpServletResponse;
import org.junit.Before;
import org.junit.Test;
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.stream.Collectors;
-
import static org.apache.sling.pipes.internal.CommandExecutorImpl.DECL_BINDING;
import static org.apache.sling.pipes.internal.CommandExecutorImpl.DECL_BINDING_CONTENT;
import static org.apache.sling.pipes.internal.CommandExecutorImpl.DECL_BINDING_PATTERN;
import static org.apache.sling.pipes.internal.CommandExecutorImpl.PARAMS_SEPARATOR;
-import static org.apache.sling.pipes.CommandUtil.keyValuesToArray;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
-import javax.json.JsonArray;
-import javax.json.JsonObject;
-import javax.json.JsonString;
-import javax.servlet.ServletException;
-
public class CommandExecutorImplTest extends AbstractPipeTest {
CommandExecutorImpl commands;
@@ -72,11 +73,15 @@ public class CommandExecutorImplTest extends AbstractPipeTest {
@Test
public void getSublist() {
- assertArrayEquals(new String[]{"check", "this"}, commands.getSpaceSeparatedTokens("check this").toArray());
- assertArrayEquals(new String[]{"and", "now","check this"}, commands.getSpaceSeparatedTokens("and now \"check this\"").toArray());
+ assertArrayEquals(
+ new String[] {"check", "this"},
+ commands.getSpaceSeparatedTokens("check this").toArray());
+ assertArrayEquals(
+ new String[] {"and", "now", "check this"},
+ commands.getSpaceSeparatedTokens("and now \"check this\"").toArray());
}
- @Test
+ @Test
public void testParseTokens() {
List<CommandExecutorImpl.Token> tokens = commands.parseTokens("some isolated items");
assertEquals("there should be 1 token", 1, tokens.size());
@@ -84,18 +89,23 @@ public class CommandExecutorImplTest extends AbstractPipeTest {
assertEquals("pipe key should be 'some'", "some", token.pipeKey);
assertEquals("pipe args should be isolated, items", Arrays.asList("isolated", "items"), token.args);
}
+
@Test
public void testParseTokensWithQuotes() {
String tokenString = "first arg | second firstarg secondarg @ name second | third blah";
List<CommandExecutorImpl.Token> tokens = commands.parseTokens(tokenString);
assertEquals("there should be 3 tokens", 3, tokens.size());
- assertEquals("keys check", Arrays.asList("first","second", "third"), tokens.stream().map(t -> t.pipeKey).collect(Collectors.toList()));
+ assertEquals(
+ "keys check",
+ Arrays.asList("first", "second", "third"),
+ tokens.stream().map(t -> t.pipeKey).collect(Collectors.toList()));
assertEquals("params check", "second", tokens.get(1).options.name);
}
@Test
public void testParseJson() {
- String tokenString = "json [{\"title\":\"this is the first\", \"path\":\"/content/nested/two\"}, {\"title\":\"this is the second\", \"path\":\"/content/nested/three\"}]";
+ String tokenString =
+ "json [{\"title\":\"this is the first\", \"path\":\"/content/nested/two\"}, {\"title\":\"this is the second\", \"path\":\"/content/nested/three\"}]";
List<CommandExecutorImpl.Token> tokens = commands.parseTokens(tokenString);
assertEquals("there should be 1 token", 1, tokens.size());
assertEquals("there should be 1 arg", 1, tokens.get(0).args.size());
@@ -106,18 +116,20 @@ public class CommandExecutorImplTest extends AbstractPipeTest {
List<CommandExecutorImpl.Token> tokens = commands.parseTokens("some isolated items \"with quotes\"");
assertEquals("there should be 1 token", 1, tokens.size());
CommandExecutorImpl.Token token = tokens.get(0);
- assertEquals("pipe args should be isolated, items", Arrays.asList("isolated", "items", "with quotes"), token.args);
+ assertEquals(
+ "pipe args should be isolated, items", Arrays.asList("isolated", "items", "with quotes"), token.args);
}
@Test
public void testSimpleExpression() throws Exception {
- PipeBuilder builder = commands.parse(context.resourceResolver(),"echo /content/fruits");
+ PipeBuilder builder = commands.parse(context.resourceResolver(), "echo /content/fruits");
assertTrue("there should be a resource", builder.build().getOutput().hasNext());
}
@Test
public void testSimpleChainedConf() throws Exception {
- PipeBuilder builder = commands.parse(context.resourceResolver(),"echo /content/fruits | write some=test key=value");
+ PipeBuilder builder =
+ commands.parse(context.resourceResolver(), "echo /content/fruits | write some=test key=value");
assertNotNull("there should be a resource", builder.run());
ValueMap props = context.currentResource(PATH_FRUITS).getValueMap();
assertEquals("there should some=test", "test", props.get("some"));
@@ -127,7 +139,8 @@ public class CommandExecutorImplTest extends AbstractPipeTest {
@Test
public void testOptions() {
String expected = "works";
- String optionString = "name works @ path works @ expr works @ with one=works two=works @ outputs one=works two=works";
+ String optionString =
+ "name works @ path works @ expr works @ with one=works two=works @ outputs one=works two=works";
CommandExecutorImpl.Options options = commands.getOptions(optionString.split(PARAMS_SEPARATOR));
assertEquals("check name", expected, options.name);
assertEquals("check expr", expected, options.expr);
@@ -152,8 +165,8 @@ public class CommandExecutorImplTest extends AbstractPipeTest {
@Test
public void testChainedConfWithInternalOptions() throws Exception {
- PipeBuilder builder = commands.parse(context.resourceResolver(),
- "echo /content/fruits @ name fruits | write some=${path.fruits} key=value");
+ PipeBuilder builder = commands.parse(
+ context.resourceResolver(), "echo /content/fruits @ name fruits | write some=${path.fruits} key=value");
assertNotNull("there should be a resource", builder.run());
ValueMap props = context.currentResource(PATH_FRUITS).getValueMap();
assertEquals("there should some=/content/fruits", PATH_FRUITS, props.get("some"));
@@ -169,26 +182,33 @@ public class CommandExecutorImplTest extends AbstractPipeTest {
@Test
public void adaptToDemoTest() throws Exception {
String url = "'http://99-bottles-of-beer.net/lyrics.html'";
- String cmd = "egrep " + url + " @ name bottles @ with pattern=(?<number>\\d(\\d)?) | mkdir /var/bottles/${bottles.number}";
+ String cmd = "egrep " + url
+ + " @ name bottles @ with pattern=(?<number>\\d(\\d)?) | mkdir /var/bottles/${bottles.number}";
PipeBuilder builder = commands.parse(context.resourceResolver(), cmd);
- ContainerPipe pipe = (ContainerPipe)builder.build();
+ ContainerPipe pipe = (ContainerPipe) builder.build();
ValueMap regexp = pipe.getResource().getChild("conf/bottles").getValueMap();
assertEquals("we expect expr to be the url", url, regexp.get("expr"));
}
@Test
public void testExecuteWithWriter() throws Exception {
- PipeBuilder builder = plumber.newPipe(context.resourceResolver()).echo("/content/${node}").$("nt:base");
+ PipeBuilder builder = plumber.newPipe(context.resourceResolver())
+ .echo("/content/${node}")
+ .$("nt:base");
String path = builder.build().getResource().getPath();
- ExecutionResult result = commands.execute(context.resourceResolver(), path, "outputs title=two['jcr:title'] desc=two['jcr:description']", "with node=fruits");
+ ExecutionResult result = commands.execute(
+ context.resourceResolver(),
+ path,
+ "outputs title=two['jcr:title'] desc=two['jcr:description']",
+ "with node=fruits");
assertNotNull(result);
}
- String testRawServlet(Map<String,Object> params) throws IOException {
+ String testRawServlet(Map<String, Object> params) throws IOException {
MockSlingHttpServletRequest request = context.request();
MockSlingHttpServletResponse response = context.response();
request.setParameterMap(params);
- MockRequestPathInfo pathInfo = (MockRequestPathInfo)request.getRequestPathInfo();
+ MockRequestPathInfo pathInfo = (MockRequestPathInfo) request.getRequestPathInfo();
pathInfo.setExtension("json");
request.setMethod("POST");
commands.doPost(request, response);
@@ -199,7 +219,7 @@ public class CommandExecutorImplTest extends AbstractPipeTest {
return response.getOutputAsString();
}
- JsonObject testServlet(Map<String,Object> params) throws ServletException, IOException {
+ JsonObject testServlet(Map<String, Object> params) throws ServletException, IOException {
return (JsonObject) JsonUtil.parse(testRawServlet(params));
}
@@ -230,30 +250,35 @@ public class CommandExecutorImplTest extends AbstractPipeTest {
@Test
public void testMultipeLineGetCommandLine() throws IOException, ServletException {
Map<String, Object> params = new HashMap<>();
- params.put(CommandExecutorImpl.REQ_PARAM_FILE, IOUtils.toString(getClass().getResourceAsStream("/commandsFormats"
- + ".txt"), "UTF-8"));
+ params.put(
+ CommandExecutorImpl.REQ_PARAM_FILE,
+ IOUtils.toString(getClass().getResourceAsStream("/commandsFormats" + ".txt"), "UTF-8"));
MockSlingHttpServletRequest request = context.request();
request.setParameterMap(params);
request.setMethod("POST");
List<String> cmdList = commands.getCommandList(context.request(), new HashMap<>());
assertEquals(5, cmdList.size());
- for (int i = 0; i < 3; i ++) {
+ for (int i = 0; i < 3; i++) {
assertEquals("echo /content | $ /apps/pipes-it/fruit | children nt:unstructured", cmdList.get(i));
}
- assertEquals ("echo /content | write one=foo nested/two=foo nested/three=foo", cmdList.get(3));
- assertEquals("echo /content | json [{\"title\":\"this is the first\", \"path\":\"/content/nested/two\"}, {\"title\":\"this is the second\", \"path\":\"/content/nested/three\"}] @ name test | echo ${test.path}", cmdList.get(4));
+ assertEquals("echo /content | write one=foo nested/two=foo nested/three=foo", cmdList.get(3));
+ assertEquals(
+ "echo /content | json [{\"title\":\"this is the first\", \"path\":\"/content/nested/two\"}, {\"title\":\"this is the second\", \"path\":\"/content/nested/three\"}] @ name test | echo ${test.path}",
+ cmdList.get(4));
}
String[] getItemsArray(JsonObject response) {
JsonArray jsonItems = response.getJsonArray("items");
- List<String> items = jsonItems.stream().map(o -> ((JsonString)o).getString()).collect(Collectors.toList());
+ List<String> items =
+ jsonItems.stream().map(o -> ((JsonString) o).getString()).collect(Collectors.toList());
return items.toArray(new String[jsonItems.size()]);
}
JsonObject executeFile(String fileName) throws IOException, ServletException {
Map<String, Object> params = new HashMap<>();
- params.put(CommandExecutorImpl.REQ_PARAM_FILE, IOUtils.toString(getClass().getResourceAsStream("/" + fileName
- + ".txt"), "UTF-8"));
+ params.put(
+ CommandExecutorImpl.REQ_PARAM_FILE,
+ IOUtils.toString(getClass().getResourceAsStream("/" + fileName + ".txt"), "UTF-8"));
return testServlet(params);
}
@@ -261,20 +286,32 @@ public class CommandExecutorImplTest extends AbstractPipeTest {
public void testChainedCommand() throws IOException, ServletException {
JsonObject response = executeFile("chainedCommand");
assertEquals(5, response.getJsonNumber("size").intValue());
- assertArrayEquals(new String[]{ "/content/fruits/banana/isnota/pea","/content/fruits/banana/isnota/carrot",
- "/content/fruits/apple/isnota/pea","/content/fruits/apple/isnota/plum",
- "/content/fruits/apple/isnota/carrot"}, getItemsArray(response));
+ assertArrayEquals(
+ new String[] {
+ "/content/fruits/banana/isnota/pea",
+ "/content/fruits/banana/isnota/carrot",
+ "/content/fruits/apple/isnota/pea",
+ "/content/fruits/apple/isnota/plum",
+ "/content/fruits/apple/isnota/carrot"
+ },
+ getItemsArray(response));
}
@Test
public void testFileCommandServlet() throws IOException, ServletException {
JsonObject response = executeFile("testcommand");
assertEquals(5, response.getJsonNumber("size").intValue());
- assertArrayEquals(new String[]{"/content/beatles/john", "/content/beatles/paul", "/content/beatles/georges",
- "/content/beatles/ringo", "/content/beatles/ringo/jcr:content"}, getItemsArray(response));
+ assertArrayEquals(
+ new String[] {
+ "/content/beatles/john",
+ "/content/beatles/paul",
+ "/content/beatles/georges",
+ "/content/beatles/ringo",
+ "/content/beatles/ringo/jcr:content"
+ },
+ getItemsArray(response));
}
-
void assertDeclBinding(String input, String expectedBinding, String expectedContent) {
Matcher matcher = DECL_BINDING_PATTERN.matcher(input);
assertTrue(input + " should match", matcher.matches());
@@ -291,23 +328,29 @@ public class CommandExecutorImplTest extends AbstractPipeTest {
assertDeclBinding("binding csvStart =", "csvStart", "");
}
-
void assertSpaceSeparatedTokens(String input, String... tokens) {
- assertArrayEquals(tokens, commands.getSpaceSeparatedTokens(input).toArray());
+ assertArrayEquals(tokens, commands.getSpaceSeparatedTokens(input).toArray());
}
+
@Test
public void getSpaceSeparatedToken() {
- assertSpaceSeparatedTokens("rm","rm");
+ assertSpaceSeparatedTokens("rm", "rm");
assertSpaceSeparatedTokens("write foo=bar a=b", "write", "foo=bar", "a=b");
assertSpaceSeparatedTokens("check \"foo bar\"", "check", "foo bar");
- assertSpaceSeparatedTokens("write prop=\"foo bar\"","write", "prop=\"foo bar\"");
+ assertSpaceSeparatedTokens("write prop=\"foo bar\"", "write", "prop=\"foo bar\"");
}
@Test
public void testDeclaredBindingBasedInit() throws ServletException, IOException {
JsonObject response = executeFile("declbasedinit");
assertEquals(4, response.getJsonNumber("size").intValue());
- assertArrayEquals(new String[]{"/content/pages/1/leaves/child1","/content/pages/1/leaves/child2",
- "/content/pages/2/leaves/child1","/content/pages/2/leaves/child2"}, getItemsArray(response));
+ assertArrayEquals(
+ new String[] {
+ "/content/pages/1/leaves/child1",
+ "/content/pages/1/leaves/child2",
+ "/content/pages/2/leaves/child1",
+ "/content/pages/2/leaves/child2"
+ },
+ getItemsArray(response));
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/sling/pipes/internal/FilterPipeTest.java b/src/test/java/org/apache/sling/pipes/internal/FilterPipeTest.java
index 2151241..1bba2a2 100644
--- a/src/test/java/org/apache/sling/pipes/internal/FilterPipeTest.java
+++ b/src/test/java/org/apache/sling/pipes/internal/FilterPipeTest.java
@@ -1,21 +1,27 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes.internal;
+import java.lang.reflect.InvocationTargetException;
+import java.util.Collection;
+import java.util.Iterator;
+
import org.apache.commons.lang3.StringUtils;
import org.apache.sling.api.resource.ModifiableValueMap;
import org.apache.sling.api.resource.PersistenceException;
@@ -26,10 +32,6 @@ import org.apache.sling.pipes.ExecutionResult;
import org.apache.sling.pipes.Pipe;
import org.junit.Test;
-import java.lang.reflect.InvocationTargetException;
-import java.util.Collection;
-import java.util.Iterator;
-
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@@ -50,7 +52,7 @@ public class FilterPipeTest extends AbstractPipeTest {
}
@Test
- public void testFilterProperties(){
+ public void testFilterProperties() {
Iterator<Resource> resourceIterator = getOutput(PATH_PIPE + "/" + NN_PROPERTIES);
assertTrue("output has one resource...", resourceIterator.hasNext());
ValueMap properties = resourceIterator.next().adaptTo(ValueMap.class);
@@ -60,7 +62,7 @@ public class FilterPipeTest extends AbstractPipeTest {
}
@Test
- public void testNoChildrenPasses(){
+ public void testNoChildrenPasses() {
Iterator<Resource> resourceIterator = getOutput(PATH_PIPE + "/" + NN_NOCHILDREN);
assertTrue("output has one resource...", resourceIterator.hasNext());
resourceIterator.next().adaptTo(ValueMap.class);
@@ -68,24 +70,30 @@ public class FilterPipeTest extends AbstractPipeTest {
}
@Test
- public void testNoChildrenFails(){
- assertFalse("output has no resource...", getOutput(PATH_PIPE + "/" + NN_NOCHILDREN_FAILS).hasNext());
+ public void testNoChildrenFails() {
+ assertFalse(
+ "output has no resource...",
+ getOutput(PATH_PIPE + "/" + NN_NOCHILDREN_FAILS).hasNext());
}
@Test
public void testTestPasses() {
- assertTrue("output has one resource...", getOutput(PATH_PIPE + "/" + NN_TEST).hasNext());
+ assertTrue(
+ "output has one resource...",
+ getOutput(PATH_PIPE + "/" + NN_TEST).hasNext());
}
@Test
public void testTestFails() {
- assertFalse("output has no resource...", getOutput(PATH_PIPE + "/" + NN_TEST_FAILS).hasNext());
+ assertFalse(
+ "output has no resource...",
+ getOutput(PATH_PIPE + "/" + NN_TEST_FAILS).hasNext());
}
@Test
public void testTestPassesWithNot() throws PersistenceException {
Resource resource = context.resourceResolver().getResource(PATH_PIPE + "/" + NN_TEST_FAILS);
- //we modify the pipe with the value NOT
+ // we modify the pipe with the value NOT
resource.adaptTo(ModifiableValueMap.class).put(FilterPipe.PN_NOT, true);
context.resourceResolver().commit();
@@ -97,7 +105,7 @@ public class FilterPipeTest extends AbstractPipeTest {
@Test
public void testTestFailsWithNot() throws PersistenceException {
Resource resource = context.resourceResolver().getResource(PATH_PIPE + "/" + NN_TEST);
- //we modify the pipe with the value NOT
+ // we modify the pipe with the value NOT
resource.adaptTo(ModifiableValueMap.class).put(FilterPipe.PN_NOT, true);
context.resourceResolver().commit();
Pipe pipe = plumber.getPipe(resource);
@@ -107,7 +115,8 @@ public class FilterPipeTest extends AbstractPipeTest {
@Test
public void testMultiplePattern() throws InvocationTargetException, IllegalAccessException {
- ExecutionResult result = execute("echo /content/fruits/apple/isnota | children nt:unstructured | grep sling:resourceType='.+' @ with slingPipesFilter_not=true");
+ ExecutionResult result = execute(
+ "echo /content/fruits/apple/isnota | children nt:unstructured | grep sling:resourceType='.+' @ with slingPipesFilter_not=true");
assertTrue("there should be some results", result.size() > 0);
}
@@ -120,21 +129,26 @@ public class FilterPipeTest extends AbstractPipeTest {
@Test
public void testPropertyRegexp() throws Exception {
Collection<String> outputs = plumber.newPipe(context.resourceResolver())
- .echo(PATH_APPLE)
- .grep("jcr:description",".*https://en.wikipedia.org.*").run().getCurrentPathSet();
+ .echo(PATH_APPLE)
+ .grep("jcr:description", ".*https://en.wikipedia.org.*")
+ .run()
+ .getCurrentPathSet();
assertEquals("there should be an item", 1, outputs.size());
outputs = plumber.newPipe(context.resourceResolver())
.echo(PATH_APPLE)
- .grep("jcr:description",".*https://en.wikipedia.org.*").run().getCurrentPathSet();
+ .grep("jcr:description", ".*https://en.wikipedia.org.*")
+ .run()
+ .getCurrentPathSet();
assertEquals("there should be an item", 1, outputs.size());
}
@Test
public void testChildrenCount() throws Exception {
Collection<String> outputs = plumber.newPipe(context.resourceResolver())
- .echo(PATH_APPLE)
- .grep("slingPipesFilter_injectChildrenCount","${true}","slingPipesFilter_test","${childrenCount==1}")
- .run().getCurrentPathSet();
+ .echo(PATH_APPLE)
+ .grep("slingPipesFilter_injectChildrenCount", "${true}", "slingPipesFilter_test", "${childrenCount==1}")
+ .run()
+ .getCurrentPathSet();
assertEquals("there should be one output", 1, outputs.size());
}
}
diff --git a/src/test/java/org/apache/sling/pipes/internal/JCRWritePipeTest.java b/src/test/java/org/apache/sling/pipes/internal/JCRWritePipeTest.java
index 7fa1b42..8962651 100644
--- a/src/test/java/org/apache/sling/pipes/internal/JCRWritePipeTest.java
+++ b/src/test/java/org/apache/sling/pipes/internal/JCRWritePipeTest.java
@@ -1,48 +1,52 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.pipes.internal;
-import static org.apache.sling.testing.mock.caconfig.ContextPlugins.CACONFIG;
-import static org.junit.Assert.assertEquals;
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.nodetype.NodeType;
import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
import java.util.Collection;
import java.util.stream.Collectors;
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-import javax.jcr.nodetype.NodeType;
-
+import org.apache.commons.collections4.CollectionUtils;
import org.apache.sling.api.resource.PersistenceException;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.pipes.AbstractPipeTest;
import org.apache.sling.testing.mock.sling.ResourceResolverType;
import org.apache.sling.testing.mock.sling.junit.SlingContext;
import org.apache.sling.testing.mock.sling.junit.SlingContextBuilder;
-import org.apache.commons.collections4.CollectionUtils;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
+import static org.apache.sling.testing.mock.caconfig.ContextPlugins.CACONFIG;
+import static org.junit.Assert.assertEquals;
+
public class JCRWritePipeTest extends AbstractPipeTest {
@Rule
- public SlingContext jcrContext = new SlingContextBuilder(ResourceResolverType.JCR_OAK).plugin(CACONFIG).build();
+ public SlingContext jcrContext = new SlingContextBuilder(ResourceResolverType.JCR_OAK)
+ .plugin(CACONFIG)
+ .build();
@Before
public void setup() throws PersistenceException {
@@ -54,10 +58,9 @@ public class JCRWritePipeTest extends AbstractPipeTest {
String[] m = mixins != null ? mixins : new String[0];
Resource resource = context.resourceResolver().getResource(path);
Node node = resource.adaptTo(Node.class);
- Collection<String> intersection = CollectionUtils.intersection(Arrays.asList(m),
- Arrays.stream(node.getMixinNodeTypes())
- .map(NodeType::getName)
- .collect(Collectors.toList()));
... 2934 lines suppressed ...