You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/11/07 09:29:39 UTC
[sling-org-apache-sling-distribution-api] 05/07: SLING-5367: allow
distribution request filters
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.distribution.api-0.3.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-distribution-api.git
commit d0b3cec8f85be6f565579ab76070abb744bc0836
Author: Marius Petria <mp...@apache.org>
AuthorDate: Wed Dec 9 15:47:02 2015 +0000
SLING-5367: allow distribution request filters
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/distribution/api@1718890 13f79535-47bb-0310-9956-ffa450edef68
---
.../sling/distribution/DistributionRequest.java | 20 +++++++++++++----
.../distribution/SimpleDistributionRequest.java | 25 ++++++++++++++++++++--
2 files changed, 39 insertions(+), 6 deletions(-)
diff --git a/src/main/java/org/apache/sling/distribution/DistributionRequest.java b/src/main/java/org/apache/sling/distribution/DistributionRequest.java
index 72edf92..1da5fd1 100644
--- a/src/main/java/org/apache/sling/distribution/DistributionRequest.java
+++ b/src/main/java/org/apache/sling/distribution/DistributionRequest.java
@@ -23,6 +23,7 @@ import aQute.bnd.annotation.ProviderType;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import java.util.Arrays;
+import java.util.Set;
/**
* A {@link org.apache.sling.distribution.DistributionRequest} represents the need from the caller to have
@@ -33,7 +34,7 @@ public interface DistributionRequest {
/**
- * get the {@link DistributionRequestType} associated with this request
+ * Get the {@link DistributionRequestType} associated with this request
*
* @return the type of the request as a {@link DistributionRequestType}
*/
@@ -41,14 +42,13 @@ public interface DistributionRequest {
public DistributionRequestType getRequestType();
/**
- * get the paths for this distribution request
+ * Get the root paths for this distribution request
*
* @return an array of paths
*/
- @CheckForNull
+ @Nonnull
public String[] getPaths();
-
/**
* Returns whether the paths are covering the entire subtree (deep) or just the specified nodes (shallow)
*
@@ -58,4 +58,16 @@ public interface DistributionRequest {
public boolean isDeep(@Nonnull String path);
+
+ /**
+ * Get the filters applicable for a specific path
+ * +/foo/.* - include all content under /foo
+ * -/foo - exclude /foo node
+ *
+ * filters are checked in order and the last matched filter determines inclusion/exclusion
+ *
+ * @return an array of filters
+ */
+ @Nonnull
+ public String[] getFilters(String path);
}
diff --git a/src/main/java/org/apache/sling/distribution/SimpleDistributionRequest.java b/src/main/java/org/apache/sling/distribution/SimpleDistributionRequest.java
index e2a98d2..c5cce14 100644
--- a/src/main/java/org/apache/sling/distribution/SimpleDistributionRequest.java
+++ b/src/main/java/org/apache/sling/distribution/SimpleDistributionRequest.java
@@ -22,7 +22,9 @@ import aQute.bnd.annotation.ProviderType;
import javax.annotation.Nonnull;
import java.util.Arrays;
+import java.util.HashMap;
import java.util.HashSet;
+import java.util.Map;
import java.util.Set;
/**
@@ -34,6 +36,7 @@ public final class SimpleDistributionRequest implements DistributionRequest {
private final DistributionRequestType requestType;
private final Set<String> deepPaths;
+ private final Map<String, String[]> pathFilters;
private final String[] paths;
/**
@@ -57,15 +60,28 @@ public final class SimpleDistributionRequest implements DistributionRequest {
/**
- * Creates a distribution request with "shallow" paths.
+ * Creates a distribution request with additional "deep" paths.
* @param requestType the request type
* @param paths the array of paths to be distributed
* @param deepPaths the set of paths that are to be distributed in depth (with all their children)
*/
public SimpleDistributionRequest(@Nonnull DistributionRequestType requestType, @Nonnull String[] paths, @Nonnull Set<String> deepPaths) {
+ this(requestType, paths, deepPaths, new HashMap<String, String[]>());
+ }
+
+
+ /**
+ * Creates a distribution request with "deep" paths and filters.
+ * @param requestType the request type
+ * @param paths the array of paths to be distributed
+ * @param deepPaths the set of paths that are to be distributed in depth (with all their children)
+ * @param pathFilters the filters applicable for each path
+ */
+ public SimpleDistributionRequest(@Nonnull DistributionRequestType requestType, @Nonnull String[] paths, @Nonnull Set<String> deepPaths, @Nonnull Map<String, String[]> pathFilters) {
this.requestType = requestType;
this.paths = paths;
this.deepPaths = deepPaths;
+ this.pathFilters = pathFilters;
}
/**
@@ -96,12 +112,17 @@ public final class SimpleDistributionRequest implements DistributionRequest {
return deepPaths.contains(path);
}
+ @Nonnull
+ public String[] getFilters(String path) {
+ String[] filters = pathFilters.get(path);
+ return filters != null ? filters : new String[0];
+ }
+
@Override
public String toString() {
return "SimpleDistributionRequest{" +
"requestType=" + requestType +
", paths=" + Arrays.toString(paths) +
- ", deep=" + Arrays.toString(deepPaths.toArray(new String[0])) +
'}';
}
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.