sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mpet...@apache.org
Subject svn commit: r1650112 - in /sling/trunk/contrib/extensions/distribution: core/src/main/java/org/apache/sling/distribution/agent/impl/ it/src/main/java/ it/src/main/java/org/ it/src/main/java/org/apache/ it/src/main/java/org/apache/sling/ it/src/main/jav...
Date Wed, 07 Jan 2015 16:38:22 GMT
Author: mpetria
Date: Wed Jan  7 16:38:21 2015
New Revision: 1650112

URL: http://svn.apache.org/r1650112
Log:
SLING-4289: fixing trigger binding to be selective by default

Added:
    sling/trunk/contrib/extensions/distribution/it/src/main/java/
    sling/trunk/contrib/extensions/distribution/it/src/main/java/org/
    sling/trunk/contrib/extensions/distribution/it/src/main/java/org/apache/
    sling/trunk/contrib/extensions/distribution/it/src/main/java/org/apache/sling/
    sling/trunk/contrib/extensions/distribution/it/src/main/java/org/apache/sling/distribution/
    sling/trunk/contrib/extensions/distribution/it/src/main/java/org/apache/sling/distribution/test/
    sling/trunk/contrib/extensions/distribution/it/src/main/java/org/apache/sling/distribution/test/DistributorServlet.java
    sling/trunk/contrib/extensions/distribution/it/src/test/java/org/apache/sling/distribution/it/DistributorTest.java
Modified:
    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/SimpleDistributionAgentFactory.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/SyncDistributionAgentFactory.java
    sling/trunk/contrib/extensions/distribution/it/src/test/java/org/apache/sling/distribution/it/DistributionIntegrationTestBase.java

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=1650112&r1=1650111&r2=1650112&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
Wed Jan  7 16:38:21 2015
@@ -65,6 +65,8 @@ public abstract class AbstractDistributi
 
     private static final String ENABLED = "enabled";
 
+    protected static final String DEFAULT_TRIGGER_TARGET = "(name=)";
+
     private ServiceRegistration componentReg;
     private BundleContext savedContext;
     private Map<String, Object> savedConfig;

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=1650112&r1=1650111&r2=1650112&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
Wed Jan  7 16:38:21 2015
@@ -29,22 +29,17 @@ import org.apache.felix.scr.annotations.
 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.agent.DistributionAgent;
 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.packaging.DistributionPackageExporter;
 import org.apache.sling.distribution.packaging.DistributionPackageImporter;
 import org.apache.sling.distribution.packaging.impl.exporter.LocalDistributionPackageExporter;
-import org.apache.sling.distribution.packaging.impl.exporter.RemoteDistributionPackageExporter;
 import org.apache.sling.distribution.packaging.impl.importer.RemoteDistributionPackageImporter;
 import org.apache.sling.distribution.queue.DistributionQueueProvider;
 import org.apache.sling.distribution.queue.impl.DistributionQueueDispatchingStrategy;
 import org.apache.sling.distribution.queue.impl.MultipleQueueDispatchingStrategy;
-import org.apache.sling.distribution.queue.impl.SingleQueueDispatchingStrategy;
 import org.apache.sling.distribution.queue.impl.jobhandling.JobHandlingDistributionQueueProvider;
-import org.apache.sling.distribution.resources.DistributionConstants;
-import org.apache.sling.distribution.resources.impl.OsgiUtils;
 import org.apache.sling.distribution.serialization.DistributionPackageBuilder;
 import org.apache.sling.distribution.transport.DistributionTransportSecretProvider;
 import org.apache.sling.distribution.transport.impl.TransportEndpointStrategyType;
@@ -52,16 +47,10 @@ import org.apache.sling.distribution.tri
 import org.apache.sling.event.jobs.JobManager;
 import org.apache.sling.settings.SlingSettingsService;
 import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.ServiceRegistration;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.Dictionary;
-import java.util.Hashtable;
-import java.util.List;
 import java.util.Map;
