diff --git a/commons/src/main/java/org/eclipse/kapua/commons/configuration/ResourceBasedServiceConfigurationMetadataProvider.java b/commons/src/main/java/org/eclipse/kapua/commons/configuration/ResourceBasedServiceConfigurationMetadataProvider.java new file mode 100644 index 00000000000..0f26ed91e0a --- /dev/null +++ b/commons/src/main/java/org/eclipse/kapua/commons/configuration/ResourceBasedServiceConfigurationMetadataProvider.java @@ -0,0 +1,47 @@ +/******************************************************************************* + * Copyright (c) 2016, 2022 Eurotech and/or its affiliates and others + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Eurotech - initial API and implementation + *******************************************************************************/ +package org.eclipse.kapua.commons.configuration; + +import java.net.URL; +import java.nio.charset.StandardCharsets; +import java.util.Optional; + +import org.eclipse.kapua.commons.util.ResourceUtils; +import org.eclipse.kapua.commons.util.xml.XmlUtil; +import org.eclipse.kapua.model.config.metatype.KapuaTmetadata; +import org.eclipse.kapua.storage.TxContext; + +public class ResourceBasedServiceConfigurationMetadataProvider implements ServiceConfigurationMetadataProvider { + + private final XmlUtil xmlUtil; + + public ResourceBasedServiceConfigurationMetadataProvider(XmlUtil xmlUtil) { + this.xmlUtil = xmlUtil; + } + + @Override + public Optional fetchMetadata(TxContext txContext, String pid) { + URL url = ResourceUtils.getResource(String.format("META-INF/metatypes/%s.xml", pid)); + + if (url == null) { + return Optional.empty(); + } + + try { + return Optional.ofNullable(xmlUtil.unmarshal(ResourceUtils.openAsReader(url, StandardCharsets.UTF_8), KapuaTmetadata.class)) + .filter(v -> v.getOCD() != null && !v.getOCD().isEmpty()); + } catch (Exception e) { + throw new RuntimeException(e); + } + } +} diff --git a/commons/src/main/java/org/eclipse/kapua/commons/configuration/ResourceLimitedServiceConfigurationManagerImpl.java b/commons/src/main/java/org/eclipse/kapua/commons/configuration/ResourceLimitedServiceConfigurationManagerImpl.java index 153eb858d72..a517a73163e 100644 --- a/commons/src/main/java/org/eclipse/kapua/commons/configuration/ResourceLimitedServiceConfigurationManagerImpl.java +++ b/commons/src/main/java/org/eclipse/kapua/commons/configuration/ResourceLimitedServiceConfigurationManagerImpl.java @@ -21,7 +21,6 @@ import org.eclipse.kapua.commons.configuration.exception.ServiceConfigurationLimitExceededException; import org.eclipse.kapua.commons.configuration.exception.ServiceConfigurationParentLimitExceededException; import org.eclipse.kapua.commons.security.KapuaSecurityUtils; -import org.eclipse.kapua.commons.util.xml.XmlUtil; import org.eclipse.kapua.model.config.metatype.KapuaTocd; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.account.Account; @@ -45,8 +44,8 @@ public ResourceLimitedServiceConfigurationManagerImpl( RootUserTester rootUserTester, AccountRelativeFinder accountRelativeFinder, UsedEntitiesCounter usedEntitiesCounter, - XmlUtil xmlUtil) { - super(pid, domain, txManager, serviceConfigRepository, rootUserTester, xmlUtil); + ServiceConfigurationMetadataProvider serviceConfigurationMetadataProvider) { + super(pid, domain, txManager, serviceConfigRepository, rootUserTester, serviceConfigurationMetadataProvider); this.accountRelativeFinder = accountRelativeFinder; this.usedEntitiesCounter = usedEntitiesCounter; } diff --git a/commons/src/main/java/org/eclipse/kapua/commons/configuration/ServiceConfigurationManagerImpl.java b/commons/src/main/java/org/eclipse/kapua/commons/configuration/ServiceConfigurationManagerImpl.java index 67b22bec4c1..7dd2137e2c7 100644 --- a/commons/src/main/java/org/eclipse/kapua/commons/configuration/ServiceConfigurationManagerImpl.java +++ b/commons/src/main/java/org/eclipse/kapua/commons/configuration/ServiceConfigurationManagerImpl.java @@ -12,9 +12,6 @@ *******************************************************************************/ package org.eclipse.kapua.commons.configuration; -import java.io.IOException; -import java.net.URL; -import java.nio.charset.StandardCharsets; import java.util.Collections; import java.util.HashMap; import java.util.List; @@ -25,7 +22,6 @@ import java.util.stream.Collectors; import javax.validation.constraints.NotNull; -import javax.xml.bind.JAXBException; import javax.xml.namespace.QName; import org.eclipse.kapua.KapuaEntityNotFoundException; @@ -34,9 +30,7 @@ import org.eclipse.kapua.KapuaIllegalNullArgumentException; import org.eclipse.kapua.commons.security.KapuaSecurityUtils; import org.eclipse.kapua.commons.util.ArgumentValidator; -import org.eclipse.kapua.commons.util.ResourceUtils; import org.eclipse.kapua.commons.util.StringUtil; -import org.eclipse.kapua.commons.util.xml.XmlUtil; import org.eclipse.kapua.model.KapuaEntityAttributes; import org.eclipse.kapua.model.config.metatype.KapuaTad; import org.eclipse.kapua.model.config.metatype.KapuaTmetadata; @@ -46,7 +40,6 @@ import org.eclipse.kapua.service.config.ServiceComponentConfiguration; import org.eclipse.kapua.storage.TxContext; import org.eclipse.kapua.storage.TxManager; -import org.xml.sax.SAXException; public class ServiceConfigurationManagerImpl implements ServiceConfigurationManager { @@ -55,20 +48,20 @@ public class ServiceConfigurationManagerImpl implements ServiceConfigurationMana private final String domain; private final ServiceConfigRepository serviceConfigRepository; private final RootUserTester rootUserTester; - private final XmlUtil xmlUtil; + private final ServiceConfigurationMetadataProvider serviceConfigurationMetadataProvider; public ServiceConfigurationManagerImpl( String pid, String domain, TxManager txManager, ServiceConfigRepository serviceConfigRepository, RootUserTester rootUserTester, - XmlUtil xmlUtil) { + ServiceConfigurationMetadataProvider serviceConfigurationMetadataProvider) { this.pid = pid; this.txManager = txManager; this.domain = domain; this.serviceConfigRepository = serviceConfigRepository; this.rootUserTester = rootUserTester; - this.xmlUtil = xmlUtil; + this.serviceConfigurationMetadataProvider = serviceConfigurationMetadataProvider; } /** @@ -443,7 +436,7 @@ protected Optional doGetConfigMetadata(TxContext txContext, KapuaId s } // Get the Tocd try { - return processMetadata(txContext, readMetadata(pid), scopeId, excludeDisabled); + return processMetadata(txContext, serviceConfigurationMetadataProvider.fetchMetadata(txContext, pid), scopeId, excludeDisabled); } catch (Exception e) { throw KapuaException.internalError(e); } @@ -476,36 +469,15 @@ public Optional extractServiceComponentConfigurat * @return The processed {@link KapuaTocd}. * @since 1.3.0 */ - private Optional processMetadata(TxContext txContext, KapuaTmetadata metadata, KapuaId scopeId, boolean excludeDisabled) { - if (metadata != null && metadata.getOCD() != null && !metadata.getOCD().isEmpty()) { - for (KapuaTocd ocd : metadata.getOCD()) { + private Optional processMetadata(TxContext txContext, Optional metadata, KapuaId scopeId, boolean excludeDisabled) { + return metadata.flatMap(meta -> { + for (KapuaTocd ocd : meta.getOCD()) { if (ocd.getId() != null && ocd.getId().equals(pid) && isServiceEnabled(txContext, scopeId)) { ocd.getAD().removeIf(ad -> excludeDisabled && !isPropertyEnabled(ad, scopeId)); return Optional.of(ocd); } } - } - return Optional.empty(); - } - - /** - * Reads the {@link KapuaTmetadata} for the given {@link KapuaConfigurableService} pid. - * - * @param pid - * The {@link KapuaConfigurableService} pid - * @return The {@link KapuaTmetadata} for the given {@link KapuaConfigurableService} pid. - * @throws Exception - * @since 1.0.0 - */ - //TODO: this must be moved in its own provider, as the logic of "where the metadata comes from" does not belong here - private KapuaTmetadata readMetadata(String pid) throws JAXBException, SAXException, IOException { - URL url = ResourceUtils.getResource(String.format("META-INF/metatypes/%s.xml", pid)); - - if (url == null) { - return null; - } - - return xmlUtil.unmarshal(ResourceUtils.openAsReader(url, StandardCharsets.UTF_8), KapuaTmetadata.class); + return Optional.empty(); + }); } - } \ No newline at end of file diff --git a/commons/src/main/java/org/eclipse/kapua/commons/configuration/ServiceConfigurationMetadataProvider.java b/commons/src/main/java/org/eclipse/kapua/commons/configuration/ServiceConfigurationMetadataProvider.java new file mode 100644 index 00000000000..85d334aa49b --- /dev/null +++ b/commons/src/main/java/org/eclipse/kapua/commons/configuration/ServiceConfigurationMetadataProvider.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * Copyright (c) 2016, 2022 Eurotech and/or its affiliates and others + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Eurotech - initial API and implementation + *******************************************************************************/ +package org.eclipse.kapua.commons.configuration; + +import java.util.Optional; + +import org.eclipse.kapua.model.config.metatype.KapuaTmetadata; +import org.eclipse.kapua.model.config.metatype.KapuaTocd; +import org.eclipse.kapua.service.config.KapuaConfigurableService; +import org.eclipse.kapua.storage.TxContext; + +public interface ServiceConfigurationMetadataProvider { + + /** + * Reads the {@link KapuaTmetadata} for the given {@link KapuaConfigurableService} pid. If no metadata can be found, just return Optional.empty() Same if the metadata is empty (containing no + * {@link KapuaTocd}s) + * + * @param txContext + * the transaction context (can be ignored if the data source is not transactional) + * @param pid + * The {@link KapuaConfigurableService} pid + * @return The {@link KapuaTmetadata} for the given {@link KapuaConfigurableService} pid. + * @since 1.0.0 + */ + Optional fetchMetadata(TxContext txContext, String pid); +} diff --git a/service/account/internal/src/main/java/org/eclipse/kapua/service/account/internal/AccountServiceConfigurationManagerModule.java b/service/account/internal/src/main/java/org/eclipse/kapua/service/account/internal/AccountServiceConfigurationManagerModule.java index 3ff53967f3f..871e0ffb6b9 100644 --- a/service/account/internal/src/main/java/org/eclipse/kapua/service/account/internal/AccountServiceConfigurationManagerModule.java +++ b/service/account/internal/src/main/java/org/eclipse/kapua/service/account/internal/AccountServiceConfigurationManagerModule.java @@ -16,6 +16,7 @@ import org.eclipse.kapua.commons.configuration.AccountRelativeFinder; import org.eclipse.kapua.commons.configuration.CachingServiceConfigRepository; +import org.eclipse.kapua.commons.configuration.ResourceBasedServiceConfigurationMetadataProvider; import org.eclipse.kapua.commons.configuration.ResourceLimitedServiceConfigurationManagerImpl; import org.eclipse.kapua.commons.configuration.RootUserTester; import org.eclipse.kapua.commons.configuration.ServiceConfigImplJpaRepository; @@ -75,7 +76,7 @@ ServiceConfigurationManager accountServiceConfigurationManager( new UsedEntitiesCounterImpl( factory, accountRepository), - xmlUtil + new ResourceBasedServiceConfigurationMetadataProvider(xmlUtil) )); } } diff --git a/service/account/test/src/test/java/org/eclipse/kapua/service/account/test/AccountLocatorConfiguration.java b/service/account/test/src/test/java/org/eclipse/kapua/service/account/test/AccountLocatorConfiguration.java index 708cf172963..ae892f2e608 100644 --- a/service/account/test/src/test/java/org/eclipse/kapua/service/account/test/AccountLocatorConfiguration.java +++ b/service/account/test/src/test/java/org/eclipse/kapua/service/account/test/AccountLocatorConfiguration.java @@ -14,6 +14,7 @@ import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.commons.configuration.AccountRelativeFinder; +import org.eclipse.kapua.commons.configuration.ResourceBasedServiceConfigurationMetadataProvider; import org.eclipse.kapua.commons.configuration.ResourceLimitedServiceConfigurationManagerImpl; import org.eclipse.kapua.commons.configuration.RootUserTester; import org.eclipse.kapua.commons.configuration.ServiceConfigImplJpaRepository; @@ -136,7 +137,7 @@ protected void configure() { new UsedEntitiesCounterImpl( accountFactory, accountRepository), - new XmlUtil(new TestJAXBContextProvider()) + new ResourceBasedServiceConfigurationMetadataProvider(new XmlUtil(new TestJAXBContextProvider())) ), new EventStorerImpl(new EventStoreRecordImplJpaRepository(jpaRepoConfig)), accountMapper)); diff --git a/service/datastore/internal/src/main/java/org/eclipse/kapua/service/datastore/internal/MessageStoreServiceConfigurationManagerModule.java b/service/datastore/internal/src/main/java/org/eclipse/kapua/service/datastore/internal/MessageStoreServiceConfigurationManagerModule.java index d0103ddf101..2433594ddfa 100644 --- a/service/datastore/internal/src/main/java/org/eclipse/kapua/service/datastore/internal/MessageStoreServiceConfigurationManagerModule.java +++ b/service/datastore/internal/src/main/java/org/eclipse/kapua/service/datastore/internal/MessageStoreServiceConfigurationManagerModule.java @@ -15,6 +15,7 @@ import javax.inject.Singleton; import org.eclipse.kapua.commons.configuration.CachingServiceConfigRepository; +import org.eclipse.kapua.commons.configuration.ResourceBasedServiceConfigurationMetadataProvider; import org.eclipse.kapua.commons.configuration.RootUserTester; import org.eclipse.kapua.commons.configuration.ServiceConfigImplJpaRepository; import org.eclipse.kapua.commons.configuration.ServiceConfigurationManager; @@ -68,7 +69,7 @@ ServiceConfigurationManager messageStoreServiceConfigurationManager( entityCacheFactory.createCache("AbstractKapuaConfigurableServiceCacheId") ), rootUserTester, - xmlUtil + new ResourceBasedServiceConfigurationMetadataProvider(xmlUtil) ) { @Override diff --git a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/DeviceConnectionServiceConfigurationManagerModule.java b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/DeviceConnectionServiceConfigurationManagerModule.java index cd4df0fb648..6ba9b379af9 100644 --- a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/DeviceConnectionServiceConfigurationManagerModule.java +++ b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/DeviceConnectionServiceConfigurationManagerModule.java @@ -18,6 +18,7 @@ import javax.inject.Singleton; import org.eclipse.kapua.commons.configuration.CachingServiceConfigRepository; +import org.eclipse.kapua.commons.configuration.ResourceBasedServiceConfigurationMetadataProvider; import org.eclipse.kapua.commons.configuration.RootUserTester; import org.eclipse.kapua.commons.configuration.ServiceConfigImplJpaRepository; import org.eclipse.kapua.commons.configuration.ServiceConfigurationManager; @@ -68,7 +69,7 @@ ServiceConfigurationManager deviceConnectionServiceConfigurationManager( rootUserTester, availableDeviceConnectionAdapters, kapuaDeviceRegistrySettings, - xmlUtil) + new ResourceBasedServiceConfigurationMetadataProvider(xmlUtil)) ); } } diff --git a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/DeviceRegistryServiceConfigurationManagerModule.java b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/DeviceRegistryServiceConfigurationManagerModule.java index 93b2ed9fdd1..df5b64b39bc 100644 --- a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/DeviceRegistryServiceConfigurationManagerModule.java +++ b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/DeviceRegistryServiceConfigurationManagerModule.java @@ -17,6 +17,7 @@ import org.eclipse.kapua.commons.configuration.AccountRelativeFinder; import org.eclipse.kapua.commons.configuration.CachingServiceConfigRepository; +import org.eclipse.kapua.commons.configuration.ResourceBasedServiceConfigurationMetadataProvider; import org.eclipse.kapua.commons.configuration.ResourceLimitedServiceConfigurationManagerImpl; import org.eclipse.kapua.commons.configuration.RootUserTester; import org.eclipse.kapua.commons.configuration.ServiceConfigImplJpaRepository; @@ -73,7 +74,7 @@ protected ServiceConfigurationManager deviceRegistryServiceConfigurationManager( new UsedEntitiesCounterImpl( factory, deviceRepository), - xmlUtil + new ResourceBasedServiceConfigurationMetadataProvider(xmlUtil) )); } } diff --git a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/internal/DeviceConnectionServiceConfigurationManager.java b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/internal/DeviceConnectionServiceConfigurationManager.java index 20e021f1ffc..41ab782f825 100644 --- a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/internal/DeviceConnectionServiceConfigurationManager.java +++ b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/internal/DeviceConnectionServiceConfigurationManager.java @@ -22,8 +22,8 @@ import org.eclipse.kapua.commons.configuration.ServiceConfigRepository; import org.eclipse.kapua.commons.configuration.ServiceConfigurationManager; import org.eclipse.kapua.commons.configuration.ServiceConfigurationManagerImpl; +import org.eclipse.kapua.commons.configuration.ServiceConfigurationMetadataProvider; import org.eclipse.kapua.commons.model.domains.Domains; -import org.eclipse.kapua.commons.util.xml.XmlUtil; import org.eclipse.kapua.model.config.metatype.KapuaTad; import org.eclipse.kapua.model.config.metatype.KapuaTocd; import org.eclipse.kapua.model.config.metatype.KapuaToption; @@ -64,8 +64,8 @@ public DeviceConnectionServiceConfigurationManager( RootUserTester rootUserTester, Map availableDeviceConnectionAdapters, KapuaDeviceRegistrySettings kapuaDeviceRegistrySettings, - XmlUtil xmlUtil) { - super(DeviceConnectionService.class.getName(), Domains.DEVICE_CONNECTION, txManager, serviceConfigRepository, rootUserTester, xmlUtil); + ServiceConfigurationMetadataProvider serviceConfigurationMetadataProvider) { + super(DeviceConnectionService.class.getName(), Domains.DEVICE_CONNECTION, txManager, serviceConfigRepository, rootUserTester, serviceConfigurationMetadataProvider); this.availableDeviceConnectionAdapters = availableDeviceConnectionAdapters; this.deviceRegistrySettings = kapuaDeviceRegistrySettings; diff --git a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/internal/JobServiceConfigurationManagerModule.java b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/internal/JobServiceConfigurationManagerModule.java index dfc3bb8cfc5..9c81df96897 100644 --- a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/internal/JobServiceConfigurationManagerModule.java +++ b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/internal/JobServiceConfigurationManagerModule.java @@ -17,6 +17,7 @@ import org.eclipse.kapua.commons.configuration.AccountRelativeFinder; import org.eclipse.kapua.commons.configuration.CachingServiceConfigRepository; +import org.eclipse.kapua.commons.configuration.ResourceBasedServiceConfigurationMetadataProvider; import org.eclipse.kapua.commons.configuration.ResourceLimitedServiceConfigurationManagerImpl; import org.eclipse.kapua.commons.configuration.RootUserTester; import org.eclipse.kapua.commons.configuration.ServiceConfigImplJpaRepository; @@ -78,7 +79,7 @@ public ServiceConfigurationManager jobServiceConfigurationManager( factory, jobRepository ), - xmlUtil)); + new ResourceBasedServiceConfigurationMetadataProvider(xmlUtil))); } } diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/shiro/CredentialServiceConfigurationManagerImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/shiro/CredentialServiceConfigurationManagerImpl.java index 32975e59e3c..dd2316ce1f3 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/shiro/CredentialServiceConfigurationManagerImpl.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/shiro/CredentialServiceConfigurationManagerImpl.java @@ -21,8 +21,8 @@ import org.eclipse.kapua.commons.configuration.ServiceConfigRepository; import org.eclipse.kapua.commons.configuration.ServiceConfigurationManager; import org.eclipse.kapua.commons.configuration.ServiceConfigurationManagerImpl; +import org.eclipse.kapua.commons.configuration.ServiceConfigurationMetadataProvider; import org.eclipse.kapua.commons.model.domains.Domains; -import org.eclipse.kapua.commons.util.xml.XmlUtil; import org.eclipse.kapua.model.config.metatype.KapuaTocd; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.authentication.credential.CredentialService; @@ -44,13 +44,13 @@ public CredentialServiceConfigurationManagerImpl( SystemPasswordLengthProvider systemPasswordLengthProvider, RootUserTester rootUserTester, KapuaAuthenticationSetting kapuaAuthenticationSetting, - XmlUtil xmlUtil) { + ServiceConfigurationMetadataProvider serviceConfigurationMetadataProvider) { super(CredentialService.class.getName(), Domains.CREDENTIAL, txManager, serviceConfigRepository, rootUserTester, - xmlUtil); + serviceConfigurationMetadataProvider); this.systemPasswordLengthProvider = systemPasswordLengthProvider; } diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/shiro/CredentialServiceConfigurationManagerModule.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/shiro/CredentialServiceConfigurationManagerModule.java index b89c5dd4dc0..54b0577f5f6 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/shiro/CredentialServiceConfigurationManagerModule.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/shiro/CredentialServiceConfigurationManagerModule.java @@ -15,6 +15,7 @@ import javax.inject.Singleton; import org.eclipse.kapua.commons.configuration.CachingServiceConfigRepository; +import org.eclipse.kapua.commons.configuration.ResourceBasedServiceConfigurationMetadataProvider; import org.eclipse.kapua.commons.configuration.RootUserTester; import org.eclipse.kapua.commons.configuration.ServiceConfigImplJpaRepository; import org.eclipse.kapua.commons.configuration.ServiceConfigurationManager; @@ -64,6 +65,6 @@ public ServiceConfigurationManager credentialServiceConfigurationManager( systemPasswordLengthProvider, rootUserTester, kapuaAuthenticationSetting, - xmlUtil)); + new ResourceBasedServiceConfigurationMetadataProvider(xmlUtil))); } } diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/shiro/GroupServiceConfigurationManagerModule.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/shiro/GroupServiceConfigurationManagerModule.java index b72b09abc3b..1c928b8fdf0 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/shiro/GroupServiceConfigurationManagerModule.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/shiro/GroupServiceConfigurationManagerModule.java @@ -16,6 +16,7 @@ import org.eclipse.kapua.commons.configuration.AccountRelativeFinder; import org.eclipse.kapua.commons.configuration.CachingServiceConfigRepository; +import org.eclipse.kapua.commons.configuration.ResourceBasedServiceConfigurationMetadataProvider; import org.eclipse.kapua.commons.configuration.ResourceLimitedServiceConfigurationManagerImpl; import org.eclipse.kapua.commons.configuration.RootUserTester; import org.eclipse.kapua.commons.configuration.ServiceConfigImplJpaRepository; @@ -75,6 +76,6 @@ public ServiceConfigurationManager groupServiceConfigurationManager( new UsedEntitiesCounterImpl( factory, groupRepository - ), xmlUtil)); + ), new ResourceBasedServiceConfigurationMetadataProvider(xmlUtil))); } } diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/shiro/RoleServiceConfigurationManagerModule.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/shiro/RoleServiceConfigurationManagerModule.java index 6aaf443306e..271085d9978 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/shiro/RoleServiceConfigurationManagerModule.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/shiro/RoleServiceConfigurationManagerModule.java @@ -16,6 +16,7 @@ import org.eclipse.kapua.commons.configuration.AccountRelativeFinder; import org.eclipse.kapua.commons.configuration.CachingServiceConfigRepository; +import org.eclipse.kapua.commons.configuration.ResourceBasedServiceConfigurationMetadataProvider; import org.eclipse.kapua.commons.configuration.ResourceLimitedServiceConfigurationManagerImpl; import org.eclipse.kapua.commons.configuration.RootUserTester; import org.eclipse.kapua.commons.configuration.ServiceConfigImplJpaRepository; @@ -76,6 +77,6 @@ public ServiceConfigurationManager roleServiceConfigurationManager( roleFactory, roleRepository ), - xmlUtil)); + new ResourceBasedServiceConfigurationMetadataProvider(xmlUtil))); } } diff --git a/service/security/test/src/test/java/org/eclipse/kapua/service/security/test/SecurityLocatorConfiguration.java b/service/security/test/src/test/java/org/eclipse/kapua/service/security/test/SecurityLocatorConfiguration.java index 4f3015ebed4..7b9a35f2b6c 100644 --- a/service/security/test/src/test/java/org/eclipse/kapua/service/security/test/SecurityLocatorConfiguration.java +++ b/service/security/test/src/test/java/org/eclipse/kapua/service/security/test/SecurityLocatorConfiguration.java @@ -18,6 +18,7 @@ import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.KapuaRuntimeException; import org.eclipse.kapua.commons.configuration.AccountRelativeFinder; +import org.eclipse.kapua.commons.configuration.ResourceBasedServiceConfigurationMetadataProvider; import org.eclipse.kapua.commons.configuration.RootUserTester; import org.eclipse.kapua.commons.configuration.ServiceConfigImplJpaRepository; import org.eclipse.kapua.commons.configuration.ServiceConfigurationManager; @@ -176,7 +177,7 @@ protected void configure() { systemMinimumPasswordLengthProvider, Mockito.mock(RootUserTester.class), new KapuaAuthenticationSetting(), - new XmlUtil(new TestJAXBContextProvider())); + new ResourceBasedServiceConfigurationMetadataProvider(new XmlUtil(new TestJAXBContextProvider()))); final AccountPasswordLengthProviderImpl accountPasswordLengthProvider = new AccountPasswordLengthProviderImpl(systemMinimumPasswordLengthProvider, credentialServiceConfigurationManager); try { diff --git a/service/tag/internal/src/main/java/org/eclipse/kapua/service/tag/internal/TagServiceConfigurationManagerModule.java b/service/tag/internal/src/main/java/org/eclipse/kapua/service/tag/internal/TagServiceConfigurationManagerModule.java index 4c08c3ccfb5..fb36f11d584 100644 --- a/service/tag/internal/src/main/java/org/eclipse/kapua/service/tag/internal/TagServiceConfigurationManagerModule.java +++ b/service/tag/internal/src/main/java/org/eclipse/kapua/service/tag/internal/TagServiceConfigurationManagerModule.java @@ -16,6 +16,7 @@ import org.eclipse.kapua.commons.configuration.AccountRelativeFinder; import org.eclipse.kapua.commons.configuration.CachingServiceConfigRepository; +import org.eclipse.kapua.commons.configuration.ResourceBasedServiceConfigurationMetadataProvider; import org.eclipse.kapua.commons.configuration.ResourceLimitedServiceConfigurationManagerImpl; import org.eclipse.kapua.commons.configuration.RootUserTester; import org.eclipse.kapua.commons.configuration.ServiceConfigImplJpaRepository; @@ -75,6 +76,6 @@ ServiceConfigurationManager tagServiceConfigurationManager( factory, tagRepository ), - xmlUtil)); + new ResourceBasedServiceConfigurationMetadataProvider(xmlUtil))); } } diff --git a/service/user/internal/src/main/java/org/eclipse/kapua/service/user/internal/UserServiceConfigurationManagerModule.java b/service/user/internal/src/main/java/org/eclipse/kapua/service/user/internal/UserServiceConfigurationManagerModule.java index ec6f2137af6..b64ed24b26b 100644 --- a/service/user/internal/src/main/java/org/eclipse/kapua/service/user/internal/UserServiceConfigurationManagerModule.java +++ b/service/user/internal/src/main/java/org/eclipse/kapua/service/user/internal/UserServiceConfigurationManagerModule.java @@ -16,6 +16,7 @@ import org.eclipse.kapua.commons.configuration.AccountRelativeFinder; import org.eclipse.kapua.commons.configuration.CachingServiceConfigRepository; +import org.eclipse.kapua.commons.configuration.ResourceBasedServiceConfigurationMetadataProvider; import org.eclipse.kapua.commons.configuration.ResourceLimitedServiceConfigurationManagerImpl; import org.eclipse.kapua.commons.configuration.RootUserTester; import org.eclipse.kapua.commons.configuration.ServiceConfigImplJpaRepository; @@ -75,6 +76,6 @@ ServiceConfigurationManager userServiceConfigurationManager( userFactory, userRepository ), - xmlUtil)); + new ResourceBasedServiceConfigurationMetadataProvider(xmlUtil))); } } diff --git a/service/user/test/src/test/java/org/eclipse/kapua/service/user/test/UserLocatorConfiguration.java b/service/user/test/src/test/java/org/eclipse/kapua/service/user/test/UserLocatorConfiguration.java index cba84829a6e..2e5aa40ea45 100644 --- a/service/user/test/src/test/java/org/eclipse/kapua/service/user/test/UserLocatorConfiguration.java +++ b/service/user/test/src/test/java/org/eclipse/kapua/service/user/test/UserLocatorConfiguration.java @@ -14,6 +14,7 @@ import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.commons.configuration.AccountRelativeFinder; +import org.eclipse.kapua.commons.configuration.ResourceBasedServiceConfigurationMetadataProvider; import org.eclipse.kapua.commons.configuration.ResourceLimitedServiceConfigurationManagerImpl; import org.eclipse.kapua.commons.configuration.RootUserTester; import org.eclipse.kapua.commons.configuration.ServiceConfigImplJpaRepository; @@ -130,7 +131,7 @@ protected void configure() { new UsedEntitiesCounterImpl( userFactory, userRepository), - new XmlUtil(new TestJAXBContextProvider()) + new ResourceBasedServiceConfigurationMetadataProvider(new XmlUtil(new TestJAXBContextProvider())) ); bind(UserService.class).toInstance( new UserServiceImpl(