sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mpet...@apache.org
Subject svn commit: r1652356 [1/2] - in /sling/trunk/contrib/extensions/distribution: core/src/main/java/org/apache/sling/distribution/agent/impl/ core/src/main/java/org/apache/sling/distribution/queue/ core/src/main/java/org/apache/sling/distribution/queue/im...
Date Fri, 16 Jan 2015 08:03:34 GMT
Author: mpetria
Date: Fri Jan 16 08:03:33 2015
New Revision: 1652356

URL: http://svn.apache.org/r1652356
Log:
SLING-4292: exposing queue and queue items as resources

Added:
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/DistributionQueueState.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/impl/DistributionQueueUtils.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/resources/DistributionResourceTypes.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/resources/impl/ExtendedDistributionServiceResourceProvider.java
    sling/trunk/contrib/extensions/distribution/it/src/test/java/org/apache/sling/distribution/it/MultipleQueueDistributionTest.java
    sling/trunk/contrib/extensions/distribution/sample/src/main/resources/SLING-CONTENT/libs/sling/distribution/install.author/queue-multiple/
    sling/trunk/contrib/extensions/distribution/sample/src/main/resources/SLING-CONTENT/libs/sling/distribution/install.author/queue-multiple/org.apache.sling.distribution.agent.impl.ForwardDistributionAgentFactory-queue-multiple.json
