sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tomm...@apache.org
Subject svn commit: r1641370 - in /sling/trunk/contrib/extensions/distribution: api/src/main/java/org/apache/sling/distribution/event/ api/src/main/java/org/apache/sling/distribution/packaging/ api/src/main/java/org/apache/sling/distribution/queue/ core/src/ma...
Date Mon, 24 Nov 2014 11:31:16 GMT
Author: tommaso
Date: Mon Nov 24 11:31:15 2014
New Revision: 1641370

URL: http://svn.apache.org/r1641370
Log:
SLING-4153 - Queue#remove returns the removed item, Importer#importPackage returns void

Modified:
    sling/trunk/contrib/extensions/distribution/api/src/main/java/org/apache/sling/distribution/event/DistributionEventType.java
    sling/trunk/contrib/extensions/distribution/api/src/main/java/org/apache/sling/distribution/packaging/DistributionPackage.java
    sling/trunk/contrib/extensions/distribution/api/src/main/java/org/apache/sling/distribution/packaging/DistributionPackageExporter.java
    sling/trunk/contrib/extensions/distribution/api/src/main/java/org/apache/sling/distribution/packaging/DistributionPackageImporter.java
    sling/trunk/contrib/extensions/distribution/api/src/main/java/org/apache/sling/distribution/packaging/DistributionPackageInfo.java
    sling/trunk/contrib/extensions/distribution/api/src/main/java/org/apache/sling/distribution/queue/DistributionQueue.java
    sling/trunk/contrib/extensions/distribution/api/src/main/java/org/apache/sling/distribution/queue/DistributionQueueItem.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/impl/exporter/AgentDistributionPackageExporter.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/impl/importer/AdvancedRemoteDistributionPackageImporter.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/impl/importer/LocalDistributionPackageImporter.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/impl/importer/LocalDistributionPackageImporterFactory.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/impl/importer/RemoteDistributionPackageImporter.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/impl/importer/RemoteDistributionPackageImporterFactory.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/impl/importer/RepositoryDistributionPackageImporter.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/impl/ErrorAwareQueueDispatchingStrategy.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/impl/jobhandling/DistributionAgentJobConsumer.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/impl/jobhandling/JobHandlingDistributionQueue.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/impl/jobhandling/JobHandlingUtils.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/impl/simple/ScheduledDistributionQueueProcessorTask.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/impl/simple/SimpleDistributionQueue.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/servlet/DistributionAgentQueueServlet.java
    sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/packaging/impl/importer/LocalDistributionPackageImporterTest.java
    sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/packaging/impl/importer/RemoteDistributionPackageImporterTest.java
    sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/queue/impl/simple/SimpleDistributionQueueTest.java
    sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/serialization/impl/VoidDistributionPackageTest.java

