sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tomm...@apache.org
Subject svn commit: r1615572 [2/2] - in /sling/trunk/contrib/extensions/replication: core/src/main/java/org/apache/sling/replication/agent/impl/ core/src/main/java/org/apache/sling/replication/queue/ core/src/main/java/org/apache/sling/replication/queue/impl/j...
Date Mon, 04 Aug 2014 14:22:17 GMT
Added: sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/transport/impl/exporter/RemoteReplicationPackageExporter.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/transport/impl/exporter/RemoteReplicationPackageExporter.java?rev=1615572&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/transport/impl/exporter/RemoteReplicationPackageExporter.java (added)
+++ sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/transport/impl/exporter/RemoteReplicationPackageExporter.java Mon Aug  4 14:22:15 2014
@@ -0,0 +1,130 @@
+/*
+ * 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.replication.transport.impl.exporter;
+
+import org.apache.felix.scr.annotations.*;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.fluent.Executor;
+import org.apache.http.client.fluent.Request;
+import org.apache.http.conn.HttpHostConnectException;
+import org.apache.sling.commons.osgi.PropertiesUtil;
+import org.apache.sling.replication.agent.ReplicationAgentConfiguration;
+import org.apache.sling.replication.communication.ReplicationActionType;
+import org.apache.sling.replication.communication.ReplicationEndpoint;
+import org.apache.sling.replication.communication.ReplicationHeader;
+import org.apache.sling.replication.communication.ReplicationRequest;
+import org.apache.sling.replication.serialization.*;
+import org.apache.sling.replication.transport.authentication.TransportAuthenticationContext;
+import org.apache.sling.replication.transport.authentication.TransportAuthenticationProvider;
+import org.apache.sling.replication.transport.authentication.TransportAuthenticationProviderFactory;
+import org.apache.sling.replication.transport.authentication.impl.UserCredentialsTransportAuthenticationProviderFactory;
+import org.osgi.framework.BundleContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Map;
+
+/**
+ * Default implementation of {@link org.apache.sling.replication.serialization.ReplicationPackageExporter}
+ */
+@Component(label = "Remote Replication Package Exporter", configurationFactory = true)
+@Service(value = ReplicationPackageExporter.class)
+public class RemoteReplicationPackageExporter implements ReplicationPackageExporter {
+    private final Logger log = LoggerFactory.getLogger(getClass());
+
+    @Property
+    private static final String NAME = "name";
+
+    @Property(name = ReplicationAgentConfiguration.TRANSPORT_AUTHENTICATION_FACTORY)
+    @Reference(name = "TransportAuthenticationProviderFactory", policy = ReferencePolicy.DYNAMIC)
+    private TransportAuthenticationProviderFactory transportAuthenticationProviderFactory;
+
+
+    @Property(label = "Target ReplicationPackageBuilder", name = "ReplicationPackageBuilder.target")
+    @Reference(name = "ReplicationPackageBuilder", policy = ReferencePolicy.STATIC)
+    private ReplicationPackageBuilder packageBuilder;
+
+    TransportAuthenticationProvider<Executor, Executor>  transportAuthenticationProvider;
+    ReplicationEndpoint replicationEndpoint;
+
+    @Activate
+    protected void activate(BundleContext context, Map<String, ?> config) throws Exception {
+
+        Map<String, String> authenticationProperties = PropertiesUtil.toMap(config.get(ReplicationAgentConfiguration.AUTHENTICATION_PROPERTIES), new String[0]);
+
+        transportAuthenticationProvider = (TransportAuthenticationProvider<Executor, Executor>) transportAuthenticationProviderFactory.createAuthenticationProvider(authenticationProperties);
+
+        String[] endpoints = PropertiesUtil.toStringArray(config.get(ReplicationAgentConfiguration.ENDPOINT), new String[0]);
+
+        replicationEndpoint = new ReplicationEndpoint(endpoints[0]);
+
+    }
+
+    @Deactivate
+    protected void deactivate() {
+    }
+
+
+    public ReplicationPackage exportPackage(ReplicationRequest replicationRequest) throws ReplicationPackageBuildingException {
+
+        try {
+            return pollPackageFromEndpoint(replicationRequest, replicationEndpoint);
+        } catch (Exception e) {
+            throw new ReplicationPackageBuildingException(e);
+        }
+    }
+
+    public ReplicationPackage exportPackageById(String replicationPackageId) {
+        return packageBuilder.getPackage(replicationPackageId);
+    }
+
+
+    private ReplicationPackage pollPackageFromEndpoint(ReplicationRequest replicationRequest, ReplicationEndpoint replicationEndpoint)
+            throws Exception {
+        log.debug("polling from {}", replicationEndpoint.getUri());
+
+
+        Executor executor = Executor.newInstance();
+        TransportAuthenticationContext context = new TransportAuthenticationContext();
+        context.addAttribute("endpoint", replicationEndpoint);
+        executor = transportAuthenticationProvider.authenticate(executor, context);
+
+        Request req = Request.Post(replicationEndpoint.getUri())
+                .addHeader(ReplicationHeader.ACTION.toString(), ReplicationActionType.POLL.getName())
+                .useExpectContinue();
+        // TODO : add queue parameter
+
+        // continuously requests package streams as long as type header is received with the response (meaning there's a package of a certain type)
+        HttpResponse httpResponse;
+        try {
+            httpResponse = executor.execute(req).returnResponse();
+            if (httpResponse.containsHeader(ReplicationHeader.TYPE.toString())) {
+                ReplicationPackage responsePackage = packageBuilder.readPackage(httpResponse.getEntity().getContent());
+
+                return responsePackage;
+            }
+        } catch (HttpHostConnectException e) {
+            log.warn("could not connect to {} - skipping", replicationEndpoint.getUri());
+        }
+
+        return null;
+
+    }
+
+}

