SLING-5180: cleaned DistributionPackageInfo
authorMarius Petria <mpetria@apache.org>
Thu, 22 Oct 2015 12:44:36 +0000 (12:44 +0000)
committerMarius Petria <mpetria@apache.org>
Thu, 22 Oct 2015 12:44:36 +0000 (12:44 +0000)
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1710007 13f79535-47bb-0310-9956-ffa450edef68

src/main/java/org/apache/sling/distribution/serialization/DistributionPackage.java
src/main/java/org/apache/sling/distribution/serialization/DistributionPackageBuilder.java
src/main/java/org/apache/sling/distribution/serialization/DistributionPackageInfo.java

index ecbd5ab..f5fb65f 100644 (file)
@@ -22,12 +22,12 @@ import javax.annotation.Nonnull;
 import java.io.IOException;
 import java.io.InputStream;
 
-import aQute.bnd.annotation.ConsumerType;
+import aQute.bnd.annotation.ProviderType;
 
 /**
  * A distribution package
  */
-@ConsumerType
+@ProviderType
 public interface DistributionPackage {
 
     /**
index b782e30..4f54a41 100644 (file)
@@ -22,6 +22,7 @@ import javax.annotation.CheckForNull;
 import javax.annotation.Nonnull;
 import java.io.InputStream;
 
+import aQute.bnd.annotation.ProviderType;
 import org.apache.sling.api.resource.ResourceResolver;
 import org.apache.sling.distribution.DistributionException;
 import org.apache.sling.distribution.DistributionRequest;
@@ -29,6 +30,7 @@ import org.apache.sling.distribution.DistributionRequest;
 /**
  * A builder for {@link DistributionPackage}s
  */
+@ProviderType
 public interface DistributionPackageBuilder {
 
     /**
index fcdc0a0..dd03abf 100644 (file)
@@ -25,6 +25,7 @@ import java.util.Arrays;
 import java.util.HashMap;
 import java.util.Map;
 
+import aQute.bnd.annotation.ProviderType;
 import org.apache.sling.api.resource.ValueMap;
 import org.apache.sling.api.wrappers.ValueMapDecorator;
 import org.apache.sling.distribution.DistributionRequestType;
@@ -33,6 +34,7 @@ import org.apache.sling.distribution.DistributionRequestType;
  * Additional information about a package.
  * Additional information is optional and components should expect every piece of it to be null.
  */
+@ProviderType
 public final class DistributionPackageInfo extends ValueMapDecorator implements ValueMap {
 
     /**
@@ -50,49 +52,31 @@ public final class DistributionPackageInfo extends ValueMapDecorator implements
      */
     public static String PROPERTY_REQUEST_TYPE = "request.type";
 
-    /**
-     * distribution package origin uri
-     */
-    public static String PROPERTY_ORIGIN_URI = "package.origin.uri";
-
-    /**
-     * distribution package origin queue
-     */
-    public static String PROPERTY_ORIGIN_QUEUE = "origin.queue";
-
 
     /**
      * Creates a new wrapper around a given map.
      *
      * @param base wrapped object
      */
-    public DistributionPackageInfo(Map<String, Object> base) {
-        super(init(null, base));
+    public DistributionPackageInfo(String packageType, Map<String, Object> base) {
+        super(base);
+        if (packageType == null) {
+            throw new IllegalArgumentException("package type cannot be null");
+        }
+
+        put(PROPERTY_PACKAGE_TYPE, packageType);
     }
 
+
     /**
-     * Creates a new wrapper around a given map.
+     * Creates a new wrapper around an empty map.
      *
      */
-    public DistributionPackageInfo(String type) {
-        super(init(type, null));
+    public DistributionPackageInfo(String packageType) {
+        this(packageType, new HashMap<String, Object>());
     }
 
 
-    private static Map<String, Object> init(String type, Map<String, Object> base) {
-        Map<String, Object> result = new HashMap<String, Object>();
-
-        if (base != null) {
-            type = (String) base.get(PROPERTY_PACKAGE_TYPE);
-
-            result = new HashMap<String, Object>(base);
-        }
-
-        result.put(PROPERTY_PACKAGE_TYPE, type);
-
-        return result;
-    }
-
     @Nonnull
     public String getType() {
         return get(PROPERTY_PACKAGE_TYPE, String.class);
@@ -118,27 +102,11 @@ public final class DistributionPackageInfo extends ValueMapDecorator implements
         return get(PROPERTY_REQUEST_TYPE, DistributionRequestType.class);
     }
 
-    /**
-     * retrieves the origin of the package holding this info
-     *
-     * @return the package origin
-     */
-    @CheckForNull
-    public URI getOrigin() {
-        return get(PROPERTY_ORIGIN_URI, URI.class);
-    }
-
-    @CheckForNull
-    public String getQueue() {
-        return get(PROPERTY_ORIGIN_QUEUE, String.class);
-    }
-
-
     @Override
     public String toString() {
         return "DistributionPackageInfo{" +
-                " requestType=" + getRequestType() +
-                ", paths=" + Arrays.toString(getPaths()) +
+                " request.type=" + getRequestType() +
+                ", request.paths=" + Arrays.toString(getPaths()) +
                 '}';
     }
 }