Modified: sling/trunk/contrib/extensions/distribution/api/src/main/java/org/apache/sling/distribution/event/DistributionEventType.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/api/src/main/java/org/apache/sling/distribution/event/DistributionEventType.java?rev=1641370&r1=1641369&r2=1641370&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/api/src/main/java/org/apache/sling/distribution/event/DistributionEventType.java
(original)
+++ sling/trunk/contrib/extensions/distribution/api/src/main/java/org/apache/sling/distribution/event/DistributionEventType.java
Mon Nov 24 11:31:15 2014
@@ -66,7 +66,7 @@ public enum DistributionEventType {
     /**
      * common event topic base for distribution events
      */
-    public static final String EVENT_TOPIC = "org/apache/sling/distribution/event";
+    public static final String EVENT_TOPIC = "org/apache/sling/distribution";
 
     /**
      * get the event topic for this event type

Modified: sling/trunk/contrib/extensions/distribution/api/src/main/java/org/apache/sling/distribution/packaging/DistributionPackage.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/api/src/main/java/org/apache/sling/distribution/packaging/DistributionPackage.java?rev=1641370&r1=1641369&r2=1641370&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/api/src/main/java/org/apache/sling/distribution/packaging/DistributionPackage.java
(original)
+++ sling/trunk/contrib/extensions/distribution/api/src/main/java/org/apache/sling/distribution/packaging/DistributionPackage.java
Mon Nov 24 11:31:15 2014
@@ -66,8 +66,7 @@ public interface DistributionPackage {
      * gets an additional info holder for this package.
      * The additional info object contains control information rather than content information.
      * For example info.origin can be used to skip distributing back to the originating endpoint.
-     * It should not be be serialized between instances as its main purpose is to allow
-     * inter component communication on the same instance.
+     *
      * @return the associated metadata to this package
      */
     @Nonnull

Modified: sling/trunk/contrib/extensions/distribution/api/src/main/java/org/apache/sling/distribution/packaging/DistributionPackageExporter.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/api/src/main/java/org/apache/sling/distribution/packaging/DistributionPackageExporter.java?rev=1641370&r1=1641369&r2=1641370&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/api/src/main/java/org/apache/sling/distribution/packaging/DistributionPackageExporter.java
(original)
+++ sling/trunk/contrib/extensions/distribution/api/src/main/java/org/apache/sling/distribution/packaging/DistributionPackageExporter.java
Mon Nov 24 11:31:15 2014
@@ -32,6 +32,10 @@ import org.apache.sling.distribution.com
  * A {@link DistributionPackageExporter ) is responsible of exporting
  * {@link DistributionPackage }s to be then imported by a {@link org.apache.sling.distribution.agent.DistributionAgent
}
  * (via a {@link DistributionPackageImporter }).
+ * <p/>
+ * Exporting a {@link org.apache.sling.distribution.packaging.DistributionPackage} means
obtaining that package by either
+ * directly creating it by bundling local Sling resources together or retrieving it from
a remote endpoint, e.g. by
+ * executing an HTTP request to another Sling instance exposing already created packages
(for remotely changed resources).
  */
 @ConsumerType
 public interface DistributionPackageExporter extends DistributionComponent {
@@ -40,18 +44,23 @@ public interface DistributionPackageExpo
      * Exports the {@link DistributionPackage}s built from the
      * passed {@link org.apache.sling.distribution.communication.DistributionRequest}.
      *
-     * @param resourceResolver   - the resource resolver used to export the packages
-     * @param distributionRequest - the request containing the information about which content
is to be exported
+     * @param resourceResolver    - the resource resolver used to export the packages, for
example a 'local' exporter
+     *                            will use the resource resolver to read the content and
assemble the binary in a certain
+     *                            location in the repository while a 'remote' exporter will
use the resolver just to
+     *                            store the binary of the remotely fetched packages in the
repository.
+     * @param distributionRequest - the request containing the needed information for content
to be exported
      * @return a {@link java.util.List} of {@link DistributionPackage}s
      */
     @Nonnull
     List<DistributionPackage> exportPackages(@Nonnull ResourceResolver resourceResolver,
@Nonnull DistributionRequest distributionRequest) throws DistributionPackageExportException;
 
     /**
-     * Retrieves a {@link DistributionPackage} given its 'id', if it already exists.
+     * Retrieves a {@link DistributionPackage} given its identifier, if it already exists.
+     * This will be used for example to get already created (and cached) packages that were
not yet distributed to the
+     * target instance.
      *
-     * @param resourceResolver     - the resource resolver use to obtain the package.
-     * @param distributionPackageId - the id of the package to be retrieved
+     * @param resourceResolver      - the resource resolver use to obtain the package.
+     * @param distributionPackageId - the {@link DistributionPackage#getId() id of the package}
to be retrieved
      * @return a {@link DistributionPackage} if available, {@code null} otherwise
      */
     @CheckForNull

Modified: sling/trunk/contrib/extensions/distribution/api/src/main/java/org/apache/sling/distribution/packaging/DistributionPackageImporter.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/api/src/main/java/org/apache/sling/distribution/packaging/DistributionPackageImporter.java?rev=1641370&r1=1641369&r2=1641370&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/api/src/main/java/org/apache/sling/distribution/packaging/DistributionPackageImporter.java
(original)
+++ sling/trunk/contrib/extensions/distribution/api/src/main/java/org/apache/sling/distribution/packaging/DistributionPackageImporter.java
Mon Nov 24 11:31:15 2014
@@ -36,12 +36,11 @@ public interface DistributionPackageImpo
     /**
      * Imports the given distribution package into the underlying system
      *
-     * @param resourceResolver   - the resource resolver used to import the resources
+     * @param resourceResolver    - the resource resolver used to import the resources
      * @param distributionPackage - the package to be imported
-     * @return {@code true} if the import succeeded, {@code false} otherwise
      * @throws DistributionPackageImportException if any error occurs during import
      */
-    boolean importPackage(@Nonnull ResourceResolver resourceResolver, @Nonnull DistributionPackage
distributionPackage) throws DistributionPackageImportException;
+    void importPackage(@Nonnull ResourceResolver resourceResolver, @Nonnull DistributionPackage
distributionPackage) throws DistributionPackageImportException;
 
     /**
      * Tries to convert an {@link java.io.InputStream} to a {@link DistributionPackage} and
then imports it into the underlying system

Modified: sling/trunk/contrib/extensions/distribution/api/src/main/java/org/apache/sling/distribution/packaging/DistributionPackageInfo.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/api/src/main/java/org/apache/sling/distribution/packaging/DistributionPackageInfo.java?rev=1641370&r1=1641369&r2=1641370&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/api/src/main/java/org/apache/sling/distribution/packaging/DistributionPackageInfo.java
(original)
+++ sling/trunk/contrib/extensions/distribution/api/src/main/java/org/apache/sling/distribution/packaging/DistributionPackageInfo.java
Mon Nov 24 11:31:15 2014
@@ -20,6 +20,7 @@ package org.apache.sling.distribution.pa
 
 import javax.annotation.CheckForNull;
 import java.net.URI;
+import java.util.Arrays;
 
 import org.apache.sling.distribution.communication.DistributionRequestType;
 
@@ -102,4 +103,13 @@ public final class DistributionPackageIn
             this.setRequestType(packageInfo.getRequestType());
         }
     }
+
+    @Override
+    public String toString() {
+        return "DistributionPackageInfo{" +
+                "origin=" + origin +
+                ", requestType=" + requestType +
+                ", paths=" + Arrays.toString(paths) +
+                '}';
+    }
 }

Modified: sling/trunk/contrib/extensions/distribution/api/src/main/java/org/apache/sling/distribution/queue/DistributionQueue.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/api/src/main/java/org/apache/sling/distribution/queue/DistributionQueue.java?rev=1641370&r1=1641369&r2=1641370&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/api/src/main/java/org/apache/sling/distribution/queue/DistributionQueue.java
(original)
+++ sling/trunk/contrib/extensions/distribution/api/src/main/java/org/apache/sling/distribution/queue/DistributionQueue.java
Mon Nov 24 11:31:15 2014
@@ -87,6 +87,7 @@ public interface DistributionQueue {
      * remove an item from the queue by specifying its id
      *
      * @param id an item's identifier
+     * @return the removed item, or {@code null} if no item could be removed
      */
-    void remove(@Nonnull String id);
+    DistributionQueueItem remove(@Nonnull String id);
 }

Modified: sling/trunk/contrib/extensions/distribution/api/src/main/java/org/apache/sling/distribution/queue/DistributionQueueItem.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/api/src/main/java/org/apache/sling/distribution/queue/DistributionQueueItem.java?rev=1641370&r1=1641369&r2=1641370&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/api/src/main/java/org/apache/sling/distribution/queue/DistributionQueueItem.java
(original)
+++ sling/trunk/contrib/extensions/distribution/api/src/main/java/org/apache/sling/distribution/queue/DistributionQueueItem.java
Mon Nov 24 11:31:15 2014
@@ -57,4 +57,13 @@ public class DistributionQueueItem {
     public DistributionPackageInfo getPackageInfo() {
         return packageInfo;
     }
+
+    @Override
+    public String toString() {
+        return "DistributionQueueItem{" +
+                "id='" + id + '\'' +
+                ", type='" + type + '\'' +
+                ", packageInfo=" + packageInfo +
+                '}';
+    }
 }

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/impl/exporter/AgentDistributionPackageExporter.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/impl/exporter/AgentDistributionPackageExporter.java?rev=1641370&r1=1641369&r2=1641370&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/impl/exporter/AgentDistributionPackageExporter.java
(original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/impl/exporter/AgentDistributionPackageExporter.java
Mon Nov 24 11:31:15 2014
@@ -63,14 +63,15 @@ public class AgentDistributionPackageExp
 
         List<DistributionPackage> result = new ArrayList<DistributionPackage>();
         try {
-            log.info("getting item from queue {}", queueName);
+            log.info("getting packages from queue {}", queueName);
 
             DistributionQueue queue = agent.getQueue(queueName);
             DistributionQueueItem info = queue.getHead();
             DistributionPackage distributionPackage;
             if (info != null) {
                 distributionPackage = packageBuilder.getPackage(resourceResolver, info.getId());
-                queue.remove(info.getId());
+                DistributionQueueItem item = queue.remove(info.getId());
+                log.info("item {} fetched and removed from the queue", item);
                 if (distributionPackage != null) {
                     result.add(distributionPackage);
                 }

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/impl/importer/AdvancedRemoteDistributionPackageImporter.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/impl/importer/AdvancedRemoteDistributionPackageImporter.java?rev=1641370&r1=1641369&r2=1641370&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/impl/importer/AdvancedRemoteDistributionPackageImporter.java
(original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/impl/importer/AdvancedRemoteDistributionPackageImporter.java
Mon Nov 24 11:31:15 2014
@@ -129,15 +129,12 @@ public class AdvancedRemoteDistributionP
     }
 
 
-    public boolean importPackage(@Nonnull ResourceResolver resourceResolver, @Nonnull DistributionPackage
distributionPackage) {
-        boolean result = false;
+    public void importPackage(@Nonnull ResourceResolver resourceResolver, @Nonnull DistributionPackage
distributionPackage) {
         try {
             transportHandler.deliverPackage(resourceResolver, distributionPackage);
-            result = true;
         } catch (Exception e) {
             log.error("failed delivery", e);
         }
-        return result;
     }
 
     public DistributionPackage importStream(@Nonnull ResourceResolver resourceResolver, @Nonnull
InputStream stream) throws DistributionPackageImportException {

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/impl/importer/LocalDistributionPackageImporter.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/impl/importer/LocalDistributionPackageImporter.java?rev=1641370&r1=1641369&r2=1641370&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/impl/importer/LocalDistributionPackageImporter.java
(original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/impl/importer/LocalDistributionPackageImporter.java
Mon Nov 24 11:31:15 2014
@@ -64,10 +64,9 @@ public class LocalDistributionPackageImp
     }
 
 
-    public boolean importPackage(@Nonnull ResourceResolver resourceResolver, @Nonnull DistributionPackage
distributionPackage) throws DistributionPackageImportException {
-        boolean success;
+    public void importPackage(@Nonnull ResourceResolver resourceResolver, @Nonnull DistributionPackage
distributionPackage) throws DistributionPackageImportException {
         try {
-            success = packageBuilder.installPackage(resourceResolver, distributionPackage);
+            boolean success = packageBuilder.installPackage(resourceResolver, distributionPackage);
 
             if (success) {
                 log.info("Distribution package read and installed for path(s) {}", Arrays.toString(distributionPackage.getInfo().getPaths()));
@@ -84,17 +83,13 @@ public class LocalDistributionPackageImp
             log.error("cannot import a package from the given stream of type {}", distributionPackage.getType());
             throw new DistributionPackageImportException(e);
         }
-        return success;
     }
 
     public DistributionPackage importStream(@Nonnull ResourceResolver resourceResolver, @Nonnull
InputStream stream) throws DistributionPackageImportException {
         try {
             DistributionPackage distributionPackage = packageBuilder.readPackage(resourceResolver,
stream);
-            if (importPackage(resourceResolver, distributionPackage)) {
-                return distributionPackage;
-            } else {
-                throw new DistributionPackageImportException("could not import the package
" + distributionPackage);
-            }
+            importPackage(resourceResolver, distributionPackage);
+            return distributionPackage;
         } catch (DistributionPackageReadingException e) {
             throw new DistributionPackageImportException("cannot read a package from the
given stream", e);
         }

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/impl/importer/LocalDistributionPackageImporterFactory.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/impl/importer/LocalDistributionPackageImporterFactory.java?rev=1641370&r1=1641369&r2=1641370&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/impl/importer/LocalDistributionPackageImporterFactory.java
(original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/impl/importer/LocalDistributionPackageImporterFactory.java
Mon Nov 24 11:31:15 2014
@@ -80,8 +80,8 @@ public class LocalDistributionPackageImp
     }
 
 
-    public boolean importPackage(@Nonnull ResourceResolver resourceResolver, @Nonnull DistributionPackage
distributionPackage) throws DistributionPackageImportException {
-        return importer.importPackage(resourceResolver, distributionPackage);
+    public void importPackage(@Nonnull ResourceResolver resourceResolver, @Nonnull DistributionPackage
distributionPackage) throws DistributionPackageImportException {
+        importer.importPackage(resourceResolver, distributionPackage);
     }
 
     public DistributionPackage importStream(@Nonnull ResourceResolver resourceResolver, @Nonnull
InputStream stream) throws DistributionPackageImportException {

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/impl/importer/RemoteDistributionPackageImporter.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/impl/importer/RemoteDistributionPackageImporter.java?rev=1641370&r1=1641369&r2=1641370&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/impl/importer/RemoteDistributionPackageImporter.java
(original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/impl/importer/RemoteDistributionPackageImporter.java
Mon Nov 24 11:31:15 2014
@@ -70,10 +70,9 @@ public class RemoteDistributionPackageIm
 
     }
 
-    public boolean importPackage(@Nonnull ResourceResolver resourceResolver, @Nonnull DistributionPackage
distributionPackage) throws DistributionPackageImportException {
+    public void importPackage(@Nonnull ResourceResolver resourceResolver, @Nonnull DistributionPackage
distributionPackage) throws DistributionPackageImportException {
         try {
             transportHandler.deliverPackage(resourceResolver, distributionPackage);
-            return true;
         } catch (Exception e) {
             throw new DistributionPackageImportException("failed in importing package " +
distributionPackage);
         }

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/impl/importer/RemoteDistributionPackageImporterFactory.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/impl/importer/RemoteDistributionPackageImporterFactory.java?rev=1641370&r1=1641369&r2=1641370&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/impl/importer/RemoteDistributionPackageImporterFactory.java
(original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/impl/importer/RemoteDistributionPackageImporterFactory.java
Mon Nov 24 11:31:15 2014
@@ -99,8 +99,8 @@ public class RemoteDistributionPackageIm
 
     }
 
-    public boolean importPackage(@Nonnull ResourceResolver resourceResolver, @Nonnull DistributionPackage
distributionPackage) throws DistributionPackageImportException {
-        return importer.importPackage(resourceResolver, distributionPackage);
+    public void importPackage(@Nonnull ResourceResolver resourceResolver, @Nonnull DistributionPackage
distributionPackage) throws DistributionPackageImportException {
+        importer.importPackage(resourceResolver, distributionPackage);
     }
 
     public DistributionPackage importStream(@Nonnull ResourceResolver resourceResolver, @Nonnull
InputStream stream) throws DistributionPackageImportException {

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/impl/importer/RepositoryDistributionPackageImporter.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/impl/importer/RepositoryDistributionPackageImporter.java?rev=1641370&r1=1641369&r2=1641370&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/impl/importer/RepositoryDistributionPackageImporter.java
(original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/impl/importer/RepositoryDistributionPackageImporter.java
Mon Nov 24 11:31:15 2014
@@ -104,8 +104,8 @@ public class RepositoryDistributionPacka
         }
     }
 
-    public boolean importPackage(@Nonnull ResourceResolver resourceResolver, @Nonnull DistributionPackage
distributionPackage) throws DistributionPackageImportException {
-        return false;
+    public void importPackage(@Nonnull ResourceResolver resourceResolver, @Nonnull DistributionPackage
distributionPackage) throws DistributionPackageImportException {
+        // do nothing
     }
 
     public DistributionPackage importStream(@Nonnull ResourceResolver resourceResolver, @Nonnull
InputStream stream) throws DistributionPackageImportException {

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/impl/ErrorAwareQueueDispatchingStrategy.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/impl/ErrorAwareQueueDispatchingStrategy.java?rev=1641370&r1=1641369&r2=1641370&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/impl/ErrorAwareQueueDispatchingStrategy.java
(original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/impl/ErrorAwareQueueDispatchingStrategy.java
Mon Nov 24 11:31:15 2014
@@ -116,8 +116,9 @@ public class ErrorAwareQueueDispatchingS
                         throw new DistributionQueueException("could not move an item to the
error queue");
                     }
                 }
-                log.warn("item {} dropped from the default queue", firstItem);
-                defaultQueue.remove(firstItem.getId());
+                if (defaultQueue.remove(firstItem.getId()) != null) {
+                    log.warn("item {} dropped from the default queue", firstItem);
+                }
             }
         }
     }

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/impl/jobhandling/DistributionAgentJobConsumer.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/impl/jobhandling/DistributionAgentJobConsumer.java?rev=1641370&r1=1641369&r2=1641370&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/impl/jobhandling/DistributionAgentJobConsumer.java
(original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/impl/jobhandling/DistributionAgentJobConsumer.java
Mon Nov 24 11:31:15 2014
@@ -41,7 +41,7 @@ class DistributionAgentJobConsumer imple
     public JobResult process(Job job) {
         log.debug("processing job {}", job.getId());
         String queueName = JobHandlingUtils.getQueueName(job);
-        DistributionQueueItem info = JobHandlingUtils.getPackage(job);
+        DistributionQueueItem info = JobHandlingUtils.getItem(job);
         log.info("processing item {} in queue {}", info.getId(), queueName);
         boolean processingResult = queueProcessor.process(queueName, info);
         JobResult jobResult = processingResult ? JobResult.OK : JobResult.FAILED;

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/impl/jobhandling/JobHandlingDistributionQueue.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/impl/jobhandling/JobHandlingDistributionQueue.java?rev=1641370&r1=1641369&r2=1641370&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/impl/jobhandling/JobHandlingDistributionQueue.java
(original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/impl/jobhandling/JobHandlingDistributionQueue.java
Mon Nov 24 11:31:15 2014
@@ -101,9 +101,9 @@ public class JobHandlingDistributionQueu
     }
 
     public DistributionQueueItem getHead() {
-        Job firstItem = getFirstJob();
-        if (firstItem != null) {
-            return JobHandlingUtils.getPackage(firstItem);
+        Job firstJob = getFirstJob();
+        if (firstJob != null) {
+            return JobHandlingUtils.getItem(firstJob);
         } else {
             return null;
         }
@@ -140,7 +140,7 @@ public class JobHandlingDistributionQueu
         Collection<Job> jobs = jobManager.findJobs(QueryType.ALL, topic, actualLimit);
         List<Job> result = new ArrayList<Job>();
 
-        int i =0;
+        int i = 0;
         for (Job job : jobs) {
             if (i >= actualSkip) {
                 result.add(job);
@@ -164,19 +164,25 @@ public class JobHandlingDistributionQueu
         List<DistributionQueueItem> items = new ArrayList<DistributionQueueItem>();
         Collection<Job> jobs = getJobs(selector.getSkip(), selector.getLimit());
         for (Job job : jobs) {
-            items.add(JobHandlingUtils.getPackage(job));
+            items.add(JobHandlingUtils.getItem(job));
         }
 
         return items;
     }
 
-    public void remove(@Nonnull String id) {
+    public DistributionQueueItem remove(@Nonnull String id) {
+        boolean removed = false;
         Job job = getJob(id);
 
+        DistributionQueueItem item = null;
+
         if (job != null) {
-            boolean removed = jobManager.removeJobById(job.getId());
-            log.info("item with id {} removed from the queue: {}", id, removed);
+            item = JobHandlingUtils.getItem(job);
+            removed = jobManager.removeJobById(job.getId());
         }
+
+        log.info("item with id {} removed from the queue: {}", id, removed);
+        return item;
     }
 
 }

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/impl/jobhandling/JobHandlingUtils.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/impl/jobhandling/JobHandlingUtils.java?rev=1641370&r1=1641369&r2=1641370&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/impl/jobhandling/JobHandlingUtils.java
(original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/impl/jobhandling/JobHandlingUtils.java
Mon Nov 24 11:31:15 2014
@@ -39,7 +39,7 @@ public class JobHandlingUtils {
 
     protected static final String ORIGIN = "distribution.package.origin";
 
-    public static DistributionQueueItem getPackage(final Job job) {
+    public static DistributionQueueItem getItem(final Job job) {
         DistributionPackageInfo packageInfo = new DistributionPackageInfo();
         packageInfo.setOrigin((URI) job.getProperty(ORIGIN));
         packageInfo.setPaths((String[]) job.getProperty(PATHS));

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/impl/simple/ScheduledDistributionQueueProcessorTask.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/impl/simple/ScheduledDistributionQueueProcessorTask.java?rev=1641370&r1=1641369&r2=1641370&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/impl/simple/ScheduledDistributionQueueProcessorTask.java
(original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/impl/simple/ScheduledDistributionQueueProcessorTask.java
Mon Nov 24 11:31:15 2014
@@ -18,8 +18,6 @@
  */
 package org.apache.sling.distribution.queue.impl.simple;
 
-import java.util.Arrays;
-
 import org.apache.sling.distribution.queue.DistributionQueue;
 import org.apache.sling.distribution.queue.DistributionQueueItem;
 import org.apache.sling.distribution.queue.DistributionQueueProcessor;
@@ -49,7 +47,9 @@ class ScheduledDistributionQueueProcesso
                     DistributionQueueItem item = queue.getHead();
                     if (item != null) {
                         if (queueProcessor.process(queue.getName(), item)) {
-                            queue.remove(item.getId());
+                            if (queue.remove(item.getId()) != null) {
+                                log.info("item {} processed and removed from the queue",
item);
+                            }
                         } else {
                             log.warn("processing of item {} failed", item.getId());
                         }

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/impl/simple/SimpleDistributionQueue.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/impl/simple/SimpleDistributionQueue.java?rev=1641370&r1=1641369&r2=1641370&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/impl/simple/SimpleDistributionQueue.java
(original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/impl/simple/SimpleDistributionQueue.java
Mon Nov 24 11:31:15 2014
@@ -93,7 +93,7 @@ public class SimpleDistributionQueue imp
             DistributionQueueItemState itemState = statusMap.get(element);
             statusMap.put(element, new DistributionQueueItemState(itemState.getEntered(),
                     itemState.getItemState(),
-                    itemState.getAttempts()+1, name));
+                    itemState.getAttempts() + 1, name));
         }
         return element;
     }
@@ -108,8 +108,7 @@ public class SimpleDistributionQueue imp
     }
 
 
-
-    public void remove(@Nonnull String id) {
+    public DistributionQueueItem remove(@Nonnull String id) {
         DistributionQueueItem toRemove = null;
         for (DistributionQueueItem item : queue) {
             if (id.equals(item.getId())) {
@@ -121,6 +120,12 @@ public class SimpleDistributionQueue imp
             removed = queue.remove(toRemove);
         }
         log.info("item with id {} removed from the queue: {}", id, removed);
+        if (removed) {
+            return toRemove;
+        }
+        else {
+            return null;
+        }
     }
 
 }

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/servlet/DistributionAgentQueueServlet.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/servlet/DistributionAgentQueueServlet.java?rev=1641370&r1=1641369&r2=1641370&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/servlet/DistributionAgentQueueServlet.java
(original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/servlet/DistributionAgentQueueServlet.java
Mon Nov 24 11:31:15 2014
@@ -32,6 +32,8 @@ import org.apache.sling.distribution.que
 import org.apache.sling.distribution.queue.DistributionQueueItem;
 import org.apache.sling.distribution.queue.DistributionQueueItemState;
 import org.apache.sling.distribution.resources.DistributionConstants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Servlet to retrieve a {@link org.apache.sling.distribution.queue.DistributionQueue} status.
@@ -39,6 +41,8 @@ import org.apache.sling.distribution.res
 @SlingServlet(resourceTypes = DistributionConstants.AGENT_QUEUE_RESOURCE_TYPE, methods =
{"GET", "POST", "DELETE"})
 public class DistributionAgentQueueServlet extends SlingAllMethodsServlet {
 
+    private final Logger log = LoggerFactory.getLogger(getClass());
+
     @Override
     protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response)
             throws ServletException, IOException {
@@ -83,7 +87,14 @@ public class DistributionAgentQueueServl
 
         while (!queue.isEmpty()) {
             DistributionQueueItem queueItem = queue.getHead();
-            queue.remove(queueItem.getId());
+            DistributionQueueItem removedItem = queue.remove(queueItem.getId());
+            if (removedItem != null) {
+                log.info("item {} removed from the queue {}", removedItem, queue);
+                response.setStatus(200);
+            } else {
+                log.warn("could not remove item {} from the queue {}", queueItem, queue);
+                response.setStatus(400);
+            }
         }
     }
 

Modified: sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/packaging/impl/importer/LocalDistributionPackageImporterTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/packaging/impl/importer/LocalDistributionPackageImporterTest.java?rev=1641370&r1=1641369&r2=1641370&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/packaging/impl/importer/LocalDistributionPackageImporterTest.java
(original)
+++ sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/packaging/impl/importer/LocalDistributionPackageImporterTest.java
Mon Nov 24 11:31:15 2014
@@ -39,7 +39,6 @@ public class LocalDistributionPackageImp
         LocalDistributionPackageImporter localdistributionPackageImporter = new LocalDistributionPackageImporter(packageBuilder,
eventFactory);
         ResourceResolver resourceResolver = mock(ResourceResolver.class);
         DistributionPackage distributionPackage = mock(DistributionPackage.class);
-        boolean success = localdistributionPackageImporter.importPackage(resourceResolver,
distributionPackage);
-        assertFalse(success);
+        localdistributionPackageImporter.importPackage(resourceResolver, distributionPackage);
     }
 }

Modified: sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/packaging/impl/importer/RemoteDistributionPackageImporterTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/packaging/impl/importer/RemoteDistributionPackageImporterTest.java?rev=1641370&r1=1641369&r2=1641370&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/packaging/impl/importer/RemoteDistributionPackageImporterTest.java
(original)
+++ sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/packaging/impl/importer/RemoteDistributionPackageImporterTest.java
Mon Nov 24 11:31:15 2014
@@ -41,8 +41,7 @@ public class RemoteDistributionPackageIm
                     authenticationProvider, endpoints, strategy.name());
             ResourceResolver resourceResolver = mock(ResourceResolver.class);
             DistributionPackage distributionPackage = mock(DistributionPackage.class);
-            boolean success = remotedistributionPackageImporter.importPackage(resourceResolver,
distributionPackage);
-            assertTrue(success);
+            remotedistributionPackageImporter.importPackage(resourceResolver, distributionPackage);
         }
     }
 }

Modified: sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/queue/impl/simple/SimpleDistributionQueueTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/queue/impl/simple/SimpleDistributionQueueTest.java?rev=1641370&r1=1641369&r2=1641370&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/queue/impl/simple/SimpleDistributionQueueTest.java
(original)
+++ sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/queue/impl/simple/SimpleDistributionQueueTest.java
Mon Nov 24 11:31:15 2014
@@ -50,7 +50,7 @@ public class SimpleDistributionQueueTest
         when(pkg.getId()).thenReturn("id");
         assertTrue(queue.add(pkg));
         assertFalse(queue.isEmpty());
-        queue.remove(pkg.getId());
+        assertNotNull(queue.remove(pkg.getId()));
         assertTrue(queue.isEmpty());
         DistributionQueueItemState status = queue.getStatus(pkg);
         assertNotNull(status);
@@ -66,7 +66,7 @@ public class SimpleDistributionQueueTest
         assertFalse(queue.isEmpty());
         assertEquals(pkg, queue.getHead());
         assertFalse(queue.isEmpty());
-        queue.remove(pkg.getId());
+        assertNotNull(queue.remove(pkg.getId()));
         assertTrue(queue.isEmpty());
         DistributionQueueItemState status = queue.getStatus(pkg);
         assertNotNull(status);

Modified: sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/serialization/impl/VoidDistributionPackageTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/serialization/impl/VoidDistributionPackageTest.java?rev=1641370&r1=1641369&r2=1641370&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/serialization/impl/VoidDistributionPackageTest.java
(original)
+++ sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/serialization/impl/VoidDistributionPackageTest.java
Mon Nov 24 11:31:15 2014
@@ -37,8 +37,8 @@ public class VoidDistributionPackageTest
     @Test
     public void testCreatedAndReadPackagesEquality() throws Exception {
         DistributionRequest request = new DistributionRequest(DistributionRequestType.DELETE,
"/abc");
-        VoidDistributionPackage createdPackage = new VoidDistributionPackage(request);
         long time = System.currentTimeMillis();
+        VoidDistributionPackage createdPackage = new VoidDistributionPackage(request);
         VoidDistributionPackage readPackage = VoidDistributionPackage.fromStream(new ByteArrayInputStream(("DELETE:/abc:"
+ time + ":VOID").getBytes()));
         assertEquals(createdPackage.getId(), readPackage.getId());
         assertEquals(createdPackage.getType(), readPackage.getType());



Mime
View raw message