-import java.util.concurrent.CopyOnWriteArrayList;
 
 /**
  * An OSGi service factory for {@link org.apache.sling.distribution.agent.DistributionAgent}s
which references already existing OSGi services.
@@ -112,6 +101,9 @@ public class ForwardDistributionAgentFac
     @Reference(name = "packageBuilder")
     private DistributionPackageBuilder packageBuilder;
 
+    @Property(value = DEFAULT_TRIGGER_TARGET)
+    public static final String TRIGGERS_TARGET = "triggers.target";
+
     @Reference
     private DistributionEventFactory distributionEventFactory;
 

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=1650112&r1=1650111&r2=1650112&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
Wed Jan  7 16:38:21 2015
@@ -26,44 +26,26 @@ import org.apache.felix.scr.annotations.
 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.fs.api.ImportMode;
-import org.apache.jackrabbit.vault.fs.io.AccessControlHandling;
 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.agent.DistributionAgent;
 import org.apache.sling.distribution.component.impl.DistributionComponentUtils;
 import org.apache.sling.distribution.event.impl.DistributionEventFactory;
 import org.apache.sling.distribution.packaging.DistributionPackageExporter;
-import org.apache.sling.distribution.packaging.DistributionPackageImporter;
 import org.apache.sling.distribution.packaging.impl.exporter.LocalDistributionPackageExporter;
-import org.apache.sling.distribution.packaging.impl.exporter.RemoteDistributionPackageExporter;
-import org.apache.sling.distribution.packaging.impl.importer.RemoteDistributionPackageImporter;
 import org.apache.sling.distribution.queue.impl.DistributionQueueDispatchingStrategy;
 import org.apache.sling.distribution.queue.DistributionQueueProvider;
 import org.apache.sling.distribution.queue.impl.SingleQueueDispatchingStrategy;
 import org.apache.sling.distribution.queue.impl.jobhandling.JobHandlingDistributionQueueProvider;
-import org.apache.sling.distribution.resources.DistributionConstants;
-import org.apache.sling.distribution.resources.impl.OsgiUtils;
 import org.apache.sling.distribution.serialization.DistributionPackageBuilder;
-import org.apache.sling.distribution.serialization.impl.ResourceSharedDistributionPackageBuilder;
-import org.apache.sling.distribution.serialization.impl.vlt.JcrVaultDistributionPackageBuilder;
-import org.apache.sling.distribution.transport.DistributionTransportSecretProvider;
-import org.apache.sling.distribution.transport.impl.TransportEndpointStrategyType;
 import org.apache.sling.distribution.trigger.DistributionTrigger;
 import org.apache.sling.event.jobs.JobManager;
 import org.apache.sling.settings.SlingSettingsService;
 import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.ServiceRegistration;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.Dictionary;
-import java.util.Hashtable;
-import java.util.List;
 import java.util.Map;
-import java.util.concurrent.CopyOnWriteArrayList;
 
 /**
  * An OSGi service factory for {@link org.apache.sling.distribution.agent.DistributionAgent}s
which references already existing OSGi services.
@@ -99,9 +81,12 @@ public class QueueDistributionAgentFacto
     private DistributionRequestAuthorizationStrategy requestAuthorizationStrategy;
 
 
-    @Property(name = "packageExporter.target")
-    @Reference(name = "packageExporter")
-    private DistributionPackageExporter packageExporter;
+    @Property(name = "packageBuilder.target")
+    @Reference(name = "packageBuilder")
+    private DistributionPackageBuilder packageBuilder;
+
+    @Property(value = DEFAULT_TRIGGER_TARGET)
+    public static final String TRIGGERS_TARGET = "triggers.target";
 
 
     @Reference
@@ -141,6 +126,7 @@ public class QueueDistributionAgentFacto
         String serviceName = PropertiesUtil.toString(config.get(SERVICE_NAME), null);
         DistributionQueueProvider queueProvider =  new JobHandlingDistributionQueueProvider(agentName,
jobManager, context);
         DistributionQueueDispatchingStrategy dispatchingStrategy = new SingleQueueDispatchingStrategy();
+        DistributionPackageExporter packageExporter = new LocalDistributionPackageExporter(packageBuilder);
 
         return new SimpleDistributionAgent(agentName, true, serviceName,
                 null, packageExporter, requestAuthorizationStrategy,

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=1650112&r1=1650111&r2=1650112&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
Wed Jan  7 16:38:21 2015
@@ -30,17 +30,13 @@ import org.apache.jackrabbit.vault.packa
 import org.apache.sling.api.resource.ResourceResolverFactory;
 import org.apache.sling.commons.osgi.PropertiesUtil;
 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.packaging.DistributionPackageExporter;
 import org.apache.sling.distribution.packaging.DistributionPackageImporter;
-import org.apache.sling.distribution.packaging.impl.exporter.LocalDistributionPackageExporter;
 import org.apache.sling.distribution.packaging.impl.exporter.RemoteDistributionPackageExporter;
 import org.apache.sling.distribution.packaging.impl.importer.LocalDistributionPackageImporter;
-import org.apache.sling.distribution.packaging.impl.importer.RemoteDistributionPackageImporter;
 import org.apache.sling.distribution.queue.DistributionQueueProvider;
 import org.apache.sling.distribution.queue.impl.DistributionQueueDispatchingStrategy;
-import org.apache.sling.distribution.queue.impl.MultipleQueueDispatchingStrategy;
 import org.apache.sling.distribution.queue.impl.SingleQueueDispatchingStrategy;
 import org.apache.sling.distribution.queue.impl.jobhandling.JobHandlingDistributionQueueProvider;
 import org.apache.sling.distribution.serialization.DistributionPackageBuilder;
@@ -111,6 +107,9 @@ public class ReverseDistributionAgentFac
     @Reference(name = "packageBuilder")
     private DistributionPackageBuilder packageBuilder;
 
+    @Property(value = DEFAULT_TRIGGER_TARGET)
+    public static final String TRIGGERS_TARGET = "triggers.target";
+
     @Reference
     private DistributionEventFactory distributionEventFactory;
 

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=1650112&r1=1650111&r2=1650112&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
Wed Jan  7 16:38:21 2015
@@ -18,11 +18,7 @@
  */
 package org.apache.sling.distribution.agent.impl;
 
