sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mpet...@apache.org
Subject svn commit: r1654776 [1/2] - in /sling/trunk/contrib/extensions/distribution: core/src/main/java/org/apache/sling/distribution/agent/ core/src/main/java/org/apache/sling/distribution/agent/impl/ core/src/main/java/org/apache/sling/distribution/componen...
Date Mon, 26 Jan 2015 12:24:22 GMT
Author: mpetria
Date: Mon Jan 26 12:24:21 2015
New Revision: 1654776

URL: http://svn.apache.org/r1654776
Log:
SLING-4351: exposing log information over http api

Added:
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/impl/CompositeDistributionResponse.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/log/
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/log/DistributionLog.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/log/impl/
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/log/impl/DefaultDistributionLog.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/servlet/DistributionAgentLogServlet.java
Modified:
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/DistributionAgent.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/AbstractDistributionAgentFactory.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/ForwardDistributionAgentFactory.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/QueueDistributionAgentFactory.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/ReverseDistributionAgentFactory.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/SimpleDistributionAgent.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/SimpleDistributionAgentFactory.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/SyncDistributionAgentFactory.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/component/impl/DefaultDistributionConfigurationManager.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/impl/SimpleDistributionResponse.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/resources/DistributionResourceTypes.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/resources/impl/ExtendedDistributionServiceResourceProvider.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/serialization/impl/SimpleDistributionPackage.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/serialization/impl/vlt/FileVaultDistributionPackage.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/serialization/impl/vlt/FileVaultDistributionPackageBuilder.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/serialization/impl/vlt/JcrVaultDistributionPackage.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/serialization/impl/vlt/JcrVaultDistributionPackageBuilder.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/servlet/DistributionAgentRootServlet.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/servlet/DistributionAgentServlet.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/servlet/DistributionPackageExporterServlet.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/servlet/DistributionPackageImporterServlet.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/transport/impl/SimpleHttpDistributionTransport.java
    sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/agent/impl/SimpleDistributionAgentTest.java
    sling/trunk/contrib/extensions/distribution/it/src/test/java/org/apache/sling/distribution/it/DistributionAgentResourcesIntegrationTest.java
    sling/trunk/contrib/extensions/distribution/it/src/test/java/org/apache/sling/distribution/it/DistributionUtils.java

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/DistributionAgent.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/DistributionAgent.java?rev=1654776&r1=1654775&r2=1654776&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/DistributionAgent.java (original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/DistributionAgent.java Mon Jan 26 12:24:21 2015
@@ -25,6 +25,7 @@ import aQute.bnd.annotation.ProviderType
 import org.apache.sling.api.resource.ResourceResolver;
 import org.apache.sling.distribution.DistributionRequest;
 import org.apache.sling.distribution.DistributionResponse;
+import org.apache.sling.distribution.log.DistributionLog;
 import org.apache.sling.distribution.queue.DistributionQueue;
 
 /**
@@ -38,7 +39,7 @@ import org.apache.sling.distribution.que
 public interface DistributionAgent {
 
     /**
-     * retrieves the names of the queues for this agent.
+     * Retrieves the names of the queues for this agent.
      *
      * @return the list of queue names
      */
@@ -46,7 +47,7 @@ public interface DistributionAgent {
     Iterable<String> getQueueNames();
 
     /**
-     * get the agent queue with the given name
+     * Get the agent queue with the given name
      *
      * @param name a queue name
      * @return a {@link org.apache.sling.distribution.queue.DistributionQueue} with the given name bound to this agent, if it exists,
@@ -56,6 +57,14 @@ public interface DistributionAgent {
     @CheckForNull
     DistributionQueue getQueue(@Nonnull String name) throws DistributionAgentException;
 
+
+    /**
+     * Get the agent log
+     * @return the log for this agent
+     */
+    @Nonnull
+    DistributionLog getLog();
+
     /**
      * Perform a {@link org.apache.sling.distribution.DistributionRequest} to distribute content from a source
      * instance to a target instance.

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/AbstractDistributionAgentFactory.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/AbstractDistributionAgentFactory.java?rev=1654776&r1=1654775&r2=1654776&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/AbstractDistributionAgentFactory.java (original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/AbstractDistributionAgentFactory.java Mon Jan 26 12:24:21 2015
@@ -20,7 +20,10 @@ package org.apache.sling.distribution.ag
 
 import org.apache.sling.commons.osgi.PropertiesUtil;
 import org.apache.sling.distribution.agent.DistributionAgent;
+import org.apache.sling.distribution.component.impl.DistributionComponentKind;
 import org.apache.sling.distribution.component.impl.DistributionComponentUtils;
+import org.apache.sling.distribution.log.DistributionLog;
+import org.apache.sling.distribution.log.impl.DefaultDistributionLog;
 import org.apache.sling.distribution.resources.impl.OsgiUtils;
 import org.apache.sling.distribution.trigger.DistributionTrigger;
 import org.osgi.framework.BundleContext;
@@ -51,6 +54,9 @@ public abstract class AbstractDistributi
 
     private static final String TRIGGERS_TARGET = "triggers.target";
 
+    protected static final String LOG_LEVEL = "log.level";
+
+
 
     private ServiceRegistration componentReg;
     private BundleContext savedContext;
@@ -93,7 +99,16 @@ public abstract class AbstractDistributi
 
                 try {
 
-                   agent = createAgent(agentName, context, config);
+                    String logLevel = PropertiesUtil.toString(config.get(LOG_LEVEL), DefaultDistributionLog.LogLevel.INFO.name());
+                    DefaultDistributionLog.LogLevel level = DefaultDistributionLog.LogLevel.valueOf(logLevel.trim().toUpperCase());
+                    if (level == null) {
+                        level = DefaultDistributionLog.LogLevel.INFO;
+                    }
+
+
+                    DefaultDistributionLog distributionLog = new DefaultDistributionLog(DistributionComponentKind.AGENT, agentName, SimpleDistributionAgent.class, level);
+
+                    agent = createAgent(agentName, context, config, distributionLog);
                 }
                 catch (IllegalArgumentException e) {
                     log.warn("cannot create agent", e);
@@ -160,6 +175,6 @@ public abstract class AbstractDistributi
     }
 
 
-    protected abstract SimpleDistributionAgent createAgent(String agentName, BundleContext context, Map<String, Object> config);
+    protected abstract SimpleDistributionAgent createAgent(String agentName, BundleContext context, Map<String, Object> config, DefaultDistributionLog distributionLog);
 
 }

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/ForwardDistributionAgentFactory.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/ForwardDistributionAgentFactory.java?rev=1654776&r1=1654775&r2=1654776&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/ForwardDistributionAgentFactory.java (original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/ForwardDistributionAgentFactory.java Mon Jan 26 12:24:21 2015
@@ -23,6 +23,7 @@ import org.apache.felix.scr.annotations.
 import org.apache.felix.scr.annotations.ConfigurationPolicy;
 import org.apache.felix.scr.annotations.Deactivate;
 import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.PropertyOption;
 import org.apache.felix.scr.annotations.Reference;
 import org.apache.felix.scr.annotations.ReferenceCardinality;
 import org.apache.felix.scr.annotations.ReferencePolicy;
@@ -32,6 +33,7 @@ import org.apache.sling.commons.osgi.Pro
 import org.apache.sling.distribution.component.impl.DistributionComponentUtils;
 import org.apache.sling.distribution.component.impl.SettingsUtils;
 import org.apache.sling.distribution.event.impl.DistributionEventFactory;
+import org.apache.sling.distribution.log.impl.DefaultDistributionLog;
 import org.apache.sling.distribution.packaging.DistributionPackageExporter;
 import org.apache.sling.distribution.packaging.DistributionPackageImporter;
 import org.apache.sling.distribution.packaging.impl.exporter.LocalDistributionPackageExporter;
@@ -79,6 +81,14 @@ public class ForwardDistributionAgentFac
     @Property(label = "Service Name", description = "The name of the service used to access the repository.")
     public static final String SERVICE_NAME = "serviceName";
 
+    @Property(options = {
+            @PropertyOption(name = "debug", value = "debug"), @PropertyOption(name = "info", value = "info"),  @PropertyOption(name = "warn", value = "warn"),
+            @PropertyOption(name = "error", value = "error")},
+            value = "info",
+            label = "Log Level", description = "The log level recorded in the transient log accessible via http."
+    )
+    public static final String LOG_LEVEL = AbstractDistributionAgentFactory.LOG_LEVEL;
+
 
     @Property(boolValue = true, label = "Queue Processing Enabled", description = "Whether or not the distribution agent should process packages in the queues.")
     public static final String QUEUE_PROCESSING_ENABLED = "queue.processing.enabled";
@@ -155,7 +165,7 @@ public class ForwardDistributionAgentFac
     }
 
     @Override
-    protected SimpleDistributionAgent createAgent(String agentName, BundleContext context, Map<String, Object> config) {
+    protected SimpleDistributionAgent createAgent(String agentName, BundleContext context, Map<String, Object> config, DefaultDistributionLog distributionLog) {
         String serviceName = PropertiesUtil.toString(config.get(SERVICE_NAME), null);
         boolean queueProcessingEnabled = PropertiesUtil.toBoolean(config.get(QUEUE_PROCESSING_ENABLED), true);
 
@@ -182,7 +192,7 @@ public class ForwardDistributionAgentFac
 
         return new SimpleDistributionAgent(agentName, queueProcessingEnabled, serviceName,
                 packageImporter, packageExporter, requestAuthorizationStrategy,
-                queueProvider, dispatchingStrategy, distributionEventFactory, resourceResolverFactory);
+                queueProvider, dispatchingStrategy, distributionEventFactory, resourceResolverFactory, distributionLog);
 
 
     }

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/QueueDistributionAgentFactory.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/QueueDistributionAgentFactory.java?rev=1654776&r1=1654775&r2=1654776&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/QueueDistributionAgentFactory.java (original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/QueueDistributionAgentFactory.java Mon Jan 26 12:24:21 2015
@@ -23,6 +23,7 @@ import org.apache.felix.scr.annotations.
 import org.apache.felix.scr.annotations.ConfigurationPolicy;
 import org.apache.felix.scr.annotations.Deactivate;
 import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.PropertyOption;
 import org.apache.felix.scr.annotations.Reference;
 import org.apache.felix.scr.annotations.ReferenceCardinality;
 import org.apache.felix.scr.annotations.ReferencePolicy;
@@ -31,6 +32,7 @@ import org.apache.sling.api.resource.Res
 import org.apache.sling.commons.osgi.PropertiesUtil;
 import org.apache.sling.distribution.component.impl.DistributionComponentUtils;
 import org.apache.sling.distribution.event.impl.DistributionEventFactory;
+import org.apache.sling.distribution.log.impl.DefaultDistributionLog;
 import org.apache.sling.distribution.packaging.DistributionPackageExporter;
 import org.apache.sling.distribution.packaging.impl.exporter.LocalDistributionPackageExporter;
 import org.apache.sling.distribution.queue.impl.DistributionQueueDispatchingStrategy;
@@ -74,6 +76,14 @@ public class QueueDistributionAgentFacto
     @Property(label = "Service Name", description = "The name of the service used to access the repository.")
     public static final String SERVICE_NAME = "serviceName";
 
+    @Property(options = {
+            @PropertyOption(name = "debug", value = "debug"), @PropertyOption(name = "info", value = "info"),  @PropertyOption(name = "warn", value = "warn"),
+            @PropertyOption(name = "error", value = "error")},
+            value = "info",
+            label = "Log Level", description = "The log level recorded in the transient log accessible via http."
+    )
+    public static final String LOG_LEVEL = AbstractDistributionAgentFactory.LOG_LEVEL;
+
 
     @Property(name = "requestAuthorizationStrategy.target", label = "Request Authorization Strategy", description = "The target reference for the DistributionRequestAuthorizationStrategy used to authorize the access to distribution process," +
             "e.g. use target=(name=...) to bind to services by name.")
@@ -125,7 +135,7 @@ public class QueueDistributionAgentFacto
     }
 
     @Override
-    protected SimpleDistributionAgent createAgent(String agentName, BundleContext context, Map<String, Object> config) {
+    protected SimpleDistributionAgent createAgent(String agentName, BundleContext context, Map<String, Object> config, DefaultDistributionLog distributionLog) {
 
         String serviceName = PropertiesUtil.toString(config.get(SERVICE_NAME), null);
         DistributionQueueProvider queueProvider =  new JobHandlingDistributionQueueProvider(agentName, jobManager, context);
@@ -134,6 +144,6 @@ public class QueueDistributionAgentFacto
 
         return new SimpleDistributionAgent(agentName, false, serviceName,
                 null, packageExporter, requestAuthorizationStrategy,
-                queueProvider, dispatchingStrategy, distributionEventFactory, resourceResolverFactory);
+                queueProvider, dispatchingStrategy, distributionEventFactory, resourceResolverFactory, distributionLog);
     }
 }

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/ReverseDistributionAgentFactory.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/ReverseDistributionAgentFactory.java?rev=1654776&r1=1654775&r2=1654776&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/ReverseDistributionAgentFactory.java (original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/ReverseDistributionAgentFactory.java Mon Jan 26 12:24:21 2015
@@ -23,6 +23,7 @@ import org.apache.felix.scr.annotations.
 import org.apache.felix.scr.annotations.ConfigurationPolicy;
 import org.apache.felix.scr.annotations.Deactivate;
 import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.PropertyOption;
 import org.apache.felix.scr.annotations.Reference;
 import org.apache.felix.scr.annotations.ReferenceCardinality;
 import org.apache.felix.scr.annotations.ReferencePolicy;
@@ -31,6 +32,7 @@ import org.apache.sling.api.resource.Res
 import org.apache.sling.commons.osgi.PropertiesUtil;
 import org.apache.sling.distribution.component.impl.DistributionComponentUtils;
 import org.apache.sling.distribution.event.impl.DistributionEventFactory;
+import org.apache.sling.distribution.log.impl.DefaultDistributionLog;
 import org.apache.sling.distribution.packaging.DistributionPackageExporter;
 import org.apache.sling.distribution.packaging.DistributionPackageImporter;
 import org.apache.sling.distribution.packaging.impl.exporter.RemoteDistributionPackageExporter;
@@ -78,6 +80,14 @@ public class ReverseDistributionAgentFac
     @Property(label = "Service Name", description = "The name of the service used to access the repository.")
     public static final String SERVICE_NAME = "serviceName";
 
+    @Property(options = {
+            @PropertyOption(name = "debug", value = "debug"), @PropertyOption(name = "info", value = "info"),  @PropertyOption(name = "warn", value = "warn"),
+            @PropertyOption(name = "error", value = "error")},
+            value = "info",
+            label = "Log Level", description = "The log level recorded in the transient log accessible via http."
+    )
+    public static final String LOG_LEVEL = AbstractDistributionAgentFactory.LOG_LEVEL;
+
 
     @Property(boolValue = true, label = "Queue Processing Enabled", description = "Whether or not the distribution agent should process packages in the queues.")
     public static final String QUEUE_PROCESSING_ENABLED = "queue.processing.enabled";
@@ -153,7 +163,7 @@ public class ReverseDistributionAgentFac
     }
 
     @Override
-    protected SimpleDistributionAgent createAgent(String agentName, BundleContext context, Map<String, Object> config) {
+    protected SimpleDistributionAgent createAgent(String agentName, BundleContext context, Map<String, Object> config, DefaultDistributionLog distributionLog) {
         String serviceName = PropertiesUtil.toString(config.get(SERVICE_NAME), null);
         boolean queueProcessingEnabled = PropertiesUtil.toBoolean(config.get(QUEUE_PROCESSING_ENABLED), true);
 
@@ -172,7 +182,7 @@ public class ReverseDistributionAgentFac
 
         return new SimpleDistributionAgent(agentName, queueProcessingEnabled, serviceName,
                 packageImporter, packageExporter, requestAuthorizationStrategy,
-                queueProvider, dispatchingStrategy, distributionEventFactory, resourceResolverFactory);
+                queueProvider, dispatchingStrategy, distributionEventFactory, resourceResolverFactory, distributionLog);
 
 
     }

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/SimpleDistributionAgent.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/SimpleDistributionAgent.java?rev=1654776&r1=1654775&r2=1654776&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/SimpleDistributionAgent.java (original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/SimpleDistributionAgent.java Mon Jan 26 12:24:21 2015
@@ -19,7 +19,6 @@
 package org.apache.sling.distribution.agent.impl;
 
 import javax.annotation.Nonnull;
-import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.HashMap;
@@ -31,15 +30,20 @@ import org.apache.sling.api.resource.Log
 import org.apache.sling.api.resource.PersistenceException;
 import org.apache.sling.api.resource.ResourceResolver;
 import org.apache.sling.api.resource.ResourceResolverFactory;
+import org.apache.sling.distribution.DistributionRequestType;
 import org.apache.sling.distribution.agent.DistributionAgent;
 import org.apache.sling.distribution.agent.DistributionAgentException;
 
 import org.apache.sling.distribution.DistributionRequest;
 import org.apache.sling.distribution.DistributionRequestState;
 import org.apache.sling.distribution.DistributionResponse;
+import org.apache.sling.distribution.component.impl.DistributionComponentKind;
+import org.apache.sling.distribution.impl.CompositeDistributionResponse;
 import org.apache.sling.distribution.impl.SimpleDistributionResponse;
 import org.apache.sling.distribution.event.DistributionEventType;
 import org.apache.sling.distribution.event.impl.DistributionEventFactory;
+import org.apache.sling.distribution.log.DistributionLog;
+import org.apache.sling.distribution.log.impl.DefaultDistributionLog;
 import org.apache.sling.distribution.packaging.DistributionPackage;
 import org.apache.sling.distribution.packaging.DistributionPackageExportException;
 import org.apache.sling.distribution.packaging.DistributionPackageExporter;
@@ -56,8 +60,6 @@ import org.apache.sling.distribution.que
 import org.apache.sling.distribution.trigger.DistributionRequestHandler;
 import org.apache.sling.distribution.trigger.DistributionTrigger;
 import org.apache.sling.distribution.trigger.DistributionTriggerException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 import static org.apache.sling.distribution.queue.DistributionQueueItemStatus.ItemState;
 
@@ -66,8 +68,6 @@ import static org.apache.sling.distribut
  */
 public class SimpleDistributionAgent implements DistributionAgent {
 
-    private final Logger log = LoggerFactory.getLogger(getClass());
-
     private final DistributionQueueProvider queueProvider;
 
     private final boolean queueProcessingEnabled;
@@ -85,6 +85,7 @@ public class SimpleDistributionAgent imp
     private final String subServiceName;
     private AgentBasedRequestHandler agentBasedRequestHandler;
     private boolean active = false;
+    private final DefaultDistributionLog log;
 
     public SimpleDistributionAgent(String name,
                                    boolean queueProcessingEnabled,
@@ -95,7 +96,9 @@ public class SimpleDistributionAgent imp
                                    DistributionQueueProvider queueProvider,
                                    DistributionQueueDispatchingStrategy queueDistributionStrategy,
                                    DistributionEventFactory distributionEventFactory,
-                                   ResourceResolverFactory resourceResolverFactory) {
+                                   ResourceResolverFactory resourceResolverFactory,
+                                   DefaultDistributionLog log) {
+        this.log = log;
 
         // check configuration is valid
         if (name == null
@@ -130,6 +133,8 @@ public class SimpleDistributionAgent imp
         this.queueProvider = queueProvider;
         this.queueDistributionStrategy = queueDistributionStrategy;
         this.distributionEventFactory = distributionEventFactory;
+
+
     }
 
     @Nonnull
@@ -139,15 +144,25 @@ public class SimpleDistributionAgent imp
         ResourceResolver agentResourceResolver = null;
 
         try {
+            boolean silent = DistributionRequestType.PULL.equals(distributionRequest.getRequestType());
+
+            log.info(silent, "starting request {}", distributionRequest);
+
             agentResourceResolver = getAgentResourceResolver();
 
             distributionRequestAuthorizationStrategy.checkPermission(resourceResolver, distributionRequest);
 
             List<DistributionPackage> distributionPackages = exportPackages(agentResourceResolver, distributionRequest);
 
-            return scheduleImport(distributionPackages);
+            log.debug("exported packages {}", distributionPackages.size());
+
+            DistributionResponse distributionResponse = scheduleImportPackages(distributionPackages);
+
+            log.info(silent, "returning response {}", distributionResponse);
+
+            return distributionResponse;
         } catch (Exception e) {
-            log.error("Error executing distribution request {} in agent " + name, distributionRequest, e);
+            log.error("Error executing distribution request {} {}", distributionRequest, e);
             throw new DistributionAgentException(e);
         } finally {
             ungetAgentResourceResolver(agentResourceResolver);
@@ -168,18 +183,19 @@ public class SimpleDistributionAgent imp
         return distributionPackages;
     }
 
-    private DistributionResponse scheduleImport(List<DistributionPackage> distributionPackages) {
+    private DistributionResponse scheduleImportPackages(List<DistributionPackage> distributionPackages) {
         List<DistributionResponse> distributionResponses = new LinkedList<DistributionResponse>();
 
         for (DistributionPackage distributionPackage : distributionPackages) {
-            distributionResponses.addAll(schedule(distributionPackage));
+            Collection<SimpleDistributionResponse> distributionResponsesForPackage = scheduleImportPackage(distributionPackage);
+            distributionResponses.addAll(distributionResponsesForPackage);
         }
         return distributionResponses.size() == 1 ? distributionResponses.get(0) : new CompositeDistributionResponse(distributionResponses);
     }
 
-    private Collection<DistributionResponse> schedule(DistributionPackage distributionPackage) {
-        Collection<DistributionResponse> distributionResponses = new LinkedList<DistributionResponse>();
-        log.info("scheduling distribution of package {}", distributionPackage);
+    private Collection<SimpleDistributionResponse> scheduleImportPackage(DistributionPackage distributionPackage) {
+        Collection<SimpleDistributionResponse> distributionResponses = new LinkedList<SimpleDistributionResponse>();
+        log.debug("scheduling distribution of package {} {}", distributionPackage.getId(), distributionPackage);
 
         // dispatch the distribution package to the queue distribution handler
         try {
@@ -198,37 +214,6 @@ public class SimpleDistributionAgent imp
         return distributionResponses;
     }
 
-    /* Convert the state of a certain item in the queue into a request state */
-    private DistributionRequestState getRequestStateFromQueueState(ItemState itemState) {
-        DistributionRequestState requestState;
-        switch (itemState) {
-            case QUEUED:
-                requestState = DistributionRequestState.ACCEPTED;
-                break;
-            case ACTIVE:
-                requestState = DistributionRequestState.ACCEPTED;
-                break;
-            case SUCCEEDED:
-                requestState = DistributionRequestState.DISTRIBUTED;
-                break;
-            case STOPPED:
-                requestState = DistributionRequestState.DROPPED;
-                break;
-            case GIVEN_UP:
-                requestState = DistributionRequestState.DROPPED;
-                break;
-            case ERROR:
-                requestState = DistributionRequestState.DROPPED;
-                break;
-            case DROPPED:
-                requestState = DistributionRequestState.DROPPED;
-                break;
-            default:
-                requestState = DistributionRequestState.DROPPED;
-                break;
-        }
-        return requestState;
-    }
 
     @Nonnull
     public Iterable<String> getQueueNames() {
@@ -249,6 +234,11 @@ public class SimpleDistributionAgent imp
         return queue;
     }
 
+    @Nonnull
+    public DistributionLog getLog() {
+        return log;
+    }
+
 
     public void enable() {
         log.info("enabling agent");
@@ -312,7 +302,6 @@ public class SimpleDistributionAgent imp
 
     private boolean processQueue(String queueName, DistributionQueueItem queueItem) {
         boolean success = false;
-        log.debug("reading package with id {}", queueItem.getId());
         ResourceResolver agentResourceResolver = null;
         try {
 
@@ -329,8 +318,10 @@ public class SimpleDistributionAgent imp
 
                 if (distributionPackage instanceof SharedDistributionPackage) {
                     ((SharedDistributionPackage) distributionPackage).release(queueName);
+                    log.debug("package {} released from queue {}", distributionPackage.getId(), queueName);
                 } else {
                     distributionPackage.delete();
+                    log.debug("package {} deleted", distributionPackage.getId());
                 }
                 success = true;
             } else {
@@ -374,9 +365,21 @@ public class SimpleDistributionAgent imp
     }
 
     class PackageQueueProcessor implements DistributionQueueProcessor {
-        public boolean process(@Nonnull String queueName, @Nonnull DistributionQueueItem packageInfo) {
-            log.info("running package queue processor for queue {}", queueName);
-            return processQueue(queueName, packageInfo);
+        public boolean process(@Nonnull String queueName, @Nonnull DistributionQueueItem queueItem) {
+            try {
+
+                log.info("queue {} processing item {}", queueName, queueItem);
+
+                boolean success = processQueue(queueName, queueItem);
+
+                log.info("queue {} processing item ended with status {}", queueName, success);
+
+                return success;
+
+            } catch (Throwable e) {
+                log.error("queue {} error while processing item {}", queueName, queueItem);
+                return false;
+            }
         }
     }
 
@@ -390,7 +393,7 @@ public class SimpleDistributionAgent imp
         public void handle(@Nonnull DistributionRequest request) {
 
             if (!active) {
-                log.debug("skipping agent handler as agent {} is disabled", name);
+                log.warn("skipping agent handler as agent is disabled");
                 return;
             }
 
@@ -408,67 +411,38 @@ public class SimpleDistributionAgent imp
         }
     }
 
-    private class CompositeDistributionResponse extends SimpleDistributionResponse {
-
-        private DistributionRequestState state;
-
-        private String message;
-
-        public CompositeDistributionResponse(List<DistributionResponse> distributionResponses) {
-            super(DistributionRequestState.DROPPED, null);
-            if (distributionResponses.isEmpty()) {
-                state = DistributionRequestState.DROPPED;
-                message = "empty response";
-            } else {
-                state = DistributionRequestState.DISTRIBUTED;
-                StringBuilder messageBuilder = new StringBuilder("[");
-                for (DistributionResponse response : distributionResponses) {
-                    state = aggregatedState(state, response.getState());
-                    messageBuilder.append(response.getMessage()).append(", ");
-                }
-                int lof = messageBuilder.lastIndexOf(", ");
-                messageBuilder.replace(lof, lof + 2, "]");
-                message = messageBuilder.toString();
-            }
-        }
 
-        @Override
-        public boolean isSuccessful() {
-            return !DistributionRequestState.DROPPED.equals(state);
-        }
 
-        @Nonnull
-        @Override
-        public DistributionRequestState getState() {
-            return state;
-        }
-
-        @Override
-        public String getMessage() {
-            return message;
-        }
-    }
-
-    /* Provide the aggregated state of two {@link org.apache.sling.distribution.DistributionRequestState}s */
-    private DistributionRequestState aggregatedState(DistributionRequestState first, DistributionRequestState second) {
-        DistributionRequestState aggregatedState;
-        switch (second) {
-            case DISTRIBUTED:
-                aggregatedState = first;
+    /* Convert the state of a certain item in the queue into a request state */
+    private DistributionRequestState getRequestStateFromQueueState(ItemState itemState) {
+        DistributionRequestState requestState;
+        switch (itemState) {
+            case QUEUED:
+                requestState = DistributionRequestState.ACCEPTED;
                 break;
-            case DROPPED:
-                aggregatedState = DistributionRequestState.DISTRIBUTED;
+            case ACTIVE:
+                requestState = DistributionRequestState.ACCEPTED;
                 break;
-            case ACCEPTED:
-                if (first.equals(DistributionRequestState.DISTRIBUTED)) {
-                    aggregatedState = DistributionRequestState.ACCEPTED;
-                } else {
-                    aggregatedState = first;
-                }
+            case SUCCEEDED:
+                requestState = DistributionRequestState.DISTRIBUTED;
+                break;
+            case STOPPED:
+                requestState = DistributionRequestState.DROPPED;
+                break;
+            case GIVEN_UP:
+                requestState = DistributionRequestState.DROPPED;
+                break;
+            case ERROR:
+                requestState = DistributionRequestState.DROPPED;
+                break;
+            case DROPPED:
+                requestState = DistributionRequestState.DROPPED;
                 break;
             default:
-                aggregatedState = DistributionRequestState.DROPPED;
+                requestState = DistributionRequestState.DROPPED;
+                break;
         }
-        return aggregatedState;
+        return requestState;
     }
+
 }

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/SimpleDistributionAgentFactory.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/SimpleDistributionAgentFactory.java?rev=1654776&r1=1654775&r2=1654776&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/SimpleDistributionAgentFactory.java (original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/SimpleDistributionAgentFactory.java Mon Jan 26 12:24:21 2015
@@ -25,6 +25,7 @@ import org.apache.felix.scr.annotations.
 import org.apache.felix.scr.annotations.ConfigurationPolicy;
 import org.apache.felix.scr.annotations.Deactivate;
 import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.PropertyOption;
 import org.apache.felix.scr.annotations.Reference;
 import org.apache.felix.scr.annotations.ReferenceCardinality;
 import org.apache.felix.scr.annotations.ReferencePolicy;
@@ -32,6 +33,7 @@ import org.apache.sling.api.resource.Res
 import org.apache.sling.commons.osgi.PropertiesUtil;
 import org.apache.sling.distribution.component.impl.DistributionComponentUtils;
 import org.apache.sling.distribution.event.impl.DistributionEventFactory;
+import org.apache.sling.distribution.log.impl.DefaultDistributionLog;
 import org.apache.sling.distribution.packaging.DistributionPackageExporter;
 import org.apache.sling.distribution.packaging.DistributionPackageImporter;
 import org.apache.sling.distribution.queue.impl.DistributionQueueDispatchingStrategy;
@@ -72,6 +74,14 @@ public class SimpleDistributionAgentFact
     @Property(label = "Service Name", description = "The name of the service used to access the repository.")
     public static final String SERVICE_NAME = "serviceName";
 
+    @Property(options = {
+            @PropertyOption(name = "debug", value = "debug"), @PropertyOption(name = "info", value = "info"),  @PropertyOption(name = "warn", value = "warn"),
+            @PropertyOption(name = "error", value = "error")},
+            value = "info",
+            label = "Log Level", description = "The log level recorded in the transient log accessible via http."
+    )
+    public static final String LOG_LEVEL = AbstractDistributionAgentFactory.LOG_LEVEL;
+
 
     @Property(boolValue = true, label = "Queue Processing Enabled", description = "Whether or not the distribution agent should process packages in the queues.")
     public static final String QUEUE_PROCESSING_ENABLED = "queue.processing.enabled";
@@ -134,7 +144,7 @@ public class SimpleDistributionAgentFact
     }
 
     @Override
-    protected SimpleDistributionAgent createAgent(String agentName, BundleContext context, Map<String, Object> config) {
+    protected SimpleDistributionAgent createAgent(String agentName, BundleContext context, Map<String, Object> config, DefaultDistributionLog distributionLog) {
         String serviceName = PropertiesUtil.toString(config.get(SERVICE_NAME), null);
 
         boolean queueProcessingEnabled = PropertiesUtil.toBoolean(config.get(QUEUE_PROCESSING_ENABLED), true);
@@ -143,7 +153,7 @@ public class SimpleDistributionAgentFact
         DistributionQueueDispatchingStrategy dispatchingStrategy = new SingleQueueDispatchingStrategy();
         return new SimpleDistributionAgent(agentName, queueProcessingEnabled, serviceName,
                 packageImporter, packageExporter, requestAuthorizationStrategy,
-                queueProvider, dispatchingStrategy, distributionEventFactory, resourceResolverFactory);
+                queueProvider, dispatchingStrategy, distributionEventFactory, resourceResolverFactory, distributionLog);
 
     }
 }

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/SyncDistributionAgentFactory.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/SyncDistributionAgentFactory.java?rev=1654776&r1=1654775&r2=1654776&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/SyncDistributionAgentFactory.java (original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/SyncDistributionAgentFactory.java Mon Jan 26 12:24:21 2015
@@ -23,15 +23,18 @@ import org.apache.felix.scr.annotations.
 import org.apache.felix.scr.annotations.ConfigurationPolicy;
 import org.apache.felix.scr.annotations.Deactivate;
 import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.PropertyOption;
 import org.apache.felix.scr.annotations.Reference;
 import org.apache.felix.scr.annotations.ReferenceCardinality;
 import org.apache.felix.scr.annotations.ReferencePolicy;
 import org.apache.jackrabbit.vault.packaging.Packaging;
 import org.apache.sling.api.resource.ResourceResolverFactory;
 import org.apache.sling.commons.osgi.PropertiesUtil;
+import org.apache.sling.distribution.component.impl.DistributionComponentKind;
 import org.apache.sling.distribution.component.impl.DistributionComponentUtils;
 import org.apache.sling.distribution.component.impl.SettingsUtils;
 import org.apache.sling.distribution.event.impl.DistributionEventFactory;
+import org.apache.sling.distribution.log.impl.DefaultDistributionLog;
 import org.apache.sling.distribution.packaging.DistributionPackageExporter;
 import org.apache.sling.distribution.packaging.DistributionPackageImporter;
 import org.apache.sling.distribution.packaging.impl.exporter.RemoteDistributionPackageExporter;
@@ -79,6 +82,16 @@ public class SyncDistributionAgentFactor
     @Property(label = "Service Name", description = "The name of the service used to access the repository.")
     public static final String SERVICE_NAME = "serviceName";
 
+    @Property(options = {
+            @PropertyOption(name = "debug", value = "debug"), @PropertyOption(name = "info", value = "info"),  @PropertyOption(name = "warn", value = "warn"),
+            @PropertyOption(name = "error", value = "error")},
+            value = "info",
+            label = "Log Level", description = "The log level recorded in the transient log accessible via http."
+    )
+    public static final String LOG_LEVEL = AbstractDistributionAgentFactory.LOG_LEVEL;
+
+
+
     @Property(boolValue = true, label = "Queue Processing Enabled", description = "Whether or not the distribution agent should process packages in the queues.")
     public static final String QUEUE_PROCESSING_ENABLED = "queue.processing.enabled";
 
@@ -159,7 +172,7 @@ public class SyncDistributionAgentFactor
 
 
     @Override
-    protected SimpleDistributionAgent createAgent(String agentName, BundleContext context, Map<String, Object> config) {
+    protected SimpleDistributionAgent createAgent(String agentName, BundleContext context, Map<String, Object> config, DefaultDistributionLog distributionLog) {
         String serviceName = PropertiesUtil.toString(config.get(SERVICE_NAME), null);
         boolean queueProcessingEnabled = PropertiesUtil.toBoolean(config.get(QUEUE_PROCESSING_ENABLED), true);
 
@@ -189,9 +202,10 @@ public class SyncDistributionAgentFactor
         DistributionPackageExporter packageExporter = new RemoteDistributionPackageExporter(packageBuilder, transportSecretProvider, exporterEndpoints, TransportEndpointStrategyType.All, 1);
         DistributionQueueProvider queueProvider =  new JobHandlingDistributionQueueProvider(agentName, jobManager, context);
 
+
         return new SimpleDistributionAgent(agentName, queueProcessingEnabled, serviceName,
                 packageImporter, packageExporter, requestAuthorizationStrategy,
-                queueProvider, dispatchingStrategy, distributionEventFactory, resourceResolverFactory);
+                queueProvider, dispatchingStrategy, distributionEventFactory, resourceResolverFactory, distributionLog);
 
     }
 }

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/component/impl/DefaultDistributionConfigurationManager.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/component/impl/DefaultDistributionConfigurationManager.java?rev=1654776&r1=1654775&r2=1654776&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/component/impl/DefaultDistributionConfigurationManager.java (original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/component/impl/DefaultDistributionConfigurationManager.java Mon Jan 26 12:24:21 2015
@@ -188,7 +188,9 @@ public class DefaultDistributionConfigur
                 result.addAll(Arrays.asList(configurations));
             }
         } catch (IOException e) {
+            log.error("cannot get osgi configs", e);
         } catch (InvalidSyntaxException e) {
+            log.error("cannot parse filter", e);
         }
 
         return result;

Added: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/impl/CompositeDistributionResponse.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/impl/CompositeDistributionResponse.java?rev=1654776&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/impl/CompositeDistributionResponse.java (added)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/impl/CompositeDistributionResponse.java Mon Jan 26 12:24:21 2015
@@ -0,0 +1,101 @@
+/*
+ * 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.impl;
+
+
+import org.apache.sling.distribution.DistributionRequestState;
+import org.apache.sling.distribution.DistributionResponse;
+
+import javax.annotation.Nonnull;
+import java.util.List;
+
+public class CompositeDistributionResponse extends SimpleDistributionResponse {
+
+    private DistributionRequestState state;
+
+    private String message;
+
+    public CompositeDistributionResponse(List<DistributionResponse> distributionResponses) {
+        super(DistributionRequestState.DISTRIBUTED, null);
+        if (distributionResponses.isEmpty()) {
+            state = DistributionRequestState.DROPPED;
+        } else {
+            state = DistributionRequestState.DISTRIBUTED;
+            StringBuilder messageBuilder = new StringBuilder("[");
+            for (DistributionResponse response : distributionResponses) {
+                state = aggregatedState(state, response.getState());
+                messageBuilder.append(response.getMessage()).append(", ");
+            }
+            int lof = messageBuilder.lastIndexOf(", ");
+            messageBuilder.replace(lof, lof + 2, "]");
+            message = messageBuilder.toString();
+        }
+    }
+
+    @Override
+    public boolean isSuccessful() {
+        return !DistributionRequestState.DROPPED.equals(state);
+    }
+
+    @Nonnull
+    @Override
+    public DistributionRequestState getState() {
+        return state;
+    }
+
+    @Override
+    public String getMessage() {
+        return message;
+    }
+
+    @Override
+    public String toString() {
+        return "CompositeDistributionResponse{" +
+                "isSuccesful=" + isSuccessful() +
+                ", state=" + state +
+                ", message=" + message +
+                '}';
+    }
+
+
+
+    /* Provide the aggregated state of two {@link org.apache.sling.distribution.DistributionRequestState}s */
+    private DistributionRequestState aggregatedState(DistributionRequestState first, DistributionRequestState second) {
+        DistributionRequestState aggregatedState;
+        switch (second) {
+            case DISTRIBUTED:
+                aggregatedState = first;
+                break;
+            case DROPPED:
+                aggregatedState = DistributionRequestState.DISTRIBUTED;
+                break;
+            case ACCEPTED:
+                if (first.equals(DistributionRequestState.DISTRIBUTED)) {
+                    aggregatedState = DistributionRequestState.ACCEPTED;
+                } else {
+                    aggregatedState = first;
+                }
+                break;
+            default:
+                aggregatedState = DistributionRequestState.DROPPED;
+        }
+        return aggregatedState;
+    }
+}

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/impl/SimpleDistributionResponse.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/impl/SimpleDistributionResponse.java?rev=1654776&r1=1654775&r2=1654776&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/impl/SimpleDistributionResponse.java (original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/impl/SimpleDistributionResponse.java Mon Jan 26 12:24:21 2015
@@ -51,4 +51,14 @@ public class SimpleDistributionResponse
     public String getMessage() {
         return message;
     }
+
+    @Override
+    public String toString() {
+        return "CompositeDistributionResponse{" +
+                "isSuccesful=" + isSuccessful() +
+                ", state=" + state +
+                ", message=" + message +
+                '}';
+    }
+
 }

Added: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/log/DistributionLog.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/log/DistributionLog.java?rev=1654776&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/log/DistributionLog.java (added)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/log/DistributionLog.java Mon Jan 26 12:24:21 2015
@@ -0,0 +1,29 @@
+/*
+ * 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.log;
+
+
+
+import java.util.List;
+
+public interface DistributionLog {
+
+    List<String> getLines();
+}

Added: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/log/impl/DefaultDistributionLog.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/log/impl/DefaultDistributionLog.java?rev=1654776&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/log/impl/DefaultDistributionLog.java (added)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/log/impl/DefaultDistributionLog.java Mon Jan 26 12:24:21 2015
@@ -0,0 +1,159 @@
+/*
+ * 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.log.impl;
+
+import org.apache.sling.distribution.component.impl.DistributionComponentKind;
+import org.apache.sling.distribution.log.DistributionLog;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.slf4j.helpers.FormattingTuple;
+import org.slf4j.helpers.MessageFormatter;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.LinkedList;
+import java.util.List;
+
+
+public class DefaultDistributionLog implements DistributionLog {
+
+
+    private final DistributionComponentKind kind;
+    private final String name;
+    private int maxLines = 1000;
+    private final LinkedList<String> lines = new LinkedList<String>();
+    private final Logger logger;
+    private final LogLevel logLevel;
+
+    public DefaultDistributionLog(DistributionComponentKind kind, String name, Class clazz, LogLevel logLevel) {
+
+        this.kind = kind;
+        this.name = name;
+        this.logLevel = logLevel;
+        this.logger = LoggerFactory.getLogger(clazz);
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public DistributionComponentKind getKind() {
+        return kind;
+    }
+
+    public List<String> getLines() {
+        synchronized (lines) {
+            return new ArrayList<String>(lines);
+        }
+    }
+
+    private void internalLog(LogLevel level, String fmt, Object... objects) {
+        try {
+            FormattingTuple fmtp = MessageFormatter.arrayFormat(fmt, objects);
+            internalLog(level, fmtp.getMessage());
+        } catch (Throwable e) {
+            logger.error("cannot add entry log", e);
+        }
+    }
+
+    private void internalLog(LogLevel level, String message) {
+        if (level.cardinal < logLevel.cardinal) {
+            return;
+        }
+
+        DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss:SSS");
+        Calendar cal = Calendar.getInstance();
+
+
+        StringBuffer logLine = new StringBuffer();
+        logLine.append(dateFormat.format(cal.getTime()));
+        logLine.append(" - ");
+        logLine.append(level.name());
+        logLine.append(" - ");
+        logLine.append(message);
+        String log = logLine.toString();
+        synchronized (lines) {
+            lines.add(log);
+            while (lines.size() > maxLines) {
+                lines.removeFirst();
+            }
+        }
+    }
+
+    public void error(String fmt, Object... objects) {
+        String specificFmt = getSpecificString(fmt);
+        logger.error(specificFmt, objects);
+        internalLog(LogLevel.ERROR, fmt, objects);
+    }
+
+    public void info(String fmt, Object... objects) {
+        String specificFmt =  getSpecificString(fmt);
+        logger.info(specificFmt, objects);
+        internalLog(LogLevel.INFO, fmt, objects);
+    }
+
+    public void info(boolean silent, String fmt, Object... objects) {
+        if (silent) {
+            debug(fmt, objects);
+        } else {
+            info(fmt, objects);
+        }
+    }
+
+    public void debug(String fmt, Object... objects) {
+        String specificFmt = getSpecificString(fmt);
+        logger.debug(specificFmt, objects);
+        internalLog(LogLevel.DEBUG, fmt, objects);
+    }
+
+    public void warn(String fmt, Object... objects) {
+        String specificFmt = getSpecificString(fmt);
+        logger.warn(specificFmt, objects);
+        internalLog(LogLevel.WARN, fmt, objects);
+    }
+
+
+    private String getSpecificString(String fmt) {
+        return "[" + kind.getName() + "][" + name + "] " + fmt;
+    }
+
+
+    /**
+     * Log level
+     */
+    public enum LogLevel {
+
+        DEBUG(0),
+
+        INFO(1),
+
+        WARN(2),
+
+        ERROR(3);
+
+        public final int cardinal;
+
+        LogLevel(int cardinal) {
+            this.cardinal = cardinal;
+        }
+    }
+}

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=1654776&r1=1654775&r2=1654776&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 Jan 26 12:24:21 2015
@@ -75,7 +75,7 @@ public class RemoteDistributionPackageIm
         try {
             transportHandler.deliverPackage(resourceResolver, distributionPackage, distributionTransportSecretProvider.getSecret());
         } catch (Exception e) {
-            throw new DistributionPackageImportException("failed in importing package " + distributionPackage);
+            throw new DistributionPackageImportException("failed in importing package " + distributionPackage, e);
         }
     }
 

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/resources/DistributionResourceTypes.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/resources/DistributionResourceTypes.java?rev=1654776&r1=1654775&r2=1654776&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/resources/DistributionResourceTypes.java (original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/resources/DistributionResourceTypes.java Mon Jan 26 12:24:21 2015
@@ -33,7 +33,7 @@ public class DistributionResourceTypes {
     public static final String AGENT_QUEUE_LIST_RESOURCE_TYPE = "sling/distribution/service/agent/queue/list";
     public static final String AGENT_QUEUE_ITEM_RESOURCE_TYPE = "sling/distribution/service/agent/queue/item";
 
-
+    public static final String LOG_RESOURCE_TYPE = "sling/distribution/service/log";
 
     public static final String IMPORTER_RESOURCE_TYPE = "sling/distribution/service/importer";
     public static final String IMPORTER_LIST_RESOURCE_TYPE = "sling/distribution/service/importer/list";

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/resources/impl/ExtendedDistributionServiceResourceProvider.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/resources/impl/ExtendedDistributionServiceResourceProvider.java?rev=1654776&r1=1654775&r2=1654776&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/resources/impl/ExtendedDistributionServiceResourceProvider.java (original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/resources/impl/ExtendedDistributionServiceResourceProvider.java Mon Jan 26 12:24:21 2015
@@ -24,6 +24,7 @@ import org.apache.sling.distribution.age
 import org.apache.sling.distribution.component.impl.DistributionComponent;
 import org.apache.sling.distribution.component.impl.DistributionComponentKind;
 import org.apache.sling.distribution.component.impl.DistributionComponentProvider;
+import org.apache.sling.distribution.log.DistributionLog;
 import org.apache.sling.distribution.queue.DistributionQueue;
 import org.apache.sling.distribution.queue.DistributionQueueException;
 import org.apache.sling.distribution.queue.DistributionQueueItem;
@@ -42,6 +43,8 @@ import java.util.Map;
 public class ExtendedDistributionServiceResourceProvider extends DistributionServiceResourceProvider {
 
     private static final String QUEUES_PATH = "queues";
+    private static final String LOG_PATH = "log";
+
     private static final int MAX_QUEUE_DEPTH = 100;
 
 
@@ -58,12 +61,21 @@ public class ExtendedDistributionService
         if (kind.equals(DistributionComponentKind.AGENT)) {
             DistributionAgent agent = (DistributionAgent) component.getService();
 
-            if (agent != null) {
+            if (agent != null && childResourceName != null) {
                 if (childResourceName.startsWith(QUEUES_PATH)) {
                     SimplePathInfo queuePathInfo = SimplePathInfo.parsePathInfo(QUEUES_PATH, childResourceName);
                     Map<String, Object> result = getQueueProperties(agent, queuePathInfo);
                     return result;
+                } else if (childResourceName.startsWith(LOG_PATH)) {
+                    Map<String, Object> result = new HashMap<String, Object>();
+                    result.put(SLING_RESOURCE_TYPE, DistributionResourceTypes.LOG_RESOURCE_TYPE);
+                    DistributionLog distributionLog = agent.getLog();
+
+                    result.put(ADAPTABLE_PROPERTY_NAME, distributionLog);
+
+                    return result;
                 }
+
             }
         }
         return null;
@@ -80,6 +92,7 @@ public class ExtendedDistributionService
                 if (childResourceName == null) {
                     List<String> nameList = new ArrayList<String>();
                     nameList.add(QUEUES_PATH);
+                    nameList.add(LOG_PATH);
                     return nameList;
                 }
             }
@@ -119,6 +132,7 @@ public class ExtendedDistributionService
                 result.put(ADAPTABLE_PROPERTY_NAME, queue);
 
             } catch (DistributionAgentException e) {
+                // do nothing
 
             }
 
@@ -149,8 +163,10 @@ public class ExtendedDistributionService
 
                 }
             } catch (DistributionAgentException e) {
+                // do nothing
 
             } catch (DistributionQueueException e) {
+                // do nothing
             }
             return result;
         }

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/serialization/impl/SimpleDistributionPackage.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/serialization/impl/SimpleDistributionPackage.java?rev=1654776&r1=1654775&r2=1654776&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/serialization/impl/SimpleDistributionPackage.java (original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/serialization/impl/SimpleDistributionPackage.java Mon Jan 26 12:24:21 2015
@@ -28,12 +28,16 @@ import org.apache.sling.distribution.Dis
 import org.apache.sling.distribution.DistributionRequestType;
 import org.apache.sling.distribution.SimpleDistributionRequest;
 import org.apache.sling.distribution.packaging.DistributionPackage;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * A simple {@link org.apache.sling.distribution.packaging.DistributionPackage} is used for deletion of certain paths on the target instance
  */
 public class SimpleDistributionPackage extends AbstractDistributionPackage implements DistributionPackage {
 
+    static Logger log = LoggerFactory.getLogger(SimpleDistributionPackage.class);
+
     private final static String PACKAGE_START = "DSTRPCK:";
     private final static String DELIM = "|";
     private final static String PATH_DELIM = ",";
@@ -157,8 +161,8 @@ public class SimpleDistributionPackage e
 
                 return fromIdString(streamString);
             }
-        } catch (Exception e) {
-
+        } catch (IOException e) {
+            log.error("cannot read stream", e);
         }
 
         return null;

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/serialization/impl/vlt/FileVaultDistributionPackage.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/serialization/impl/vlt/FileVaultDistributionPackage.java?rev=1654776&r1=1654775&r2=1654776&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/serialization/impl/vlt/FileVaultDistributionPackage.java (original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/serialization/impl/vlt/FileVaultDistributionPackage.java Mon Jan 26 12:24:21 2015
@@ -28,12 +28,16 @@ import org.apache.jackrabbit.vault.packa
 import org.apache.sling.distribution.DistributionRequestType;
 import org.apache.sling.distribution.packaging.DistributionPackage;
 import org.apache.sling.distribution.serialization.impl.AbstractDistributionPackage;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * a FileVault {@link org.apache.sling.distribution.packaging.DistributionPackage}
  */
 public class FileVaultDistributionPackage extends AbstractDistributionPackage implements DistributionPackage {
 
+    Logger log = LoggerFactory.getLogger(FileVaultDistributionPackage.class);
+
     private static final long serialVersionUID = 1L;
 
     private final String id;
@@ -76,7 +80,8 @@ public class FileVaultDistributionPackag
             if (file.exists()) {
                 file.delete();
             }
-        } catch (Exception e) {
+        } catch (Throwable e) {
+            log.error("cannot delete file", e);
         }
     }
 

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/serialization/impl/vlt/FileVaultDistributionPackageBuilder.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/serialization/impl/vlt/FileVaultDistributionPackageBuilder.java?rev=1654776&r1=1654775&r2=1654776&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/serialization/impl/vlt/FileVaultDistributionPackageBuilder.java (original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/serialization/impl/vlt/FileVaultDistributionPackageBuilder.java Mon Jan 26 12:24:21 2015
@@ -21,6 +21,7 @@ package org.apache.sling.distribution.se
 import javax.jcr.Session;
 import java.io.File;
 import java.io.FileOutputStream;
+import java.io.IOException;
 import java.io.InputStream;
 import java.util.UUID;
 
@@ -30,6 +31,7 @@ import org.apache.jackrabbit.vault.fs.ap
 import org.apache.jackrabbit.vault.fs.io.AccessControlHandling;
 import org.apache.jackrabbit.vault.fs.io.ImportOptions;
 import org.apache.jackrabbit.vault.packaging.ExportOptions;
+import org.apache.jackrabbit.vault.packaging.PackageException;
 import org.apache.jackrabbit.vault.packaging.Packaging;
 import org.apache.jackrabbit.vault.packaging.VaultPackage;
 import org.apache.sling.api.resource.ResourceResolver;
@@ -131,8 +133,8 @@ public class FileVaultDistributionPackag
                 VaultPackage pkg = packaging.getPackageManager().open(file);
                 distributionPackage = new FileVaultDistributionPackage(getType(), pkg);
             }
-        } catch (Exception e) {
-            log.warn("could not find a package with id : {}", id);
+        } catch (IOException e) {
+            log.warn("could not find a package with id {}", id, e);
         }
         return distributionPackage;
     }

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/serialization/impl/vlt/JcrVaultDistributionPackage.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/serialization/impl/vlt/JcrVaultDistributionPackage.java?rev=1654776&r1=1654775&r2=1654776&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/serialization/impl/vlt/JcrVaultDistributionPackage.java (original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/serialization/impl/vlt/JcrVaultDistributionPackage.java Mon Jan 26 12:24:21 2015
@@ -31,7 +31,7 @@ public class JcrVaultDistributionPackage
         String[] paths = new String[0];
         try {
             paths = VltUtils.getPaths(jcrPackage.getDefinition().getMetaInf());
-        } catch (Throwable e) {
+        } catch (RepositoryException e) {
             log.error("cannot read paths", e);
         }
         this.getInfo().setPaths(paths);

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/serialization/impl/vlt/JcrVaultDistributionPackageBuilder.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/serialization/impl/vlt/JcrVaultDistributionPackageBuilder.java?rev=1654776&r1=1654775&r2=1654776&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/serialization/impl/vlt/JcrVaultDistributionPackageBuilder.java (original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/serialization/impl/vlt/JcrVaultDistributionPackageBuilder.java Mon Jan 26 12:24:21 2015
@@ -20,7 +20,9 @@ import org.apache.sling.distribution.ser
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.jcr.RepositoryException;
 import javax.jcr.Session;
+import java.io.IOException;
 import java.io.InputStream;
 import java.util.UUID;
 /**
@@ -135,7 +137,8 @@ public class JcrVaultDistributionPackage
                 return null;
             }
             return new JcrVaultDistributionPackage(getType(), jcrPackage, session);
-        } catch (Exception e) {
+        } catch (RepositoryException e) {
+            log.error("cannot ge package with id {}", id, e);
             return null;
         } finally {
             ungetSession(session);

Added: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/servlet/DistributionAgentLogServlet.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/servlet/DistributionAgentLogServlet.java?rev=1654776&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/servlet/DistributionAgentLogServlet.java (added)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/servlet/DistributionAgentLogServlet.java Mon Jan 26 12:24:21 2015
@@ -0,0 +1,71 @@
+/*
+ * 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.servlet;
+
+import org.apache.felix.scr.annotations.sling.SlingServlet;
+import org.apache.sling.api.SlingHttpServletRequest;
+import org.apache.sling.api.SlingHttpServletResponse;
+import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.api.servlets.SlingAllMethodsServlet;
+import org.apache.sling.distribution.DistributionRequest;
+import org.apache.sling.distribution.DistributionResponse;
+import org.apache.sling.distribution.agent.DistributionAgent;
+import org.apache.sling.distribution.agent.DistributionAgentException;
+import org.apache.sling.distribution.log.DistributionLog;
+import org.apache.sling.distribution.resources.DistributionResourceTypes;
+import org.apache.sling.distribution.util.RequestUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.servlet.ServletException;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+/**
+ * Servlet to ask {@link org.apache.sling.distribution.agent.DistributionAgent}s to distribute (via HTTP POST).
+ */
+@SlingServlet(resourceTypes = DistributionResourceTypes.LOG_RESOURCE_TYPE, methods = "GET", extensions = "txt")
+public class DistributionAgentLogServlet extends SlingAllMethodsServlet {
+
+    private final Logger log = LoggerFactory.getLogger(getClass());
+
+    @Override
+    protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response)
+            throws ServletException, IOException {
+
+        response.setContentType("text/plain");
+
+        DistributionRequest distributionRequest = RequestUtils.fromServletRequest(request);
+
+        log.debug("distribution request : {}", distributionRequest);
+
+        DistributionLog distributionLog = request.getResource().adaptTo(DistributionLog.class);
+        PrintWriter writer = response.getWriter();
+
+        if (distributionLog != null) {
+            for (String line : distributionLog.getLines()) {
+                writer.append(line);
+                writer.append("\n");
+            }
+        } else {
+            response.setStatus(404);
+            writer.append("Agent not found");
+        }
+    }
+}

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/servlet/DistributionAgentRootServlet.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/servlet/DistributionAgentRootServlet.java?rev=1654776&r1=1654775&r2=1654776&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/servlet/DistributionAgentRootServlet.java (original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/servlet/DistributionAgentRootServlet.java Mon Jan 26 12:24:21 2015
@@ -67,7 +67,7 @@ public class DistributionAgentRootServle
         for (DistributionAgent agent : agents) {
             try {
                 agent.execute(resourceResolver, distributionRequest);
-            } catch (DistributionAgentException e) {
+            } catch (Throwable e) {
                 log.warn("agent {} execution failed", agent, e);
 
                 response.getWriter().append("error :'").append(e.toString()).append("'");

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/servlet/DistributionAgentServlet.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/servlet/DistributionAgentServlet.java?rev=1654776&r1=1654775&r2=1654776&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/servlet/DistributionAgentServlet.java (original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/servlet/DistributionAgentServlet.java Mon Jan 26 12:24:21 2015
@@ -84,5 +84,4 @@ public class DistributionAgentServlet ex
                     .append(" not found\"}");
         }
     }
-
 }

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/servlet/DistributionPackageExporterServlet.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/servlet/DistributionPackageExporterServlet.java?rev=1654776&r1=1654775&r2=1654776&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/servlet/DistributionPackageExporterServlet.java (original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/servlet/DistributionPackageExporterServlet.java Mon Jan 26 12:24:21 2015
@@ -101,9 +101,9 @@ public class DistributionPackageExporter
                 log.debug("nothing to fetch");
             }
 
-        } catch (Exception e) {
+        } catch (Throwable e) {
             response.setStatus(503);
-            log.error("error while exporting from {}", request.getRequestURL(), e);
+            log.error("error while exporting package", e);
         }
     }
 

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/servlet/DistributionPackageImporterServlet.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/servlet/DistributionPackageImporterServlet.java?rev=1654776&r1=1654775&r2=1654776&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/servlet/DistributionPackageImporterServlet.java (original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/servlet/DistributionPackageImporterServlet.java Mon Jan 26 12:24:21 2015
@@ -65,10 +65,10 @@ public class DistributionPackageImporter
                 response.setStatus(400);
                 response.getWriter().print("error: could not import a package from the request stream");
             }
-        } catch (final Exception e) {
+        } catch (final Throwable e) {
             response.setStatus(400);
             response.getWriter().print("error: " + e.toString());
-            log.error("Error during distribution import: {}", e.getMessage(), e);
+            log.error("Error during distribution import", e);
         } finally {
             long end = System.currentTimeMillis();
             log.info("Processed package import request in {} ms", end - start);

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/transport/impl/SimpleHttpDistributionTransport.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/transport/impl/SimpleHttpDistributionTransport.java?rev=1654776&r1=1654775&r2=1654776&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/transport/impl/SimpleHttpDistributionTransport.java (original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/transport/impl/SimpleHttpDistributionTransport.java Mon Jan 26 12:24:21 2015
@@ -148,12 +148,17 @@ public class SimpleHttpDistributionTrans
 
                         pulls++;
                     } else {
-                        log.info("");
+                        log.info("no entity available");
                         break;
                     }
                 }
 
-                log.info("pulled {} packages from {}", pulls, distributionEndpoint.getUri());
+                // only log.info when something is pulled in order to keep a quite log
+                if (pulls == 0) {
+                    log.debug("pulled {} packages from {}", pulls, distributionEndpoint.getUri());
+                } else {
+                    log.info("pulled {} packages from {}", pulls, distributionEndpoint.getUri());
+                }
 
             } catch (HttpHostConnectException e) {
                 log.info("could not connect to {} - skipping", distributionEndpoint.getUri());

Modified: sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/agent/impl/SimpleDistributionAgentTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/agent/impl/SimpleDistributionAgentTest.java?rev=1654776&r1=1654775&r2=1654776&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/agent/impl/SimpleDistributionAgentTest.java (original)
+++ sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/agent/impl/SimpleDistributionAgentTest.java Mon Jan 26 12:24:21 2015
@@ -28,6 +28,7 @@ import org.apache.sling.distribution.Dis
 import org.apache.sling.distribution.DistributionResponse;
 import org.apache.sling.distribution.SimpleDistributionRequest;
 import org.apache.sling.distribution.event.impl.DistributionEventFactory;
+import org.apache.sling.distribution.log.impl.DefaultDistributionLog;
 import org.apache.sling.distribution.packaging.DistributionPackage;
 import org.apache.sling.distribution.packaging.DistributionPackageExporter;
 import org.apache.sling.distribution.packaging.DistributionPackageImporter;
@@ -68,7 +69,7 @@ public class SimpleDistributionAgentTest
                 false, "serviceName", packageImporter,
                 packageExporter, packageExporterStrategy,
                 queueProvider, distributionHandler,
-                distributionEventFactory, resolverFactory);
+                distributionEventFactory, resolverFactory, mock(DefaultDistributionLog.class));
         DistributionRequest request = new SimpleDistributionRequest(DistributionRequestType.ADD, "/");
         DistributionPackage distributionPackage = mock(DistributionPackage.class);
         ResourceResolver resourceResolver = mock(ResourceResolver.class);