Propchange: sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/transport/impl/exporter/RemoteReplicationPackageExporter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/transport/impl/importer/RemoteReplicationPackageImporter.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/transport/impl/importer/RemoteReplicationPackageImporter.java?rev=1615572&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/transport/impl/importer/RemoteReplicationPackageImporter.java (added)
+++ sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/transport/impl/importer/RemoteReplicationPackageImporter.java Mon Aug  4 14:22:15 2014
@@ -0,0 +1,151 @@
+/*
+ * 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.replication.transport.impl.importer;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.felix.scr.annotations.*;
+import org.apache.http.client.fluent.Content;
+import org.apache.http.client.fluent.Executor;
+import org.apache.http.client.fluent.Request;
+import org.apache.http.client.fluent.Response;
+import org.apache.http.entity.ContentType;
+import org.apache.sling.commons.osgi.PropertiesUtil;
+import org.apache.sling.replication.agent.ReplicationAgentConfiguration;
+import org.apache.sling.replication.communication.ReplicationEndpoint;
+import org.apache.sling.replication.communication.ReplicationHeader;
+import org.apache.sling.replication.event.ReplicationEventFactory;
+import org.apache.sling.replication.event.ReplicationEventType;
+import org.apache.sling.replication.serialization.ReplicationPackage;
+import org.apache.sling.replication.serialization.ReplicationPackageBuildingException;
+import org.apache.sling.replication.serialization.ReplicationPackageImporter;
+import org.apache.sling.replication.serialization.ReplicationPackageReadingException;
+import org.apache.sling.replication.transport.TransportHandler;
+import org.apache.sling.replication.transport.authentication.TransportAuthenticationContext;
+import org.apache.sling.replication.transport.authentication.TransportAuthenticationProvider;
+import org.apache.sling.replication.transport.authentication.TransportAuthenticationProviderFactory;
+import org.apache.sling.replication.transport.authentication.impl.UserCredentialsTransportAuthenticationProviderFactory;
+import org.osgi.framework.BundleContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Arrays;
+import java.util.Dictionary;
+import java.util.Hashtable;
+import java.util.Map;
+
+/**
+ * Default implementation of {@link org.apache.sling.replication.serialization.ReplicationPackageImporter}
+ */
+@Component(label = "Remote Replication Package Importer", configurationFactory = true)
+@Service(value = ReplicationPackageImporter.class)
+public class RemoteReplicationPackageImporter implements ReplicationPackageImporter {
+
+    private final Logger log = LoggerFactory.getLogger(getClass());
+
+    @Property
+    private static final String NAME = "name";
+
+    @Property(name = ReplicationAgentConfiguration.TRANSPORT_AUTHENTICATION_FACTORY)
+    @Reference(name = "TransportAuthenticationProviderFactory", policy = ReferencePolicy.DYNAMIC)
+    private TransportAuthenticationProviderFactory transportAuthenticationProviderFactory;
+
+    @Reference
+    private ReplicationEventFactory replicationEventFactory;
+
+    TransportAuthenticationProvider<Executor, Executor>  transportAuthenticationProvider;
+    ReplicationEndpoint replicationEndpoint;
+
+    @Activate
+    protected void activate(BundleContext context, Map<String, ?> config) throws Exception {
+
+        Map<String, String> authenticationProperties = PropertiesUtil.toMap(config.get(ReplicationAgentConfiguration.AUTHENTICATION_PROPERTIES), new String[0]);
+
+        transportAuthenticationProvider = (TransportAuthenticationProvider<Executor, Executor>) transportAuthenticationProviderFactory.createAuthenticationProvider(authenticationProperties);
+
+        String[] endpoints = PropertiesUtil.toStringArray(config.get(ReplicationAgentConfiguration.ENDPOINT), new String[0]);
+
+        replicationEndpoint = new ReplicationEndpoint(endpoints[0]);
+    }
+
+
+    public boolean importPackage(ReplicationPackage replicationPackage) {
+
+        try {
+           deliverPackageToEndpoint(replicationPackage, replicationEndpoint);
+
+            return true;
+        } catch (Exception e) {
+
+        }
+
+        return false;
+    }
+
+    public ReplicationPackage readPackage(InputStream stream) throws ReplicationPackageReadingException {
+
+        return null;
+    }
+
+
+    public void deliverPackageToEndpoint(ReplicationPackage replicationPackage,
+                                         ReplicationEndpoint replicationEndpoint) throws Exception {
+        log.info("delivering package {} to {} using auth {}",
+                new Object[]{replicationPackage.getId(),
+                        replicationEndpoint.getUri(), transportAuthenticationProvider});
+
+
+        Executor executor = Executor.newInstance();
+        TransportAuthenticationContext context = new TransportAuthenticationContext();
+        context.addAttribute("endpoint", replicationEndpoint);
+        executor =  transportAuthenticationProvider.authenticate(executor, context);
+
+        Request req = Request.Post(replicationEndpoint.getUri()).useExpectContinue();
+
+
+        InputStream inputStream = null;
+        Response response = null;
+        try{
+
+            inputStream = replicationPackage.createInputStream();
+
+
+            if(inputStream != null) {
+                req = req.bodyStream(inputStream, ContentType.APPLICATION_OCTET_STREAM);
+            }
+
+            response = executor.execute(req);
+        }
+        finally {
+            IOUtils.closeQuietly(inputStream);
+        }
+
+        if (response != null) {
+            Content content = response.returnContent();
+            log.info("Replication content of type {} for {} delivered: {}", new Object[]{
+                    replicationPackage.getType(), Arrays.toString(replicationPackage.getPaths()), content});
+        }
+        else {
+            throw new IOException("response is empty");
+        }
+    }
+
+}

Propchange: sling/trunk/contrib/extensions/replication/core/src/main/java/org/apache/sling/replication/transport/impl/importer/RemoteReplicationPackageImporter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: sling/trunk/contrib/extensions/replication/core/src/main/resources/SLING-CONTENT/libs/sling/replication/config/author/org.apache.sling.replication.agent.impl.ReplicationAgentServiceFactory-publish-reverse.json
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/core/src/main/resources/SLING-CONTENT/libs/sling/replication/config/author/org.apache.sling.replication.agent.impl.ReplicationAgentServiceFactory-publish-reverse.json?rev=1615572&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/replication/core/src/main/resources/SLING-CONTENT/libs/sling/replication/config/author/org.apache.sling.replication.agent.impl.ReplicationAgentServiceFactory-publish-reverse.json (added)
+++ sling/trunk/contrib/extensions/replication/core/src/main/resources/SLING-CONTENT/libs/sling/replication/config/author/org.apache.sling.replication.agent.impl.ReplicationAgentServiceFactory-publish-reverse.json Mon Aug  4 14:22:15 2014
@@ -0,0 +1,10 @@
+{
+    "jcr:primaryType" : "sling:OsgiConfig",
+    "name" : "publish-reverse",
+    "ReplicationPackageExporter.target" : "(name=publish)",
+    "ReplicationPackageImporter.target" : "(name=default)",
+    "ReplicationQueueProvider.target" : "(name=sjh)",
+    "ReplicationQueueDistributionStrategy.target" : "(name=error)",
+    "rules" : ["scheduled poll every 30 sec"],
+    "runModes" : ["author"]
+}

Added: sling/trunk/contrib/extensions/replication/core/src/main/resources/SLING-CONTENT/libs/sling/replication/config/author/org.apache.sling.replication.agent.impl.ReplicationAgentServiceFactory-publish.json
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/core/src/main/resources/SLING-CONTENT/libs/sling/replication/config/author/org.apache.sling.replication.agent.impl.ReplicationAgentServiceFactory-publish.json?rev=1615572&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/replication/core/src/main/resources/SLING-CONTENT/libs/sling/replication/config/author/org.apache.sling.replication.agent.impl.ReplicationAgentServiceFactory-publish.json (added)
+++ sling/trunk/contrib/extensions/replication/core/src/main/resources/SLING-CONTENT/libs/sling/replication/config/author/org.apache.sling.replication.agent.impl.ReplicationAgentServiceFactory-publish.json Mon Aug  4 14:22:15 2014
@@ -0,0 +1,9 @@
+{
+    "jcr:primaryType" : "sling:OsgiConfig",
+    "name" : "publish",
+    "ReplicationPackageExporter.target" : "(name=default)",
+    "ReplicationPackageImporter.target" : "(name=publish)",
+    "ReplicationQueueProvider.target" : "(name=sjh)",
+    "ReplicationQueueDistributionStrategy.target" : "(name=single)",
+    "runModes" : ["author"]
+}