-import java.util.Dictionary;
-import java.util.Hashtable;
-import java.util.List;
 import java.util.Map;
-import java.util.concurrent.CopyOnWriteArrayList;
 
 import org.apache.felix.scr.annotations.Activate;
 import org.apache.felix.scr.annotations.Component;
@@ -34,7 +30,6 @@ import org.apache.felix.scr.annotations.
 import org.apache.felix.scr.annotations.ReferencePolicy;
 import org.apache.sling.api.resource.ResourceResolverFactory;
 import org.apache.sling.commons.osgi.PropertiesUtil;
-import org.apache.sling.distribution.agent.DistributionAgent;
 import org.apache.sling.distribution.component.impl.DistributionComponentUtils;
 import org.apache.sling.distribution.event.impl.DistributionEventFactory;
 import org.apache.sling.distribution.packaging.DistributionPackageExporter;
@@ -43,14 +38,10 @@ import org.apache.sling.distribution.que
 import org.apache.sling.distribution.queue.DistributionQueueProvider;
 import org.apache.sling.distribution.queue.impl.SingleQueueDispatchingStrategy;
 import org.apache.sling.distribution.queue.impl.jobhandling.JobHandlingDistributionQueueProvider;
-import org.apache.sling.distribution.resources.DistributionConstants;
-import org.apache.sling.distribution.resources.impl.OsgiUtils;
 import org.apache.sling.distribution.trigger.DistributionTrigger;
 import org.apache.sling.event.jobs.JobManager;
 import org.apache.sling.settings.SlingSettingsService;
 import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.ServiceRegistration;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -97,6 +88,10 @@ public class SimpleDistributionAgentFact
     @Reference(name = "requestAuthorizationStrategy")
     private DistributionRequestAuthorizationStrategy requestAuthorizationStrategy;
 