@@ -98,7 +99,7 @@ public class SimpleDistributionAgentTest
                 false, "subServiceName", packageImporter,
                 packageExporter, packageExporterStrategy,
                 queueProvider,
-                distributionHandler, distributionEventFactory, resolverFactory);
+                distributionHandler, distributionEventFactory, resolverFactory, mock(DefaultDistributionLog.class));
         DistributionRequest request = new SimpleDistributionRequest(DistributionRequestType.ADD, "/");
         DistributionPackage distributionPackage = mock(DistributionPackage.class);
         ResourceResolver resourceResolver = mock(ResourceResolver.class);
@@ -132,7 +133,7 @@ public class SimpleDistributionAgentTest
                 false, "serviceName", packageImporter,
                 packageExporter, packageExporterStrategy,
                 queueProvider, distributionHandler,
-                distributionEventFactory, resolverFactory);
+                distributionEventFactory, resolverFactory, mock(DefaultDistributionLog.class));
         DistributionRequest request = new SimpleDistributionRequest(DistributionRequestType.ADD, "/");
         DistributionPackage distributionPackage = mock(DistributionPackage.class);
         DistributionPackageInfo packageInfo = new DistributionPackageInfo();
@@ -162,7 +163,7 @@ public class SimpleDistributionAgentTest
                 false, "serviceName", packageImporter,
                 packageExporter, packageExporterStrategy,
                 queueProvider, distributionHandler,
