true if the paths are deep
*/
- public boolean isDeep(@NotNull String path);
+ public boolean isDeep(String path);
@@ -65,6 +65,6 @@ public interface DistributionRequest {
* @param path the path to get applicable filters for
* @return an array of filters
*/
- @NotNull
+ @Nonnull
public String[] getFilters(String path);
}
diff --git a/src/main/java/org/apache/sling/distribution/DistributionRequestState.java b/src/main/java/org/apache/sling/distribution/DistributionRequestState.java
index 4dcf6d6..2e3045e 100644
--- a/src/main/java/org/apache/sling/distribution/DistributionRequestState.java
+++ b/src/main/java/org/apache/sling/distribution/DistributionRequestState.java
@@ -18,7 +18,7 @@
*/
package org.apache.sling.distribution;
-import aQute.bnd.annotation.ProviderType;
+import org.osgi.annotation.versioning.ProviderType;
/**
* diff --git a/src/main/java/org/apache/sling/distribution/DistributionRequestType.java b/src/main/java/org/apache/sling/distribution/DistributionRequestType.java index c534983..d183a57 100644 --- a/src/main/java/org/apache/sling/distribution/DistributionRequestType.java +++ b/src/main/java/org/apache/sling/distribution/DistributionRequestType.java @@ -18,9 +18,9 @@ */ package org.apache.sling.distribution; -import aQute.bnd.annotation.ProviderType; +import javax.annotation.Nullable; -import org.jetbrains.annotations.Nullable; +import org.osgi.annotation.versioning.ProviderType; /** *
@@ -66,7 +66,7 @@ public enum DistributionRequestType { * @return the type or {@code null} */ @Nullable - public static DistributionRequestType fromName(String n) { + public static DistributionRequestType fromName(@Nullable String n) { if (n == null) { return null; } diff --git a/src/main/java/org/apache/sling/distribution/DistributionResponse.java b/src/main/java/org/apache/sling/distribution/DistributionResponse.java index 12f778c..55c936f 100644 --- a/src/main/java/org/apache/sling/distribution/DistributionResponse.java +++ b/src/main/java/org/apache/sling/distribution/DistributionResponse.java @@ -18,10 +18,10 @@ */ package org.apache.sling.distribution; -import aQute.bnd.annotation.ProviderType; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.osgi.annotation.versioning.ProviderType; /** * A {@link org.apache.sling.distribution.DistributionResponse} represents the outcome of a @@ -47,7 +47,7 @@ public interface DistributionResponse { * * @return the state of the associated request */ - @NotNull + @Nonnull DistributionRequestState getState(); /** diff --git a/src/main/java/org/apache/sling/distribution/Distributor.java b/src/main/java/org/apache/sling/distribution/Distributor.java index 8895401..cdaab0e 100644 --- a/src/main/java/org/apache/sling/distribution/Distributor.java +++ b/src/main/java/org/apache/sling/distribution/Distributor.java @@ -19,9 +19,10 @@ package org.apache.sling.distribution; -import aQute.bnd.annotation.ProviderType; +import javax.annotation.Nonnull; + import org.apache.sling.api.resource.ResourceResolver; -import org.jetbrains.annotations.NotNull; +import org.osgi.annotation.versioning.ProviderType; /** *
@@ -49,9 +50,9 @@ public interface Distributor {
* @param resourceResolver the resource resolver used for authorizing the request,
* @return a {@link org.apache.sling.distribution.DistributionResponse}
*/
- @NotNull
- DistributionResponse distribute(@NotNull String agentName, @NotNull ResourceResolver resourceResolver,
- @NotNull DistributionRequest distributionRequest);
+ @Nonnull
+ DistributionResponse distribute(String agentName, ResourceResolver resourceResolver,
+ DistributionRequest distributionRequest);
}
diff --git a/src/main/java/org/apache/sling/distribution/SimpleDistributionRequest.java b/src/main/java/org/apache/sling/distribution/SimpleDistributionRequest.java
index a1645fe..123d27a 100644
--- a/src/main/java/org/apache/sling/distribution/SimpleDistributionRequest.java
+++ b/src/main/java/org/apache/sling/distribution/SimpleDistributionRequest.java
@@ -18,14 +18,15 @@
*/
package org.apache.sling.distribution;
-import aQute.bnd.annotation.ProviderType;
-
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
-import org.jetbrains.annotations.NotNull;
+
+import javax.annotation.Nonnull;
+
+import org.osgi.annotation.versioning.ProviderType;
/**
* A {@link SimpleDistributionRequest} is a {@link DistributionRequest} where all paths are either "deep" or "shallow".
@@ -45,7 +46,7 @@ public final class SimpleDistributionRequest implements DistributionRequest {
* @param isDeep is
diff --git a/src/main/java/org/apache/sling/distribution/transport/DistributionTransportSecretProvider.java b/src/main/java/org/apache/sling/distribution/transport/DistributionTransportSecretProvider.java
index eaac9c9..3a0c933 100644
--- a/src/main/java/org/apache/sling/distribution/transport/DistributionTransportSecretProvider.java
+++ b/src/main/java/org/apache/sling/distribution/transport/DistributionTransportSecretProvider.java
@@ -18,11 +18,11 @@
*/
package org.apache.sling.distribution.transport;
-import aQute.bnd.annotation.ConsumerType;
-
import java.net.URI;
-import org.jetbrains.annotations.Nullable;
+import javax.annotation.Nullable;
+
+import org.osgi.annotation.versioning.ConsumerType;
/**
*
diff --git a/src/main/java/org/apache/sling/distribution/transport/package-info.java b/src/main/java/org/apache/sling/distribution/transport/package-info.java
index 822acfc..32a676f 100644
--- a/src/main/java/org/apache/sling/distribution/transport/package-info.java
+++ b/src/main/java/org/apache/sling/distribution/transport/package-info.java
@@ -17,8 +17,8 @@
* under the License.
*/
-@Version("0.1.1")
+@javax.annotation.ParametersAreNonnullByDefault
+@org.osgi.annotation.versioning.Version("0.1.1")
package org.apache.sling.distribution.transport;
-import aQute.bnd.annotation.Version;
diff --git a/src/test/java/org/apache/sling/distribution/event/DistributionEventTest.java b/src/test/java/org/apache/sling/distribution/event/DistributionEventTest.java
new file mode 100644
index 0000000..ce9a006
--- /dev/null
+++ b/src/test/java/org/apache/sling/distribution/event/DistributionEventTest.java
@@ -0,0 +1,69 @@
+/*
+ * 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
+ *
+ * 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.distribution.event;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.junit.Assert.assertThat;
+
+import java.util.Arrays;
+
+import org.hamcrest.CoreMatchers;
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.service.event.Event;
+
+public class DistributionEventTest {
+
+ private static final String PATH1 = "/test";
+ private static final String DIST_TYPE = "ADD";
+ private static final String NAME = "myagent";
+ private static final String KIND = "agent";
+ private static final String PKG_ID = "pkg-1";
+ private DistributionEvent event;
+
+ @Before
+ public void before() {
+ event = new DistributionEvent(PKG_ID, NAME, KIND, DIST_TYPE, new String[] {PATH1});
+ }
+
+ @Test
+ public void testToEvent() {
+ Event osgiEvent = event.toEvent(DistributionEventTopics.AGENT_PACKAGE_CREATED);
+ assertThat(osgiEvent.getTopic(), equalTo(DistributionEventTopics.AGENT_PACKAGE_CREATED));
+ assertThat((String)osgiEvent.getProperty(DistributionEventProperties.DISTRIBUTION_PACKAGE_ID), equalTo(PKG_ID));
+ assertThat((String)osgiEvent.getProperty(DistributionEventProperties.DISTRIBUTION_COMPONENT_KIND), equalTo(KIND));
+ assertThat((String)osgiEvent.getProperty(DistributionEventProperties.DISTRIBUTION_COMPONENT_NAME), equalTo(NAME));
+ assertThat((String)osgiEvent.getProperty(DistributionEventProperties.DISTRIBUTION_TYPE), equalTo(DIST_TYPE));
+ String[] paths = (String[])(osgiEvent.getProperty(DistributionEventProperties.DISTRIBUTION_PATHS));
+ assertThat(Arrays.asList(paths), CoreMatchers.hasItems(PATH1));
+ }
+
+ @Test
+ public void testFromEvent() {
+ Event osgiEvent = event.toEvent(DistributionEventTopics.AGENT_PACKAGE_CREATED);
+ DistributionEvent event2 = DistributionEvent.fromEvent(osgiEvent);
+ assertThat(event2.getPackageId(), equalTo(PKG_ID));
+ assertThat(event2.getComponentKind(), equalTo(KIND));
+ assertThat(event2.getComponentName(), equalTo(NAME));
+ assertThat(event2.getDistType(), equalTo(DIST_TYPE));
+ String[] paths = event2.getDistPaths();
+ assertThat(Arrays.asList(paths), CoreMatchers.hasItems(PATH1));
+ }
+
+}
true if all paths are "deep" and is false if all paths are "shallow"
* @param paths the array of paths to be distributed
*/
- public SimpleDistributionRequest(@NotNull DistributionRequestType requestType, boolean isDeep, @NotNull String... paths) {
+ public SimpleDistributionRequest(DistributionRequestType requestType, boolean isDeep, String... paths) {
this(requestType, paths, isDeep? new HashSettrue if the path is deep
*/
- public boolean isDeep(@NotNull String path) {
+ public boolean isDeep(String path) {
return deepPaths.contains(path);
}
- @NotNull
+ @Nonnull
public String[] getFilters(String path) {
String[] filters = pathFilters.get(path);
return filters != null ? filters : new String[0];
diff --git a/src/main/java/org/apache/sling/distribution/event/DistributionEvent.java b/src/main/java/org/apache/sling/distribution/event/DistributionEvent.java
new file mode 100644
index 0000000..7512065
--- /dev/null
+++ b/src/main/java/org/apache/sling/distribution/event/DistributionEvent.java
@@ -0,0 +1,91 @@
+/*
+ * 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
+ *
+ * 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.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_PACKAGE_ID;
+import static org.apache.sling.distribution.event.DistributionEventProperties.DISTRIBUTION_PATHS;
+import static org.apache.sling.distribution.event.DistributionEventProperties.DISTRIBUTION_TYPE;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+
+import org.osgi.service.event.Event;
+
+public class DistributionEvent {
+
+ private final String packageId;
+ private final String componentName;
+ private final String componentKind;
+ private final String distType;
+ private final String[] distPaths;
+
+ public DistributionEvent(
+ String packageId,
+ String componentName,
+ String componentKind,
+ String distType,
+ String[] distPaths) {
+ this.packageId = packageId;
+ this.componentName = componentName;
+ this.componentKind = componentKind;
+ this.distType = distType;
+ this.distPaths = distPaths;
+ }
+
+ public String getPackageId() {
+ return packageId;
+ }
+
+ public String getComponentName() {
+ return componentName;
+ }
+
+ public String getComponentKind() {
+ return componentKind;
+ }
+
+ public String getDistType() {
+ return distType;
+ }
+
+ public String[] getDistPaths() {
+ return distPaths;
+ }
+
+ public Event toEvent(String topic) {
+ Dictionary