Added: sling/trunk/contrib/extensions/replication/core/src/main/resources/SLING-CONTENT/libs/sling/replication/config/author/org.apache.sling.replication.transport.impl.exporter.RemoteReplicationPackageExporter-publish.json
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/core/src/main/resources/SLING-CONTENT/libs/sling/replication/config/author/org.apache.sling.replication.transport.impl.exporter.RemoteReplicationPackageExporter-publish.json?rev=1615572&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/replication/core/src/main/resources/SLING-CONTENT/libs/sling/replication/config/author/org.apache.sling.replication.transport.impl.exporter.RemoteReplicationPackageExporter-publish.json (added)
+++ sling/trunk/contrib/extensions/replication/core/src/main/resources/SLING-CONTENT/libs/sling/replication/config/author/org.apache.sling.replication.transport.impl.exporter.RemoteReplicationPackageExporter-publish.json Mon Aug  4 14:22:15 2014
@@ -0,0 +1,9 @@
+{
+    "jcr:primaryType" : "sling:OsgiConfig",
+    "name": "publish",
+    "TransportAuthenticationProviderFactory.target" : "(name=user)",
+    "authentication.properties" : ["user=admin","password=admin"],
+    "ReplicationPackageBuilder.target" : "(name=vlt)",
+    "endpoints" : [ "http://localhost:4503/libs/sling/replication/exporters/agent" ],
+    "runModes" : ["author"]
+}
\ No newline at end of file

Added: sling/trunk/contrib/extensions/replication/core/src/main/resources/SLING-CONTENT/libs/sling/replication/config/author/org.apache.sling.replication.transport.impl.importer.RemoteReplicationPackageImporter-publish.json
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/core/src/main/resources/SLING-CONTENT/libs/sling/replication/config/author/org.apache.sling.replication.transport.impl.importer.RemoteReplicationPackageImporter-publish.json?rev=1615572&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/replication/core/src/main/resources/SLING-CONTENT/libs/sling/replication/config/author/org.apache.sling.replication.transport.impl.importer.RemoteReplicationPackageImporter-publish.json (added)
+++ sling/trunk/contrib/extensions/replication/core/src/main/resources/SLING-CONTENT/libs/sling/replication/config/author/org.apache.sling.replication.transport.impl.importer.RemoteReplicationPackageImporter-publish.json Mon Aug  4 14:22:15 2014
@@ -0,0 +1,9 @@
+{
+    "jcr:primaryType" : "sling:OsgiConfig",
+    "name": "publish",
+    "TransportAuthenticationProviderFactory.target" : "(name=user)",
+    "authentication.properties" : ["user=admin","password=admin"],
+    "ReplicationPackageBuilder.target" : "(name=vlt)",
+    "endpoints" : [ "http://localhost:4503/libs/sling/replication/importers/default" ],
+    "runModes" : ["author"]
+}
\ No newline at end of file

Added: sling/trunk/contrib/extensions/replication/core/src/main/resources/SLING-CONTENT/libs/sling/replication/config/publish/org.apache.sling.replication.agent.impl.ReplicationAgentServiceFactory-cache-flush.json
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/core/src/main/resources/SLING-CONTENT/libs/sling/replication/config/publish/org.apache.sling.replication.agent.impl.ReplicationAgentServiceFactory-cache-flush.json?rev=1615572&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/replication/core/src/main/resources/SLING-CONTENT/libs/sling/replication/config/publish/org.apache.sling.replication.agent.impl.ReplicationAgentServiceFactory-cache-flush.json (added)
+++ sling/trunk/contrib/extensions/replication/core/src/main/resources/SLING-CONTENT/libs/sling/replication/config/publish/org.apache.sling.replication.agent.impl.ReplicationAgentServiceFactory-cache-flush.json Mon Aug  4 14:22:15 2014
@@ -0,0 +1,12 @@
+{
+    "jcr:primaryType" : "sling:OsgiConfig",
+    "name" : "cache-flush",
+    "TransportHandler.target" : "(name=http-cache-flush)",
+    "useAggregatePaths" : false,
+    "ReplicationPackageExporter.target" : "(name=void)",
+    "ReplicationQueueProvider.target" : "(name=simple)",
+    "ReplicationQueueDistributionStrategy.target" : "(name=single)",
+    "rules" : ["trigger on path: /content/usergenerated"],
+    "enabled" : false,
+    "runModes" : ["publish"]
+}

Added: sling/trunk/contrib/extensions/replication/core/src/main/resources/SLING-CONTENT/libs/sling/replication/config/publish/org.apache.sling.replication.agent.impl.ReplicationAgentServiceFactory-reverse.json
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/core/src/main/resources/SLING-CONTENT/libs/sling/replication/config/publish/org.apache.sling.replication.agent.impl.ReplicationAgentServiceFactory-reverse.json?rev=1615572&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/replication/core/src/main/resources/SLING-CONTENT/libs/sling/replication/config/publish/org.apache.sling.replication.agent.impl.ReplicationAgentServiceFactory-reverse.json (added)
+++ sling/trunk/contrib/extensions/replication/core/src/main/resources/SLING-CONTENT/libs/sling/replication/config/publish/org.apache.sling.replication.agent.impl.ReplicationAgentServiceFactory-reverse.json Mon Aug  4 14:22:15 2014
@@ -0,0 +1,10 @@
+{
+    "jcr:primaryType" : "sling:OsgiConfig",
+    "name" : "reverse",
+    "ReplicationPackageExporter.target" : "(name=default)",
+    "ReplicationQueueProvider.target" : "(name=sjh)",
+    "ReplicationQueueDistributionStrategy.target" : "(name=error)",
+    "rules" : ["trigger on path: /content/usergenerated"],
+    "runModes" : ["publish"],
+    "isPassive" : true
+}

Added: sling/trunk/contrib/extensions/replication/core/src/main/resources/SLING-CONTENT/libs/sling/replication/config/publish/org.apache.sling.replication.serialization.impl.exporter.AgentReplicationPackageExporter.json
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/core/src/main/resources/SLING-CONTENT/libs/sling/replication/config/publish/org.apache.sling.replication.serialization.impl.exporter.AgentReplicationPackageExporter.json?rev=1615572&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/replication/core/src/main/resources/SLING-CONTENT/libs/sling/replication/config/publish/org.apache.sling.replication.serialization.impl.exporter.AgentReplicationPackageExporter.json (added)
+++ sling/trunk/contrib/extensions/replication/core/src/main/resources/SLING-CONTENT/libs/sling/replication/config/publish/org.apache.sling.replication.serialization.impl.exporter.AgentReplicationPackageExporter.json Mon Aug  4 14:22:15 2014
@@ -0,0 +1,6 @@
+{
+    "jcr:primaryType" : "sling:OsgiConfig",
+    "ReplicationPackageBuilder.target" : "(name=vlt)",
+    "ReplicationAgent.target" : "(name=reverse)",
+    "runModes" : ["publish"]
+}
\ No newline at end of file

Added: sling/trunk/contrib/extensions/replication/core/src/main/resources/SLING-CONTENT/libs/sling/replication/config/publish/org.apache.sling.replication.transport.impl.HttpTransportHandlerFactory-cache-flush.json
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/core/src/main/resources/SLING-CONTENT/libs/sling/replication/config/publish/org.apache.sling.replication.transport.impl.HttpTransportHandlerFactory-cache-flush.json?rev=1615572&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/replication/core/src/main/resources/SLING-CONTENT/libs/sling/replication/config/publish/org.apache.sling.replication.transport.impl.HttpTransportHandlerFactory-cache-flush.json (added)
+++ sling/trunk/contrib/extensions/replication/core/src/main/resources/SLING-CONTENT/libs/sling/replication/config/publish/org.apache.sling.replication.transport.impl.HttpTransportHandlerFactory-cache-flush.json Mon Aug  4 14:22:15 2014
@@ -0,0 +1,13 @@
+{
+    "jcr:primaryType" : "sling:OsgiConfig",
+    "name" : "http-cache-flush",
+    "useCustomHeaders" : true,
+    "customHeaders" : [
+            "Path: {path}",
+            "add -> Action : REFRESH",
+            "delete -> Change : REMOVE" ],
+    "useCustomBody": true,
+    "customBody" : "",
+    "TransportAuthenticationProviderFactory.target" : "(name=nop)",
+    "endpoints" : [ "http://localhost:8000/invalidatecache" ]
+}
\ No newline at end of file

