Author: mpetria
Date: Mon Dec 15 12:51:50 2014
New Revision: 1645643
URL: http://svn.apache.org/r1645643
Log:
SLING-4153: moving all extensions API from api package to core
Added:
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/DistributionAgent.java
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/DistributionAgentException.java
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/DistributionPackage.java
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/DistributionPackageExportException.java
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/DistributionPackageExporter.java
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/DistributionPackageImportException.java
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/DistributionPackageImporter.java
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/DistributionPackageInfo.java
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/SharedDistributionPackage.java
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/DistributionQueue.java
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/DistributionQueueException.java
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/DistributionQueueItem.java
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/DistributionQueueItemStatus.java
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/DistributionQueueProcessor.java
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/DistributionQueueProvider.java
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/transport/core/
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/transport/core/DistributionTransport.java
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/transport/core/DistributionTransportException.java
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/trigger/DistributionRequestHandler.java
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/trigger/DistributionTrigger.java
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/trigger/DistributionTriggerException.java
Removed:
sling/trunk/contrib/extensions/distribution/api/src/main/java/org/apache/sling/distribution/agent/
sling/trunk/contrib/extensions/distribution/api/src/main/java/org/apache/sling/distribution/packaging/
sling/trunk/contrib/extensions/distribution/api/src/main/java/org/apache/sling/distribution/queue/
sling/trunk/contrib/extensions/distribution/api/src/main/java/org/apache/sling/distribution/trigger/
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/transport/DistributionTransport.java
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/transport/DistributionTransportException.java
Modified:
sling/trunk/contrib/extensions/distribution/api/pom.xml
sling/trunk/contrib/extensions/distribution/api/src/main/java/org/apache/sling/distribution/communication/DistributionResponse.java
sling/trunk/contrib/extensions/distribution/api/src/main/java/org/apache/sling/distribution/communication/Distributor.java
sling/trunk/contrib/extensions/distribution/api/src/main/java/org/apache/sling/distribution/communication/SimpleDistributionRequest.java
sling/trunk/contrib/extensions/distribution/api/src/main/java/org/apache/sling/distribution/transport/DistributionTransportSecret.java
sling/trunk/contrib/extensions/distribution/api/src/main/java/org/apache/sling/distribution/transport/DistributionTransportSecretProvider.java
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/impl/exporter/RemoteDistributionPackageExporter.java
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/impl/importer/AdvancedRemoteDistributionPackageImporter.java
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/impl/importer/RemoteDistributionPackageImporter.java
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/transport/impl/AdvancedHttpDistributionTransport.java
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/transport/impl/MultipleEndpointDistributionTransport.java
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/transport/impl/SimpleHttpDistributionTransport.java
sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/transport/impl/MultipleEndpointDistributionTransportTest.java
Modified: sling/trunk/contrib/extensions/distribution/api/pom.xml
URL:
http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/api/pom.xml?rev=1645643&r1=1645642&r2=1645643&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/api/pom.xml (original)
+++ sling/trunk/contrib/extensions/distribution/api/pom.xml Mon Dec 15 12:51:50
2014
@@ -69,13 +69,8 @@
<instructions>
<Bundle-SymbolicName>org.apache.sling.distribution.api</Bundle-SymbolicName>
<Export-Package>
- org.apache.sling.distribution.component,
- org.apache.sling.distribution.agent,
org.apache.sling.distribution.communication,
org.apache.sling.distribution.event,
- org.apache.sling.distribution.queue,
- org.apache.sling.distribution.trigger,
- org.apache.sling.distribution.packaging,
org.apache.sling.distribution.transport
</Export-Package>
</instructions>
Modified:
sling/trunk/contrib/extensions/distribution/api/src/main/java/org/apache/sling/distribution/communication/DistributionResponse.java
URL:
http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/api/src/main/java/org/apache/sling/distribution/communication/DistributionResponse.java?rev=1645643&r1=1645642&r2=1645643&view=diff
==============================================================================
---
sling/trunk/contrib/extensions/distribution/api/src/main/java/org/apache/sling/distribution/communication/DistributionResponse.java
(original)
+++
sling/trunk/contrib/extensions/distribution/api/src/main/java/org/apache/sling/distribution/communication/DistributionResponse.java
Mon Dec 15 12:51:50 2014
@@ -26,7 +26,7 @@ import javax.annotation.Nullable;
/**
* A {@link org.apache.sling.distribution.communication.DistributionResponse}
represents the outcome of a
- * {@link org.apache.sling.distribution.communication.DistributionRequest} as
handled by a certain {@link
org.apache.sling.distribution.agent.DistributionAgent}.
+ * {@link org.apache.sling.distribution.communication.DistributionRequest} as
handled by a certain distribution agent.
* Such a response will include the {@link
org.apache.sling.distribution.communication.DistributionRequestState state} of
* the {@link org.apache.sling.distribution.communication.DistributionRequest
request} and optionally a message for more
* verbose information about the outcome of the request.
Modified:
sling/trunk/contrib/extensions/distribution/api/src/main/java/org/apache/sling/distribution/communication/Distributor.java
URL:
http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/api/src/main/java/org/apache/sling/distribution/communication/Distributor.java?rev=1645643&r1=1645642&r2=1645643&view=diff
==============================================================================
---
sling/trunk/contrib/extensions/distribution/api/src/main/java/org/apache/sling/distribution/communication/Distributor.java
(original)
+++
sling/trunk/contrib/extensions/distribution/api/src/main/java/org/apache/sling/distribution/communication/Distributor.java
Mon Dec 15 12:51:50 2014
@@ -1,11 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
package org.apache.sling.distribution.communication;
import aQute.bnd.annotation.ProviderType;
import org.apache.sling.api.resource.ResourceResolver;
-import org.apache.sling.distribution.agent.DistributionAgentException;
import javax.annotation.Nonnull;
+/**
+ * A distributor is responsible for dispatching {@link
org.apache.sling.distribution.communication.DistributionRequest}s to
distribution agents.
+ * <p/>
+ * The distribution agents are executing the requests by creating packages
from a source Sling instance containing content for the specified paths
+ * and then pushing and installing these on a target instance.
+ */
@ProviderType
public interface Distributor {
/**
@@ -14,7 +38,7 @@ public interface Distributor {
* The content to be sent will be assembled according to the information
contained in the request.
* A {@link
org.apache.sling.distribution.communication.DistributionResponse} holding the
{@link org.apache.sling.distribution.communication.DistributionRequestState}
* of the provided request will be returned.
- * Synchronous {@link
org.apache.sling.distribution.agent.DistributionAgent}s will usually block
until the execution has finished
+ * Synchronous distribution agents will usually block until the execution
has finished
* while asynchronous agents will usually return the response as soon as
the content to be distributed has been assembled
* and scheduled for distribution.
*
@@ -23,6 +47,7 @@ public interface Distributor {
* @param resourceResolver the resource resolver used for authorizing
the request,
* @return a {@link
org.apache.sling.distribution.communication.DistributionResponse}
*/
+ @Nonnull
DistributionResponse distribute(@Nonnull String agentName, @Nonnull
ResourceResolver resourceResolver, @Nonnull DistributionRequest
distributionRequest);
Modified:
sling/trunk/contrib/extensions/distribution/api/src/main/java/org/apache/sling/distribution/communication/SimpleDistributionRequest.java
URL:
http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/api/src/main/java/org/apache/sling/distribution/communication/SimpleDistributionRequest.java?rev=1645643&r1=1645642&r2=1645643&view=diff
==============================================================================
---
sling/trunk/contrib/extensions/distribution/api/src/main/java/org/apache/sling/distribution/communication/SimpleDistributionRequest.java
(original)
+++
sling/trunk/contrib/extensions/distribution/api/src/main/java/org/apache/sling/distribution/communication/SimpleDistributionRequest.java
Mon Dec 15 12:51:50 2014
@@ -40,7 +40,7 @@ public final class SimpleDistributionReq
*/
public SimpleDistributionRequest(@Nonnull DistributionRequestType
requestType, boolean isDeep, @Nonnull String... paths) {
this.requestType = requestType;
- deep = isDeep;
+ this.deep = isDeep;
this.paths = paths;
}
@@ -82,9 +82,10 @@ public final class SimpleDistributionReq
@Override
public String toString() {
- return "DistributionRequest{" +
+ return "SimpleDistributionRequest{" +
", requestType=" + requestType +
", paths=" + Arrays.toString(paths) +
+ ", deep=" + deep +
'}';
}
Modified:
sling/trunk/contrib/extensions/distribution/api/src/main/java/org/apache/sling/distribution/transport/DistributionTransportSecret.java
URL:
http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/api/src/main/java/org/apache/sling/distribution/transport/DistributionTransportSecret.java?rev=1645643&r1=1645642&r2=1645643&view=diff
==============================================================================
---
sling/trunk/contrib/extensions/distribution/api/src/main/java/org/apache/sling/distribution/transport/DistributionTransportSecret.java
(original)
+++
sling/trunk/contrib/extensions/distribution/api/src/main/java/org/apache/sling/distribution/transport/DistributionTransportSecret.java
Mon Dec 15 12:51:50 2014
@@ -28,8 +28,7 @@ import aQute.bnd.annotation.ConsumerType
* The secret to be transported for authenticating transport layer connecting
two instances.
* <p/>
* Secrets can take different forms, like e.g. username and password, tokens,
public keys, etc. and are meant to be used
- * by transport implementations lying under {@link
org.apache.sling.distribution.packaging.DistributionPackageImporter importers}
- * and / or {@link
org.apache.sling.distribution.packaging.DistributionPackageExporter exporters}.
+ * by transport implementations used by distribution agents.
*/
@ConsumerType
public interface DistributionTransportSecret {
Modified:
sling/trunk/contrib/extensions/distribution/api/src/main/java/org/apache/sling/distribution/transport/DistributionTransportSecretProvider.java
URL:
http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/api/src/main/java/org/apache/sling/distribution/transport/DistributionTransportSecretProvider.java?rev=1645643&r1=1645642&r2=1645643&view=diff
==============================================================================
---
sling/trunk/contrib/extensions/distribution/api/src/main/java/org/apache/sling/distribution/transport/DistributionTransportSecretProvider.java
(original)
+++
sling/trunk/contrib/extensions/distribution/api/src/main/java/org/apache/sling/distribution/transport/DistributionTransportSecretProvider.java
Mon Dec 15 12:51:50 2014
@@ -25,8 +25,7 @@ import aQute.bnd.annotation.ConsumerType
/**
* A provider for {@link
org.apache.sling.distribution.transport.DistributionTransportSecret}s
* <p/>
- * Such providers can be used by {@link
org.apache.sling.distribution.packaging.DistributionPackageExporter exporters}
or
- * {@link org.apache.sling.distribution.packaging.DistributionPackageImporter
importers} implementations in order to plug
+ * Such providers can be used by distribution agents implementations in order
to plug
* in different types of {@link
org.apache.sling.distribution.transport.DistributionTransportSecret secrets} to
be used
* to authenticate the underlying Sling instances.
*/
Added:
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/DistributionAgent.java
URL:
http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/DistributionAgent.java?rev=1645643&view=auto
==============================================================================
---
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/DistributionAgent.java
(added)
+++
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/DistributionAgent.java
Mon Dec 15 12:51:50 2014
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.distribution.agent;
+
+import javax.annotation.CheckForNull;
+import javax.annotation.Nonnull;
+
+import aQute.bnd.annotation.ProviderType;
+import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.distribution.communication.DistributionRequest;
+import org.apache.sling.distribution.communication.DistributionResponse;
+import org.apache.sling.distribution.queue.DistributionQueue;
+
+/**
+ * A distribution agent is responsible for handling {@link
org.apache.sling.distribution.communication.DistributionRequest}s.
+ * <p/>
+ * This means executing actions of e.g.: a specific {@link
org.apache.sling.distribution.communication.DistributionRequestType}s on
+ * specific path(s) which will resume pulling resources from a certain Sling
instance and / or pushing resources to
+ * other instances.
+ */
+@ProviderType
+public interface DistributionAgent {
+
+ /**
+ * retrieves the names of the queues for this agent.
+ *
+ * @return the list of queue names
+ */
+ @Nonnull
+ Iterable<String> getQueueNames();
+
+ /**
+ * get the agent queue with the given name
+ *
+ * @param name a queue name
+ * @return a {@link org.apache.sling.distribution.queue.DistributionQueue}
with the given name bound to this agent, if it exists,
+ * {@code null} otherwise
+ * @throws DistributionAgentException if an error occurs in retrieving the
queue
+ */
+ @CheckForNull
+ DistributionQueue getQueue(@Nonnull String name) throws
DistributionAgentException;
+
+ /**
+ * Perform a {@link
org.apache.sling.distribution.communication.DistributionRequest} to distribute
content from a source
+ * instance to a target instance.
+ * The content to be sent will be assembled according to the information
contained in the request.
+ * A {@link
org.apache.sling.distribution.communication.DistributionResponse} holding the
{@link org.apache.sling.distribution.communication.DistributionRequestState}
+ * of the provided request will be returned.
+ * Synchronous {@link
org.apache.sling.distribution.agent.DistributionAgent}s will usually block
until the execution has finished
+ * while asynchronous agents will usually return the response as soon as
the content to be distributed has been assembled
+ * and scheduled for distribution.
+ *
+ * @param distributionRequest the distribution request
+ * @param resourceResolver the resource resolver used for authorizing
the request,
+ * @return a {@link
org.apache.sling.distribution.communication.DistributionResponse}
+ * @throws DistributionAgentException if any error happens during the
execution of the request or if the authentication fails
+ */
+ @Nonnull
+ DistributionResponse execute(@Nonnull ResourceResolver resourceResolver,
@Nonnull DistributionRequest distributionRequest) throws
DistributionAgentException;
+
+}
Added:
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/DistributionAgentException.java
URL:
http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/DistributionAgentException.java?rev=1645643&view=auto
==============================================================================
---
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/DistributionAgentException.java
(added)
+++
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/DistributionAgentException.java
Mon Dec 15 12:51:50 2014
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.distribution.agent;
+
+/**
+ * Represents errors happened while {@link DistributionAgent}s do
distributions.
+ */
+@SuppressWarnings("serial")
+public class DistributionAgentException extends Exception {
+
+ public DistributionAgentException(Exception e) {
+ super(e);
+ }
+
+ public DistributionAgentException(String string) {
+ super(string);
+ }
+}
Added:
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/DistributionPackage.java
URL:
http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/DistributionPackage.java?rev=1645643&view=auto
==============================================================================
---
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/DistributionPackage.java
(added)
+++
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/DistributionPackage.java
Mon Dec 15 12:51:50 2014
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.distribution.packaging;
+
+import javax.annotation.Nonnull;
+import java.io.IOException;
+import java.io.InputStream;
+
+import aQute.bnd.annotation.ConsumerType;
+
+/**
+ * A distribution package
+ */
+@ConsumerType
+public interface DistributionPackage {
+
+ /**
+ * get package id. the id is a unique string that can be used to retrieve
+ * the package from an {@link DistributionPackageExporter}
+ *
+ * @return the package id
+ */
+ @Nonnull
+ String getId();
+
+ /**
+ * get the type of package
+ *
+ * @return the package type
+ */
+ @Nonnull
+ String getType();
+
+ /**
+ * creates a package stream.
+ * a new stream is created for each call and it is the caller's obligation
to close the stream.
+ *
+ * @return an {@link InputStream}
+ * @throws IOException
+ */
+ @Nonnull
+ InputStream createInputStream() throws IOException;
+
+ /**
+ * releases all resources associated with this package
+ */
+ void delete();
+
+ /**
+ * gets an additional info holder for this package.
+ * The additional info object contains control information rather than
content information.
+ * For example info.origin can be used to skip distributing back to the
originating endpoint.
+ *
+ * @return the associated metadata to this package
+ */
+ @Nonnull
+ DistributionPackageInfo getInfo();
+
+}
Added:
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/DistributionPackageExportException.java
URL:
http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/DistributionPackageExportException.java?rev=1645643&view=auto
==============================================================================
---
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/DistributionPackageExportException.java
(added)
+++
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/DistributionPackageExportException.java
Mon Dec 15 12:51:50 2014
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.distribution.packaging;
+
+/**
+ * This represents an error happening while exporting a {@link
DistributionPackage}
+ */
+@SuppressWarnings("serial")
+public class DistributionPackageExportException extends Exception {
+
+ public DistributionPackageExportException(String message) {
+ super(message);
+ }
+
+ public DistributionPackageExportException(Throwable t) {
+ super(t);
+ }
+}
Added:
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/DistributionPackageExporter.java
URL:
http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/DistributionPackageExporter.java?rev=1645643&view=auto
==============================================================================
---
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/DistributionPackageExporter.java
(added)
+++
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/DistributionPackageExporter.java
Mon Dec 15 12:51:50 2014
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.distribution.packaging;
+
+
+import javax.annotation.CheckForNull;
+import javax.annotation.Nonnull;
+import java.util.List;
+
+import aQute.bnd.annotation.ConsumerType;
+import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.distribution.communication.DistributionRequest;
+
+/**
+ * A {@link DistributionPackageExporter ) is responsible of exporting
+ * {@link DistributionPackage }s to be then imported by a {@link
org.apache.sling.distribution.agent.DistributionAgent }
+ * (via a {@link DistributionPackageImporter }).
+ * <p/>
+ * Exporting a {@link
org.apache.sling.distribution.packaging.DistributionPackage} means obtaining
that package by either
+ * directly creating it by bundling local Sling resources together or
retrieving it from a remote endpoint, e.g. by
+ * executing an HTTP POST request on another Sling instance exposing already
created packages (for remotely changed resources).
+ */
+@ConsumerType
+public interface DistributionPackageExporter {
+
+ /**
+ * Exports the {@link DistributionPackage}s built from the
+ * passed {@link
org.apache.sling.distribution.communication.DistributionRequest}.
+ *
+ * @param resourceResolver - the resource resolver used to export the
packages, for example a 'local' exporter
+ * will use the resource resolver to read the
content and assemble the binary in a certain
+ * location in the repository while a 'remote'
exporter will use the resolver just to
+ * store the binary of the remotely fetched
packages in the repository.
+ * @param distributionRequest - the request containing the needed
information for content to be exported
+ * @return a {@link java.util.List} of {@link DistributionPackage}s
+ */
+ @Nonnull
+ List<DistributionPackage> exportPackages(@Nonnull ResourceResolver
resourceResolver, @Nonnull DistributionRequest distributionRequest) throws
DistributionPackageExportException;
+
+ /**
+ * Retrieves a {@link DistributionPackage} given its identifier, if it
already exists.
+ * This will be used for example to get already created (and cached)
packages that were not yet distributed to the
+ * target instance.
+ *
+ * @param resourceResolver - the resource resolver use to obtain the
package.
+ * @param distributionPackageId - the {@link DistributionPackage#getId()
id of the package} to be retrieved
+ * @return a {@link DistributionPackage} if available, {@code null}
otherwise
+ */
+ @CheckForNull
+ DistributionPackage getPackage(@Nonnull ResourceResolver resourceResolver,
@Nonnull String distributionPackageId);
+}
Added:
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/DistributionPackageImportException.java
URL:
http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/DistributionPackageImportException.java?rev=1645643&view=auto
==============================================================================
---
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/DistributionPackageImportException.java
(added)
+++
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/DistributionPackageImportException.java
Mon Dec 15 12:51:50 2014
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.distribution.packaging;
+
+/**
+ * This represents an error happening while importing a {@link
DistributionPackage}
+ */
+@SuppressWarnings("serial")
+public class DistributionPackageImportException extends Exception {
+
+ public DistributionPackageImportException(String message) {
+ super(message);
+ }
+
+ public DistributionPackageImportException(Throwable t) {
+ super(t);
+ }
+
+ public DistributionPackageImportException(String message, Exception e) {
+ super(message, e);
+ }
+}
Added:
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/DistributionPackageImporter.java
URL:
http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/DistributionPackageImporter.java?rev=1645643&view=auto
==============================================================================
---
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/DistributionPackageImporter.java
(added)
+++
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/DistributionPackageImporter.java
Mon Dec 15 12:51:50 2014
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.distribution.packaging;
+
+import javax.annotation.CheckForNull;
+import javax.annotation.Nonnull;
+import java.io.InputStream;
+
+import aQute.bnd.annotation.ConsumerType;
+import org.apache.sling.api.resource.ResourceResolver;
+
+/**
+ * A {@link DistributionPackageImporter} is responsible for importing
+ * {@link DistributionPackage}s into the resource tree.
+ */
+@ConsumerType
+public interface DistributionPackageImporter {
+
+ /**
+ * Imports the given distribution package into the underlying system
+ *
+ * @param resourceResolver - the resource resolver used to import the
resources
+ * @param distributionPackage - the package to be imported
+ * @throws DistributionPackageImportException if any error occurs during
import
+ */
+ void importPackage(@Nonnull ResourceResolver resourceResolver, @Nonnull
DistributionPackage distributionPackage) throws
DistributionPackageImportException;
+
+ /**
+ * Tries to convert an {@link java.io.InputStream} to a {@link
DistributionPackage} and then imports it into the underlying system
+ *
+ * @param resourceResolver - the resource resolver used to read the package
+ * @param stream the {@link InputStream} of the package to be
converted and installed
+ * @return a {@link DistributionPackage} if the stream has been
successfully converted and installed
+ * @throws DistributionPackageImportException when the stream cannot be
read as a {@link DistributionPackage} and installed
+ */
+ @CheckForNull
+ DistributionPackage importStream(@Nonnull ResourceResolver
resourceResolver, @Nonnull InputStream stream) throws
DistributionPackageImportException;
+
+}
Added:
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/DistributionPackageInfo.java
URL:
http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/DistributionPackageInfo.java?rev=1645643&view=auto
==============================================================================
---
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/DistributionPackageInfo.java
(added)
+++
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/DistributionPackageInfo.java
Mon Dec 15 12:51:50 2014
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.distribution.packaging;
+
+import javax.annotation.CheckForNull;
+import java.net.URI;
+import java.util.Arrays;
+
+import org.apache.sling.distribution.communication.DistributionRequestType;
+
+/**
+ * Additional information about a package.
+ * Additional information is optional and components should expect every piece
of it to be null.
+ */
+public final class DistributionPackageInfo {
+
+ private URI origin;
+ private DistributionRequestType requestType;
+ private String[] paths;
+
+ /**
+ * get the paths covered by the package holding this info
+ *
+ * @return an array of paths
+ */
+ @CheckForNull
+ public String[] getPaths() {
+ return paths;
+ }
+
+ /**
+ * get the request type associated to the package holding this info
+ *
+ * @return the request type
+ */
+ @CheckForNull
+ public DistributionRequestType getRequestType() {
+ return requestType;
+ }
+
+ /**
+ * retrieves the origin of the package holding this info
+ *
+ * @return the package origin
+ */
+ @CheckForNull
+ public URI getOrigin() {
+ return origin;
+ }
+
+ /**
+ * sets the origin of the package.
+ *
+ * @param origin the originating instance of this package
+ */
+ public void setOrigin(URI origin) {
+ this.origin = origin;
+ }
+
+ /**
+ * sets the request type for the package holding this info
+ *
+ * @param requestType the request type that originated this package
+ */
+ public void setRequestType(DistributionRequestType requestType) {
+ this.requestType = requestType;
+ }
+
+ /**
+ * sets the paths "covered" by the package holding this info
+ *
+ * @param paths the paths "covered" by this package
+ */
+ public void setPaths(String[] paths) {
+ this.paths = paths;
+ }
+
+ /**
+ * fills the current info object from the provided one.
+ *
+ * @param packageInfo package metadata
+ */
+ public void fillInfo(DistributionPackageInfo packageInfo) {
+ if (packageInfo != null) {
+ this.setOrigin(packageInfo.getOrigin());
+ this.setPaths(packageInfo.getPaths());
+ this.setRequestType(packageInfo.getRequestType());
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "DistributionPackageInfo{" +
+ "origin=" + origin +
+ ", requestType=" + requestType +
+ ", paths=" + Arrays.toString(paths) +
+ '}';
+ }
+}
Added:
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/SharedDistributionPackage.java
URL:
http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/SharedDistributionPackage.java?rev=1645643&view=auto
==============================================================================
---
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/SharedDistributionPackage.java
(added)
+++
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/SharedDistributionPackage.java
Mon Dec 15 12:51:50 2014
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.distribution.packaging;
+
+import javax.annotation.Nonnull;
+
+import aQute.bnd.annotation.ConsumerType;
+
+/**
+ * A {@link DistributionPackage} that offers basic reference counting
+ */
+@ConsumerType
+public interface SharedDistributionPackage extends DistributionPackage {
+
+
+ /**
+ * acquire a reference to this package and increase the reference count.
+ */
+ void acquire(@Nonnull String holderName);
+
+ /**
+ * release a reference to this package and decrease the reference count.
+ * when no more references are hold the package {@code
DistributionPackage#delete} method is called.
+ */
+ void release(@Nonnull String holderName);
+
+}
Modified:
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/impl/exporter/RemoteDistributionPackageExporter.java
URL:
http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/impl/exporter/RemoteDistributionPackageExporter.java?rev=1645643&r1=1645642&r2=1645643&view=diff
==============================================================================
---
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/impl/exporter/RemoteDistributionPackageExporter.java
(original)
+++
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/impl/exporter/RemoteDistributionPackageExporter.java
Mon Dec 15 12:51:50 2014
@@ -28,7 +28,7 @@ import org.apache.sling.distribution.pac
import
org.apache.sling.distribution.packaging.DistributionPackageExportException;
import org.apache.sling.distribution.packaging.DistributionPackageExporter;
import org.apache.sling.distribution.serialization.DistributionPackageBuilder;
-import org.apache.sling.distribution.transport.DistributionTransport;
+import org.apache.sling.distribution.transport.core.DistributionTransport;
import
org.apache.sling.distribution.transport.DistributionTransportSecretProvider;
import org.apache.sling.distribution.transport.impl.DistributionEndpoint;
import
org.apache.sling.distribution.transport.impl.MultipleEndpointDistributionTransport;
Modified:
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/impl/importer/AdvancedRemoteDistributionPackageImporter.java
URL:
http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/impl/importer/AdvancedRemoteDistributionPackageImporter.java?rev=1645643&r1=1645642&r2=1645643&view=diff
==============================================================================
---
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/impl/importer/AdvancedRemoteDistributionPackageImporter.java
(original)
+++
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/impl/importer/AdvancedRemoteDistributionPackageImporter.java
Mon Dec 15 12:51:50 2014
@@ -34,7 +34,7 @@ import org.apache.sling.distribution.eve
import org.apache.sling.distribution.packaging.DistributionPackage;
import
org.apache.sling.distribution.packaging.DistributionPackageImportException;
import org.apache.sling.distribution.packaging.DistributionPackageImporter;
-import org.apache.sling.distribution.transport.DistributionTransport;
+import org.apache.sling.distribution.transport.core.DistributionTransport;
import
org.apache.sling.distribution.transport.DistributionTransportSecretProvider;
import
org.apache.sling.distribution.transport.impl.AdvancedHttpDistributionTransport;
import org.apache.sling.distribution.transport.impl.DistributionEndpoint;
Modified:
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/impl/importer/RemoteDistributionPackageImporter.java
URL:
http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/impl/importer/RemoteDistributionPackageImporter.java?rev=1645643&r1=1645642&r2=1645643&view=diff
==============================================================================
---
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/impl/importer/RemoteDistributionPackageImporter.java
(original)
+++
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/impl/importer/RemoteDistributionPackageImporter.java
Mon Dec 15 12:51:50 2014
@@ -27,7 +27,7 @@ import org.apache.sling.api.resource.Res
import org.apache.sling.distribution.packaging.DistributionPackage;
import
org.apache.sling.distribution.packaging.DistributionPackageImportException;
import org.apache.sling.distribution.packaging.DistributionPackageImporter;
-import org.apache.sling.distribution.transport.DistributionTransport;
+import org.apache.sling.distribution.transport.core.DistributionTransport;
import
org.apache.sling.distribution.transport.DistributionTransportSecretProvider;
import org.apache.sling.distribution.transport.impl.DistributionEndpoint;
import
org.apache.sling.distribution.transport.impl.MultipleEndpointDistributionTransport;
Added:
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/DistributionQueue.java
URL:
http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/DistributionQueue.java?rev=1645643&view=auto
==============================================================================
---
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/DistributionQueue.java
(added)
+++
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/DistributionQueue.java
Mon Dec 15 12:51:50 2014
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.distribution.queue;
+
+import javax.annotation.CheckForNull;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+import aQute.bnd.annotation.ProviderType;
+
+/**
+ * A queue is responsible for collecting the {@link
org.apache.sling.distribution.packaging.DistributionPackage}s
+ * exported by a {@link org.apache.sling.distribution.agent.DistributionAgent}
in
+ * order to be able to process them also when there are multiple (concurrent)
+ * {@link org.apache.sling.distribution.communication.DistributionRequest}s
executed
+ * on that same agent.
+ * <p/>
+ * The items (packages) in the queue can then get processed according to a FIFO
+ * strategy or in parallel, or some other way, via {@link
org.apache.sling.distribution.queue.DistributionQueueProcessor}s.
+ */
+@ProviderType
+public interface DistributionQueue {
+
+ /**
+ * get this queue name
+ *
+ * @return the queue name
+ */
+ @Nonnull
+ String getName();
+
+ /**
+ * add a distribution item to this queue
+ *
+ * @param item a distribution item representing a {@link
org.apache.sling.distribution.packaging.DistributionPackage}
+ * to distribute
+ * @return {@code true} if the distribution item was added correctly to
the queue,
+ * {@code false} otherwise
+ */
+ boolean add(@Nonnull DistributionQueueItem item);
+
+ /**
+ * get the status of a certain item in the queue
+ *
+ * @param item the distribution item to get the status for
+ * @return the item status in the queue
+ * @throws DistributionQueueException if any error occurs while getting
the status
+ */
+ @Nonnull
+ DistributionQueueItemStatus getStatus(@Nonnull DistributionQueueItem item)
+ throws DistributionQueueException;
+
+ /**
+ * get the first item (in a FIFO strategy, the next to be processed) from
the queue
+ *
+ * @return the first item into the queue or {@code null} if the queue is
empty
+ */
+ @CheckForNull
+ DistributionQueueItem getHead();
+
+ /**
+ * check if the queue is empty
+ *
+ * @return {@code true} if the queue is empty, {@code false} otherwise
+ */
+ boolean isEmpty();
+
+ /**
+ * get all the items in the queue
+ *
+ * @param skip the number of items to skip
+ * @param limit the maximum number of items to return. use -1 to return
all items.
+ * @return a {@link java.lang.Iterable} of {@link DistributionQueueItem}s
+ */
+ @Nonnull
+ Iterable<DistributionQueueItem> getItems(int skip, int limit);
+
+ /**
+ * remove an item from the queue by specifying its id
+ *
+ * @param packageId the id of the package represented by the item
+ * @return the removed item, or {@code null} if the item with the given id
+ * doesn't exist
+ */
+ DistributionQueueItem remove(@Nonnull String packageId);
+}
Added:
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/DistributionQueueException.java
URL:
http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/DistributionQueueException.java?rev=1645643&view=auto
==============================================================================
---
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/DistributionQueueException.java
(added)
+++
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/DistributionQueueException.java
Mon Dec 15 12:51:50 2014
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.distribution.queue;
+
+/**
+ * Represents errors happening during queue operations
+ */
+@SuppressWarnings("serial")
+public class DistributionQueueException extends Exception {
+
+ public DistributionQueueException(String message, Exception e) {
+ super(message, e);
+ }
+
+ public DistributionQueueException(String string) {
+ super(string);
+ }
+}
Added:
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/DistributionQueueItem.java
URL:
http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/DistributionQueueItem.java?rev=1645643&view=auto
==============================================================================
---
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/DistributionQueueItem.java
(added)
+++
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/DistributionQueueItem.java
Mon Dec 15 12:51:50 2014
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.distribution.queue;
+
+import javax.annotation.Nonnull;
+
+import org.apache.sling.distribution.packaging.DistributionPackageInfo;
+
+/**
+ * An item in a {@link DistributionQueue}
+ * <p/>
+ * This is basically a proxy to {@link
org.apache.sling.distribution.packaging.DistributionPackage} designed to avoid
having
+ * to keep the package {@link
org.apache.sling.distribution.packaging.DistributionPackage#createInputStream()
stream} into
+ * the queues.
+ */
+public class DistributionQueueItem {
+
+ private final String id;
+
+ private final String type;
+
+ private final DistributionPackageInfo packageInfo;
+
+ public DistributionQueueItem(@Nonnull String id, @Nonnull String type,
@Nonnull DistributionPackageInfo packageInfo) {
+ this.id = id;
+ this.type = type;
+ this.packageInfo = packageInfo;
+ }
+
+ @Nonnull
+ public String getId() {
+ return id;
+ }
+
+ @Nonnull
+ public String getType() {
+ return type;
+ }
+
+ @Nonnull
+ public DistributionPackageInfo getPackageInfo() {
+ return packageInfo;
+ }
+
+ @Override
+ public String toString() {
+ return "DistributionQueueItem{" +
+ "id='" + id + '\'' +
+ ", type='" + type + '\'' +
+ ", packageInfo=" + packageInfo +
+ '}';
+ }
+}
Added:
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/DistributionQueueItemStatus.java
URL:
http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/DistributionQueueItemStatus.java?rev=1645643&view=auto
==============================================================================
---
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/DistributionQueueItemStatus.java
(added)
+++
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/DistributionQueueItemStatus.java
Mon Dec 15 12:51:50 2014
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.distribution.queue;
+
+import java.util.Calendar;
+
+/**
+ * the current status of a certain item in a {@link DistributionQueue}
+ */
+
+public class DistributionQueueItemStatus {
+
+ private final int attempts;
+
+ private final ItemState state;
+
+ private final Calendar entered;
+
+ private final String queueName;
+
+ public DistributionQueueItemStatus(Calendar entered, ItemState state, int
attempts, String queueName) {
+ this.entered = entered;
+ this.state = state;
+ this.attempts = attempts;
+ this.queueName = queueName;
+ }
+
+ public DistributionQueueItemStatus(ItemState state, String queueName) {
+ this(Calendar.getInstance(), state, 0, queueName);
+ }
+
+ public boolean isSuccessful() {
+ return ItemState.SUCCEEDED.equals(state);
+ }
+
+ public int getAttempts() {
+ return attempts;
+ }
+
+ public ItemState getItemState() {
+ return state;
+ }
+
+ public String getQueueName() {
+ return queueName;
+ }
+
+ @Override
+ public String toString() {
+ return "{\"attempts\":\"" + attempts + "\",\"" + "successful\":\"" +
isSuccessful() + "\",\"" + "state\":\"" + state +
+ "\",\"" + "queueName\":\"" + queueName + "\"}";
+ }
+
+ public Calendar getEntered() {
+ return entered;
+ }
+
+
+ public enum ItemState {
+ QUEUED, // waiting in queue after adding or for restart after failing
+ ACTIVE, // job is currently in processing
+ SUCCEEDED, // processing finished successfully
+ STOPPED, // processing was stopped by a user
+ GIVEN_UP, // number of retries reached
+ ERROR, // processing signaled CANCELLED or throw an exception
+ DROPPED // dropped jobs
+ }
+
+}
Added:
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/DistributionQueueProcessor.java
URL:
http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/DistributionQueueProcessor.java?rev=1645643&view=auto
==============================================================================
---
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/DistributionQueueProcessor.java
(added)
+++
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/DistributionQueueProcessor.java
Mon Dec 15 12:51:50 2014
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.distribution.queue;
+
+import javax.annotation.Nonnull;
+
+import aQute.bnd.annotation.ProviderType;
+
+/**
+ * Processor of {@link DistributionQueueItem}s
+ */
+@ProviderType
+public interface DistributionQueueProcessor {
+
+ /**
+ * Process an item from a certain {@link
org.apache.sling.distribution.queue.DistributionQueue}
+ *
+ * @param queueName the name of the {@link
org.apache.sling.distribution.queue.DistributionQueue} to be processed
+ * @param distributionQueueItem the {@link
org.apache.sling.distribution.queue.DistributionQueueItem} to be processed
+ * @return {@code true} if the item was successfully processed, {@code
false} otherwise
+ */
+ public boolean process(@Nonnull String queueName, @Nonnull
DistributionQueueItem distributionQueueItem);
+}
Added:
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/DistributionQueueProvider.java
URL:
http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/DistributionQueueProvider.java?rev=1645643&view=auto
==============================================================================
---
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/DistributionQueueProvider.java
(added)
+++
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/DistributionQueueProvider.java
Mon Dec 15 12:51:50 2014
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.distribution.queue;
+
+import javax.annotation.Nonnull;
+
+import aQute.bnd.annotation.ProviderType;
+
+/**
+ * A provider for {@link DistributionQueue}s
+ */
+@ProviderType
+public interface DistributionQueueProvider {
+
+ /**
+ * provide a named queue for the given agent
+ *
+ * @param queueName the name of the queue to retrieve
+ * @return a {@link DistributionQueue}
+ * @throws DistributionQueueException if any error happens
+ */
+ @Nonnull
+ DistributionQueue getQueue(@Nonnull String queueName) throws
DistributionQueueException;
+
+ /**
+ * enables queue processing
+ *
+ * @param queueProcessor the queue processor to be used
+ */
+ void enableQueueProcessing(@Nonnull DistributionQueueProcessor
queueProcessor) throws DistributionQueueException;
+
+
+ /**
+ * disables queue processing
+ *
+ */
+ void disableQueueProcessing() throws DistributionQueueException;
+}
Added:
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/transport/core/DistributionTransport.java
URL:
http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/transport/core/DistributionTransport.java?rev=1645643&view=auto
==============================================================================
---
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/transport/core/DistributionTransport.java
(added)
+++
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/transport/core/DistributionTransport.java
Mon Dec 15 12:51:50 2014
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.distribution.transport.core;
+
+import javax.annotation.Nonnull;
+
+import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.distribution.communication.DistributionRequest;
+import org.apache.sling.distribution.packaging.DistributionPackage;
+import org.apache.sling.distribution.transport.DistributionTransportSecret;
+
+/**
+ * A transport layer implementation to transport data between two (or
eventually more) Sling instances.
+ * <p/>
+ * Each implementation is meant to be stateful in the sense that it will hide
the details about the sending / receiving
+ * endpoints of the transport.
+ */
+public interface DistributionTransport {
+
+ /**
+ * Deliver a {@link
org.apache.sling.distribution.packaging.DistributionPackage} to a target
instance using this
+ * transport layer implementation.
+ *
+ * @param resourceResolver a resolver used to eventually access local
resources needed by the transport algorithm
+ * @param distributionPackage a {@link
org.apache.sling.distribution.packaging.DistributionPackage} to transport
+ * @param secret the {@link
org.apache.sling.distribution.transport.DistributionTransportSecret} used to
authenticate
+ * against the target instance according to an
authentication algorithm implemented by the transport.
+ * @throws DistributionTransportException if the {@link
org.apache.sling.distribution.packaging.DistributionPackage}
+ * fails to be delivered to the
target instance (e.g. because of network, I/O issues)
+ */
+ void deliverPackage(@Nonnull ResourceResolver resourceResolver, @Nonnull
DistributionPackage
+ distributionPackage, @Nonnull DistributionTransportSecret secret)
throws DistributionTransportException;
+
+ /**
+ * Retrieve {@link
org.apache.sling.distribution.packaging.DistributionPackage}s from a target
Sling instance, which
+ * will create them according to {@link
org.apache.sling.distribution.communication.DistributionRequest}.
+ *
+ * @param resourceResolver a resolver used to eventually access local
resources needed by the transport algorithm
+ * @param request a {@link
org.apache.sling.distribution.communication.DistributionRequest} to be
forwarded to the target
+ * instance
+ * @param secret the {@link
org.apache.sling.distribution.transport.DistributionTransportSecret} used to
authenticate
+ * against the target instance according to an
authentication algorithm implemented by the transport.
+ * @return an {@link java.lang.Iterable} of {@link
org.apache.sling.distribution.packaging.DistributionPackage}s fetched
+ * from the target instance.
+ * @throws DistributionTransportException if the {@link
org.apache.sling.distribution.packaging.DistributionPackage}s
+ * fail to be retrieved from the
target instance
+ */
+ @Nonnull
+ Iterable<DistributionPackage> retrievePackages(@Nonnull ResourceResolver
resourceResolver, @Nonnull DistributionRequest
+ request, @Nonnull DistributionTransportSecret secret) throws
DistributionTransportException;
+
+}
Added:
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/transport/core/DistributionTransportException.java
URL:
http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/transport/core/DistributionTransportException.java?rev=1645643&view=auto
==============================================================================
---
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/transport/core/DistributionTransportException.java
(added)
+++
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/transport/core/DistributionTransportException.java
Mon Dec 15 12:51:50 2014
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.distribution.transport.core;
+
+/**
+ * Represents an error happened while a {@link DistributionTransportHandler}Â
is delivering a distribution item to
+ * and endpoint.
+ */
+@SuppressWarnings("serial")
+public class DistributionTransportException extends Exception {
+
+ public DistributionTransportException(Exception e) {
+ super(e);
+ }
+
+ public DistributionTransportException(String string) {
+ super(string);
+ }
+}
Modified:
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/transport/impl/AdvancedHttpDistributionTransport.java
URL:
http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/transport/impl/AdvancedHttpDistributionTransport.java?rev=1645643&r1=1645642&r2=1645643&view=diff
==============================================================================
---
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/transport/impl/AdvancedHttpDistributionTransport.java
(original)
+++
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/transport/impl/AdvancedHttpDistributionTransport.java
Mon Dec 15 12:51:50 2014
@@ -35,13 +35,13 @@ import org.apache.http.entity.ContentTyp
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.distribution.packaging.DistributionPackage;
import org.apache.sling.distribution.serialization.DistributionPackageBuilder;
-import org.apache.sling.distribution.transport.DistributionTransportException;
+import
org.apache.sling.distribution.transport.core.DistributionTransportException;
import org.apache.sling.distribution.transport.DistributionTransportSecret;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * Advanced HTTP {@link
org.apache.sling.distribution.transport.DistributionTransport} supporting
custom HTTP headers
+ * Advanced HTTP {@link
org.apache.sling.distribution.transport.core.DistributionTransport} supporting
custom HTTP headers
* and body.
*/
public class AdvancedHttpDistributionTransport extends
SimpleHttpDistributionTransport {
Modified:
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/transport/impl/MultipleEndpointDistributionTransport.java
URL:
http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/transport/impl/MultipleEndpointDistributionTransport.java?rev=1645643&r1=1645642&r2=1645643&view=diff
==============================================================================
---
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/transport/impl/MultipleEndpointDistributionTransport.java
(original)
+++
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/transport/impl/MultipleEndpointDistributionTransport.java
Mon Dec 15 12:51:50 2014
@@ -25,12 +25,12 @@ import java.util.List;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.distribution.communication.DistributionRequest;
import org.apache.sling.distribution.packaging.DistributionPackage;
-import org.apache.sling.distribution.transport.DistributionTransport;
-import org.apache.sling.distribution.transport.DistributionTransportException;
+import org.apache.sling.distribution.transport.core.DistributionTransport;
+import
org.apache.sling.distribution.transport.core.DistributionTransportException;
import org.apache.sling.distribution.transport.DistributionTransportSecret;
/**
- * {@link org.apache.sling.distribution.transport.DistributionTransport}
supporting delivery / retrieval from multiple
+ * {@link org.apache.sling.distribution.transport.core.DistributionTransport}
supporting delivery / retrieval from multiple
* endpoints.
*/
public class MultipleEndpointDistributionTransport implements
DistributionTransport {
Modified:
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/transport/impl/SimpleHttpDistributionTransport.java
URL:
http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/transport/impl/SimpleHttpDistributionTransport.java?rev=1645643&r1=1645642&r2=1645643&view=diff
==============================================================================
---
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/transport/impl/SimpleHttpDistributionTransport.java
(original)
+++
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/transport/impl/SimpleHttpDistributionTransport.java
Mon Dec 15 12:51:50 2014
@@ -40,8 +40,8 @@ import org.apache.sling.api.resource.Res
import org.apache.sling.distribution.communication.DistributionRequest;
import org.apache.sling.distribution.packaging.DistributionPackage;
import org.apache.sling.distribution.serialization.DistributionPackageBuilder;
-import org.apache.sling.distribution.transport.DistributionTransport;
-import org.apache.sling.distribution.transport.DistributionTransportException;
+import org.apache.sling.distribution.transport.core.DistributionTransport;
+import
org.apache.sling.distribution.transport.core.DistributionTransportException;
import org.apache.sling.distribution.transport.DistributionTransportSecret;
import org.apache.sling.distribution.util.RequestUtils;
import org.slf4j.Logger;
Added:
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/trigger/DistributionRequestHandler.java
URL:
http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/trigger/DistributionRequestHandler.java?rev=1645643&view=auto
==============================================================================
---
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/trigger/DistributionRequestHandler.java
(added)
+++
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/trigger/DistributionRequestHandler.java
Mon Dec 15 12:51:50 2014
@@ -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.distribution.trigger;
+
+import javax.annotation.Nonnull;
+
+import aQute.bnd.annotation.ConsumerType;
+import org.apache.sling.distribution.communication.DistributionRequest;
+
+/**
+ * An handler for {@link
org.apache.sling.distribution.communication.DistributionRequest}s passed to a
+ * {@link DistributionTrigger}
+ */
+@ConsumerType
+public interface DistributionRequestHandler {
+
+ /**
+ * handle the request according to the trigger implementation.
+ *
+ * @param request a distribution request
+ */
+ void handle(@Nonnull DistributionRequest request);
+
+}
Added:
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/trigger/DistributionTrigger.java
URL:
http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/trigger/DistributionTrigger.java?rev=1645643&view=auto
==============================================================================
---
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/trigger/DistributionTrigger.java
(added)
+++
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/trigger/DistributionTrigger.java
Mon Dec 15 12:51:50 2014
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.distribution.trigger;
+
+import javax.annotation.Nonnull;
+
+import aQute.bnd.annotation.ConsumerType;
+
+/**
+ * A {@link DistributionTrigger} is responsible to trigger
+ * {@link org.apache.sling.distribution.communication.DistributionRequest}s
upon certain 'events' (e.g. Sling / Jcr events,
+ * periodic pulling, etc.).
+ * A {@link DistributionTrigger} is meant to be stateless so that more than one
+ * {@link DistributionRequestHandler} can be registered into the same trigger.
+ */
+@ConsumerType
+public interface DistributionTrigger {
+
+ /**
+ * register a request handler to be triggered and returns a corresponding
registration id
+ *
+ * @param requestHandler handler
+ * @throws DistributionTriggerException if registration fails
+ */
+ void register(@Nonnull DistributionRequestHandler requestHandler) throws
DistributionTriggerException;
+
+ /**
+ * unregister the given handler, if existing
+ *
+ * @param requestHandler handler to unregister
+ * @throws DistributionTriggerException if any error happen
+ */
+ void unregister(@Nonnull DistributionRequestHandler requestHandler) throws
DistributionTriggerException;
+}
Added:
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/trigger/DistributionTriggerException.java
URL:
http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/trigger/DistributionTriggerException.java?rev=1645643&view=auto
==============================================================================
---
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/trigger/DistributionTriggerException.java
(added)
+++
sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/trigger/DistributionTriggerException.java
Mon Dec 15 12:51:50 2014
@@ -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.distribution.trigger;
+
+/**
+ * Exception representing errors during (un)registration of {@link
DistributionTrigger}s
+ */
+public class DistributionTriggerException extends Exception {
+
+ public DistributionTriggerException(String message, Throwable throwable) {
+ super(message, throwable);
+ }
+
+ public DistributionTriggerException(String message) {
+ super(message);
+ }
+}
Modified:
sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/transport/impl/MultipleEndpointDistributionTransportTest.java
URL:
http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/transport/impl/MultipleEndpointDistributionTransportTest.java?rev=1645643&r1=1645642&r2=1645643&view=diff
==============================================================================
---
sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/transport/impl/MultipleEndpointDistributionTransportTest.java
(original)
+++
sling/trunk/contrib/extensions/distribution/core/src/test/java/org/apache/sling/distribution/transport/impl/MultipleEndpointDistributionTransportTest.java
Mon Dec 15 12:51:50 2014
@@ -27,8 +27,7 @@ import org.apache.sling.distribution.com
import org.apache.sling.distribution.communication.DistributionRequestType;
import org.apache.sling.distribution.communication.SimpleDistributionRequest;
import org.apache.sling.distribution.packaging.DistributionPackage;
-import org.apache.sling.distribution.transport.DistributionTransport;
-import org.apache.sling.distribution.transport.DistributionTransport;
+import org.apache.sling.distribution.transport.core.DistributionTransport;
import org.apache.sling.distribution.transport.DistributionTransportSecret;
import org.junit.Test;