You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by np...@apache.org on 2018/06/12 10:16:27 UTC
[sling-org-apache-sling-pipes] branch master updated: SLING-7640
add assembly capability
This is an automated email from the ASF dual-hosted git repository.
npeltier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-pipes.git
The following commit(s) were added to refs/heads/master by this push:
new 572ed2d SLING-7640 add assembly capability
572ed2d is described below
commit 572ed2d2ef65feb5b0d0241fd3986c8473693bc2
Author: Nicolas Peltier <pe...@gmail.com>
AuthorDate: Tue Jun 12 12:16:09 2018 +0200
SLING-7640 add assembly capability
- move after hook to after the last commit and log of the pipe execution which is more natural, and work better here,
- add checkExistence flag: a filter is added only if resource exists and this is true (default to true),
- add assemble flag: after hook is called that builds the package if assemble flag is set (default to true)
---
.../apache/sling/pipes/internal/PackagePipe.java | 36 +++++++++++++++++++---
.../apache/sling/pipes/internal/PlumberImpl.java | 4 +--
2 files changed, 33 insertions(+), 7 deletions(-)
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 29aef52..73e46cb 100644
--- a/src/main/java/org/apache/sling/pipes/internal/PackagePipe.java
+++ b/src/main/java/org/apache/sling/pipes/internal/PackagePipe.java
@@ -48,9 +48,18 @@ public class PackagePipe extends BasePipe {
public static final String PN_FILTERCOLLECTIONMODE = "filterCollectionMode";
+ public static final String PN_ASSEMBLE = "assemble";
+
+ public static final String PN_CHECKEXISTENCE = "checkExistence";
+
DefaultWorkspaceFilter filters;
JcrPackage jcrPackage;
+
+ boolean assemble;
+
+ boolean checkExistence;
+
/**
* Pipe Constructor
*
@@ -61,6 +70,8 @@ public class PackagePipe extends BasePipe {
*/
public PackagePipe(Plumber plumber, Resource resource, PipeBindings upperBindings) throws Exception {
super(plumber, resource, upperBindings);
+ assemble = properties.get(PN_ASSEMBLE, true);
+ checkExistence = properties.get(PN_CHECKEXISTENCE, true);
}
@Override
@@ -73,12 +84,18 @@ public class PackagePipe extends BasePipe {
Iterator<Resource> output = EMPTY_ITERATOR;
init();
if (properties.get(PN_FILTERCOLLECTIONMODE, false)){
- if (filters == null){
- filters = new DefaultWorkspaceFilter();
+ Resource filterResource = getInput();
+ if (filterResource != null || !checkExistence){
+ 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
+ String filter = filterResource != null ? filterResource.getPath() : getComputedPath();
+ filters.add(new PathFilterSet(filter));
+ jcrPackage.getDefinition().setFilter(filters, true);
+ output = IteratorUtils.singletonIterator(getInput());
}
- filters.add(new PathFilterSet(getInput().getPath()));
- jcrPackage.getDefinition().setFilter(filters, true);
- output = IteratorUtils.singletonIterator(getInput());
}
return output;
}
@@ -112,4 +129,13 @@ public class PackagePipe extends BasePipe {
}
}
}
+
+ @Override
+ public void after() throws Exception {
+ super.after();
+ if (assemble) {
+ JcrPackageManager mgr = PackagingService.getPackageManager(resolver.adaptTo(Session.class));
+ mgr.assemble(jcrPackage, 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 7d0e286..6f84674 100644
--- a/src/main/java/org/apache/sling/pipes/internal/PlumberImpl.java
+++ b/src/main/java/org/apache/sling/pipes/internal/PlumberImpl.java
@@ -288,8 +288,6 @@ public class PlumberImpl implements Plumber, JobConsumer, PlumberMXBean {
}
}
checkError(pipe, result);
- log.debug("[{}] after execution hook is called", pipe);
- pipe.after();
if (save && pipe.modifiesContent()) {
persist(resolver, pipe, result, null);
}
@@ -304,6 +302,8 @@ public class PlumberImpl implements Plumber, JobConsumer, PlumberMXBean {
writeStatus(pipe, STATUS_FINISHED);
resolver.commit();
log.info("[{}] done executing.", pipe.getName());
+ log.debug("[{}] after execution hook is called", pipe);
+ pipe.after();
if (!success && monitor != null){
monitor.failed();
}
--
To stop receiving notification emails like this one, please contact
npeltier@apache.org.