+    @Property(value = DEFAULT_TRIGGER_TARGET)
+    public static final String TRIGGERS_TARGET = "triggers.target";
+
+
     @Reference
     private DistributionEventFactory distributionEventFactory;
 

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=1650112&r1=1650111&r2=1650112&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
Wed Jan  7 16:38:21 2015
@@ -26,12 +26,9 @@ import org.apache.felix.scr.annotations.
 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.fs.api.ImportMode;
-import org.apache.jackrabbit.vault.fs.io.AccessControlHandling;
 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.agent.DistributionAgent;
 import org.apache.sling.distribution.component.impl.DistributionComponentUtils;
 import org.apache.sling.distribution.component.impl.SettingsUtils;
 import org.apache.sling.distribution.event.impl.DistributionEventFactory;
@@ -43,28 +40,17 @@ import org.apache.sling.distribution.que
 import org.apache.sling.distribution.queue.DistributionQueueProvider;
 import org.apache.sling.distribution.queue.impl.SingleQueueDispatchingStrategy;
 import org.apache.sling.distribution.queue.impl.jobhandling.JobHandlingDistributionQueueProvider;
-import org.apache.sling.distribution.resources.DistributionConstants;
-import org.apache.sling.distribution.resources.impl.OsgiUtils;
 import org.apache.sling.distribution.serialization.DistributionPackageBuilder;
-import org.apache.sling.distribution.serialization.impl.ResourceSharedDistributionPackageBuilder;
-import org.apache.sling.distribution.serialization.impl.vlt.FileVaultDistributionPackageBuilder;
-import org.apache.sling.distribution.serialization.impl.vlt.JcrVaultDistributionPackageBuilder;
 import org.apache.sling.distribution.transport.DistributionTransportSecretProvider;
 import org.apache.sling.distribution.transport.impl.TransportEndpointStrategyType;
 import org.apache.sling.distribution.trigger.DistributionTrigger;
 import org.apache.sling.event.jobs.JobManager;
 import org.apache.sling.settings.SlingSettingsService;
 import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.ServiceRegistration;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.Dictionary;
-import java.util.Hashtable;
-import java.util.List;
 import java.util.Map;
