sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tomm...@apache.org
Subject svn commit: r1578436 [2/2] - in /sling/trunk/contrib/extensions/replication/src: main/java/org/apache/sling/replication/agent/impl/ main/java/org/apache/sling/replication/resources/ main/java/org/apache/sling/replication/resources/impl/ main/java/org/a...
Date Mon, 17 Mar 2014 15:26:46 GMT
Added: sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/servlet/ReplicationPackageImporterServlet.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/servlet/ReplicationPackageImporterServlet.java?rev=1578436&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/servlet/ReplicationPackageImporterServlet.java
(added)
+++ sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/servlet/ReplicationPackageImporterServlet.java
Mon Mar 17 15:26:45 2014
@@ -0,0 +1,84 @@
+/*
+ * 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 java.io.InputStream;
+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.servlets.SlingAllMethodsServlet;
+import org.apache.sling.replication.communication.ReplicationHeader;
+import org.apache.sling.replication.resources.ReplicationConstants;
+import org.apache.sling.replication.serialization.ReplicationPackageImporter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Servlet to handle reception of replication content.
+ */
+@SuppressWarnings("serial")
+@Component(metatype = false)
+@Service(value = Servlet.class)
+@Properties({
+        @Property(name = "sling.servlet.resourceTypes", value = ReplicationConstants.IMPORTER_RESOURCE_TYPE),
+        @Property(name = "sling.servlet.methods", value = "POST")})
+public class ReplicationPackageImporterServlet extends SlingAllMethodsServlet {
+
+    private final Logger log = LoggerFactory.getLogger(getClass());
+
+    @Override
+    protected void doPost(SlingHttpServletRequest request, SlingHttpServletResponse response)
+            throws ServletException, IOException {
+
+        ReplicationPackageImporter replicationPackageImporter = request
+                .getResource()
+                .adaptTo(ReplicationPackageImporter.class);
+
+        boolean success = false;
+        final long start = System.currentTimeMillis();
+        response.setContentType("text/plain");
+        response.setCharacterEncoding("utf-8");
+
+        InputStream stream = request.getInputStream();
+        String type = request.getHeader(ReplicationHeader.TYPE.toString());
+        try {
+           success = replicationPackageImporter.importStream(stream, type);
+        } catch (final Exception e) {
+            response.setStatus(400);
+            if (log.isErrorEnabled()) {
+                log.error("Error during replication: {}", e.getMessage(), e);
+            }
+            response.getWriter().print("error: " + e.toString());
+        } finally {
+            final long end = System.currentTimeMillis();
+            if (log.isInfoEnabled()) {
+                log.info("Processed replication request in {}ms: : {}", new Object[]{
+                        end - start, success});
+            }
+        }
+
+    }
+
+}

Propchange: sling/trunk/contrib/extensions/replication/src/main/java/org/apache/sling/replication/servlet/ReplicationPackageImporterServlet.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: sling/trunk/contrib/extensions/replication/src/main/resources/SLING-CONTENT/libs/sling/replication/config/org.apache.sling.replication.transport.impl.HttpTransportHandlerFactory-http-publish-receive.json
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/src/main/resources/SLING-CONTENT/libs/sling/replication/config/org.apache.sling.replication.transport.impl.HttpTransportHandlerFactory-http-publish-receive.json?rev=1578436&r1=1578435&r2=1578436&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/replication/src/main/resources/SLING-CONTENT/libs/sling/replication/config/org.apache.sling.replication.transport.impl.HttpTransportHandlerFactory-http-publish-receive.json
(original)
+++ sling/trunk/contrib/extensions/replication/src/main/resources/SLING-CONTENT/libs/sling/replication/config/org.apache.sling.replication.transport.impl.HttpTransportHandlerFactory-http-publish-receive.json
Mon Mar 17 15:26:45 2014
@@ -3,5 +3,5 @@
     "name" : "http-publish-receive",
     "TransportAuthenticationProviderFactory.target" : "(name=user)",
     "authentication.properties" : ["user=admin","password=admin"],
-    "endpoints" : [ "http://localhost:4503/system/replication/receive" ]
+    "endpoints" : [ "http://localhost:4503/system/replication/importer/default" ]
 }
\ No newline at end of file

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

Added: sling/trunk/contrib/extensions/replication/src/main/resources/SLING-CONTENT/libs/sling/replication/config/resourceproviders/org.apache.sling.replication.resources.impl.OsgiPropertiesResourceProviderFactory-replicationAgentsConfig.json
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/replication/src/main/resources/SLING-CONTENT/libs/sling/replication/config/resourceproviders/org.apache.sling.replication.resources.impl.OsgiPropertiesResourceProviderFactory-replicationAgentsConfig.json?rev=1578436&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/replication/src/main/resources/SLING-CONTENT/libs/sling/replication/config/resourceproviders/org.apache.sling.replication.resources.impl.OsgiPropertiesResourceProviderFactory-replicationAgentsConfig.json
(added)
+++ sling/trunk/contrib/extensions/replication/src/main/resources/SLING-CONTENT/libs/sling/replication/config/resourceproviders/org.apache.sling.replication.resources.impl.OsgiPropertiesResourceProviderFactory-replicationAgentsConfig.json
Mon Mar 17 15:26:45 2014
@@ -0,0 +1,20 @@
+{
+    "jcr:primaryType" : "sling:OsgiConfig",
+    "name" : "replicationAgentsConfig",
+    "provider.roots" : [ "/libs/sling/replication/config/agent" ],
+    "serviceType" : "org.apache.sling.replication.agent.impl.ReplicationAgentServiceFactory",
+    "providerType" : "osgiConfig",
+    "resourceProperties" : [
+        "../sling:resourceType=replication/config/agents",
+
+        "sling:resourceType=replication/config/agent",
+        "name={name}",
+        "runModes={runModes}",
+        "queueProvider={ReplicationQueueProvider.target}",
+        "packageBuilder={ReplicationPackageBuilder.target}",
+        "queueStrategy={ReplicationQueueDistributionStrategy.target}",
+        "transportHandler={TransportHandler.target}"
+    ]
+
+
+}
\ No newline at end of file

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



Mime
View raw message