-                distributionEventFactory, resolverFactory);
+                distributionEventFactory, resolverFactory, mock(DefaultDistributionLog.class));
         DistributionQueue queue = mock(DistributionQueue.class);
         when(queueProvider.getQueue(DistributionQueueDispatchingStrategy.DEFAULT_QUEUE_NAME))
                 .thenReturn(queue);
@@ -185,7 +186,7 @@ public class SimpleDistributionAgentTest
                 false, "serviceName", packageImporter,
                 packageExporter, packageExporterStrategy,
                 queueProvider, distributionHandler,
-                distributionEventFactory, resolverFactory);
+                distributionEventFactory, resolverFactory, mock(DefaultDistributionLog.class));
         DistributionQueue queue = mock(DistributionQueue.class);
         when(queueProvider.getQueue("priority")).thenReturn(queue);
         assertNotNull(agent.getQueue("priority"));
@@ -207,7 +208,7 @@ public class SimpleDistributionAgentTest
                 false, "serviceName", packageImporter,
                 packageExporter, packageExporterStrategy,
                 queueProvider, distributionHandler,
-                distributionEventFactory, resolverFactory);
+                distributionEventFactory, resolverFactory, mock(DefaultDistributionLog.class));
         DistributionQueue queue = mock(DistributionQueue.class);
         when(queueProvider.getQueue("priority")).thenReturn(queue);
         assertNull(agent.getQueue("weird"));



Mime
View raw message