Added: sling/trunk/contrib/extensions/replication/core/src/main/resources/SLING-CONTENT/libs/sling/replication/config/resourceproviders/configs/org.apache.sling.replication.resources.impl.OsgiPropertiesResourceProviderFactory-agentsConfig.json
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/core/src/main/resources/SLING-CONTENT/libs/sling/replication/config/resourceproviders/configs/org.apache.sling.replication.resources.impl.OsgiPropertiesResourceProviderFactory-agentsConfig.json?rev=1615572&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/replication/core/src/main/resources/SLING-CONTENT/libs/sling/replication/config/resourceproviders/configs/org.apache.sling.replication.resources.impl.OsgiPropertiesResourceProviderFactory-agentsConfig.json (added)
+++ sling/trunk/contrib/extensions/replication/core/src/main/resources/SLING-CONTENT/libs/sling/replication/config/resourceproviders/configs/org.apache.sling.replication.resources.impl.OsgiPropertiesResourceProviderFactory-agentsConfig.json Mon Aug  4 14:22:15 2014
@@ -0,0 +1,19 @@
+{
+    "jcr:primaryType" : "sling:OsgiConfig",
+    "name" : "replicationAgentsConfig",
+    "provider.roots" : [ "/libs/sling/replication/config/agents" ],
+    "serviceType" : "org.apache.sling.replication.agent.impl.ReplicationAgentServiceFactory",
+    "providerType" : "osgiConfig",
+    "resourceProperties" : [
+        "sling:resourceType=replication/config/agent",
+        "name={name}",
+        "runModes={runModes}",
+        "queueProvider={ReplicationQueueProvider.target}",
+        "packageExporter={ReplicationPackageExporter.target}",
+        "packageImporter={ReplicationPackageImporter.target}",
+        "queueStrategy={ReplicationQueueDistributionStrategy.target}",
+        "transportHandler={TransportHandler.target}"
+    ]
+
+
+}
\ No newline at end of file

Added: sling/trunk/contrib/extensions/replication/core/src/main/resources/SLING-CONTENT/libs/sling/replication/config/resourceproviders/configs/org.apache.sling.replication.resources.impl.OsgiPropertiesResourceProviderFactory-httpTransportConfig.json
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/core/src/main/resources/SLING-CONTENT/libs/sling/replication/config/resourceproviders/configs/org.apache.sling.replication.resources.impl.OsgiPropertiesResourceProviderFactory-httpTransportConfig.json?rev=1615572&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/replication/core/src/main/resources/SLING-CONTENT/libs/sling/replication/config/resourceproviders/configs/org.apache.sling.replication.resources.impl.OsgiPropertiesResourceProviderFactory-httpTransportConfig.json (added)
+++ sling/trunk/contrib/extensions/replication/core/src/main/resources/SLING-CONTENT/libs/sling/replication/config/resourceproviders/configs/org.apache.sling.replication.resources.impl.OsgiPropertiesResourceProviderFactory-httpTransportConfig.json Mon Aug  4 14:22:15 2014
@@ -0,0 +1,12 @@
+{
+    "jcr:primaryType" : "sling:OsgiConfig",
+    "name" : "replicationHttpTransportConfig",
+    "provider.roots" : [ "/libs/sling/replication/config/transport/http" ],
+    "serviceType" : "org.apache.sling.replication.transport.impl.HttpTransportHandlerFactory",
+    "providerType" : "osgiConfig",
+    "resourceProperties" : [
+        "sling:resourceType=replication/config/transport/http",
+        "name={name}",
+        "endpoints={endpoints}"
+    ]
+}
\ No newline at end of file

Added: sling/trunk/contrib/extensions/replication/core/src/main/resources/SLING-CONTENT/libs/sling/replication/config/resourceproviders/configs/org.apache.sling.replication.resources.impl.OsgiPropertiesResourceProviderFactory-remoteExportersConfig.json
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/core/src/main/resources/SLING-CONTENT/libs/sling/replication/config/resourceproviders/configs/org.apache.sling.replication.resources.impl.OsgiPropertiesResourceProviderFactory-remoteExportersConfig.json?rev=1615572&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/replication/core/src/main/resources/SLING-CONTENT/libs/sling/replication/config/resourceproviders/configs/org.apache.sling.replication.resources.impl.OsgiPropertiesResourceProviderFactory-remoteExportersConfig.json (added)
+++ sling/trunk/contrib/extensions/replication/core/src/main/resources/SLING-CONTENT/libs/sling/replication/config/resourceproviders/configs/org.apache.sling.replication.resources.impl.OsgiPropertiesResourceProviderFactory-remoteExportersConfig.json Mon Aug  4 14:22:15 2014
@@ -0,0 +1,13 @@
+{
+    "jcr:primaryType" : "sling:OsgiConfig",
+    "name" : "replicationExportersConfig",
+    "provider.roots" : [ "/libs/sling/replication/config/exporters/remote" ],
+    "serviceType" : "org.apache.sling.replication.transport.impl.exporter.RemoteReplicationPackageExporter",
+    "providerType" : "osgiConfig",
+
+    "resourceProperties" : [
+        "sling:resourceType=replication/config/exporter/remote",
+        "name={name}",
+        "endpoints={endpoints}"
+    ]
+}
\ No newline at end of file

Added: sling/trunk/contrib/extensions/replication/core/src/main/resources/SLING-CONTENT/libs/sling/replication/config/resourceproviders/configs/org.apache.sling.replication.resources.impl.OsgiPropertiesResourceProviderFactory-remoteImportersConfig.json
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/core/src/main/resources/SLING-CONTENT/libs/sling/replication/config/resourceproviders/configs/org.apache.sling.replication.resources.impl.OsgiPropertiesResourceProviderFactory-remoteImportersConfig.json?rev=1615572&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/replication/core/src/main/resources/SLING-CONTENT/libs/sling/replication/config/resourceproviders/configs/org.apache.sling.replication.resources.impl.OsgiPropertiesResourceProviderFactory-remoteImportersConfig.json (added)
+++ sling/trunk/contrib/extensions/replication/core/src/main/resources/SLING-CONTENT/libs/sling/replication/config/resourceproviders/configs/org.apache.sling.replication.resources.impl.OsgiPropertiesResourceProviderFactory-remoteImportersConfig.json Mon Aug  4 14:22:15 2014
@@ -0,0 +1,13 @@
+{
+    "jcr:primaryType" : "sling:OsgiConfig",
+    "name" : "replicationImportersConfig",
+    "provider.roots" : [ "/libs/sling/replication/config/importers/remote" ],
+    "serviceType" : "org.apache.sling.replication.transport.impl.importer.RemoteReplicationPackageImporter",
+    "providerType" : "osgiConfig",
+
+    "resourceProperties" : [
+        "sling:resourceType=replication/config/importer/remote",
+        "name={name}",
+        "endpoints={endpoints}"
+    ]
+}
\ No newline at end of file

