You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by bd...@apache.org on 2013/12/09 14:37:50 UTC
svn commit: r1549567 [3/5] - in /sling/trunk/contrib/extensions/replication:
./ src/main/java/org/apache/sling/replication/agent/
src/main/java/org/apache/sling/replication/agent/impl/
src/main/java/org/apache/sling/replication/communication/ src/main/...
Modified: sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/serialization/impl/vlt/FileVaultReplicationPackage.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/serialization/impl/vlt/FileVaultReplicationPackage.java?rev=1549567&r1=1549566&r2=1549567&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/serialization/impl/vlt/FileVaultReplicationPackage.java (original)
+++ sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/serialization/impl/vlt/FileVaultReplicationPackage.java Mon Dec 9 13:37:48 2013
@@ -40,9 +40,9 @@ public class FileVaultReplicationPackage
private final String[] paths;
- private VaultPackage pkg;
+ private final VaultPackage pkg;
- private String action;
+ private final String action;
public FileVaultReplicationPackage(VaultPackage pkg) {
this.pkg = pkg;
@@ -53,7 +53,7 @@ public class FileVaultReplicationPackage
}
this.paths = paths;
this.id = pkg.getFile().getAbsolutePath();
- this.action = ReplicationActionType.ACTIVATE.toString();
+ this.action = ReplicationActionType.ADD.toString();
}
public String getId() {
Modified: sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/serialization/impl/vlt/FileVaultReplicationPackageBuilder.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/serialization/impl/vlt/FileVaultReplicationPackageBuilder.java?rev=1549567&r1=1549566&r2=1549567&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/serialization/impl/vlt/FileVaultReplicationPackageBuilder.java (original)
+++ sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/serialization/impl/vlt/FileVaultReplicationPackageBuilder.java Mon Dec 9 13:37:48 2013
@@ -22,6 +22,7 @@ import java.io.File;
import java.io.InputStream;
import java.util.Properties;
+import javax.jcr.RepositoryException;
import javax.jcr.Session;
import org.apache.felix.scr.annotations.Component;
@@ -37,30 +38,32 @@ import org.apache.jackrabbit.vault.packa
import org.apache.jackrabbit.vault.packaging.Packaging;
import org.apache.jackrabbit.vault.packaging.VaultPackage;
import org.apache.sling.jcr.api.SlingRepository;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.apache.sling.replication.communication.ReplicationRequest;
import org.apache.sling.replication.serialization.ReplicationPackage;
import org.apache.sling.replication.serialization.ReplicationPackageBuilder;
import org.apache.sling.replication.serialization.ReplicationPackageBuildingException;
+
+import org.apache.sling.replication.serialization.ReplicationPackageReadingException;
import org.apache.sling.replication.serialization.impl.AbstractReplicationPackageBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
- * a {@link ReplicationPackageBuilder} based on Apache Jackrabbit FileVault.
- *
- * Each {@link ReplicationPackage} created by <code>FileVaultReplicationPackageBuilder</code> is
- * backed by a {@link VaultPackage}.
+ * a {@link ReplicationPackageBuilder}Â based on Apache Jackrabbit FileVault.
+ * <p/>
+ * Each {@link ReplicationPackage}Â created by <code>FileVaultReplicationPackageBuilder</code> is
+ * backed by a {@link VaultPackage}.Â
*/
@Component(metatype = false)
@Service(value = ReplicationPackageBuilder.class)
@Property(name = "name", value = FileVaultReplicationPackageBuilder.NAME)
public class FileVaultReplicationPackageBuilder extends AbstractReplicationPackageBuilder implements
- ReplicationPackageBuilder {
+ ReplicationPackageBuilder {
public static final String NAME = "vlt";
- private Logger log = LoggerFactory.getLogger(getClass());
+ private final Logger log = LoggerFactory.getLogger(getClass());
@Reference
private SlingRepository repository;
@@ -68,12 +71,12 @@ public class FileVaultReplicationPackage
@Reference
private Packaging packaging;
- protected ReplicationPackage createPackageForActivation(ReplicationRequest request)
- throws ReplicationPackageBuildingException {
+ protected ReplicationPackage createPackageForAdd(ReplicationRequest request)
+ throws ReplicationPackageBuildingException {
Session session = null;
try {
// TODO : replace this by using Credentials
- session = repository.loginAdministrative(null);
+ session = getSession();
final String[] paths = request.getPaths();
@@ -86,22 +89,19 @@ public class FileVaultReplicationPackage
inf.setFilter(filter);
Properties props = new Properties();
- String packageGroup = new StringBuilder("sling/replication").toString();
+ String packageGroup = "sling/replication";
props.setProperty(VaultPackage.NAME_GROUP, packageGroup);
String packageName = String.valueOf(request.getTime());
props.setProperty(VaultPackage.NAME_NAME, packageName);
if (log.isInfoEnabled()) {
- log.info("assembling package {}", new StringBuilder(packageGroup).append('/')
- .append(packageName).toString());
+ log.info("assembling package {}", packageGroup + '/' + packageName);
}
inf.setProperties(props);
opts.setMetaInf(inf);
opts.setRootPath("/");
File tmpFile = File.createTempFile("vlt-rp-" + System.nanoTime(), ".zip");
- tmpFile.createNewFile();
VaultPackage pkg = packaging.getPackageManager().assemble(session, opts, tmpFile);
-
return new FileVaultReplicationPackage(pkg);
} catch (Exception e) {
throw new ReplicationPackageBuildingException(e);
@@ -113,27 +113,42 @@ public class FileVaultReplicationPackage
}
@Override
- protected ReplicationPackage readPackageForActivation(ReplicationRequest request,
- final InputStream stream, boolean install)
- throws ReplicationPackageBuildingException {
+ protected String getName() {
+ return NAME;
+ }
+
+ @Override
+ protected Session getSession() throws RepositoryException {
+ return repository.loginAdministrative(null);
+ }
+
+ @Override
+ protected ReplicationPackage readPackageForAdd(final InputStream stream, boolean install)
+ throws ReplicationPackageReadingException {
if (log.isInfoEnabled()) {
log.info("reading a stream {}", stream);
}
Session session = null;
ReplicationPackage pkg = null;
try {
- session = repository.loginAdministrative(null);
- final JcrPackage jcrPackage = packaging.getPackageManager(session).upload(stream, true,
- false);
- if (install) {
- jcrPackage.install(new ImportOptions());
+ if (log.isInfoEnabled()) {
+ log.info("reading package for addition");
+ }
+ // TODO : use proper Credentials here
+ session = getSession();
+ if (session != null) {
+ final JcrPackage jcrPackage = packaging.getPackageManager(session).upload(stream, true,
+ false);
+ if (install) {
+ jcrPackage.install(new ImportOptions());
+ }
+ pkg = new FileVaultReplicationPackage(jcrPackage.getPackage());
}
- pkg = new FileVaultReplicationPackage(jcrPackage.getPackage());
} catch (Exception e) {
if (log.isErrorEnabled()) {
log.error("could not read / install the package", e);
}
- throw new ReplicationPackageBuildingException(e);
+ throw new ReplicationPackageReadingException(e);
} finally {
if (session != null) {
session.logout();
@@ -145,8 +160,11 @@ public class FileVaultReplicationPackage
public ReplicationPackage getPackage(String id) {
ReplicationPackage replicationPackage = null;
try {
- VaultPackage pkg = packaging.getPackageManager().open(new File(id));
- replicationPackage = new FileVaultReplicationPackage(pkg);
+ File file = new File(id);
+ if (file.exists()) {
+ VaultPackage pkg = packaging.getPackageManager().open(file);
+ replicationPackage = new FileVaultReplicationPackage(pkg);
+ }
} catch (Exception e) {
if (log.isWarnEnabled()) {
log.info("could not find a package with id : {}", id);
@@ -155,43 +173,4 @@ public class FileVaultReplicationPackage
return replicationPackage;
}
- @Override
- protected ReplicationPackage readPackageForDeactivation(ReplicationRequest request,
- InputStream stream, boolean install) throws ReplicationPackageBuildingException {
- Session session = null;
- ReplicationPackage pkg = new VoidReplicationPackage(request, NAME);
- try {
- session = repository.loginAdministrative(null);
- for (String path : request.getPaths()) {
- try {
- if (session.itemExists(path)) {
- session.removeItem(path);
- }
- else if (log.isInfoEnabled()) {
- log.info("nothing to remove: path {} doesn't exist", path);
- }
- } catch (Exception e) {
- if (log.isInfoEnabled()) {
- log.info("could not remove path {}", path, e);
- }
- }
- }
- session.save();
- } catch (Exception e) {
- if (log.isErrorEnabled()) {
- log.error("could not read / install the package", e);
- }
- } finally {
- if (session != null) {
- session.logout();
- }
- }
- return pkg;
- }
-
- @Override
- protected ReplicationPackage createPackageForDeactivation(ReplicationRequest request) {
- return new VoidReplicationPackage(request, NAME);
- }
-
}
Modified: sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/servlet/ReplicationAgentPollServlet.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/servlet/ReplicationAgentPollServlet.java?rev=1549567&r1=1549566&r2=1549567&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/servlet/ReplicationAgentPollServlet.java (original)
+++ sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/servlet/ReplicationAgentPollServlet.java Mon Dec 9 13:37:48 2013
@@ -19,8 +19,6 @@
package org.apache.sling.replication.servlet;
import java.io.IOException;
-import java.util.Arrays;
-
import javax.servlet.Servlet;
import javax.servlet.ServletException;
@@ -33,13 +31,13 @@ import org.apache.http.entity.ContentTyp
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.servlets.SlingAllMethodsServlet;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import org.apache.sling.replication.agent.ReplicationAgent;
import org.apache.sling.replication.agent.impl.ReplicationAgentResource;
+import org.apache.sling.replication.communication.ReplicationHeader;
import org.apache.sling.replication.queue.ReplicationQueue;
import org.apache.sling.replication.serialization.ReplicationPackage;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
@Component(metatype = false)
@Service(value = Servlet.class)
@@ -58,25 +56,29 @@ public class ReplicationAgentPollServlet
response.setContentType(ContentType.APPLICATION_OCTET_STREAM.toString());
- String queueName = request.getParameter("queue");
+ String queueName = request.getParameter(ReplicationHeader.QUEUE.toString());
ReplicationAgent agent = request.getResource().adaptTo(ReplicationAgent.class);
if (agent != null) {
try {
- // TODO : consider using queue distribution strategy some way and validating who's making this request
+ // TODO : consider using queue distribution strategy and validating who's making this request
+ if (log.isInfoEnabled()) {
+ log.info("getting item from queue {}", queueName);
+ }
ReplicationQueue queue = agent.getQueue(queueName);
// get first item
ReplicationPackage head = queue.getHead();
if (head != null) {
int bytesCopied = IOUtils.copy(head.getInputStream(),
response.getOutputStream());
- response.setHeader("type", head.getType());
- response.setHeader("action", head.getAction().toString());
- response.setHeader("path", Arrays.toString(head.getPaths()));
+ response.setHeader(ReplicationHeader.TYPE.toString(), head.getType());
if (log.isInfoEnabled()) {
log.info("{} bytes written into the response", bytesCopied);
}
+ // remove the item from the queue
+ // TODO : this should be conditional to successful import on polling instance
+ queue.removeHead();
} else {
if (log.isInfoEnabled()) {
log.info("nothing to fetch");
Modified: sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/servlet/ReplicationAgentPostServlet.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/servlet/ReplicationAgentPostServlet.java?rev=1549567&r1=1549566&r2=1549567&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/servlet/ReplicationAgentPostServlet.java (original)
+++ sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/servlet/ReplicationAgentPostServlet.java Mon Dec 9 13:37:48 2013
@@ -35,6 +35,7 @@ import org.apache.sling.replication.agen
import org.apache.sling.replication.agent.ReplicationAgent;
import org.apache.sling.replication.agent.impl.ReplicationAgentResource;
import org.apache.sling.replication.communication.ReplicationActionType;
+import org.apache.sling.replication.communication.ReplicationHeader;
import org.apache.sling.replication.communication.ReplicationRequest;
import org.apache.sling.replication.communication.ReplicationResponse;
import org.apache.sling.replication.queue.ReplicationQueueItemState.ItemState;
@@ -56,8 +57,8 @@ public class ReplicationAgentPostServlet
response.setContentType("application/json");
- String action = request.getParameter("action");
- String[] path = request.getParameterValues("path");
+ String action = request.getParameter(ReplicationHeader.ACTION.toString());
+ String[] path = request.getParameterValues(ReplicationHeader.PATH.toString());
ReplicationRequest replicationRequest = new ReplicationRequest(System.currentTimeMillis(),
ReplicationActionType.valueOf(action), path);
@@ -67,7 +68,7 @@ public class ReplicationAgentPostServlet
if (agent != null) {
try {
ReplicationResponse replicationResponse = agent.execute(replicationRequest);
- if (replicationResponse.isSuccessfull()
+ if (replicationResponse.isSuccessful()
|| ItemState.DROPPED.toString().equals(
replicationResponse.getStatus())) {
response.setStatus(200);
Modified: sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/servlet/ReplicationConfigurationServlet.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/servlet/ReplicationConfigurationServlet.java?rev=1549567&r1=1549566&r2=1549567&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/servlet/ReplicationConfigurationServlet.java (original)
+++ sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/servlet/ReplicationConfigurationServlet.java Mon Dec 9 13:37:48 2013
@@ -58,6 +58,7 @@ public class ReplicationConfigurationSer
@Override
protected void doPost(SlingHttpServletRequest request, SlingHttpServletResponse response)
throws ServletException, IOException {
+ response.setContentType("application/json");
@SuppressWarnings("unchecked")
Map<String, Object> parameterMap = request.getParameterMap();
Resource agentResource = request.getResource().getParent();
@@ -76,6 +77,7 @@ public class ReplicationConfigurationSer
@Override
protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response)
throws ServletException, IOException {
+ response.setContentType("application/json");
Resource resource = request.getResource();
ReplicationAgentConfiguration configuration = resource
.adaptTo(ReplicationAgentConfiguration.class);
Added: sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/servlet/ReplicationQueueServlet.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/servlet/ReplicationQueueServlet.java?rev=1549567&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/servlet/ReplicationQueueServlet.java (added)
+++ sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/servlet/ReplicationQueueServlet.java Mon Dec 9 13:37:48 2013
@@ -0,0 +1,61 @@
+/*
+ * 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.servlet;
+
+import java.io.IOException;
+import javax.servlet.Servlet;
+import javax.servlet.ServletException;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Properties;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.sling.api.SlingHttpServletRequest;
+import org.apache.sling.api.SlingHttpServletResponse;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.servlets.SlingAllMethodsServlet;
+import org.apache.sling.replication.agent.impl.ReplicationAgentQueueResource;
+import org.apache.sling.replication.queue.ReplicationQueue;
+
+@SuppressWarnings("serial")
+@Component(metatype = false)
+@Service(value = Servlet.class)
+@Properties({
+ @Property(name = "sling.servlet.resourceTypes", value = ReplicationAgentQueueResource.RESOURCE_TYPE),
+ @Property(name = "sling.servlet.methods", value = {"GET"})})
+public class ReplicationQueueServlet extends SlingAllMethodsServlet {
+
+ @Override
+ protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("application/json");
+ Resource resource = request.getResource();
+ ReplicationQueue queue = resource
+ .adaptTo(ReplicationQueue.class);
+ if (queue != null) {
+ response.getWriter().write(toJSoN(queue));
+ } else {
+ response.getWriter().write("{\"status\" : \"error\", \"message\":\"queue not found\"}");
+ }
+ }
+
+ private String toJSoN(ReplicationQueue queue) {
+ return "{" + "\"name\":\"" + queue.getName() + "\",\"empty\":" + queue.isEmpty() + "}";
+ }
+
+}
Modified: sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/servlet/ReplicationReceiverServlet.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/servlet/ReplicationReceiverServlet.java?rev=1549567&r1=1549566&r2=1549567&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/servlet/ReplicationReceiverServlet.java (original)
+++ sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/servlet/ReplicationReceiverServlet.java Mon Dec 9 13:37:48 2013
@@ -18,61 +18,97 @@
*/
package org.apache.sling.replication.servlet;
+import java.io.BufferedInputStream;
import java.io.IOException;
import java.util.Arrays;
-
+import java.util.Dictionary;
+import java.util.Hashtable;
import javax.servlet.Servlet;
import javax.servlet.ServletException;
-
+import javax.servlet.ServletInputStream;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Properties;
import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
-import org.apache.jackrabbit.util.Text;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.servlets.SlingAllMethodsServlet;
+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.ReplicationPackageBuilder;
+import org.apache.sling.replication.serialization.ReplicationPackageBuilderProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.apache.sling.replication.communication.ReplicationActionType;
-import org.apache.sling.replication.serialization.ReplicationPackage;
-
/**
* Servlet to handle reception of replication content.
*/
@SuppressWarnings("serial")
@Component(metatype = false)
@Service(value = Servlet.class)
-@Properties({ @Property(name = "sling.servlet.paths", value = "/system/replication/receive"),
- @Property(name = "sling.servlet.methods", value = "POST") })
+@Properties({@Property(name = "sling.servlet.paths", value = "/system/replication/receive"),
+ @Property(name = "sling.servlet.methods", value = "POST")})
public class ReplicationReceiverServlet extends SlingAllMethodsServlet {
private final Logger log = LoggerFactory.getLogger(getClass());
+ @Reference
+ private ReplicationPackageBuilderProvider replicationPackageBuilderProvider;
+
+ @Reference
+ private ReplicationEventFactory replicationEventFactory;
+
@Override
protected void doPost(SlingHttpServletRequest request, SlingHttpServletResponse response)
- throws ServletException, IOException {
+ throws ServletException, IOException {
boolean success = false;
final long start = System.currentTimeMillis();
response.setContentType("text/plain");
response.setCharacterEncoding("utf-8");
- ReplicationActionType actionType = ReplicationActionType.fromName(request
- .getHeader("Action"));
- String path = Text.unescape(request.getHeader("Path"));
try {
+ ReplicationPackage replicationPackage = null;
+ ServletInputStream stream = request.getInputStream();
+ String typeHeader = request.getHeader(ReplicationHeader.TYPE.toString());
+ if (typeHeader != null) {
+ ReplicationPackageBuilder replicationPackageBuilder = replicationPackageBuilderProvider.getReplicationPackageBuilder(typeHeader);
+ if (replicationPackageBuilder != null) {
+ replicationPackage = replicationPackageBuilder.readPackage(stream, true);
+ } else {
+ if (log.isWarnEnabled()) {
+ log.warn("cannot read streams of type {}", typeHeader);
+ }
+ }
+ } else {
+ BufferedInputStream bufferedInputStream = new BufferedInputStream(stream); // needed to allow for multiple reads
+ for (ReplicationPackageBuilder replicationPackageBuilder : replicationPackageBuilderProvider.getAvailableReplicationPackageBuilders()) {
+ try {
+ replicationPackage = replicationPackageBuilder.readPackage(bufferedInputStream, true);
+ } catch (Exception e) {
+ if (log.isWarnEnabled()) {
+ log.warn("received stream cannot be read with {}", replicationPackageBuilder);
+ }
+ }
+ }
+ }
- ReplicationPackage replicationPackage = request.adaptTo(ReplicationPackage.class);
if (replicationPackage != null) {
if (log.isInfoEnabled()) {
log.info("replication package read and installed for path(s) {}",
- Arrays.toString(replicationPackage.getPaths()));
+ Arrays.toString(replicationPackage.getPaths()));
}
success = true;
+
+ Dictionary<String, Object> dictionary = new Hashtable<String, Object>();
+ dictionary.put("replication.action", replicationPackage.getAction());
+ dictionary.put("replication.path", replicationPackage.getPaths());
+ replicationEventFactory.generateEvent(ReplicationEventType.PACKAGE_INSTALLED, dictionary);
} else {
- if (log.isInfoEnabled()) {
- log.info("could not read a replication package for path(s) {}", path);
+ if (log.isWarnEnabled()) {
+ log.warn("could not read a replication package");
}
}
} catch (final Exception e) {
@@ -81,12 +117,11 @@ public class ReplicationReceiverServlet
log.error("Error during replication: {}", e.getMessage(), e);
}
response.getWriter().print("error: " + e.toString());
- }
- finally {
+ } finally {
final long end = System.currentTimeMillis();
if (log.isInfoEnabled()) {
- log.info("Processed replication request in {}ms: {} of {} : {}", new Object[] {
- end - start, actionType, path, success });
+ log.info("Processed replication request in {}ms: : {}", new Object[]{
+ end - start, success});
}
}
Modified: sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/ReplicationTransportException.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/ReplicationTransportException.java?rev=1549567&r1=1549566&r2=1549567&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/ReplicationTransportException.java (original)
+++ sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/ReplicationTransportException.java Mon Dec 9 13:37:48 2013
@@ -19,7 +19,7 @@
package org.apache.sling.replication.transport;
/**
- * Represents an error happened while a {@link TransportHandler} is delivering a replication item to
+ * Represents an error happened while a {@link TransportHandler}Â is delivering a replication item to
* and endpoint.
*/
@SuppressWarnings("serial")
Modified: sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/TransportHandler.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/TransportHandler.java?rev=1549567&r1=1549566&r2=1549567&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/TransportHandler.java (original)
+++ sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/TransportHandler.java Mon Dec 9 13:37:48 2013
@@ -18,9 +18,9 @@
*/
package org.apache.sling.replication.transport;
-import org.apache.sling.replication.transport.authentication.AuthenticationHandler;
import org.apache.sling.replication.communication.ReplicationEndpoint;
import org.apache.sling.replication.serialization.ReplicationPackage;
+import org.apache.sling.replication.transport.authentication.TransportAuthenticationProvider;
/**
* A <code>TransportHandler</code> is responsible for implementing the transport of a
@@ -28,10 +28,27 @@ import org.apache.sling.replication.seri
*/
public interface TransportHandler {
+ /**
+ * execute the transport of a given {@link ReplicationPackage} to a specific {@link ReplicationEndpoint} using this
+ * transport and the supplied {@link TransportAuthenticationProvider} for authenticating the endpoint
+ *
+ * @param replicationPackage a {@link ReplicationPackage} to transport
+ * @param replicationEndpoint a {@link ReplicationEndpoint} to transport the package to
+ * @param transportAuthenticationProvider
+ * a {@link TransportAuthenticationProvider} to authenticate the endpoint
+ * @throws ReplicationTransportException if any error occurs during the transport
+ */
void transport(ReplicationPackage replicationPackage, ReplicationEndpoint replicationEndpoint,
- AuthenticationHandler<?, ?> authenticationHandler)
- throws ReplicationTransportException;
+ TransportAuthenticationProvider<?, ?> transportAuthenticationProvider)
+ throws ReplicationTransportException;
- boolean supportsAuthenticationHandler(AuthenticationHandler<?, ?> authenticationHandler);
+ /**
+ * defines if this {@link TransportHandler} can be authenticated using the given {@link TransportAuthenticationProvider}
+ *
+ * @param transportAuthenticationProvider
+ * a {@link TransportAuthenticationProvider} to be used to authenticate {@link ReplicationEndpoint}s with this {@link TransportHandler}
+ * @return <code>true</code> if the given {@link TransportAuthenticationProvider} is supported by this {@link TransportHandler}
+ */
+ boolean supportsAuthenticationProvider(TransportAuthenticationProvider<?, ?> transportAuthenticationProvider);
}
\ No newline at end of file
Added: sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/authentication/TransportAuthenticationContext.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/authentication/TransportAuthenticationContext.java?rev=1549567&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/authentication/TransportAuthenticationContext.java (added)
+++ sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/authentication/TransportAuthenticationContext.java Mon Dec 9 13:37:48 2013
@@ -0,0 +1,40 @@
+/*
+ * 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.authentication;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class TransportAuthenticationContext {
+ private final Map<String, Object> attributes = new HashMap<String, Object>();
+
+ @SuppressWarnings("unchecked")
+ public <T> T getAttribute(String name, Class<? extends T> klass) {
+ T result = null;
+ Object object = attributes.get(name);
+ if (klass.isInstance(object)) {
+ result = (T) object;
+ }
+ return result;
+ }
+
+ public <T> void addAttribute(String name, T object) {
+ attributes.put(name, object);
+ }
+}
Added: sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/authentication/TransportAuthenticationException.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/authentication/TransportAuthenticationException.java?rev=1549567&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/authentication/TransportAuthenticationException.java (added)
+++ sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/authentication/TransportAuthenticationException.java Mon Dec 9 13:37:48 2013
@@ -0,0 +1,33 @@
+/*
+ * 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.authentication;
+
+
+@SuppressWarnings("serial")
+public class TransportAuthenticationException extends Exception {
+
+ public TransportAuthenticationException(String string) {
+ super(string);
+ }
+
+ public TransportAuthenticationException(Exception e) {
+ super(e);
+ }
+
+}
Added: sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/authentication/TransportAuthenticationProvider.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/authentication/TransportAuthenticationProvider.java?rev=1549567&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/authentication/TransportAuthenticationProvider.java (added)
+++ sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/authentication/TransportAuthenticationProvider.java Mon Dec 9 13:37:48 2013
@@ -0,0 +1,33 @@
+/*
+ * 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.authentication;
+
+
+/**
+ * A <code>TransportAuthenticationProvider</code> is responsible for authentication of instances sending and
+ * receiving replication items via {@link org.apache.sling.replication.transport.TransportHandler}s
+ */
+public interface TransportAuthenticationProvider<A, T> {
+
+ boolean canAuthenticate(Class<?> authenticable);
+
+ T authenticate(A authenticable, TransportAuthenticationContext context)
+ throws TransportAuthenticationException;
+
+}
Added: sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/authentication/TransportAuthenticationProviderFactory.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/authentication/TransportAuthenticationProviderFactory.java?rev=1549567&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/authentication/TransportAuthenticationProviderFactory.java (added)
+++ sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/authentication/TransportAuthenticationProviderFactory.java Mon Dec 9 13:37:48 2013
@@ -0,0 +1,31 @@
+/*
+ * 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.authentication;
+
+import java.util.Map;
+
+/**
+ * Factory for {@link TransportAuthenticationProvider}s
+ */
+public interface TransportAuthenticationProviderFactory {
+
+ TransportAuthenticationProvider<?, ?> createAuthenticationProvider(Map<String, String> properties);
+
+ String getType();
+}
Added: sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/authentication/impl/NopTransportAuthenticationProvider.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/authentication/impl/NopTransportAuthenticationProvider.java?rev=1549567&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/authentication/impl/NopTransportAuthenticationProvider.java (added)
+++ sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/authentication/impl/NopTransportAuthenticationProvider.java Mon Dec 9 13:37:48 2013
@@ -0,0 +1,44 @@
+/*
+ * 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.authentication.impl;
+
+import org.apache.sling.replication.transport.TransportHandler;
+import org.apache.sling.replication.transport.authentication.TransportAuthenticationContext;
+import org.apache.sling.replication.transport.authentication.TransportAuthenticationException;
+import org.apache.sling.replication.transport.authentication.TransportAuthenticationProvider;
+
+/**
+ * {@link org.apache.sling.replication.transport.authentication.TransportAuthenticationProvider}Â used when no authentication is required
+ */
+public class NopTransportAuthenticationProvider implements TransportAuthenticationProvider<Object, Object> {
+
+ public boolean supportsTransportHandler(TransportHandler transportHandler) {
+ return true;
+ }
+
+ public Object authenticate(Object authenticable, TransportAuthenticationContext context)
+ throws TransportAuthenticationException {
+ return authenticable;
+ }
+
+ public boolean canAuthenticate(Class<?> authenticable) {
+ return true;
+ }
+
+}
Added: sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/authentication/impl/NopTransportAuthenticationProviderFactory.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/authentication/impl/NopTransportAuthenticationProviderFactory.java?rev=1549567&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/authentication/impl/NopTransportAuthenticationProviderFactory.java (added)
+++ sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/authentication/impl/NopTransportAuthenticationProviderFactory.java Mon Dec 9 13:37:48 2013
@@ -0,0 +1,46 @@
+/*
+ * 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.authentication.impl;
+
+import java.util.Map;
+
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.sling.replication.transport.authentication.TransportAuthenticationProvider;
+import org.apache.sling.replication.transport.authentication.TransportAuthenticationProviderFactory;
+
+
+@Component(immediate = true)
+@Service(value = TransportAuthenticationProviderFactory.class)
+@Property(name = "name", value = NopTransportAuthenticationProviderFactory.TYPE)
+public class NopTransportAuthenticationProviderFactory implements TransportAuthenticationProviderFactory {
+ public static final String TYPE = "nop";
+
+ private static final TransportAuthenticationProvider<Object, Object> NOP_TRANSPORT_AUTHENTICATION_PROVIDER = new NopTransportAuthenticationProvider();
+
+ public TransportAuthenticationProvider<Object, Object> createAuthenticationProvider(Map<String, String> properties) {
+ return NOP_TRANSPORT_AUTHENTICATION_PROVIDER;
+ }
+
+ public String getType() {
+ return TYPE;
+ }
+
+}
Added: sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/authentication/impl/RepositoryTransportAuthenticationProvider.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/authentication/impl/RepositoryTransportAuthenticationProvider.java?rev=1549567&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/authentication/impl/RepositoryTransportAuthenticationProvider.java (added)
+++ sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/authentication/impl/RepositoryTransportAuthenticationProvider.java Mon Dec 9 13:37:48 2013
@@ -0,0 +1,73 @@
+/*
+ * 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.authentication.impl;
+
+import javax.jcr.Credentials;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.SimpleCredentials;
+import org.apache.sling.jcr.api.SlingRepository;
+import org.apache.sling.replication.transport.authentication.TransportAuthenticationContext;
+import org.apache.sling.replication.transport.authentication.TransportAuthenticationException;
+import org.apache.sling.replication.transport.authentication.TransportAuthenticationProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RepositoryTransportAuthenticationProvider implements TransportAuthenticationProvider<SlingRepository, Session> {
+
+ private final Logger log = LoggerFactory.getLogger(getClass());
+
+ private final Credentials credentials;
+
+ public RepositoryTransportAuthenticationProvider(String user, String password) {
+ this.credentials = new SimpleCredentials(user, password.toCharArray());
+ }
+
+ public boolean canAuthenticate(Class<?> authenticable) {
+ return SlingRepository.class.isAssignableFrom(authenticable);
+ }
+
+ public Session authenticate(SlingRepository authenticable, TransportAuthenticationContext context)
+ throws TransportAuthenticationException {
+ String path = context.getAttribute("path", String.class);
+ if (path != null) {
+ Session session = null;
+ try {
+ session = authenticable.login(credentials);
+ if (!session.nodeExists(path)) {
+ throw new TransportAuthenticationException("failed to read path " + path);
+ } else {
+ if (log.isInfoEnabled()) {
+ log.info("authenticated path {} ", path);
+ }
+ return session;
+ }
+ } catch (RepositoryException re) {
+ if (session != null) {
+ session.logout();
+ }
+ throw new TransportAuthenticationException(re);
+ }
+ } else {
+ throw new TransportAuthenticationException(
+ "the path to authenticate is missing from the context");
+ }
+ }
+
+}
Added: sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/authentication/impl/RepositoryTransportAuthenticationProviderFactory.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/authentication/impl/RepositoryTransportAuthenticationProviderFactory.java?rev=1549567&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/authentication/impl/RepositoryTransportAuthenticationProviderFactory.java (added)
+++ sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/authentication/impl/RepositoryTransportAuthenticationProviderFactory.java Mon Dec 9 13:37:48 2013
@@ -0,0 +1,56 @@
+/*
+ * 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.authentication.impl;
+
+import java.util.Map;
+import javax.jcr.Session;
+
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.sling.jcr.api.SlingRepository;
+import org.apache.sling.replication.transport.authentication.TransportAuthenticationProvider;
+import org.apache.sling.replication.transport.authentication.TransportAuthenticationProviderFactory;
+
+
+@Component(immediate = true)
+@Service(value = TransportAuthenticationProviderFactory.class)
+@Property(name = "name", value = RepositoryTransportAuthenticationProviderFactory.TYPE)
+public class RepositoryTransportAuthenticationProviderFactory implements TransportAuthenticationProviderFactory {
+ public static final String TYPE = "repo-user";
+
+ public TransportAuthenticationProvider<SlingRepository, Session> createAuthenticationProvider(Map<String, String> properties) {
+ String user = null;
+ Object userProp = properties.get("user");
+ if (userProp != null) {
+ user = String.valueOf(userProp);
+ }
+ String password = null;
+ Object passwordProp = properties.get("password");
+ if (passwordProp != null) {
+ password = String.valueOf(passwordProp);
+ }
+ return new RepositoryTransportAuthenticationProvider(user, password);
+ }
+
+ public String getType() {
+ return TYPE;
+ }
+
+}
Added: sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/authentication/impl/UserCredentialsTransportAuthenticationProvider.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/authentication/impl/UserCredentialsTransportAuthenticationProvider.java?rev=1549567&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/authentication/impl/UserCredentialsTransportAuthenticationProvider.java (added)
+++ sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/authentication/impl/UserCredentialsTransportAuthenticationProvider.java Mon Dec 9 13:37:48 2013
@@ -0,0 +1,65 @@
+/*
+ * 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.authentication.impl;
+
+import org.apache.http.HttpHost;
+import org.apache.http.client.fluent.Executor;
+import org.apache.sling.replication.communication.ReplicationEndpoint;
+import org.apache.sling.replication.transport.authentication.TransportAuthenticationContext;
+import org.apache.sling.replication.transport.authentication.TransportAuthenticationException;
+import org.apache.sling.replication.transport.authentication.TransportAuthenticationProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class UserCredentialsTransportAuthenticationProvider implements
+ TransportAuthenticationProvider<Executor, Executor> {
+
+ private final Logger log = LoggerFactory.getLogger(getClass());
+
+ private final String username;
+
+ private final String password;
+
+ public UserCredentialsTransportAuthenticationProvider(String username, String password) {
+ this.username = username;
+ this.password = password;
+ }
+
+ public Executor authenticate(Executor authenticable, TransportAuthenticationContext context)
+ throws TransportAuthenticationException {
+ ReplicationEndpoint endpoint = context.getAttribute("endpoint",
+ ReplicationEndpoint.class);
+ if (endpoint != null) {
+ Executor authenticated = authenticable.auth(new HttpHost(endpoint
+ .getUri().getHost()), username, password);
+ if (log.isInfoEnabled()) {
+ log.info("authenticated executor {} with user and password", authenticated);
+ }
+ return authenticated;
+ } else {
+ throw new TransportAuthenticationException(
+ "the endpoint to authenticate is missing from the context");
+ }
+ }
+
+ public boolean canAuthenticate(Class<?> authenticable) {
+ return Executor.class.isAssignableFrom(authenticable);
+ }
+
+}
Added: sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/authentication/impl/UserCredentialsTransportAuthenticationProviderFactory.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/authentication/impl/UserCredentialsTransportAuthenticationProviderFactory.java?rev=1549567&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/authentication/impl/UserCredentialsTransportAuthenticationProviderFactory.java (added)
+++ sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/authentication/impl/UserCredentialsTransportAuthenticationProviderFactory.java Mon Dec 9 13:37:48 2013
@@ -0,0 +1,56 @@
+/*
+ * 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.authentication.impl;
+
+import java.util.Map;
+
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.http.client.fluent.Executor;
+import org.apache.sling.replication.transport.authentication.TransportAuthenticationProvider;
+import org.apache.sling.replication.transport.authentication.TransportAuthenticationProviderFactory;
+
+
+@Component(immediate = true)
+@Service(value = TransportAuthenticationProviderFactory.class)
+@Property(name = "name", value = UserCredentialsTransportAuthenticationProviderFactory.TYPE)
+public class UserCredentialsTransportAuthenticationProviderFactory implements TransportAuthenticationProviderFactory {
+ public static final String TYPE = "user";
+
+ public TransportAuthenticationProvider<Executor, Executor> createAuthenticationProvider(
+ Map<String, String> properties) {
+ String user = null;
+ Object userProp = properties.get("user");
+ if (userProp != null) {
+ user = String.valueOf(userProp);
+ }
+ String password = null;
+ Object passwordProp = properties.get("password");
+ if (passwordProp != null) {
+ password = String.valueOf(passwordProp);
+ }
+ return new UserCredentialsTransportAuthenticationProvider(user, password);
+ }
+
+ public String getType() {
+ return TYPE;
+ }
+
+}
Modified: sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/impl/HttpTransportHandler.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/impl/HttpTransportHandler.java?rev=1549567&r1=1549566&r2=1549567&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/impl/HttpTransportHandler.java (original)
+++ sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/impl/HttpTransportHandler.java Mon Dec 9 13:37:48 2013
@@ -28,13 +28,13 @@ import org.apache.http.client.fluent.Exe
import org.apache.http.client.fluent.Request;
import org.apache.http.client.fluent.Response;
import org.apache.http.entity.ContentType;
-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.serialization.ReplicationPackage;
import org.apache.sling.replication.transport.ReplicationTransportException;
import org.apache.sling.replication.transport.TransportHandler;
-import org.apache.sling.replication.transport.authentication.AuthenticationContext;
-import org.apache.sling.replication.transport.authentication.AuthenticationHandler;
+import org.apache.sling.replication.transport.authentication.TransportAuthenticationContext;
+import org.apache.sling.replication.transport.authentication.TransportAuthenticationProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -53,28 +53,25 @@ public class HttpTransportHandler implem
@SuppressWarnings("unchecked")
public void transport(ReplicationPackage replicationPackage,
ReplicationEndpoint replicationEndpoint,
- AuthenticationHandler<?, ?> authenticationHandler)
+ TransportAuthenticationProvider<?, ?> transportAuthenticationProvider)
throws ReplicationTransportException {
if (log.isInfoEnabled()) {
log.info("delivering package {} to {} using auth {}",
new Object[]{replicationPackage.getId(),
- replicationEndpoint.getUri(), authenticationHandler});
+ replicationEndpoint.getUri(), transportAuthenticationProvider});
}
try {
Executor executor = Executor.newInstance();
- AuthenticationContext context = new AuthenticationContext();
+ TransportAuthenticationContext context = new TransportAuthenticationContext();
context.addAttribute("endpoint", replicationEndpoint);
- executor = ((AuthenticationHandler<Executor, Executor>) authenticationHandler)
+ executor = ((TransportAuthenticationProvider<Executor, Executor>) transportAuthenticationProvider)
.authenticate(executor, context);
String[] paths = replicationPackage.getPaths();
String type = replicationPackage.getType();
String pathsString = Arrays.toString(paths);
- ReplicationActionType action = ReplicationActionType.valueOf(replicationPackage
- .getAction());
Request req = Request.Post(replicationEndpoint.getUri()).useExpectContinue()
- .addHeader("Path", pathsString).addHeader("Action", action.toString())
- .addHeader("Type", type);
+ .addHeader(ReplicationHeader.TYPE.toString(), type);
if (replicationPackage.getInputStream() != null) {
req = req.bodyStream(replicationPackage.getInputStream(),
ContentType.APPLICATION_OCTET_STREAM);
@@ -95,7 +92,7 @@ public class HttpTransportHandler implem
}
}
- public boolean supportsAuthenticationHandler(AuthenticationHandler<?, ?> authenticationHandler) {
- return authenticationHandler.canAuthenticate(Executor.class);
+ public boolean supportsAuthenticationProvider(TransportAuthenticationProvider<?, ?> transportAuthenticationProvider) {
+ return transportAuthenticationProvider.canAuthenticate(Executor.class);
}
}
\ No newline at end of file
Modified: sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/impl/PollingTransportHandler.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/impl/PollingTransportHandler.java?rev=1549567&r1=1549566&r2=1549567&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/impl/PollingTransportHandler.java (original)
+++ sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/impl/PollingTransportHandler.java Mon Dec 9 13:37:48 2013
@@ -28,16 +28,14 @@ import org.apache.http.HttpResponse;
import org.apache.http.client.fluent.Executor;
import org.apache.http.client.fluent.Request;
import org.apache.http.client.fluent.Response;
-import org.apache.jackrabbit.util.Text;
-import org.apache.sling.replication.communication.ReplicationActionType;
import org.apache.sling.replication.communication.ReplicationEndpoint;
-import org.apache.sling.replication.communication.ReplicationRequest;
+import org.apache.sling.replication.communication.ReplicationHeader;
import org.apache.sling.replication.serialization.ReplicationPackage;
import org.apache.sling.replication.serialization.ReplicationPackageBuilderProvider;
import org.apache.sling.replication.transport.ReplicationTransportException;
import org.apache.sling.replication.transport.TransportHandler;
-import org.apache.sling.replication.transport.authentication.AuthenticationContext;
-import org.apache.sling.replication.transport.authentication.AuthenticationHandler;
+import org.apache.sling.replication.transport.authentication.TransportAuthenticationContext;
+import org.apache.sling.replication.transport.authentication.TransportAuthenticationProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -59,16 +57,16 @@ public class PollingTransportHandler imp
@SuppressWarnings("unchecked")
public void transport(ReplicationPackage replicationPackage,
ReplicationEndpoint replicationEndpoint,
- AuthenticationHandler<?, ?> authenticationHandler)
+ TransportAuthenticationProvider<?, ?> transportAuthenticationProvider)
throws ReplicationTransportException {
if (log.isInfoEnabled()) {
log.info("polling from {}", replicationEndpoint.getUri());
}
try {
Executor executor = Executor.newInstance();
- AuthenticationContext context = new AuthenticationContext();
+ TransportAuthenticationContext context = new TransportAuthenticationContext();
context.addAttribute("endpoint", replicationEndpoint);
- executor = ((AuthenticationHandler<Executor, Executor>) authenticationHandler)
+ executor = ((TransportAuthenticationProvider<Executor, Executor>) transportAuthenticationProvider)
.authenticate(executor, context);
Request req = Request.Get(replicationEndpoint.getUri()).useExpectContinue();
@@ -76,22 +74,12 @@ public class PollingTransportHandler imp
Response response = executor.execute(req);
HttpResponse httpResponse = response.returnResponse();
HttpEntity entity = httpResponse.getEntity();
- Header typeHeader = httpResponse.getFirstHeader("type");
- Header pathsHeader = httpResponse.getFirstHeader("path");
- Header actionHeader = httpResponse.getFirstHeader("action");
+ Header typeHeader = httpResponse.getFirstHeader(ReplicationHeader.TYPE.toString());
- if (typeHeader != null && pathsHeader != null && actionHeader != null) {
+ if (typeHeader != null) {
String type = typeHeader.getValue();
- String[] paths = Text.unescape(pathsHeader.getValue()).replace("[", "")
- .replace("]", "").split(", ");
- ReplicationActionType action = ReplicationActionType.valueOf(actionHeader
- .getValue());
- ReplicationRequest replicationRequest = new ReplicationRequest(
- System.currentTimeMillis(), action, paths);
-
ReplicationPackage readPackage = packageBuilderProvider
- .getReplicationPacakageBuilder(type).readPackage(
- replicationRequest, entity.getContent(), true);
+ .getReplicationPackageBuilder(type).readPackage(entity.getContent(), true);
if (log.isInfoEnabled()) {
log.info("package {} fetched and installed", readPackage.getId());
@@ -108,7 +96,7 @@ public class PollingTransportHandler imp
}
- public boolean supportsAuthenticationHandler(AuthenticationHandler<?, ?> authenticationHandler) {
- return authenticationHandler.canAuthenticate(Executor.class);
+ public boolean supportsAuthenticationProvider(TransportAuthenticationProvider<?, ?> transportAuthenticationProvider) {
+ return transportAuthenticationProvider.canAuthenticate(Executor.class);
}
}
Modified: sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/impl/RepositoryTransportHandler.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/impl/RepositoryTransportHandler.java?rev=1549567&r1=1549566&r2=1549567&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/impl/RepositoryTransportHandler.java (original)
+++ sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/transport/impl/RepositoryTransportHandler.java Mon Dec 9 13:37:48 2013
@@ -19,6 +19,8 @@
package org.apache.sling.replication.transport.impl;
import java.net.URI;
+import java.util.Dictionary;
+import java.util.Properties;
import javax.jcr.Node;
import javax.jcr.Session;
import javax.jcr.nodetype.NodeType;
@@ -27,13 +29,18 @@ import org.apache.felix.scr.annotations.
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
+import org.apache.jackrabbit.JcrConstants;
+import org.apache.jackrabbit.util.Text;
import org.apache.sling.jcr.api.SlingRepository;
import org.apache.sling.replication.communication.ReplicationEndpoint;
+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.transport.ReplicationTransportException;
import org.apache.sling.replication.transport.TransportHandler;
-import org.apache.sling.replication.transport.authentication.AuthenticationContext;
-import org.apache.sling.replication.transport.authentication.AuthenticationHandler;
+import org.apache.sling.replication.transport.authentication.TransportAuthenticationContext;
+import org.apache.sling.replication.transport.authentication.TransportAuthenticationProvider;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -51,37 +58,57 @@ public class RepositoryTransportHandler
@Reference
private SlingRepository repository;
+ @Reference
+ private ReplicationEventFactory replicationEventFactory;
+
public void transport(ReplicationPackage replicationPackage,
- ReplicationEndpoint replicationEndpoint,
- AuthenticationHandler<?, ?> authenticationHandler)
- throws ReplicationTransportException {
+ ReplicationEndpoint replicationEndpoint,
+ TransportAuthenticationProvider<?, ?> transportAuthenticationProvider)
+ throws ReplicationTransportException {
if (validateEndpoint(replicationEndpoint)) {
+ Session session = null;
try {
- AuthenticationContext authenticationContext = new AuthenticationContext();
- String path = new StringBuilder(replicationEndpoint.getUri().getHost()).append(
- replicationEndpoint.getUri().getPath()).toString();
- authenticationContext.addAttribute("path", path);
- @SuppressWarnings("unchecked")
- Session session = ((AuthenticationHandler<SlingRepository, Session>) authenticationHandler)
- .authenticate(repository, authenticationContext);
+ TransportAuthenticationContext transportAuthenticationContext = new TransportAuthenticationContext();
+ String path = replicationEndpoint.getUri().toString().replace("repo:/", "");
+ transportAuthenticationContext.addAttribute("path", path);
+ session = ((TransportAuthenticationProvider<SlingRepository, Session>) transportAuthenticationProvider)
+ .authenticate(repository, transportAuthenticationContext);
+ int lastSlash = replicationPackage.getId().lastIndexOf('/');
+ String nodeName = Text.escape(lastSlash < 0 ? replicationPackage.getId() : replicationPackage.getId().substring(lastSlash + 1));
+ if (log.isInfoEnabled()) {
+ log.info("creating node {} in {}", replicationPackage.getId(), nodeName);
+ }
if (session != null) {
- Node addedNode = session.getNode(path).addNode(replicationPackage.getId(),
- NodeType.NT_FILE);
+ Node addedNode = session.getNode(path).addNode(nodeName,
+ NodeType.NT_FILE);
+ Node contentNode = addedNode.addNode(JcrConstants.JCR_CONTENT, NodeType.NT_RESOURCE);
+ if (contentNode != null) {
+ contentNode.setProperty(JcrConstants.JCR_DATA, session.getValueFactory().createBinary(replicationPackage.getInputStream()));
+ session.save();
+ }
if (log.isInfoEnabled()) {
log.info("package {} delivered to the repository as node {} ",
- replicationPackage.getId(), addedNode.getPath());
+ replicationPackage.getId(), addedNode.getPath());
}
- // TODO : trigger event, this event can be used to ask an author to get the persisted package
+ Dictionary<Object, Object> props = new Properties();
+ props.put("transport", NAME);
+ props.put("path", replicationPackage.getPaths());
+ replicationEventFactory.generateEvent(ReplicationEventType.PACKAGE_REPLICATED, props);
+
} else {
throw new ReplicationTransportException(
- "could not get a Session to deliver package to the repository");
+ "could not get a Session to deliver package to the repository");
}
} catch (Exception e) {
throw new ReplicationTransportException(e);
+ } finally {
+ if (session != null) {
+ session.logout();
+ }
}
} else {
throw new ReplicationTransportException("invalid endpoint "
- + replicationEndpoint.getUri());
+ + replicationEndpoint.getUri());
}
}
@@ -90,7 +117,7 @@ public class RepositoryTransportHandler
return REPO_SCHEME.equals(uri.getScheme()) && uri.getHost() != null;
}
- public boolean supportsAuthenticationHandler(AuthenticationHandler<?, ?> authenticationHandler) {
- return authenticationHandler.canAuthenticate(SlingRepository.class);
+ public boolean supportsAuthenticationProvider(TransportAuthenticationProvider<?, ?> transportAuthenticationProvider) {
+ return transportAuthenticationProvider.canAuthenticate(SlingRepository.class);
}
}
Modified: sling/trunk/contrib/extensions/replication/src/main/resources/SLING-CONTENT/libs/sling/replication/agents/org.apache.sling.replication.agent.impl.ReplicationAgentServiceFactory-publish-reverse.json
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/src/main/resources/SLING-CONTENT/libs/sling/replication/agents/org.apache.sling.replication.agent.impl.ReplicationAgentServiceFactory-publish-reverse.json?rev=1549567&r1=1549566&r2=1549567&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/replication/src/main/resources/SLING-CONTENT/libs/sling/replication/agents/org.apache.sling.replication.agent.impl.ReplicationAgentServiceFactory-publish-reverse.json (original)
+++ sling/trunk/contrib/extensions/replication/src/main/resources/SLING-CONTENT/libs/sling/replication/agents/org.apache.sling.replication.agent.impl.ReplicationAgentServiceFactory-publish-reverse.json Mon Dec 9 13:37:48 2013
@@ -1,11 +0,0 @@
-{
- "jcr:primaryType" : "sling:OsgiConfig",
- "name" : "publish-reverse",
- "endpoint" : "http://localhost:4503/system/replication/agent/reverse-pub",
- "TransportHandler.target" : "(name=poll)",
- "ReplicationPackageBuilder.target" : "(name=vlt)",
- "ReplicationQueueProvider.target" : "(name=sjh)",
- "AuthenticationHandlerFactory.target" : "(name=user)",
- "authentication.properties" : ["user=admin","password=admin"],
- "ReplicationQueueDistributionStrategy.target" : "(name=single)"
-}
Modified: sling/trunk/contrib/extensions/replication/src/main/resources/SLING-CONTENT/libs/sling/replication/agents/org.apache.sling.replication.agent.impl.ReplicationAgentServiceFactory-publish.json
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/src/main/resources/SLING-CONTENT/libs/sling/replication/agents/org.apache.sling.replication.agent.impl.ReplicationAgentServiceFactory-publish.json?rev=1549567&r1=1549566&r2=1549567&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/replication/src/main/resources/SLING-CONTENT/libs/sling/replication/agents/org.apache.sling.replication.agent.impl.ReplicationAgentServiceFactory-publish.json (original)
+++ sling/trunk/contrib/extensions/replication/src/main/resources/SLING-CONTENT/libs/sling/replication/agents/org.apache.sling.replication.agent.impl.ReplicationAgentServiceFactory-publish.json Mon Dec 9 13:37:48 2013
@@ -1,11 +0,0 @@
-{
- "jcr:primaryType" : "sling:OsgiConfig",
- "name" : "publish",
- "endpoint" : "http://localhost:4503/system/replication/receive",
- "TransportHandler.target" : "(name=http)",
- "ReplicationPackageBuilder.target" : "(name=vlt)",
- "ReplicationQueueProvider.target" : "(name=sjh)",
- "AuthenticationHandlerFactory.target" : "(name=user)",
- "authentication.properties" : ["user=admin","password=admin"],
- "ReplicationQueueDistributionStrategy.target" : "(name=single)"
-}
Modified: sling/trunk/contrib/extensions/replication/src/main/resources/SLING-CONTENT/libs/sling/replication/agents/org.apache.sling.replication.agent.impl.ReplicationAgentServiceFactory-reversehttp.json
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/src/main/resources/SLING-CONTENT/libs/sling/replication/agents/org.apache.sling.replication.agent.impl.ReplicationAgentServiceFactory-reversehttp.json?rev=1549567&r1=1549566&r2=1549567&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/replication/src/main/resources/SLING-CONTENT/libs/sling/replication/agents/org.apache.sling.replication.agent.impl.ReplicationAgentServiceFactory-reversehttp.json (original)
+++ sling/trunk/contrib/extensions/replication/src/main/resources/SLING-CONTENT/libs/sling/replication/agents/org.apache.sling.replication.agent.impl.ReplicationAgentServiceFactory-reversehttp.json Mon Dec 9 13:37:48 2013
@@ -1,12 +0,0 @@
-{
- "jcr:primaryType" : "sling:OsgiConfig",
- "name" : "reversehttp",
- "endpoint" : "http://localhost:4502/system/replication/receive",
- "TransportHandler.target" : "(name=http)",
- "ReplicationPackageBuilder.target" : "(name=vlt)",
- "ReplicationQueueProvider.target" : "(name=sjh)",
- "AuthenticationHandlerFactory.target" : "(name=user)",
- "authentication.properties" : ["user=admin","password=admin"],
- "ReplicationQueueDistributionStrategy.target" : "(name=error)",
- "rules" : ["trigger on path: /content/usergenerated"]
-}
Modified: sling/trunk/contrib/extensions/replication/src/main/resources/SLING-CONTENT/libs/sling/replication/agents/org.apache.sling.replication.agent.impl.ReplicationAgentServiceFactory-reverserepo.json
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/src/main/resources/SLING-CONTENT/libs/sling/replication/agents/org.apache.sling.replication.agent.impl.ReplicationAgentServiceFactory-reverserepo.json?rev=1549567&r1=1549566&r2=1549567&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/replication/src/main/resources/SLING-CONTENT/libs/sling/replication/agents/org.apache.sling.replication.agent.impl.ReplicationAgentServiceFactory-reverserepo.json (original)
+++ sling/trunk/contrib/extensions/replication/src/main/resources/SLING-CONTENT/libs/sling/replication/agents/org.apache.sling.replication.agent.impl.ReplicationAgentServiceFactory-reverserepo.json Mon Dec 9 13:37:48 2013
@@ -1,12 +0,0 @@
-{
- "jcr:primaryType" : "sling:OsgiConfig",
- "name" : "reverserepo",
- "endpoint" : "repo://var/replication/outbox",
- "TransportHandler.target" : "(name=repository)",
- "ReplicationPackageBuilder.target" : "(name=vlt)",
- "ReplicationQueueProvider.target" : "(name=sjh)",
- "AuthenticationHandlerFactory.target" : "(name=repo-user)",
- "authentication.properties" : ["user=admin","password=admin"],
- "ReplicationQueueDistributionStrategy.target" : "(name=single)",
- "rules" : ["trigger on path: /content"]
-}
Added: sling/trunk/contrib/extensions/replication/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/src/main/resources/SLING-CONTENT/libs/sling/replication/config.author/org.apache.sling.replication.agent.impl.ReplicationAgentServiceFactory-publish-reverse.json?rev=1549567&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/replication/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/src/main/resources/SLING-CONTENT/libs/sling/replication/config.author/org.apache.sling.replication.agent.impl.ReplicationAgentServiceFactory-publish-reverse.json Mon Dec 9 13:37:48 2013
@@ -0,0 +1,11 @@
+{
+ "jcr:primaryType" : "sling:OsgiConfig",
+ "name" : "publish-reverse",
+ "endpoint" : "http://localhost:4503/system/replication/agent/reverserepo",
+ "TransportHandler.target" : "(name=poll)",
+ "ReplicationPackageBuilder.target" : "(name=vlt)",
+ "ReplicationQueueProvider.target" : "(name=sjh)",
+ "TransportAuthenticationProviderFactory.target" : "(name=user)",
+ "authentication.properties" : ["user=admin","password=admin"],
+ "ReplicationQueueDistributionStrategy.target" : "(name=single)"
+}
Added: sling/trunk/contrib/extensions/replication/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/src/main/resources/SLING-CONTENT/libs/sling/replication/config.author/org.apache.sling.replication.agent.impl.ReplicationAgentServiceFactory-publish.json?rev=1549567&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/replication/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/src/main/resources/SLING-CONTENT/libs/sling/replication/config.author/org.apache.sling.replication.agent.impl.ReplicationAgentServiceFactory-publish.json Mon Dec 9 13:37:48 2013
@@ -0,0 +1,11 @@
+{
+ "jcr:primaryType" : "sling:OsgiConfig",
+ "name" : "publish",
+ "endpoint" : "http://localhost:4503/system/replication/receive",
+ "TransportHandler.target" : "(name=http)",
+ "ReplicationPackageBuilder.target" : "(name=vlt)",
+ "ReplicationQueueProvider.target" : "(name=sjh)",
+ "TransportAuthenticationProviderFactory.target" : "(name=user)",
+ "authentication.properties" : ["user=admin","password=admin"],
+ "ReplicationQueueDistributionStrategy.target" : "(name=single)"
+}
Added: sling/trunk/contrib/extensions/replication/src/main/resources/SLING-CONTENT/libs/sling/replication/config.publish/org.apache.sling.replication.agent.impl.ReplicationAgentServiceFactory-reversehttp.json
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/src/main/resources/SLING-CONTENT/libs/sling/replication/config.publish/org.apache.sling.replication.agent.impl.ReplicationAgentServiceFactory-reversehttp.json?rev=1549567&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/replication/src/main/resources/SLING-CONTENT/libs/sling/replication/config.publish/org.apache.sling.replication.agent.impl.ReplicationAgentServiceFactory-reversehttp.json (added)
+++ sling/trunk/contrib/extensions/replication/src/main/resources/SLING-CONTENT/libs/sling/replication/config.publish/org.apache.sling.replication.agent.impl.ReplicationAgentServiceFactory-reversehttp.json Mon Dec 9 13:37:48 2013
@@ -0,0 +1,13 @@
+{
+ "jcr:primaryType" : "sling:OsgiConfig",
+ "name" : "reversehttp",
+ "endpoint" : "http://localhost:4502/system/replication/receive",
+ "TransportHandler.target" : "(name=http)",
+ "ReplicationPackageBuilder.target" : "(name=vlt)",
+ "ReplicationQueueProvider.target" : "(name=sjh)",
+ "TransportAuthenticationProviderFactory.target" : "(name=user)",
+ "authentication.properties" : ["user=admin","password=admin"],
+ "ReplicationQueueDistributionStrategy.target" : "(name=error)",
+ "rules" : ["trigger on path: /content/usergenerated"],
+ "enabled" : false
+}