-import java.util.concurrent.CopyOnWriteArrayList;
 
 /**
  * An OSGi service factory for {@link org.apache.sling.distribution.agent.DistributionAgent}s
which references already existing OSGi services.
@@ -121,6 +107,9 @@ public class SyncDistributionAgentFactor
     @Reference(name = "packageBuilder")
     private DistributionPackageBuilder packageBuilder;
 
+    @Property(value = DEFAULT_TRIGGER_TARGET)
+    public static final String TRIGGERS_TARGET = "triggers.target";
+
     @Reference
     private DistributionEventFactory distributionEventFactory;
 

Added: sling/trunk/contrib/extensions/distribution/it/src/main/java/org/apache/sling/distribution/test/DistributorServlet.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/it/src/main/java/org/apache/sling/distribution/test/DistributorServlet.java?rev=1650112&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/distribution/it/src/main/java/org/apache/sling/distribution/test/DistributorServlet.java
(added)
+++ sling/trunk/contrib/extensions/distribution/it/src/main/java/org/apache/sling/distribution/test/DistributorServlet.java
Wed Jan  7 16:38:21 2015
@@ -0,0 +1,74 @@
+/*
+ * 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.test;
+
+
+import org.apache.felix.scr.annotations.Reference;
+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.servlets.SlingAllMethodsServlet;
+import org.apache.sling.api.servlets.SlingSafeMethodsServlet;
+import org.apache.sling.distribution.DistributionRequest;
+import org.apache.sling.distribution.DistributionRequestType;
+import org.apache.sling.distribution.DistributionResponse;
+import org.apache.sling.distribution.Distributor;
+import org.apache.sling.distribution.SimpleDistributionRequest;
+
+import javax.servlet.ServletException;
+import java.io.IOException;
+
+@SlingServlet(paths = "/bin/test/distributor")
+public class DistributorServlet extends SlingAllMethodsServlet {
+
+
+    @Reference
+    Distributor distributor;
+
+
+    @Override
+    protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response)
throws ServletException, IOException {
+        doPost(request, response);
+    }
+
+    @Override
+    protected void doPost(SlingHttpServletRequest request, SlingHttpServletResponse response)
throws ServletException, IOException {
+
+        String action = request.getParameter("action");
+        String agentName = request.getParameter("agent");
+        String[] paths = request.getParameterValues("path");
+
+        if (agentName == null) {
+            response.getWriter().print("agent is required");
+            return;
+        }
+
+        DistributionRequest distributionRequest = new SimpleDistributionRequest(DistributionRequestType.fromName(action),
+                paths);
+
+        DistributionResponse distributionResponse = distributor.distribute(agentName, request.getResourceResolver(),
distributionRequest);
+
+        if (distributionResponse.isSuccessful()) {
+            response.setStatus(200);
+        }
+        else {
+            response.setStatus(400);
+        }
+    }
+}

Modified: sling/trunk/contrib/extensions/distribution/it/src/test/java/org/apache/sling/distribution/it/DistributionIntegrationTestBase.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/it/src/test/java/org/apache/sling/distribution/it/DistributionIntegrationTestBase.java?rev=1650112&r1=1650111&r2=1650112&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/it/src/test/java/org/apache/sling/distribution/it/DistributionIntegrationTestBase.java
(original)
+++ sling/trunk/contrib/extensions/distribution/it/src/test/java/org/apache/sling/distribution/it/DistributionIntegrationTestBase.java
Wed Jan  7 16:38:21 2015
@@ -44,8 +44,7 @@ public abstract class DistributionIntegr
     protected static SlingClient authorClient;
     protected static SlingClient publishClient;
 
-    @BeforeClass
-    public static void setUpBefore() {
+     static {
         SlingInstanceManager slingInstances = new SlingInstanceManager("author", "publish");
         author = slingInstances.getInstance("author");
         publish = slingInstances.getInstance("publish");
@@ -100,10 +99,5 @@ public abstract class DistributionIntegr
         }
 
     }
-
-    public static void setAuthorAgentProperties(String agentName, String... properties) throws
IOException {
-        assertPostResourceWithParameters(author, 200, authorAgentConfigUrl(agentName),
-                properties);
-    }
-
+    
 }

Added: sling/trunk/contrib/extensions/distribution/it/src/test/java/org/apache/sling/distribution/it/DistributorTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/it/src/test/java/org/apache/sling/distribution/it/DistributorTest.java?rev=1650112&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/distribution/it/src/test/java/org/apache/sling/distribution/it/DistributorTest.java
(added)
+++ sling/trunk/contrib/extensions/distribution/it/src/test/java/org/apache/sling/distribution/it/DistributorTest.java
Wed Jan  7 16:38:21 2015
@@ -0,0 +1,39 @@
+/*
+ * 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.it;
+
+import org.apache.sling.distribution.DistributionRequestType;
+import org.junit.Test;
+
+import static org.apache.sling.distribution.it.DistributionUtils.assertExists;
+import static org.apache.sling.distribution.it.DistributionUtils.assertPostResourceWithParameters;
+import static org.apache.sling.distribution.it.DistributionUtils.createRandomNode;
+
+public class DistributorTest extends DistributionIntegrationTestBase {
+
+    @Test
+    public void testAddContent() throws Exception {
+        String nodePath = createRandomNode(authorClient, "/content/forward_add_" + System.nanoTime());
+        assertExists(authorClient, nodePath);
+
+        assertPostResourceWithParameters(author, 200, "/bin/test/distributor", "agent", "publish",
+                "path", nodePath, "action", DistributionRequestType.ADD.name());
+        assertExists(publishClient, nodePath);
+    }
+}



Mime
View raw message