Added: sling/trunk/contrib/extensions/replication/core/src/main/resources/SLING-CONTENT/libs/sling/replication/config/resourceproviders/services/org.apache.sling.replication.resources.impl.OsgiPropertiesResourceProviderFactory-agents.json
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/core/src/main/resources/SLING-CONTENT/libs/sling/replication/config/resourceproviders/services/org.apache.sling.replication.resources.impl.OsgiPropertiesResourceProviderFactory-agents.json?rev=1615572&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/replication/core/src/main/resources/SLING-CONTENT/libs/sling/replication/config/resourceproviders/services/org.apache.sling.replication.resources.impl.OsgiPropertiesResourceProviderFactory-agents.json (added)
+++ sling/trunk/contrib/extensions/replication/core/src/main/resources/SLING-CONTENT/libs/sling/replication/config/resourceproviders/services/org.apache.sling.replication.resources.impl.OsgiPropertiesResourceProviderFactory-agents.json Mon Aug  4 14:22:15 2014
@@ -0,0 +1,12 @@
+{
+    "jcr:primaryType" : "sling:OsgiConfig",
+    "name" : "replicationAgents",
+    "provider.roots" : [ "/libs/sling/replication/agents" ],
+    "serviceType" : "org.apache.sling.replication.agent.ReplicationAgent",
+    "resourceProperties" : [
+        "sling:resourceType=replication/agent",
+        "name={name}",
+
+        "queue/sling:resourceType=replication/agent/queue"
+    ]
+}
\ No newline at end of file

Added: sling/trunk/contrib/extensions/replication/core/src/main/resources/SLING-CONTENT/libs/sling/replication/config/resourceproviders/services/org.apache.sling.replication.resources.impl.OsgiPropertiesResourceProviderFactory-exporters.json
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/core/src/main/resources/SLING-CONTENT/libs/sling/replication/config/resourceproviders/services/org.apache.sling.replication.resources.impl.OsgiPropertiesResourceProviderFactory-exporters.json?rev=1615572&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/replication/core/src/main/resources/SLING-CONTENT/libs/sling/replication/config/resourceproviders/services/org.apache.sling.replication.resources.impl.OsgiPropertiesResourceProviderFactory-exporters.json (added)
+++ sling/trunk/contrib/extensions/replication/core/src/main/resources/SLING-CONTENT/libs/sling/replication/config/resourceproviders/services/org.apache.sling.replication.resources.impl.OsgiPropertiesResourceProviderFactory-exporters.json Mon Aug  4 14:22:15 2014
@@ -0,0 +1,10 @@
+{
+    "jcr:primaryType" : "sling:OsgiConfig",
+    "name" : "replicationExporters",
+    "provider.roots" : [ "/libs/sling/replication/exporters" ],
+    "serviceType" : "org.apache.sling.replication.serialization.ReplicationPackageExporter",
+    "resourceProperties" : [
+        "sling:resourceType=replication/exporter",
+        "name={name}"
+    ]
+}
\ No newline at end of file

Added: sling/trunk/contrib/extensions/replication/core/src/main/resources/SLING-CONTENT/libs/sling/replication/config/resourceproviders/services/org.apache.sling.replication.resources.impl.OsgiPropertiesResourceProviderFactory-importers.json
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/core/src/main/resources/SLING-CONTENT/libs/sling/replication/config/resourceproviders/services/org.apache.sling.replication.resources.impl.OsgiPropertiesResourceProviderFactory-importers.json?rev=1615572&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/replication/core/src/main/resources/SLING-CONTENT/libs/sling/replication/config/resourceproviders/services/org.apache.sling.replication.resources.impl.OsgiPropertiesResourceProviderFactory-importers.json (added)
+++ sling/trunk/contrib/extensions/replication/core/src/main/resources/SLING-CONTENT/libs/sling/replication/config/resourceproviders/services/org.apache.sling.replication.resources.impl.OsgiPropertiesResourceProviderFactory-importers.json Mon Aug  4 14:22:15 2014
@@ -0,0 +1,10 @@
+{
+    "jcr:primaryType" : "sling:OsgiConfig",
+    "name" : "replicationImporters",
+    "provider.roots" : [ "/libs/sling/replication/importers" ],
+    "serviceType" : "org.apache.sling.replication.serialization.ReplicationPackageImporter",
+    "resourceProperties" : [
+        "sling:resourceType=replication/importer",
+        "name={name}"
+    ]
+}
\ No newline at end of file

Modified: sling/trunk/contrib/extensions/replication/core/src/test/java/org/apache/sling/replication/agent/impl/ReplicationAgentServiceFactoryTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/core/src/test/java/org/apache/sling/replication/agent/impl/ReplicationAgentServiceFactoryTest.java?rev=1615572&r1=1615571&r2=1615572&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/replication/core/src/test/java/org/apache/sling/replication/agent/impl/ReplicationAgentServiceFactoryTest.java (original)
+++ sling/trunk/contrib/extensions/replication/core/src/test/java/org/apache/sling/replication/agent/impl/ReplicationAgentServiceFactoryTest.java Mon Aug  4 14:22:15 2014
@@ -25,6 +25,8 @@ import org.apache.sling.replication.agen
 import org.apache.sling.replication.queue.ReplicationQueueDistributionStrategy;
 import org.apache.sling.replication.queue.ReplicationQueueProvider;
 import org.apache.sling.replication.serialization.ReplicationPackageBuilder;
+import org.apache.sling.replication.serialization.ReplicationPackageExporter;
+import org.apache.sling.replication.serialization.ReplicationPackageImporter;
 import org.apache.sling.replication.transport.TransportHandler;
 import org.junit.Test;
 import org.osgi.framework.BundleContext;
