SLING-4153 - moved paths and request type into package's packageinfo
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1640955 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/main/java/org/apache/sling/distribution/agent/DistributionAgent.java b/src/main/java/org/apache/sling/distribution/agent/DistributionAgent.java
index 15a0d6b..b3f19e3 100644
--- a/src/main/java/org/apache/sling/distribution/agent/DistributionAgent.java
+++ b/src/main/java/org/apache/sling/distribution/agent/DistributionAgent.java
@@ -31,7 +31,7 @@
/**
* A distribution agent is responsible for handling {@link org.apache.sling.distribution.communication.DistributionRequest}s.
* <p/>
- * This means executing actions of e.g.: a specific {@link org.apache.sling.distribution.communication.DistributionActionType}s on
+ * This means executing actions of e.g.: a specific {@link org.apache.sling.distribution.communication.DistributionRequestType}s on
* specific path(s) which will resume pulling resources from a certain Sling instance and / or pushing resources to
* other instances.
*/
diff --git a/src/main/java/org/apache/sling/distribution/communication/DistributionRequest.java b/src/main/java/org/apache/sling/distribution/communication/DistributionRequest.java
index 14c2dc9..05811f8 100644
--- a/src/main/java/org/apache/sling/distribution/communication/DistributionRequest.java
+++ b/src/main/java/org/apache/sling/distribution/communication/DistributionRequest.java
@@ -29,11 +29,11 @@
private final long time;
- private final DistributionActionType actionType;
+ private final DistributionRequestType actionType;
private final String[] paths;
- public DistributionRequest(@Nonnull DistributionActionType actionType, @Nonnull String... paths) {
+ public DistributionRequest(@Nonnull DistributionRequestType actionType, @Nonnull String... paths) {
this.time = System.currentTimeMillis();
this.actionType = actionType;
this.paths = paths;
@@ -49,11 +49,11 @@
}
/**
- * get the {@link DistributionActionType} associated with this request
+ * get the {@link DistributionRequestType} associated with this request
*
- * @return the type of actionType for request as a {@link DistributionActionType}
+ * @return the type of actionType for request as a {@link DistributionRequestType}
*/
- public DistributionActionType getActionType() {
+ public DistributionRequestType getRequestType() {
return actionType;
}
diff --git a/src/main/java/org/apache/sling/distribution/communication/DistributionActionType.java b/src/main/java/org/apache/sling/distribution/communication/DistributionRequestType.java
similarity index 87%
rename from src/main/java/org/apache/sling/distribution/communication/DistributionActionType.java
rename to src/main/java/org/apache/sling/distribution/communication/DistributionRequestType.java
index ddf02be..360b415 100644
--- a/src/main/java/org/apache/sling/distribution/communication/DistributionActionType.java
+++ b/src/main/java/org/apache/sling/distribution/communication/DistributionRequestType.java
@@ -21,7 +21,7 @@
import javax.annotation.CheckForNull;
/**
- * The action type tied to a specific {@link org.apache.sling.distribution.communication.DistributionRequest}, used to decide how
+ * The request type tied to a specific {@link org.apache.sling.distribution.communication.DistributionRequest}, used to decide how
* the distribution content should be aggregated.
* <p/>
* {@code ADD} requests can for example lead to the creation of a package of resources to be persisted on the target instance.
@@ -30,7 +30,7 @@
* {@code PULL} requests can for example lead to the creation of a "command package" that will trigger fetching of content
* from the target instance.
*/
-public enum DistributionActionType {
+public enum DistributionRequestType {
/**
* Action type for adding content
@@ -55,12 +55,12 @@
* @return the type or {@code null}
*/
@CheckForNull
- public static DistributionActionType fromName(String n) {
+ public static DistributionRequestType fromName(String n) {
if (n == null) {
return null;
}
try {
- return DistributionActionType.valueOf(n.toUpperCase());
+ return DistributionRequestType.valueOf(n.toUpperCase());
} catch (IllegalArgumentException e) {
return null;
}
diff --git a/src/main/java/org/apache/sling/distribution/packaging/DistributionPackage.java b/src/main/java/org/apache/sling/distribution/packaging/DistributionPackage.java
index 620723c..9aca4e8 100644
--- a/src/main/java/org/apache/sling/distribution/packaging/DistributionPackage.java
+++ b/src/main/java/org/apache/sling/distribution/packaging/DistributionPackage.java
@@ -40,22 +40,6 @@
String getId();
/**
- * get the paths covered by this package
- *
- * @return an array of paths
- */
- @Nonnull
- String[] getPaths();
-
- /**
- * get the action this package is used for
- *
- * @return the action
- */
- @Nonnull
- String getActionType();
-
- /**
* get the type of package
*
* @return the package type
@@ -74,13 +58,6 @@
InputStream createInputStream() throws IOException;
/**
- * get package stream length
- *
- * @return the package length
- */
- long getLength();
-
- /**
* releases all resources associated with this package
*/
void delete();
diff --git a/src/main/java/org/apache/sling/distribution/packaging/DistributionPackageInfo.java b/src/main/java/org/apache/sling/distribution/packaging/DistributionPackageInfo.java
index 300c245..31d62ea 100644
--- a/src/main/java/org/apache/sling/distribution/packaging/DistributionPackageInfo.java
+++ b/src/main/java/org/apache/sling/distribution/packaging/DistributionPackageInfo.java
@@ -16,12 +16,13 @@
* specific language governing permissions and limitations
* under the License.
*/
-
package org.apache.sling.distribution.packaging;
import javax.annotation.CheckForNull;
import java.net.URI;
+import org.apache.sling.distribution.communication.DistributionRequestType;
+
/**
* Additional information about a package.
* Additional information is optional and components should expect every piece of it to be null.
@@ -29,9 +30,32 @@
public final class DistributionPackageInfo {
private URI origin;
+ private DistributionRequestType requestType;
+ private String[] paths;
/**
- * retrieves the origin of the package.
+ * get the paths covered by the package holding this info
+ *
+ * @return an array of paths
+ */
+ @CheckForNull
+ public String[] getPaths() {
+ return paths;
+ }
+
+ /**
+ * get the request type associated to the package holding this info
+ *
+ * @return the request type
+ */
+ @CheckForNull
+ public DistributionRequestType getRequestType() {
+ return requestType;
+ }
+
+ /**
+ * retrieves the origin of the package holding this info
+ *
* @return the package origin
*/
@CheckForNull
@@ -41,6 +65,7 @@
/**
* sets the origin of the package.
+ *
* @param origin the originating instance of this package
*/
public void setOrigin(URI origin) {
@@ -48,12 +73,33 @@
}
/**
+ * sets the request type for the package holding this info
+ *
+ * @param requestType the request type that originated this package
+ */
+ public void setRequestType(DistributionRequestType requestType) {
+ this.requestType = requestType;
+ }
+
+ /**
+ * sets the paths "covered" by the package holding this info
+ *
+ * @param paths the paths "covered" by this package
+ */
+ public void setPaths(String[] paths) {
+ this.paths = paths;
+ }
+
+ /**
* fills the current info object from the provided one.
+ *
* @param packageInfo package metadata
*/
public void fillInfo(DistributionPackageInfo packageInfo) {
if (packageInfo != null) {
this.setOrigin(packageInfo.getOrigin());
+ this.setPaths(packageInfo.getPaths());
+ this.setRequestType(packageInfo.getRequestType());
}
}
}
diff --git a/src/main/java/org/apache/sling/distribution/queue/DistributionQueueItem.java b/src/main/java/org/apache/sling/distribution/queue/DistributionQueueItem.java
index 42f570f..f9cacf3 100644
--- a/src/main/java/org/apache/sling/distribution/queue/DistributionQueueItem.java
+++ b/src/main/java/org/apache/sling/distribution/queue/DistributionQueueItem.java
@@ -18,6 +18,8 @@
*/
package org.apache.sling.distribution.queue;
+import javax.annotation.Nonnull;
+
import org.apache.sling.distribution.packaging.DistributionPackageInfo;
/**
@@ -31,38 +33,27 @@
private final String id;
- private final String[] paths;
-
- private final String action;
-
private final String type;
private final DistributionPackageInfo packageInfo;
- public DistributionQueueItem(String id, String[] paths, String action, String type, DistributionPackageInfo packageInfo) {
+ public DistributionQueueItem(@Nonnull String id, @Nonnull String type, @Nonnull DistributionPackageInfo packageInfo) {
this.id = id;
- this.paths = paths;
- this.action = action;
this.type = type;
this.packageInfo = packageInfo;
}
+ @Nonnull
public String getId() {
return id;
}
- public String[] getPaths() {
- return paths;
- }
-
- public String getAction() {
- return action;
- }
-
+ @Nonnull
public String getType() {
return type;
}
+ @Nonnull
public DistributionPackageInfo getPackageInfo() {
return packageInfo;
}