You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cs...@apache.org on 2021/05/19 14:10:44 UTC

[sling-org-apache-sling-distribution-api] branch master updated: SLING-9492 - Add deep paths

This is an automated email from the ASF dual-hosted git repository.

cschneider pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-distribution-api.git


The following commit(s) were added to refs/heads/master by this push:
     new a57e692  SLING-9492 - Add deep paths
a57e692 is described below

commit a57e692e80a1f39f1950b80261e079de302dcbcb
Author: Christian Schneider <cs...@adobe.com>
AuthorDate: Wed May 19 16:10:18 2021 +0200

    SLING-9492 - Add deep paths
---
 .../apache/sling/distribution/event/DistributionEvent.java | 14 ++++++++++++--
 .../distribution/event/DistributionEventProperties.java    |  5 +++++
 .../sling/distribution/event/DistributionEventTest.java    |  7 +++++--
 3 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/src/main/java/org/apache/sling/distribution/event/DistributionEvent.java b/src/main/java/org/apache/sling/distribution/event/DistributionEvent.java
index 7512065..068a2b3 100644
--- a/src/main/java/org/apache/sling/distribution/event/DistributionEvent.java
+++ b/src/main/java/org/apache/sling/distribution/event/DistributionEvent.java
@@ -20,6 +20,7 @@ package org.apache.sling.distribution.event;
 
 import static org.apache.sling.distribution.event.DistributionEventProperties.DISTRIBUTION_COMPONENT_KIND;
 import static org.apache.sling.distribution.event.DistributionEventProperties.DISTRIBUTION_COMPONENT_NAME;
+import static org.apache.sling.distribution.event.DistributionEventProperties.DISTRIBUTION_DEEP_PATHS;
 import static org.apache.sling.distribution.event.DistributionEventProperties.DISTRIBUTION_PACKAGE_ID;
 import static org.apache.sling.distribution.event.DistributionEventProperties.DISTRIBUTION_PATHS;
 import static org.apache.sling.distribution.event.DistributionEventProperties.DISTRIBUTION_TYPE;
@@ -36,18 +37,21 @@ public class DistributionEvent {
     private final String componentKind;
     private final String distType;
     private final String[] distPaths;
+    private final String[] distDeepPaths;
 
     public DistributionEvent(
             String packageId,
             String componentName,
             String componentKind,
             String distType,
-            String[] distPaths) {
+            String[] distPaths,
+            String[] distDeepPaths) {
         this.packageId = packageId;
         this.componentName = componentName;
         this.componentKind = componentKind;
         this.distType = distType;
         this.distPaths = distPaths;
+        this.distDeepPaths = distDeepPaths == null ? new String[] {} : distDeepPaths;
     }
 
     public String getPackageId() {
@@ -70,6 +74,10 @@ public class DistributionEvent {
         return distPaths;
     }
 
+    public String[] getDistDeepPaths() {
+        return distDeepPaths;
+    }
+
     public Event toEvent(String topic) {
         Dictionary<String, Object> props = new Hashtable<String, Object>();
         props.put(DISTRIBUTION_PACKAGE_ID, packageId);
@@ -77,6 +85,7 @@ public class DistributionEvent {
         props.put(DISTRIBUTION_COMPONENT_KIND, componentKind);
         props.put(DISTRIBUTION_TYPE, distType);
         props.put(DISTRIBUTION_PATHS, distPaths);
+        props.put(DISTRIBUTION_DEEP_PATHS, distDeepPaths);
         return new Event(topic, props);
     }
 
@@ -86,6 +95,7 @@ public class DistributionEvent {
                 event.getProperty(DISTRIBUTION_COMPONENT_NAME).toString(),
                 event.getProperty(DISTRIBUTION_COMPONENT_KIND).toString(),
                 event.getProperty(DISTRIBUTION_TYPE).toString(),
-                (String[])event.getProperty(DISTRIBUTION_PATHS));
+                (String[])event.getProperty(DISTRIBUTION_PATHS),
+                (String[])event.getProperty(DISTRIBUTION_DEEP_PATHS));
     }
 }
diff --git a/src/main/java/org/apache/sling/distribution/event/DistributionEventProperties.java b/src/main/java/org/apache/sling/distribution/event/DistributionEventProperties.java
index dd5da1e..3a13b55 100644
--- a/src/main/java/org/apache/sling/distribution/event/DistributionEventProperties.java
+++ b/src/main/java/org/apache/sling/distribution/event/DistributionEventProperties.java
@@ -48,6 +48,11 @@ public interface DistributionEventProperties {
     String DISTRIBUTION_PATHS= "distribution.paths";
     
     /**
+     * property containing the type of the distribution paths
+     */
+    String DISTRIBUTION_DEEP_PATHS= "distribution.deep.paths";
+    
+    /**
      * Package id
      */
     String DISTRIBUTION_PACKAGE_ID = "distribution.package.id";
diff --git a/src/test/java/org/apache/sling/distribution/event/DistributionEventTest.java b/src/test/java/org/apache/sling/distribution/event/DistributionEventTest.java
index ce9a006..c51e14e 100644
--- a/src/test/java/org/apache/sling/distribution/event/DistributionEventTest.java
+++ b/src/test/java/org/apache/sling/distribution/event/DistributionEventTest.java
@@ -31,6 +31,7 @@ import org.osgi.service.event.Event;
 public class DistributionEventTest {
 
     private static final String PATH1 = "/test";
+    private static final String DEEP_PATH = "/deep";
     private static final String DIST_TYPE = "ADD";
     private static final String NAME = "myagent";
     private static final String KIND = "agent";
@@ -39,7 +40,7 @@ public class DistributionEventTest {
 
     @Before
     public void before() {
-        event = new DistributionEvent(PKG_ID, NAME, KIND, DIST_TYPE, new String[] {PATH1});
+        event = new DistributionEvent(PKG_ID, NAME, KIND, DIST_TYPE, new String[] {PATH1, DEEP_PATH}, new String[] {DEEP_PATH});
     }
 
     @Test
@@ -63,7 +64,9 @@ public class DistributionEventTest {
         assertThat(event2.getComponentName(), equalTo(NAME));
         assertThat(event2.getDistType(), equalTo(DIST_TYPE));
         String[] paths = event2.getDistPaths();
-        assertThat(Arrays.asList(paths), CoreMatchers.hasItems(PATH1));
+        assertThat(Arrays.asList(paths), CoreMatchers.hasItems(PATH1, DEEP_PATH));
+        String[] deepPaths = event2.getDistDeepPaths();
+        assertThat(Arrays.asList(deepPaths), CoreMatchers.hasItems(DEEP_PATH));
     }
 
 }