@@ -41,10 +43,17 @@ public class ReplicationAgentServiceFact
     public void testActivationWithAllServicesAndPropertiesBound() throws Exception {
         ReplicationAgentServiceFactory serviceFactory = new ReplicationAgentServiceFactory();
 
-        Field packageBuilderField = serviceFactory.getClass().getDeclaredField("packageBuilder");
-        packageBuilderField.setAccessible(true);
-        ReplicationPackageBuilder packageBuilder = mock(ReplicationPackageBuilder.class);
-        packageBuilderField.set(serviceFactory, packageBuilder);
+        Field packageImporterField = serviceFactory.getClass().getDeclaredField("packageImporter");
+        packageImporterField.setAccessible(true);
+        ReplicationPackageImporter packageImporter = mock(ReplicationPackageImporter.class);
+        packageImporterField.set(serviceFactory, packageImporter);
+
+
+        Field packageExporterField = serviceFactory.getClass().getDeclaredField("packageExporter");
+        packageExporterField.setAccessible(true);
+        ReplicationPackageExporter packageExporter = mock(ReplicationPackageExporter.class);
+        packageExporterField.set(serviceFactory, packageExporter);
+
 
         Field distributionField = serviceFactory.getClass().getDeclaredField("queueDistributionStrategy");
         distributionField.setAccessible(true);
@@ -56,11 +65,6 @@ public class ReplicationAgentServiceFact
         ReplicationQueueProvider queueProvider = mock(ReplicationQueueProvider.class);
         queueField.set(serviceFactory, queueProvider);
 
-        Field transportField = serviceFactory.getClass().getDeclaredField("transportHandler");
-        transportField.setAccessible(true);
-        TransportHandler transportHandler = mock(TransportHandler.class);
-        transportField.set(serviceFactory, transportHandler);
-
 
         Map<String, Object> dictionary = new HashMap<String, Object>();
         dictionary.put("endpoint", "http://somewhere.com");

Modified: sling/trunk/contrib/extensions/replication/core/src/test/java/org/apache/sling/replication/agent/impl/SimpleReplicationAgentTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/core/src/test/java/org/apache/sling/replication/agent/impl/SimpleReplicationAgentTest.java?rev=1615572&r1=1615571&r2=1615572&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/replication/core/src/test/java/org/apache/sling/replication/agent/impl/SimpleReplicationAgentTest.java (original)
+++ sling/trunk/contrib/extensions/replication/core/src/test/java/org/apache/sling/replication/agent/impl/SimpleReplicationAgentTest.java Mon Aug  4 14:22:15 2014
@@ -30,6 +30,8 @@ import org.apache.sling.replication.queu
 import org.apache.sling.replication.queue.impl.simple.SimpleReplicationQueue;
 import org.apache.sling.replication.serialization.ReplicationPackage;
 import org.apache.sling.replication.serialization.ReplicationPackageBuilder;
+import org.apache.sling.replication.serialization.ReplicationPackageExporter;
+import org.apache.sling.replication.serialization.ReplicationPackageImporter;
 import org.apache.sling.replication.transport.TransportHandler;
 import org.junit.Test;
 
@@ -50,17 +52,20 @@ public class SimpleReplicationAgentTest 
     public void testSyncReplicationWithFailingDistributionStrategy() throws Exception {
         String name = "sample-agent";
         TransportHandler transportHandler = mock(TransportHandler.class);
-        ReplicationPackageBuilder packageBuilder = mock(ReplicationPackageBuilder.class);
+        ReplicationPackageImporter packageImporter = mock(ReplicationPackageImporter.class);
+        ReplicationPackageExporter packageExporter = mock(ReplicationPackageExporter.class);
+
+
         ReplicationQueueProvider queueProvider = mock(ReplicationQueueProvider.class);
         ReplicationQueueDistributionStrategy distributionHandler = mock(ReplicationQueueDistributionStrategy.class);
         ReplicationEventFactory replicationEventFactory = mock(ReplicationEventFactory.class);
         SimpleReplicationAgent agent = new SimpleReplicationAgent(name, new String[0], true,
-                transportHandler, packageBuilder, queueProvider, distributionHandler, replicationEventFactory, null);
+                false, packageImporter, packageExporter, queueProvider, distributionHandler, replicationEventFactory, null);
         ReplicationRequest request = new ReplicationRequest(System.nanoTime(),
                 ReplicationActionType.ADD, "/");
         ReplicationPackage replicationPackage = mock(ReplicationPackage.class);
         when(replicationPackage.getPaths()).thenReturn(new String[]{"/"});
-        when(packageBuilder.createPackage(request)).thenReturn(replicationPackage);
+        when(packageExporter.exportPackage(request)).thenReturn(replicationPackage);
         when(queueProvider.getDefaultQueue(agent.getName())).thenReturn(
                 new SimpleReplicationQueue(agent.getName(), "name"));
         ReplicationResponse response = agent.execute(request);
@@ -72,12 +77,12 @@ public class SimpleReplicationAgentTest 
     public void testSyncReplicationWithWorkingDistributionStrategy() throws Exception {
         String name = "sample-agent";
         TransportHandler transportHandler = mock(TransportHandler.class);
-        ReplicationPackageBuilder packageBuilder = mock(ReplicationPackageBuilder.class);
-        ReplicationQueueProvider queueProvider = mock(ReplicationQueueProvider.class);
+        ReplicationPackageImporter packageImporter = mock(ReplicationPackageImporter.class);
+        ReplicationPackageExporter packageExporter = mock(ReplicationPackageExporter.class);        ReplicationQueueProvider queueProvider = mock(ReplicationQueueProvider.class);
         ReplicationQueueDistributionStrategy distributionHandler = mock(ReplicationQueueDistributionStrategy.class);
         ReplicationEventFactory replicationEventFactory = mock(ReplicationEventFactory.class);
         SimpleReplicationAgent agent = new SimpleReplicationAgent(name, new String[0], true,
-                transportHandler, packageBuilder, queueProvider, distributionHandler, replicationEventFactory, null);
+                false, packageImporter, packageExporter, queueProvider, distributionHandler, replicationEventFactory, null);
         ReplicationRequest request = new ReplicationRequest(System.nanoTime(),
                 ReplicationActionType.ADD, "/");
         ReplicationPackage replicationPackage = mock(ReplicationPackage.class);
@@ -85,7 +90,7 @@ public class SimpleReplicationAgentTest 
         ReplicationQueueItemState state = new ReplicationQueueItemState();
         state.setItemState(ReplicationQueueItemState.ItemState.SUCCEEDED);
         when(distributionHandler.add(any(String.class), any(ReplicationQueueItem.class), eq(queueProvider))).thenReturn(state);
-        when(packageBuilder.createPackage(any(ReplicationRequest.class))).thenReturn(replicationPackage);
+        when(packageExporter.exportPackage(any(ReplicationRequest.class))).thenReturn(replicationPackage);
         when(queueProvider.getDefaultQueue(agent.getName())).thenReturn(
                 new SimpleReplicationQueue(agent.getName(), "name"));
         ReplicationResponse response = agent.execute(request);
@@ -97,17 +102,17 @@ public class SimpleReplicationAgentTest 
     public void testAsyncReplication() throws Exception {
         String name = "sample-agent";
         TransportHandler transportHandler = mock(TransportHandler.class);
-        ReplicationPackageBuilder packageBuilder = mock(ReplicationPackageBuilder.class);
-        ReplicationQueueProvider queueProvider = mock(ReplicationQueueProvider.class);
+        ReplicationPackageImporter packageImporter = mock(ReplicationPackageImporter.class);
+        ReplicationPackageExporter packageExporter = mock(ReplicationPackageExporter.class);        ReplicationQueueProvider queueProvider = mock(ReplicationQueueProvider.class);
         ReplicationQueueDistributionStrategy distributionHandler = mock(ReplicationQueueDistributionStrategy.class);
         ReplicationEventFactory replicationEventFactory = mock(ReplicationEventFactory.class);
         SimpleReplicationAgent agent = new SimpleReplicationAgent(name, new String[0], true,
-                transportHandler, packageBuilder, queueProvider, distributionHandler, replicationEventFactory, null);
+                false, packageImporter, packageExporter, queueProvider, distributionHandler, replicationEventFactory, null);
         ReplicationRequest request = new ReplicationRequest(System.nanoTime(),
                 ReplicationActionType.ADD, "/");
         ReplicationPackage replicationPackage = mock(ReplicationPackage.class);
         when(replicationPackage.getPaths()).thenReturn(new String[]{"/"});
-        when(packageBuilder.createPackage(request)).thenReturn(replicationPackage);
+        when(packageExporter.exportPackage(request)).thenReturn(replicationPackage);
         when(queueProvider.getDefaultQueue(agent.getName())).thenReturn(
                 new SimpleReplicationQueue(agent.getName(), "name"));
         agent.send(request);
@@ -117,11 +122,12 @@ public class SimpleReplicationAgentTest 
     public void testGetDefaultQueue() throws Exception {
         String name = "sample-agent";
         TransportHandler transportHandler = mock(TransportHandler.class);
-        ReplicationPackageBuilder packageBuilder = mock(ReplicationPackageBuilder.class);
+        ReplicationPackageImporter packageImporter = mock(ReplicationPackageImporter.class);
+        ReplicationPackageExporter packageExporter = mock(ReplicationPackageExporter.class);
         ReplicationQueueProvider queueProvider = mock(ReplicationQueueProvider.class);
         ReplicationQueueDistributionStrategy distributionHandler = mock(ReplicationQueueDistributionStrategy.class);
         SimpleReplicationAgent agent = new SimpleReplicationAgent(name, new String[0], true,
-                transportHandler, packageBuilder, queueProvider, distributionHandler, null, null);
+                false, packageImporter, packageExporter, queueProvider, distributionHandler, null, null);
         ReplicationQueue queue = mock(ReplicationQueue.class);
         when(queueProvider.getDefaultQueue(agent.getName())).thenReturn(queue);
         assertNotNull(agent.getQueue(null));
@@ -131,11 +137,12 @@ public class SimpleReplicationAgentTest 
     public void testGetExistingNamedQueue() throws Exception {
         String name = "sample-agent";
         TransportHandler transportHandler = mock(TransportHandler.class);
-        ReplicationPackageBuilder packageBuilder = mock(ReplicationPackageBuilder.class);
+        ReplicationPackageImporter packageImporter = mock(ReplicationPackageImporter.class);
+        ReplicationPackageExporter packageExporter = mock(ReplicationPackageExporter.class);
         ReplicationQueueProvider queueProvider = mock(ReplicationQueueProvider.class);
         ReplicationQueueDistributionStrategy distributionHandler = mock(ReplicationQueueDistributionStrategy.class);
         SimpleReplicationAgent agent = new SimpleReplicationAgent(name, new String[0], true,
-                transportHandler, packageBuilder, queueProvider, distributionHandler, null, null);
+                false, packageImporter, packageExporter, queueProvider, distributionHandler, null, null);
         ReplicationQueue queue = mock(ReplicationQueue.class);
         when(queueProvider.getQueue(agent.getName(), "priority")).thenReturn(queue);
         assertNotNull(agent.getQueue("priority"));
@@ -145,11 +152,12 @@ public class SimpleReplicationAgentTest 
     public void testGetNonExistingNamedQueue() throws Exception {
         String name = "sample-agent";
         TransportHandler transportHandler = mock(TransportHandler.class);
-        ReplicationPackageBuilder packageBuilder = mock(ReplicationPackageBuilder.class);
+        ReplicationPackageImporter packageImporter = mock(ReplicationPackageImporter.class);
+        ReplicationPackageExporter packageExporter = mock(ReplicationPackageExporter.class);
         ReplicationQueueProvider queueProvider = mock(ReplicationQueueProvider.class);
         ReplicationQueueDistributionStrategy distributionHandler = mock(ReplicationQueueDistributionStrategy.class);
         SimpleReplicationAgent agent = new SimpleReplicationAgent(name, new String[0], true,
-                transportHandler, packageBuilder, queueProvider, distributionHandler, null, null);
+                false, packageImporter, packageExporter, queueProvider, distributionHandler, null, null);
         ReplicationQueue queue = mock(ReplicationQueue.class);
         when(queueProvider.getQueue(agent.getName(), "priority")).thenReturn(queue);
         assertNull(agent.getQueue("weird"));

Modified: sling/trunk/contrib/extensions/replication/core/src/test/java/org/apache/sling/replication/serialization/impl/VoidReplicationPackageTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/core/src/test/java/org/apache/sling/replication/serialization/impl/VoidReplicationPackageTest.java?rev=1615572&r1=1615571&r2=1615572&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/replication/core/src/test/java/org/apache/sling/replication/serialization/impl/VoidReplicationPackageTest.java (original)
+++ sling/trunk/contrib/extensions/replication/core/src/test/java/org/apache/sling/replication/serialization/impl/VoidReplicationPackageTest.java Mon Aug  4 14:22:15 2014
@@ -37,7 +37,7 @@ public class VoidReplicationPackageTest 
     public void testCreatedAndReadPackagesEquality() throws Exception {
         ReplicationRequest request = new ReplicationRequest(123l, ReplicationActionType.DELETE, "/abc");
         VoidReplicationPackage createdPackage = new VoidReplicationPackage(request, "VOID");
-        VoidReplicationPackage readPackage = VoidReplicationPackage.fromStream(new ByteArrayInputStream("DELETE:[/abc]:123:VOID".getBytes()));
+        VoidReplicationPackage readPackage = VoidReplicationPackage.fromStream(new ByteArrayInputStream("DELETE:/abc:123:VOID".getBytes()));
         assertEquals(createdPackage.getId(), readPackage.getId());
         assertEquals(createdPackage.getAction(), readPackage.getAction());
         assertEquals(createdPackage.getType(), readPackage.getType());

Modified: sling/trunk/contrib/extensions/replication/core/src/test/java/org/apache/sling/replication/transport/impl/HttpTransportHandlerTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/core/src/test/java/org/apache/sling/replication/transport/impl/HttpTransportHandlerTest.java?rev=1615572&r1=1615571&r2=1615572&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/replication/core/src/test/java/org/apache/sling/replication/transport/impl/HttpTransportHandlerTest.java (original)
+++ sling/trunk/contrib/extensions/replication/core/src/test/java/org/apache/sling/replication/transport/impl/HttpTransportHandlerTest.java Mon Aug  4 14:22:15 2014
@@ -62,7 +62,7 @@ public class HttpTransportHandlerTest {
         when(response.returnContent()).thenReturn(content);
         when(executor.execute(any(Request.class))).thenReturn(response);
         when(transportAuthenticationProvider.authenticate(any(Executor.class), any(TransportAuthenticationContext.class))).thenReturn(executor);
-        httpTransportHandler.transport("agentName", replicationPackage);
+        httpTransportHandler.transport(replicationPackage);
     }
 
     @Test
@@ -87,7 +87,7 @@ public class HttpTransportHandlerTest {
         when(executor.execute(any(Request.class))).thenReturn(response);
         when(transportAuthenticationProvider.authenticate(any(Executor.class), any(TransportAuthenticationContext.class))).thenReturn(executor);
 
-        httpTransportHandler.transport("agentName", replicationPackage);
+        httpTransportHandler.transport(replicationPackage);
 
         verify(executor, times(1)).execute(any(Request.class));
     }

Modified: sling/trunk/contrib/extensions/replication/core/src/test/java/org/apache/sling/replication/transport/impl/RepositoryTransportHandlerTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/core/src/test/java/org/apache/sling/replication/transport/impl/RepositoryTransportHandlerTest.java?rev=1615572&r1=1615571&r2=1615572&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/replication/core/src/test/java/org/apache/sling/replication/transport/impl/RepositoryTransportHandlerTest.java (original)
+++ sling/trunk/contrib/extensions/replication/core/src/test/java/org/apache/sling/replication/transport/impl/RepositoryTransportHandlerTest.java Mon Aug  4 14:22:15 2014
@@ -48,7 +48,7 @@ public class RepositoryTransportHandlerT
                 transportAuthenticationProvider,
                 new ReplicationEndpoint[] {  new ReplicationEndpoint("repo://var/outbox/replication/rev1") });
         try {
-            handler.transport("agentName", null);
+            handler.transport(null);
             fail("cannot deliver without a proper session");
         } catch (ReplicationTransportException re) {
             // failure expected
@@ -84,6 +84,6 @@ public class RepositoryTransportHandlerT
         ReplicationPackage replicationPackage = mock(ReplicationPackage.class);
         when(replicationPackage.getId()).thenReturn("some-id");
         when(replicationPackage.getPaths()).thenReturn(new String[]{"/apps", "/libs"});
-        handler.transport("agentName", replicationPackage);
+        handler.transport(replicationPackage);
     }
 }