Removed:
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/resources/DistributionConstants.java
Modified:
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/AbstractDistributionAgentFactory.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/DistributionQueue.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/impl/jobhandling/JobHandlingDistributionQueue.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/impl/simple/SimpleDistributionQueue.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/resources/impl/DistributionConfigurationResourceProvider.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/resources/impl/DistributionConfigurationResourceProviderFactory.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/resources/impl/DistributionServiceResourceProvider.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/resources/impl/DistributionServiceResourceProviderFactory.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/resources/impl/common/AbstractModifyingResourceProvider.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/resources/impl/common/AbstractReadableResourceProvider.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/serialization/impl/ResourceSharedDistributionPackage.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/serialization/impl/ResourceSharedDistributionPackageBuilder.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/servlet/DistributionAgentQueueServlet.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/servlet/DistributionAgentRootServlet.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/servlet/DistributionAgentServlet.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/servlet/DistributionPackageExporterServlet.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/servlet/DistributionPackageImporterServlet.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/servlet/DistributionTriggerServlet.java
    sling/trunk/contrib/extensions/distribution/it/src/test/java/org/apache/sling/distribution/it/DistributionIntegrationTestBase.java
    sling/trunk/contrib/extensions/distribution/it/src/test/java/org/apache/sling/distribution/it/DistributionUtils.java
    sling/trunk/contrib/extensions/distribution/sample/src/main/resources/SLING-CONTENT/libs/sling/distribution/install/resources/services/org.apache.sling.distribution.resources.impl.DistributionServiceResourceProviderFactory-agents.json
    sling/trunk/contrib/extensions/distribution/sample/src/main/resources/SLING-CONTENT/libs/sling/distribution/install/resources/services/org.apache.sling.distribution.resources.impl.DistributionServiceResourceProviderFactory-exporters.json
    sling/trunk/contrib/extensions/distribution/sample/src/main/resources/SLING-CONTENT/libs/sling/distribution/install/resources/services/org.apache.sling.distribution.resources.impl.DistributionServiceResourceProviderFactory-importers.json
    sling/trunk/contrib/extensions/distribution/sample/src/main/resources/SLING-CONTENT/libs/sling/distribution/install/resources/services/org.apache.sling.distribution.resources.impl.DistributionServiceResourceProviderFactory-triggers.json
    sling/trunk/contrib/extensions/distribution/sample/src/main/resources/SLING-CONTENT/libs/sling/distribution/install/resources/settings/org.apache.sling.distribution.resources.impl.DistributionConfigurationResourceProviderFactory-agents.json

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/AbstractDistributionAgentFactory.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/AbstractDistributionAgentFactory.java?rev=1652356&r1=1652355&r2=1652356&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/AbstractDistributionAgentFactory.java (original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/AbstractDistributionAgentFactory.java Fri Jan 16 08:03:33 2015
@@ -21,7 +21,6 @@ package org.apache.sling.distribution.ag
 import org.apache.sling.commons.osgi.PropertiesUtil;
 import org.apache.sling.distribution.agent.DistributionAgent;
 import org.apache.sling.distribution.component.impl.DistributionComponentUtils;
-import org.apache.sling.distribution.resources.DistributionConstants;
 import org.apache.sling.distribution.resources.impl.OsgiUtils;
 import org.apache.sling.distribution.trigger.DistributionTrigger;
 import org.osgi.framework.BundleContext;
@@ -74,9 +73,6 @@ public abstract class AbstractDistributi
             agentName = PropertiesUtil.toString(config.get(NAME), null);
             props.put(NAME, agentName);
 
-            boolean isResource = PropertiesUtil.toBoolean(config.get(DistributionConstants.PN_IS_RESOURCE), false);
-            props.put(DistributionConstants.PN_IS_RESOURCE, isResource);
-
             if (componentReg == null) {
 
                 try {

Modified: 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=1652356&r1=1652355&r2=1652356&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/DistributionQueue.java (original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/DistributionQueue.java Fri Jan 16 08:03:33 2015
@@ -74,13 +74,6 @@ public interface DistributionQueue {
     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
@@ -90,6 +83,16 @@ public interface DistributionQueue {
     @Nonnull
     Iterable<DistributionQueueItem> getItems(int skip, int limit);
 
+
+    /**
+     * gets an item from the queue by specifying its id
+     *
+     * @param packageId the id of the package represented by the item
+     * @return the item, or {@code null} if the item with the given id
+     * doesn't exist
+     */
+    DistributionQueueItem getItem(@Nonnull String packageId);
+
     /**
      * remove an item from the queue by specifying its id
      *
@@ -98,4 +101,23 @@ public interface DistributionQueue {
      * doesn't exist
      */
     DistributionQueueItem remove(@Nonnull String packageId);
+
+
+    /**
+     * check if the queue is empty
+     *
+     * @return {@code true} if the queue is empty, {@code false} otherwise
+     */
+    boolean isEmpty();
+
+    /**
+     * returns the count of items in the queue
+     */
+    int getItemsCount();
+
+    /**
+     * returns the state of the queue
+     * @return the queue state
+     */
+    DistributionQueueState getState();
 }

Added: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/DistributionQueueState.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/DistributionQueueState.java?rev=1652356&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/DistributionQueueState.java (added)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/DistributionQueueState.java Fri Jan 16 08:03:33 2015
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.sling.distribution.queue;
+
+/**
+ * The state of a distribution queue.
+ */
+public enum DistributionQueueState {
+
+    /**
+     * The queue is not active
+     */
+    PAUSED,
+
+    /**
+     * The queue is active but empty
+     */
+    IDLE,
+
+    /**
+     * The queue is active and there are items in it and it is not blocked.
+     */
+    RUNNING,
+
+    /**
+     * The queue is active, there are items in the queue but it cannot process them.
+     */
+    BLOCKED
+}

Added: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/impl/DistributionQueueUtils.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/impl/DistributionQueueUtils.java?rev=1652356&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/impl/DistributionQueueUtils.java (added)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/impl/DistributionQueueUtils.java Fri Jan 16 08:03:33 2015
@@ -0,0 +1,51 @@
+/*
+ * 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.impl;
+
+import org.apache.sling.distribution.queue.DistributionQueue;
+import org.apache.sling.distribution.queue.DistributionQueueException;
+import org.apache.sling.distribution.queue.DistributionQueueItem;
+import org.apache.sling.distribution.queue.DistributionQueueItemStatus;
+import org.apache.sling.distribution.queue.DistributionQueueState;
+
+public class DistributionQueueUtils {
+
+    public static DistributionQueueState calculateState(DistributionQueue queue) {
+        if (queue.getItemsCount() > 0) {
+            DistributionQueueItem item = queue.getHead();
+            DistributionQueueItemStatus status = null;
+            try {
+                status = queue.getStatus(item);
+            } catch (DistributionQueueException e) {
+                return DistributionQueueState.BLOCKED;
+            }
+
+            int attempts = status.getAttempts();
+
+            if (attempts > 0) {
+                return DistributionQueueState.BLOCKED;
+            } else {
+                return DistributionQueueState.RUNNING;
+            }
+        } else {
+            return DistributionQueueState.IDLE;
+        }
+    }
+}

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/impl/jobhandling/JobHandlingDistributionQueue.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/impl/jobhandling/JobHandlingDistributionQueue.java?rev=1652356&r1=1652355&r2=1652356&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/impl/jobhandling/JobHandlingDistributionQueue.java (original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/impl/jobhandling/JobHandlingDistributionQueue.java Fri Jan 16 08:03:33 2015
@@ -29,6 +29,8 @@ import org.apache.sling.distribution.que
 import org.apache.sling.distribution.queue.DistributionQueueItem;
 import org.apache.sling.distribution.queue.DistributionQueueItemStatus;
 import org.apache.sling.distribution.queue.DistributionQueueItemStatus.ItemState;
+import org.apache.sling.distribution.queue.DistributionQueueState;
+import org.apache.sling.distribution.queue.impl.DistributionQueueUtils;
 import org.apache.sling.event.jobs.Job;
 import org.apache.sling.event.jobs.JobManager;
 import org.apache.sling.event.jobs.JobManager.QueryType;
@@ -154,6 +156,11 @@ public class JobHandlingDistributionQueu
         return getJobs(0, -1).isEmpty();
     }
 
+    public int getItemsCount() {
+        List<Job> jobs = getJobs(0, -1);
+        return jobs.size();
+    }
+
     @Nonnull
     public List<DistributionQueueItem> getItems(int skip, int limit) {
 
@@ -167,6 +174,20 @@ public class JobHandlingDistributionQueu
         return items;
     }
 
+    public DistributionQueueItem getItem(@Nonnull String id) {
+        Job job = getJob(id);
+
+        DistributionQueueItem item = null;
+
+        if (job != null) {
+            item = JobHandlingUtils.getItem(job);
+
+            return item;
+        }
+
+        return null;
+    }
+
     public DistributionQueueItem remove(@Nonnull String id) {
         boolean removed = false;
         Job job = getJob(id);
@@ -182,4 +203,8 @@ public class JobHandlingDistributionQueu
         return item;
     }
 
+    public DistributionQueueState getState() {
+        return DistributionQueueUtils.calculateState(this);
+    }
+
 }

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/impl/simple/SimpleDistributionQueue.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/impl/simple/SimpleDistributionQueue.java?rev=1652356&r1=1652355&r2=1652356&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/impl/simple/SimpleDistributionQueue.java (original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/queue/impl/simple/SimpleDistributionQueue.java Fri Jan 16 08:03:33 2015
@@ -30,6 +30,8 @@ import org.apache.sling.distribution.que
 import org.apache.sling.distribution.queue.DistributionQueueItem;
 import org.apache.sling.distribution.queue.DistributionQueueItemStatus;
 import org.apache.sling.distribution.queue.DistributionQueueItemStatus.ItemState;
+import org.apache.sling.distribution.queue.DistributionQueueState;
+import org.apache.sling.distribution.queue.impl.DistributionQueueUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -101,19 +103,35 @@ public class SimpleDistributionQueue imp
         return queue.isEmpty();
     }
 
+    public int getItemsCount() {
+        return queue.size();
+    }
+
+    public DistributionQueueState getState() {
+        return DistributionQueueUtils.calculateState(this);
+    }
+
+
     @Nonnull
     public Iterable<DistributionQueueItem> getItems(int skip, int limit) {
         return queue;
     }
 
-
-    public DistributionQueueItem remove(@Nonnull String id) {
+    public DistributionQueueItem getItem(@Nonnull String id) {
         DistributionQueueItem toRemove = null;
         for (DistributionQueueItem item : queue) {
             if (id.equals(item.getId())) {
-                toRemove = item;
+                return item;
             }
         }
+
+        return null;
+    }
+
+
+    public DistributionQueueItem remove(@Nonnull String id) {
+        DistributionQueueItem toRemove =getItem(id);
+
         boolean removed = false;
         if (toRemove != null) {
             removed = queue.remove(toRemove);

Added: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/resources/DistributionResourceTypes.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/resources/DistributionResourceTypes.java?rev=1652356&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/resources/DistributionResourceTypes.java (added)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/resources/DistributionResourceTypes.java Fri Jan 16 08:03:33 2015
@@ -0,0 +1,49 @@
+/*
+ * 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.resources;
+
+/**
+ * constants distribution resource types and paths
+ */
+public class DistributionResourceTypes {
+
+    public static final String DEFAULT_SETTING_RESOURCE_TYPE = "sling/distribution/setting";
+    public static final String DEFAULT_SERVICE_RESOURCE_TYPE = "sling/distribution/service";
+
+
+    public static final String AGENT_RESOURCE_TYPE = "sling/distribution/service/agent";
+    public static final String AGENT_LIST_RESOURCE_TYPE = "sling/distribution/service/agent/list";
+    public static final String AGENT_QUEUE_RESOURCE_TYPE = "sling/distribution/service/agent/queue";
+    public static final String AGENT_QUEUE_LIST_RESOURCE_TYPE = "sling/distribution/service/agent/queue/list";
+    public static final String AGENT_QUEUE_ITEM_RESOURCE_TYPE = "sling/distribution/service/agent/queue/item";
+
+
+
+    public static final String IMPORTER_RESOURCE_TYPE = "sling/distribution/service/importer";
+    public static final String IMPORTER_LIST_RESOURCE_TYPE = "sling/distribution/service/importer/list";
+
+    public static final String EXPORTER_RESOURCE_TYPE = "sling/distribution/service/exporter";
+    public static final String EXPORTER_LIST_RESOURCE_TYPE = "sling/distribution/service/exporter/list";
+
+    public static final String TRIGGER_RESOURCE_TYPE = "sling/distribution/service/trigger";
+    public static final String TRIGGER_LIST_RESOURCE_TYPE = "sling/distribution/service/trigger/list";
+
+
+
+}

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/resources/impl/DistributionConfigurationResourceProvider.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/resources/impl/DistributionConfigurationResourceProvider.java?rev=1652356&r1=1652355&r2=1652356&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/resources/impl/DistributionConfigurationResourceProvider.java (original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/resources/impl/DistributionConfigurationResourceProvider.java Fri Jan 16 08:03:33 2015
@@ -21,20 +21,20 @@ package org.apache.sling.distribution.re
 
 import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
 import org.apache.sling.api.resource.ModifyingResourceProvider;
 import org.apache.sling.api.resource.PersistenceException;
-import org.apache.sling.api.resource.Resource;
 import org.apache.sling.api.resource.ResourceProvider;
 import org.apache.sling.api.resource.ResourceResolver;
 import org.apache.sling.distribution.component.impl.DistributionComponentKind;
 import org.apache.sling.distribution.component.impl.DistributionConfiguration;
 import org.apache.sling.distribution.component.impl.DistributionConfigurationManager;
+import org.apache.sling.distribution.resources.DistributionResourceTypes;
 import org.apache.sling.distribution.resources.impl.common.AbstractModifyingResourceProvider;
+import org.apache.sling.distribution.resources.impl.common.SimplePathInfo;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -47,13 +47,15 @@ public class DistributionConfigurationRe
 
     private final Logger log = LoggerFactory.getLogger(getClass());
 
+    private static final String SETTINGS_RESOURCE_TYPE = DistributionResourceTypes.DEFAULT_SETTING_RESOURCE_TYPE;
+
+
     private final DistributionConfigurationManager configurationManager;
 
     private final DistributionComponentKind kind;
 
-    public DistributionConfigurationResourceProvider(DistributionConfigurationManager configurationManager, String kind,
-                                                     String resourceRoot, Map<String, String> additionalResourceProperties) {
-        super(resourceRoot, additionalResourceProperties);
+    public DistributionConfigurationResourceProvider(DistributionConfigurationManager configurationManager, String kind, String resourceRoot) {
+        super(resourceRoot);
         this.configurationManager = configurationManager;
         this.kind = DistributionComponentKind.fromName(kind);
 
@@ -80,6 +82,22 @@ public class DistributionConfigurationRe
     }
 
     @Override
+    protected Map<String, Object> getResourceProperties(SimplePathInfo pathInfo) {
+        if (pathInfo.isRoot()) {
+            return getResourceRootProperties();
+        }
+        else if (pathInfo.isMain()) {
+            return getResourceProperties(pathInfo.getMainResourceName());
+        }
+
+        return null;
+    }
+
+    @Override
+    protected Iterable<String> getResourceChildren(SimplePathInfo pathInfo) {
+        return null;
+    }
+
     protected Map<String, Object> getResourceRootProperties() {
         List<DistributionConfiguration> configsList = configurationManager.getConfigs(kind);
 
@@ -89,12 +107,17 @@ public class DistributionConfigurationRe
         }
 
         Map<String, Object> result = new HashMap<String, Object>();
-        result.put("items", nameList.toArray(new String[nameList.size()]));
+        result.put(ITEMS, nameList.toArray(new String[nameList.size()]));
+
+        String resourceType = getRootResourceType(kind);
+        result.put(SLING_RESOURCE_TYPE, resourceType);
 
         return result;
     }
 
-    @Override
+
+
+
     protected Map<String, Object> getResourceProperties(String resourceName) {
 
         String componentName = getConfigName(resourceName);
@@ -102,19 +125,33 @@ public class DistributionConfigurationRe
         DistributionConfiguration config = configurationManager.getConfig(kind, componentName);
 
         if (config != null) {
-            return config.getProperties();
+
+            Map<String, Object> result = new HashMap<String, Object>();
+
+            result.putAll(config.getProperties());
+            String resourceType = getResourceType(kind);
+            result.put(SLING_RESOURCE_TYPE, resourceType);
+
+            return result;
         }
 
         return null;
     }
 
 
-    public Iterator<Resource> listChildren(Resource parent) {
-        return null;
-    }
 
 
     private String getConfigName(String configName) {
         return configName;
     }
+
+    String getResourceType(DistributionComponentKind kind) {
+        return SETTINGS_RESOURCE_TYPE;
+    }
+
+    private String getRootResourceType(DistributionComponentKind kind) {
+        return SETTINGS_RESOURCE_TYPE;
+    }
+
+
 }

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/resources/impl/DistributionConfigurationResourceProviderFactory.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/resources/impl/DistributionConfigurationResourceProviderFactory.java?rev=1652356&r1=1652355&r2=1652356&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/resources/impl/DistributionConfigurationResourceProviderFactory.java (original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/resources/impl/DistributionConfigurationResourceProviderFactory.java Fri Jan 16 08:03:33 2015
@@ -59,28 +59,11 @@ public class DistributionConfigurationRe
     @Property
     public final static String KIND = DistributionComponentUtils.PN_KIND;
 
-    /**
-     * resourceProperties contains the list of properties returned by this provider.
-     * Properties can be configured for the main resource, for the root resource and for child resources.
-     * Root resource properties are static and can be configured as follows:
-     * ../rootResourcePropertyName = rootResourcePropertyValue
-     * <p/>
-     * Main resource properties can be static or dynamic (depending on the underlying resource) are configured as follows:
-     * mainResourceStaticPropertyName = mainResourceStaticPropertyValue
-     * mainResourceDynamicPropertyName = {mainResourceSourcePropertyName}
-     * <p/>
-     * Child resource properties are static an can be configured as follows:
-     * childResourceName/childResourcePropertyName=childResourcePropertyValue
-     */
-    @Property(cardinality = Integer.MAX_VALUE)
-    public final static String RESOURCE_PROPERTIES = "resourceProperties";
-
     @Reference
     DistributionConfigurationManager configurationManager;
 
     private String resourceRoot;
     private String kind;
-    Map<String, String> additionalResourceProperties;
 
     @Activate
     public void activate(BundleContext context, Map<String, Object> properties) {
@@ -90,10 +73,6 @@ public class DistributionConfigurationRe
         resourceRoot = PropertiesUtil.toString(properties.get(ResourceProvider.ROOTS), null);
         kind = PropertiesUtil.toString(properties.get(KIND), null);
 
-
-
-        additionalResourceProperties = PropertiesUtil.toMap(properties.get(RESOURCE_PROPERTIES), new String[0]);
-
     }
 
     @Deactivate
@@ -102,9 +81,7 @@ public class DistributionConfigurationRe
     }
 
     public ResourceProvider getResourceProvider(Map<String, Object> authenticationInfo) throws LoginException {
-        return new DistributionConfigurationResourceProvider(configurationManager, kind,
-                resourceRoot,
-                additionalResourceProperties);
+        return new DistributionConfigurationResourceProvider(configurationManager, kind, resourceRoot);
     }
 
     public ResourceProvider getAdministrativeResourceProvider(Map<String, Object> authenticationInfo) throws LoginException {

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/resources/impl/DistributionServiceResourceProvider.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/resources/impl/DistributionServiceResourceProvider.java?rev=1652356&r1=1652355&r2=1652356&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/resources/impl/DistributionServiceResourceProvider.java (original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/resources/impl/DistributionServiceResourceProvider.java Fri Jan 16 08:03:33 2015
@@ -22,17 +22,17 @@ package org.apache.sling.distribution.re
 
 import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
-import org.apache.sling.api.resource.Resource;
 import org.apache.sling.api.resource.ResourceProvider;
 import org.apache.sling.distribution.component.impl.DistributionComponent;
 import org.apache.sling.distribution.component.impl.DistributionComponentKind;
 import org.apache.sling.distribution.component.impl.DistributionComponentProvider;
 import org.apache.sling.distribution.component.impl.DistributionComponentUtils;
+import org.apache.sling.distribution.resources.DistributionResourceTypes;
 import org.apache.sling.distribution.resources.impl.common.AbstractReadableResourceProvider;
+import org.apache.sling.distribution.resources.impl.common.SimplePathInfo;
 
 /**
  * {@link ResourceProvider} for Osgi services for a specific service interface.
@@ -44,17 +44,52 @@ public class DistributionServiceResource
     private final DistributionComponentKind kind;
     private final DistributionComponentProvider componentProvider;
 
+    private static final String SERVICES_RESOURCE_TYPE = DistributionResourceTypes.DEFAULT_SERVICE_RESOURCE_TYPE;
+
 
     public DistributionServiceResourceProvider(String kind,
                                                DistributionComponentProvider componentProvider,
-                                               String resourceRoot,
-                                               Map<String, String> additionalResourceProperties) {
-        super(resourceRoot, additionalResourceProperties);
+                                               String resourceRoot) {
+        super(resourceRoot);
         this.kind = DistributionComponentKind.fromName(kind);
         this.componentProvider = componentProvider;
     }
 
+
+
+    @Override
+    protected Map<String, Object> getResourceProperties(SimplePathInfo pathInfo) {
+        if (pathInfo.isRoot()) {
+            return getResourceRootProperties();
+        }
+        else if (pathInfo.isMain()) {
+            return getResourceProperties(pathInfo.getMainResourceName());
+        } else if (pathInfo.isChild()) {
+            DistributionComponent component = componentProvider.getComponent(kind, pathInfo.getMainResourceName());
+
+            if (component != null) {
+                return getChildResourceProperties(component, pathInfo.getChildResourceName());
+            }
+        }
+
+        return null;
+    }
+
+
     @Override
+    protected Iterable<String> getResourceChildren(SimplePathInfo pathInfo) {
+        if (pathInfo.isMain()) {
+            DistributionComponent component = componentProvider.getComponent(kind, pathInfo.getMainResourceName());
+
+            if (component != null) {
+                return getChildResourceChildren(component, pathInfo.getChildResourceName());
+            }
+        }
+
+        return null;
+    }
+
+
     protected Map<String, Object> getResourceProperties(String resourceName) {
 
         DistributionComponent component = componentProvider.getComponent(kind, resourceName);
@@ -64,13 +99,15 @@ public class DistributionServiceResource
 
             properties.put(DistributionComponentUtils.PN_NAME, resourceName);
             properties.put(ADAPTABLE_PROPERTY_NAME, component.getService());
+
+            String resourceType = getResourceType(kind);
+            properties.put(SLING_RESOURCE_TYPE, resourceType);
             return properties;
         }
 
         return null;
     }
 
-    @Override
     protected Map<String, Object> getResourceRootProperties() {
 
         List<DistributionComponent> componentList = componentProvider.getComponents(kind);
@@ -81,13 +118,52 @@ public class DistributionServiceResource
         }
 
         Map<String, Object> result = new HashMap<String, Object>();
-        result.put("items", nameList.toArray(new String[nameList.size()]));
+        result.put(ITEMS, nameList.toArray(new String[nameList.size()]));
+
+        String resourceType = getRootResourceType(kind);
+        result.put(SLING_RESOURCE_TYPE, resourceType);
 
         return result;
     }
 
-    public Iterator<Resource> listChildren(Resource parent) {
+
+
+    String getResourceType(DistributionComponentKind kind) {
+        if (DistributionComponentKind.AGENT.equals(kind)) {
+            return DistributionResourceTypes.AGENT_RESOURCE_TYPE;
+        } else if (DistributionComponentKind.IMPORTER.equals(kind)) {
+            return DistributionResourceTypes.IMPORTER_RESOURCE_TYPE;
+        } else if (DistributionComponentKind.EXPORTER.equals(kind)) {
+            return DistributionResourceTypes.EXPORTER_RESOURCE_TYPE;
+        } else if (DistributionComponentKind.TRIGGER.equals(kind)) {
+            return DistributionResourceTypes.TRIGGER_RESOURCE_TYPE;
+        }
+
+        return SERVICES_RESOURCE_TYPE;
+    }
+
+    String getRootResourceType(DistributionComponentKind kind) {
+        if (DistributionComponentKind.AGENT.equals(kind)) {
+            return DistributionResourceTypes.AGENT_LIST_RESOURCE_TYPE;
+        } else if (DistributionComponentKind.IMPORTER.equals(kind)) {
+            return DistributionResourceTypes.IMPORTER_LIST_RESOURCE_TYPE;
+        } else if (DistributionComponentKind.EXPORTER.equals(kind)) {
+            return DistributionResourceTypes.EXPORTER_LIST_RESOURCE_TYPE;
+        } else if (DistributionComponentKind.TRIGGER.equals(kind)) {
+            return DistributionResourceTypes.TRIGGER_LIST_RESOURCE_TYPE;
+        }
+
+        return SERVICES_RESOURCE_TYPE;
+    }
+
+
+
+    protected Map<String, Object> getChildResourceProperties(DistributionComponent component, String childResourceName) {
         return null;
     }
 
+
+    protected Iterable<String> getChildResourceChildren(DistributionComponent component, String childResourceName) {
+        return null;
+    }
 }

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/resources/impl/DistributionServiceResourceProviderFactory.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/resources/impl/DistributionServiceResourceProviderFactory.java?rev=1652356&r1=1652355&r2=1652356&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/resources/impl/DistributionServiceResourceProviderFactory.java (original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/resources/impl/DistributionServiceResourceProviderFactory.java Fri Jan 16 08:03:33 2015
@@ -62,22 +62,6 @@ public class DistributionServiceResource
     @Property
     public final static String KIND = DistributionComponentUtils.PN_KIND;
 
-    /**
-     * resourceProperties contains the list of properties returned by this provider.
-     * Properties can be configured for the main resource, for the root resource and for child resources.
-     * Root resource properties are static and can be configured as follows:
-     * ../rootResourcePropertyName = rootResourcePropertyValue
-     * <p/>
-     * Main resource properties can be static or dynamic (depending on the underlying resource) are configured as follows:
-     * mainResourceStaticPropertyName = mainResourceStaticPropertyValue
-     * mainResourceDynamicPropertyName = {mainResourceSourcePropertyName}
-     * <p/>
-     * Child resource properties are static an can be configured as follows:
-     * childResourceName/childResourcePropertyName=childResourcePropertyValue
-     */
-    @Property(cardinality = Integer.MAX_VALUE)
-    public final static String RESOURCE_PROPERTIES = "resourceProperties";
-
     @Reference
     DistributionComponentProvider componentProvider;
 
@@ -91,13 +75,9 @@ public class DistributionServiceResource
         String kind = PropertiesUtil.toString(properties.get(KIND), null);
         String resourceRoot = PropertiesUtil.toString(properties.get(ResourceProvider.ROOTS), null);
 
-
-        Map<String, String> additionalResourceProperties = PropertiesUtil.toMap(properties.get(RESOURCE_PROPERTIES), new String[0]);
-
-        resourceProvider = new DistributionServiceResourceProvider(kind,
+        resourceProvider = new ExtendedDistributionServiceResourceProvider(kind,
                 componentProvider,
-                resourceRoot,
-                additionalResourceProperties);
+                resourceRoot);
 
         log.debug("created resource provider {}", resourceProvider);
     }

Added: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/resources/impl/ExtendedDistributionServiceResourceProvider.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/resources/impl/ExtendedDistributionServiceResourceProvider.java?rev=1652356&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/resources/impl/ExtendedDistributionServiceResourceProvider.java (added)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/resources/impl/ExtendedDistributionServiceResourceProvider.java Fri Jan 16 08:03:33 2015
@@ -0,0 +1,161 @@
+/*
+ * 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.resources.impl;
+
+import org.apache.sling.distribution.agent.DistributionAgent;
+import org.apache.sling.distribution.agent.DistributionAgentException;
+import org.apache.sling.distribution.component.impl.DistributionComponent;
+import org.apache.sling.distribution.component.impl.DistributionComponentKind;
+import org.apache.sling.distribution.component.impl.DistributionComponentProvider;
+import org.apache.sling.distribution.queue.DistributionQueue;
+import org.apache.sling.distribution.queue.DistributionQueueException;
+import org.apache.sling.distribution.queue.DistributionQueueItem;
+import org.apache.sling.distribution.queue.DistributionQueueItemStatus;
+import org.apache.sling.distribution.resources.DistributionResourceTypes;
+import org.apache.sling.distribution.resources.impl.common.SimplePathInfo;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Extended service resource provider exposes children resources like .../agents/agentName/queues/queueName/queueItem
+ */
+public class ExtendedDistributionServiceResourceProvider extends DistributionServiceResourceProvider {
+
+    private static final String QUEUES_PATH = "queues";
+    private static final int MAX_QUEUE_DEPTH = 100;
+
+
+    public ExtendedDistributionServiceResourceProvider(String kind,
+                                               DistributionComponentProvider componentProvider,
+                                               String resourceRoot) {
+        super(kind, componentProvider, resourceRoot);
+    }
+
+
+    @Override
+    protected Map<String,Object> getChildResourceProperties(DistributionComponent component, String childResourceName) {
+        DistributionComponentKind kind =  component.getKind();
+        if (kind.equals(DistributionComponentKind.AGENT)) {
+            DistributionAgent agent = (DistributionAgent) component.getService();
+
+            if (agent != null) {
+                if (childResourceName.startsWith(QUEUES_PATH)) {
+                    SimplePathInfo queuePathInfo = SimplePathInfo.parsePathInfo(QUEUES_PATH, childResourceName);
+                    Map<String, Object> result = getQueueProperties(agent, queuePathInfo);
+                    return result;
+                }
+            }
+        }
+        return null;
+    }
+
+    @Override
+    protected Iterable<String> getChildResourceChildren(DistributionComponent component, String childResourceName) {
+
+        DistributionComponentKind kind =  component.getKind();
+        if (kind.equals(DistributionComponentKind.AGENT)) {
+            DistributionAgent agent = (DistributionAgent) component.getService();
+
+            if (agent != null) {
+                if (childResourceName == null) {
+                    List<String> nameList = new ArrayList<String>();
+                    nameList.add(QUEUES_PATH);
+                    return nameList;
+                }
+            }
+        }
+        return null;
+    }
+
+    private Map<String,Object> getQueueProperties(DistributionAgent agent, SimplePathInfo queueInfo) {
+        if (queueInfo.isRoot()) {
+            Map<String, Object> result = new HashMap<String, Object>();
+
+            List<String> nameList = new ArrayList<String>();
+            for (String name : agent.getQueueNames()) {
+                nameList.add(name);
+            }
+            result.put(ITEMS, nameList.toArray(new String[nameList.size()]));
+
+            result.put(SLING_RESOURCE_TYPE, DistributionResourceTypes.AGENT_QUEUE_LIST_RESOURCE_TYPE);
+            return result;
+        } else if (queueInfo.isMain()) {
+            String queueName = queueInfo.getMainResourceName();
+            Map<String, Object> result = new HashMap<String, Object>();
+
+            try {
+                DistributionQueue queue = agent.getQueue(queueName);
+
+                result.put(SLING_RESOURCE_TYPE, DistributionResourceTypes.AGENT_QUEUE_RESOURCE_TYPE);
+                result.put("state", queue.getState().name());
+                result.put("empty", queue.isEmpty());
+                result.put("itemsCount", queue.getItemsCount());
+
+                List<String> nameList = new ArrayList<String>();
+                for (DistributionQueueItem item : queue.getItems(0, MAX_QUEUE_DEPTH)) {
+                    nameList.add(item.getId());
+                }
+                result.put(ITEMS, nameList.toArray(new String[0]));
+                result.put(ADAPTABLE_PROPERTY_NAME, queue);
+
+            } catch (DistributionAgentException e) {
+
+            }
+
+            return result;
+
+        } else if (queueInfo.isChild()) {
+            String queueName = queueInfo.getMainResourceName();
+            Map<String, Object> result = new HashMap<String, Object>();
+
+            try {
+                DistributionQueue queue = agent.getQueue(queueName);
+                String itemId = queueInfo.getChildResourceName();
+
+                DistributionQueueItem item = queue.getItem(itemId);
+
+                if (item != null) {
+
+                    result.put(SLING_RESOURCE_TYPE, DistributionResourceTypes.AGENT_QUEUE_ITEM_RESOURCE_TYPE);
+                    result.put("id", item.getId());
+                    result.put("paths", item.getPackageInfo().getPaths());
+                    result.put("action", item.getPackageInfo().getRequestType());
+                    result.put("type", item.getType());
+
+                    DistributionQueueItemStatus status = queue.getStatus(item);
+                    result.put("attempts", status.getAttempts());
+                    result.put("time", status.getEntered().getTime());
+                    result.put("state", status.getItemState().name());
+
+                }
+            } catch (DistributionAgentException e) {
+
+            } catch (DistributionQueueException e) {
+            }
+            return result;
+        }
+
+        return null;
+    }
+
+}

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/resources/impl/common/AbstractModifyingResourceProvider.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/resources/impl/common/AbstractModifyingResourceProvider.java?rev=1652356&r1=1652355&r2=1652356&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/resources/impl/common/AbstractModifyingResourceProvider.java (original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/resources/impl/common/AbstractModifyingResourceProvider.java Fri Jan 16 08:03:33 2015
@@ -36,9 +36,8 @@ public abstract class AbstractModifyingR
     private final Map<String, Map<String, Object>> changedResources = new HashMap<String, Map<String, Object>>();
     private final Set<String> deletedResources = new HashSet<String>();
 
-    protected AbstractModifyingResourceProvider(String resourceRoot,
-                                                Map<String, String> additionalResourceProperties) {
-        super(resourceRoot, additionalResourceProperties);
+    protected AbstractModifyingResourceProvider(String resourceRoot) {
+        super(resourceRoot);
 
     }
 
@@ -62,7 +61,9 @@ public abstract class AbstractModifyingR
             throw new PersistenceException("Resource already exists at " + path, null, resourceName, null);
         }
 
-        return buildMainResource(resolver, pathInfo, properties);
+        Resource resource = buildMainResource(resolver, pathInfo, properties);
+
+        return resource;
     }
 
     public void delete(ResourceResolver resolver, String requestPath) throws PersistenceException {
@@ -140,7 +141,6 @@ public abstract class AbstractModifyingR
         return true;
     }
 
-    @Override
     protected Map<String, Object> getMainResourceProperties(String resourceName) {
 
         if (deletedResources.contains(resourceName)) {
@@ -151,14 +151,20 @@ public abstract class AbstractModifyingR
             return changedResources.get(resourceName);
         }
 
-        return super.getMainResourceProperties(resourceName);
+        SimplePathInfo pathInfo = SimplePathInfo.parsePathInfo(resourceRoot, resourceRoot + "/" + resourceName);
+
+        return getResourceProperties(pathInfo);
     }
 
-    @Override
-    protected Resource buildMainResource(ResourceResolver resourceResolver, SimplePathInfo pathInfo, Map<String, Object> properties, Object... adapters) {
+    Resource buildMainResource(ResourceResolver resourceResolver,
+                               SimplePathInfo pathInfo,
+                               Map<String, Object> properties,
+                               Object... adapters) {
         return new SimpleModifiableResource(resourceResolver, this, pathInfo.getResourcePath(), properties);
     }
 
+
+
     protected abstract void save(ResourceResolver resourceResolver,
                                  Map<String, Map<String, Object>> changedResources,
                                  Set<String> deletedResources) throws PersistenceException;

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/resources/impl/common/AbstractReadableResourceProvider.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/resources/impl/common/AbstractReadableResourceProvider.java?rev=1652356&r1=1652355&r2=1652356&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/resources/impl/common/AbstractReadableResourceProvider.java (original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/resources/impl/common/AbstractReadableResourceProvider.java Fri Jan 16 08:03:33 2015
@@ -23,7 +23,11 @@ package org.apache.sling.distribution.re
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 import javax.servlet.http.HttpServletRequest;
+import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
 
 import org.apache.sling.api.resource.Resource;
@@ -34,32 +38,15 @@ public abstract class AbstractReadableRe
 
     protected static final String ADAPTABLE_PROPERTY_NAME = "adaptable";
 
-    private static final String MAIN_RESOURCE_PREFIX = ".";
+    protected static final String ITEMS = "items";
 
-    private final String resourceRoot;
-    private final Map<String, Map<String, String>> additionalResourcePropertiesMap = new HashMap<String, Map<String, String>>();
+    protected static final String SLING_RESOURCE_TYPE = "sling:resourceType";
 
-    protected AbstractReadableResourceProvider(String resourceRoot,
-                                               Map<String, String> additionalResourceProperties) {
+    protected final String resourceRoot;
 
-        this.resourceRoot = resourceRoot;
-
-        additionalResourcePropertiesMap.put(MAIN_RESOURCE_PREFIX, new HashMap<String, String>());
-        for (Map.Entry<String, String> entry : additionalResourceProperties.entrySet()) {
-            String resourceName = MAIN_RESOURCE_PREFIX;
-            String propertyName = entry.getKey();
-            int idx = propertyName.indexOf("/");
-            if (idx >= 0) {
-                resourceName = propertyName.substring(0, idx);
-                propertyName = propertyName.substring(idx + 1);
-            }
+    protected AbstractReadableResourceProvider(String resourceRoot) {
 
-            if (!additionalResourcePropertiesMap.containsKey(resourceName)) {
-                additionalResourcePropertiesMap.put(resourceName, new HashMap<String, String>());
-            }
-
-            additionalResourcePropertiesMap.get(resourceName).put(propertyName, entry.getValue());
-        }
+        this.resourceRoot = resourceRoot;
     }
 
     public Resource getResource(ResourceResolver resourceResolver, HttpServletRequest request, String path) {
@@ -83,55 +70,17 @@ public abstract class AbstractReadableRe
 
         Resource resource = null;
 
-        if (pathInfo.isRoot()) {
-
-            Map<String, Object> properties = getResourceRootProperties();
-
-            if (properties != null) {
-                Object adaptable = properties.remove(ADAPTABLE_PROPERTY_NAME);
-
-                Map<String, String> additionalProperties = additionalResourcePropertiesMap.get(MAIN_RESOURCE_PREFIX);
-                if (!properties.containsKey("sling:resourceType") && additionalProperties.containsKey("sling:resourceType")) {
-                    properties.put("sling:resourceType", additionalProperties.get("sling:resourceType") + "/list");
-                }
-                if (!properties.containsKey("sling:resourceSuperType") && additionalProperties.containsKey("sling:resourceSuperType")) {
-                    properties.put("sling:resourceSuperType", additionalProperties.get("sling:resourceSuperType") + "/list");
-                }
-
-                resource = new SimpleReadableResource(resourceResolver, pathInfo.getResourcePath(), properties, adaptable);
-            }
-        } else if (pathInfo.isMain()) {
-            Map<String, Object> properties = getMainResourceProperties(pathInfo.getMainResourceName());
-
-            Map<String, String> additionalProperties = additionalResourcePropertiesMap.get(MAIN_RESOURCE_PREFIX);
-            if (!properties.containsKey("sling:resourceType") && additionalProperties.containsKey("sling:resourceType")) {
-                properties.put("sling:resourceType", additionalProperties.get("sling:resourceType"));
-            }
+        Map<String, Object> properties = getResourceProperties(pathInfo);
 
-            if (properties != null) {
-                Object adaptable = properties.remove(ADAPTABLE_PROPERTY_NAME);
+        if (properties != null) {
+            Object adaptable = properties.remove(ADAPTABLE_PROPERTY_NAME);
 
-                resource = buildMainResource(resourceResolver, pathInfo, properties, adaptable);
-            }
-        } else if (pathInfo.isChild()) {
-            Map<String, Object> mainProperties = getMainResourceProperties(pathInfo.getMainResourceName());
-            Map<String, String> childProperties = additionalResourcePropertiesMap.get(pathInfo.getChildResourceName());
-
-            if (mainProperties != null && childProperties != null) {
-                Object adaptable = mainProperties.remove(ADAPTABLE_PROPERTY_NAME);
-
-                Map<String, Object> properties = new HashMap<String, Object>();
-                properties.putAll(childProperties);
-                resource = new SimpleReadableResource(resourceResolver, pathInfo.getResourcePath(), properties, adaptable);
-            }
+            resource = buildMainResource(resourceResolver, pathInfo, properties, adaptable);
         }
 
         return resource;
     }
 
-    Map<String, Object> getMainResourceProperties(String resourceName) {
-        return getResourceProperties(resourceName);
-    }
 
     Resource buildMainResource(ResourceResolver resourceResolver,
                                SimplePathInfo pathInfo,
@@ -140,6 +89,9 @@ public abstract class AbstractReadableRe
         return new SimpleReadableResource(resourceResolver, pathInfo.getResourcePath(), properties, adapters);
     }
 
+
+
+
     SimplePathInfo extractPathInfo(String path) {
         return SimplePathInfo.parsePathInfo(resourceRoot, path);
     }
@@ -161,7 +113,50 @@ public abstract class AbstractReadableRe
     }
 
 
-    protected abstract Map<String, Object> getResourceProperties(String resourceName);
+    public Iterator<Resource> listChildren(Resource parent) {
+        String path = parent.getPath();
+        ResourceResolver resourceResolver = parent.getResourceResolver();
+
+        SimplePathInfo pathInfo = extractPathInfo(path);
+
+        if (pathInfo == null) {
+            return null;
+        }
+
+        if (pathInfo.getResourcePathInfo() != null && pathInfo.getResourcePathInfo().length() > 0) {
+            return null;
+        }
+
+        if (!hasPermission(resourceResolver, pathInfo.getResourcePath(), Session.ACTION_READ)) {
+            return null;
+        }
+
+        List<Resource> resourceList = new ArrayList<Resource>();
+        Iterable<String> childrenList = getResourceChildren(pathInfo);
+
+        if (childrenList == null) {
+            Map<String, Object> properties = getResourceProperties(pathInfo);
+
+            if (properties != null && properties.containsKey(ITEMS)
+                    && properties.get(ITEMS) instanceof String[]) {
+                String[] itemsArray = (String[]) properties.get(ITEMS);
+                childrenList = Arrays.asList(itemsArray);
+            }
+        }
+
+        if (childrenList != null) {
+            for (String childResourceName : childrenList) {
+                Resource childResource = getResource(resourceResolver, path + "/" + childResourceName);
+
+                resourceList.add(childResource);
+            }
+        }
+
+        return resourceList.listIterator();
+    }
+
+
+    protected abstract Map<String, Object> getResourceProperties(SimplePathInfo pathInfo);
+    protected abstract Iterable<String> getResourceChildren(SimplePathInfo pathInfo);
 
-    protected abstract Map<String, Object> getResourceRootProperties();
 }

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/serialization/impl/ResourceSharedDistributionPackage.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/serialization/impl/ResourceSharedDistributionPackage.java?rev=1652356&r1=1652355&r2=1652356&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/serialization/impl/ResourceSharedDistributionPackage.java (original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/serialization/impl/ResourceSharedDistributionPackage.java Fri Jan 16 08:03:33 2015
@@ -23,6 +23,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.util.Collections;
 
+import org.apache.jackrabbit.util.Text;
 import org.apache.sling.api.resource.PersistenceException;
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.api.resource.ResourceResolver;
@@ -36,15 +37,16 @@ public class ResourceSharedDistributionP
     private final Logger log = LoggerFactory.getLogger(getClass());
 
     protected static final String  REFERENCE_ROOT_NODE = "refs";
-    private static final String  PN_REFERENCE_COUNT = "ref.count";
 
 
     private final ResourceResolver resourceResolver;
     private final String packagePath;
     private final DistributionPackage distributionPackage;
+    private final String packageName;
 
-    public ResourceSharedDistributionPackage(ResourceResolver resourceResolver, String packagePath, DistributionPackage distributionPackage) {
+    public ResourceSharedDistributionPackage(ResourceResolver resourceResolver, String packageName, String packagePath, DistributionPackage distributionPackage) {
         this.resourceResolver = resourceResolver;
+        this.packageName = packageName;
         this.packagePath = packagePath;
         this.distributionPackage = distributionPackage;
     }
@@ -83,7 +85,7 @@ public class ResourceSharedDistributionP
 
     @Nonnull
     public String getId() {
-        return packagePath;
+        return packageName;
     }
 
     @Nonnull

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/serialization/impl/ResourceSharedDistributionPackageBuilder.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/serialization/impl/ResourceSharedDistributionPackageBuilder.java?rev=1652356&r1=1652355&r2=1652356&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/serialization/impl/ResourceSharedDistributionPackageBuilder.java (original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/serialization/impl/ResourceSharedDistributionPackageBuilder.java Fri Jan 16 08:03:33 2015
@@ -62,9 +62,11 @@ public class ResourceSharedDistributionP
         }
 
         try {
-            String packagePath = generatePathFromId(resourceResolver, distributionPackage);
+            String packageName = generateNameFromId(resourceResolver, distributionPackage);
+            String packagePath = getPathFromName(packageName);
 
-            return new ResourceSharedDistributionPackage(resourceResolver, packagePath, distributionPackage);
+
+            return new ResourceSharedDistributionPackage(resourceResolver, packageName, packagePath, distributionPackage);
         }
         catch (PersistenceException e) {
             throw new DistributionPackageBuildingException(e);
@@ -80,9 +82,10 @@ public class ResourceSharedDistributionP
         }
 
         try {
-            String packagePath = generatePathFromId(resourceResolver, distributionPackage);
+            String packageName = generateNameFromId(resourceResolver, distributionPackage);
+            String packagePath = getPathFromName(packageName);
 
-            return new ResourceSharedDistributionPackage(resourceResolver, packagePath, distributionPackage);
+            return new ResourceSharedDistributionPackage(resourceResolver, packageName, packagePath, distributionPackage);
         }
         catch (PersistenceException e) {
             throw new DistributionPackageReadingException(e);
@@ -90,7 +93,8 @@ public class ResourceSharedDistributionP
     }
 
     public DistributionPackage getPackage(@Nonnull ResourceResolver resourceResolver, @Nonnull String distributionPackageId) {
-        String originalPackageId = retrieveIdFromPath(resourceResolver, distributionPackageId);
+        String packageName = distributionPackageId;
+        String originalPackageId = retrieveIdFromName(resourceResolver, packageName);
 
         if (originalPackageId == null) {
             return null;
@@ -101,8 +105,8 @@ public class ResourceSharedDistributionP
         if (distributionPackage == null) {
             return null;
         }
-
-        return new ResourceSharedDistributionPackage(resourceResolver, distributionPackageId, distributionPackage);
+        String packagePath = getPathFromName(packageName);
+        return new ResourceSharedDistributionPackage(resourceResolver, packageName, packagePath, distributionPackage);
     }
 
     public boolean installPackage(@Nonnull ResourceResolver resourceResolver, @Nonnull DistributionPackage distributionPackage) throws DistributionPackageReadingException {
@@ -117,9 +121,8 @@ public class ResourceSharedDistributionP
     }
 
 
-    private String generatePathFromId(ResourceResolver resourceResolver, DistributionPackage distributionPackage) throws PersistenceException {
+    private String generateNameFromId(ResourceResolver resourceResolver, DistributionPackage distributionPackage) throws PersistenceException {
         String name = PACKAGE_NAME_PREFIX + "_" + System.currentTimeMillis() + "_" +  UUID.randomUUID();
-        String packagePath = sharedPackagesRoot + name;
 
         Map<String, Object> properties = new HashMap<String, Object>();
         properties.put(PN_ORIGINAL_ID, distributionPackage.getId());
@@ -133,7 +136,10 @@ public class ResourceSharedDistributionP
             properties.put(PN_ORIGINAL_PATHS, distributionPackage.getInfo().getPaths());
         }
 
-        Resource resource = ResourceUtil.getOrCreateResource(resourceResolver, packagePath, "sling:Folder", "sling:Folder", false);
+        String packagePath = getPathFromName(name);
+
+        Resource resource = ResourceUtil.getOrCreateResource(resourceResolver, packagePath,
+                "sling:Folder", "sling:Folder", false);
 
         ModifiableValueMap valueMap = resource.adaptTo(ModifiableValueMap.class);
         valueMap.putAll(properties);
@@ -142,14 +148,16 @@ public class ResourceSharedDistributionP
                 Collections.singletonMap(ResourceResolver.PROPERTY_RESOURCE_TYPE, (Object)"sling:Folder"));
 
         resourceResolver.commit();
-        return packagePath;
+        return name;
+    }
 
+    private String getPathFromName(String name) {
+        String packagePath = sharedPackagesRoot + name;
+        return packagePath;
     }
 
-    private String retrieveIdFromPath(ResourceResolver resourceResolver, String packagePath) {
-        if (!packagePath.startsWith(sharedPackagesRoot)) {
-            return null;
-        }
+    private String retrieveIdFromName(ResourceResolver resourceResolver, String name) {
+        String packagePath = getPathFromName(name);
 
         Resource resource = resourceResolver.getResource(packagePath);
 

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/servlet/DistributionAgentQueueServlet.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/servlet/DistributionAgentQueueServlet.java?rev=1652356&r1=1652355&r2=1652356&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/servlet/DistributionAgentQueueServlet.java (original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/servlet/DistributionAgentQueueServlet.java Fri Jan 16 08:03:33 2015
@@ -25,120 +25,59 @@ import org.apache.felix.scr.annotations.
 import org.apache.sling.api.SlingHttpServletRequest;
 import org.apache.sling.api.SlingHttpServletResponse;
 import org.apache.sling.api.servlets.SlingAllMethodsServlet;
-import org.apache.sling.distribution.agent.DistributionAgent;
-import org.apache.sling.distribution.impl.DistributionParameter;
 import org.apache.sling.distribution.queue.DistributionQueue;
-import org.apache.sling.distribution.queue.impl.DistributionQueueDispatchingStrategy;
 import org.apache.sling.distribution.queue.DistributionQueueItem;
-import org.apache.sling.distribution.queue.DistributionQueueItemStatus;
-import org.apache.sling.distribution.resources.DistributionConstants;
+import org.apache.sling.distribution.resources.DistributionResourceTypes;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
  * Servlet to retrieve a {@link org.apache.sling.distribution.queue.DistributionQueue} status.
  */
-@SlingServlet(resourceTypes = DistributionConstants.AGENT_QUEUE_RESOURCE_TYPE, methods = {"GET", "POST", "DELETE"})
+@SlingServlet(resourceTypes = DistributionResourceTypes.AGENT_QUEUE_RESOURCE_TYPE, methods = {"POST"})
 public class DistributionAgentQueueServlet extends SlingAllMethodsServlet {
 
     private final Logger log = LoggerFactory.getLogger(getClass());
 
-    @Override
-    protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response)
-            throws ServletException, IOException {
-        response.setContentType("application/json");
-
-        String queueName = request.getParameter(DistributionParameter.QUEUE.toString());
-
-        DistributionAgent agent = request.getResource().adaptTo(DistributionAgent.class);
-
-        if (agent != null) {
-            try {
-                DistributionQueue queue = agent.getQueue(queueName != null ? queueName : DistributionQueueDispatchingStrategy.DEFAULT_QUEUE_NAME);
-                response.getWriter().write(toJSoN(queue)); // TODO : use json writer
-                response.setStatus(200);
-            } catch (Exception e) {
-                response.setStatus(400);
-                response.getWriter().write("{\"status\" : \"error\",\"message\":\"error reading from the queue\",\"reason\":\""
-                        + e.getLocalizedMessage() + "\"}");
-            }
-        } else {
-            response.getWriter().write("{\"status\" : \"error\",\"message\":\"queue not found\"}");
-        }
-    }
-
 
     @Override
     protected void doPost(SlingHttpServletRequest request, SlingHttpServletResponse response)
             throws ServletException, IOException {
         @SuppressWarnings("unchecked")
-        String operation = request.getParameter(":operation");
+        String operation = request.getParameter("operation");
 
-        if ("delete".equals(operation)) {
-            doDelete(request, response);
-        }
-    }
+        DistributionQueue queue = request.getResource().adaptTo(DistributionQueue.class);
 
+        String limitParam = request.getParameter("limit");
+        String[] idParam = request.getParameterValues("id");
 
-    @Override
-    protected void doDelete(SlingHttpServletRequest request, SlingHttpServletResponse response)
-            throws ServletException, IOException {
-        DistributionQueue queue = request.getResource().adaptTo(DistributionQueue.class);
+        if ("delete".equals(operation)) {
 
-        while (!queue.isEmpty()) {
-            DistributionQueueItem queueItem = queue.getHead();
-            DistributionQueueItem removedItem = queue.remove(queueItem.getId());
-            if (removedItem != null) {
-                log.info("item {} removed from the queue {}", removedItem, queue);
-                response.setStatus(200);
-            } else {
-                log.warn("could not remove item {} from the queue {}", queueItem, queue);
-                response.setStatus(400);
+            if (idParam != null) {
+                deleteItem(queue, idParam);
             }
-        }
-    }
+            else {
+                int limit = 1;
+                try {
+                    limit = Integer.parseInt(limitParam);
+                }
+                catch (NumberFormatException ex) {
 
-    private String toJSoN(DistributionQueue queue) throws Exception {
-        StringBuilder builder = new StringBuilder("{\"name\":\"" + queue.getName() + "\",\"empty\":" + queue.isEmpty());
-        if (!queue.isEmpty()) {
-            builder.append(",\"items\":[");
-            for (DistributionQueueItem item : queue.getItems(0, -1)) {
-                builder.append('{');
-                builder.append(toJSoN(item));
-                builder.append(',');
-                builder.append(toJSoN(queue.getStatus(item)));
-                builder.append("},");
+                }
+                deleteItems(queue, limit);
             }
-            builder.deleteCharAt(builder.length() - 1);
-            builder.append(']');
         }
-        builder.append('}');
-        return builder.toString();
     }
 
-    private String toJSoN(DistributionQueueItemStatus status) {
-        StringBuilder builder = new StringBuilder("\"attempts\":" + status.getAttempts() + ",\"state\":\"" +
-                status.getItemState().name() + "\"");
-        if (status.getEntered() != null) {
-            builder.append(",\"entered\":\"").append(status.getEntered().getTime()).append("\"");
-        }
-        return builder.toString();
+    protected void deleteItems(DistributionQueue queue, int limit) {
+       for(DistributionQueueItem item : queue.getItems(0, limit)) {
+           queue.remove(item.getId());
+       }
     }
 
-    private String toJSoN(DistributionQueueItem item) {
-        StringBuilder builder = new StringBuilder();
-        builder.append("\"id\":\"").append(item.getId().replace("\\", "\\\\"));
-        builder.append("\",\"paths\":[");
-        for (int i = 0; i < item.getPackageInfo().getPaths().length; i++) {
-            builder.append("\"");
-            builder.append(item.getPackageInfo().getPaths()[i]);
-            builder.append("\",");
+    protected void deleteItem(DistributionQueue queue, String[] ids) {
+        for(String id : ids) {
+            queue.remove(id);
         }
-        builder.deleteCharAt(builder.length() - 1);
-        builder.append(']');
-        builder.append(",\"action\":\"").append(item.getPackageInfo().getRequestType());
-        builder.append("\",\"type\":\"").append(item.getType());
-        builder.append("\"");
-        return builder.toString();
     }
 }

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/servlet/DistributionAgentRootServlet.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/servlet/DistributionAgentRootServlet.java?rev=1652356&r1=1652355&r2=1652356&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/servlet/DistributionAgentRootServlet.java (original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/servlet/DistributionAgentRootServlet.java Fri Jan 16 08:03:33 2015
@@ -31,14 +31,14 @@ import org.apache.sling.distribution.age
 import org.apache.sling.distribution.DistributionRequest;
 import org.apache.sling.distribution.DistributionRequestType;
 import org.apache.sling.distribution.SimpleDistributionRequest;
-import org.apache.sling.distribution.resources.DistributionConstants;
+import org.apache.sling.distribution.resources.DistributionResourceTypes;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
  * Servlet for aggregate distribution on all agents
  */
-@SlingServlet(resourceTypes = DistributionConstants.AGENT_ROOT_RESOURCE_TYPE, methods = "POST")
+@SlingServlet(resourceTypes = DistributionResourceTypes.AGENT_LIST_RESOURCE_TYPE, methods = "POST")
 public class DistributionAgentRootServlet extends SlingAllMethodsServlet {
 
     private final Logger log = LoggerFactory.getLogger(getClass());

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/servlet/DistributionAgentServlet.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/servlet/DistributionAgentServlet.java?rev=1652356&r1=1652355&r2=1652356&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/servlet/DistributionAgentServlet.java (original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/servlet/DistributionAgentServlet.java Fri Jan 16 08:03:33 2015
@@ -30,7 +30,7 @@ import org.apache.sling.distribution.age
 import org.apache.sling.distribution.agent.DistributionAgentException;
 import org.apache.sling.distribution.DistributionRequest;
 import org.apache.sling.distribution.DistributionResponse;
-import org.apache.sling.distribution.resources.DistributionConstants;
+import org.apache.sling.distribution.resources.DistributionResourceTypes;
 import org.apache.sling.distribution.util.RequestUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -38,7 +38,7 @@ import org.slf4j.LoggerFactory;
 /**
  * Servlet to ask {@link org.apache.sling.distribution.agent.DistributionAgent}s to distribute (via HTTP POST).
  */
-@SlingServlet(resourceTypes = DistributionConstants.AGENT_RESOURCE_TYPE, methods = "POST")
+@SlingServlet(resourceTypes = DistributionResourceTypes.AGENT_RESOURCE_TYPE, methods = "POST")
 public class DistributionAgentServlet extends SlingAllMethodsServlet {
 
     private final Logger log = LoggerFactory.getLogger(getClass());

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/servlet/DistributionPackageExporterServlet.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/servlet/DistributionPackageExporterServlet.java?rev=1652356&r1=1652355&r2=1652356&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/servlet/DistributionPackageExporterServlet.java (original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/servlet/DistributionPackageExporterServlet.java Fri Jan 16 08:03:33 2015
@@ -33,7 +33,7 @@ import org.apache.sling.api.servlets.Sli
 import org.apache.sling.distribution.DistributionRequest;
 import org.apache.sling.distribution.packaging.DistributionPackage;
 import org.apache.sling.distribution.packaging.DistributionPackageExporter;
-import org.apache.sling.distribution.resources.DistributionConstants;
+import org.apache.sling.distribution.resources.DistributionResourceTypes;
 import org.apache.sling.distribution.util.RequestUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -41,7 +41,7 @@ import org.slf4j.LoggerFactory;
 /**
  * Servlet to handle fetching of distribution content.
  */
-@SlingServlet(resourceTypes = DistributionConstants.EXPORTER_RESOURCE_TYPE, methods = "POST")
+@SlingServlet(resourceTypes = DistributionResourceTypes.EXPORTER_RESOURCE_TYPE, methods = "POST")
 public class DistributionPackageExporterServlet extends SlingAllMethodsServlet {
 
     private final Logger log = LoggerFactory.getLogger(getClass());

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/servlet/DistributionPackageImporterServlet.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/servlet/DistributionPackageImporterServlet.java?rev=1652356&r1=1652355&r2=1652356&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/servlet/DistributionPackageImporterServlet.java (original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/servlet/DistributionPackageImporterServlet.java Fri Jan 16 08:03:33 2015
@@ -29,14 +29,14 @@ import org.apache.sling.api.resource.Res
 import org.apache.sling.api.servlets.SlingAllMethodsServlet;
 import org.apache.sling.distribution.packaging.DistributionPackage;
 import org.apache.sling.distribution.packaging.DistributionPackageImporter;
-import org.apache.sling.distribution.resources.DistributionConstants;
+import org.apache.sling.distribution.resources.DistributionResourceTypes;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
  * Servlet to handle reception of distribution content.
  */
-@SlingServlet(resourceTypes = DistributionConstants.IMPORTER_RESOURCE_TYPE, methods = "POST")
+@SlingServlet(resourceTypes = DistributionResourceTypes.IMPORTER_RESOURCE_TYPE, methods = "POST")
 public class DistributionPackageImporterServlet extends SlingAllMethodsServlet {
 
     private final Logger log = LoggerFactory.getLogger(getClass());

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/servlet/DistributionTriggerServlet.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/servlet/DistributionTriggerServlet.java?rev=1652356&r1=1652355&r2=1652356&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/servlet/DistributionTriggerServlet.java (original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/servlet/DistributionTriggerServlet.java Fri Jan 16 08:03:33 2015
@@ -29,6 +29,7 @@ import org.apache.sling.api.SlingHttpSer
 import org.apache.sling.api.SlingHttpServletResponse;
 import org.apache.sling.api.servlets.SlingAllMethodsServlet;
 import org.apache.sling.distribution.DistributionRequest;
+import org.apache.sling.distribution.resources.DistributionResourceTypes;
 import org.apache.sling.distribution.trigger.DistributionRequestHandler;
 import org.apache.sling.distribution.trigger.DistributionTrigger;
 import org.apache.sling.distribution.trigger.DistributionTriggerException;
@@ -38,7 +39,7 @@ import org.slf4j.LoggerFactory;
 /**
  * Triggers Server Sent Events servlet
  */
-@SlingServlet(resourceTypes = "sling/distribution/service/trigger", extensions = "event", methods = "GET")
+@SlingServlet(resourceTypes = DistributionResourceTypes.TRIGGER_RESOURCE_TYPE, extensions = "event", methods = "GET")
 public class DistributionTriggerServlet extends SlingAllMethodsServlet {
 
     private final Logger log = LoggerFactory.getLogger(getClass());

Modified: sling/trunk/contrib/extensions/distribution/it/src/test/java/org/apache/sling/distribution/it/DistributionIntegrationTestBase.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/it/src/test/java/org/apache/sling/distribution/it/DistributionIntegrationTestBase.java?rev=1652356&r1=1652355&r2=1652356&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/it/src/test/java/org/apache/sling/distribution/it/DistributionIntegrationTestBase.java (original)
+++ sling/trunk/contrib/extensions/distribution/it/src/test/java/org/apache/sling/distribution/it/DistributionIntegrationTestBase.java Fri Jan 16 08:03:33 2015
@@ -77,9 +77,6 @@ public abstract class DistributionIntegr
 
             assertExists(authorClient, agentUrl("publish-multiple"));
 
-
-
-
             assertExists(authorClient, authorAgentConfigUrl("publish-reverse"));
 
             String remoteExporterUrl = publish.getServerBaseUrl() + exporterUrl("reverse");

Modified: sling/trunk/contrib/extensions/distribution/it/src/test/java/org/apache/sling/distribution/it/DistributionUtils.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/it/src/test/java/org/apache/sling/distribution/it/DistributionUtils.java?rev=1652356&r1=1652355&r2=1652356&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/it/src/test/java/org/apache/sling/distribution/it/DistributionUtils.java (original)
+++ sling/trunk/contrib/extensions/distribution/it/src/test/java/org/apache/sling/distribution/it/DistributionUtils.java Fri Jan 16 08:03:33 2015
@@ -28,6 +28,10 @@ import org.apache.http.NameValuePair;
 import org.apache.http.client.entity.UrlEncodedFormEntity;
 import org.apache.http.entity.ByteArrayEntity;
 import org.apache.http.message.BasicNameValuePair;
+import org.apache.sling.commons.json.JSONArray;
+import org.apache.sling.commons.json.JSONException;
+import org.apache.sling.commons.json.JSONObject;
+import org.apache.sling.commons.json.JSONTokener;
 import org.apache.sling.distribution.DistributionRequestType;
 import org.apache.sling.testing.tools.http.Request;
 import org.apache.sling.testing.tools.sling.SlingClient;
@@ -45,6 +49,25 @@ public class DistributionUtils {
     private static final String JSON_SELECTOR = ".json";
     private static final String DISTRIBUTION_ROOT_PATH = "/libs/sling/distribution";
 
+    public static JSONObject getResource(SlingInstance slingInstance, String path) throws IOException, JSONException {
+        if (!path.endsWith(JSON_SELECTOR)) {
+            path += JSON_SELECTOR;
+        }
+        Request request = slingInstance.getRequestBuilder().buildGetRequest(path)
+                .withCredentials(slingInstance.getServerUsername(), slingInstance.getServerPassword());
+
+
+        // Get list of tests in JSON format
+        String content = slingInstance.getRequestExecutor().execute(request)
+                .assertStatus(200)
+                .assertContentType("application/json").getContent();
+
+        // Parse JSON response for more precise testing
+        final JSONObject json = new JSONObject(new JSONTokener(content));
+
+        return json;
+    }
+
     public static String assertPostResourceWithParameters(SlingInstance slingInstance,
                                                            int status, String path, String... parameters) throws IOException {
         Request request = slingInstance.getRequestBuilder().buildPostRequest(path);
@@ -193,7 +216,7 @@ public class DistributionUtils {
     }
 
     public static String queueUrl(String agentName) {
-        return agentUrl(agentName) + "/queue";
+        return agentUrl(agentName) + "/queues";
     }
 
     public static String authorAgentConfigUrl(String agentName) {



Mime
View raw message