diff --git a/openidm-config/src/main/java/org/forgerock/openidm/metadata/impl/ProviderTracker.java b/openidm-config/src/main/java/org/forgerock/openidm/metadata/impl/ProviderTracker.java index 7e18d55177..e96b29d4c3 100644 --- a/openidm-config/src/main/java/org/forgerock/openidm/metadata/impl/ProviderTracker.java +++ b/openidm-config/src/main/java/org/forgerock/openidm/metadata/impl/ProviderTracker.java @@ -139,7 +139,7 @@ private ServiceTracker initServiceTracker(Bu } public void addedService(ServiceReference reference, MetaDataProvider service) { - String pid = (String) reference.getProperty(Constants.SERVICE_PID); + String pid = Long.valueOf(reference.getBundle().getBundleId()).toString(); // Instantiate and set the provider callback service.setCallback(new ProviderTrackerCallback(service, pid)); // Add the provider to the listener @@ -147,12 +147,12 @@ public void addedService(ServiceReference reference, MetaDataP } public void removedService(ServiceReference reference, MetaDataProvider service) { - String pid = (String) reference.getProperty(Constants.SERVICE_PID); + String pid = Long.valueOf(reference.getBundle().getBundleId()).toString(); providers.remove(pid); } public void modifiedService(ServiceReference reference, MetaDataProvider service) { - String pid = (String) reference.getProperty(Constants.SERVICE_PID); + String pid = Long.valueOf(reference.getBundle().getBundleId()).toString(); modifiedProvider(pid, service, true); } @@ -177,8 +177,8 @@ public Collection getProviders() { */ private class ProviderTrackerCallback implements MetaDataProviderCallback { - private MetaDataProvider provider = null; - private String originId = null; + private MetaDataProvider provider; + private String originId; /** * Constructor diff --git a/openidm-enhanced-config/src/main/java/org/forgerock/openidm/config/enhanced/JSONEnhancedConfig.java b/openidm-enhanced-config/src/main/java/org/forgerock/openidm/config/enhanced/JSONEnhancedConfig.java index a41357ef97..557dd91842 100644 --- a/openidm-enhanced-config/src/main/java/org/forgerock/openidm/config/enhanced/JSONEnhancedConfig.java +++ b/openidm-enhanced-config/src/main/java/org/forgerock/openidm/config/enhanced/JSONEnhancedConfig.java @@ -17,18 +17,11 @@ package org.forgerock.openidm.config.enhanced; -import static org.forgerock.json.JsonValue.json; -import static org.forgerock.json.JsonValue.object; - -import java.util.Dictionary; -import java.util.Map; - import org.forgerock.json.JsonValue; import org.forgerock.json.JsonValueException; import org.forgerock.openidm.core.PropertyUtil; import org.forgerock.openidm.core.ServerConstants; import org.forgerock.openidm.crypto.CryptoService; -import org.forgerock.openidm.osgi.ServiceUtil; import org.forgerock.openidm.util.JsonUtil; import org.forgerock.util.Reject; import org.osgi.framework.BundleContext; @@ -42,6 +35,13 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.Dictionary; +import java.util.List; +import java.util.Map; + +import static org.forgerock.json.JsonValue.json; +import static org.forgerock.json.JsonValue.object; + /** * A service to handle enhanced configuration, including nested lists and maps * to represent JSON based structures. @@ -93,7 +93,12 @@ public JsonValue getConfigurationAsJson(ComponentContext compContext) Reject.ifNull(compContext); Dictionary dict = compContext.getProperties(); - String servicePid = (String) dict.get(Constants.SERVICE_PID); + final String servicePid; + if(dict.get(Constants.SERVICE_PID) instanceof List) { + servicePid = ((List) dict.get(Constants.SERVICE_PID)).get(0); + } else { + servicePid = (String) dict.get(Constants.SERVICE_PID); + } return getConfiguration(dict, compContext.getBundleContext(), servicePid); } diff --git a/openidm-infoservice/src/main/java/org/forgerock/openidm/info/impl/HealthService.java b/openidm-infoservice/src/main/java/org/forgerock/openidm/info/impl/HealthService.java index d963f2ad4e..a3021bf2c8 100644 --- a/openidm-infoservice/src/main/java/org/forgerock/openidm/info/impl/HealthService.java +++ b/openidm-infoservice/src/main/java/org/forgerock/openidm/info/impl/HealthService.java @@ -16,16 +16,6 @@ */ package org.forgerock.openidm.info.impl; -import static org.forgerock.json.resource.Router.uriTemplate; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; - import org.forgerock.api.models.ApiDescription; import org.forgerock.http.ApiProducer; import org.forgerock.json.JsonValue; @@ -56,7 +46,6 @@ import org.forgerock.openidm.info.health.ReconInfoResourceProvider; import org.forgerock.openidm.osgi.ServiceTrackerListener; import org.forgerock.openidm.osgi.ServiceTrackerNotifier; -import org.forgerock.openidm.osgi.ServiceUtil; import org.forgerock.services.context.Context; import org.forgerock.services.descriptor.Describable; import org.forgerock.util.promise.Promise; @@ -82,6 +71,16 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; + +import static org.forgerock.json.resource.Router.uriTemplate; + /** * A health service determining system state. */ @@ -566,7 +565,12 @@ private void checkState() { if (refs != null && refs.length > 0) { for (String req : requiredServices) { for (ServiceReference ref : refs) { - String pid = (String) ref.getProperty(Constants.SERVICE_PID); + final String pid; + if(ref.getProperty(Constants.SERVICE_PID) instanceof List) { + pid = ((List) ref.getProperty(Constants.SERVICE_PID)).get(0); + } else { + pid = (String) ref.getProperty(Constants.SERVICE_PID); + } if (pid != null && (pid.matches(req)||pid.replace("org.forgerock.","org.openidentityplatform.").matches(req))) { missingServices.remove(req); break; diff --git a/openidm-provisioner-openicf/src/main/java/org/forgerock/openidm/provisioner/openicf/impl/OpenICFProvisionerService.java b/openidm-provisioner-openicf/src/main/java/org/forgerock/openidm/provisioner/openicf/impl/OpenICFProvisionerService.java index 1f4a599bf2..cdd0eeb032 100644 --- a/openidm-provisioner-openicf/src/main/java/org/forgerock/openidm/provisioner/openicf/impl/OpenICFProvisionerService.java +++ b/openidm-provisioner-openicf/src/main/java/org/forgerock/openidm/provisioner/openicf/impl/OpenICFProvisionerService.java @@ -16,24 +16,9 @@ */ package org.forgerock.openidm.provisioner.openicf.impl; -import static org.forgerock.json.JsonValue.json; -import static org.forgerock.json.JsonValue.object; -import static org.forgerock.json.resource.Responses.newActionResponse; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; -import java.util.concurrent.atomic.AtomicReference; - -import org.apache.commons.lang3.StringUtils; import com.google.common.base.Predicate; import com.google.common.collect.FluentIterable; -import org.forgerock.services.context.Context; +import org.apache.commons.lang3.StringUtils; import org.forgerock.json.JsonValue; import org.forgerock.json.JsonValueException; import org.forgerock.json.resource.ActionRequest; @@ -47,8 +32,8 @@ import org.forgerock.json.resource.ReadRequest; import org.forgerock.json.resource.RequestHandler; import org.forgerock.json.resource.Requests; -import org.forgerock.json.resource.ResourceResponse; import org.forgerock.json.resource.ResourceException; +import org.forgerock.json.resource.ResourceResponse; import org.forgerock.json.resource.ServiceUnavailableException; import org.forgerock.json.resource.SingletonResourceProvider; import org.forgerock.json.resource.UpdateRequest; @@ -77,6 +62,7 @@ import org.forgerock.openidm.router.RouteBuilder; import org.forgerock.openidm.router.RouteEntry; import org.forgerock.openidm.router.RouterRegistry; +import org.forgerock.services.context.Context; import org.forgerock.util.promise.Promise; import org.identityconnectors.common.security.GuardedString; import org.identityconnectors.framework.api.APIConfiguration; @@ -98,7 +84,6 @@ import org.identityconnectors.framework.common.objects.SyncToken; import org.identityconnectors.framework.common.serializer.SerializerUtil; import org.identityconnectors.framework.impl.api.local.LocalConnectorFacadeImpl; -import org.osgi.framework.Constants; import org.osgi.service.component.ComponentContext; import org.osgi.service.component.ComponentException; import org.osgi.service.component.annotations.Activate; @@ -112,6 +97,20 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.atomic.AtomicReference; + +import static org.forgerock.json.JsonValue.json; +import static org.forgerock.json.JsonValue.object; +import static org.forgerock.json.resource.Responses.newActionResponse; + /** * The OpenICFProvisionerService is the implementation of * {@link CollectionResourceProvider} interface with objectTypes; /** The Connection Factory */ - @Reference(policy = ReferencePolicy.STATIC) + protected IDMConnectionFactory connectionFactory; + @Reference( + service = IDMConnectionFactory.class, + unbind = "unbindConnectionFactory", + policy = ReferencePolicy.STATIC) void bindConnectionFactory(final IDMConnectionFactory connectionFactory) { this.connectionFactory = connectionFactory; // update activityLogger to use the "real" activity logger on the router @@ -214,6 +217,12 @@ protected void activate(ComponentContext context) { try { factoryPid = (String)context.getProperties().get("config.factory-pid"); jsonConfiguration = enhancedConfig.getConfigurationAsJson(context); + + if(!jsonConfiguration.isDefined("name")) { + logger.info("OpenICF Provisioner Service config is not defined"); + return; + } + systemIdentifier = new SimpleSystemIdentifier(jsonConfiguration); if (!jsonConfiguration.get("enabled").defaultTo(true).asBoolean()) { diff --git a/openidm-provisioner/src/main/java/org/forgerock/openidm/provisioner/impl/SystemObjectSetService.java b/openidm-provisioner/src/main/java/org/forgerock/openidm/provisioner/impl/SystemObjectSetService.java index 87a394922d..882b5818f2 100644 --- a/openidm-provisioner/src/main/java/org/forgerock/openidm/provisioner/impl/SystemObjectSetService.java +++ b/openidm-provisioner/src/main/java/org/forgerock/openidm/provisioner/impl/SystemObjectSetService.java @@ -168,7 +168,7 @@ boolean isLiveSync() { } } - private Map provisionerServices = new HashMap(); + private final Map provisionerServices = new HashMap<>(); @SuppressWarnings("rawtypes") @Reference( @@ -198,7 +198,7 @@ protected void bindConnectionFactory(IDMConnectionFactory connectionFactory) { this.connectionFactory = connectionFactory; } - private Map connectorConfigurationHelpers = new HashMap(); + private Map connectorConfigurationHelpers = new HashMap<>(); @Reference( service = ConnectorConfigurationHelper.class,