Modified: sling/trunk/contrib/extensions/replication/it/src/test/java/org/apache/sling/replication/it/ForwardReplicationTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/it/src/test/java/org/apache/sling/replication/it/ForwardReplicationTest.java?rev=1615572&r1=1615571&r2=1615572&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/replication/it/src/test/java/org/apache/sling/replication/it/ForwardReplicationTest.java (original)
+++ sling/trunk/contrib/extensions/replication/it/src/test/java/org/apache/sling/replication/it/ForwardReplicationTest.java Mon Aug  4 14:22:15 2014
@@ -37,8 +37,8 @@ public class ForwardReplicationTest exte
 
     @Test
     public void testDeleteContent() throws Exception {
-        String nodePath = createRandomNode(authorClient, "/content");
-        replicate(author, "publish", ReplicationActionType.ADD, nodePath);
+        String nodePath = createRandomNode(publishClient, "/content");
+
         assertExists(publishClient, nodePath);
 
         replicate(author, "publish", ReplicationActionType.DELETE, nodePath);

Modified: sling/trunk/contrib/extensions/replication/it/src/test/java/org/apache/sling/replication/it/ReplicationIntegrationTestBase.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/it/src/test/java/org/apache/sling/replication/it/ReplicationIntegrationTestBase.java?rev=1615572&r1=1615571&r2=1615572&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/replication/it/src/test/java/org/apache/sling/replication/it/ReplicationIntegrationTestBase.java (original)
+++ sling/trunk/contrib/extensions/replication/it/src/test/java/org/apache/sling/replication/it/ReplicationIntegrationTestBase.java Mon Aug  4 14:22:15 2014
@@ -24,8 +24,6 @@ import org.apache.sling.testing.tools.sl
 import org.apache.sling.testing.tools.sling.SlingInstanceManager;
 
 import static org.apache.sling.replication.it.ReplicationUtils.assertExists;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
 
 /**
  * Integration test base class for replication
@@ -49,15 +47,13 @@ public abstract class ReplicationIntegra
 
         try {
             // change the url for publish agent and wait for it to start
-
-            String receiverUrl = "http://localhost:4503/libs/sling/replication/importer/default"
+            String receiverUrl = "http://localhost:4503/libs/sling/replication/importers/default"
                     .replace("http://localhost:4503", publish.getServerBaseUrl());
-            authorClient.setProperties("/libs/sling/replication/config/transport/http/http-publish-receive",
+            authorClient.setProperties("/libs/sling/replication/config/importers/remote/publish",
                     "endpoints", receiverUrl);
-            assertExists(authorClient, "/libs/sling/replication/agent/publish");
-        }
-        catch (Exception ex) {
-
+            assertExists(authorClient, "/libs/sling/replication/agents/publish");
+        } catch (Exception ex) {
+            throw new RuntimeException(ex);
         }
 
     }

Modified: sling/trunk/contrib/extensions/replication/it/src/test/java/org/apache/sling/replication/it/ReplicationUtils.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/it/src/test/java/org/apache/sling/replication/it/ReplicationUtils.java?rev=1615572&r1=1615571&r2=1615572&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/replication/it/src/test/java/org/apache/sling/replication/it/ReplicationUtils.java (original)
+++ sling/trunk/contrib/extensions/replication/it/src/test/java/org/apache/sling/replication/it/ReplicationUtils.java Mon Aug  4 14:22:15 2014
@@ -88,17 +88,15 @@ public class ReplicationUtils {
         ).getContent().replaceAll("\n", "").trim();
 
 
-        for (int i = 0; i < parameters.length; i++) {
-            assertTrue(parameters[i] + " is not contained in " + content,
-                    content.contains(parameters[i])
-            );
+        for (String parameter : parameters) {
+            assertTrue(parameter + " is not contained in " + content,
+                    content.contains(parameter));
         }
     }
 
 
-    public static void replicate(SlingInstance slingInstance, String agent, ReplicationActionType action, String... paths) throws IOException {
-        String agentResource = agentUrl("publish");
-
+    public static void replicate(SlingInstance slingInstance, String agentName, ReplicationActionType action, String... paths) throws IOException {
+        String agentResource = agentUrl(agentName);
 
         List<String> args = new ArrayList<String>();
         args.add(ReplicationHeader.ACTION.toString());
@@ -116,7 +114,6 @@ public class ReplicationUtils {
 
     public static void deleteNode(SlingInstance slingInstance, String path) throws IOException {
         assertPostResourceWithParameters(slingInstance, 200, path, ":operation", "delete");
-
     }
 
     public static void assertExists(SlingClient slingClient, String path) throws Exception {
@@ -133,7 +130,6 @@ public class ReplicationUtils {
         while(slingClient.exists(path) && retries-- > 0) {
             Thread.sleep(1000);
         }
-
         assertTrue(retries > 0);
     }
 
@@ -149,23 +145,23 @@ public class ReplicationUtils {
     }
 
     public static String agentUrl(String agentName) {
-        return REPLICATION_ROOT_PATH + "/agent/" + agentName;
+        return REPLICATION_ROOT_PATH + "/agents/" + agentName;
     }
 
     public static String queueUrl(String agentName) {
-        return REPLICATION_ROOT_PATH + "/agent/" + agentName +"/queue";
+        return REPLICATION_ROOT_PATH + "/agents/" + agentName +"/queue";
     }
 
     public static String agentConfigUrl(String agentName) {
-        return REPLICATION_ROOT_PATH + "/config/agent/" + agentName;
+        return REPLICATION_ROOT_PATH + "/config/agents/" + agentName;
     }
 
 
     public static String importerRootUrl() {
-        return REPLICATION_ROOT_PATH + "/importer";
+        return REPLICATION_ROOT_PATH + "/importers";
     }
 
     public static String importerUrl(String importerName) {
-        return REPLICATION_ROOT_PATH + "/importer/" + importerName;
+        return REPLICATION_ROOT_PATH + "/importers/" + importerName;
     }
 }

Added: sling/trunk/contrib/extensions/replication/it/src/test/java/org/apache/sling/replication/it/ReverseReplicationTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/it/src/test/java/org/apache/sling/replication/it/ReverseReplicationTest.java?rev=1615572&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/replication/it/src/test/java/org/apache/sling/replication/it/ReverseReplicationTest.java (added)
+++ sling/trunk/contrib/extensions/replication/it/src/test/java/org/apache/sling/replication/it/ReverseReplicationTest.java Mon Aug  4 14:22:15 2014
@@ -0,0 +1,20 @@
+package org.apache.sling.replication.it;
+
+
+import org.apache.sling.replication.communication.ReplicationActionType;
+import org.junit.Test;
+
+import static org.apache.sling.replication.it.ReplicationUtils.assertExists;
+import static org.apache.sling.replication.it.ReplicationUtils.createRandomNode;
+import static org.apache.sling.replication.it.ReplicationUtils.replicate;
+
+public class ReverseReplicationTest extends ReplicationIntegrationTestBase {
+    @Test
+    public void testAddContent() throws Exception {
+        String nodePath = createRandomNode(publishClient, "/content");
+        assertExists(publishClient, nodePath);
+        replicate(publish, "reverse", ReplicationActionType.ADD, nodePath);
+
+        assertExists(authorClient, nodePath);
+    }
+}

Propchange: sling/trunk/contrib/extensions/replication/it/src/test/java/org/apache/sling/replication/it/ReverseReplicationTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message