sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tma...@apache.org
Subject svn commit: r1802937 - /sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/component/impl/DefaultDistributionComponentProvider.java
Date Tue, 25 Jul 2017 13:26:35 GMT
Author: tmaret
Date: Tue Jul 25 13:26:35 2017
New Revision: 1802937

URL: http://svn.apache.org/viewvc?rev=1802937&view=rev
Log:
SLING-7020 - DefaultDistributionComponentProvider is causing an NPE when agents are listed

* Add mapping for missing component kinds (DistributionRequestAuthorizationStrategy, DistributionTrigger)

Modified:
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/component/impl/DefaultDistributionComponentProvider.java

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/component/impl/DefaultDistributionComponentProvider.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/component/impl/DefaultDistributionComponentProvider.java?rev=1802937&r1=1802936&r2=1802937&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/component/impl/DefaultDistributionComponentProvider.java
(original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/component/impl/DefaultDistributionComponentProvider.java
Tue Jul 25 13:26:35 2017
@@ -32,12 +32,14 @@ import org.apache.felix.scr.annotations.
 import org.apache.felix.scr.annotations.Service;
 import org.apache.sling.commons.osgi.PropertiesUtil;
 import org.apache.sling.distribution.agent.DistributionAgent;
+import org.apache.sling.distribution.agent.impl.DistributionRequestAuthorizationStrategy;
 import org.apache.sling.distribution.packaging.DistributionPackageBuilder;
 import org.apache.sling.distribution.packaging.DistributionPackageExporter;
 import org.apache.sling.distribution.packaging.DistributionPackageImporter;
 import org.apache.sling.distribution.queue.DistributionQueueProvider;
 import org.apache.sling.distribution.queue.impl.DistributionQueueDispatchingStrategy;
 import org.apache.sling.distribution.transport.DistributionTransportSecretProvider;
+import org.apache.sling.distribution.trigger.DistributionTrigger;
 
 /**
  * {@link DistributionComponentProvider} OSGi service.
@@ -51,6 +53,8 @@ import org.apache.sling.distribution.tra
         @Reference(name = "distributionQueueProvider", referenceInterface = DistributionQueueProvider.class,
cardinality = ReferenceCardinality.OPTIONAL_MULTIPLE, policy = ReferencePolicy.DYNAMIC),
         @Reference(name = "distributionQueueDistributionStrategy", referenceInterface = DistributionQueueDispatchingStrategy.class,
cardinality = ReferenceCardinality.OPTIONAL_MULTIPLE, policy = ReferencePolicy.DYNAMIC),
         @Reference(name = "distributionTransportSecretProvider", referenceInterface = DistributionTransportSecretProvider.class,
cardinality = ReferenceCardinality.OPTIONAL_MULTIPLE, policy = ReferencePolicy.DYNAMIC),
+        @Reference(name = "distributionTrigger", referenceInterface = DistributionTrigger.class,
cardinality = ReferenceCardinality.OPTIONAL_MULTIPLE, policy = ReferencePolicy.DYNAMIC),
+        @Reference(name = "distributionRequestAuthorizationStrategy", referenceInterface
= DistributionRequestAuthorizationStrategy.class, cardinality = ReferenceCardinality.OPTIONAL_MULTIPLE,
policy = ReferencePolicy.DYNAMIC),
         @Reference(name = "distributionPackageBuilder", referenceInterface = DistributionPackageBuilder.class,
cardinality = ReferenceCardinality.OPTIONAL_MULTIPLE, policy = ReferencePolicy.DYNAMIC)
 })
 @Service(DistributionComponentProvider.class)
@@ -72,6 +76,10 @@ public class DefaultDistributionComponen
 
     private final Map<String, DistributionComponent<DistributionPackageBuilder>>
distributionPackageBuilderMap = new ConcurrentHashMap<String, DistributionComponent<DistributionPackageBuilder>>();
 
+    private final Map<String, DistributionComponent<DistributionTrigger>> distributionTriggerMap
= new ConcurrentHashMap<String, DistributionComponent<DistributionTrigger>>();
+
+    private final Map<String, DistributionComponent<DistributionRequestAuthorizationStrategy>>
distributionRequestAuthorizationStrategy = new ConcurrentHashMap<String, DistributionComponent<DistributionRequestAuthorizationStrategy>>();
+
     public DistributionComponent<?> getComponent(DistributionComponentKind kind, String
componentName) {
         Map<String, DistributionComponent<?>> componentMap = getComponentMap(kind.asClass());
         return componentMap.get(componentName);
@@ -114,9 +122,13 @@ public class DefaultDistributionComponen
             return (Map) distributionTransportSecretProviderMap;
         } else if (type.isAssignableFrom(DistributionPackageBuilder.class)) {
             return (Map) distributionPackageBuilderMap;
+        } else if (type.isAssignableFrom(DistributionTrigger.class)) {
+            return (Map) distributionTriggerMap;
+        } else if (type.isAssignableFrom(DistributionRequestAuthorizationStrategy.class))
{
+            return (Map) distributionRequestAuthorizationStrategy;
         }
 
-        return null;
+        throw new IllegalArgumentException(String.format("Components of type: %s are not
supported", type));
     }
 
     // (un)binding methods
@@ -177,6 +189,23 @@ public class DefaultDistributionComponen
         remove(DistributionPackageBuilder.class, distributionPackageBuilder, config);
     }
 
+    public void bindDistributionTrigger(DistributionTrigger distributionTrigger, Map<String,
Object> config) {
+        put(DistributionTrigger.class, distributionTrigger, config);
+    }
+
+    public void unbindDistributionTrigger(DistributionTrigger distributionTrigger, Map<String,
Object> config) {
+        remove(DistributionTrigger.class, distributionTrigger, config);
+    }
+
+    public void bindDistributionRequestAuthorizationStrategy(DistributionRequestAuthorizationStrategy
distributionRequestAuthorizationStrategy, Map<String, Object> config) {
+        put(DistributionRequestAuthorizationStrategy.class, distributionRequestAuthorizationStrategy,
config);
+    }
+
+    public void unbindDistributionRequestAuthorizationStrategy(DistributionRequestAuthorizationStrategy
distributionRequestAuthorizationStrategy, Map<String, Object> config) {
+        remove(DistributionRequestAuthorizationStrategy.class, distributionRequestAuthorizationStrategy,
config);
+    }
+
+
     // internals
 
     private <ComponentType> void put(Class<ComponentType> typeClass, ComponentType
service, Map<String, Object> config) {



Mime
View raw message