sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mpet...@apache.org
Subject svn commit: r1662421 - in /sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution: agent/impl/ component/impl/ packaging/impl/exporter/ packaging/impl/importer/
Date Thu, 26 Feb 2015 11:07:55 GMT
Author: mpetria
Date: Thu Feb 26 11:07:54 2015
New Revision: 1662421

URL: http://svn.apache.org/r1662421
Log:
SLING-4459: cleaning empty entries in distribution config string arrays

Modified:
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/ForwardDistributionAgentFactory.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/QueueDistributionAgentFactory.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/ReverseDistributionAgentFactory.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/SyncDistributionAgentFactory.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/component/impl/SettingsUtils.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/impl/exporter/RemoteDistributionPackageExporterFactory.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/impl/importer/AdvancedRemoteDistributionPackageImporter.java

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/ForwardDistributionAgentFactory.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/ForwardDistributionAgentFactory.java?rev=1662421&r1=1662420&r2=1662421&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/ForwardDistributionAgentFactory.java
(original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/ForwardDistributionAgentFactory.java
Thu Feb 26 11:07:54 2015
@@ -180,6 +180,7 @@ public class ForwardDistributionAgentFac
     protected SimpleDistributionAgent createAgent(String agentName, BundleContext context,
Map<String, Object> config, DefaultDistributionLog distributionLog) {
         String serviceName = PropertiesUtil.toString(config.get(SERVICE_NAME), null);
         String[] allowedRoots = PropertiesUtil.toStringArray(config.get(ALLOWED_ROOTS), null);
+        allowedRoots = SettingsUtils.removeEmptyEntries(allowedRoots);
 
         boolean queueProcessingEnabled = PropertiesUtil.toBoolean(config.get(QUEUE_PROCESSING_ENABLED),
true);
 

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/QueueDistributionAgentFactory.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/QueueDistributionAgentFactory.java?rev=1662421&r1=1662420&r2=1662421&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/QueueDistributionAgentFactory.java
(original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/QueueDistributionAgentFactory.java
Thu Feb 26 11:07:54 2015
@@ -32,6 +32,7 @@ import org.apache.sling.api.resource.Res
 import org.apache.sling.commons.osgi.PropertiesUtil;
 import org.apache.sling.distribution.DistributionRequestType;
 import org.apache.sling.distribution.component.impl.DistributionComponentConstants;
+import org.apache.sling.distribution.component.impl.SettingsUtils;
 import org.apache.sling.distribution.event.impl.DistributionEventFactory;
 import org.apache.sling.distribution.log.impl.DefaultDistributionLog;
 import org.apache.sling.distribution.packaging.DistributionPackageExporter;
@@ -151,6 +152,8 @@ public class QueueDistributionAgentFacto
 
         String serviceName = PropertiesUtil.toString(config.get(SERVICE_NAME), null);
         String[] allowedRoots = PropertiesUtil.toStringArray(config.get(ALLOWED_ROOTS), null);
+        allowedRoots = SettingsUtils.removeEmptyEntries(allowedRoots);
+
         DistributionQueueProvider queueProvider =  new JobHandlingDistributionQueueProvider(agentName,
jobManager, context);
         DistributionQueueDispatchingStrategy dispatchingStrategy = new SingleQueueDispatchingStrategy();
         DistributionPackageExporter packageExporter = new LocalDistributionPackageExporter(packageBuilder);

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/ReverseDistributionAgentFactory.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/ReverseDistributionAgentFactory.java?rev=1662421&r1=1662420&r2=1662421&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/ReverseDistributionAgentFactory.java
(original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/ReverseDistributionAgentFactory.java
Thu Feb 26 11:07:54 2015
@@ -32,6 +32,7 @@ import org.apache.sling.api.resource.Res
 import org.apache.sling.commons.osgi.PropertiesUtil;
 import org.apache.sling.distribution.DistributionRequestType;
 import org.apache.sling.distribution.component.impl.DistributionComponentConstants;
+import org.apache.sling.distribution.component.impl.SettingsUtils;
 import org.apache.sling.distribution.event.impl.DistributionEventFactory;
 import org.apache.sling.distribution.log.impl.DefaultDistributionLog;
 import org.apache.sling.distribution.packaging.DistributionPackageExporter;
@@ -176,6 +177,8 @@ public class ReverseDistributionAgentFac
 
 
         String[] exporterEndpoints = PropertiesUtil.toStringArray(config.get(EXPORTER_ENDPOINTS),
new String[0]);
+        exporterEndpoints = SettingsUtils.removeEmptyEntries(exporterEndpoints);
+
 
         int pollItems = PropertiesUtil.toInteger(config.get(PULL_ITEMS), Integer.MAX_VALUE);
 

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/SyncDistributionAgentFactory.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/SyncDistributionAgentFactory.java?rev=1662421&r1=1662420&r2=1662421&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/SyncDistributionAgentFactory.java
(original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/SyncDistributionAgentFactory.java
Thu Feb 26 11:07:54 2015
@@ -188,6 +188,8 @@ public class SyncDistributionAgentFactor
         Object importerEndpointsValue = config.get(IMPORTER_ENDPOINTS);
 
         String[] exporterEndpoints = PropertiesUtil.toStringArray(exporterEndpointsValue,
new String[0]);
+        exporterEndpoints = SettingsUtils.removeEmptyEntries(exporterEndpoints);
+
         Map<String, String> importerEndpointsMap = SettingsUtils.toUriMap(importerEndpointsValue);
 
         boolean useMultipleQueues = PropertiesUtil.toBoolean(config.get(USE_MULTIPLE_QUEUES),
false);

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/component/impl/SettingsUtils.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/component/impl/SettingsUtils.java?rev=1662421&r1=1662420&r2=1662421&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/component/impl/SettingsUtils.java
(original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/component/impl/SettingsUtils.java
Thu Feb 26 11:07:54 2015
@@ -175,8 +175,24 @@ public class SettingsUtils {
 
         if (uriMap.size() == 0) {
             String[] endpoints = PropertiesUtil.toStringArray(obj, new String[0]);
+            endpoints = removeEmptyEntries(endpoints);
             uriMap = toMap(Arrays.asList(endpoints), "endpoint");
         }
         return uriMap;
     }
+
+    public static String[] removeEmptyEntries(String[] array) {
+        if (array == null || array.length == 0) {
+            return array;
+        }
+
+        List<String> result = new ArrayList<String>();
+        for (String string : array) {
+            if (string != null && string.trim().length() > 0) {
+                result.add(string);
+            }
+        }
+
+        return result.toArray(new String[0]);
+    }
 }

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/impl/exporter/RemoteDistributionPackageExporterFactory.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/impl/exporter/RemoteDistributionPackageExporterFactory.java?rev=1662421&r1=1662420&r2=1662421&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/impl/exporter/RemoteDistributionPackageExporterFactory.java
(original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/packaging/impl/exporter/RemoteDistributionPackageExporterFactory.java
Thu Feb 26 11:07:54 2015
@@ -35,6 +35,7 @@ import org.apache.sling.commons.osgi.Pro
 import org.apache.sling.distribution.DistributionRequest;
 import org.apache.sling.distribution.component.impl.DistributionComponentKind;
 import org.apache.sling.distribution.component.impl.DistributionComponentConstants;
+import org.apache.sling.distribution.component.impl.SettingsUtils;
 import org.apache.sling.distribution.log.impl.DefaultDistributionLog;
 import org.apache.sling.distribution.packaging.DistributionPackage;
 import org.apache.sling.distribution.packaging.DistributionPackageExportException;
@@ -111,6 +112,8 @@ public class RemoteDistributionPackageEx
         log.info("activating remote exporter with pb {} and dtsp {}", packageBuilder, transportSecretProvider);
 
         String[] endpoints = PropertiesUtil.toStringArray(config.get(ENDPOINTS), new String[0]);
+        endpoints = SettingsUtils.removeEmptyEntries(endpoints);
+
         String endpointStrategyName = PropertiesUtil.toString(config.get(ENDPOINTS_STRATEGY),
"One");
         int pollItems = PropertiesUtil.toInteger(config.get(PULL_ITEMS), Integer.MAX_VALUE);
 

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=1662421&r1=1662420&r2=1662421&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
Thu Feb 26 11:07:54 2015
@@ -32,6 +32,7 @@ import org.apache.sling.api.resource.Res
 import org.apache.sling.commons.osgi.PropertiesUtil;
 import org.apache.sling.distribution.component.impl.DistributionComponentKind;
 import org.apache.sling.distribution.component.impl.DistributionComponentConstants;
+import org.apache.sling.distribution.component.impl.SettingsUtils;
 import org.apache.sling.distribution.event.impl.DistributionEventFactory;
 import org.apache.sling.distribution.log.impl.DefaultDistributionLog;
 import org.apache.sling.distribution.packaging.DistributionPackage;
@@ -101,6 +102,8 @@ public class AdvancedRemoteDistributionP
     protected void activate(Map<String, ?> config) throws Exception {
 
         String[] endpoints = PropertiesUtil.toStringArray(config.get(ENDPOINTS), new String[0]);
+        endpoints = SettingsUtils.removeEmptyEntries(endpoints);
+
         String endpointStrategyName = PropertiesUtil.toString(config.get(ENDPOINT_STRATEGY),
                 TransportEndpointStrategyType.One.name());
         TransportEndpointStrategyType transportEndpointStrategyType = TransportEndpointStrategyType.valueOf(endpointStrategyName);
@@ -108,6 +111,8 @@ public class AdvancedRemoteDistributionP
 
         boolean useCustomHeaders = PropertiesUtil.toBoolean(config.get(USE_CUSTOM_HEADERS),
false);
         String[] customHeaders = PropertiesUtil.toStringArray(config.get(CUSTOM_HEADERS),
new String[0]);
+        customHeaders = SettingsUtils.removeEmptyEntries(customHeaders);
+
         boolean useCustomBody = PropertiesUtil.toBoolean(config.get(USE_CUSTOM_BODY), false);
         String customBody = PropertiesUtil.toString(config.get(CUSTOM_BODY), "");
 



Mime
View raw message