some minor adjustments
- few sonar lint fixes,
- removal of unnecessary protected modifiers
diff --git a/src/main/java/org/apache/sling/pipes/PipeExecutor.java b/src/main/java/org/apache/sling/pipes/PipeExecutor.java
index 105b3b6..7668442 100644
--- a/src/main/java/org/apache/sling/pipes/PipeExecutor.java
+++ b/src/main/java/org/apache/sling/pipes/PipeExecutor.java
@@ -27,5 +27,5 @@
String command();
String resourceType();
String description();
- Class pipeClass();
+ 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 b3be41e..63ef638 100644
--- a/src/main/java/org/apache/sling/pipes/Plumber.java
+++ b/src/main/java/org/apache/sling/pipes/Plumber.java
@@ -16,17 +16,13 @@
*/
package org.apache.sling.pipes;
-import org.apache.commons.lang3.StringUtils;
import org.apache.sling.api.SlingHttpServletRequest;
-import org.apache.sling.api.request.RequestParameter;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.event.jobs.Job;
-import org.apache.sling.pipes.internal.JsonUtil;
import org.osgi.annotation.versioning.ProviderType;
import java.io.IOException;
-import java.util.HashMap;
import java.util.Map;
/**
@@ -35,8 +31,6 @@
@ProviderType
public interface Plumber {
- String RESOURCE_TYPE = "slingPipes/plumber";
-
/**
* Instantiate a pipe from the given resource and returns it
*
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 e2132c9..6c2b530 100644
--- a/src/main/java/org/apache/sling/pipes/internal/ACLPipe.java
+++ b/src/main/java/org/apache/sling/pipes/internal/ACLPipe.java
@@ -136,7 +136,7 @@
* @param resource current resource
*/
- protected void bindACLs(Resource resource) {
+ void bindACLs(Resource resource) {
try {
Authorizable auth = checkIsAuthorizableResource(resource);
if ( null != auth ) {
@@ -177,7 +177,7 @@
* @throws RepositoryException in case something goes wrong while executing xpath query
*/
- protected void bindAclsForAuthorizableResource(Authorizable auth) throws RepositoryException {
+ void bindAclsForAuthorizableResource(Authorizable auth) throws RepositoryException {
//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() + "']";
@@ -207,7 +207,7 @@
outputBinding = JsonUtil.toString(authPermisions);
}
- protected Authorizable checkIsAuthorizableResource(Resource resource) {
+ Authorizable checkIsAuthorizableResource(Resource resource) {
return resource.adaptTo(Authorizable.class);
}
@@ -217,7 +217,7 @@
* @return Principal for the principalName
*/
- protected Principal getPrincipalFor(String prinicipalName) {
+ Principal getPrincipalFor(String prinicipalName) {
Principal principal = null;
try {
if (StringUtils.isNotBlank(prinicipalName)) {
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 db11401..9fde30a 100644
--- a/src/main/java/org/apache/sling/pipes/internal/AuthorizablePipe.java
+++ b/src/main/java/org/apache/sling/pipes/internal/AuthorizablePipe.java
@@ -115,7 +115,7 @@
* @return corresponding authorizable
* @throws RepositoryException can happen with any JCR operation
*/
- protected Authorizable getAuthorizable() throws RepositoryException {
+ Authorizable getAuthorizable() throws RepositoryException {
Authorizable auth = null;
String authId = getExpr();
if (StringUtils.isNotBlank(authId)) {
@@ -140,7 +140,7 @@
* Add current authorizable to configured addToGroup expression (should resolve as a group id)
* @param auth authorizable to add to the group
*/
- protected void addToGroup(Authorizable auth){
+ void addToGroup(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
@@ -161,7 +161,7 @@
* Add to current authorizable (that should be a group) the configured members in addMembers expression
* @param auth group to which members should be added
*/
- protected void addMembers(Authorizable auth) {
+ void addMembers(Authorizable auth) {
try {
if (auth.isGroup()) {
Group group = (Group)auth;
@@ -191,7 +191,7 @@
* add current group's members to the bindings
* @param auth group whose members should be bound in the pipe bindings
*/
- protected void bindMembers(Authorizable auth){
+ void bindMembers(Authorizable auth){
try {
if (auth.isGroup()){
Group group = (Group)auth;
diff --git a/src/main/java/org/apache/sling/pipes/internal/JxltEngine.java b/src/main/java/org/apache/sling/pipes/internal/JxltEngine.java
index 76ca936..a1c5c96 100644
--- a/src/main/java/org/apache/sling/pipes/internal/JxltEngine.java
+++ b/src/main/java/org/apache/sling/pipes/internal/JxltEngine.java
@@ -26,7 +26,6 @@
public class JxltEngine {
-
JexlEngine jexl;
JexlContext jc;
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 fd19b03..9620e1a 100644
--- a/src/main/java/org/apache/sling/pipes/internal/ManifoldPipe.java
+++ b/src/main/java/org/apache/sling/pipes/internal/ManifoldPipe.java
@@ -20,7 +20,6 @@
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.resource.NonExistingResource;
import org.apache.sling.api.resource.Resource;
-import org.apache.sling.pipes.ExecutionResult;
import org.apache.sling.pipes.OutputWriter;
import org.apache.sling.pipes.Pipe;
import org.apache.sling.pipes.PipeBindings;
@@ -32,7 +31,6 @@
import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.concurrent.ArrayBlockingQueue;
-import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
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 fb9308b..1e62713 100644
--- a/src/main/java/org/apache/sling/pipes/internal/MovePipe.java
+++ b/src/main/java/org/apache/sling/pipes/internal/MovePipe.java
@@ -49,7 +49,6 @@
private boolean overwriteTarget;
private boolean orderBefore;
-
public MovePipe(Plumber plumber, Resource resource, PipeBindings upperBindings) {
super(plumber, resource, upperBindings);
overwriteTarget = properties.get(PN_OVERWRITE_TARGET, false);
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 852d629..791731b 100644
--- a/src/main/java/org/apache/sling/pipes/internal/PipeBuilderImpl.java
+++ b/src/main/java/org/apache/sling/pipes/internal/PipeBuilderImpl.java
@@ -80,11 +80,11 @@
ResourceResolver resolver;
/**
- * protected constructor (to only allow internal classes to build it out)
+ * constructor (to only allow internal classes to build it out)
* @param resolver resolver with which the pipe will be built and executed
* @param plumber instance of the plumber
*/
- protected PipeBuilderImpl(ResourceResolver resolver, Plumber plumber){
+ PipeBuilderImpl(ResourceResolver resolver, Plumber plumber){
this.plumber = plumber;
this.resolver = resolver;
}
@@ -108,7 +108,7 @@
* @param expr expression
* @return updated instance of PipeBuilder
*/
- protected PipeBuilder pipeWithExpr(String type, String expr){
+ PipeBuilder pipeWithExpr(String type, String expr){
try {
pipe(type).expr(expr);
} catch (IllegalAccessException e){
@@ -275,7 +275,7 @@
* @return updated instance of PipeBuilder
* @throws IllegalAccessException in case configuration is wrong
*/
- protected PipeBuilder writeToCurrentStep(String name, Object... params) throws IllegalAccessException {
+ PipeBuilder writeToCurrentStep(String name, Object... params) throws IllegalAccessException {
checkArguments(params);
Map<String, Object> props = name != null ? currentStep.confs.get(name) : currentStep.properties;
if (props == null){
@@ -308,7 +308,7 @@
* build a time + random based path under /var/pipes
* @return full path of future Pipe
*/
- protected String buildRandomPipePath() {
+ String buildRandomPipePath() {
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();
@@ -324,7 +324,7 @@
* @return resource created
*/
Resource createResource(ResourceResolver resolver, String path, String type, Map<String, Object> data) throws PersistenceException {
- if (! data.keySet().stream().anyMatch(k -> k.contains(SLASH))) {
+ if (data.keySet().stream().noneMatch(k -> k.contains(SLASH))) {
return ResourceUtil.getOrCreateResource(resolver, path, data, type, false);
}
String returnPath = EMPTY;
@@ -361,7 +361,7 @@
* @return created resource
* @throws PersistenceException in case persistence fails
*/
- protected Resource persistStep(String path, String parentType, Step step) throws PersistenceException {
+ 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){
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 27dcc3a..3736d0f 100644
--- a/src/main/java/org/apache/sling/pipes/internal/PlumberImpl.java
+++ b/src/main/java/org/apache/sling/pipes/internal/PlumberImpl.java
@@ -94,14 +94,14 @@
private final Logger log = LoggerFactory.getLogger(this.getClass());
public static final int DEFAULT_BUFFER_SIZE = 1000;
- protected static final String PN_MONITORED = "monitored";
- protected static final String MONITORED_PIPES_QUERY = String.format("//element(*,nt:base)[@sling:resourceType='%s' and @%s]", ContainerPipe.RESOURCE_TYPE, PN_MONITORED);
+ 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);
- protected static final String MBEAN_NAME_FORMAT = "org.apache.sling.pipes:name=%s";
+ static final String MBEAN_NAME_FORMAT = "org.apache.sling.pipes:name=%s";
- protected static final String PARAM_BINDINGS = "bindings";
+ static final String PARAM_BINDINGS = "bindings";
- protected static final String PARAM_FILE = "pipes_inputFile";
+ static final String PARAM_FILE = "pipes_inputFile";
@ObjectClassDefinition(name="Apache Sling Pipes : Plumber configuration")
public @interface Configuration {
@@ -144,7 +144,7 @@
/**
* Register all pipes declared in pipe builder
*/
- protected void registerPipes(){
+ void registerPipes(){
registerPipe(ContainerPipe.RESOURCE_TYPE, ContainerPipe.class);
registerPipe(ManifoldPipe.RESOURCE_TYPE, ManifoldPipe.class);
for (Method method : PipeBuilder.class.getDeclaredMethods()){
@@ -191,7 +191,7 @@
}
@Reference(policy= ReferencePolicy.DYNAMIC, cardinality= ReferenceCardinality.OPTIONAL)
- protected volatile Distributor distributor = null;
+ volatile Distributor distributor = null;
@Reference
JobManager jobManager;
@@ -357,7 +357,7 @@
* @param pipe current pipe
* @param result current result
*/
- protected void checkError(Pipe pipe, ExecutionResult result){
+ void checkError(Pipe pipe, ExecutionResult result){
String error = pipe.getBindings().popCurrentError();
if (StringUtils.isNotBlank(error)){
result.addError(error);
@@ -379,7 +379,7 @@
* @param currentResource if running, null if ended
* @throws PersistenceException in case save fails
*/
- protected 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());
@@ -417,7 +417,7 @@
* @param status status to write
* @throws RepositoryException in case write goes wrong
*/
- protected void writeStatus(Pipe pipe, String status){
+ void writeStatus(Pipe pipe, String status){
if (StringUtils.isNotBlank(status)){
ModifiableValueMap vm = pipe.getResource().adaptTo(ModifiableValueMap.class);
if( vm != null) {
@@ -484,7 +484,7 @@
}
}
- protected Collection<PipeMonitor> getMonitoredPipes() {
+ Collection<PipeMonitor> getMonitoredPipes() {
Collection<PipeMonitor> beans = new ArrayList<>();
if (serviceUser != null) {
try (ResourceResolver resolver = factory.getServiceResourceResolver(serviceUser)) {
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 4ebbaa6..0bfee1e 100644
--- a/src/main/java/org/apache/sling/pipes/internal/PlumberServlet.java
+++ b/src/main/java/org/apache/sling/pipes/internal/PlumberServlet.java
@@ -16,29 +16,26 @@
*/
package org.apache.sling.pipes.internal;
+import static org.apache.sling.pipes.internal.PlumberServlet.RESOURCE_TYPE;
+
import org.apache.commons.lang3.StringUtils;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
-import org.apache.sling.api.request.RequestParameter;
import org.apache.sling.api.servlets.ServletResolverConstants;
import org.apache.sling.api.servlets.SlingAllMethodsServlet;
import org.apache.sling.event.jobs.Job;
-import org.apache.sling.pipes.AbstractInputStreamPipe;
import org.apache.sling.pipes.BasePipe;
import org.apache.sling.pipes.OutputWriter;
import org.apache.sling.pipes.Plumber;
import org.apache.sling.pipes.internal.slingquery.ChildrenPipe;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import javax.servlet.Servlet;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Arrays;
-import java.util.HashMap;
import java.util.Map;
/**
@@ -47,7 +44,7 @@
*/
@Component(service = {Servlet.class},
property= {
- ServletResolverConstants.SLING_SERVLET_RESOURCE_TYPES + "=" + Plumber.RESOURCE_TYPE,
+ ServletResolverConstants.SLING_SERVLET_RESOURCE_TYPES + "=" + RESOURCE_TYPE,
ServletResolverConstants.SLING_SERVLET_RESOURCE_TYPES + "=" + ContainerPipe.RESOURCE_TYPE,
ServletResolverConstants.SLING_SERVLET_RESOURCE_TYPES + "=" + ManifoldPipe.RESOURCE_TYPE,
ServletResolverConstants.SLING_SERVLET_RESOURCE_TYPES + "=" + AuthorizablePipe.RESOURCE_TYPE,
@@ -59,14 +56,13 @@
ServletResolverConstants.SLING_SERVLET_EXTENSIONS + "=csv"
})
public class PlumberServlet extends SlingAllMethodsServlet {
+ public static final String RESOURCE_TYPE = "slingPipes/plumber";
- Logger log = LoggerFactory.getLogger(this.getClass());
+ static final String PARAM_PATH = "path";
- protected static final String PARAM_PATH = "path";
+ static final String PARAM_BINDINGS = "bindings";
- protected static final String PARAM_BINDINGS = "bindings";
-
- protected static final String PARAM_ASYNC = "async";
+ static final String PARAM_ASYNC = "async";
@Reference
Plumber plumber;
@@ -92,8 +88,8 @@
* @param writeAllowed should we consider this execution is about to modify content
* @throws ServletException in case something is wrong...
*/
- protected void execute(SlingHttpServletRequest request, SlingHttpServletResponse response, boolean writeAllowed) throws ServletException {
- String path = request.getResource().getResourceType().equals(Plumber.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");
diff --git a/src/test/java/org/apache/sling/pipes/ManifoldPipeTest.java b/src/test/java/org/apache/sling/pipes/ManifoldPipeTest.java
index fb36a25..daa69f1 100644
--- a/src/test/java/org/apache/sling/pipes/ManifoldPipeTest.java
+++ b/src/test/java/org/apache/sling/pipes/ManifoldPipeTest.java
@@ -37,8 +37,6 @@
public static final String NN_DEFAULT = "defaultExecutor";
public static final String NN_STRAINED = "strainedExecutor";
-
-
@Before
public void setup() throws PersistenceException {
super.setup();