From e13bc0d3b3f0942c4e7047c65c2ebea9da48b2f6 Mon Sep 17 00:00:00 2001 From: dseurotech Date: Mon, 13 Jan 2025 12:17:40 +0100 Subject: [PATCH 1/4] :boom: KapuaListResult is now concrete, as are all subclasses (needed only to provide xml annotations), avoiding the split between interfaces and implementations Signed-off-by: dseurotech --- ...puaConfigurableResourceLimitedService.java | 137 +++++++++------ .../AbstractKapuaConfigurableService.java | 4 +- .../ServiceConfigImplJpaRepository.java | 2 +- .../ServiceConfigListResult.java | 6 +- .../ServiceConfigListResultImpl.java | 26 --- .../UsedEntitiesCounterImpl.java | 4 +- .../model/query/KapuaListResultImpl.java | 134 --------------- .../event/store/api/EventStoreFactory.java | 2 +- .../store/api/EventStoreRecordListResult.java | 7 +- .../store/api/EventStoreXmlRegistry.java | 13 +- .../store/internal/EventStoreFactoryImpl.java | 10 +- .../EventStoreRecordImplJpaRepository.java | 4 +- .../EventStoreRecordListResultImpl.java | 27 --- .../service/internal/cache/EntityCache.java | 44 +++-- .../misc/CollisionEntityJpaRepository.java | 4 +- ...ImplTest.java => KapuaListResultTest.java} | 51 +++--- .../internal/EventStoreFactoryImplTest.java | 26 +-- .../util/GwtKapuaDeviceModelConverter.java | 47 +++-- .../job/servlet/JobTargetExporterServlet.java | 16 +- .../MfaOptionMigratorJpaRepository.java | 7 +- .../MfaOptionMigratorListResultImpl.java | 25 --- .../job/JobStepMigratorJpaRepository.java | 6 +- .../job/JobStepMigratorListResultImpl.java | 25 --- .../queue/QueuedJobExecutionFactory.java | 2 +- .../queue/QueuedJobExecutionListResult.java | 4 +- .../queue/QueuedJobExecutionXmlRegistry.java | 13 +- .../jbatch/QueuedJobExecutionFactoryImpl.java | 10 +- .../QueuedJobExecutionImplJpaRepository.java | 3 +- .../QueuedJobExecutionListResultImpl.java | 26 --- .../misc/RolePermissionFactoryTest.java | 12 +- .../v1/resources/DeviceManagementAssets.java | 86 ++++++---- .../kapua/service/account/AccountFactory.java | 8 +- .../service/account/AccountListResult.java | 11 +- .../account/xml/AccountXmlRegistry.java | 15 +- .../account/internal/AccountFactoryImpl.java | 10 +- .../internal/AccountImplJpaRepository.java | 8 +- .../internal/AccountListResultImpl.java | 27 --- .../kapua/model/KapuaEntityFactory.java | 36 ++-- .../kapua/model/query/KapuaListResult.java | 160 +++++++++++++----- .../model/ChannelInfoListResultImpl.java | 22 --- .../management/asset/DeviceAssetFactory.java | 8 - .../asset/DeviceAssetXmlRegistry.java | 14 +- .../device/management/asset/DeviceAssets.java | 29 +++- .../internal/DeviceAssetFactoryImpl.java | 10 +- .../DeviceAssetManagementServiceImpl.java | 13 +- .../asset/internal/DeviceAssetsImpl.java | 45 ----- .../JobDeviceManagementOperationFactory.java | 2 +- ...obDeviceManagementOperationListResult.java | 8 +- ...bDeviceManagementOperationXmlRegistry.java | 8 +- ...bDeviceManagementOperationFactoryImpl.java | 10 +- ...eManagementOperationImplJpaRepository.java | 3 +- ...viceManagementOperationListResultImpl.java | 25 --- .../DeviceManagementOperationFactory.java | 11 +- .../DeviceManagementOperationListResult.java | 8 +- .../DeviceManagementOperationXmlRegistry.java | 8 +- ...anagementOperationNotificationFactory.java | 2 +- ...gementOperationNotificationListResult.java | 8 +- ...ementOperationNotificationXmlRegistry.java | 9 +- .../DeviceManagementOperationFactoryImpl.java | 10 +- ...viceManagementOperationListResultImpl.java | 26 --- ...tOperationRepositoryImplJpaRepository.java | 7 +- ...ementOperationNotificationFactoryImpl.java | 10 +- ...perationNotificationImplJpaRepository.java | 3 +- ...ntOperationNotificationListResultImpl.java | 26 --- .../device/registry/DeviceFactory.java | 17 +- .../device/registry/DeviceListResult.java | 7 +- .../device/registry/DeviceXmlRegistry.java | 14 +- .../connection/DeviceConnectionFactory.java | 2 +- .../DeviceConnectionListResult.java | 6 +- .../DeviceConnectionXmlRegistry.java | 13 +- .../option/DeviceConnectionOptionFactory.java | 2 +- .../DeviceConnectionOptionListResult.java | 6 +- .../DeviceConnectionOptionXmlRegistry.java | 13 +- .../registry/event/DeviceEventFactory.java | 18 +- .../registry/event/DeviceEventListResult.java | 7 +- .../event/DeviceEventXmlRegistry.java | 13 +- .../internal/DeviceConnectionFactoryImpl.java | 10 +- .../DeviceConnectionImplJpaRepository.java | 2 +- .../DeviceConnectionListResultImpl.java | 26 --- .../DeviceConnectionOptionFactoryImpl.java | 10 +- ...viceConnectionOptionImplJpaRepository.java | 3 +- .../DeviceConnectionOptionListResultImpl.java | 27 --- .../internal/DeviceEventFactoryImpl.java | 13 +- .../DeviceEventImplJpaRepository.java | 3 +- .../internal/DeviceEventListResultImpl.java | 27 --- .../registry/internal/DeviceFactoryImpl.java | 10 +- .../internal/DeviceImplJpaRepository.java | 13 +- .../internal/DeviceListResultImpl.java | 27 --- .../device/registry/steps/BrokerSteps.java | 18 +- .../registry/steps/DeviceRegistrySteps.java | 140 +++++++-------- .../service/endpoint/EndpointInfoFactory.java | 5 +- .../endpoint/EndpointInfoListResult.java | 8 +- .../endpoint/EndpointInfoXmlRegistry.java | 13 +- .../internal/EndpointInfoFactoryImpl.java | 10 +- .../EndpointInfoImplJpaRepository.java | 3 +- .../internal/EndpointInfoListResultImpl.java | 26 --- .../eclipse/kapua/service/job/JobFactory.java | 2 +- .../kapua/service/job/JobListResult.java | 6 +- .../kapua/service/job/JobXmlRegistry.java | 13 +- .../job/execution/JobExecutionFactory.java | 2 +- .../job/execution/JobExecutionListResult.java | 5 +- .../execution/JobExecutionXmlRegistry.java | 13 +- .../service/job/step/JobStepFactory.java | 11 +- .../service/job/step/JobStepListResult.java | 7 +- .../service/job/step/JobStepXmlRegistry.java | 13 +- .../definition/JobStepDefinitionFactory.java | 23 ++- .../JobStepDefinitionListResult.java | 7 +- .../JobStepDefinitionXmlRegistry.java | 13 +- .../service/job/targets/JobTargetFactory.java | 2 +- .../job/targets/JobTargetListResult.java | 5 +- .../job/targets/JobTargetXmlRegistry.java | 13 +- .../internal/JobExecutionFactoryImpl.java | 10 +- .../JobExecutionImplJpaRepository.java | 3 +- .../internal/JobExecutionListResultImpl.java | 26 --- .../service/job/internal/JobFactoryImpl.java | 10 +- .../job/internal/JobImplJpaRepository.java | 2 +- .../job/internal/JobListResultImpl.java | 28 --- .../JobStepDefinitionFactoryImpl.java | 6 - .../JobStepDefinitionImplJpaRepository.java | 2 +- .../JobStepDefinitionListResultImpl.java | 29 ---- .../job/step/internal/JobStepFactoryImpl.java | 6 - .../internal/JobStepImplJpaRepository.java | 3 +- .../step/internal/JobStepListResultImpl.java | 28 --- .../internal/JobTargetFactoryImpl.java | 10 +- .../internal/JobTargetImplJpaRepository.java | 2 +- .../internal/JobTargetListResultImpl.java | 26 --- .../job/steps/JobExecutionServiceSteps.java | 41 ++--- .../service/job/steps/JobServiceSteps.java | 29 ++-- .../steps/JobStepDefinitionServiceSteps.java | 27 +-- .../job/steps/JobStepServiceSteps.java | 50 +++--- .../job/steps/JobTargetServiceSteps.java | 83 ++++----- .../scheduler/trigger/TriggerFactory.java | 11 +- .../scheduler/trigger/TriggerListResult.java | 11 +- .../scheduler/trigger/TriggerXmlRegistry.java | 8 +- .../definition/TriggerDefinitionFactory.java | 11 +- .../TriggerDefinitionListResult.java | 10 +- .../TriggerDefinitionXmlRegistry.java | 8 +- .../trigger/fired/FiredTriggerFactory.java | 3 +- .../trigger/fired/FiredTriggerListResult.java | 8 +- .../fired/FiredTriggerXmlRegistry.java | 8 +- .../quartz/TriggerDefinitionFactoryImpl.java | 10 +- .../TriggerDefinitionImplJpaRepository.java | 3 +- .../TriggerDefinitionListResultImpl.java | 28 --- .../fired/quartz/FiredTriggerFactoryImpl.java | 10 +- .../quartz/FiredTriggerImplJpaRepository.java | 3 +- .../quartz/FiredTriggerListResultImpl.java | 25 --- .../trigger/quartz/TriggerFactoryImpl.java | 10 +- .../quartz/TriggerImplJpaRepository.java | 14 +- .../trigger/quartz/TriggerListResultImpl.java | 27 --- .../trigger/quartz/TriggerServiceImpl.java | 36 ++-- .../credential/CredentialFactory.java | 42 +++-- .../credential/CredentialListResult.java | 6 +- .../credential/CredentialXmlRegistry.java | 14 +- .../credential/mfa/MfaOptionFactory.java | 8 +- .../credential/mfa/MfaOptionListResult.java | 10 +- .../credential/mfa/MfaOptionXmlRegistry.java | 14 +- .../credential/mfa/ScratchCodeFactory.java | 22 +-- .../credential/mfa/ScratchCodeListResult.java | 10 +- .../mfa/ScratchCodeXmlRegistry.java | 14 +- .../token/AccessTokenFactory.java | 21 ++- .../token/AccessTokenListResult.java | 5 +- .../access/AccessInfoFactory.java | 2 +- .../access/AccessInfoListResult.java | 6 +- .../access/AccessInfoXmlRegistry.java | 13 +- .../access/AccessPermissionFactory.java | 2 +- .../access/AccessPermissionListResult.java | 6 +- .../access/AccessPermissionXmlRegistry.java | 13 +- .../access/AccessRoleFactory.java | 2 +- .../access/AccessRoleListResult.java | 6 +- .../access/AccessRoleXmlRegistry.java | 13 +- .../authorization/domain/DomainFactory.java | 5 +- .../domain/DomainListResult.java | 4 +- .../authorization/group/GroupFactory.java | 8 +- .../authorization/group/GroupListResult.java | 6 +- .../authorization/group/GroupXmlRegistry.java | 14 +- .../authorization/role/RoleFactory.java | 2 +- .../authorization/role/RoleListResult.java | 6 +- .../role/RolePermissionFactory.java | 2 +- .../role/RolePermissionListResult.java | 6 +- .../role/RolePermissionXmlRegistry.java | 13 +- .../authorization/role/RoleXmlRegistry.java | 14 +- .../certificate/CertificateFactory.java | 14 +- .../certificate/CertificateListResult.java | 10 +- .../service/certificate/CertificateQuery.java | 16 +- .../info/CertificateInfoFactory.java | 3 +- .../info/CertificateInfoListResult.java | 10 +- .../info/xml/CertificateInfoXmlRegistry.java | 9 +- .../xml/CertificateXmlRegistry.java | 9 +- .../internal/CertificateInfoFactoryImpl.java | 10 +- .../CertificateInfoListResultImpl.java | 27 --- .../internal/CertificateInfoServiceImpl.java | 11 +- .../internal/CertificateFactoryImpl.java | 10 +- .../internal/CertificateListResultImpl.java | 27 --- .../internal/CertificateServiceImpl.java | 22 +-- .../mfa/shiro/MfaOptionFactoryImpl.java | 10 +- .../mfa/shiro/MfaOptionImplJpaRepository.java | 3 +- .../mfa/shiro/MfaOptionListResultImpl.java | 25 --- .../mfa/shiro/MfaOptionServiceImpl.java | 26 +-- .../mfa/shiro/ScratchCodeFactoryImpl.java | 10 +- .../shiro/ScratchCodeImplJpaRepository.java | 2 +- .../mfa/shiro/ScratchCodeListResultImpl.java | 25 --- .../shiro/CredentialFactoryImpl.java | 14 +- .../shiro/CredentialImplJpaRepository.java | 5 +- .../shiro/CredentialListResultImpl.java | 28 --- .../token/shiro/AccessTokenFactoryImpl.java | 13 +- .../shiro/AccessTokenImplJpaRepository.java | 7 +- .../shiro/AccessTokenListResultImpl.java | 28 --- .../access/shiro/AccessInfoFactoryImpl.java | 10 +- .../shiro/AccessInfoImplJpaRepository.java | 7 +- .../shiro/AccessInfoListResultImpl.java | 28 --- .../shiro/AccessPermissionFactoryImpl.java | 10 +- .../AccessPermissionImplJpaRepository.java | 21 +-- .../shiro/AccessPermissionListResultImpl.java | 28 --- .../access/shiro/AccessRoleFactoryImpl.java | 10 +- .../shiro/AccessRoleImplJpaRepository.java | 3 +- .../shiro/AccessRoleListResultImpl.java | 28 --- .../domain/shiro/DomainFactoryImpl.java | 10 +- .../domain/shiro/DomainImplJpaRepository.java | 7 +- .../domain/shiro/DomainListResultImpl.java | 27 --- .../group/shiro/GroupFactoryImpl.java | 10 +- .../group/shiro/GroupImplJpaRepository.java | 3 +- .../group/shiro/GroupListResultImpl.java | 27 --- .../role/shiro/RoleFactoryImpl.java | 10 +- .../role/shiro/RoleImplJpaRepository.java | 3 +- .../role/shiro/RoleListResultImpl.java | 28 --- .../role/shiro/RolePermissionFactoryImpl.java | 10 +- .../RolePermissionImplJpaRepository.java | 21 +-- .../shiro/RolePermissionListResultImpl.java | 28 --- .../mfa/shiro/MfaOptionFactoryImplTest.java | 15 +- .../shiro/CredentialFactoryImplTest.java | 27 ++- .../shiro/AccessTokenFactoryImplTest.java | 30 ++-- .../shiro/AccessInfoFactoryImplTest.java | 16 +- .../AccessPermissionFactoryImplTest.java | 9 +- .../shiro/AccessRoleFactoryImplTest.java | 12 +- .../domain/shiro/DomainFactoryImplTest.java | 19 +-- .../group/shiro/GroupFactoryImplTest.java | 15 +- .../role/shiro/RoleFactoryImplTest.java | 14 +- .../steps/AuthorizationServiceSteps.java | 68 ++++---- .../eclipse/kapua/service/tag/TagFactory.java | 8 +- .../kapua/service/tag/TagListResult.java | 10 +- .../kapua/service/tag/TagXmlRegistry.java | 13 +- .../service/tag/internal/TagFactoryImpl.java | 10 +- .../tag/internal/TagImplJpaRepository.java | 7 +- .../tag/internal/TagListResultImpl.java | 27 --- .../kapua/service/user/UserFactory.java | 8 +- .../kapua/service/user/UserListResult.java | 6 +- .../kapua/service/user/UserXmlRegistry.java | 13 +- .../user/internal/UserFactoryImpl.java | 10 +- .../user/internal/UserImplJpaRepository.java | 7 +- .../user/internal/UserListResultImpl.java | 28 --- .../kura/TranslatorAppAssetKapuaKura.java | 20 ++- .../kapua/TranslatorAppAssetKuraKapua.java | 2 +- .../mqtt/MqttResponseTimeoutTimer.java | 15 +- 253 files changed, 1320 insertions(+), 2796 deletions(-) delete mode 100644 commons/src/main/java/org/eclipse/kapua/commons/configuration/ServiceConfigListResultImpl.java delete mode 100644 commons/src/main/java/org/eclipse/kapua/commons/model/query/KapuaListResultImpl.java delete mode 100644 commons/src/main/java/org/eclipse/kapua/commons/service/event/store/internal/EventStoreRecordListResultImpl.java rename commons/src/test/java/org/eclipse/kapua/commons/model/query/{KapuaListResultImplTest.java => KapuaListResultTest.java} (85%) delete mode 100644 extras/encryption-migrator/src/main/java/org/eclipse/kapua/extras/migrator/encryption/authentication/MfaOptionMigratorListResultImpl.java delete mode 100644 extras/encryption-migrator/src/main/java/org/eclipse/kapua/extras/migrator/encryption/job/JobStepMigratorListResultImpl.java delete mode 100644 job-engine/jbatch/src/main/java/org/eclipse/kapua/job/engine/queue/jbatch/QueuedJobExecutionListResultImpl.java delete mode 100644 service/account/internal/src/main/java/org/eclipse/kapua/service/account/internal/AccountListResultImpl.java delete mode 100644 service/device/management/asset/internal/src/main/java/org/eclipse/kapua/service/device/management/asset/internal/DeviceAssetsImpl.java delete mode 100644 service/device/management/job/internal/src/main/java/org/eclipse/kapua/service/device/management/job/internal/JobDeviceManagementOperationListResultImpl.java delete mode 100644 service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/internal/DeviceManagementOperationListResultImpl.java delete mode 100644 service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/internal/ManagementOperationNotificationListResultImpl.java delete mode 100644 service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/internal/DeviceConnectionListResultImpl.java delete mode 100644 service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/internal/DeviceConnectionOptionListResultImpl.java delete mode 100644 service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/event/internal/DeviceEventListResultImpl.java delete mode 100644 service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/internal/DeviceListResultImpl.java delete mode 100644 service/endpoint/internal/src/main/java/org/eclipse/kapua/service/endpoint/internal/EndpointInfoListResultImpl.java delete mode 100644 service/job/internal/src/main/java/org/eclipse/kapua/service/job/execution/internal/JobExecutionListResultImpl.java delete mode 100644 service/job/internal/src/main/java/org/eclipse/kapua/service/job/internal/JobListResultImpl.java delete mode 100644 service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/definition/internal/JobStepDefinitionListResultImpl.java delete mode 100644 service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/internal/JobStepListResultImpl.java delete mode 100644 service/job/internal/src/main/java/org/eclipse/kapua/service/job/targets/internal/JobTargetListResultImpl.java delete mode 100644 service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/definition/quartz/TriggerDefinitionListResultImpl.java delete mode 100644 service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/fired/quartz/FiredTriggerListResultImpl.java delete mode 100644 service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/quartz/TriggerListResultImpl.java delete mode 100644 service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/info/internal/CertificateInfoListResultImpl.java delete mode 100644 service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/internal/CertificateListResultImpl.java delete mode 100644 service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionListResultImpl.java delete mode 100644 service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/ScratchCodeListResultImpl.java delete mode 100644 service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialListResultImpl.java delete mode 100644 service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/token/shiro/AccessTokenListResultImpl.java delete mode 100644 service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoListResultImpl.java delete mode 100644 service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionListResultImpl.java delete mode 100644 service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessRoleListResultImpl.java delete mode 100644 service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/domain/shiro/DomainListResultImpl.java delete mode 100644 service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/group/shiro/GroupListResultImpl.java delete mode 100644 service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RoleListResultImpl.java delete mode 100644 service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RolePermissionListResultImpl.java delete mode 100644 service/tag/internal/src/main/java/org/eclipse/kapua/service/tag/internal/TagListResultImpl.java delete mode 100644 service/user/internal/src/main/java/org/eclipse/kapua/service/user/internal/UserListResultImpl.java diff --git a/commons/src/main/java/org/eclipse/kapua/commons/configuration/AbstractKapuaConfigurableResourceLimitedService.java b/commons/src/main/java/org/eclipse/kapua/commons/configuration/AbstractKapuaConfigurableResourceLimitedService.java index 719a0a0addf..5129b904874 100644 --- a/commons/src/main/java/org/eclipse/kapua/commons/configuration/AbstractKapuaConfigurableResourceLimitedService.java +++ b/commons/src/main/java/org/eclipse/kapua/commons/configuration/AbstractKapuaConfigurableResourceLimitedService.java @@ -12,6 +12,9 @@ *******************************************************************************/ package org.eclipse.kapua.commons.configuration; +import java.util.Map; +import java.util.Optional; + import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.KapuaMaxNumberOfItemsReachedException; import org.eclipse.kapua.commons.configuration.exception.ServiceConfigurationLimitExceededException; @@ -36,9 +39,6 @@ import org.eclipse.kapua.service.authorization.permission.PermissionFactory; import org.eclipse.kapua.service.config.KapuaConfigurableService; -import java.util.Map; -import java.util.Optional; - /** * Base {@code abstract} {@link KapuaConfigurableService} implementation for services that have a max number of entities allowed. *

@@ -48,12 +48,16 @@ *

  • maxNumberChildEntities
  • * * - * @param The {@link KapuaEntity} type. - * @param The {@link KapuaEntityCreator} type. - * @param The {@link KapuaEntityService} type. - * @param The {@link KapuaListResult} type. - * @param The {@link KapuaQuery} type. - * @param The {@link KapuaEntityFactory} type. + * @param + * The {@link KapuaEntity} type. + * @param + * The {@link KapuaEntityCreator} type. + * @param + * The {@link KapuaEntityService} type. + * @param + * The {@link KapuaQuery} type. + * @param + * The {@link KapuaEntityFactory} type. * @since 1.0.0 * @deprecated since 2.0.0, in favour of separate configuration component - see {@link ServiceConfigurationManager} and implementations for more details */ @@ -62,14 +66,12 @@ public abstract class AbstractKapuaConfigurableResourceLimitedService< E extends KapuaEntity, C extends KapuaEntityCreator, S extends KapuaEntityService, - L extends KapuaListResult, Q extends KapuaQuery, - F extends KapuaEntityFactory + F extends KapuaEntityFactory > extends AbstractKapuaConfigurableService implements KapuaEntityService { - //TODO: make final as soon as deprecated constructors are removed private AccountRelativeFinder accountRelativeFinder; private F factory; @@ -79,11 +81,16 @@ public abstract class AbstractKapuaConfigurableResourceLimitedService< /** * Constructor. * - * @param pid The {@link KapuaConfigurableService} id. - * @param domain The {@link Domain} on which check access. - * @param entityManagerFactory The {@link EntityManagerFactory} that handles persistence unit - * @param serviceClass The {@link KapuaService} type. - * @param factoryClass The {@link KapuaEntityFactory} type. + * @param pid + * The {@link KapuaConfigurableService} id. + * @param domain + * The {@link Domain} on which check access. + * @param entityManagerFactory + * The {@link EntityManagerFactory} that handles persistence unit + * @param serviceClass + * The {@link KapuaService} type. + * @param factoryClass + * The {@link KapuaEntityFactory} type. * @deprecated Since 1.2.0. This constructor will be removed in a next release (may be) */ @Deprecated @@ -104,12 +111,18 @@ protected AbstractKapuaConfigurableResourceLimitedService( /** * Constructor. * - * @param pid The {@link KapuaConfigurableService} id. - * @param domain The {@link Domain} on which check access. - * @param entityManagerFactory The {@link EntityManagerFactory} that handles persistence unit - * @param abstractCacheFactory The {@link CacheFactory} that handles caching of the entities + * @param pid + * The {@link KapuaConfigurableService} id. + * @param domain + * The {@link Domain} on which check access. + * @param entityManagerFactory + * The {@link EntityManagerFactory} that handles persistence unit + * @param abstractCacheFactory + * The {@link CacheFactory} that handles caching of the entities * @since 1.2.0 - * @deprecated Since 2.0.0. Please use {@link #AbstractKapuaConfigurableResourceLimitedService(String, Domain, EntityManagerFactory, EntityCacheFactory, KapuaEntityFactory, PermissionFactory, AuthorizationService, AccountRelativeFinder, RootUserTester)} This constructor may be removed in a next release + * @deprecated Since 2.0.0. Please use + * {@link #AbstractKapuaConfigurableResourceLimitedService(String, Domain, EntityManagerFactory, EntityCacheFactory, KapuaEntityFactory, PermissionFactory, AuthorizationService, + * AccountRelativeFinder, RootUserTester)} This constructor may be removed in a next release */ @Deprecated protected AbstractKapuaConfigurableResourceLimitedService( @@ -133,24 +146,32 @@ protected AbstractKapuaConfigurableResourceLimitedService( /** * Constructor. * - * @param pid The {@link KapuaConfigurableService} id. - * @param domain The {@link Domain} on which check access. - * @param entityManagerFactory The {@link EntityManagerFactory} that handles persistence unit - * @param abstractCacheFactory The {@link CacheFactory} that handles caching of the entities - * @param factory The {@link KapuaEntityFactory} instance. - * @param permissionFactory The {@link PermissionFactory} instance. - * @param authorizationService The {@link AuthorizationService} instance. - * @param rootUserTester The {@link RootUserTester} instance. + * @param pid + * The {@link KapuaConfigurableService} id. + * @param domain + * The {@link Domain} on which check access. + * @param entityManagerFactory + * The {@link EntityManagerFactory} that handles persistence unit + * @param abstractCacheFactory + * The {@link CacheFactory} that handles caching of the entities + * @param factory + * The {@link KapuaEntityFactory} instance. + * @param permissionFactory + * The {@link PermissionFactory} instance. + * @param authorizationService + * The {@link AuthorizationService} instance. + * @param rootUserTester + * The {@link RootUserTester} instance. */ protected AbstractKapuaConfigurableResourceLimitedService(String pid, - Domain domain, - EntityManagerFactory entityManagerFactory, - EntityCacheFactory abstractCacheFactory, - F factory, - PermissionFactory permissionFactory, - AuthorizationService authorizationService, - AccountRelativeFinder accountRelativeFinder, - RootUserTester rootUserTester) { + Domain domain, + EntityManagerFactory entityManagerFactory, + EntityCacheFactory abstractCacheFactory, + F factory, + PermissionFactory permissionFactory, + AuthorizationService authorizationService, + AccountRelativeFinder accountRelativeFinder, + RootUserTester rootUserTester) { super(pid, domain, entityManagerFactory, abstractCacheFactory, permissionFactory, authorizationService, rootUserTester); this.factory = factory; this.factoryClass = null; //TODO: not needed for this construction path, remove as soon as the deprecated constructor is removed @@ -180,8 +201,10 @@ protected boolean validateNewConfigValuesCoherence(KapuaTocd ocd, Map * The exclusion of the scope is required when updating a limit for a target account. * - * @param scopeId The scope {@link KapuaId}. - * @param targetScopeId The excluded scope {@link KapuaId}. + * @param scopeId + * The scope {@link KapuaId}. + * @param targetScopeId + * The excluded scope {@link KapuaId}. * @return The number of entities remaining for the given scope * @throws KapuaException * @since 1.0.0 @@ -220,14 +246,16 @@ private long allowedChildEntities(KapuaId scopeId, KapuaId targetScopeId) throws } /** - * Gets the number of remaining allowed entity for the given scope, according to the given {@link KapuaConfigurableService} - * excluding a specific scope when checking resources available. + * Gets the number of remaining allowed entity for the given scope, according to the given {@link KapuaConfigurableService} excluding a specific scope when checking resources available. *

    * The exclusion of the scope is required when updating a limit for a target account. * - * @param scopeId The scope {@link KapuaId}. - * @param targetScopeId The excluded scope {@link KapuaId}. - * @param configuration The configuration to be checked. If not provided will be read from the current service configuration + * @param scopeId + * The scope {@link KapuaId}. + * @param targetScopeId + * The excluded scope {@link KapuaId}. + * @param configuration + * The configuration to be checked. If not provided will be read from the current service configuration * @return The number of entities remaining for the given scope * @throws KapuaException * @since 1.0.0 @@ -263,10 +291,9 @@ private long allowedChildEntities(KapuaId scopeId, KapuaId targetScopeId, Map getConfigValues(KapuaId scopeId, boolean excludeDi ); ServiceConfigListResult result = entityManagerSession.doAction(EntityManagerContainer.create() - .onResultHandler(em -> ServiceDAO.query(em, ServiceConfig.class, ServiceConfigImpl.class, new ServiceConfigListResultImpl(), query)) + .onResultHandler(em -> ServiceDAO.query(em, ServiceConfig.class, ServiceConfigImpl.class, new ServiceConfigListResult(), query)) .onBeforeHandler(() -> (ServiceConfigListResult) PRIVATE_ENTITY_CACHE.getList(scopeId, pid)) .onAfterHandler(entity -> PRIVATE_ENTITY_CACHE.putList(scopeId, pid, entity))); @@ -592,7 +592,7 @@ public void setConfigValues(KapuaId scopeId, KapuaId parentId, Mapcreate(). - onResultHandler(em -> ServiceDAO.query(em, ServiceConfig.class, ServiceConfigImpl.class, new ServiceConfigListResultImpl(), query)) + onResultHandler(em -> ServiceDAO.query(em, ServiceConfig.class, ServiceConfigImpl.class, new ServiceConfigListResult(), query)) ); Properties props = toProperties(values); diff --git a/commons/src/main/java/org/eclipse/kapua/commons/configuration/ServiceConfigImplJpaRepository.java b/commons/src/main/java/org/eclipse/kapua/commons/configuration/ServiceConfigImplJpaRepository.java index 31b63e33cab..438de108ee4 100644 --- a/commons/src/main/java/org/eclipse/kapua/commons/configuration/ServiceConfigImplJpaRepository.java +++ b/commons/src/main/java/org/eclipse/kapua/commons/configuration/ServiceConfigImplJpaRepository.java @@ -22,7 +22,7 @@ public class ServiceConfigImplJpaRepository extends KapuaUpdatableEntityJpaRepository implements ServiceConfigRepository { public ServiceConfigImplJpaRepository(KapuaJpaRepositoryConfiguration jpaRepoConfig) { - super(ServiceConfigImpl.class, ServiceConfig.TYPE, () -> new ServiceConfigListResultImpl(), jpaRepoConfig); + super(ServiceConfigImpl.class, ServiceConfig.TYPE, () -> new ServiceConfigListResult(), jpaRepoConfig); } @Override diff --git a/commons/src/main/java/org/eclipse/kapua/commons/configuration/ServiceConfigListResult.java b/commons/src/main/java/org/eclipse/kapua/commons/configuration/ServiceConfigListResult.java index 5701270b445..22229c46b19 100644 --- a/commons/src/main/java/org/eclipse/kapua/commons/configuration/ServiceConfigListResult.java +++ b/commons/src/main/java/org/eclipse/kapua/commons/configuration/ServiceConfigListResult.java @@ -18,7 +18,9 @@ * Service configuration result list definition. * * @since 1.0 - * */ -public interface ServiceConfigListResult extends KapuaListResult { +public class ServiceConfigListResult extends KapuaListResult { + + private static final long serialVersionUID = -2550359084026132096L; + } diff --git a/commons/src/main/java/org/eclipse/kapua/commons/configuration/ServiceConfigListResultImpl.java b/commons/src/main/java/org/eclipse/kapua/commons/configuration/ServiceConfigListResultImpl.java deleted file mode 100644 index 79136d21865..00000000000 --- a/commons/src/main/java/org/eclipse/kapua/commons/configuration/ServiceConfigListResultImpl.java +++ /dev/null @@ -1,26 +0,0 @@ -/******************************************************************************* - * 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 org.eclipse.kapua.commons.model.query.KapuaListResultImpl; - -/** - * Service configuration result list reference implementation. - * - * @since 1.0 - * - */ -public class ServiceConfigListResultImpl extends KapuaListResultImpl implements ServiceConfigListResult { - - private static final long serialVersionUID = -2550359084026132096L; -} diff --git a/commons/src/main/java/org/eclipse/kapua/commons/configuration/UsedEntitiesCounterImpl.java b/commons/src/main/java/org/eclipse/kapua/commons/configuration/UsedEntitiesCounterImpl.java index 227dccac161..4b0e24d0251 100644 --- a/commons/src/main/java/org/eclipse/kapua/commons/configuration/UsedEntitiesCounterImpl.java +++ b/commons/src/main/java/org/eclipse/kapua/commons/configuration/UsedEntitiesCounterImpl.java @@ -28,14 +28,14 @@ public class UsedEntitiesCounterImpl< C extends KapuaEntityCreator, L extends KapuaListResult, Q extends KapuaQuery, - F extends KapuaEntityFactory + F extends KapuaEntityFactory > implements UsedEntitiesCounter { private final F factory; private final KapuaEntityRepository entityRepository; public UsedEntitiesCounterImpl(F factory, - KapuaEntityRepository entityRepository) { + KapuaEntityRepository entityRepository) { this.factory = factory; this.entityRepository = entityRepository; } diff --git a/commons/src/main/java/org/eclipse/kapua/commons/model/query/KapuaListResultImpl.java b/commons/src/main/java/org/eclipse/kapua/commons/model/query/KapuaListResultImpl.java deleted file mode 100644 index 3ff330435d3..00000000000 --- a/commons/src/main/java/org/eclipse/kapua/commons/model/query/KapuaListResultImpl.java +++ /dev/null @@ -1,134 +0,0 @@ -/******************************************************************************* - * 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.model.query; - -import org.eclipse.kapua.model.KapuaEntity; -import org.eclipse.kapua.model.query.KapuaListResult; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Comparator; -import java.util.List; -import java.util.Map; -import java.util.function.Function; -import java.util.function.Predicate; -import java.util.stream.Collectors; - -/** - * {@link KapuaListResult} implementation. - * - * @param {@link KapuaEntity} type. - * @since 1.0.0 - */ -public class KapuaListResultImpl implements KapuaListResult { - - private static final long serialVersionUID = 8939666089540269261L; - - private ArrayList items; - private boolean limitExceeded; - private Long totalCount; - - /** - * Constructor. - * - * @since 1.0.0 - */ - public KapuaListResultImpl() { - limitExceeded = false; - } - - @Override - public boolean isLimitExceeded() { - return limitExceeded; - } - - @Override - public void setLimitExceeded(boolean limitExceeded) { - this.limitExceeded = limitExceeded; - } - - @Override - public List getItems() { - if (items == null) { - items = new ArrayList<>(); - } - - return items; - } - - @Override - public List getItems(Predicate filter) { - return getItems().stream().filter(filter).collect(Collectors.toList()); - } - - @Override - public Map getItemsAsMap(Function keyMapper) { - return getItems().stream().collect(Collectors.toMap(keyMapper, e -> e)); - } - - @Override - public Map getItemsAsMap(Function keyMapper, Function valueMapper) { - return getItems().stream().collect(Collectors.toMap(keyMapper, valueMapper)); - } - - @Override - public E getItem(int index) { - return getItems().get(index); - } - - @Override - public E getFirstItem() { - return this.isEmpty() ? null : getItem(0); - } - - @Override - public int getSize() { - return getItems().size(); - } - - @Override - public boolean isEmpty() { - return getItems().isEmpty(); - } - - @Override - public void addItems(Collection items) { - getItems().addAll(items); - } - - @Override - public void addItem(E item) { - getItems().add(item); - } - - @Override - public void clearItems() { - getItems().clear(); - } - - @Override - public void sort(Comparator comparator) { - getItems().sort(comparator); - } - - @Override - public Long getTotalCount() { - return totalCount; - } - - @Override - public void setTotalCount(Long totalCount) { - this.totalCount = totalCount; - } - -} diff --git a/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/api/EventStoreFactory.java b/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/api/EventStoreFactory.java index d26edcfbaca..944d14d51db 100644 --- a/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/api/EventStoreFactory.java +++ b/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/api/EventStoreFactory.java @@ -20,6 +20,6 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface EventStoreFactory extends KapuaEntityFactory { +public interface EventStoreFactory extends KapuaEntityFactory { } diff --git a/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/api/EventStoreRecordListResult.java b/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/api/EventStoreRecordListResult.java index 1ca0de04f84..604c3b771ea 100644 --- a/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/api/EventStoreRecordListResult.java +++ b/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/api/EventStoreRecordListResult.java @@ -23,11 +23,12 @@ * KapuaEvent result list definition. * * @since 1.0 - * */ @XmlRootElement(name = "eventStoreRecords") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = EventStoreXmlRegistry.class,factoryMethod = "newEventStoreRecordListResult") -public interface EventStoreRecordListResult extends KapuaListResult { +@XmlType +public class EventStoreRecordListResult extends KapuaListResult { + + private static final long serialVersionUID = -5118004898345748297L; } diff --git a/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/api/EventStoreXmlRegistry.java b/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/api/EventStoreXmlRegistry.java index 39fd356fa6b..0ea0521588e 100644 --- a/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/api/EventStoreXmlRegistry.java +++ b/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/api/EventStoreXmlRegistry.java @@ -12,10 +12,10 @@ *******************************************************************************/ package org.eclipse.kapua.commons.service.event.store.api; -import org.eclipse.kapua.commons.service.event.store.internal.EventStoreFactoryImpl; - import javax.xml.bind.annotation.XmlRegistry; +import org.eclipse.kapua.commons.service.event.store.internal.EventStoreFactoryImpl; + @XmlRegistry public class EventStoreXmlRegistry { @@ -39,15 +39,6 @@ public EventStoreRecordCreator newEventStoreRecordCreator() { return kapuaEventFactory.newCreator(null); } - /** - * Creates a new kapuaEvent list result instance - * - * @return - */ - public EventStoreRecordListResult newEventStoreRecordListResult() { - return kapuaEventFactory.newListResult(); - } - public EventStoreRecordQuery newQuery() { return kapuaEventFactory.newQuery(null); } diff --git a/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/internal/EventStoreFactoryImpl.java b/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/internal/EventStoreFactoryImpl.java index e5622dfc59c..c6b25def06f 100644 --- a/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/internal/EventStoreFactoryImpl.java +++ b/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/internal/EventStoreFactoryImpl.java @@ -12,16 +12,15 @@ *******************************************************************************/ package org.eclipse.kapua.commons.service.event.store.internal; +import javax.inject.Singleton; + import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.commons.service.event.store.api.EventStoreFactory; import org.eclipse.kapua.commons.service.event.store.api.EventStoreRecord; import org.eclipse.kapua.commons.service.event.store.api.EventStoreRecordCreator; -import org.eclipse.kapua.commons.service.event.store.api.EventStoreRecordListResult; import org.eclipse.kapua.commons.service.event.store.api.EventStoreRecordQuery; import org.eclipse.kapua.model.id.KapuaId; -import javax.inject.Singleton; - /** * {@link EventStoreFactory} implementation * @@ -45,11 +44,6 @@ public EventStoreRecordQuery newQuery(KapuaId scopeId) { return new EventStoreQueryImpl(scopeId); } - @Override - public EventStoreRecordListResult newListResult() { - return new EventStoreRecordListResultImpl(); - } - @Override public EventStoreRecord clone(EventStoreRecord eventStoreRecord) { try { diff --git a/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/internal/EventStoreRecordImplJpaRepository.java b/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/internal/EventStoreRecordImplJpaRepository.java index 10363ed304a..67b965941f6 100644 --- a/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/internal/EventStoreRecordImplJpaRepository.java +++ b/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/internal/EventStoreRecordImplJpaRepository.java @@ -21,9 +21,9 @@ public class EventStoreRecordImplJpaRepository extends KapuaUpdatableEntityJpaRepository implements EventStoreRecordRepository { + public EventStoreRecordImplJpaRepository(KapuaJpaRepositoryConfiguration jpaRepoConfig) { - super(EventStoreRecordImpl.class, EventStoreRecord.TYPE, () -> new EventStoreRecordListResultImpl(), jpaRepoConfig); + super(EventStoreRecordImpl.class, EventStoreRecord.TYPE, () -> new EventStoreRecordListResult(), jpaRepoConfig); } - } diff --git a/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/internal/EventStoreRecordListResultImpl.java b/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/internal/EventStoreRecordListResultImpl.java deleted file mode 100644 index 38ed77fbcc8..00000000000 --- a/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/internal/EventStoreRecordListResultImpl.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * 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.service.event.store.internal; - -import org.eclipse.kapua.commons.model.query.KapuaListResultImpl; -import org.eclipse.kapua.commons.service.event.store.api.EventStoreRecord; -import org.eclipse.kapua.commons.service.event.store.api.EventStoreRecordListResult; - -/** - * KapuaEvent list result implementation. - * - * @since 1.0 - */ -public class EventStoreRecordListResultImpl extends KapuaListResultImpl implements EventStoreRecordListResult { - - private static final long serialVersionUID = -5118004898345748297L; -} diff --git a/commons/src/main/java/org/eclipse/kapua/commons/service/internal/cache/EntityCache.java b/commons/src/main/java/org/eclipse/kapua/commons/service/internal/cache/EntityCache.java index f17db8d4930..481a90e69d7 100644 --- a/commons/src/main/java/org/eclipse/kapua/commons/service/internal/cache/EntityCache.java +++ b/commons/src/main/java/org/eclipse/kapua/commons/service/internal/cache/EntityCache.java @@ -12,6 +12,10 @@ *******************************************************************************/ package org.eclipse.kapua.commons.service.internal.cache; +import java.io.Serializable; + +import javax.cache.Cache; + import org.eclipse.kapua.commons.metric.CommonsMetric; import org.eclipse.kapua.model.KapuaEntity; import org.eclipse.kapua.model.id.KapuaId; @@ -19,12 +23,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.cache.Cache; -import java.io.Serializable; - /** - * The basic cache class, it contains two {@link Cache} objects. - * The {@code idCache} cache contains {@link KapuaEntity} objects, while the {@code listsCache} contains {@link KapuaListResult} objects. + * The basic cache class, it contains two {@link Cache} objects. The {@code idCache} cache contains {@link KapuaEntity} objects, while the {@code listsCache} contains {@link KapuaListResult} objects. */ public class EntityCache { @@ -134,11 +134,13 @@ public KapuaListResult removeList(KapuaId scopeId, Serializable id) { } /** - * Checks that the scopeId of the entity matches the provided one. - * This mimics the checks that are performed in the 'find' method of the {@link org.eclipse.kapua.commons.jpa.KapuaEntityJpaRepository} class. + * Checks that the scopeId of the entity matches the provided one. This mimics the checks that are performed in the 'find' method of the + * {@link org.eclipse.kapua.commons.jpa.KapuaEntityJpaRepository} class. * - * @param scopeId a {@link KapuaId} representing the scopeId - * @param entity the {@link KapuaEntity} to be checked + * @param scopeId + * a {@link KapuaId} representing the scopeId + * @param entity + * the {@link KapuaEntity} to be checked * @return the provided entity if it has the required scopeId, null otherwise */ protected KapuaEntity checkResult(KapuaId scopeId, KapuaEntity entity) { @@ -158,14 +160,16 @@ protected KapuaEntity checkResult(KapuaId scopeId, KapuaEntity entity) { } /** - * Checks that the scopeId of the entity matches the provided one. - * This mimics the checks that are performed in the 'find' method of the {@link org.eclipse.kapua.commons.jpa.KapuaEntityJpaRepository} class. + * Checks that the scopeId of the entity matches the provided one. This mimics the checks that are performed in the 'find' method of the + * {@link org.eclipse.kapua.commons.jpa.KapuaEntityJpaRepository} class. * - * @param scopeId a {@link KapuaId} representing the scopeId - * @param entity the {@link KapuaListResult} entity to be checked + * @param scopeId + * a {@link KapuaId} representing the scopeId + * @param entity + * the {@link KapuaListResult} entity to be checked * @return the provided entity if it has the required scopeId, null otherwise */ - protected KapuaListResult checkResult(KapuaId scopeId, KapuaListResult entity) { + protected KapuaListResult checkResult(KapuaId scopeId, KapuaListResult entity) { if (entity != null) { if (entity.getSize() == 0) { return entity; // If the list is empty, I want to return the empty list @@ -186,10 +190,14 @@ protected KapuaListResult checkResult(KapuaId scopeId, KapuaListResult entity) { /** * Handles logging for cache exceptions. * - * @param operation the name of the method/operation - * @param cacheName the name of the cache in which the operation is performed - * @param keyId the Id of the entry's key in the cache - * @param t the exception + * @param operation + * the name of the method/operation + * @param cacheName + * the name of the cache in which the operation is performed + * @param keyId + * the Id of the entry's key in the cache + * @param t + * the exception */ protected void cacheErrorLogger(String operation, String cacheName, Serializable keyId, Throwable t) { commonsMetric.getCacheError().inc(); diff --git a/commons/src/test/java/org/eclipse/kapua/commons/model/misc/CollisionEntityJpaRepository.java b/commons/src/test/java/org/eclipse/kapua/commons/model/misc/CollisionEntityJpaRepository.java index dacf2bbb7e1..e8d5726b35d 100644 --- a/commons/src/test/java/org/eclipse/kapua/commons/model/misc/CollisionEntityJpaRepository.java +++ b/commons/src/test/java/org/eclipse/kapua/commons/model/misc/CollisionEntityJpaRepository.java @@ -14,14 +14,12 @@ import org.eclipse.kapua.commons.jpa.KapuaEntityJpaRepository; import org.eclipse.kapua.commons.jpa.KapuaJpaRepositoryConfiguration; -import org.eclipse.kapua.commons.model.query.KapuaListResultImpl; import org.eclipse.kapua.model.query.KapuaListResult; - public class CollisionEntityJpaRepository extends KapuaEntityJpaRepository> { public CollisionEntityJpaRepository(KapuaJpaRepositoryConfiguration configuration) { - super(CollisionEntity.class, CollisionEntity.TYPE, () -> new KapuaListResultImpl<>(), configuration); + super(CollisionEntity.class, CollisionEntity.TYPE, () -> new KapuaListResult<>(), configuration); } } diff --git a/commons/src/test/java/org/eclipse/kapua/commons/model/query/KapuaListResultImplTest.java b/commons/src/test/java/org/eclipse/kapua/commons/model/query/KapuaListResultTest.java similarity index 85% rename from commons/src/test/java/org/eclipse/kapua/commons/model/query/KapuaListResultImplTest.java rename to commons/src/test/java/org/eclipse/kapua/commons/model/query/KapuaListResultTest.java index db57913c750..add84b7c7cc 100644 --- a/commons/src/test/java/org/eclipse/kapua/commons/model/query/KapuaListResultImplTest.java +++ b/commons/src/test/java/org/eclipse/kapua/commons/model/query/KapuaListResultTest.java @@ -12,31 +12,32 @@ *******************************************************************************/ package org.eclipse.kapua.commons.model.query; +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; +import java.util.Map; +import java.util.Random; + import org.eclipse.kapua.commons.model.AbstractKapuaEntity; import org.eclipse.kapua.commons.model.id.KapuaEid; import org.eclipse.kapua.commons.util.RandomUtils; import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.model.query.KapuaListResult; import org.eclipse.kapua.qa.markers.junit.JUnitTests; import org.junit.Assert; import org.junit.Test; import org.junit.experimental.categories.Category; import org.mockito.Mockito; -import java.math.BigInteger; -import java.util.ArrayList; -import java.util.Comparator; -import java.util.List; -import java.util.Map; -import java.util.Random; - @Category(JUnitTests.class) -public class KapuaListResultImplTest { +public class KapuaListResultTest { private final static Random RANDOM = RandomUtils.getInstance(); @Test public void kapuaListResultImplTest() { - KapuaListResultImpl kapuaListResult = new KapuaListResultImpl<>(); + KapuaListResult kapuaListResult = new KapuaListResult<>(); Assert.assertNotNull(kapuaListResult.getItems()); Assert.assertTrue(kapuaListResult.getItems().isEmpty()); @@ -53,7 +54,7 @@ public void addItemsTest() { items.add(kapuaEntity1); items.add(kapuaEntity2); - KapuaListResultImpl kapuaListResult = new KapuaListResultImpl<>(); + KapuaListResult kapuaListResult = new KapuaListResult<>(); kapuaListResult.addItems(items); Assert.assertEquals(2, kapuaListResult.getItems().size()); @@ -67,7 +68,7 @@ public void addItemTest() { AbstractKapuaEntity kapuaEntity1 = Mockito.mock(AbstractKapuaEntity.class); AbstractKapuaEntity kapuaEntity2 = Mockito.mock(AbstractKapuaEntity.class); - KapuaListResultImpl kapuaListResult = new KapuaListResultImpl<>(); + KapuaListResult kapuaListResult = new KapuaListResult<>(); kapuaListResult.addItem(kapuaEntity1); kapuaListResult.addItem(kapuaEntity2); @@ -79,7 +80,7 @@ public void addItemTest() { @Test public void clearItemsTest() { int testSize = 10; - KapuaListResultImpl kapuaListResult = new KapuaListResultImpl<>(); + KapuaListResult kapuaListResult = new KapuaListResult<>(); for (int i = 0; i < testSize; i++) { kapuaListResult.addItem(Mockito.mock(AbstractKapuaEntity.class)); @@ -94,7 +95,7 @@ public void clearItemsTest() { @Test public void getFirstItemTest() { - KapuaListResultImpl kapuaListResult = new KapuaListResultImpl<>(); + KapuaListResult kapuaListResult = new KapuaListResult<>(); AbstractKapuaEntity kapuaEntity1 = Mockito.mock(AbstractKapuaEntity.class); kapuaListResult.addItem(kapuaEntity1); @@ -108,7 +109,7 @@ public void getFirstItemTest() { @Test public void getItemsTest() { - KapuaListResultImpl kapuaListResult = new KapuaListResultImpl<>(); + KapuaListResult kapuaListResult = new KapuaListResult<>(); AbstractKapuaEntity kapuaEntity1 = Mockito.mock(AbstractKapuaEntity.class); kapuaListResult.addItem(kapuaEntity1); @@ -124,7 +125,7 @@ public void getItemsTest() { @Test public void getItemsPredicateTest() { int testSize = 10; - KapuaListResultImpl kapuaListResult = new KapuaListResultImpl<>(); + KapuaListResult kapuaListResult = new KapuaListResult<>(); for (int i = 0; i < testSize; i++) { AbstractKapuaEntity kapuaEntity = Mockito.mock(AbstractKapuaEntity.class); @@ -144,7 +145,7 @@ public void getItemsPredicateTest() { @Test public void getItemsAsMapKeyTest() { int testSize = 10; - KapuaListResultImpl kapuaListResult = new KapuaListResultImpl<>(); + KapuaListResult kapuaListResult = new KapuaListResult<>(); for (int i = 0; i < testSize; i++) { AbstractKapuaEntity kapuaEntity = Mockito.mock(AbstractKapuaEntity.class); @@ -164,7 +165,7 @@ public void getItemsAsMapKeyTest() { @Test public void getItemsAsMapKeyValueTest() { int testSize = 10; - KapuaListResultImpl kapuaListResult = new KapuaListResultImpl<>(); + KapuaListResult kapuaListResult = new KapuaListResult<>(); for (int i = 0; i < testSize; i++) { AbstractKapuaEntity kapuaEntity = Mockito.mock(AbstractKapuaEntity.class); @@ -184,7 +185,7 @@ public void getItemsAsMapKeyValueTest() { @Test public void getItemTest() { - KapuaListResultImpl kapuaListResult = new KapuaListResultImpl<>(); + KapuaListResult kapuaListResult = new KapuaListResult<>(); AbstractKapuaEntity kapuaEntity1 = Mockito.mock(AbstractKapuaEntity.class); kapuaListResult.addItem(kapuaEntity1); @@ -199,7 +200,7 @@ public void getItemTest() { @Test public void getSizeTest() { int testSize = 10; - KapuaListResultImpl kapuaListResult = new KapuaListResultImpl<>(); + KapuaListResult kapuaListResult = new KapuaListResult<>(); for (int i = 0; i < testSize; i++) { kapuaListResult.addItem(Mockito.mock(AbstractKapuaEntity.class)); @@ -210,7 +211,7 @@ public void getSizeTest() { @Test public void isEmptyTest() { - KapuaListResultImpl kapuaListResult = new KapuaListResultImpl<>(); + KapuaListResult kapuaListResult = new KapuaListResult<>(); Assert.assertTrue(kapuaListResult.isEmpty()); kapuaListResult.addItem(Mockito.mock(AbstractKapuaEntity.class)); @@ -219,7 +220,7 @@ public void isEmptyTest() { @Test public void setGetLimitExceededTrueTest() { - KapuaListResultImpl kapuaListResult = new KapuaListResultImpl<>(); + KapuaListResult kapuaListResult = new KapuaListResult<>(); kapuaListResult.setLimitExceeded(true); Assert.assertTrue(kapuaListResult.isLimitExceeded()); @@ -227,7 +228,7 @@ public void setGetLimitExceededTrueTest() { @Test public void setGetLimitExceededFalseTest() { - KapuaListResultImpl kapuaListResult = new KapuaListResultImpl<>(); + KapuaListResult kapuaListResult = new KapuaListResult<>(); kapuaListResult.setLimitExceeded(false); Assert.assertFalse(kapuaListResult.isLimitExceeded()); @@ -235,14 +236,14 @@ public void setGetLimitExceededFalseTest() { @Test public void setGetTotalCountDefaultTest() { - KapuaListResultImpl kapuaListResult = new KapuaListResultImpl<>(); + KapuaListResult kapuaListResult = new KapuaListResult<>(); Assert.assertNull(kapuaListResult.getTotalCount()); } @Test public void setGetTotalCountValueTest() { - KapuaListResultImpl kapuaListResult = new KapuaListResultImpl<>(); + KapuaListResult kapuaListResult = new KapuaListResult<>(); kapuaListResult.setTotalCount(10L); Assert.assertEquals(new Long(10L), kapuaListResult.getTotalCount()); @@ -251,7 +252,7 @@ public void setGetTotalCountValueTest() { @Test public void sortComparatorTest() { int testSize = 10; - KapuaListResultImpl kapuaListResult = new KapuaListResultImpl<>(); + KapuaListResult kapuaListResult = new KapuaListResult<>(); // Add the max value AbstractKapuaEntity kapuaEntityMax = Mockito.mock(AbstractKapuaEntity.class); diff --git a/commons/src/test/java/org/eclipse/kapua/commons/service/event/store/internal/EventStoreFactoryImplTest.java b/commons/src/test/java/org/eclipse/kapua/commons/service/event/store/internal/EventStoreFactoryImplTest.java index 23379802a93..e112a27e521 100644 --- a/commons/src/test/java/org/eclipse/kapua/commons/service/event/store/internal/EventStoreFactoryImplTest.java +++ b/commons/src/test/java/org/eclipse/kapua/commons/service/event/store/internal/EventStoreFactoryImplTest.java @@ -12,11 +12,12 @@ *******************************************************************************/ package org.eclipse.kapua.commons.service.event.store.internal; +import java.math.BigInteger; + import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.commons.model.id.KapuaEid; import org.eclipse.kapua.commons.service.event.store.api.EventStoreRecord; import org.eclipse.kapua.model.id.KapuaId; - import org.eclipse.kapua.qa.markers.junit.JUnitTests; import org.hamcrest.core.IsInstanceOf; import org.junit.Assert; @@ -24,53 +25,42 @@ import org.junit.experimental.categories.Category; import org.mockito.Mockito; -import java.math.BigInteger; - - @Category(JUnitTests.class) public class EventStoreFactoryImplTest { @Test public void newEntityTest() { EventStoreFactoryImpl eventStoreFactoryImpl = new EventStoreFactoryImpl(); - KapuaId[] scopeIdList = {null, new KapuaEid(BigInteger.ONE)}; + KapuaId[] scopeIdList = { null, new KapuaEid(BigInteger.ONE) }; for (KapuaId scopeId : scopeIdList) { Assert.assertNotNull("Null not expected.", eventStoreFactoryImpl.newEntity(scopeId)); - Assert.assertThat("EventStoreRecordImpl object expected.", eventStoreFactoryImpl.newEntity(scopeId), IsInstanceOf.instanceOf(EventStoreRecordImpl.class)); + Assert.assertThat("EventStoreRecordImpl object expected.", eventStoreFactoryImpl.newEntity(scopeId), IsInstanceOf.instanceOf(EventStoreRecordImpl.class)); } } @Test public void newCreatorTest() { EventStoreFactoryImpl eventStoreFactoryImpl = new EventStoreFactoryImpl(); - KapuaId[] scopeIdList = {null, new KapuaEid(BigInteger.ONE)}; + KapuaId[] scopeIdList = { null, new KapuaEid(BigInteger.ONE) }; for (KapuaId scopeId : scopeIdList) { Assert.assertNotNull("Null not expected.", eventStoreFactoryImpl.newCreator(scopeId)); - Assert.assertThat("EventStoreRecordImpl object expected.", eventStoreFactoryImpl.newCreator(scopeId), IsInstanceOf.instanceOf(EventStoreRecordCreatorImpl.class)); + Assert.assertThat("EventStoreRecordImpl object expected.", eventStoreFactoryImpl.newCreator(scopeId), IsInstanceOf.instanceOf(EventStoreRecordCreatorImpl.class)); } } @Test public void newQueryTest() { EventStoreFactoryImpl eventStoreFactoryImpl = new EventStoreFactoryImpl(); - KapuaId[] scopeIdList = {null, new KapuaEid(BigInteger.ONE)}; + KapuaId[] scopeIdList = { null, new KapuaEid(BigInteger.ONE) }; for (KapuaId scopeId : scopeIdList) { Assert.assertNotNull("Null not expected.", eventStoreFactoryImpl.newQuery(scopeId)); - Assert.assertThat("EventStoreQueryImpl object expected.", eventStoreFactoryImpl.newQuery(scopeId), IsInstanceOf.instanceOf(EventStoreQueryImpl.class)); + Assert.assertThat("EventStoreQueryImpl object expected.", eventStoreFactoryImpl.newQuery(scopeId), IsInstanceOf.instanceOf(EventStoreQueryImpl.class)); } } - @Test - public void newListResultTest() { - EventStoreFactoryImpl eventStoreFactoryImpl = new EventStoreFactoryImpl(); - - Assert.assertNotNull("Null not expected.", eventStoreFactoryImpl.newListResult()); - Assert.assertThat("EventStoreRecordListResultImpl object expected.", eventStoreFactoryImpl.newListResult(), IsInstanceOf.instanceOf(EventStoreRecordListResultImpl.class)); - } - @Test public void cloneTest() { EventStoreFactoryImpl eventStoreFactoryImpl = new EventStoreFactoryImpl(); diff --git a/console/module/device/src/main/java/org/eclipse/kapua/app/console/module/device/shared/util/GwtKapuaDeviceModelConverter.java b/console/module/device/src/main/java/org/eclipse/kapua/app/console/module/device/shared/util/GwtKapuaDeviceModelConverter.java index 4a70ef4d824..b9c310f807d 100644 --- a/console/module/device/src/main/java/org/eclipse/kapua/app/console/module/device/shared/util/GwtKapuaDeviceModelConverter.java +++ b/console/module/device/src/main/java/org/eclipse/kapua/app/console/module/device/shared/util/GwtKapuaDeviceModelConverter.java @@ -12,8 +12,9 @@ *******************************************************************************/ package org.eclipse.kapua.app.console.module.device.shared.util; -import com.extjs.gxt.ui.client.Style.SortDir; -import com.extjs.gxt.ui.client.data.PagingLoadConfig; +import java.util.ArrayList; +import java.util.List; + import org.apache.commons.lang3.StringUtils; import org.eclipse.kapua.app.console.module.api.shared.util.GwtKapuaCommonsModelConverter; import org.eclipse.kapua.app.console.module.device.shared.model.GwtDeviceQuery; @@ -51,8 +52,8 @@ import org.eclipse.kapua.service.device.registry.connection.DeviceConnectionQuery; import org.eclipse.kapua.service.device.registry.connection.DeviceConnectionStatus; -import java.util.ArrayList; -import java.util.List; +import com.extjs.gxt.ui.client.Style.SortDir; +import com.extjs.gxt.ui.client.data.PagingLoadConfig; public class GwtKapuaDeviceModelConverter { @@ -64,7 +65,6 @@ public class GwtKapuaDeviceModelConverter { private static final DeviceAssetFactory ASSET_FACTORY = LOCATOR.getFactory(DeviceAssetFactory.class); - private GwtKapuaDeviceModelConverter() { } @@ -89,11 +89,11 @@ public static DeviceConnectionQuery convertConnectionQuery(PagingLoadConfig load } if (gwtDeviceConnectionQuery.getGwtDeviceConnectionReservedUser() != null) { switch (gwtDeviceConnectionQuery.getGwtDeviceConnectionReservedUser()) { - case NONE: - predicate = predicate.and(query.attributePredicate(DeviceConnectionAttributes.RESERVED_USER_ID, null, Operator.IS_NULL)); - break; - default: - predicate = predicate.and(query.attributePredicate(DeviceConnectionAttributes.RESERVED_USER_ID, KapuaEid.parseCompactId(gwtDeviceConnectionQuery.getReservedUserId()))); + case NONE: + predicate = predicate.and(query.attributePredicate(DeviceConnectionAttributes.RESERVED_USER_ID, null, Operator.IS_NULL)); + break; + default: + predicate = predicate.and(query.attributePredicate(DeviceConnectionAttributes.RESERVED_USER_ID, KapuaEid.parseCompactId(gwtDeviceConnectionQuery.getReservedUserId()))); } } @@ -122,7 +122,7 @@ public static DeviceConnectionStatus convertConnectionStatus(String connectionSt } public static DeviceAssets convertDeviceAssets(GwtDeviceAssets deviceAssets) { - DeviceAssets assets = ASSET_FACTORY.newAssetListResult(); + DeviceAssets assets = new DeviceAssets(); List assetList = new ArrayList(); for (GwtDeviceAsset gwtDeviceAsset : deviceAssets.getAssets()) { assetList.add(convertDeviceAsset(gwtDeviceAsset)); @@ -199,22 +199,22 @@ public static DeviceQuery convertDeviceQuery(PagingLoadConfig loadConfig, GwtDev } if (predicates.getDeviceConnectionStatus() != null) { switch (predicates.getDeviceConnectionStatusEnum()) { - case UNKNOWN: - andPred = andPred.and(query.attributePredicate(DeviceAttributes.CONNECTION_ID, DeviceConnectionStatus.NULL, Operator.IS_NULL)); - break; - default: - andPred = andPred.and(query.attributePredicate(DeviceAttributes.CONNECTION_STATUS, DeviceConnectionStatus.valueOf(predicates.getDeviceConnectionStatus()))); + case UNKNOWN: + andPred = andPred.and(query.attributePredicate(DeviceAttributes.CONNECTION_ID, DeviceConnectionStatus.NULL, Operator.IS_NULL)); + break; + default: + andPred = andPred.and(query.attributePredicate(DeviceAttributes.CONNECTION_STATUS, DeviceConnectionStatus.valueOf(predicates.getDeviceConnectionStatus()))); } } if (predicates.getGroupDevice() != null) { switch (predicates.getGroupDeviceEnum()) { - case NO_GROUP: - andPred = andPred.and(query.attributePredicate(DeviceAttributes.GROUP_ID, null, Operator.IS_NULL)); - break; - default: - if (predicates.getGroupId() != null) { - andPred = andPred.and(query.attributePredicate(DeviceAttributes.GROUP_ID, KapuaEid.parseCompactId(predicates.getGroupId()))); - } + case NO_GROUP: + andPred = andPred.and(query.attributePredicate(DeviceAttributes.GROUP_ID, null, Operator.IS_NULL)); + break; + default: + if (predicates.getGroupId() != null) { + andPred = andPred.and(query.attributePredicate(DeviceAttributes.GROUP_ID, KapuaEid.parseCompactId(predicates.getGroupId()))); + } } } if (predicates.getTagIds() != null) { @@ -241,7 +241,6 @@ public static DeviceQuery convertDeviceQuery(PagingLoadConfig loadConfig, GwtDev return query; } - public static DeviceManagementOperationQuery convertDeviceManagementOperationQuery(PagingLoadConfig loadConfig, GwtDeviceManagementOperationQuery gwtQuery) { DeviceManagementOperationQuery query = DEVICE_MANAGEMENT_OPERATION_FACTORY.newQuery(KapuaEid.parseCompactId(gwtQuery.getScopeId())); diff --git a/console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/servlet/JobTargetExporterServlet.java b/console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/servlet/JobTargetExporterServlet.java index 3826c67c117..763c0070c58 100644 --- a/console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/servlet/JobTargetExporterServlet.java +++ b/console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/servlet/JobTargetExporterServlet.java @@ -12,6 +12,13 @@ *******************************************************************************/ package org.eclipse.kapua.app.console.module.job.servlet; +import java.io.IOException; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + import org.eclipse.kapua.KapuaEntityNotFoundException; import org.eclipse.kapua.KapuaIllegalAccessException; import org.eclipse.kapua.KapuaUnauthenticatedException; @@ -21,17 +28,12 @@ import org.eclipse.kapua.service.job.targets.JobTarget; import org.eclipse.kapua.service.job.targets.JobTargetAttributes; import org.eclipse.kapua.service.job.targets.JobTargetFactory; +import org.eclipse.kapua.service.job.targets.JobTargetListResult; import org.eclipse.kapua.service.job.targets.JobTargetQuery; import org.eclipse.kapua.service.job.targets.JobTargetService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; - public class JobTargetExporterServlet extends HttpServlet { private static final long serialVersionUID = -2533869595709953567L; @@ -87,7 +89,7 @@ private void internalDoGet(HttpServletRequest request, HttpServletResponse respo // paginate through the matching message jobTargetQuery.setLimit(250); - KapuaListResult totalJobTargets = jobTargetFactory.newListResult(); + KapuaListResult totalJobTargets = new JobTargetListResult(); KapuaListResult results; do { jobTargetQuery.setOffset(offset); diff --git a/extras/encryption-migrator/src/main/java/org/eclipse/kapua/extras/migrator/encryption/authentication/MfaOptionMigratorJpaRepository.java b/extras/encryption-migrator/src/main/java/org/eclipse/kapua/extras/migrator/encryption/authentication/MfaOptionMigratorJpaRepository.java index aebb923387d..d97364cfe39 100644 --- a/extras/encryption-migrator/src/main/java/org/eclipse/kapua/extras/migrator/encryption/authentication/MfaOptionMigratorJpaRepository.java +++ b/extras/encryption-migrator/src/main/java/org/eclipse/kapua/extras/migrator/encryption/authentication/MfaOptionMigratorJpaRepository.java @@ -12,6 +12,8 @@ *******************************************************************************/ package org.eclipse.kapua.extras.migrator.encryption.authentication; +import java.util.Optional; + import org.eclipse.kapua.commons.jpa.KapuaJpaRepositoryConfiguration; import org.eclipse.kapua.commons.jpa.KapuaUpdatableEntityJpaRepository; import org.eclipse.kapua.model.id.KapuaId; @@ -20,13 +22,12 @@ import org.eclipse.kapua.service.authentication.credential.mfa.MfaOptionRepository; import org.eclipse.kapua.storage.TxContext; -import java.util.Optional; - public class MfaOptionMigratorJpaRepository extends KapuaUpdatableEntityJpaRepository implements MfaOptionRepository { + public MfaOptionMigratorJpaRepository(KapuaJpaRepositoryConfiguration jpaRepoConfig) { - super(MfaOptionMigrator.class, MfaOption.TYPE, () -> new MfaOptionMigratorListResultImpl(), jpaRepoConfig); + super(MfaOptionMigrator.class, MfaOption.TYPE, () -> new MfaOptionListResult(), jpaRepoConfig); } @Override diff --git a/extras/encryption-migrator/src/main/java/org/eclipse/kapua/extras/migrator/encryption/authentication/MfaOptionMigratorListResultImpl.java b/extras/encryption-migrator/src/main/java/org/eclipse/kapua/extras/migrator/encryption/authentication/MfaOptionMigratorListResultImpl.java deleted file mode 100644 index fcade9feb5e..00000000000 --- a/extras/encryption-migrator/src/main/java/org/eclipse/kapua/extras/migrator/encryption/authentication/MfaOptionMigratorListResultImpl.java +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 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.extras.migrator.encryption.authentication; - -import org.eclipse.kapua.commons.model.query.KapuaListResultImpl; -import org.eclipse.kapua.service.authentication.credential.mfa.MfaOption; -import org.eclipse.kapua.service.authentication.credential.mfa.MfaOptionListResult; - -/** - * {@link MfaOptionListResult} implementation. - * - * @since 1.0.0 - */ -public class MfaOptionMigratorListResultImpl extends KapuaListResultImpl implements MfaOptionListResult { -} diff --git a/extras/encryption-migrator/src/main/java/org/eclipse/kapua/extras/migrator/encryption/job/JobStepMigratorJpaRepository.java b/extras/encryption-migrator/src/main/java/org/eclipse/kapua/extras/migrator/encryption/job/JobStepMigratorJpaRepository.java index 252b5bcf617..62e73c3956f 100644 --- a/extras/encryption-migrator/src/main/java/org/eclipse/kapua/extras/migrator/encryption/job/JobStepMigratorJpaRepository.java +++ b/extras/encryption-migrator/src/main/java/org/eclipse/kapua/extras/migrator/encryption/job/JobStepMigratorJpaRepository.java @@ -12,6 +12,8 @@ *******************************************************************************/ package org.eclipse.kapua.extras.migrator.encryption.job; +import java.util.Optional; + import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.commons.jpa.KapuaJpaRepositoryConfiguration; import org.eclipse.kapua.commons.jpa.KapuaNamedEntityJpaRepository; @@ -22,14 +24,12 @@ import org.eclipse.kapua.service.job.step.definition.JobStepProperty; import org.eclipse.kapua.storage.TxContext; -import java.util.Optional; - public class JobStepMigratorJpaRepository extends KapuaNamedEntityJpaRepository implements JobStepRepository { public JobStepMigratorJpaRepository(KapuaJpaRepositoryConfiguration jpaRepoConfig) { - super(JobStepMigrator.class, JobStep.TYPE, () -> new JobStepMigratorListResultImpl(), jpaRepoConfig); + super(JobStepMigrator.class, JobStep.TYPE, () -> new JobStepListResult(), jpaRepoConfig); } @Override diff --git a/extras/encryption-migrator/src/main/java/org/eclipse/kapua/extras/migrator/encryption/job/JobStepMigratorListResultImpl.java b/extras/encryption-migrator/src/main/java/org/eclipse/kapua/extras/migrator/encryption/job/JobStepMigratorListResultImpl.java deleted file mode 100644 index 7662b098c99..00000000000 --- a/extras/encryption-migrator/src/main/java/org/eclipse/kapua/extras/migrator/encryption/job/JobStepMigratorListResultImpl.java +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 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.extras.migrator.encryption.job; - -import org.eclipse.kapua.commons.model.query.KapuaListResultImpl; -import org.eclipse.kapua.service.job.step.JobStep; -import org.eclipse.kapua.service.job.step.JobStepListResult; - -/** - * {@link JobStepListResult} implementation. - * - * @since 1.0.0 - */ -public class JobStepMigratorListResultImpl extends KapuaListResultImpl implements JobStepListResult { -} diff --git a/job-engine/api/src/main/java/org/eclipse/kapua/job/engine/queue/QueuedJobExecutionFactory.java b/job-engine/api/src/main/java/org/eclipse/kapua/job/engine/queue/QueuedJobExecutionFactory.java index 788da3a3d2f..88305e0d0a6 100644 --- a/job-engine/api/src/main/java/org/eclipse/kapua/job/engine/queue/QueuedJobExecutionFactory.java +++ b/job-engine/api/src/main/java/org/eclipse/kapua/job/engine/queue/QueuedJobExecutionFactory.java @@ -19,6 +19,6 @@ * * @since 1.1.0 */ -public interface QueuedJobExecutionFactory extends KapuaEntityFactory { +public interface QueuedJobExecutionFactory extends KapuaEntityFactory { } diff --git a/job-engine/api/src/main/java/org/eclipse/kapua/job/engine/queue/QueuedJobExecutionListResult.java b/job-engine/api/src/main/java/org/eclipse/kapua/job/engine/queue/QueuedJobExecutionListResult.java index d3c35da8534..906559a3a38 100644 --- a/job-engine/api/src/main/java/org/eclipse/kapua/job/engine/queue/QueuedJobExecutionListResult.java +++ b/job-engine/api/src/main/java/org/eclipse/kapua/job/engine/queue/QueuedJobExecutionListResult.java @@ -26,7 +26,7 @@ */ @XmlRootElement(name = "queuedJobListResult") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = QueuedJobExecutionXmlRegistry.class, factoryMethod = "newQueuedJobExecutionListResult") -public interface QueuedJobExecutionListResult extends KapuaListResult { +@XmlType +public class QueuedJobExecutionListResult extends KapuaListResult { } diff --git a/job-engine/api/src/main/java/org/eclipse/kapua/job/engine/queue/QueuedJobExecutionXmlRegistry.java b/job-engine/api/src/main/java/org/eclipse/kapua/job/engine/queue/QueuedJobExecutionXmlRegistry.java index 3f5554b0966..e8a33d71999 100644 --- a/job-engine/api/src/main/java/org/eclipse/kapua/job/engine/queue/QueuedJobExecutionXmlRegistry.java +++ b/job-engine/api/src/main/java/org/eclipse/kapua/job/engine/queue/QueuedJobExecutionXmlRegistry.java @@ -12,10 +12,10 @@ *******************************************************************************/ package org.eclipse.kapua.job.engine.queue; -import org.eclipse.kapua.locator.KapuaLocator; - import javax.xml.bind.annotation.XmlRegistry; +import org.eclipse.kapua.locator.KapuaLocator; + /** * {@link QueuedJobExecution} xml factory class * @@ -44,15 +44,6 @@ public QueuedJobExecutionCreator newQueuedJobExecutionCreator() { return queuedJobExecutionFactory.newCreator(null); } - /** - * Creates a new job list result instance - * - * @return - */ - public QueuedJobExecutionListResult newQueuedJobExecutionListResult() { - return queuedJobExecutionFactory.newListResult(); - } - public QueuedJobExecutionQuery newQuery() { return queuedJobExecutionFactory.newQuery(null); } diff --git a/job-engine/jbatch/src/main/java/org/eclipse/kapua/job/engine/queue/jbatch/QueuedJobExecutionFactoryImpl.java b/job-engine/jbatch/src/main/java/org/eclipse/kapua/job/engine/queue/jbatch/QueuedJobExecutionFactoryImpl.java index fd5c6642390..6a9029ac52b 100644 --- a/job-engine/jbatch/src/main/java/org/eclipse/kapua/job/engine/queue/jbatch/QueuedJobExecutionFactoryImpl.java +++ b/job-engine/jbatch/src/main/java/org/eclipse/kapua/job/engine/queue/jbatch/QueuedJobExecutionFactoryImpl.java @@ -12,16 +12,15 @@ *******************************************************************************/ package org.eclipse.kapua.job.engine.queue.jbatch; +import javax.inject.Singleton; + import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.job.engine.queue.QueuedJobExecution; import org.eclipse.kapua.job.engine.queue.QueuedJobExecutionCreator; import org.eclipse.kapua.job.engine.queue.QueuedJobExecutionFactory; -import org.eclipse.kapua.job.engine.queue.QueuedJobExecutionListResult; import org.eclipse.kapua.job.engine.queue.QueuedJobExecutionQuery; import org.eclipse.kapua.model.id.KapuaId; -import javax.inject.Singleton; - /** * {@link QueuedJobExecutionFactory} implementation. * @@ -45,11 +44,6 @@ public QueuedJobExecutionQuery newQuery(KapuaId scopeId) { return new QueuedJobExecutionQueryImpl(scopeId); } - @Override - public QueuedJobExecutionListResult newListResult() { - return new QueuedJobExecutionListResultImpl(); - } - @Override public QueuedJobExecution clone(QueuedJobExecution queuedJobExecution) { try { diff --git a/job-engine/jbatch/src/main/java/org/eclipse/kapua/job/engine/queue/jbatch/QueuedJobExecutionImplJpaRepository.java b/job-engine/jbatch/src/main/java/org/eclipse/kapua/job/engine/queue/jbatch/QueuedJobExecutionImplJpaRepository.java index a5956470dbf..d4b98e6d520 100644 --- a/job-engine/jbatch/src/main/java/org/eclipse/kapua/job/engine/queue/jbatch/QueuedJobExecutionImplJpaRepository.java +++ b/job-engine/jbatch/src/main/java/org/eclipse/kapua/job/engine/queue/jbatch/QueuedJobExecutionImplJpaRepository.java @@ -22,7 +22,8 @@ public class QueuedJobExecutionImplJpaRepository extends KapuaUpdatableEntityJpaRepository implements QueuedJobExecutionRepository { + public QueuedJobExecutionImplJpaRepository(KapuaJpaRepositoryConfiguration jpaRepoConfig) { - super(QueuedJobExecutionImpl.class, JobExecution.TYPE, () -> new QueuedJobExecutionListResultImpl(), jpaRepoConfig); + super(QueuedJobExecutionImpl.class, JobExecution.TYPE, () -> new QueuedJobExecutionListResult(), jpaRepoConfig); } } diff --git a/job-engine/jbatch/src/main/java/org/eclipse/kapua/job/engine/queue/jbatch/QueuedJobExecutionListResultImpl.java b/job-engine/jbatch/src/main/java/org/eclipse/kapua/job/engine/queue/jbatch/QueuedJobExecutionListResultImpl.java deleted file mode 100644 index d7a642d35d0..00000000000 --- a/job-engine/jbatch/src/main/java/org/eclipse/kapua/job/engine/queue/jbatch/QueuedJobExecutionListResultImpl.java +++ /dev/null @@ -1,26 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2019, 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.job.engine.queue.jbatch; - -import org.eclipse.kapua.commons.model.query.KapuaListResultImpl; -import org.eclipse.kapua.job.engine.queue.QueuedJobExecution; -import org.eclipse.kapua.job.engine.queue.QueuedJobExecutionListResult; - -/** - * {@link QueuedJobExecutionListResult} implementation. - * - * @since 1.1.0 - */ -public class QueuedJobExecutionListResultImpl extends KapuaListResultImpl implements QueuedJobExecutionListResult { - -} diff --git a/qa/integration/src/test/java/org/eclipse/kapua/integration/misc/RolePermissionFactoryTest.java b/qa/integration/src/test/java/org/eclipse/kapua/integration/misc/RolePermissionFactoryTest.java index 0c5d9152e5c..6de74c1e466 100644 --- a/qa/integration/src/test/java/org/eclipse/kapua/integration/misc/RolePermissionFactoryTest.java +++ b/qa/integration/src/test/java/org/eclipse/kapua/integration/misc/RolePermissionFactoryTest.java @@ -12,12 +12,13 @@ *******************************************************************************/ package org.eclipse.kapua.integration.misc; +import java.util.Date; + import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.qa.markers.junit.JUnitTests; import org.eclipse.kapua.service.authorization.permission.shiro.PermissionImpl; import org.eclipse.kapua.service.authorization.role.RolePermission; import org.eclipse.kapua.service.authorization.role.RolePermissionCreator; -import org.eclipse.kapua.service.authorization.role.RolePermissionListResult; import org.eclipse.kapua.service.authorization.role.RolePermissionQuery; import org.eclipse.kapua.service.authorization.role.shiro.RolePermissionFactoryImpl; import org.junit.Assert; @@ -26,9 +27,6 @@ import org.junit.experimental.categories.Category; import org.mockito.Mockito; -import java.util.Date; - - @Category(JUnitTests.class) public class RolePermissionFactoryTest { @@ -91,12 +89,6 @@ public void newQueryNullTest() { Assert.assertNull("Null expected.", rolePermissionFactoryImpl.newQuery(null).getScopeId()); } - @Test - public void newListResultTest() { - Assert.assertTrue("True expected.", rolePermissionFactoryImpl.newListResult() instanceof RolePermissionListResult); - Assert.assertTrue("True expected.", rolePermissionFactoryImpl.newListResult().isEmpty()); - } - @Test public void cloneTest() { RolePermission resultRolePermission = rolePermissionFactoryImpl.clone(rolePermission); diff --git a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/DeviceManagementAssets.java b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/DeviceManagementAssets.java index a3e12cc6f7d..ea256b9ced7 100644 --- a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/DeviceManagementAssets.java +++ b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/DeviceManagementAssets.java @@ -12,6 +12,18 @@ *******************************************************************************/ package org.eclipse.kapua.app.api.resources.v1.resources; +import javax.inject.Inject; +import javax.ws.rs.DefaultValue; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.app.api.core.model.EntityId; import org.eclipse.kapua.app.api.core.model.ScopeId; @@ -25,18 +37,6 @@ import org.eclipse.kapua.service.device.management.asset.store.settings.DeviceAssetStoreSettings; import org.eclipse.kapua.service.device.registry.Device; -import javax.inject.Inject; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - @Path("{scopeId}/devices/{deviceId}/assets") public class DeviceManagementAssets extends AbstractKapuaResource { @@ -50,34 +50,42 @@ public class DeviceManagementAssets extends AbstractKapuaResource { /** * Returns the list of all the Assets configured on the device. * - * @param scopeId The {@link ScopeId} of the {@link Device}. - * @param deviceId The id of the device - * @param timeout The timeout of the operation in milliseconds + * @param scopeId + * The {@link ScopeId} of the {@link Device}. + * @param deviceId + * The id of the device + * @param timeout + * The timeout of the operation in milliseconds * @return The list of Assets - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @GET - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public DeviceAssets get( @PathParam("scopeId") ScopeId scopeId, @PathParam("deviceId") EntityId deviceId, @QueryParam("timeout") @DefaultValue("30000") Long timeout) throws KapuaException { - return get(scopeId, deviceId, timeout, deviceAssetFilter.newAssetListResult()); + return get(scopeId, deviceId, timeout, new DeviceAssets()); } /** * Returns the list of all the Assets configured on the device filtered by the {@link DeviceAssets} parameter. * - * @param scopeId The {@link ScopeId} of the {@link Device}. - * @param deviceId The id of the device - * @param timeout The timeout of the operation in milliseconds + * @param scopeId + * The {@link ScopeId} of the {@link Device}. + * @param deviceId + * The id of the device + * @param timeout + * The timeout of the operation in milliseconds * @return The list of Assets - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @POST - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public DeviceAssets get( @PathParam("scopeId") ScopeId scopeId, @PathParam("deviceId") EntityId deviceId, @@ -89,16 +97,20 @@ public DeviceAssets get( /** * Reads {@link DeviceAssetChannel}s values available on the device filtered by the {@link DeviceAssets} parameter. * - * @param scopeId The {@link ScopeId} of the {@link Device}. - * @param deviceId The id of the device - * @param timeout The timeout of the operation in milliseconds + * @param scopeId + * The {@link ScopeId} of the {@link Device}. + * @param deviceId + * The id of the device + * @param timeout + * The timeout of the operation in milliseconds * @return The list of Assets - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @POST @Path("_read") - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public DeviceAssets read( @PathParam("scopeId") ScopeId scopeId, @PathParam("deviceId") EntityId deviceId, @@ -110,16 +122,20 @@ public DeviceAssets read( /** * Writes {@link DeviceAssetChannel}s configured on the device filtered by the {@link DeviceAssets} parameter. * - * @param scopeId The {@link ScopeId} of the {@link Device}. - * @param deviceId The id of the device - * @param timeout The timeout of the operation in milliseconds + * @param scopeId + * The {@link ScopeId} of the {@link Device}. + * @param deviceId + * The id of the device + * @param timeout + * The timeout of the operation in milliseconds * @return The list of Assets - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @POST @Path("_write") - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public DeviceAssets write( @PathParam("scopeId") ScopeId scopeId, @PathParam("deviceId") EntityId deviceId, @@ -130,7 +146,7 @@ public DeviceAssets write( @GET @Path("_settings") - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public DeviceAssetStoreSettings getSettings( @PathParam("scopeId") ScopeId scopeId, @PathParam("deviceId") EntityId deviceId) @@ -140,7 +156,7 @@ public DeviceAssetStoreSettings getSettings( @PUT @Path("_settings") - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public Response postSettings( @PathParam("scopeId") ScopeId scopeId, @PathParam("deviceId") EntityId deviceId, diff --git a/service/account/api/src/main/java/org/eclipse/kapua/service/account/AccountFactory.java b/service/account/api/src/main/java/org/eclipse/kapua/service/account/AccountFactory.java index 81ee1ba3ba5..9e2a0d806ad 100644 --- a/service/account/api/src/main/java/org/eclipse/kapua/service/account/AccountFactory.java +++ b/service/account/api/src/main/java/org/eclipse/kapua/service/account/AccountFactory.java @@ -21,13 +21,15 @@ * @see KapuaEntityFactory * @since 1.0.0 */ -public interface AccountFactory extends KapuaEntityFactory { +public interface AccountFactory extends KapuaEntityFactory { /** * Instantiates a new {@link AccountCreator} with the given name. * - * @param scopeId The scope {@link KapuaId} to set in the {@link AccountCreator} - * @param name The name to set in the {@link AccountCreator} + * @param scopeId + * The scope {@link KapuaId} to set in the {@link AccountCreator} + * @param name + * The name to set in the {@link AccountCreator} * @return The newly instantiated {@link AccountCreator} * @since 1.0.0 * @deprecated Since 1.6.0. Please make use of {@link #newCreator(KapuaId)} and then use {@link AccountCreator#setName(String)}. diff --git a/service/account/api/src/main/java/org/eclipse/kapua/service/account/AccountListResult.java b/service/account/api/src/main/java/org/eclipse/kapua/service/account/AccountListResult.java index 2a722a816d7..e6802552b7c 100644 --- a/service/account/api/src/main/java/org/eclipse/kapua/service/account/AccountListResult.java +++ b/service/account/api/src/main/java/org/eclipse/kapua/service/account/AccountListResult.java @@ -12,14 +12,13 @@ *******************************************************************************/ package org.eclipse.kapua.service.account; -import org.eclipse.kapua.model.query.KapuaListResult; -import org.eclipse.kapua.service.account.xml.AccountXmlRegistry; - import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import org.eclipse.kapua.model.query.KapuaListResult; + /** * {@link Account} {@link KapuaListResult} definition. * @@ -28,7 +27,9 @@ */ @XmlRootElement(name = "accountListResult") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = AccountXmlRegistry.class, factoryMethod = "newAccountListResult") -public interface AccountListResult extends KapuaListResult { +@XmlType +public class AccountListResult extends KapuaListResult { + + private static final long serialVersionUID = -5118004898345748297L; } diff --git a/service/account/api/src/main/java/org/eclipse/kapua/service/account/xml/AccountXmlRegistry.java b/service/account/api/src/main/java/org/eclipse/kapua/service/account/xml/AccountXmlRegistry.java index c18879dfbeb..08ea6672fee 100644 --- a/service/account/api/src/main/java/org/eclipse/kapua/service/account/xml/AccountXmlRegistry.java +++ b/service/account/api/src/main/java/org/eclipse/kapua/service/account/xml/AccountXmlRegistry.java @@ -12,16 +12,15 @@ *******************************************************************************/ package org.eclipse.kapua.service.account.xml; +import javax.xml.bind.annotation.XmlRegistry; + import org.eclipse.kapua.locator.KapuaLocator; import org.eclipse.kapua.service.account.Account; import org.eclipse.kapua.service.account.AccountCreator; import org.eclipse.kapua.service.account.AccountFactory; -import org.eclipse.kapua.service.account.AccountListResult; import org.eclipse.kapua.service.account.AccountQuery; import org.eclipse.kapua.service.account.Organization; -import javax.xml.bind.annotation.XmlRegistry; - /** * {@link Account} xml factory class * @@ -53,16 +52,6 @@ public AccountCreator newAccountCreator() { return factory.newCreator(null); } - /** - * Instantiates a new {@link AccountListResult}. - * - * @return The newly instantiated {@link AccountListResult}. - * @since 1.0.0 - */ - public AccountListResult newAccountListResult() { - return factory.newListResult(); - } - /** * Instantiates a new {@link AccountQuery}. * diff --git a/service/account/internal/src/main/java/org/eclipse/kapua/service/account/internal/AccountFactoryImpl.java b/service/account/internal/src/main/java/org/eclipse/kapua/service/account/internal/AccountFactoryImpl.java index 947da2ca339..39a2399496f 100644 --- a/service/account/internal/src/main/java/org/eclipse/kapua/service/account/internal/AccountFactoryImpl.java +++ b/service/account/internal/src/main/java/org/eclipse/kapua/service/account/internal/AccountFactoryImpl.java @@ -12,17 +12,16 @@ *******************************************************************************/ package org.eclipse.kapua.service.account.internal; +import javax.inject.Singleton; + import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.account.Account; import org.eclipse.kapua.service.account.AccountCreator; import org.eclipse.kapua.service.account.AccountFactory; -import org.eclipse.kapua.service.account.AccountListResult; import org.eclipse.kapua.service.account.AccountQuery; import org.eclipse.kapua.service.account.Organization; -import javax.inject.Singleton; - /** * {@link AccountFactory} implementation. * @@ -58,11 +57,6 @@ public AccountQuery newQuery(KapuaId scopeId) { return new AccountQueryImpl(scopeId); } - @Override - public AccountListResult newListResult() { - return new AccountListResultImpl(); - } - @Override public Account clone(Account account) { try { diff --git a/service/account/internal/src/main/java/org/eclipse/kapua/service/account/internal/AccountImplJpaRepository.java b/service/account/internal/src/main/java/org/eclipse/kapua/service/account/internal/AccountImplJpaRepository.java index 123d2691720..40eaad6d959 100644 --- a/service/account/internal/src/main/java/org/eclipse/kapua/service/account/internal/AccountImplJpaRepository.java +++ b/service/account/internal/src/main/java/org/eclipse/kapua/service/account/internal/AccountImplJpaRepository.java @@ -12,6 +12,9 @@ *******************************************************************************/ package org.eclipse.kapua.service.account.internal; +import javax.persistence.EntityManager; +import javax.persistence.TypedQuery; + import org.eclipse.kapua.commons.jpa.JpaAwareTxContext; import org.eclipse.kapua.commons.jpa.KapuaJpaRepositoryConfiguration; import org.eclipse.kapua.commons.jpa.KapuaNamedEntityJpaRepository; @@ -20,15 +23,12 @@ import org.eclipse.kapua.service.account.AccountRepository; import org.eclipse.kapua.storage.TxContext; -import javax.persistence.EntityManager; -import javax.persistence.TypedQuery; - public class AccountImplJpaRepository extends KapuaNamedEntityJpaRepository implements AccountRepository { public AccountImplJpaRepository(KapuaJpaRepositoryConfiguration jpaRepoConfig) { - super(AccountImpl.class, Account.TYPE, () -> new AccountListResultImpl(), jpaRepoConfig); + super(AccountImpl.class, Account.TYPE, () -> new AccountListResult(), jpaRepoConfig); } @Override diff --git a/service/account/internal/src/main/java/org/eclipse/kapua/service/account/internal/AccountListResultImpl.java b/service/account/internal/src/main/java/org/eclipse/kapua/service/account/internal/AccountListResultImpl.java deleted file mode 100644 index 34d05856e03..00000000000 --- a/service/account/internal/src/main/java/org/eclipse/kapua/service/account/internal/AccountListResultImpl.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * 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.service.account.internal; - -import org.eclipse.kapua.commons.model.query.KapuaListResultImpl; -import org.eclipse.kapua.service.account.Account; -import org.eclipse.kapua.service.account.AccountListResult; - -/** - * {@link AccountListResult} implementation. - * - * @since 1.0.0 - */ -public class AccountListResultImpl extends KapuaListResultImpl implements AccountListResult { - - private static final long serialVersionUID = -5118004898345748297L; -} diff --git a/service/api/src/main/java/org/eclipse/kapua/model/KapuaEntityFactory.java b/service/api/src/main/java/org/eclipse/kapua/model/KapuaEntityFactory.java index 9ff2033129b..c2475140c7b 100644 --- a/service/api/src/main/java/org/eclipse/kapua/model/KapuaEntityFactory.java +++ b/service/api/src/main/java/org/eclipse/kapua/model/KapuaEntityFactory.java @@ -14,24 +14,26 @@ import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.model.query.KapuaListResult; import org.eclipse.kapua.model.query.KapuaQuery; /** * {@link KapuaEntityFactory} definition. * - * @param The {@link KapuaEntity} for which this {@link KapuaEntityFactory} is for. - * @param The {@link KapuaEntityCreator} for which this {@link KapuaEntityFactory} is for. - * @param The {@link KapuaQuery} for which this {@link KapuaEntityFactory} is for. - * @param The {@link KapuaListResult} for which this {@link KapuaEntityFactory} is for. + * @param + * The {@link KapuaEntity} for which this {@link KapuaEntityFactory} is for. + * @param + * The {@link KapuaEntityCreator} for which this {@link KapuaEntityFactory} is for. + * @param + * The {@link KapuaQuery} for which this {@link KapuaEntityFactory} is for. * @since 1.0.0 */ -public interface KapuaEntityFactory, Q extends KapuaQuery, L extends KapuaListResult> extends KapuaObjectFactory { +public interface KapuaEntityFactory, Q extends KapuaQuery> extends KapuaObjectFactory { /** * Instantiates a new {@link KapuaEntity}. * - * @param scopeId The scope {@link KapuaId} to be set in the {@link KapuaEntity} + * @param scopeId + * The scope {@link KapuaId} to be set in the {@link KapuaEntity} * @return The newly instantiated {@link KapuaEntity} * @since 1.0.0 */ @@ -40,7 +42,8 @@ public interface KapuaEntityFactory {@link KapuaEntity} type. + * @param + * {@link KapuaEntity} type. * @since 1.0.0 */ @XmlRootElement(name = "result") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(propOrder = {"limitExceeded", "size", "items", "totalCount"}) -public interface KapuaListResult extends KapuaSerializable { +@XmlType(propOrder = { "limitExceeded", "size", "items", "totalCount" }) +public class KapuaListResult implements KapuaSerializable { + + private static final long serialVersionUID = 8939666089540269261L; + + private ArrayList items; + private boolean limitExceeded; + private Long totalCount; + + /** + * Constructor. + * + * @since 1.0.0 + */ + public KapuaListResult() { + limitExceeded = false; + } /** * Gets the limit exceeded flag. *

    - * This flag is {@code true} if there are more results that exceded the {@link KapuaQuery#getLimit()}. - * Increasing the {@link KapuaQuery#getLimit()} or moving the {@link KapuaQuery#getOffset()} will return more results + * This flag is {@code true} if there are more results that exceded the {@link KapuaQuery#getLimit()}. Increasing the {@link KapuaQuery#getLimit()} or moving the {@link KapuaQuery#getOffset()} + * will return more results * * @return The limit exceeded flag * @since 1.0.0 */ @XmlElement(name = "limitExceeded") - boolean isLimitExceeded(); + public boolean isLimitExceeded() { + return limitExceeded; + } /** * Sets the limit exceeded flag. *

    * To be set to {@code true} if the {@link KapuaQuery} matching elements are more than {@link KapuaQuery#getLimit()}. * - * @param limitExceeded The limit exceeded flag. + * @param limitExceeded + * The limit exceeded flag. * @since 1.0.0 */ - void setLimitExceeded(boolean limitExceeded); + public void setLimitExceeded(boolean limitExceeded) { + this.limitExceeded = limitExceeded; + } /** * Gets the {@link KapuaEntity}s that matched the {@link KapuaQuery#getPredicate()}. @@ -72,55 +95,77 @@ public interface KapuaListResult extends KapuaSerializabl */ @XmlElementWrapper(name = "items") @XmlElement(name = "item") - List getItems(); + public List getItems() { + if (items == null) { + items = new ArrayList<>(); + } + + return items; + } /** * Gets the {@link KapuaEntity}s that matched the {@link KapuaQuery#getPredicate()} and applies even more filtering. *

    * This is meant to be used to filter result when is not possible to do so with {@link KapuaQuery#getPredicate()}s. * - * @param filter The filter to apply to select results. + * @param filter + * The filter to apply to select results. * @return The filtered {@link KapuaEntity}s that matched the {@link KapuaQuery#getPredicate()}. * @since 2.0.0 */ - List getItems(@NotNull Predicate filter); + public List getItems(Predicate filter) { + return getItems().stream().filter(filter).collect(Collectors.toList()); + } /** - * Gets a {@link Map} whose {@link Map#keySet()} are generated from the given {@link Map.Entry#getKey()} mapper {@link Function}. - * The {@link Map#values()} are the {@link KapuaEntity}s themself. + * Gets a {@link Map} whose {@link Map#keySet()} are generated from the given {@link Map.Entry#getKey()} mapper {@link Function}. The {@link Map#values()} are the {@link KapuaEntity}s themself. *

    * This is like invoking {@link #getItemsAsMap(Function, Function)} whose value mapper returns the {@link KapuaEntity} itself. * - * @param keyMapper The {@link Function} which defines the {@link Map.Entry#getKey()} for each {@link Map.Entry} - * @param The type of the {@link Map.Entry#getKey()} + * @param keyMapper + * The {@link Function} which defines the {@link Map.Entry#getKey()} for each {@link Map.Entry} + * @param + * The type of the {@link Map.Entry#getKey()} * @return The {@link Map} generated according to the mapping {@link Map.Entry#getKey()} {@link Function}. * @since 2.0.0 */ - Map getItemsAsMap(@NotNull Function keyMapper); + public Map getItemsAsMap(Function keyMapper) { + return getItems().stream().collect(Collectors.toMap(keyMapper, e -> e)); + } /** - * Gets a {@link Map} whose {@link Map#keySet()} are generated from the given {@link Map.Entry#getKey()} mapper {@link Function}. - * The {@link Map#values()} are generated from the given {@link Map.Entry#getValue()} mapper {@link Function}. + * Gets a {@link Map} whose {@link Map#keySet()} are generated from the given {@link Map.Entry#getKey()} mapper {@link Function}. The {@link Map#values()} are generated from the given + * {@link Map.Entry#getValue()} mapper {@link Function}. * - * @param keyMapper The {@link Function} which defines the {@link Map.Entry#getKey()} for each {@link Map.Entry} - * @param valueMapper The {@link Function} which defines the {@link Map.Entry#getValue()} for each {@link Map.Entry} - * @param The type of the {@link Map.Entry#getKey()} - * @param The type of the {@link Map.Entry#getValue()} + * @param keyMapper + * The {@link Function} which defines the {@link Map.Entry#getKey()} for each {@link Map.Entry} + * @param valueMapper + * The {@link Function} which defines the {@link Map.Entry#getValue()} for each {@link Map.Entry} + * @param + * The type of the {@link Map.Entry#getKey()} + * @param + * The type of the {@link Map.Entry#getValue()} * @return The {@link Map} generated according to the mapping {@link Function}s. * @since 2.0.0 */ - Map getItemsAsMap(@NotNull Function keyMapper, @NotNull Function valueMapper); + public Map getItemsAsMap(Function keyMapper, Function valueMapper) { + return getItems().stream().collect(Collectors.toMap(keyMapper, valueMapper)); + } /** * Gets the {@link KapuaEntity} at the given position in the {@link KapuaListResult}. * - * @param i The position in the {@link KapuaListResult} + * @param index + * The position in the {@link KapuaListResult} * @return The {@link KapuaEntity} at the position - * @throws IndexOutOfBoundsException If position is not available. + * @throws IndexOutOfBoundsException + * If position is not available. * @see List#get(int) * @since 1.0.0 */ - E getItem(int i); + public E getItem(int index) { + return getItems().get(index); + } /** * Gets the first {@link KapuaEntity} in the {@link KapuaListResult}. @@ -130,7 +175,9 @@ public interface KapuaListResult extends KapuaSerializabl * @return The first element in the {@link KapuaListResult} or {@code null} if not present. * @since 1.0.0 */ - E getFirstItem(); + public E getFirstItem() { + return this.isEmpty() ? null : getItem(0); + } /** * Gets the result {@link KapuaListResult} size @@ -140,7 +187,9 @@ public interface KapuaListResult extends KapuaSerializabl * @since 1.0.0 */ @XmlElement(name = "size") - int getSize(); + public int getSize() { + return getItems().size(); + } /** * Checks if the result {@link KapuaListResult} is empty @@ -149,23 +198,31 @@ public interface KapuaListResult extends KapuaSerializabl * @see List#isEmpty() * @since 1.0.0 */ - boolean isEmpty(); + public boolean isEmpty() { + return getItems().isEmpty(); + } /** * Adds {@link KapuaEntity}s to the result {@link KapuaListResult} * - * @param items The {@link KapuaEntity}s to add. + * @param items + * The {@link KapuaEntity}s to add. * @see List#addAll(Collection) * @since 1.0.0 */ - void addItems(@NotNull Collection items); + public void addItems(Collection items) { + getItems().addAll(items); + } /** * Adds a {@link KapuaEntity} to the {@link KapuaListResult}. * - * @param item The {@link KapuaEntity} to add. + * @param item + * The {@link KapuaEntity} to add. */ - void addItem(@NotNull E item); + public void addItem(E item) { + getItems().add(item); + } /** * Clears {@link KapuaEntity} result {@link KapuaListResult} @@ -173,17 +230,22 @@ public interface KapuaListResult extends KapuaSerializabl * @see List#clear() * @since 1.0.0 */ - void clearItems(); + public void clearItems() { + getItems().clear(); + } /** * Sorts the result {@link List} according to the given {@link Comparator}. * - * @param comparator The {@link Comparator} used to compare items. + * @param comparator + * The {@link Comparator} used to compare items. * @see List#sort(Comparator) * @see Comparator * @since 1.0.0 */ - void sort(@NotNull Comparator comparator); + public void sort(Comparator comparator) { + getItems().sort(comparator); + } /** * Gets the total count of entries that match the {@link KapuaQuery#getPredicate()}s regardless of {@link KapuaQuery#getLimit()} and {@link KapuaQuery#getOffset()} @@ -191,12 +253,16 @@ public interface KapuaListResult extends KapuaSerializabl * @return The total count * @since 1.2.0 */ - Long getTotalCount(); + public Long getTotalCount() { + return totalCount; + } /** * Sets the total count of entries that match the {@link KapuaQuery#getPredicate()}s regardless of {@link KapuaQuery#getLimit()} and {@link KapuaQuery#getOffset()}. * * @since 1.2.0 */ - void setTotalCount(Long totalCount); + public void setTotalCount(Long totalCount) { + this.totalCount = totalCount; + } } diff --git a/service/datastore/internal/src/main/java/org/eclipse/kapua/service/datastore/internal/model/ChannelInfoListResultImpl.java b/service/datastore/internal/src/main/java/org/eclipse/kapua/service/datastore/internal/model/ChannelInfoListResultImpl.java index 30ed498d629..94786a11658 100644 --- a/service/datastore/internal/src/main/java/org/eclipse/kapua/service/datastore/internal/model/ChannelInfoListResultImpl.java +++ b/service/datastore/internal/src/main/java/org/eclipse/kapua/service/datastore/internal/model/ChannelInfoListResultImpl.java @@ -14,7 +14,6 @@ import org.eclipse.kapua.service.datastore.model.ChannelInfo; import org.eclipse.kapua.service.datastore.model.ChannelInfoListResult; -import org.eclipse.kapua.service.elasticsearch.client.model.ResultList; import org.eclipse.kapua.service.storable.model.AbstractStorableListResult; /** @@ -24,25 +23,4 @@ */ public class ChannelInfoListResultImpl extends AbstractStorableListResult implements ChannelInfoListResult { - private static final long serialVersionUID = 1L; - - /** - * Constructor. - * - * @since 1.0.0 - */ - public ChannelInfoListResultImpl() { - super(); - } - - /** - * Constructor. - * - * @param resultList The {@link ResultList} to add. - * @since 1.0.0 - */ - public ChannelInfoListResultImpl(ResultList resultList) { - super(resultList.getResult(), resultList.getTotalCount()); - } - } diff --git a/service/device/management/asset/api/src/main/java/org/eclipse/kapua/service/device/management/asset/DeviceAssetFactory.java b/service/device/management/asset/api/src/main/java/org/eclipse/kapua/service/device/management/asset/DeviceAssetFactory.java index 2898dc9e806..ccef9ce5087 100644 --- a/service/device/management/asset/api/src/main/java/org/eclipse/kapua/service/device/management/asset/DeviceAssetFactory.java +++ b/service/device/management/asset/api/src/main/java/org/eclipse/kapua/service/device/management/asset/DeviceAssetFactory.java @@ -22,14 +22,6 @@ */ public interface DeviceAssetFactory extends KapuaObjectFactory { - /** - * Instantiates a new {@link DeviceAssets} instance. - * - * @return The newly instantiated {@link DeviceAssets}. - * @since 1.0.0 - */ - DeviceAssets newAssetListResult(); - /** * Instantiates a new {@link DeviceAsset} instance. * diff --git a/service/device/management/asset/api/src/main/java/org/eclipse/kapua/service/device/management/asset/DeviceAssetXmlRegistry.java b/service/device/management/asset/api/src/main/java/org/eclipse/kapua/service/device/management/asset/DeviceAssetXmlRegistry.java index 3756d7c6ae8..73d5e2b2d2c 100644 --- a/service/device/management/asset/api/src/main/java/org/eclipse/kapua/service/device/management/asset/DeviceAssetXmlRegistry.java +++ b/service/device/management/asset/api/src/main/java/org/eclipse/kapua/service/device/management/asset/DeviceAssetXmlRegistry.java @@ -12,10 +12,10 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.management.asset; -import org.eclipse.kapua.locator.KapuaLocator; - import javax.xml.bind.annotation.XmlRegistry; +import org.eclipse.kapua.locator.KapuaLocator; + /** * {@link DeviceAsset} XML factory class * @@ -26,16 +26,6 @@ public class DeviceAssetXmlRegistry { private final DeviceAssetFactory deviceAssetFactory = KapuaLocator.getInstance().getFactory(DeviceAssetFactory.class); - /** - * Instantiate a new {@link DeviceAssets}. - * - * @return The newly instantiate {@link DeviceAssets}. - * @since 1.0.0 - */ - public DeviceAssets newAssetListResult() { - return deviceAssetFactory.newAssetListResult(); - } - /** * Instantiate a new {@link DeviceAsset}. * diff --git a/service/device/management/asset/api/src/main/java/org/eclipse/kapua/service/device/management/asset/DeviceAssets.java b/service/device/management/asset/api/src/main/java/org/eclipse/kapua/service/device/management/asset/DeviceAssets.java index c5519a59607..5cd77306707 100644 --- a/service/device/management/asset/api/src/main/java/org/eclipse/kapua/service/device/management/asset/DeviceAssets.java +++ b/service/device/management/asset/api/src/main/java/org/eclipse/kapua/service/device/management/asset/DeviceAssets.java @@ -12,14 +12,16 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.management.asset; -import org.eclipse.kapua.KapuaSerializable; +import java.util.ArrayList; +import java.util.List; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; -import java.util.List; + +import org.eclipse.kapua.KapuaSerializable; /** * {@link DeviceAssets} definition. @@ -28,8 +30,12 @@ */ @XmlRootElement(name = "deviceAssets") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = DeviceAssetXmlRegistry.class, factoryMethod = "newAssetListResult") -public interface DeviceAssets extends KapuaSerializable { +@XmlType +public class DeviceAssets implements KapuaSerializable { + + private static final long serialVersionUID = -6657213220333406876L; + + private List assets; /** * Get the {@link DeviceAsset} {@link List} @@ -38,13 +44,22 @@ public interface DeviceAssets extends KapuaSerializable { * @since 1.0.0 */ @XmlElement(name = "deviceAsset") - List getAssets(); + public List getAssets() { + if (assets == null) { + assets = new ArrayList<>(); + } + + return assets; + } /** * Sets the {@link DeviceAsset} {@link List}. * - * @param assets The {@link DeviceAsset} {@link List}. + * @param assets + * The {@link DeviceAsset} {@link List}. * @since 1.0.0 */ - void setAssets(List assets); + public void setAssets(List assets) { + this.assets = assets; + } } diff --git a/service/device/management/asset/internal/src/main/java/org/eclipse/kapua/service/device/management/asset/internal/DeviceAssetFactoryImpl.java b/service/device/management/asset/internal/src/main/java/org/eclipse/kapua/service/device/management/asset/internal/DeviceAssetFactoryImpl.java index 50dc4e9a9b7..5dc8cff6e00 100644 --- a/service/device/management/asset/internal/src/main/java/org/eclipse/kapua/service/device/management/asset/internal/DeviceAssetFactoryImpl.java +++ b/service/device/management/asset/internal/src/main/java/org/eclipse/kapua/service/device/management/asset/internal/DeviceAssetFactoryImpl.java @@ -12,12 +12,11 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.management.asset.internal; +import javax.inject.Singleton; + import org.eclipse.kapua.service.device.management.asset.DeviceAsset; import org.eclipse.kapua.service.device.management.asset.DeviceAssetChannel; import org.eclipse.kapua.service.device.management.asset.DeviceAssetFactory; -import org.eclipse.kapua.service.device.management.asset.DeviceAssets; - -import javax.inject.Singleton; /** * {@link DeviceAssetFactory} implementation. @@ -27,11 +26,6 @@ @Singleton public class DeviceAssetFactoryImpl implements DeviceAssetFactory { - @Override - public DeviceAssets newAssetListResult() { - return new DeviceAssetsImpl(); - } - @Override public DeviceAsset newDeviceAsset() { return new DeviceAssetImpl(); diff --git a/service/device/management/asset/internal/src/main/java/org/eclipse/kapua/service/device/management/asset/internal/DeviceAssetManagementServiceImpl.java b/service/device/management/asset/internal/src/main/java/org/eclipse/kapua/service/device/management/asset/internal/DeviceAssetManagementServiceImpl.java index a0ef5363703..2b50eed84e8 100644 --- a/service/device/management/asset/internal/src/main/java/org/eclipse/kapua/service/device/management/asset/internal/DeviceAssetManagementServiceImpl.java +++ b/service/device/management/asset/internal/src/main/java/org/eclipse/kapua/service/device/management/asset/internal/DeviceAssetManagementServiceImpl.java @@ -12,6 +12,10 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.management.asset.internal; +import java.util.Date; + +import javax.inject.Singleton; + import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.commons.model.domains.Domains; import org.eclipse.kapua.commons.util.ArgumentValidator; @@ -39,9 +43,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.inject.Singleton; -import java.util.Date; - /** * {@link DeviceAssetManagementService} implementation. * @@ -126,7 +127,7 @@ public DeviceAssets get(KapuaId scopeId, KapuaId deviceId, DeviceAssets deviceAs // Create event createDeviceEvent(scopeId, deviceId, assetRequestMessage, responseMessage); // Check response - DeviceAssets onlineDeviceAssets = checkResponseAcceptedOrThrowError(responseMessage, () -> responseMessage.getPayload().getDeviceAssets().orElse(deviceAssetFactory.newAssetListResult())); + DeviceAssets onlineDeviceAssets = checkResponseAcceptedOrThrowError(responseMessage, () -> responseMessage.getPayload().getDeviceAssets().orElse(new DeviceAssets())); // Store value and return if (deviceAssetStoreService.isServiceEnabled(scopeId) && deviceAssetStoreService.isApplicationEnabled(scopeId, deviceId)) { @@ -192,7 +193,7 @@ public DeviceAssets read(KapuaId scopeId, KapuaId deviceId, DeviceAssets deviceA // Create event createDeviceEvent(scopeId, deviceId, assetRequestMessage, responseMessage); // Check response - DeviceAssets onlineDeviceAssets = checkResponseAcceptedOrThrowError(responseMessage, () -> responseMessage.getPayload().getDeviceAssets().orElse(deviceAssetFactory.newAssetListResult())); + DeviceAssets onlineDeviceAssets = checkResponseAcceptedOrThrowError(responseMessage, () -> responseMessage.getPayload().getDeviceAssets().orElse(new DeviceAssets())); // Store value and return if (deviceAssetStoreService.isServiceEnabled(scopeId) && deviceAssetStoreService.isApplicationEnabled(scopeId, deviceId)) { @@ -258,6 +259,6 @@ public DeviceAssets write(KapuaId scopeId, KapuaId deviceId, DeviceAssets device // Create event createDeviceEvent(scopeId, deviceId, assetRequestMessage, responseMessage); // Check response - return checkResponseAcceptedOrThrowError(responseMessage, () -> responseMessage.getPayload().getDeviceAssets().orElse(deviceAssetFactory.newAssetListResult())); + return checkResponseAcceptedOrThrowError(responseMessage, () -> responseMessage.getPayload().getDeviceAssets().orElse(new DeviceAssets())); } } diff --git a/service/device/management/asset/internal/src/main/java/org/eclipse/kapua/service/device/management/asset/internal/DeviceAssetsImpl.java b/service/device/management/asset/internal/src/main/java/org/eclipse/kapua/service/device/management/asset/internal/DeviceAssetsImpl.java deleted file mode 100644 index 997e09c0bf5..00000000000 --- a/service/device/management/asset/internal/src/main/java/org/eclipse/kapua/service/device/management/asset/internal/DeviceAssetsImpl.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * 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.service.device.management.asset.internal; - -import org.eclipse.kapua.service.device.management.asset.DeviceAsset; -import org.eclipse.kapua.service.device.management.asset.DeviceAssets; - -import java.util.ArrayList; -import java.util.List; - -/** - * {@link DeviceAssets} implementation. - * - * @since 1.0.0 - */ -public class DeviceAssetsImpl implements DeviceAssets { - - private static final long serialVersionUID = -6657213220333406876L; - - private List assets; - - @Override - public List getAssets() { - if (assets == null) { - assets = new ArrayList<>(); - } - - return assets; - } - - @Override - public void setAssets(List assets) { - this.assets = assets; - } -} diff --git a/service/device/management/job/api/src/main/java/org/eclipse/kapua/service/device/management/job/JobDeviceManagementOperationFactory.java b/service/device/management/job/api/src/main/java/org/eclipse/kapua/service/device/management/job/JobDeviceManagementOperationFactory.java index e44a31feee6..c125842e2ed 100644 --- a/service/device/management/job/api/src/main/java/org/eclipse/kapua/service/device/management/job/JobDeviceManagementOperationFactory.java +++ b/service/device/management/job/api/src/main/java/org/eclipse/kapua/service/device/management/job/JobDeviceManagementOperationFactory.java @@ -19,6 +19,6 @@ * * @since 1.1.0 */ -public interface JobDeviceManagementOperationFactory extends KapuaEntityFactory { +public interface JobDeviceManagementOperationFactory extends KapuaEntityFactory { } diff --git a/service/device/management/job/api/src/main/java/org/eclipse/kapua/service/device/management/job/JobDeviceManagementOperationListResult.java b/service/device/management/job/api/src/main/java/org/eclipse/kapua/service/device/management/job/JobDeviceManagementOperationListResult.java index c7c8afb6642..5a8855a82d8 100644 --- a/service/device/management/job/api/src/main/java/org/eclipse/kapua/service/device/management/job/JobDeviceManagementOperationListResult.java +++ b/service/device/management/job/api/src/main/java/org/eclipse/kapua/service/device/management/job/JobDeviceManagementOperationListResult.java @@ -12,13 +12,13 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.management.job; -import org.eclipse.kapua.model.query.KapuaListResult; - import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import org.eclipse.kapua.model.query.KapuaListResult; + /** * {@link JobDeviceManagementOperationListResult} definition. * @@ -26,7 +26,7 @@ */ @XmlRootElement(name = "jobDeviceManagementOperationListResult") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = JobDeviceManagementOperationXmlRegistry.class, factoryMethod = "newJobDeviceManagementOperationListResult") -public interface JobDeviceManagementOperationListResult extends KapuaListResult { +@XmlType +public class JobDeviceManagementOperationListResult extends KapuaListResult { } diff --git a/service/device/management/job/api/src/main/java/org/eclipse/kapua/service/device/management/job/JobDeviceManagementOperationXmlRegistry.java b/service/device/management/job/api/src/main/java/org/eclipse/kapua/service/device/management/job/JobDeviceManagementOperationXmlRegistry.java index 604a0f8d1d0..f9b2513eb14 100644 --- a/service/device/management/job/api/src/main/java/org/eclipse/kapua/service/device/management/job/JobDeviceManagementOperationXmlRegistry.java +++ b/service/device/management/job/api/src/main/java/org/eclipse/kapua/service/device/management/job/JobDeviceManagementOperationXmlRegistry.java @@ -12,10 +12,10 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.management.job; -import org.eclipse.kapua.locator.KapuaLocator; - import javax.xml.bind.annotation.XmlRegistry; +import org.eclipse.kapua.locator.KapuaLocator; + /** * {@link JobDeviceManagementOperation} xml factory class * @@ -34,10 +34,6 @@ public JobDeviceManagementOperationCreator newJobDeviceManagementOperationCreato return jobDeviceManagementOperationFactory.newCreator(null); } - public JobDeviceManagementOperationListResult newJobDeviceManagementOperationListResult() { - return jobDeviceManagementOperationFactory.newListResult(); - } - public JobDeviceManagementOperationQuery newQuery() { return jobDeviceManagementOperationFactory.newQuery(null); } diff --git a/service/device/management/job/internal/src/main/java/org/eclipse/kapua/service/device/management/job/internal/JobDeviceManagementOperationFactoryImpl.java b/service/device/management/job/internal/src/main/java/org/eclipse/kapua/service/device/management/job/internal/JobDeviceManagementOperationFactoryImpl.java index cbd204575e2..3db27bf80c4 100644 --- a/service/device/management/job/internal/src/main/java/org/eclipse/kapua/service/device/management/job/internal/JobDeviceManagementOperationFactoryImpl.java +++ b/service/device/management/job/internal/src/main/java/org/eclipse/kapua/service/device/management/job/internal/JobDeviceManagementOperationFactoryImpl.java @@ -12,16 +12,15 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.management.job.internal; +import javax.inject.Singleton; + import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.device.management.job.JobDeviceManagementOperation; import org.eclipse.kapua.service.device.management.job.JobDeviceManagementOperationCreator; import org.eclipse.kapua.service.device.management.job.JobDeviceManagementOperationFactory; -import org.eclipse.kapua.service.device.management.job.JobDeviceManagementOperationListResult; import org.eclipse.kapua.service.device.management.job.JobDeviceManagementOperationQuery; -import javax.inject.Singleton; - /** * {@link JobDeviceManagementOperationFactory} implementation. * @@ -45,11 +44,6 @@ public JobDeviceManagementOperationQuery newQuery(KapuaId scopeId) { return new JobDeviceManagementOperationQueryImpl(scopeId); } - @Override - public JobDeviceManagementOperationListResult newListResult() { - return new JobDeviceManagementOperationListResultImpl(); - } - @Override public JobDeviceManagementOperation clone(JobDeviceManagementOperation jobDeviceManagementOperation) { try { diff --git a/service/device/management/job/internal/src/main/java/org/eclipse/kapua/service/device/management/job/internal/JobDeviceManagementOperationImplJpaRepository.java b/service/device/management/job/internal/src/main/java/org/eclipse/kapua/service/device/management/job/internal/JobDeviceManagementOperationImplJpaRepository.java index dbd24d8cefb..68198b09322 100644 --- a/service/device/management/job/internal/src/main/java/org/eclipse/kapua/service/device/management/job/internal/JobDeviceManagementOperationImplJpaRepository.java +++ b/service/device/management/job/internal/src/main/java/org/eclipse/kapua/service/device/management/job/internal/JobDeviceManagementOperationImplJpaRepository.java @@ -21,7 +21,8 @@ public class JobDeviceManagementOperationImplJpaRepository extends KapuaUpdatableEntityJpaRepository implements JobDeviceManagementOperationRepository { + public JobDeviceManagementOperationImplJpaRepository(KapuaJpaRepositoryConfiguration jpaRepoConfig) { - super(JobDeviceManagementOperationImpl.class, JobDeviceManagementOperation.TYPE, () -> new JobDeviceManagementOperationListResultImpl(), jpaRepoConfig); + super(JobDeviceManagementOperationImpl.class, JobDeviceManagementOperation.TYPE, () -> new JobDeviceManagementOperationListResult(), jpaRepoConfig); } } diff --git a/service/device/management/job/internal/src/main/java/org/eclipse/kapua/service/device/management/job/internal/JobDeviceManagementOperationListResultImpl.java b/service/device/management/job/internal/src/main/java/org/eclipse/kapua/service/device/management/job/internal/JobDeviceManagementOperationListResultImpl.java deleted file mode 100644 index cfd1a91eaf7..00000000000 --- a/service/device/management/job/internal/src/main/java/org/eclipse/kapua/service/device/management/job/internal/JobDeviceManagementOperationListResultImpl.java +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2019, 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.service.device.management.job.internal; - -import org.eclipse.kapua.commons.model.query.KapuaListResultImpl; -import org.eclipse.kapua.service.device.management.job.JobDeviceManagementOperation; -import org.eclipse.kapua.service.device.management.job.JobDeviceManagementOperationListResult; - -/** - * {@link JobDeviceManagementOperationListResult} implementation. - * - * @since 1.1.0 - */ -public class JobDeviceManagementOperationListResultImpl extends KapuaListResultImpl implements JobDeviceManagementOperationListResult { -} diff --git a/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/DeviceManagementOperationFactory.java b/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/DeviceManagementOperationFactory.java index 157f43cab15..bb1a7c27f9f 100644 --- a/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/DeviceManagementOperationFactory.java +++ b/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/DeviceManagementOperationFactory.java @@ -20,14 +20,17 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface DeviceManagementOperationFactory extends KapuaEntityFactory { +public interface DeviceManagementOperationFactory extends KapuaEntityFactory { /** * Instantiates a new {@link DeviceManagementOperationProperty}. * - * @param name The name to set in the {@link DeviceManagementOperationProperty} - * @param propertyType The property type to set in the {@link DeviceManagementOperationProperty} - * @param propertyValue The property value to set in the {@link DeviceManagementOperationProperty} + * @param name + * The name to set in the {@link DeviceManagementOperationProperty} + * @param propertyType + * The property type to set in the {@link DeviceManagementOperationProperty} + * @param propertyValue + * The property value to set in the {@link DeviceManagementOperationProperty} * @return The newly instantiated {@link DeviceManagementOperationProperty} * @since 1.0.0 */ diff --git a/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/DeviceManagementOperationListResult.java b/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/DeviceManagementOperationListResult.java index 303304154d3..377b61fb8a6 100644 --- a/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/DeviceManagementOperationListResult.java +++ b/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/DeviceManagementOperationListResult.java @@ -12,13 +12,13 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.management.registry.operation; -import org.eclipse.kapua.model.query.KapuaListResult; - import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import org.eclipse.kapua.model.query.KapuaListResult; + /** * {@link DeviceManagementOperationListResult} definition. * @@ -26,7 +26,7 @@ */ @XmlRootElement(name = "deviceManagementOperationListResult") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = DeviceManagementOperationXmlRegistry.class, factoryMethod = "newDeviceManagementOperationListResult") -public interface DeviceManagementOperationListResult extends KapuaListResult { +@XmlType +public class DeviceManagementOperationListResult extends KapuaListResult { } diff --git a/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/DeviceManagementOperationXmlRegistry.java b/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/DeviceManagementOperationXmlRegistry.java index 42f4859e536..827c836a9ac 100644 --- a/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/DeviceManagementOperationXmlRegistry.java +++ b/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/DeviceManagementOperationXmlRegistry.java @@ -12,10 +12,10 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.management.registry.operation; -import org.eclipse.kapua.locator.KapuaLocator; - import javax.xml.bind.annotation.XmlRegistry; +import org.eclipse.kapua.locator.KapuaLocator; + /** * {@link DeviceManagementOperation} xml factory class * @@ -35,10 +35,6 @@ DeviceManagementOperationCreator newDeviceManagementOperationCreator() { return factory.newCreator(null); } - DeviceManagementOperationListResult newDeviceManagementOperationListResult() { - return factory.newListResult(); - } - DeviceManagementOperationQuery newQuery() { return factory.newQuery(null); } diff --git a/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/ManagementOperationNotificationFactory.java b/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/ManagementOperationNotificationFactory.java index b1c814e7366..8e8a3761efb 100644 --- a/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/ManagementOperationNotificationFactory.java +++ b/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/ManagementOperationNotificationFactory.java @@ -20,6 +20,6 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface ManagementOperationNotificationFactory extends KapuaEntityFactory { +public interface ManagementOperationNotificationFactory extends KapuaEntityFactory { } diff --git a/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/ManagementOperationNotificationListResult.java b/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/ManagementOperationNotificationListResult.java index bc28b4ce399..6060a034194 100644 --- a/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/ManagementOperationNotificationListResult.java +++ b/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/ManagementOperationNotificationListResult.java @@ -12,13 +12,13 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.management.registry.operation.notification; -import org.eclipse.kapua.model.query.KapuaListResult; - import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import org.eclipse.kapua.model.query.KapuaListResult; + /** * {@link ManagementOperationNotificationListResult} definition. * @@ -26,7 +26,7 @@ */ @XmlRootElement(name = "managementOperationNotificationListResult") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = ManagementOperationNotificationXmlRegistry.class, factoryMethod = "newManagementOperationNotificationListResult") -public interface ManagementOperationNotificationListResult extends KapuaListResult { +@XmlType +public class ManagementOperationNotificationListResult extends KapuaListResult { } diff --git a/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/ManagementOperationNotificationXmlRegistry.java b/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/ManagementOperationNotificationXmlRegistry.java index 8e9ad286ab4..f98b3685674 100644 --- a/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/ManagementOperationNotificationXmlRegistry.java +++ b/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/ManagementOperationNotificationXmlRegistry.java @@ -12,10 +12,10 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.management.registry.operation.notification; -import org.eclipse.kapua.locator.KapuaLocator; - import javax.xml.bind.annotation.XmlRegistry; +import org.eclipse.kapua.locator.KapuaLocator; + /** * {@link ManagementOperationNotification} xml MANAGEMENT_OPERATION_NOTIFICATION_REGISTRY_FACTORY class * @@ -34,11 +34,6 @@ ManagementOperationNotificationCreator newManagementOperationNotificationCreator return managementOperationNotificationFactory.newCreator(null); } - - ManagementOperationNotificationListResult newManagementOperationNotificationListResult() { - return managementOperationNotificationFactory.newListResult(); - } - ManagementOperationNotificationQuery newQuery() { return managementOperationNotificationFactory.newQuery(null); } diff --git a/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/internal/DeviceManagementOperationFactoryImpl.java b/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/internal/DeviceManagementOperationFactoryImpl.java index 3f1802d340d..d9a977b8528 100644 --- a/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/internal/DeviceManagementOperationFactoryImpl.java +++ b/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/internal/DeviceManagementOperationFactoryImpl.java @@ -12,17 +12,16 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.management.registry.operation.internal; +import javax.inject.Singleton; + import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.device.management.registry.operation.DeviceManagementOperation; import org.eclipse.kapua.service.device.management.registry.operation.DeviceManagementOperationCreator; import org.eclipse.kapua.service.device.management.registry.operation.DeviceManagementOperationFactory; -import org.eclipse.kapua.service.device.management.registry.operation.DeviceManagementOperationListResult; import org.eclipse.kapua.service.device.management.registry.operation.DeviceManagementOperationProperty; import org.eclipse.kapua.service.device.management.registry.operation.DeviceManagementOperationQuery; -import javax.inject.Singleton; - /** * {@link DeviceManagementOperationFactory} implementation * @@ -46,11 +45,6 @@ public DeviceManagementOperationQuery newQuery(KapuaId scopeId) { return new DeviceManagementOperationQueryImpl(scopeId); } - @Override - public DeviceManagementOperationListResult newListResult() { - return new DeviceManagementOperationListResultImpl(); - } - @Override public DeviceManagementOperationProperty newStepProperty(String name, String propertyType, String propertyValue) { return new DeviceManagementOperationPropertyImpl(name, propertyType, propertyValue); diff --git a/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/internal/DeviceManagementOperationListResultImpl.java b/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/internal/DeviceManagementOperationListResultImpl.java deleted file mode 100644 index 70231c167da..00000000000 --- a/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/internal/DeviceManagementOperationListResultImpl.java +++ /dev/null @@ -1,26 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017, 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.service.device.management.registry.operation.internal; - -import org.eclipse.kapua.commons.model.query.KapuaListResultImpl; -import org.eclipse.kapua.service.device.management.registry.operation.DeviceManagementOperation; -import org.eclipse.kapua.service.device.management.registry.operation.DeviceManagementOperationListResult; - -/** - * {@link DeviceManagementOperationListResultImpl} definition. - * - * @since 1.0.0 - */ -public class DeviceManagementOperationListResultImpl extends KapuaListResultImpl implements DeviceManagementOperationListResult { - -} diff --git a/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/internal/DeviceManagementOperationRepositoryImplJpaRepository.java b/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/internal/DeviceManagementOperationRepositoryImplJpaRepository.java index 0912d291a5a..32914d8fbfd 100644 --- a/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/internal/DeviceManagementOperationRepositoryImplJpaRepository.java +++ b/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/internal/DeviceManagementOperationRepositoryImplJpaRepository.java @@ -12,6 +12,8 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.management.registry.operation.internal; +import java.util.Optional; + import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.commons.jpa.KapuaJpaRepositoryConfiguration; import org.eclipse.kapua.commons.jpa.KapuaUpdatableEntityJpaRepository; @@ -21,13 +23,12 @@ import org.eclipse.kapua.service.device.management.registry.operation.DeviceManagementOperationRepository; import org.eclipse.kapua.storage.TxContext; -import java.util.Optional; - public class DeviceManagementOperationRepositoryImplJpaRepository extends KapuaUpdatableEntityJpaRepository implements DeviceManagementOperationRepository { + public DeviceManagementOperationRepositoryImplJpaRepository(KapuaJpaRepositoryConfiguration jpaRepoConfig) { - super(DeviceManagementOperationImpl.class, DeviceManagementOperation.TYPE, () -> new DeviceManagementOperationListResultImpl(), jpaRepoConfig); + super(DeviceManagementOperationImpl.class, DeviceManagementOperation.TYPE, () -> new DeviceManagementOperationListResult(), jpaRepoConfig); } @Override diff --git a/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/internal/ManagementOperationNotificationFactoryImpl.java b/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/internal/ManagementOperationNotificationFactoryImpl.java index a6303dc87c9..5140ad1768b 100644 --- a/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/internal/ManagementOperationNotificationFactoryImpl.java +++ b/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/internal/ManagementOperationNotificationFactoryImpl.java @@ -12,15 +12,14 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.management.registry.operation.notification.internal; +import javax.inject.Singleton; + import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.device.management.registry.operation.notification.ManagementOperationNotification; import org.eclipse.kapua.service.device.management.registry.operation.notification.ManagementOperationNotificationCreator; import org.eclipse.kapua.service.device.management.registry.operation.notification.ManagementOperationNotificationFactory; -import org.eclipse.kapua.service.device.management.registry.operation.notification.ManagementOperationNotificationListResult; import org.eclipse.kapua.service.device.management.registry.operation.notification.ManagementOperationNotificationQuery; -import javax.inject.Singleton; - /** * {@link ManagementOperationNotificationFactory} implementation. * @@ -44,11 +43,6 @@ public ManagementOperationNotificationQuery newQuery(KapuaId scopeId) { return new ManagementOperationNotificationQueryImpl(scopeId); } - @Override - public ManagementOperationNotificationListResult newListResult() { - return new ManagementOperationNotificationListResultImpl(); - } - @Override public ManagementOperationNotification clone(ManagementOperationNotification managementOperationNotification) { return new ManagementOperationNotificationImpl(managementOperationNotification); diff --git a/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/internal/ManagementOperationNotificationImplJpaRepository.java b/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/internal/ManagementOperationNotificationImplJpaRepository.java index 0851913ef21..48e3e245194 100644 --- a/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/internal/ManagementOperationNotificationImplJpaRepository.java +++ b/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/internal/ManagementOperationNotificationImplJpaRepository.java @@ -21,7 +21,8 @@ public class ManagementOperationNotificationImplJpaRepository extends KapuaEntityJpaRepository implements ManagementOperationNotificationRepository { + public ManagementOperationNotificationImplJpaRepository(KapuaJpaRepositoryConfiguration configuration) { - super(ManagementOperationNotificationImpl.class, ManagementOperationNotification.TYPE, () -> new ManagementOperationNotificationListResultImpl(), configuration); + super(ManagementOperationNotificationImpl.class, ManagementOperationNotification.TYPE, () -> new ManagementOperationNotificationListResult(), configuration); } } diff --git a/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/internal/ManagementOperationNotificationListResultImpl.java b/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/internal/ManagementOperationNotificationListResultImpl.java deleted file mode 100644 index 55063328ae2..00000000000 --- a/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/internal/ManagementOperationNotificationListResultImpl.java +++ /dev/null @@ -1,26 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017, 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.service.device.management.registry.operation.notification.internal; - -import org.eclipse.kapua.commons.model.query.KapuaListResultImpl; -import org.eclipse.kapua.service.device.management.registry.operation.notification.ManagementOperationNotification; -import org.eclipse.kapua.service.device.management.registry.operation.notification.ManagementOperationNotificationListResult; - -/** - * {@link ManagementOperationNotificationListResultImpl} definition. - * - * @since 1.0.0 - */ -public class ManagementOperationNotificationListResultImpl extends KapuaListResultImpl implements ManagementOperationNotificationListResult { - -} diff --git a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/DeviceFactory.java b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/DeviceFactory.java index 6a526e6d7b5..6960844892b 100644 --- a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/DeviceFactory.java +++ b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/DeviceFactory.java @@ -21,13 +21,15 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface DeviceFactory extends KapuaEntityFactory { +public interface DeviceFactory extends KapuaEntityFactory { /** * Instantiates a new {@link DeviceCreator} * - * @param scopeId The scope {@link KapuaId} to set into the {@link DeviceCreator} - * @param clientId The client id to set into the {@link DeviceCreator} + * @param scopeId + * The scope {@link KapuaId} to set into the {@link DeviceCreator} + * @param clientId + * The client id to set into the {@link DeviceCreator} * @return The newly instantiated {@link DeviceCreator}. * @since 1.0.0 * @deprecated Since 1.5.0. Please use {@link #newCreator(KapuaId)}. @@ -38,9 +40,12 @@ public interface DeviceFactory extends KapuaEntityFactory { +@XmlType +public class DeviceListResult extends KapuaListResult { + + private static final long serialVersionUID = -3870951363076544938L; } diff --git a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/DeviceXmlRegistry.java b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/DeviceXmlRegistry.java index 573905a636b..36f44928f1d 100644 --- a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/DeviceXmlRegistry.java +++ b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/DeviceXmlRegistry.java @@ -12,10 +12,10 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.registry; -import org.eclipse.kapua.locator.KapuaLocator; - import javax.xml.bind.annotation.XmlRegistry; +import org.eclipse.kapua.locator.KapuaLocator; + /** * {@link Device} xml factory class * @@ -46,16 +46,6 @@ public DeviceCreator newDeviceCreator() { return deviceFactory.newCreator(null, null); } - /** - * Creates a new device list result - * - * @return - * @since 1.0.0 - */ - public DeviceListResult newDeviceListResult() { - return deviceFactory.newListResult(); - } - public DeviceQuery newQuery() { return deviceFactory.newQuery(null); } diff --git a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/DeviceConnectionFactory.java b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/DeviceConnectionFactory.java index f2340123de1..a19a31be804 100644 --- a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/DeviceConnectionFactory.java +++ b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/DeviceConnectionFactory.java @@ -20,6 +20,6 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface DeviceConnectionFactory extends KapuaEntityFactory { +public interface DeviceConnectionFactory extends KapuaEntityFactory { } diff --git a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/DeviceConnectionListResult.java b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/DeviceConnectionListResult.java index e37886dcaa6..5203c40b686 100644 --- a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/DeviceConnectionListResult.java +++ b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/DeviceConnectionListResult.java @@ -23,6 +23,8 @@ * @since 1.0 */ @XmlRootElement(name = "deviceConnections") -@XmlType(factoryClass = DeviceConnectionXmlRegistry.class, factoryMethod = "newDeviceConnectionListResult") -public interface DeviceConnectionListResult extends KapuaListResult { +@XmlType +public class DeviceConnectionListResult extends KapuaListResult { + + private static final long serialVersionUID = -4450707993798807403L; } diff --git a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/DeviceConnectionXmlRegistry.java b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/DeviceConnectionXmlRegistry.java index b4812c01608..d9b01446c9f 100644 --- a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/DeviceConnectionXmlRegistry.java +++ b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/DeviceConnectionXmlRegistry.java @@ -12,10 +12,10 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.registry.connection; -import org.eclipse.kapua.locator.KapuaLocator; - import javax.xml.bind.annotation.XmlRegistry; +import org.eclipse.kapua.locator.KapuaLocator; + /** * {@link DeviceConnection} xml factory class * @@ -35,15 +35,6 @@ public DeviceConnection newDeviceConnection() { return deviceConnectionFactory.newEntity(null); } - /** - * Creates a new device list result - * - * @return - */ - public DeviceConnectionListResult newDeviceConnectionListResult() { - return deviceConnectionFactory.newListResult(); - } - public DeviceConnectionQuery newQuery() { return deviceConnectionFactory.newQuery(null); } diff --git a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/DeviceConnectionOptionFactory.java b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/DeviceConnectionOptionFactory.java index 231671e4ec2..2c5ee017b0a 100644 --- a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/DeviceConnectionOptionFactory.java +++ b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/DeviceConnectionOptionFactory.java @@ -20,6 +20,6 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface DeviceConnectionOptionFactory extends KapuaEntityFactory { +public interface DeviceConnectionOptionFactory extends KapuaEntityFactory { } diff --git a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/DeviceConnectionOptionListResult.java b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/DeviceConnectionOptionListResult.java index 35281032b68..cefbaaf77ac 100644 --- a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/DeviceConnectionOptionListResult.java +++ b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/DeviceConnectionOptionListResult.java @@ -23,6 +23,8 @@ * @since 1.0.0 */ @XmlRootElement(name = "deviceConnectionOptions") -@XmlType(factoryClass = DeviceConnectionOptionXmlRegistry.class, factoryMethod = "newDeviceConnectionOptionListResult") -public interface DeviceConnectionOptionListResult extends KapuaListResult { +@XmlType +public class DeviceConnectionOptionListResult extends KapuaListResult { + + private static final long serialVersionUID = -4450707993798807403L; } diff --git a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/DeviceConnectionOptionXmlRegistry.java b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/DeviceConnectionOptionXmlRegistry.java index c2da267c5a2..39c5b6fbf7d 100644 --- a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/DeviceConnectionOptionXmlRegistry.java +++ b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/DeviceConnectionOptionXmlRegistry.java @@ -12,10 +12,10 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.registry.connection.option; -import org.eclipse.kapua.locator.KapuaLocator; - import javax.xml.bind.annotation.XmlRegistry; +import org.eclipse.kapua.locator.KapuaLocator; + /** * {@link DeviceConnectionOptionService} XML factory class * @@ -35,15 +35,6 @@ public DeviceConnectionOption newDeviceConnectionOption() { return deviceConnectionOptionFactory.newEntity(null); } - /** - * Creates a new device connection options list result - * - * @return - */ - public DeviceConnectionOptionListResult newDeviceConnectionOptionListResult() { - return deviceConnectionOptionFactory.newListResult(); - } - public DeviceConnectionOptionQuery newQuery() { return deviceConnectionOptionFactory.newQuery(null); } diff --git a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/event/DeviceEventFactory.java b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/event/DeviceEventFactory.java index f6bd2fe9d1e..8ec7d44c5a8 100644 --- a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/event/DeviceEventFactory.java +++ b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/event/DeviceEventFactory.java @@ -12,26 +12,30 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.registry.event; +import java.util.Date; + import org.eclipse.kapua.model.KapuaEntityFactory; import org.eclipse.kapua.model.id.KapuaId; -import java.util.Date; - /** * {@link DeviceEventFactory} definition. * * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface DeviceEventFactory extends KapuaEntityFactory { +public interface DeviceEventFactory extends KapuaEntityFactory { /** * Instantiates a new {@link DeviceEventCreator} * - * @param scopeId The scope {@link KapuaId} to be set in the {@link DeviceEventCreator} - * @param deviceId The {@link org.eclipse.kapua.service.device.registry.Device} {@link KapuaId} to be set in the {@link DeviceEventCreator} - * @param receivedOn The received on {@link KapuaId} to be set in the {@link DeviceEventCreator} - * @param resource The resource {@link KapuaId} to be set in the {@link DeviceEventCreator} + * @param scopeId + * The scope {@link KapuaId} to be set in the {@link DeviceEventCreator} + * @param deviceId + * The {@link org.eclipse.kapua.service.device.registry.Device} {@link KapuaId} to be set in the {@link DeviceEventCreator} + * @param receivedOn + * The received on {@link KapuaId} to be set in the {@link DeviceEventCreator} + * @param resource + * The resource {@link KapuaId} to be set in the {@link DeviceEventCreator} * @return The newly instantiated {@link DeviceEventCreator} * @since 1.0.0 */ diff --git a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/event/DeviceEventListResult.java b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/event/DeviceEventListResult.java index a15cf87c0c4..6e834d0ccb3 100644 --- a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/event/DeviceEventListResult.java +++ b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/event/DeviceEventListResult.java @@ -23,11 +23,12 @@ * Device event list definition. * * @since 1.0 - * */ @XmlRootElement(name = "deviceEventListResult") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = DeviceEventXmlRegistry.class, factoryMethod = "newDeviceEventListResult") -public interface DeviceEventListResult extends KapuaListResult { +@XmlType +public class DeviceEventListResult extends KapuaListResult { + + private static final long serialVersionUID = 6537888946643944463L; } diff --git a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/event/DeviceEventXmlRegistry.java b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/event/DeviceEventXmlRegistry.java index ca95c3f14eb..aff51f6f7ef 100644 --- a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/event/DeviceEventXmlRegistry.java +++ b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/event/DeviceEventXmlRegistry.java @@ -12,10 +12,10 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.registry.event; -import org.eclipse.kapua.locator.KapuaLocator; - import javax.xml.bind.annotation.XmlRegistry; +import org.eclipse.kapua.locator.KapuaLocator; + /** * {@link DeviceEvent} xml factory class. * @@ -35,15 +35,6 @@ public DeviceEvent newDeviceEvent() { return deviceEventFactory.newEntity(null); } - /** - * Creates a new device event list result - * - * @return - */ - public DeviceEventListResult newDeviceEventListResult() { - return deviceEventFactory.newListResult(); - } - public DeviceEventQuery newQuery() { return deviceEventFactory.newQuery(null); } diff --git a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/internal/DeviceConnectionFactoryImpl.java b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/internal/DeviceConnectionFactoryImpl.java index 2cfb367a158..d1c1f083156 100644 --- a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/internal/DeviceConnectionFactoryImpl.java +++ b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/internal/DeviceConnectionFactoryImpl.java @@ -12,16 +12,15 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.registry.connection.internal; +import javax.inject.Singleton; + import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.device.registry.connection.DeviceConnection; import org.eclipse.kapua.service.device.registry.connection.DeviceConnectionCreator; import org.eclipse.kapua.service.device.registry.connection.DeviceConnectionFactory; -import org.eclipse.kapua.service.device.registry.connection.DeviceConnectionListResult; import org.eclipse.kapua.service.device.registry.connection.DeviceConnectionQuery; -import javax.inject.Singleton; - /** * {@link DeviceConnectionFactory} implementation. * @@ -45,11 +44,6 @@ public DeviceConnection newEntity(KapuaId scopeId) { return new DeviceConnectionImpl(scopeId); } - @Override - public DeviceConnectionListResult newListResult() { - return new DeviceConnectionListResultImpl(); - } - @Override public DeviceConnection clone(DeviceConnection deviceConnection) { try { diff --git a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/internal/DeviceConnectionImplJpaRepository.java b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/internal/DeviceConnectionImplJpaRepository.java index 43a5329bcff..2dd44dedb61 100644 --- a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/internal/DeviceConnectionImplJpaRepository.java +++ b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/internal/DeviceConnectionImplJpaRepository.java @@ -28,7 +28,7 @@ public class DeviceConnectionImplJpaRepository implements DeviceConnectionRepository { public DeviceConnectionImplJpaRepository(KapuaJpaRepositoryConfiguration jpaRepoConfig) { - super(DeviceConnectionImpl.class, DeviceConnection.TYPE, () -> new DeviceConnectionListResultImpl(), jpaRepoConfig); + super(DeviceConnectionImpl.class, DeviceConnection.TYPE, () -> new DeviceConnectionListResult(), jpaRepoConfig); } @Override diff --git a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/internal/DeviceConnectionListResultImpl.java b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/internal/DeviceConnectionListResultImpl.java deleted file mode 100644 index c8414fe0915..00000000000 --- a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/internal/DeviceConnectionListResultImpl.java +++ /dev/null @@ -1,26 +0,0 @@ -/******************************************************************************* - * 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.service.device.registry.connection.internal; - -import org.eclipse.kapua.commons.model.query.KapuaListResultImpl; -import org.eclipse.kapua.service.device.registry.connection.DeviceConnection; -import org.eclipse.kapua.service.device.registry.connection.DeviceConnectionListResult; - -/** - * Device connection list. - * - * @since 1.0 - */ -public class DeviceConnectionListResultImpl extends KapuaListResultImpl implements DeviceConnectionListResult { - private static final long serialVersionUID = -4450707993798807403L; -} diff --git a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/internal/DeviceConnectionOptionFactoryImpl.java b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/internal/DeviceConnectionOptionFactoryImpl.java index cc6a3a70378..fb9249787ad 100644 --- a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/internal/DeviceConnectionOptionFactoryImpl.java +++ b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/internal/DeviceConnectionOptionFactoryImpl.java @@ -12,16 +12,15 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.registry.connection.option.internal; +import javax.inject.Singleton; + import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.device.registry.connection.option.DeviceConnectionOption; import org.eclipse.kapua.service.device.registry.connection.option.DeviceConnectionOptionCreator; import org.eclipse.kapua.service.device.registry.connection.option.DeviceConnectionOptionFactory; -import org.eclipse.kapua.service.device.registry.connection.option.DeviceConnectionOptionListResult; import org.eclipse.kapua.service.device.registry.connection.option.DeviceConnectionOptionQuery; -import javax.inject.Singleton; - /** * {@link DeviceConnectionOptionFactory} implementation. * @@ -45,11 +44,6 @@ public DeviceConnectionOption newEntity(KapuaId scopeId) { return new DeviceConnectionOptionImpl(scopeId); } - @Override - public DeviceConnectionOptionListResult newListResult() { - return new DeviceConnectionOptionListResultImpl(); - } - @Override public DeviceConnectionOption clone(DeviceConnectionOption deviceConnectionOption) { try { diff --git a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/internal/DeviceConnectionOptionImplJpaRepository.java b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/internal/DeviceConnectionOptionImplJpaRepository.java index 63375409a5a..930c2344323 100644 --- a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/internal/DeviceConnectionOptionImplJpaRepository.java +++ b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/internal/DeviceConnectionOptionImplJpaRepository.java @@ -21,7 +21,8 @@ public class DeviceConnectionOptionImplJpaRepository extends KapuaUpdatableEntityJpaRepository implements DeviceConnectionOptionRepository { + public DeviceConnectionOptionImplJpaRepository(KapuaJpaRepositoryConfiguration jpaRepoConfig) { - super(DeviceConnectionOptionImpl.class, DeviceConnectionOption.TYPE, () -> new DeviceConnectionOptionListResultImpl(), jpaRepoConfig); + super(DeviceConnectionOptionImpl.class, DeviceConnectionOption.TYPE, () -> new DeviceConnectionOptionListResult(), jpaRepoConfig); } } diff --git a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/internal/DeviceConnectionOptionListResultImpl.java b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/internal/DeviceConnectionOptionListResultImpl.java deleted file mode 100644 index 002d804adcb..00000000000 --- a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/internal/DeviceConnectionOptionListResultImpl.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * 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.service.device.registry.connection.option.internal; - -import org.eclipse.kapua.commons.model.query.KapuaListResultImpl; -import org.eclipse.kapua.service.device.registry.connection.option.DeviceConnectionOption; -import org.eclipse.kapua.service.device.registry.connection.option.DeviceConnectionOptionListResult; - -/** - * Device connection options list. - * - * @since 1.0.0 - */ -public class DeviceConnectionOptionListResultImpl extends KapuaListResultImpl implements DeviceConnectionOptionListResult { - - private static final long serialVersionUID = -4450707993798807403L; -} diff --git a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/event/internal/DeviceEventFactoryImpl.java b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/event/internal/DeviceEventFactoryImpl.java index 223cc0e63d6..1011a7d50f4 100644 --- a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/event/internal/DeviceEventFactoryImpl.java +++ b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/event/internal/DeviceEventFactoryImpl.java @@ -12,17 +12,17 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.registry.event.internal; +import java.util.Date; + +import javax.inject.Singleton; + import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.device.management.message.KapuaMethod; import org.eclipse.kapua.service.device.registry.event.DeviceEvent; import org.eclipse.kapua.service.device.registry.event.DeviceEventCreator; import org.eclipse.kapua.service.device.registry.event.DeviceEventFactory; -import org.eclipse.kapua.service.device.registry.event.DeviceEventListResult; import org.eclipse.kapua.service.device.registry.event.DeviceEventQuery; -import javax.inject.Singleton; -import java.util.Date; - /** * {@link DeviceEventFactory} implementation. * @@ -58,11 +58,6 @@ public DeviceEventCreator newCreator(KapuaId scopeId) { return new DeviceEventCreatorImpl(scopeId); } - @Override - public DeviceEventListResult newListResult() { - return new DeviceEventListResultImpl(); - } - @Override public DeviceEvent clone(DeviceEvent deviceEvent) { return new DeviceEventImpl(deviceEvent); diff --git a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/event/internal/DeviceEventImplJpaRepository.java b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/event/internal/DeviceEventImplJpaRepository.java index f77f26fadd7..4ff3d01f411 100644 --- a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/event/internal/DeviceEventImplJpaRepository.java +++ b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/event/internal/DeviceEventImplJpaRepository.java @@ -21,7 +21,8 @@ public class DeviceEventImplJpaRepository extends KapuaEntityJpaRepository implements DeviceEventRepository { + public DeviceEventImplJpaRepository(KapuaJpaRepositoryConfiguration configuration) { - super(DeviceEventImpl.class, DeviceEvent.TYPE, () -> new DeviceEventListResultImpl(), configuration); + super(DeviceEventImpl.class, DeviceEvent.TYPE, () -> new DeviceEventListResult(), configuration); } } diff --git a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/event/internal/DeviceEventListResultImpl.java b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/event/internal/DeviceEventListResultImpl.java deleted file mode 100644 index aba3659c2d0..00000000000 --- a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/event/internal/DeviceEventListResultImpl.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * 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.service.device.registry.event.internal; - -import org.eclipse.kapua.commons.model.query.KapuaListResultImpl; -import org.eclipse.kapua.service.device.registry.event.DeviceEvent; -import org.eclipse.kapua.service.device.registry.event.DeviceEventListResult; - -/** - * Device event list. - * - * @since 1.0 - */ -public class DeviceEventListResultImpl extends KapuaListResultImpl implements DeviceEventListResult { - - private static final long serialVersionUID = 6537888946643944463L; -} diff --git a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/internal/DeviceFactoryImpl.java b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/internal/DeviceFactoryImpl.java index 70524bf2ba0..b4483e0f333 100644 --- a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/internal/DeviceFactoryImpl.java +++ b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/internal/DeviceFactoryImpl.java @@ -12,17 +12,16 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.registry.internal; +import javax.inject.Singleton; + import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.device.registry.Device; import org.eclipse.kapua.service.device.registry.DeviceCreator; import org.eclipse.kapua.service.device.registry.DeviceExtendedProperty; import org.eclipse.kapua.service.device.registry.DeviceFactory; -import org.eclipse.kapua.service.device.registry.DeviceListResult; import org.eclipse.kapua.service.device.registry.DeviceQuery; -import javax.inject.Singleton; - /** * {@link DeviceFactory} implementation. * @@ -43,11 +42,6 @@ public DeviceQuery newQuery(KapuaId scopeId) { return new DeviceQueryImpl(scopeId); } - @Override - public DeviceListResult newListResult() { - return new DeviceListResultImpl(); - } - @Override public Device newEntity(KapuaId scopeId) { return new DeviceImpl(scopeId); diff --git a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/internal/DeviceImplJpaRepository.java b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/internal/DeviceImplJpaRepository.java index 2be2228b60a..503a877deb1 100644 --- a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/internal/DeviceImplJpaRepository.java +++ b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/internal/DeviceImplJpaRepository.java @@ -12,7 +12,11 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.registry.internal; -import com.google.common.collect.Lists; +import java.util.Optional; + +import javax.persistence.EntityManager; +import javax.persistence.LockModeType; + import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.commons.jpa.JpaAwareTxContext; import org.eclipse.kapua.commons.jpa.KapuaJpaRepositoryConfiguration; @@ -24,15 +28,14 @@ import org.eclipse.kapua.service.device.registry.DeviceRepository; import org.eclipse.kapua.storage.TxContext; -import javax.persistence.EntityManager; -import javax.persistence.LockModeType; -import java.util.Optional; +import com.google.common.collect.Lists; public class DeviceImplJpaRepository extends KapuaUpdatableEntityJpaRepository implements DeviceRepository { + public DeviceImplJpaRepository(KapuaJpaRepositoryConfiguration jpaRepoConfig) { - super(DeviceImpl.class, Device.TYPE, () -> new DeviceListResultImpl(), jpaRepoConfig); + super(DeviceImpl.class, Device.TYPE, () -> new DeviceListResult(), jpaRepoConfig); } @Override diff --git a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/internal/DeviceListResultImpl.java b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/internal/DeviceListResultImpl.java deleted file mode 100644 index 4f3543482cb..00000000000 --- a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/internal/DeviceListResultImpl.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * 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.service.device.registry.internal; - -import org.eclipse.kapua.commons.model.query.KapuaListResultImpl; -import org.eclipse.kapua.service.device.registry.Device; -import org.eclipse.kapua.service.device.registry.DeviceListResult; - -/** - * Device list result implementation. - * - * @since 1.0 - */ -public class DeviceListResultImpl extends KapuaListResultImpl implements DeviceListResult { - - private static final long serialVersionUID = -3870951363076544938L; -} diff --git a/service/device/registry/test-steps/src/main/java/org/eclipse/kapua/service/device/registry/steps/BrokerSteps.java b/service/device/registry/test-steps/src/main/java/org/eclipse/kapua/service/device/registry/steps/BrokerSteps.java index c0e71b9b03b..e6ccc530895 100644 --- a/service/device/registry/test-steps/src/main/java/org/eclipse/kapua/service/device/registry/steps/BrokerSteps.java +++ b/service/device/registry/test-steps/src/main/java/org/eclipse/kapua/service/device/registry/steps/BrokerSteps.java @@ -32,7 +32,6 @@ import org.eclipse.kapua.service.device.management.asset.DeviceAssetChannel; import org.eclipse.kapua.service.device.management.asset.DeviceAssetManagementService; import org.eclipse.kapua.service.device.management.asset.DeviceAssets; -import org.eclipse.kapua.service.device.management.asset.internal.DeviceAssetsImpl; import org.eclipse.kapua.service.device.management.bundle.DeviceBundle; import org.eclipse.kapua.service.device.management.bundle.DeviceBundleManagementService; import org.eclipse.kapua.service.device.management.bundle.DeviceBundles; @@ -72,9 +71,7 @@ import io.cucumber.java.en.When; /** - * Steps used in integration scenarios with running MQTT broker and process of - * registering mocked Kura device registering with Kapua and issuing basic administrative - * commands on Mocked Kura. + * Steps used in integration scenarios with running MQTT broker and process of registering mocked Kura device registering with Kapua and issuing basic administrative commands on Mocked Kura. */ @Singleton public class BrokerSteps extends TestBase { @@ -252,8 +249,10 @@ public void deviceBirthMessage() throws Exception { /** * Checks that the {@link Device} with the given {@link Device#getClientId()} has {@link DeviceConnection#getStatus()} {@link DeviceConnectionStatus#CONNECTED} within the given time. * - * @param clientId The {@link Device#getClientId()} to check - * @param waitSeconds The max time of wait in seconds + * @param clientId + * The {@link Device#getClientId()} to check + * @param waitSeconds + * The max time of wait in seconds * @throws Exception * @since 1.2.0 */ @@ -261,7 +260,7 @@ public void deviceBirthMessage() throws Exception { public void deviceConnected(String clientId, int waitSeconds) throws Exception { long now = System.currentTimeMillis(); - while ((System.currentTimeMillis() - now) < (waitSeconds * 1000L)){ + while ((System.currentTimeMillis() - now) < (waitSeconds * 1000L)) { Device kuraDevice = deviceRegistryService.findByClientId(getCurrentScopeId(), clientId); if (kuraDevice != null && @@ -493,7 +492,6 @@ public void deviceWithServerIp(String serverIp) { Assert.assertEquals(serverIp, deviceConn.getServerIp()); } - @When("Client with name {string} with client id {string} user {string} password {string} is connected") public void clientConnect(String clientName, String clientId, String user, String password) throws Exception { MqttClient mqttClient = null; @@ -570,7 +568,7 @@ public void disconnectConnectionWithClientId(String clientId) throws Exception { @Then("Device(s) status is {string} within {int} second(s) for client id {string}") public void deviceStatusIs(String expectedStatus, int timeout, String clientId) throws Exception { String currentStatus = null; - while(!expectedStatus.equals(currentStatus) && timeout-->0) { + while (!expectedStatus.equals(currentStatus) && timeout-- > 0) { Thread.sleep(1000); logger.info("Device(s) status countdown check: {}", timeout); @@ -619,7 +617,7 @@ public void iAddDeviceToKuraMock(int numberOfDevices) { @And("Device assets are requested") public void deviceAssetsAreRequested() throws Exception { - DeviceAssets deviceAssets = new DeviceAssetsImpl(); + DeviceAssets deviceAssets = new DeviceAssets(); for (KuraDevice kuraDevice : kuraDevices) { Device device = deviceRegistryService.findByClientId(SYS_SCOPE_ID, kuraDevice.getClientId()); Assert.assertNotNull(device); diff --git a/service/device/registry/test-steps/src/main/java/org/eclipse/kapua/service/device/registry/steps/DeviceRegistrySteps.java b/service/device/registry/test-steps/src/main/java/org/eclipse/kapua/service/device/registry/steps/DeviceRegistrySteps.java index a970d78eeff..0f70b334561 100644 --- a/service/device/registry/test-steps/src/main/java/org/eclipse/kapua/service/device/registry/steps/DeviceRegistrySteps.java +++ b/service/device/registry/test-steps/src/main/java/org/eclipse/kapua/service/device/registry/steps/DeviceRegistrySteps.java @@ -23,18 +23,9 @@ import java.util.Set; import java.util.UUID; import java.util.Vector; + import javax.inject.Inject; -import com.google.common.base.Strings; -import com.google.common.collect.Lists; -import com.google.inject.Singleton; -import io.cucumber.java.After; -import io.cucumber.java.Before; -import io.cucumber.java.Scenario; -import io.cucumber.java.en.And; -import io.cucumber.java.en.Given; -import io.cucumber.java.en.Then; -import io.cucumber.java.en.When; import org.apache.commons.lang3.StringUtils; import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.commons.model.id.KapuaEid; @@ -115,12 +106,22 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.google.common.base.Strings; +import com.google.common.collect.Lists; +import com.google.inject.Singleton; + +import io.cucumber.java.After; +import io.cucumber.java.Before; +import io.cucumber.java.Scenario; +import io.cucumber.java.en.And; +import io.cucumber.java.en.Given; +import io.cucumber.java.en.Then; +import io.cucumber.java.en.When; + /** * Implementation of Gherkin steps used in DeviceRegistry.feature scenarios. *

    - * MockedLocator is used for Location Service. Mockito is used to mock other - * services that the Device Registry services dependent on. Dependent services are: - - * Authorization Service - + * MockedLocator is used for Location Service. Mockito is used to mock other services that the Device Registry services dependent on. Dependent services are: - Authorization Service - */ @Singleton public class DeviceRegistrySteps extends TestBase { @@ -178,7 +179,6 @@ public class DeviceRegistrySteps extends TestBase { private DeviceEventService eventService; private DeviceEventFactory eventFactory; - // Additional service references for integration testing private DeviceLifeCycleService deviceLifeCycleService; private AccountService accountService; @@ -391,7 +391,6 @@ public void createDevicesWithParametersAndConnection(List devLst) thr createDevicesAsSpecifiedInternal(devLst, deviceConnection); } - private void createDevicesAsSpecifiedInternal(List cucDevices, DeviceConnection deviceConnection) throws Exception { primeException(); try { @@ -1004,7 +1003,7 @@ public void exerciseAllDeviceFactoryFunctions() { tmpDevice = deviceFactory.newEntity(SYS_SCOPE_ID); tmpCreator = deviceFactory.newCreator(SYS_SCOPE_ID); tmpQuery = deviceFactory.newQuery(SYS_SCOPE_ID); - tmpListRes = deviceFactory.newListResult(); + tmpListRes = new DeviceListResult(); Assert.assertNotNull(tmpDevice); Assert.assertNotNull(tmpCreator); Assert.assertNotNull(tmpQuery); @@ -1071,7 +1070,7 @@ public void createConnections(List cucConnections) throws Excepti DeviceConnectionCreator connectionCreator = null; DeviceConnection deviceConnection = null; - DeviceConnectionListResult deviceConnections = deviceConnectionFactory.newListResult(); + DeviceConnectionListResult deviceConnections = new DeviceConnectionListResult(); for (CucConnection cucConnection : cucConnections) { connectionCreator = deviceConnectionFactory.newCreator(scopeId); @@ -1083,7 +1082,8 @@ public void createConnections(List cucConnections) throws Excepti connectionCreator.setServerIp(cucConnection.getServerIp()); connectionCreator.setProtocol(cucConnection.getProtocol()); connectionCreator.setAllowUserChange(false); - connectionCreator.setAuthenticationType(deviceConnectionService.getAvailableAuthTypes().stream().findFirst().orElseThrow(() -> new IllegalStateException("No DeviceConnection authenticationTypes are available for testing"))); + connectionCreator.setAuthenticationType(deviceConnectionService.getAvailableAuthTypes().stream().findFirst() + .orElseThrow(() -> new IllegalStateException("No DeviceConnection authenticationTypes are available for testing"))); deviceConnection = deviceConnectionService.create(connectionCreator); deviceConnections.addItem(deviceConnection); } @@ -1613,14 +1613,14 @@ public void checkEventList(int number) throws Exception { private void printEvents(DeviceEventListResult eventList, int count) throws Exception { logger.info("Events size: {}", eventList.getSize()); eventList.getItems().forEach((event) -> logger.info("\ttype: {} - id: {} - date: {} - {}", event.getType(), event.getDeviceId(), event.getCreatedOn(), event.getEventMessage())); -// if (count > eventList.getSize()) { -// logger.info("++++++++++++++++++++++++++++++++++++++++++++++++\n===========================================================\n\n"); -// Thread.sleep(30000); -// searchForEventsFromDeviceWithClientID("rpione3", "kapua-sys" ); -// eventList = (DeviceEventListResult) stepData.get(DEVICE_EVENT_LIST); -// eventList.getItems().forEach((event) -> logger.info("\ttype: {} - id: {} - date: {} - {}", event.getType(), event.getDeviceId(), event.getCreatedOn(), event.getEventMessage())); -// logger.info("++++++++++++++++++++++++++++++++++++++++++++++++\n===========================================================\n\n"); -// } + // if (count > eventList.getSize()) { + // logger.info("++++++++++++++++++++++++++++++++++++++++++++++++\n===========================================================\n\n"); + // Thread.sleep(30000); + // searchForEventsFromDeviceWithClientID("rpione3", "kapua-sys" ); + // eventList = (DeviceEventListResult) stepData.get(DEVICE_EVENT_LIST); + // eventList.getItems().forEach((event) -> logger.info("\ttype: {} - id: {} - date: {} - {}", event.getType(), event.getDeviceId(), event.getCreatedOn(), event.getEventMessage())); + // logger.info("++++++++++++++++++++++++++++++++++++++++++++++++\n===========================================================\n\n"); + // } } @Then("There is no such event") @@ -1637,7 +1637,7 @@ public void exerciseAllEventFactoryFunctions() { tmpEvent = eventFactory.newEntity(SYS_SCOPE_ID); tmpCreator = eventFactory.newCreator(SYS_SCOPE_ID, getKapuaId(), new Date(), ""); tmpQuery = eventFactory.newQuery(SYS_SCOPE_ID); - tmpList = eventFactory.newListResult(); + tmpList = new DeviceEventListResult(); Assert.assertNotNull(tmpEvent); Assert.assertNotNull(tmpCreator); Assert.assertNotNull(tmpQuery); @@ -1661,7 +1661,7 @@ public void checkDeviceEventDomainUpdate() { @When("I search for the device {string} in account {string}") public void searchForDeviceWithClientID(String clientId, String account) throws Exception { - DeviceListResult tmpList = deviceFactory.newListResult(); + DeviceListResult tmpList = new DeviceListResult(); primeException(); try { stepData.remove(DEVICE); @@ -1886,7 +1886,6 @@ public void createAnApplicationMessage(String clientId) throws Exception { } } - @Given("Such a set of privileged users for account {string}") public void createPrivilegedUsers(String accName, List users) throws Throwable { KapuaSecurityUtils.doPrivileged(() -> { @@ -1935,7 +1934,8 @@ public void createConnectionForDevice(List connections) throws Ka tmpCreator.setReservedUserId(tmpConn.getReservedUserId()); tmpCreator.setAllowUserChange(tmpConn.getAllowUserChange()); tmpCreator.setUserCouplingMode(tmpConn.getUserCouplingMode()); - tmpCreator.setAuthenticationType(deviceConnectionService.getAvailableAuthTypes().stream().findFirst().orElseThrow(() -> new IllegalStateException("No DeviceConnection authenticationTypes are available for testing"))); + tmpCreator.setAuthenticationType(deviceConnectionService.getAvailableAuthTypes().stream().findFirst() + .orElseThrow(() -> new IllegalStateException("No DeviceConnection authenticationTypes are available for testing"))); DeviceConnection tmpDevConn = deviceConnectionService.create(tmpCreator); tmpDevConn.setStatus(DeviceConnectionStatus.DISCONNECTED); deviceConnectionService.update(tmpDevConn); @@ -1953,7 +1953,7 @@ public void searchForConnectionFromDeviceWithClientID(String clientId, String ac KapuaSecurityUtils.doPrivileged(() -> { Account tmpAcc; DeviceConnection tmpConn; - DeviceConnectionListResult tmpConnLst = deviceConnectionFactory.newListResult(); + DeviceConnectionListResult tmpConnLst = new DeviceConnectionListResult(); tmpAcc = accountService.findByName(account); Assert.assertNotNull(tmpAcc); Assert.assertNotNull(tmpAcc.getId()); @@ -1999,7 +1999,8 @@ public void searchForConnectionFromDeviceWithClientIDStatusAndUser(String client searchForConnectionFromDeviceWithClientIDStatusAndUser(clientId, account.getId(), status, connectionUserId.getId(), true); } - private boolean searchForConnectionFromDeviceWithClientIDStatusAndUser(String clientId, KapuaId accountId, String connectionStatus, KapuaId connectionUserId, boolean timeoutOccurred) throws Exception { + private boolean searchForConnectionFromDeviceWithClientIDStatusAndUser(String clientId, KapuaId accountId, String connectionStatus, KapuaId connectionUserId, boolean timeoutOccurred) + throws Exception { try { Device device = deviceRegistryService.findByClientId(accountId, clientId); if (timeoutOccurred) { @@ -2022,7 +2023,7 @@ private boolean searchForConnectionFromDeviceWithClientIDStatusAndUser(String cl } } stepData.put(DEVICE_CONNECTION, deviceConnection); - DeviceConnectionListResult tmpConnLst = deviceConnectionFactory.newListResult(); + DeviceConnectionListResult tmpConnLst = new DeviceConnectionListResult(); Vector dcv = new Vector<>(); dcv.add(deviceConnection); tmpConnLst.addItems(dcv); @@ -2193,7 +2194,8 @@ private DeviceConnectionCreator prepareRegularConnectionCreator(KapuaId scopeId, creator.setServerIp(SERVER_IP); creator.setProtocol("tcp"); creator.setAllowUserChange(false); - creator.setAuthenticationType(deviceConnectionService.getAvailableAuthTypes().stream().findFirst().orElseThrow(() -> new IllegalStateException("No DeviceConnection authenticationTypes are available for testing"))); + creator.setAuthenticationType( + deviceConnectionService.getAvailableAuthTypes().stream().findFirst().orElseThrow(() -> new IllegalStateException("No DeviceConnection authenticationTypes are available for testing"))); return creator; } @@ -2226,24 +2228,24 @@ private DeviceEventCreator prepareRegularDeviceEventCreator(KapuaId accountId, K private KapuaMethod getMethodFromString(String name) { KapuaMethod tmpMeth = null; switch (name.trim().toUpperCase()) { - case "READ": - tmpMeth = KapuaMethod.READ; - break; - case "CREATE": - tmpMeth = KapuaMethod.CREATE; - break; - case "WRITE": - tmpMeth = KapuaMethod.WRITE; - break; - case "DELETE": - tmpMeth = KapuaMethod.DELETE; - break; - case "OPTIONS": - tmpMeth = KapuaMethod.OPTIONS; - break; - case "EXECUTE": - tmpMeth = KapuaMethod.EXECUTE; - break; + case "READ": + tmpMeth = KapuaMethod.READ; + break; + case "CREATE": + tmpMeth = KapuaMethod.CREATE; + break; + case "WRITE": + tmpMeth = KapuaMethod.WRITE; + break; + case "DELETE": + tmpMeth = KapuaMethod.DELETE; + break; + case "OPTIONS": + tmpMeth = KapuaMethod.OPTIONS; + break; + case "EXECUTE": + tmpMeth = KapuaMethod.EXECUTE; + break; } Assert.assertNotNull(tmpMeth); return tmpMeth; @@ -2454,34 +2456,34 @@ private DeviceCreator prepareDeviceCreatorFromCucDevice(CucDevice cucDevice) { DeviceConnectionStatus parseConnectionStatusString(String stat) { switch (stat.trim().toUpperCase()) { - case "CONNECTED": - return DeviceConnectionStatus.CONNECTED; - case "DISCONNECTED": - return DeviceConnectionStatus.DISCONNECTED; - case "MISSING": - return DeviceConnectionStatus.MISSING; + case "CONNECTED": + return DeviceConnectionStatus.CONNECTED; + case "DISCONNECTED": + return DeviceConnectionStatus.DISCONNECTED; + case "MISSING": + return DeviceConnectionStatus.MISSING; } return null; } ConnectionUserCouplingMode parseConnectionCouplingString(String mode) { switch (mode.trim().toUpperCase()) { - case "INHERITED": - return ConnectionUserCouplingMode.INHERITED; - case "LOOSE": - return ConnectionUserCouplingMode.LOOSE; - case "STRICT": - return ConnectionUserCouplingMode.STRICT; + case "INHERITED": + return ConnectionUserCouplingMode.INHERITED; + case "LOOSE": + return ConnectionUserCouplingMode.LOOSE; + case "STRICT": + return ConnectionUserCouplingMode.STRICT; } return null; } boolean parseBooleanFromString(String value) { switch (value.trim().toLowerCase()) { - case "true": - return true; - case "false": - return false; + case "true": + return true; + case "false": + return false; } return false; } @@ -2501,7 +2503,6 @@ public void iCreateADeviceWithName(String clientId) throws Exception { } } - @Then("I create a device with name {string} and tags") public void iCreateADeviceWithName(String clientId, List tags) throws Exception { final HashSet tagIds = new HashSet<>(); @@ -2813,7 +2814,6 @@ private void iChangeDeviceLastEventIdTo(String lastEventId) throws Throwable { } } - @And("The devices display name is {string}") public void theDevicesDisplayNameIs(String displayName) throws Throwable { Device device = (Device) stepData.get(DEVICE); diff --git a/service/endpoint/api/src/main/java/org/eclipse/kapua/service/endpoint/EndpointInfoFactory.java b/service/endpoint/api/src/main/java/org/eclipse/kapua/service/endpoint/EndpointInfoFactory.java index ace01e1d96f..73f8dd57b48 100644 --- a/service/endpoint/api/src/main/java/org/eclipse/kapua/service/endpoint/EndpointInfoFactory.java +++ b/service/endpoint/api/src/main/java/org/eclipse/kapua/service/endpoint/EndpointInfoFactory.java @@ -19,12 +19,13 @@ * * @since 1.0.0 */ -public interface EndpointInfoFactory extends KapuaEntityFactory { +public interface EndpointInfoFactory extends KapuaEntityFactory { /** * Instantiates a new {@link EndpointUsage}. * - * @param name The name to set into the {@link EndpointUsage}. + * @param name + * The name to set into the {@link EndpointUsage}. * @return The newly instantiated {@link EndpointUsage}. * @since 1.0.0 */ diff --git a/service/endpoint/api/src/main/java/org/eclipse/kapua/service/endpoint/EndpointInfoListResult.java b/service/endpoint/api/src/main/java/org/eclipse/kapua/service/endpoint/EndpointInfoListResult.java index 642f0944762..df3f7d48953 100644 --- a/service/endpoint/api/src/main/java/org/eclipse/kapua/service/endpoint/EndpointInfoListResult.java +++ b/service/endpoint/api/src/main/java/org/eclipse/kapua/service/endpoint/EndpointInfoListResult.java @@ -12,18 +12,18 @@ *******************************************************************************/ package org.eclipse.kapua.service.endpoint; -import org.eclipse.kapua.model.query.KapuaListResult; - import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import org.eclipse.kapua.model.query.KapuaListResult; + /** * {@link EndpointInfo} list result definition. * * @since 1.0.0 */ @XmlRootElement(name = "endpointInfos") -@XmlType(factoryClass = EndpointInfoXmlRegistry.class, factoryMethod = "newListResult") -public interface EndpointInfoListResult extends KapuaListResult { +@XmlType +public class EndpointInfoListResult extends KapuaListResult { } diff --git a/service/endpoint/api/src/main/java/org/eclipse/kapua/service/endpoint/EndpointInfoXmlRegistry.java b/service/endpoint/api/src/main/java/org/eclipse/kapua/service/endpoint/EndpointInfoXmlRegistry.java index 334e2f8380f..b6f9cc352bb 100644 --- a/service/endpoint/api/src/main/java/org/eclipse/kapua/service/endpoint/EndpointInfoXmlRegistry.java +++ b/service/endpoint/api/src/main/java/org/eclipse/kapua/service/endpoint/EndpointInfoXmlRegistry.java @@ -12,10 +12,10 @@ *******************************************************************************/ package org.eclipse.kapua.service.endpoint; -import org.eclipse.kapua.locator.KapuaLocator; - import javax.xml.bind.annotation.XmlRegistry; +import org.eclipse.kapua.locator.KapuaLocator; + @XmlRegistry public class EndpointInfoXmlRegistry { @@ -39,15 +39,6 @@ public EndpointInfoCreator newCreator() { return endpointInfoFactory.newCreator(null); } - /** - * Creates a new {@link EndpointInfoListResult} - * - * @return - */ - public EndpointInfoListResult newListResult() { - return endpointInfoFactory.newListResult(); - } - /** * Creates a new {@link EndpointInfoQuery} * diff --git a/service/endpoint/internal/src/main/java/org/eclipse/kapua/service/endpoint/internal/EndpointInfoFactoryImpl.java b/service/endpoint/internal/src/main/java/org/eclipse/kapua/service/endpoint/internal/EndpointInfoFactoryImpl.java index 0bfdb553646..4b2d655a7b8 100644 --- a/service/endpoint/internal/src/main/java/org/eclipse/kapua/service/endpoint/internal/EndpointInfoFactoryImpl.java +++ b/service/endpoint/internal/src/main/java/org/eclipse/kapua/service/endpoint/internal/EndpointInfoFactoryImpl.java @@ -12,17 +12,16 @@ *******************************************************************************/ package org.eclipse.kapua.service.endpoint.internal; +import javax.inject.Singleton; + import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.endpoint.EndpointInfo; import org.eclipse.kapua.service.endpoint.EndpointInfoCreator; import org.eclipse.kapua.service.endpoint.EndpointInfoFactory; -import org.eclipse.kapua.service.endpoint.EndpointInfoListResult; import org.eclipse.kapua.service.endpoint.EndpointInfoQuery; import org.eclipse.kapua.service.endpoint.EndpointUsage; -import javax.inject.Singleton; - /** * {@link EndpointInfoFactory} implementation. * @@ -36,11 +35,6 @@ public EndpointInfo newEntity(KapuaId scopeId) { return new EndpointInfoImpl(scopeId); } - @Override - public EndpointInfoListResult newListResult() { - return new EndpointInfoListResultImpl(); - } - @Override public EndpointInfoQuery newQuery(KapuaId scopeId) { return new EndpointInfoQueryImpl(scopeId); diff --git a/service/endpoint/internal/src/main/java/org/eclipse/kapua/service/endpoint/internal/EndpointInfoImplJpaRepository.java b/service/endpoint/internal/src/main/java/org/eclipse/kapua/service/endpoint/internal/EndpointInfoImplJpaRepository.java index 3f9034dd861..2d83e376a1e 100644 --- a/service/endpoint/internal/src/main/java/org/eclipse/kapua/service/endpoint/internal/EndpointInfoImplJpaRepository.java +++ b/service/endpoint/internal/src/main/java/org/eclipse/kapua/service/endpoint/internal/EndpointInfoImplJpaRepository.java @@ -21,7 +21,8 @@ public class EndpointInfoImplJpaRepository extends KapuaUpdatableEntityJpaRepository implements EndpointInfoRepository { + public EndpointInfoImplJpaRepository(KapuaJpaRepositoryConfiguration jpaRepoConfig) { - super(EndpointInfoImpl.class, EndpointInfo.TYPE, () -> new EndpointInfoListResultImpl(), jpaRepoConfig); + super(EndpointInfoImpl.class, EndpointInfo.TYPE, () -> new EndpointInfoListResult(), jpaRepoConfig); } } diff --git a/service/endpoint/internal/src/main/java/org/eclipse/kapua/service/endpoint/internal/EndpointInfoListResultImpl.java b/service/endpoint/internal/src/main/java/org/eclipse/kapua/service/endpoint/internal/EndpointInfoListResultImpl.java deleted file mode 100644 index 36b624f5730..00000000000 --- a/service/endpoint/internal/src/main/java/org/eclipse/kapua/service/endpoint/internal/EndpointInfoListResultImpl.java +++ /dev/null @@ -1,26 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017, 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.service.endpoint.internal; - -import org.eclipse.kapua.commons.model.query.KapuaListResultImpl; -import org.eclipse.kapua.service.endpoint.EndpointInfo; -import org.eclipse.kapua.service.endpoint.EndpointInfoListResult; - -/** - * {@link EndpointInfoListResult} implementation. - * - * @since 1.0.0 - */ -public class EndpointInfoListResultImpl extends KapuaListResultImpl implements EndpointInfoListResult { - -} diff --git a/service/job/api/src/main/java/org/eclipse/kapua/service/job/JobFactory.java b/service/job/api/src/main/java/org/eclipse/kapua/service/job/JobFactory.java index 2019e306624..7b985707f04 100644 --- a/service/job/api/src/main/java/org/eclipse/kapua/service/job/JobFactory.java +++ b/service/job/api/src/main/java/org/eclipse/kapua/service/job/JobFactory.java @@ -20,6 +20,6 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface JobFactory extends KapuaEntityFactory { +public interface JobFactory extends KapuaEntityFactory { } diff --git a/service/job/api/src/main/java/org/eclipse/kapua/service/job/JobListResult.java b/service/job/api/src/main/java/org/eclipse/kapua/service/job/JobListResult.java index 8973c004e95..6b070dc7347 100644 --- a/service/job/api/src/main/java/org/eclipse/kapua/service/job/JobListResult.java +++ b/service/job/api/src/main/java/org/eclipse/kapua/service/job/JobListResult.java @@ -23,11 +23,11 @@ * {@link JobListResult} definition. * * @since 1.0.0 - * */ @XmlRootElement(name = "jobListResult") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = JobXmlRegistry.class, factoryMethod = "newJobListResult") -public interface JobListResult extends KapuaListResult { +@XmlType +public class JobListResult extends KapuaListResult { + private static final long serialVersionUID = -7466853155307881848L; } diff --git a/service/job/api/src/main/java/org/eclipse/kapua/service/job/JobXmlRegistry.java b/service/job/api/src/main/java/org/eclipse/kapua/service/job/JobXmlRegistry.java index c8a7ee86d60..74abe55360f 100644 --- a/service/job/api/src/main/java/org/eclipse/kapua/service/job/JobXmlRegistry.java +++ b/service/job/api/src/main/java/org/eclipse/kapua/service/job/JobXmlRegistry.java @@ -12,10 +12,10 @@ *******************************************************************************/ package org.eclipse.kapua.service.job; -import org.eclipse.kapua.locator.KapuaLocator; - import javax.xml.bind.annotation.XmlRegistry; +import org.eclipse.kapua.locator.KapuaLocator; + /** * {@link Job} xml factory class * @@ -44,15 +44,6 @@ public JobCreator newJobCreator() { return jobFactory.newCreator(null); } - /** - * Creates a new job list result instance - * - * @return - */ - public JobListResult newJobListResult() { - return jobFactory.newListResult(); - } - public JobQuery newQuery() { return jobFactory.newQuery(null); } diff --git a/service/job/api/src/main/java/org/eclipse/kapua/service/job/execution/JobExecutionFactory.java b/service/job/api/src/main/java/org/eclipse/kapua/service/job/execution/JobExecutionFactory.java index ff4fb3d0e98..9a73594b5b1 100644 --- a/service/job/api/src/main/java/org/eclipse/kapua/service/job/execution/JobExecutionFactory.java +++ b/service/job/api/src/main/java/org/eclipse/kapua/service/job/execution/JobExecutionFactory.java @@ -20,6 +20,6 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface JobExecutionFactory extends KapuaEntityFactory { +public interface JobExecutionFactory extends KapuaEntityFactory { } diff --git a/service/job/api/src/main/java/org/eclipse/kapua/service/job/execution/JobExecutionListResult.java b/service/job/api/src/main/java/org/eclipse/kapua/service/job/execution/JobExecutionListResult.java index 59a93a12798..02dcea3020c 100644 --- a/service/job/api/src/main/java/org/eclipse/kapua/service/job/execution/JobExecutionListResult.java +++ b/service/job/api/src/main/java/org/eclipse/kapua/service/job/execution/JobExecutionListResult.java @@ -23,11 +23,10 @@ * {@link JobExecutionListResult} definition. * * @since 1.0.0 - * */ @XmlRootElement(name = "jobExecutionListResult") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = JobExecutionXmlRegistry.class, factoryMethod = "newJobExecutionListResult") -public interface JobExecutionListResult extends KapuaListResult { +@XmlType +public class JobExecutionListResult extends KapuaListResult { } diff --git a/service/job/api/src/main/java/org/eclipse/kapua/service/job/execution/JobExecutionXmlRegistry.java b/service/job/api/src/main/java/org/eclipse/kapua/service/job/execution/JobExecutionXmlRegistry.java index b1a6903c338..0de567b3408 100644 --- a/service/job/api/src/main/java/org/eclipse/kapua/service/job/execution/JobExecutionXmlRegistry.java +++ b/service/job/api/src/main/java/org/eclipse/kapua/service/job/execution/JobExecutionXmlRegistry.java @@ -12,10 +12,10 @@ *******************************************************************************/ package org.eclipse.kapua.service.job.execution; -import org.eclipse.kapua.locator.KapuaLocator; - import javax.xml.bind.annotation.XmlRegistry; +import org.eclipse.kapua.locator.KapuaLocator; + /** * {@link JobExecution} xml factory class * @@ -44,15 +44,6 @@ public JobExecutionCreator newJobExecutionCreator() { return jobExecutionFactory.newCreator(null); } - /** - * Creates a new job list result instance - * - * @return - */ - public JobExecutionListResult newJobExecutionListResult() { - return jobExecutionFactory.newListResult(); - } - public JobExecutionQuery newQuery() { return jobExecutionFactory.newQuery(null); } diff --git a/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/JobStepFactory.java b/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/JobStepFactory.java index 8509317161f..fa3b3a8bf5c 100644 --- a/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/JobStepFactory.java +++ b/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/JobStepFactory.java @@ -21,14 +21,17 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface JobStepFactory extends KapuaEntityFactory { +public interface JobStepFactory extends KapuaEntityFactory { /** * Instantiates a new {@link JobStepProperty}. * - * @param name The name to set into the {@link JobStepProperty}. - * @param propertyType The type to set into the {@link JobStepProperty}. - * @param propertyValue The value to set into the {@link JobStepProperty}. + * @param name + * The name to set into the {@link JobStepProperty}. + * @param propertyType + * The type to set into the {@link JobStepProperty}. + * @param propertyValue + * The value to set into the {@link JobStepProperty}. * @return The newly instantiated {@link JobStepProperty} * @since 1.0.0 */ diff --git a/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/JobStepListResult.java b/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/JobStepListResult.java index 8b0dd67edd9..a568f646352 100644 --- a/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/JobStepListResult.java +++ b/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/JobStepListResult.java @@ -23,11 +23,12 @@ * {@link JobStepListResult} definition. * * @since 1.0.0 - * */ @XmlRootElement(name = "jobStepListResult") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = JobStepXmlRegistry.class, factoryMethod = "newJobStepListResult") -public interface JobStepListResult extends KapuaListResult { +@XmlType +public class JobStepListResult extends KapuaListResult { + + private static final long serialVersionUID = -7466853155307881848L; } diff --git a/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/JobStepXmlRegistry.java b/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/JobStepXmlRegistry.java index 9cc8763ba30..13eaf71fe5c 100644 --- a/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/JobStepXmlRegistry.java +++ b/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/JobStepXmlRegistry.java @@ -12,11 +12,11 @@ *******************************************************************************/ package org.eclipse.kapua.service.job.step; +import javax.xml.bind.annotation.XmlRegistry; + import org.eclipse.kapua.locator.KapuaLocator; import org.eclipse.kapua.service.job.step.definition.JobStepProperty; -import javax.xml.bind.annotation.XmlRegistry; - /** * {@link JobStep} xml factory class * @@ -45,15 +45,6 @@ public JobStepCreator newJobStepCreator() { return jobStepFactory.newCreator(null); } - /** - * Creates a new job list result instance - * - * @return - */ - public JobStepListResult newJobStepListResult() { - return jobStepFactory.newListResult(); - } - public JobStepQuery newQuery() { return jobStepFactory.newQuery(null); } diff --git a/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/definition/JobStepDefinitionFactory.java b/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/definition/JobStepDefinitionFactory.java index 7e7d0f9068f..bc1c86a7f8b 100644 --- a/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/definition/JobStepDefinitionFactory.java +++ b/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/definition/JobStepDefinitionFactory.java @@ -20,15 +20,19 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface JobStepDefinitionFactory extends KapuaEntityFactory { +public interface JobStepDefinitionFactory extends KapuaEntityFactory { /** * Instantiates a new {@link JobStepProperty}. * - * @param name The name to set into the {@link JobStepProperty}. - * @param type The type to set into the {@link JobStepProperty}. - * @param value The value to set into the {@link JobStepProperty}. - * @param exampleValue The example value to set into the {@link JobStepProperty} + * @param name + * The name to set into the {@link JobStepProperty}. + * @param type + * The type to set into the {@link JobStepProperty}. + * @param value + * The value to set into the {@link JobStepProperty}. + * @param exampleValue + * The example value to set into the {@link JobStepProperty} * @return The newly instantiated {@link JobStepProperty}. * @since 1.1.0 */ @@ -37,9 +41,12 @@ public interface JobStepDefinitionFactory extends KapuaEntityFactory { +@XmlType +public class JobStepDefinitionListResult extends KapuaListResult { + + private static final long serialVersionUID = 977813250632719295L; } diff --git a/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/definition/JobStepDefinitionXmlRegistry.java b/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/definition/JobStepDefinitionXmlRegistry.java index 019d7fd1776..1ec589e7d1e 100644 --- a/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/definition/JobStepDefinitionXmlRegistry.java +++ b/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/definition/JobStepDefinitionXmlRegistry.java @@ -12,10 +12,10 @@ *******************************************************************************/ package org.eclipse.kapua.service.job.step.definition; -import org.eclipse.kapua.locator.KapuaLocator; - import javax.xml.bind.annotation.XmlRegistry; +import org.eclipse.kapua.locator.KapuaLocator; + /** * {@link JobStepDefinition} xml factory class * @@ -44,15 +44,6 @@ public JobStepDefinitionCreator newJobStepDefinitionCreator() { return jobStepDefinitionFactory.newCreator(null); } - /** - * Creates a new job list result instance - * - * @return - */ - public JobStepDefinitionListResult newJobStepDefinitionListResult() { - return jobStepDefinitionFactory.newListResult(); - } - public JobStepDefinitionQuery newQuery() { return jobStepDefinitionFactory.newQuery(null); } diff --git a/service/job/api/src/main/java/org/eclipse/kapua/service/job/targets/JobTargetFactory.java b/service/job/api/src/main/java/org/eclipse/kapua/service/job/targets/JobTargetFactory.java index 27b4e8dae25..6e6870017c1 100644 --- a/service/job/api/src/main/java/org/eclipse/kapua/service/job/targets/JobTargetFactory.java +++ b/service/job/api/src/main/java/org/eclipse/kapua/service/job/targets/JobTargetFactory.java @@ -20,6 +20,6 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface JobTargetFactory extends KapuaEntityFactory { +public interface JobTargetFactory extends KapuaEntityFactory { } diff --git a/service/job/api/src/main/java/org/eclipse/kapua/service/job/targets/JobTargetListResult.java b/service/job/api/src/main/java/org/eclipse/kapua/service/job/targets/JobTargetListResult.java index 3ad08fabff5..629c92c318b 100644 --- a/service/job/api/src/main/java/org/eclipse/kapua/service/job/targets/JobTargetListResult.java +++ b/service/job/api/src/main/java/org/eclipse/kapua/service/job/targets/JobTargetListResult.java @@ -23,11 +23,10 @@ * {@link JobTargetListResult} definition. * * @since 1.0.0 - * */ @XmlRootElement(name = "jobTargetListResult") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = JobTargetXmlRegistry.class, factoryMethod = "newJobTargetListResult") -public interface JobTargetListResult extends KapuaListResult { +@XmlType +public class JobTargetListResult extends KapuaListResult { } diff --git a/service/job/api/src/main/java/org/eclipse/kapua/service/job/targets/JobTargetXmlRegistry.java b/service/job/api/src/main/java/org/eclipse/kapua/service/job/targets/JobTargetXmlRegistry.java index 0e09d0c313d..8b6b8407ec1 100644 --- a/service/job/api/src/main/java/org/eclipse/kapua/service/job/targets/JobTargetXmlRegistry.java +++ b/service/job/api/src/main/java/org/eclipse/kapua/service/job/targets/JobTargetXmlRegistry.java @@ -12,10 +12,10 @@ *******************************************************************************/ package org.eclipse.kapua.service.job.targets; -import org.eclipse.kapua.locator.KapuaLocator; - import javax.xml.bind.annotation.XmlRegistry; +import org.eclipse.kapua.locator.KapuaLocator; + /** * {@link JobTarget} xml factory class * @@ -44,15 +44,6 @@ public JobTargetCreator newJobTargetCreator() { return jobTargetFactory.newCreator(null); } - /** - * Creates a new job list result instance - * - * @return - */ - public JobTargetListResult newJobTargetListResult() { - return jobTargetFactory.newListResult(); - } - public JobTargetQuery newQuery() { return jobTargetFactory.newQuery(null); } diff --git a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/execution/internal/JobExecutionFactoryImpl.java b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/execution/internal/JobExecutionFactoryImpl.java index 71fa2a9f3d0..2cb49565760 100644 --- a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/execution/internal/JobExecutionFactoryImpl.java +++ b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/execution/internal/JobExecutionFactoryImpl.java @@ -12,16 +12,15 @@ *******************************************************************************/ package org.eclipse.kapua.service.job.execution.internal; +import javax.inject.Singleton; + import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.job.execution.JobExecution; import org.eclipse.kapua.service.job.execution.JobExecutionCreator; import org.eclipse.kapua.service.job.execution.JobExecutionFactory; -import org.eclipse.kapua.service.job.execution.JobExecutionListResult; import org.eclipse.kapua.service.job.execution.JobExecutionQuery; -import javax.inject.Singleton; - /** * {@link JobExecutionFactory} implementation. * @@ -45,11 +44,6 @@ public JobExecutionQuery newQuery(KapuaId scopeId) { return new JobExecutionQueryImpl(scopeId); } - @Override - public JobExecutionListResult newListResult() { - return new JobExecutionListResultImpl(); - } - @Override public JobExecution clone(JobExecution jobExecution) { try { diff --git a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/execution/internal/JobExecutionImplJpaRepository.java b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/execution/internal/JobExecutionImplJpaRepository.java index c4224d0d2bd..848c4e5e520 100644 --- a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/execution/internal/JobExecutionImplJpaRepository.java +++ b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/execution/internal/JobExecutionImplJpaRepository.java @@ -25,8 +25,9 @@ public class JobExecutionImplJpaRepository extends KapuaUpdatableEntityJpaRepository implements JobExecutionRepository { + public JobExecutionImplJpaRepository(KapuaJpaRepositoryConfiguration jpaRepoConfig) { - super(JobExecutionImpl.class, JobExecution.TYPE, () -> new JobExecutionListResultImpl(), jpaRepoConfig); + super(JobExecutionImpl.class, JobExecution.TYPE, () -> new JobExecutionListResult(), jpaRepoConfig); } @Override diff --git a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/execution/internal/JobExecutionListResultImpl.java b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/execution/internal/JobExecutionListResultImpl.java deleted file mode 100644 index f0d37bcad5f..00000000000 --- a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/execution/internal/JobExecutionListResultImpl.java +++ /dev/null @@ -1,26 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017, 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.service.job.execution.internal; - -import org.eclipse.kapua.commons.model.query.KapuaListResultImpl; -import org.eclipse.kapua.service.job.execution.JobExecution; -import org.eclipse.kapua.service.job.execution.JobExecutionListResult; - -/** - * {@link JobExecutionListResult} implementation. - * - * @since 1.0.0 - */ -public class JobExecutionListResultImpl extends KapuaListResultImpl implements JobExecutionListResult { - -} diff --git a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/internal/JobFactoryImpl.java b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/internal/JobFactoryImpl.java index 9f5c0ade8e5..95a580e025c 100644 --- a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/internal/JobFactoryImpl.java +++ b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/internal/JobFactoryImpl.java @@ -12,16 +12,15 @@ *******************************************************************************/ package org.eclipse.kapua.service.job.internal; +import javax.inject.Singleton; + import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.job.Job; import org.eclipse.kapua.service.job.JobCreator; import org.eclipse.kapua.service.job.JobFactory; -import org.eclipse.kapua.service.job.JobListResult; import org.eclipse.kapua.service.job.JobQuery; -import javax.inject.Singleton; - /** * {@link JobFactory} implementation. * @@ -45,11 +44,6 @@ public JobQuery newQuery(KapuaId scopeId) { return new JobQueryImpl(scopeId); } - @Override - public JobListResult newListResult() { - return new JobListResultImpl(); - } - @Override public Job clone(Job job) { try { diff --git a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/internal/JobImplJpaRepository.java b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/internal/JobImplJpaRepository.java index 14fcb9432b3..b4f61507844 100644 --- a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/internal/JobImplJpaRepository.java +++ b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/internal/JobImplJpaRepository.java @@ -23,6 +23,6 @@ public class JobImplJpaRepository implements JobRepository { public JobImplJpaRepository(KapuaJpaRepositoryConfiguration jpaRepoConfig) { - super(JobImpl.class, Job.TYPE, () -> new JobListResultImpl(), jpaRepoConfig); + super(JobImpl.class, Job.TYPE, () -> new JobListResult(), jpaRepoConfig); } } diff --git a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/internal/JobListResultImpl.java b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/internal/JobListResultImpl.java deleted file mode 100644 index 20e01878c1f..00000000000 --- a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/internal/JobListResultImpl.java +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017, 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.service.job.internal; - -import org.eclipse.kapua.commons.model.query.KapuaListResultImpl; -import org.eclipse.kapua.service.job.Job; -import org.eclipse.kapua.service.job.JobListResult; - -/** - * {@link JobListResult} implementation. - * - * @since 1.0.0 - */ -public class JobListResultImpl extends KapuaListResultImpl implements JobListResult { - - private static final long serialVersionUID = -7466853155307881848L; - -} diff --git a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/definition/internal/JobStepDefinitionFactoryImpl.java b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/definition/internal/JobStepDefinitionFactoryImpl.java index 6363e60b085..120038b64ca 100644 --- a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/definition/internal/JobStepDefinitionFactoryImpl.java +++ b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/definition/internal/JobStepDefinitionFactoryImpl.java @@ -19,7 +19,6 @@ import org.eclipse.kapua.service.job.step.definition.JobStepDefinition; import org.eclipse.kapua.service.job.step.definition.JobStepDefinitionCreator; import org.eclipse.kapua.service.job.step.definition.JobStepDefinitionFactory; -import org.eclipse.kapua.service.job.step.definition.JobStepDefinitionListResult; import org.eclipse.kapua.service.job.step.definition.JobStepDefinitionQuery; import org.eclipse.kapua.service.job.step.definition.JobStepProperty; @@ -46,11 +45,6 @@ public JobStepDefinitionQuery newQuery(KapuaId scopeId) { return new JobStepDefinitionQueryImpl(scopeId); } - @Override - public JobStepDefinitionListResult newListResult() { - return new JobStepDefinitionListResultImpl(); - } - @Override public JobStepProperty newStepProperty(String name, String type, String value) { return new JobStepPropertyImpl(name, type, value, null); diff --git a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/definition/internal/JobStepDefinitionImplJpaRepository.java b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/definition/internal/JobStepDefinitionImplJpaRepository.java index 484085a0538..9614d08874e 100644 --- a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/definition/internal/JobStepDefinitionImplJpaRepository.java +++ b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/definition/internal/JobStepDefinitionImplJpaRepository.java @@ -23,7 +23,7 @@ public class JobStepDefinitionImplJpaRepository implements JobStepDefinitionRepository { public JobStepDefinitionImplJpaRepository(KapuaJpaRepositoryConfiguration jpaRepoConfig) { - super(JobStepDefinitionImpl.class, JobStepDefinition.TYPE, () -> new JobStepDefinitionListResultImpl(), jpaRepoConfig); + super(JobStepDefinitionImpl.class, JobStepDefinition.TYPE, () -> new JobStepDefinitionListResult(), jpaRepoConfig); } } diff --git a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/definition/internal/JobStepDefinitionListResultImpl.java b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/definition/internal/JobStepDefinitionListResultImpl.java deleted file mode 100644 index d829517d144..00000000000 --- a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/definition/internal/JobStepDefinitionListResultImpl.java +++ /dev/null @@ -1,29 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017, 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.service.job.step.definition.internal; - -import org.eclipse.kapua.commons.model.query.KapuaListResultImpl; -import org.eclipse.kapua.service.job.step.definition.JobStepDefinition; -import org.eclipse.kapua.service.job.step.definition.JobStepDefinitionListResult; - -/** - * {@link JobStepDefinitionListResult} definition. - * - * @since 1.0.0 - * - */ -public class JobStepDefinitionListResultImpl extends KapuaListResultImpl implements JobStepDefinitionListResult { - - private static final long serialVersionUID = 977813250632719295L; - -} diff --git a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/internal/JobStepFactoryImpl.java b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/internal/JobStepFactoryImpl.java index acab84ae774..ad8f9356333 100644 --- a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/internal/JobStepFactoryImpl.java +++ b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/internal/JobStepFactoryImpl.java @@ -18,7 +18,6 @@ import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.job.step.JobStepCreator; import org.eclipse.kapua.service.job.step.JobStepFactory; -import org.eclipse.kapua.service.job.step.JobStepListResult; import org.eclipse.kapua.service.job.step.JobStepQuery; import org.eclipse.kapua.service.job.step.definition.JobStepProperty; import org.eclipse.kapua.service.job.step.definition.internal.JobStepPropertyImpl; @@ -46,11 +45,6 @@ public JobStepQuery newQuery(KapuaId scopeId) { return new JobStepQueryImpl(scopeId); } - @Override - public JobStepListResult newListResult() { - return new JobStepListResultImpl(); - } - @Override public JobStepProperty newStepProperty(String name, String propertyType, String propertyValue) { return new JobStepPropertyImpl(name, propertyType, propertyValue, null); diff --git a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/internal/JobStepImplJpaRepository.java b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/internal/JobStepImplJpaRepository.java index a92003a6358..c0c9201c1cf 100644 --- a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/internal/JobStepImplJpaRepository.java +++ b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/internal/JobStepImplJpaRepository.java @@ -26,8 +26,9 @@ public class JobStepImplJpaRepository extends KapuaNamedEntityJpaRepository implements JobStepRepository { + public JobStepImplJpaRepository(KapuaJpaRepositoryConfiguration jpaRepoConfig) { - super(JobStepImpl.class, JobStep.TYPE, () -> new JobStepListResultImpl(), jpaRepoConfig); + super(JobStepImpl.class, JobStep.TYPE, () -> new JobStepListResult(), jpaRepoConfig); } @Override diff --git a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/internal/JobStepListResultImpl.java b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/internal/JobStepListResultImpl.java deleted file mode 100644 index 4ce385b5462..00000000000 --- a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/internal/JobStepListResultImpl.java +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017, 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.service.job.step.internal; - -import org.eclipse.kapua.commons.model.query.KapuaListResultImpl; -import org.eclipse.kapua.service.job.step.JobStep; -import org.eclipse.kapua.service.job.step.JobStepListResult; - -/** - * {@link JobStepListResult} implementation. - * - * @since 1.0.0 - */ -public class JobStepListResultImpl extends KapuaListResultImpl implements JobStepListResult { - - private static final long serialVersionUID = -7466853155307881848L; - -} diff --git a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/targets/internal/JobTargetFactoryImpl.java b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/targets/internal/JobTargetFactoryImpl.java index f7827b78da1..cfd25291c12 100644 --- a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/targets/internal/JobTargetFactoryImpl.java +++ b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/targets/internal/JobTargetFactoryImpl.java @@ -12,16 +12,15 @@ *******************************************************************************/ package org.eclipse.kapua.service.job.targets.internal; +import javax.inject.Singleton; + import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.job.targets.JobTarget; import org.eclipse.kapua.service.job.targets.JobTargetCreator; import org.eclipse.kapua.service.job.targets.JobTargetFactory; -import org.eclipse.kapua.service.job.targets.JobTargetListResult; import org.eclipse.kapua.service.job.targets.JobTargetQuery; -import javax.inject.Singleton; - /** * {@link JobTargetFactory} implementation. * @@ -45,11 +44,6 @@ public JobTargetQuery newQuery(KapuaId scopeId) { return new JobTargetQueryImpl(scopeId); } - @Override - public JobTargetListResult newListResult() { - return new JobTargetListResultImpl(); - } - @Override public JobTarget clone(JobTarget jobTarget) { try { diff --git a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/targets/internal/JobTargetImplJpaRepository.java b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/targets/internal/JobTargetImplJpaRepository.java index 3cee4ad8f3a..d91afb19d0e 100644 --- a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/targets/internal/JobTargetImplJpaRepository.java +++ b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/targets/internal/JobTargetImplJpaRepository.java @@ -23,7 +23,7 @@ public class JobTargetImplJpaRepository implements JobTargetRepository { public JobTargetImplJpaRepository(KapuaJpaRepositoryConfiguration jpaRepoConfig) { - super(JobTargetImpl.class, JobTarget.TYPE, () -> new JobTargetListResultImpl(), jpaRepoConfig); + super(JobTargetImpl.class, JobTarget.TYPE, () -> new JobTargetListResult(), jpaRepoConfig); } } diff --git a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/targets/internal/JobTargetListResultImpl.java b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/targets/internal/JobTargetListResultImpl.java deleted file mode 100644 index 8c3f98a494c..00000000000 --- a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/targets/internal/JobTargetListResultImpl.java +++ /dev/null @@ -1,26 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017, 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.service.job.targets.internal; - -import org.eclipse.kapua.commons.model.query.KapuaListResultImpl; -import org.eclipse.kapua.service.job.targets.JobTarget; -import org.eclipse.kapua.service.job.targets.JobTargetListResult; - -/** - * {@link JobTargetListResult} implementation. - * - * @since 1.0.0 - */ -public class JobTargetListResultImpl extends KapuaListResultImpl implements JobTargetListResult { - -} diff --git a/service/job/test-steps/src/main/java/org/eclipse/kapua/service/job/steps/JobExecutionServiceSteps.java b/service/job/test-steps/src/main/java/org/eclipse/kapua/service/job/steps/JobExecutionServiceSteps.java index acb57217905..8315e9a5d02 100644 --- a/service/job/test-steps/src/main/java/org/eclipse/kapua/service/job/steps/JobExecutionServiceSteps.java +++ b/service/job/test-steps/src/main/java/org/eclipse/kapua/service/job/steps/JobExecutionServiceSteps.java @@ -14,16 +14,9 @@ import java.util.Calendar; import java.util.Date; + import javax.inject.Inject; -import com.google.inject.Singleton; -import io.cucumber.java.After; -import io.cucumber.java.Before; -import io.cucumber.java.Scenario; -import io.cucumber.java.en.And; -import io.cucumber.java.en.Given; -import io.cucumber.java.en.Then; -import io.cucumber.java.en.When; import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.locator.KapuaLocator; import org.eclipse.kapua.model.id.KapuaId; @@ -47,6 +40,16 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.google.inject.Singleton; + +import io.cucumber.java.After; +import io.cucumber.java.Before; +import io.cucumber.java.Scenario; +import io.cucumber.java.en.And; +import io.cucumber.java.en.Given; +import io.cucumber.java.en.Then; +import io.cucumber.java.en.When; + @Singleton public class JobExecutionServiceSteps extends JobServiceTestBase { @@ -149,7 +152,8 @@ public void deleteLastJobExecution() throws Exception { /** * Checks that the last {@link Job} in context has the given number of {@link JobExecution}s * - * @param expectedNumberOfExecution Expected number of {@link JobExecution}s + * @param expectedNumberOfExecution + * Expected number of {@link JobExecution}s * @throws Exception * @since 2.1.0 */ @@ -163,8 +167,10 @@ public void checkJobInContextHasExecution(int expectedNumberOfExecution) throws /** * Looks for a {@link Job} by its {@link Job#getName()} and checks that has the given number of {@link JobExecution}s * - * @param jobName The {@link Job#getName()} to look for - * @param expectedNumberOfExecution Expected number of {@link JobExecution}s + * @param jobName + * The {@link Job#getName()} to look for + * @param expectedNumberOfExecution + * Expected number of {@link JobExecution}s * @throws Exception * @since 2.1.0 */ @@ -178,8 +184,10 @@ public void checkJobByNameHasExecution(String jobName, int expectedNumberOfExecu /** * Checks that the given {@link Job} has the given number of {@link JobExecution}s * - * @param job The {@link Job} to check - * @param expectedNumberOfExecution Expected number of {@link JobExecution}s + * @param job + * The {@link Job} to check + * @param expectedNumberOfExecution + * Expected number of {@link JobExecution}s * @throws Exception * @since 2.1.0 */ @@ -213,21 +221,18 @@ public void queryExecutionsForJobWithPackages() throws Exception { } } - @Then("I query for the execution items for the current job starting from date in the future") public void queryExecutionsForJobWithStartDateInFuture() throws Exception { final Date startDate = createDateInFuture(); queryExecutionsForJobWithStartDate(startDate); } - @Then("I query for the execution items for the current job starting from date in the past") public void queryExecutionsForJobWithStartDateInPast() throws Exception { final Date startDate = createDateInPast(); queryExecutionsForJobWithStartDate(startDate); } - private void queryExecutionsForJobWithStartDate(Date startDate) throws Exception { final Job job = (Job) stepData.get("Job"); final JobExecutionQuery tmpQuery = jobExecutionFactory.newQuery(getCurrentScopeId()); @@ -245,14 +250,12 @@ private void queryExecutionsForJobWithStartDate(Date startDate) throws Exception } } - private Date createDateInFuture() { final Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.DAY_OF_MONTH, 7); return calendar.getTime(); } - private Date createDateInPast() { final Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.DAY_OF_MONTH, -7); @@ -419,7 +422,6 @@ private void logJobInfo(JobExecutionListResult jobExecutionList, Job job, int ex } } - @Then("The job execution matches the creator") public void checkJobExecutionItemAgainstCreator() { JobExecutionCreator executionCreator = (JobExecutionCreator) stepData.get("JobExecutionCreator"); @@ -448,7 +450,6 @@ public void checkThatNoExecutionWasFound() { public void testTheJobExecutionFactory() { Assert.assertNotNull(jobExecutionFactory.newCreator(SYS_SCOPE_ID)); Assert.assertNotNull(jobExecutionFactory.newEntity(SYS_SCOPE_ID)); - Assert.assertNotNull(jobExecutionFactory.newListResult()); Assert.assertNotNull(jobExecutionFactory.newQuery(SYS_SCOPE_ID)); } // Private methods diff --git a/service/job/test-steps/src/main/java/org/eclipse/kapua/service/job/steps/JobServiceSteps.java b/service/job/test-steps/src/main/java/org/eclipse/kapua/service/job/steps/JobServiceSteps.java index c46794eefcd..71e02233eaa 100644 --- a/service/job/test-steps/src/main/java/org/eclipse/kapua/service/job/steps/JobServiceSteps.java +++ b/service/job/test-steps/src/main/java/org/eclipse/kapua/service/job/steps/JobServiceSteps.java @@ -13,14 +13,12 @@ *******************************************************************************/ package org.eclipse.kapua.service.job.steps; -import com.google.inject.Singleton; -import io.cucumber.java.After; -import io.cucumber.java.Before; -import io.cucumber.java.Scenario; -import io.cucumber.java.en.And; -import io.cucumber.java.en.Given; -import io.cucumber.java.en.Then; -import io.cucumber.java.en.When; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.inject.Inject; + import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.locator.KapuaLocator; import org.eclipse.kapua.model.id.KapuaId; @@ -37,10 +35,15 @@ import org.eclipse.kapua.service.job.step.JobStep; import org.junit.Assert; -import javax.inject.Inject; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import com.google.inject.Singleton; + +import io.cucumber.java.After; +import io.cucumber.java.Before; +import io.cucumber.java.Scenario; +import io.cucumber.java.en.And; +import io.cucumber.java.en.Given; +import io.cucumber.java.en.Then; +import io.cucumber.java.en.When; @Singleton public class JobServiceSteps extends JobServiceTestBase { @@ -339,7 +342,6 @@ public void testJobFactorySanity() { Assert.assertNotNull("The job factory returned a null creator!", jobFactory.newCreator(SYS_SCOPE_ID)); Assert.assertNotNull("The job factory returned a null job object!", jobFactory.newEntity(SYS_SCOPE_ID)); Assert.assertNotNull("The job factory returned a null job query!", jobFactory.newQuery(SYS_SCOPE_ID)); - Assert.assertNotNull("The job factory returned a null job list result!", jobFactory.newListResult()); } @Then("I find a job with name {string}") @@ -374,7 +376,6 @@ public void iTryToEditJobToName(String jobName) throws Throwable { } } - @When("I query for the job with the name {string} and I find it") public void iQueryForTheJobWithTheNameAndIFoundIt(String jobName) throws Exception { JobQuery tmpQuery = jobFactory.newQuery(getCurrentScopeId()); diff --git a/service/job/test-steps/src/main/java/org/eclipse/kapua/service/job/steps/JobStepDefinitionServiceSteps.java b/service/job/test-steps/src/main/java/org/eclipse/kapua/service/job/steps/JobStepDefinitionServiceSteps.java index a8952780e54..96a18e4f432 100644 --- a/service/job/test-steps/src/main/java/org/eclipse/kapua/service/job/steps/JobStepDefinitionServiceSteps.java +++ b/service/job/test-steps/src/main/java/org/eclipse/kapua/service/job/steps/JobStepDefinitionServiceSteps.java @@ -12,14 +12,11 @@ *******************************************************************************/ package org.eclipse.kapua.service.job.steps; -import com.google.inject.Singleton; -import io.cucumber.java.After; -import io.cucumber.java.Before; -import io.cucumber.java.Scenario; -import io.cucumber.java.en.And; -import io.cucumber.java.en.Given; -import io.cucumber.java.en.Then; -import io.cucumber.java.en.When; +import java.util.ArrayList; +import java.util.List; + +import javax.inject.Inject; + import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.locator.KapuaLocator; import org.eclipse.kapua.model.id.KapuaId; @@ -34,9 +31,15 @@ import org.eclipse.kapua.service.job.steps.model.TestJobStepProcessor; import org.junit.Assert; -import javax.inject.Inject; -import java.util.ArrayList; -import java.util.List; +import com.google.inject.Singleton; + +import io.cucumber.java.After; +import io.cucumber.java.Before; +import io.cucumber.java.Scenario; +import io.cucumber.java.en.And; +import io.cucumber.java.en.Given; +import io.cucumber.java.en.Then; +import io.cucumber.java.en.When; @Singleton public class JobStepDefinitionServiceSteps extends JobServiceTestBase { @@ -324,12 +327,10 @@ public void checkStepDefinitionProcessorName(String name) { public void testTheStepDefinitionFactory() { Assert.assertNotNull(jobStepDefinitionFactory.newCreator(SYS_SCOPE_ID)); Assert.assertNotNull(jobStepDefinitionFactory.newEntity(SYS_SCOPE_ID)); - Assert.assertNotNull(jobStepDefinitionFactory.newListResult()); Assert.assertNotNull(jobStepDefinitionFactory.newQuery(SYS_SCOPE_ID)); Assert.assertNotNull(jobStepDefinitionFactory.newStepProperty("TestName", "TestType", "TestValue", "TestExampleValue")); } - private JobStepType getTypeFromString(String type) { if (type.trim().toUpperCase().equals("TARGET")) { return JobStepType.TARGET; diff --git a/service/job/test-steps/src/main/java/org/eclipse/kapua/service/job/steps/JobStepServiceSteps.java b/service/job/test-steps/src/main/java/org/eclipse/kapua/service/job/steps/JobStepServiceSteps.java index b2f2f218968..219e528ffef 100644 --- a/service/job/test-steps/src/main/java/org/eclipse/kapua/service/job/steps/JobStepServiceSteps.java +++ b/service/job/test-steps/src/main/java/org/eclipse/kapua/service/job/steps/JobStepServiceSteps.java @@ -12,14 +12,14 @@ *******************************************************************************/ package org.eclipse.kapua.service.job.steps; -import com.google.inject.Singleton; -import io.cucumber.java.After; -import io.cucumber.java.Before; -import io.cucumber.java.Scenario; -import io.cucumber.java.en.And; -import io.cucumber.java.en.Given; -import io.cucumber.java.en.Then; -import io.cucumber.java.en.When; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + +import javax.inject.Inject; + import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.locator.KapuaLocator; import org.eclipse.kapua.model.id.KapuaId; @@ -40,12 +40,15 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.inject.Inject; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.stream.Collectors; +import com.google.inject.Singleton; + +import io.cucumber.java.After; +import io.cucumber.java.Before; +import io.cucumber.java.Scenario; +import io.cucumber.java.en.And; +import io.cucumber.java.en.Given; +import io.cucumber.java.en.Then; +import io.cucumber.java.en.When; @Singleton public class JobStepServiceSteps extends JobServiceTestBase { @@ -106,13 +109,15 @@ public void iPrepareAJobStepCreatorWithPropertyList(String name, List cucJobStepProperties) throws Exception{ + public void iAddJobStepToJobWithSelectedJobStepDefinitionAndFollowingJobStepProperties(String jobStepName, List cucJobStepProperties) throws Exception { Job job = (Job) stepData.get(JOB); JobStepDefinition jobStepDefinition = (JobStepDefinition) stepData.get(JOB_STEP_DEFINITION); @@ -123,11 +128,11 @@ public void iAddJobStepToJobWithSelectedJobStepDefinitionAndFollowingJobStepProp jobStepCreator.setStepProperties( cucJobStepProperties.stream() .map( - (cucJobStepProperty) -> jobStepFactory.newStepProperty( - cucJobStepProperty.getName(), - cucJobStepProperty.getType(), - cucJobStepProperty.getValue() - ) + (cucJobStepProperty) -> jobStepFactory.newStepProperty( + cucJobStepProperty.getName(), + cucJobStepProperty.getType(), + cucJobStepProperty.getValue() + ) ) .collect(Collectors.toList()) ); @@ -375,7 +380,6 @@ public void checkJobStepNotFound() { public void testTheStepFactory() { Assert.assertNotNull(jobStepFactory.newCreator(SYS_SCOPE_ID)); Assert.assertNotNull(jobStepFactory.newEntity(SYS_SCOPE_ID)); - Assert.assertNotNull(jobStepFactory.newListResult()); Assert.assertNotNull(jobStepFactory.newQuery(SYS_SCOPE_ID)); Assert.assertNotNull(jobStepFactory.newStepProperty("TestName", "TestType", "TestValue")); } diff --git a/service/job/test-steps/src/main/java/org/eclipse/kapua/service/job/steps/JobTargetServiceSteps.java b/service/job/test-steps/src/main/java/org/eclipse/kapua/service/job/steps/JobTargetServiceSteps.java index ea7e630c583..5f3a7f60349 100644 --- a/service/job/test-steps/src/main/java/org/eclipse/kapua/service/job/steps/JobTargetServiceSteps.java +++ b/service/job/test-steps/src/main/java/org/eclipse/kapua/service/job/steps/JobTargetServiceSteps.java @@ -12,14 +12,12 @@ *******************************************************************************/ package org.eclipse.kapua.service.job.steps; -import com.google.inject.Singleton; -import io.cucumber.java.After; -import io.cucumber.java.Before; -import io.cucumber.java.Scenario; -import io.cucumber.java.en.And; -import io.cucumber.java.en.Given; -import io.cucumber.java.en.Then; -import io.cucumber.java.en.When; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +import javax.inject.Inject; + import org.eclipse.kapua.KapuaEntityNotFoundException; import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.locator.KapuaLocator; @@ -46,10 +44,15 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.inject.Inject; -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Collectors; +import com.google.inject.Singleton; + +import io.cucumber.java.After; +import io.cucumber.java.Before; +import io.cucumber.java.Scenario; +import io.cucumber.java.en.And; +import io.cucumber.java.en.Given; +import io.cucumber.java.en.Then; +import io.cucumber.java.en.When; @Singleton public class JobTargetServiceSteps extends JobServiceTestBase { @@ -77,7 +80,7 @@ public void beforeScenarioNone(Scenario scenario) { public void setServices() { KapuaLocator locator = KapuaLocator.getInstance(); - deviceFactory= locator.getFactory(DeviceFactory.class); + deviceFactory = locator.getFactory(DeviceFactory.class); deviceRegistryService = locator.getService(DeviceRegistryService.class); jobTargetService = locator.getService(JobTargetService.class); @@ -126,7 +129,6 @@ public void iCreateANewJobTargetItem() throws Exception { } } - @And("I confirm the step index is different than {int} and status is {string}") public void iConfirmTheStepIndexIsDifferentThanAndStatusIs(int stepIndex, String status) { JobTarget jobTarget = (JobTarget) stepData.get(JOB_TARGET); @@ -134,7 +136,6 @@ public void iConfirmTheStepIndexIsDifferentThanAndStatusIs(int stepIndex, String Assert.assertEquals(status, jobTarget.getStatus().toString()); } - @And("I search for the job targets in database") public void iSearchForTheJobTargetsInDatabase() { ArrayList jobTargets = (ArrayList) stepData.get(JOB_TARGET_LIST); @@ -144,7 +145,8 @@ public void iSearchForTheJobTargetsInDatabase() { /** * Adds {@link Device}s with the given {@link Device#getClientId()}s as a {@link JobTarget} of the {@link Job} in context. * - * @param clientIds The {@link Device#getClientId()}s to add + * @param clientIds + * The {@link Device#getClientId()}s to add * @throws Exception * @since 2.1.0 */ @@ -367,23 +369,22 @@ public void checkThatNoTargetWasFound() { Assert.assertNull("Unexpected job target item found!", stepData.get(JOB_TARGET)); } - @When("I test the sanity of the job target factory") public void testTheJobTargetFactory() { Assert.assertNotNull(jobTargetFactory.newCreator(SYS_SCOPE_ID)); Assert.assertNotNull(jobTargetFactory.newEntity(SYS_SCOPE_ID)); - Assert.assertNotNull(jobTargetFactory.newListResult()); Assert.assertNotNull(jobTargetFactory.newQuery(SYS_SCOPE_ID)); } - // Check Job Targets /** * Checks that the {@link JobTarget} in context for the {@link Job} in context has the expected {@link JobTarget#getStepIndex()} and {@link JobTarget#getStatus()} * - * @param expectedStepIndex The expected {@link JobTarget#getStepIndex()} - * @param expectedJobTargetStatus The expected {@link JobTarget#getStatus()} + * @param expectedStepIndex + * The expected {@link JobTarget#getStepIndex()} + * @param expectedJobTargetStatus + * The expected {@link JobTarget#getStatus()} * @throws Exception * @since 2.1.0 */ @@ -396,11 +397,15 @@ public void checkJobTargetForJobInContextHas(int expectedStepIndex, String expec } /** - * Checks that the {@link JobTarget} that matches the {@link Device} with the given {@link Device#getClientId()} for the {@link Job} in context has the expected {@link JobTarget#getStepIndex()} and {@link JobTarget#getStatus()} + * Checks that the {@link JobTarget} that matches the {@link Device} with the given {@link Device#getClientId()} for the {@link Job} in context has the expected {@link JobTarget#getStepIndex()} + * and {@link JobTarget#getStatus()} * - * @param clientId The {@link Device#getClientId()} to look for - * @param expectedStepIndex The expected {@link JobTarget#getStepIndex()} - * @param expectedJobTargetStatus The expected {@link JobTarget#getStatus()} + * @param clientId + * The {@link Device#getClientId()} to look for + * @param expectedStepIndex + * The expected {@link JobTarget#getStepIndex()} + * @param expectedJobTargetStatus + * The expected {@link JobTarget#getStatus()} * @throws Exception * @since 2.1.0 */ @@ -416,10 +421,10 @@ public void checkJobTargetByNameForJobHas(String clientId, int expectedStepIndex JobTargetQuery jobTargetQuery = jobTargetFactory.newQuery(job.getScopeId()); jobTargetQuery.setPredicate( - jobTargetQuery.andPredicate( - jobTargetQuery.attributePredicate(JobTargetAttributes.JOB_ID, job.getId()), - jobTargetQuery.attributePredicate(JobTargetAttributes.JOB_TARGET_ID, device.getId()) - ) + jobTargetQuery.andPredicate( + jobTargetQuery.attributePredicate(JobTargetAttributes.JOB_ID, job.getId()), + jobTargetQuery.attributePredicate(JobTargetAttributes.JOB_TARGET_ID, device.getId()) + ) ); JobTarget jobTarget = jobTargetService.query(jobTargetQuery).getFirstItem(); @@ -434,8 +439,10 @@ public void checkJobTargetByNameForJobHas(String clientId, int expectedStepIndex /** * Checks that given {@link JobTarget} has the expected {@link JobTarget#getStepIndex()} and {@link JobTarget#getStatus()} * - * @param expectedStepIndex The expected {@link JobTarget#getStepIndex()} - * @param expectedJobTargetStatus The expected {@link JobTarget#getStatus()} + * @param expectedStepIndex + * The expected {@link JobTarget#getStepIndex()} + * @param expectedJobTargetStatus + * The expected {@link JobTarget#getStatus()} * @throws Exception * @since 2.1.0 */ @@ -470,13 +477,13 @@ private JobTargetCreator prepareDefaultJobTargetCreator() { private JobTargetStatus parseJobTargetStatusFromString(String stat) { switch (stat.toUpperCase().trim()) { - case "PROCESS_AWAITING": - return JobTargetStatus.PROCESS_AWAITING; - case "PROCESS_OK": - return JobTargetStatus.PROCESS_OK; - case "PROCESS_FAILED": - default: - return JobTargetStatus.PROCESS_FAILED; + case "PROCESS_AWAITING": + return JobTargetStatus.PROCESS_AWAITING; + case "PROCESS_OK": + return JobTargetStatus.PROCESS_OK; + case "PROCESS_FAILED": + default: + return JobTargetStatus.PROCESS_FAILED; } } } diff --git a/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/TriggerFactory.java b/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/TriggerFactory.java index cbf4d65b3af..728fa9a8813 100644 --- a/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/TriggerFactory.java +++ b/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/TriggerFactory.java @@ -21,14 +21,17 @@ * @see KapuaEntityFactory * @since 1.0.0 */ -public interface TriggerFactory extends KapuaEntityFactory { +public interface TriggerFactory extends KapuaEntityFactory { /** * Instantiates a new {@link TriggerProperty} * - * @param name The name to set into the {@link TriggerProperty}. - * @param type The type to set into the {@link TriggerProperty}. - * @param value The value to set into the {@link TriggerProperty}. + * @param name + * The name to set into the {@link TriggerProperty}. + * @param type + * The type to set into the {@link TriggerProperty}. + * @param value + * The value to set into the {@link TriggerProperty}. * @return The newly instatiated {@link TriggerProperty}. * @since 1.0.0 */ diff --git a/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/TriggerListResult.java b/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/TriggerListResult.java index 13d9269bb76..b66c2033051 100644 --- a/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/TriggerListResult.java +++ b/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/TriggerListResult.java @@ -12,13 +12,13 @@ *******************************************************************************/ package org.eclipse.kapua.service.scheduler.trigger; -import org.eclipse.kapua.model.query.KapuaListResult; - import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import org.eclipse.kapua.model.query.KapuaListResult; + /** * {@link Trigger} {@link KapuaListResult} definition. * @@ -27,6 +27,9 @@ */ @XmlRootElement(name = "scheduleListResult") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = TriggerXmlRegistry.class, factoryMethod = "newListResult") -public interface TriggerListResult extends KapuaListResult { +@XmlType +public class TriggerListResult extends KapuaListResult { + + private static final long serialVersionUID = -5118004898345748297L; + } diff --git a/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/TriggerXmlRegistry.java b/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/TriggerXmlRegistry.java index 60814fad7e5..93f2523a11e 100644 --- a/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/TriggerXmlRegistry.java +++ b/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/TriggerXmlRegistry.java @@ -12,11 +12,11 @@ *******************************************************************************/ package org.eclipse.kapua.service.scheduler.trigger; +import javax.xml.bind.annotation.XmlRegistry; + import org.eclipse.kapua.locator.KapuaLocator; import org.eclipse.kapua.service.scheduler.trigger.definition.TriggerProperty; -import javax.xml.bind.annotation.XmlRegistry; - /** * {@link Trigger} xml factory class * @@ -35,10 +35,6 @@ public TriggerCreator newCreator() { return triggerFactory.newCreator(null); } - public TriggerListResult newListResult() { - return triggerFactory.newListResult(); - } - public TriggerQuery newQuery() { return triggerFactory.newQuery(null); } diff --git a/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/definition/TriggerDefinitionFactory.java b/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/definition/TriggerDefinitionFactory.java index fac9db3f880..c8f10f4663f 100644 --- a/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/definition/TriggerDefinitionFactory.java +++ b/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/definition/TriggerDefinitionFactory.java @@ -20,14 +20,17 @@ * @see KapuaEntityFactory * @since 1.1.0 */ -public interface TriggerDefinitionFactory extends KapuaEntityFactory { +public interface TriggerDefinitionFactory extends KapuaEntityFactory { /** * Instantiates a new {@link TriggerProperty}. * - * @param name The name to set into the {@link TriggerProperty}. - * @param type The type to set into the {@link TriggerProperty}. - * @param value The value to set into the {@link TriggerProperty}. + * @param name + * The name to set into the {@link TriggerProperty}. + * @param type + * The type to set into the {@link TriggerProperty}. + * @param value + * The value to set into the {@link TriggerProperty}. * @return The newly instantiated {@link TriggerProperty}. * @since 1.1.0 */ diff --git a/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/definition/TriggerDefinitionListResult.java b/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/definition/TriggerDefinitionListResult.java index 82e707bc26b..b7aa84a052f 100644 --- a/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/definition/TriggerDefinitionListResult.java +++ b/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/definition/TriggerDefinitionListResult.java @@ -12,13 +12,13 @@ *******************************************************************************/ package org.eclipse.kapua.service.scheduler.trigger.definition; -import org.eclipse.kapua.model.query.KapuaListResult; - import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import org.eclipse.kapua.model.query.KapuaListResult; + /** * {@link TriggerDefinition} {@link KapuaListResult} definition. * @@ -27,7 +27,9 @@ */ @XmlRootElement(name = "triggerDefinitionListResult") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = TriggerDefinitionXmlRegistry.class, factoryMethod = "newListResult") -public interface TriggerDefinitionListResult extends KapuaListResult { +@XmlType +public class TriggerDefinitionListResult extends KapuaListResult { + + private static final long serialVersionUID = 977813250632719295L; } diff --git a/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/definition/TriggerDefinitionXmlRegistry.java b/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/definition/TriggerDefinitionXmlRegistry.java index 6303d16a524..24994cfc93b 100644 --- a/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/definition/TriggerDefinitionXmlRegistry.java +++ b/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/definition/TriggerDefinitionXmlRegistry.java @@ -12,10 +12,10 @@ *******************************************************************************/ package org.eclipse.kapua.service.scheduler.trigger.definition; -import org.eclipse.kapua.locator.KapuaLocator; - import javax.xml.bind.annotation.XmlRegistry; +import org.eclipse.kapua.locator.KapuaLocator; + /** * {@link TriggerDefinition} xml factory class * @@ -34,10 +34,6 @@ public TriggerDefinitionCreator newCreator() { return triggerDefinitionFactory.newCreator(null); } - public TriggerDefinitionListResult newListResult() { - return triggerDefinitionFactory.newListResult(); - } - public TriggerDefinitionQuery newQuery() { return triggerDefinitionFactory.newQuery(null); } diff --git a/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/fired/FiredTriggerFactory.java b/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/fired/FiredTriggerFactory.java index 01a68558f16..a666528f17e 100644 --- a/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/fired/FiredTriggerFactory.java +++ b/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/fired/FiredTriggerFactory.java @@ -20,5 +20,6 @@ * @see KapuaEntityFactory * @since 1.5.0 */ -public interface FiredTriggerFactory extends KapuaEntityFactory { +public interface FiredTriggerFactory extends KapuaEntityFactory { + } diff --git a/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/fired/FiredTriggerListResult.java b/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/fired/FiredTriggerListResult.java index 4f0a10bbfe0..e58137f685b 100644 --- a/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/fired/FiredTriggerListResult.java +++ b/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/fired/FiredTriggerListResult.java @@ -12,13 +12,13 @@ *******************************************************************************/ package org.eclipse.kapua.service.scheduler.trigger.fired; -import org.eclipse.kapua.model.query.KapuaListResult; - import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import org.eclipse.kapua.model.query.KapuaListResult; + /** * {@link FiredTrigger} {@link KapuaListResult} definition. * @@ -26,7 +26,7 @@ */ @XmlRootElement(name = "firedTriggerListResult") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = FiredTriggerXmlRegistry.class, factoryMethod = "newListResult") -public interface FiredTriggerListResult extends KapuaListResult { +@XmlType +public class FiredTriggerListResult extends KapuaListResult { } diff --git a/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/fired/FiredTriggerXmlRegistry.java b/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/fired/FiredTriggerXmlRegistry.java index a7f6222ca4c..eea6c01f05f 100644 --- a/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/fired/FiredTriggerXmlRegistry.java +++ b/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/fired/FiredTriggerXmlRegistry.java @@ -12,10 +12,10 @@ *******************************************************************************/ package org.eclipse.kapua.service.scheduler.trigger.fired; -import org.eclipse.kapua.locator.KapuaLocator; - import javax.xml.bind.annotation.XmlRegistry; +import org.eclipse.kapua.locator.KapuaLocator; + /** * {@link FiredTrigger} xml factory class. * @@ -34,10 +34,6 @@ public FiredTriggerCreator newCreator() { return firedTriggerFactory.newCreator(null); } - public FiredTriggerListResult newListResult() { - return firedTriggerFactory.newListResult(); - } - public FiredTriggerQuery newQuery() { return firedTriggerFactory.newQuery(null); } diff --git a/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/definition/quartz/TriggerDefinitionFactoryImpl.java b/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/definition/quartz/TriggerDefinitionFactoryImpl.java index f69c6742196..4e85f48cbe6 100644 --- a/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/definition/quartz/TriggerDefinitionFactoryImpl.java +++ b/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/definition/quartz/TriggerDefinitionFactoryImpl.java @@ -12,17 +12,16 @@ *******************************************************************************/ package org.eclipse.kapua.service.scheduler.trigger.definition.quartz; +import javax.inject.Singleton; + import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.scheduler.trigger.definition.TriggerDefinition; import org.eclipse.kapua.service.scheduler.trigger.definition.TriggerDefinitionCreator; import org.eclipse.kapua.service.scheduler.trigger.definition.TriggerDefinitionFactory; -import org.eclipse.kapua.service.scheduler.trigger.definition.TriggerDefinitionListResult; import org.eclipse.kapua.service.scheduler.trigger.definition.TriggerDefinitionQuery; import org.eclipse.kapua.service.scheduler.trigger.definition.TriggerProperty; -import javax.inject.Singleton; - /** * {@link TriggerDefinitionFactory} implementation. * @@ -46,11 +45,6 @@ public TriggerDefinitionQuery newQuery(KapuaId scopeId) { return new TriggerDefinitionQueryImpl(scopeId); } - @Override - public TriggerDefinitionListResult newListResult() { - return new TriggerDefinitionListResultImpl(); - } - @Override public TriggerProperty newTriggerProperty(String name, String type, String value) { return new TriggerPropertyImpl(name, type, value); diff --git a/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/definition/quartz/TriggerDefinitionImplJpaRepository.java b/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/definition/quartz/TriggerDefinitionImplJpaRepository.java index 5d1ab2ce348..224fc38e96e 100644 --- a/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/definition/quartz/TriggerDefinitionImplJpaRepository.java +++ b/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/definition/quartz/TriggerDefinitionImplJpaRepository.java @@ -21,7 +21,8 @@ public class TriggerDefinitionImplJpaRepository extends KapuaNamedEntityJpaRepository implements TriggerDefinitionRepository { + public TriggerDefinitionImplJpaRepository(KapuaJpaRepositoryConfiguration jpaRepoConfig) { - super(TriggerDefinitionImpl.class, TriggerDefinition.TYPE, () -> new TriggerDefinitionListResultImpl(), jpaRepoConfig); + super(TriggerDefinitionImpl.class, TriggerDefinition.TYPE, () -> new TriggerDefinitionListResult(), jpaRepoConfig); } } diff --git a/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/definition/quartz/TriggerDefinitionListResultImpl.java b/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/definition/quartz/TriggerDefinitionListResultImpl.java deleted file mode 100644 index 978cd775cc6..00000000000 --- a/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/definition/quartz/TriggerDefinitionListResultImpl.java +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2019, 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.service.scheduler.trigger.definition.quartz; - -import org.eclipse.kapua.commons.model.query.KapuaListResultImpl; -import org.eclipse.kapua.service.scheduler.trigger.definition.TriggerDefinition; -import org.eclipse.kapua.service.scheduler.trigger.definition.TriggerDefinitionListResult; - -/** - * {@link TriggerDefinitionListResult} definition. - * - * @since 1.1.0 - */ -public class TriggerDefinitionListResultImpl extends KapuaListResultImpl implements TriggerDefinitionListResult { - - private static final long serialVersionUID = 977813250632719295L; - -} diff --git a/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/fired/quartz/FiredTriggerFactoryImpl.java b/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/fired/quartz/FiredTriggerFactoryImpl.java index 991f69b1603..74812094769 100644 --- a/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/fired/quartz/FiredTriggerFactoryImpl.java +++ b/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/fired/quartz/FiredTriggerFactoryImpl.java @@ -12,16 +12,15 @@ *******************************************************************************/ package org.eclipse.kapua.service.scheduler.trigger.fired.quartz; +import javax.inject.Singleton; + import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.scheduler.trigger.fired.FiredTrigger; import org.eclipse.kapua.service.scheduler.trigger.fired.FiredTriggerCreator; import org.eclipse.kapua.service.scheduler.trigger.fired.FiredTriggerFactory; -import org.eclipse.kapua.service.scheduler.trigger.fired.FiredTriggerListResult; import org.eclipse.kapua.service.scheduler.trigger.fired.FiredTriggerQuery; -import javax.inject.Singleton; - /** * {@link FiredTriggerFactory} implementation. * @@ -45,11 +44,6 @@ public FiredTriggerQuery newQuery(KapuaId scopeId) { return new FiredTriggerQueryImpl(scopeId); } - @Override - public FiredTriggerListResult newListResult() { - return new FiredTriggerListResultImpl(); - } - @Override public FiredTrigger clone(FiredTrigger firedTrigger) { try { diff --git a/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/fired/quartz/FiredTriggerImplJpaRepository.java b/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/fired/quartz/FiredTriggerImplJpaRepository.java index 99f95315d1a..39af73e1fff 100644 --- a/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/fired/quartz/FiredTriggerImplJpaRepository.java +++ b/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/fired/quartz/FiredTriggerImplJpaRepository.java @@ -21,8 +21,9 @@ public class FiredTriggerImplJpaRepository extends KapuaEntityJpaRepository implements FiredTriggerRepository { + public FiredTriggerImplJpaRepository(KapuaJpaRepositoryConfiguration configuration) { - super(FiredTriggerImpl.class, FiredTrigger.TYPE, () -> new FiredTriggerListResultImpl(), configuration); + super(FiredTriggerImpl.class, FiredTrigger.TYPE, () -> new FiredTriggerListResult(), configuration); } } diff --git a/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/fired/quartz/FiredTriggerListResultImpl.java b/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/fired/quartz/FiredTriggerListResultImpl.java deleted file mode 100644 index 7f0a93c0f41..00000000000 --- a/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/fired/quartz/FiredTriggerListResultImpl.java +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2021, 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.service.scheduler.trigger.fired.quartz; - -import org.eclipse.kapua.commons.model.query.KapuaListResultImpl; -import org.eclipse.kapua.service.scheduler.trigger.fired.FiredTrigger; -import org.eclipse.kapua.service.scheduler.trigger.fired.FiredTriggerListResult; - -/** - * {@link FiredTriggerListResult} implementation. - * - * @since 1.5.0 - */ -public class FiredTriggerListResultImpl extends KapuaListResultImpl implements FiredTriggerListResult { -} diff --git a/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/quartz/TriggerFactoryImpl.java b/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/quartz/TriggerFactoryImpl.java index 2b924c6e397..399b2f141f8 100644 --- a/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/quartz/TriggerFactoryImpl.java +++ b/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/quartz/TriggerFactoryImpl.java @@ -12,18 +12,17 @@ *******************************************************************************/ package org.eclipse.kapua.service.scheduler.trigger.quartz; +import javax.inject.Singleton; + import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.scheduler.trigger.Trigger; import org.eclipse.kapua.service.scheduler.trigger.TriggerCreator; import org.eclipse.kapua.service.scheduler.trigger.TriggerFactory; -import org.eclipse.kapua.service.scheduler.trigger.TriggerListResult; import org.eclipse.kapua.service.scheduler.trigger.TriggerQuery; import org.eclipse.kapua.service.scheduler.trigger.definition.TriggerProperty; import org.eclipse.kapua.service.scheduler.trigger.definition.quartz.TriggerPropertyImpl; -import javax.inject.Singleton; - /** * {@link TriggerFactory} implementation. * @@ -47,11 +46,6 @@ public TriggerQuery newQuery(KapuaId scopeId) { return new TriggerQueryImpl(scopeId); } - @Override - public TriggerListResult newListResult() { - return new TriggerListResultImpl(); - } - @Override public TriggerProperty newTriggerProperty(String name, String type, String value) { return new TriggerPropertyImpl(name, type, value); diff --git a/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/quartz/TriggerImplJpaRepository.java b/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/quartz/TriggerImplJpaRepository.java index 5e4e056cc2f..d95e4f48a88 100644 --- a/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/quartz/TriggerImplJpaRepository.java +++ b/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/quartz/TriggerImplJpaRepository.java @@ -12,6 +12,12 @@ *******************************************************************************/ package org.eclipse.kapua.service.scheduler.trigger.quartz; +import javax.persistence.criteria.CriteriaBuilder; +import javax.persistence.criteria.CriteriaDelete; +import javax.persistence.criteria.JoinType; +import javax.persistence.criteria.ListJoin; +import javax.persistence.criteria.Root; + import org.eclipse.kapua.commons.jpa.JpaAwareTxContext; import org.eclipse.kapua.commons.jpa.KapuaJpaRepositoryConfiguration; import org.eclipse.kapua.commons.jpa.KapuaNamedEntityJpaRepository; @@ -24,18 +30,12 @@ import org.eclipse.kapua.service.scheduler.trigger.definition.quartz.TriggerPropertyImpl_; import org.eclipse.kapua.storage.TxContext; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.CriteriaDelete; -import javax.persistence.criteria.JoinType; -import javax.persistence.criteria.ListJoin; -import javax.persistence.criteria.Root; - public class TriggerImplJpaRepository extends KapuaNamedEntityJpaRepository implements TriggerRepository { public TriggerImplJpaRepository(KapuaJpaRepositoryConfiguration jpaRepoConfig) { - super(TriggerImpl.class, Trigger.TYPE, () -> new TriggerListResultImpl(), jpaRepoConfig); + super(TriggerImpl.class, Trigger.TYPE, () -> new TriggerListResult(), jpaRepoConfig); } @Override diff --git a/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/quartz/TriggerListResultImpl.java b/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/quartz/TriggerListResultImpl.java deleted file mode 100644 index 5004338a596..00000000000 --- a/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/quartz/TriggerListResultImpl.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017, 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.service.scheduler.trigger.quartz; - -import org.eclipse.kapua.commons.model.query.KapuaListResultImpl; -import org.eclipse.kapua.service.scheduler.trigger.Trigger; -import org.eclipse.kapua.service.scheduler.trigger.TriggerListResult; - -/** - * {@link TriggerListResult} implementation. - * - * @since 1.0.0 - */ -public class TriggerListResultImpl extends KapuaListResultImpl implements TriggerListResult { - - private static final long serialVersionUID = -5118004898345748297L; -} diff --git a/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/quartz/TriggerServiceImpl.java b/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/quartz/TriggerServiceImpl.java index 5dbd613e106..74920b767bd 100755 --- a/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/quartz/TriggerServiceImpl.java +++ b/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/quartz/TriggerServiceImpl.java @@ -19,6 +19,7 @@ import java.util.Optional; import java.util.function.Function; import java.util.stream.Collectors; + import javax.inject.Singleton; import javax.validation.constraints.NotNull; @@ -122,7 +123,8 @@ public Trigger create(TriggerCreator triggerCreator) throws KapuaException { TriggerDefinition triggerDefinition = triggerDefinitionRepository.find(tx, KapuaId.ANY, triggerCreator.getTriggerDefinitionId()) .orElseThrow(() -> new KapuaEntityNotFoundException(TriggerDefinition.TYPE, triggerCreator.getTriggerDefinitionId())); - final Map triggerDefinitionPropertiesByName = triggerDefinition.getTriggerProperties().stream().collect(Collectors.toMap(jsdp -> jsdp.getName(), Function.identity())); + final Map triggerDefinitionPropertiesByName = triggerDefinition.getTriggerProperties().stream() + .collect(Collectors.toMap(jsdp -> jsdp.getName(), Function.identity())); for (TriggerProperty jsp : triggerCreator.getTriggerProperties()) { final TriggerProperty jsdp = triggerDefinitionPropertiesByName.get(jsp.getName()); if (jsdp == null) { @@ -312,7 +314,7 @@ public TriggerListResult query(KapuaQuery query) throws KapuaException { return txManager.execute(tx -> { // Do query TriggerListResult triggers = triggerRepository.query(tx, query); - final TriggerListResult res = triggerFactory.newListResult(); + final TriggerListResult res = new TriggerListResult(); for (Trigger trigger : triggers.getItems()) { res.addItem(adaptTrigger(tx, trigger)); } @@ -349,7 +351,8 @@ public long count(KapuaQuery query) throws KapuaException { * Gets the {@link TriggerDefinition} named 'Interval Job' * * @return he {@link TriggerDefinition} named 'Interval Job' - * @throws KapuaException In case is not found. + * @throws KapuaException + * In case is not found. * @since 1.1.0 */ private synchronized TriggerDefinition getIntervalJobTriggerDefinition() throws KapuaException { @@ -364,7 +367,8 @@ private synchronized TriggerDefinition getIntervalJobTriggerDefinition() throws * Gets the {@link TriggerDefinition} named 'Cron Job' * * @return he {@link TriggerDefinition} named 'Cron Job' - * @throws KapuaException In case is not found. + * @throws KapuaException + * In case is not found. * @since 1.1.0 */ private synchronized TriggerDefinition getCronJobTriggerDefinition() throws KapuaException { @@ -378,9 +382,11 @@ private synchronized TriggerDefinition getCronJobTriggerDefinition() throws Kapu /** * Gets the {@link TriggerDefinition} by the given name. * - * @param triggerDefinitionName The {@link TriggerDefinition#getName()} to look for. + * @param triggerDefinitionName + * The {@link TriggerDefinition#getName()} to look for. * @return The {@link TriggerDefinition} by the given name. - * @throws KapuaException In case nothing is found. + * @throws KapuaException + * In case nothing is found. * @since 1.1.0 */ private synchronized TriggerDefinition getTriggerDefinition(String triggerDefinitionName) throws KapuaException { @@ -390,11 +396,12 @@ private synchronized TriggerDefinition getTriggerDefinition(String triggerDefini } /** - * Adapts {@link TriggerCreator#getRetryInterval()} and {@link TriggerCreator#getCronScheduling()} to the new model - * which make use of {@link TriggerDefinition}s + * Adapts {@link TriggerCreator#getRetryInterval()} and {@link TriggerCreator#getCronScheduling()} to the new model which make use of {@link TriggerDefinition}s * - * @param triggerCreator The {@link TriggerCreator} to adapt. - * @throws KapuaException In case that {@link TriggerDefinition} is not found. + * @param triggerCreator + * The {@link TriggerCreator} to adapt. + * @throws KapuaException + * In case that {@link TriggerDefinition} is not found. * @since 1.1.0 */ private void adaptTriggerCreator(TriggerCreator triggerCreator) throws KapuaException { @@ -408,12 +415,13 @@ private void adaptTriggerCreator(TriggerCreator triggerCreator) throws KapuaExce } /** - * Adapts {@link Trigger#getRetryInterval()} and {@link Trigger#getCronScheduling()} to the new model - * which make use of {@link TriggerDefinition}s + * Adapts {@link Trigger#getRetryInterval()} and {@link Trigger#getCronScheduling()} to the new model which make use of {@link TriggerDefinition}s * - * @param trigger The {@link Trigger} to adapt. + * @param trigger + * The {@link Trigger} to adapt. * @return - * @throws KapuaException In case that {@link TriggerDefinition} is not found. + * @throws KapuaException + * In case that {@link TriggerDefinition} is not found. * @since 1.1.0 */ private @NotNull Trigger adaptTrigger(TxContext tx, @NotNull Trigger trigger) throws KapuaException { diff --git a/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/credential/CredentialFactory.java b/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/credential/CredentialFactory.java index 42434a61f87..1e31dab6b5a 100644 --- a/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/credential/CredentialFactory.java +++ b/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/credential/CredentialFactory.java @@ -12,27 +12,33 @@ *******************************************************************************/ package org.eclipse.kapua.service.authentication.credential; +import java.util.Date; + import org.eclipse.kapua.model.KapuaEntityFactory; import org.eclipse.kapua.model.id.KapuaId; -import java.util.Date; - /** * {@link Credential} {@link KapuaEntityFactory} definition. * * @since 1.0.0 */ -public interface CredentialFactory extends KapuaEntityFactory { +public interface CredentialFactory extends KapuaEntityFactory { /** * Instantiates a new {@link Credential}. * - * @param scopeId The scope {@link KapuaId} to set into the {@link Credential}. - * @param userId The {@link org.eclipse.kapua.service.user.User} {@link KapuaId} to set into the {@link Credential}. - * @param credentialType The {@link Credential} type to set into the {@link Credential}. - * @param credentialKey The key to set into the {@link Credential}. - * @param credentialStatus The {@link CredentialStatus} to set into the {@link Credential}. - * @param expirationDate The expiration date to set into the {@link Credential}. + * @param scopeId + * The scope {@link KapuaId} to set into the {@link Credential}. + * @param userId + * The {@link org.eclipse.kapua.service.user.User} {@link KapuaId} to set into the {@link Credential}. + * @param credentialType + * The {@link Credential} type to set into the {@link Credential}. + * @param credentialKey + * The key to set into the {@link Credential}. + * @param credentialStatus + * The {@link CredentialStatus} to set into the {@link Credential}. + * @param expirationDate + * The expiration date to set into the {@link Credential}. * @return The newly instantiated {@link Credential} * @since 1.0.0 */ @@ -41,12 +47,18 @@ public interface CredentialFactory extends KapuaEntityFactory { +@XmlType +public class CredentialListResult extends KapuaListResult { + + static final long serialVersionUID = -7949012585401032274L; } diff --git a/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/credential/CredentialXmlRegistry.java b/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/credential/CredentialXmlRegistry.java index 0c4fa741366..6b571b48204 100644 --- a/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/credential/CredentialXmlRegistry.java +++ b/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/credential/CredentialXmlRegistry.java @@ -12,10 +12,10 @@ *******************************************************************************/ package org.eclipse.kapua.service.authentication.credential; -import org.eclipse.kapua.locator.KapuaLocator; - import javax.xml.bind.annotation.XmlRegistry; +import org.eclipse.kapua.locator.KapuaLocator; + /** * The {@link Credential} {@link XmlRegistry} * @@ -46,16 +46,6 @@ public CredentialCreator newCredentialCreator() { return credentialFactory.newCreator(null, null, null, null, null, null); } - /** - * Instantiates a new {@link CredentialListResult}. - * - * @return The newly instantiated {@link CredentialListResult} - * @since 1.0.0 - */ - public CredentialListResult newCredentialListResult() { - return credentialFactory.newListResult(); - } - /** * Instantiates a new {@link CredentialQuery}. * diff --git a/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/MfaOptionFactory.java b/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/MfaOptionFactory.java index 72734309d73..c21a9c159d9 100644 --- a/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/MfaOptionFactory.java +++ b/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/MfaOptionFactory.java @@ -22,13 +22,15 @@ * @see KapuaEntityFactory * @since 1.3.0 */ -public interface MfaOptionFactory extends KapuaEntityFactory { +public interface MfaOptionFactory extends KapuaEntityFactory { /** * Instantiates a new {@link MfaOptionCreator}. * - * @param scopeId The scope {@link KapuaId} to set into the {@link MfaOptionCreator}. - * @param userId The {@link org.eclipse.kapua.service.user.User} {@link KapuaId} to set into the{@link AccessToken}. + * @param scopeId + * The scope {@link KapuaId} to set into the {@link MfaOptionCreator}. + * @param userId + * The {@link org.eclipse.kapua.service.user.User} {@link KapuaId} to set into the{@link AccessToken}. * @return The newly instantiated {@link MfaOptionCreator} * @since 1.3.0 */ diff --git a/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/MfaOptionListResult.java b/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/MfaOptionListResult.java index 2f9ebbcd453..bc729c21269 100644 --- a/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/MfaOptionListResult.java +++ b/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/MfaOptionListResult.java @@ -12,13 +12,13 @@ *******************************************************************************/ package org.eclipse.kapua.service.authentication.credential.mfa; -import org.eclipse.kapua.model.query.KapuaListResult; - import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import org.eclipse.kapua.model.query.KapuaListResult; + /** * {@link MfaOption} {@link KapuaListResult} definition. * @@ -26,7 +26,9 @@ */ @XmlRootElement(name = "mfaOptionListResult") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = MfaOptionXmlRegistry.class, factoryMethod = "newMfaOptionListResult") -public interface MfaOptionListResult extends KapuaListResult { +@XmlType +public class MfaOptionListResult extends KapuaListResult { + + private static final long serialVersionUID = -4204695192086365901L; } diff --git a/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/MfaOptionXmlRegistry.java b/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/MfaOptionXmlRegistry.java index 033942201c0..773adea771e 100644 --- a/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/MfaOptionXmlRegistry.java +++ b/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/MfaOptionXmlRegistry.java @@ -12,10 +12,10 @@ *******************************************************************************/ package org.eclipse.kapua.service.authentication.credential.mfa; -import org.eclipse.kapua.locator.KapuaLocator; - import javax.xml.bind.annotation.XmlRegistry; +import org.eclipse.kapua.locator.KapuaLocator; + @XmlRegistry public class MfaOptionXmlRegistry { @@ -41,16 +41,6 @@ public MfaOption newMfaOption() { return mfaOptionFactory.newEntity(null); } - /** - * Instantiates a new {@link MfaOptionListResult} instance - * - * @return The newly instantiated {@link MfaOptionListResult} - * @since 1.3.0 - */ - public MfaOptionListResult newMfaOptionListResult() { - return mfaOptionFactory.newListResult(); - } - /** * Instantiates a new {@link MfaOptionQuery} instance. * diff --git a/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/ScratchCodeFactory.java b/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/ScratchCodeFactory.java index d055ddcc70e..d1d702a6e49 100644 --- a/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/ScratchCodeFactory.java +++ b/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/ScratchCodeFactory.java @@ -15,7 +15,6 @@ import org.eclipse.kapua.model.KapuaEntityFactory; import org.eclipse.kapua.model.KapuaObjectFactory; import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.model.query.KapuaListResult; /** * {@link ScratchCode} {@link KapuaEntityFactory} definition. @@ -27,26 +26,23 @@ public interface ScratchCodeFactory extends KapuaObjectFactory { /** * Instantiates a new {@link ScratchCode}. - * @param scopeId The {@link ScratchCode#getScopeId()} + * + * @param scopeId + * The {@link ScratchCode#getScopeId()} * @return The newly instantiated {@link ScratchCode} * @since 1.3.0 */ ScratchCode newEntity(KapuaId scopeId); - /** - * Instantiates a new {@link KapuaListResult}. - * - * @return The newly instantiated {@link KapuaListResult} - * @since 1.0.0 - */ - ScratchCodeListResult newListResult(); - /** * Instantiates a new {@link ScratchCode}. * - * @param scopeId The {@link ScratchCode#getScopeId()} - * @param mfaOptionId The {@link MfaOption#getId()} - * @param code The {@link ScratchCode#getCode()}. + * @param scopeId + * The {@link ScratchCode#getScopeId()} + * @param mfaOptionId + * The {@link MfaOption#getId()} + * @param code + * The {@link ScratchCode#getCode()}. * @return The newly instantiated {@link ScratchCode} * @since 1.3.0 */ diff --git a/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/ScratchCodeListResult.java b/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/ScratchCodeListResult.java index a34014fb6e6..9d375196a40 100644 --- a/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/ScratchCodeListResult.java +++ b/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/ScratchCodeListResult.java @@ -12,19 +12,21 @@ *******************************************************************************/ package org.eclipse.kapua.service.authentication.credential.mfa; -import org.eclipse.kapua.model.query.KapuaListResult; - import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import org.eclipse.kapua.model.query.KapuaListResult; + /** * {@link ScratchCode} {@link KapuaListResult} definition. */ @XmlRootElement(name = "scratchCodeListResult") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = ScratchCodeXmlRegistry.class, factoryMethod = "newScratchCodeListResult") -public interface ScratchCodeListResult extends KapuaListResult { +@XmlType +public class ScratchCodeListResult extends KapuaListResult { + + private static final long serialVersionUID = -5154461760797879319L; } diff --git a/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/ScratchCodeXmlRegistry.java b/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/ScratchCodeXmlRegistry.java index 41a194f7b52..726ab4f071c 100644 --- a/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/ScratchCodeXmlRegistry.java +++ b/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/ScratchCodeXmlRegistry.java @@ -12,10 +12,10 @@ *******************************************************************************/ package org.eclipse.kapua.service.authentication.credential.mfa; -import org.eclipse.kapua.locator.KapuaLocator; - import javax.xml.bind.annotation.XmlRegistry; +import org.eclipse.kapua.locator.KapuaLocator; + @XmlRegistry public class ScratchCodeXmlRegistry { @@ -30,14 +30,4 @@ public class ScratchCodeXmlRegistry { public ScratchCode newScratchCode() { return scratchCodeFactory.newEntity(null); } - - /** - * Instantiates a new {@link ScratchCodeListResult} instance - * - * @return The newly instantiated {@link ScratchCodeListResult} - * @since 1.3.0 - */ - public ScratchCodeListResult newScratchCodeListResult() { - return scratchCodeFactory.newListResult(); - } } diff --git a/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/token/AccessTokenFactory.java b/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/token/AccessTokenFactory.java index 5aabab8123b..376817c9d1d 100644 --- a/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/token/AccessTokenFactory.java +++ b/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/token/AccessTokenFactory.java @@ -12,27 +12,32 @@ *******************************************************************************/ package org.eclipse.kapua.service.authentication.token; +import java.util.Date; + import org.eclipse.kapua.model.KapuaEntityFactory; import org.eclipse.kapua.model.id.KapuaId; -import java.util.Date; - /** * {@link AccessTokenFactory} definition. * * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface AccessTokenFactory extends KapuaEntityFactory { +public interface AccessTokenFactory extends KapuaEntityFactory { /** * Instantiates a new {@link AccessTokenCreator}. * - * @param scopeId The scope {@link KapuaId} to set into the{@link AccessToken}. - * @param userId The {@link org.eclipse.kapua.service.user.User} {@link KapuaId} to set into the{@link AccessToken}. - * @param tokenId The token id to set into the{@link AccessToken}. - * @param expiresOn The expiration date to set into the{@link AccessToken}. - * @param refreshToken The refresh token to set into the{@link AccessToken}. + * @param scopeId + * The scope {@link KapuaId} to set into the{@link AccessToken}. + * @param userId + * The {@link org.eclipse.kapua.service.user.User} {@link KapuaId} to set into the{@link AccessToken}. + * @param tokenId + * The token id to set into the{@link AccessToken}. + * @param expiresOn + * The expiration date to set into the{@link AccessToken}. + * @param refreshToken + * The refresh token to set into the{@link AccessToken}. * @return The newly instantiated {@link AccessTokenCreator}. * @since 1.0.0 */ diff --git a/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/token/AccessTokenListResult.java b/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/token/AccessTokenListResult.java index 1aac02406e8..6ce21f55b6f 100644 --- a/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/token/AccessTokenListResult.java +++ b/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/token/AccessTokenListResult.java @@ -18,8 +18,9 @@ * Access token list result definition. * * @since 1.0 - * */ -public interface AccessTokenListResult extends KapuaListResult { +public class AccessTokenListResult extends KapuaListResult { + + private static final long serialVersionUID = -2596004122285166444L; } diff --git a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessInfoFactory.java b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessInfoFactory.java index 0e90817c47c..941d00df0bc 100644 --- a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessInfoFactory.java +++ b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessInfoFactory.java @@ -20,6 +20,6 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface AccessInfoFactory extends KapuaEntityFactory { +public interface AccessInfoFactory extends KapuaEntityFactory { } diff --git a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessInfoListResult.java b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessInfoListResult.java index 386d15a601a..c9ffc9f7c3f 100644 --- a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessInfoListResult.java +++ b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessInfoListResult.java @@ -23,7 +23,9 @@ * @since 1.0.0 */ @XmlRootElement(name = "accessInfos") -@XmlType(factoryClass = AccessInfoXmlRegistry.class, factoryMethod = "newAccessInfoListResult") -public interface AccessInfoListResult extends KapuaListResult { +@XmlType +public class AccessInfoListResult extends KapuaListResult { + + static final long serialVersionUID = 2231053707705207563L; } diff --git a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessInfoXmlRegistry.java b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessInfoXmlRegistry.java index f856ce81d65..78a7a8e4732 100644 --- a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessInfoXmlRegistry.java +++ b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessInfoXmlRegistry.java @@ -12,10 +12,10 @@ *******************************************************************************/ package org.eclipse.kapua.service.authorization.access; -import org.eclipse.kapua.locator.KapuaLocator; - import javax.xml.bind.annotation.XmlRegistry; +import org.eclipse.kapua.locator.KapuaLocator; + @XmlRegistry public class AccessInfoXmlRegistry { @@ -39,15 +39,6 @@ public AccessInfoCreator newAccessInfoCreator() { return accessInfoFactory.newCreator(null); } - /** - * Creates a new {@link AccessInfoListResult} instance - * - * @return - */ - public AccessInfoListResult newAccessInfoListResult() { - return accessInfoFactory.newListResult(); - } - public AccessInfoQuery newQuery() { return accessInfoFactory.newQuery(null); } diff --git a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessPermissionFactory.java b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessPermissionFactory.java index 02f84fab518..f8958976955 100644 --- a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessPermissionFactory.java +++ b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessPermissionFactory.java @@ -20,6 +20,6 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface AccessPermissionFactory extends KapuaEntityFactory { +public interface AccessPermissionFactory extends KapuaEntityFactory { } diff --git a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessPermissionListResult.java b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessPermissionListResult.java index a2d61dabed3..2ab808b4973 100644 --- a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessPermissionListResult.java +++ b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessPermissionListResult.java @@ -23,7 +23,9 @@ * @since 1.0.0 */ @XmlRootElement(name = "accessPermissions") -@XmlType(factoryClass = AccessPermissionXmlRegistry.class, factoryMethod = "newAccessPermissionListResult") -public interface AccessPermissionListResult extends KapuaListResult { +@XmlType +public class AccessPermissionListResult extends KapuaListResult { + + private static final long serialVersionUID = -7673771564266332772L; } diff --git a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessPermissionXmlRegistry.java b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessPermissionXmlRegistry.java index c34f043188d..fd14485b1b9 100644 --- a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessPermissionXmlRegistry.java +++ b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessPermissionXmlRegistry.java @@ -12,10 +12,10 @@ *******************************************************************************/ package org.eclipse.kapua.service.authorization.access; -import org.eclipse.kapua.locator.KapuaLocator; - import javax.xml.bind.annotation.XmlRegistry; +import org.eclipse.kapua.locator.KapuaLocator; + @XmlRegistry public class AccessPermissionXmlRegistry { @@ -39,15 +39,6 @@ public AccessPermissionCreator newCreator() { return accessPermissionFactory.newCreator(null); } - /** - * Creates a new {@link AccessPermission} instance - * - * @return - */ - public AccessPermissionListResult newAccessPermissionListResult() { - return accessPermissionFactory.newListResult(); - } - public AccessPermissionQuery newQuery() { return accessPermissionFactory.newQuery(null); } diff --git a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessRoleFactory.java b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessRoleFactory.java index f4e158d1310..5e9ff8007bc 100644 --- a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessRoleFactory.java +++ b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessRoleFactory.java @@ -20,6 +20,6 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface AccessRoleFactory extends KapuaEntityFactory { +public interface AccessRoleFactory extends KapuaEntityFactory { } diff --git a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessRoleListResult.java b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessRoleListResult.java index 5a54983a4c8..7cb32c9f004 100644 --- a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessRoleListResult.java +++ b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessRoleListResult.java @@ -23,7 +23,9 @@ * @since 1.0.0 */ @XmlRootElement(name = "accessPermissions") -@XmlType(factoryClass = AccessRoleXmlRegistry.class, factoryMethod = "newAccessRoleListResult") -public interface AccessRoleListResult extends KapuaListResult { +@XmlType +public class AccessRoleListResult extends KapuaListResult { + + private static final long serialVersionUID = 2406073775830391702L; } diff --git a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessRoleXmlRegistry.java b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessRoleXmlRegistry.java index 0b8ef61befc..1131edbd059 100644 --- a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessRoleXmlRegistry.java +++ b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessRoleXmlRegistry.java @@ -12,10 +12,10 @@ *******************************************************************************/ package org.eclipse.kapua.service.authorization.access; -import org.eclipse.kapua.locator.KapuaLocator; - import javax.xml.bind.annotation.XmlRegistry; +import org.eclipse.kapua.locator.KapuaLocator; + @XmlRegistry public class AccessRoleXmlRegistry { @@ -39,15 +39,6 @@ public AccessRoleCreator newCreator() { return accessRoleFactory.newCreator(null); } - /** - * Creates a new {@link AccessRole} instance - * - * @return - */ - public AccessRoleListResult newAccessRoleListResult() { - return accessRoleFactory.newListResult(); - } - public AccessRoleQuery newQuery() { return accessRoleFactory.newQuery(null); } diff --git a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/domain/DomainFactory.java b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/domain/DomainFactory.java index faed82b4ee8..a99af9f63b0 100644 --- a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/domain/DomainFactory.java +++ b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/domain/DomainFactory.java @@ -20,12 +20,13 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface DomainFactory extends KapuaEntityFactory { +public interface DomainFactory extends KapuaEntityFactory { /** * Instantiates a new {@link DomainCreator} * - * @param name The name to set into the {@link Domain}. + * @param name + * The name to set into the {@link Domain}. * @return The newly instantiated {@link Domain}. * @since 1.0.0 */ diff --git a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/domain/DomainListResult.java b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/domain/DomainListResult.java index c38cffc1a20..7426fe39b02 100644 --- a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/domain/DomainListResult.java +++ b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/domain/DomainListResult.java @@ -22,6 +22,8 @@ * @since 1.0.0 */ @XmlRootElement(name = "domains") -public interface DomainListResult extends KapuaListResult { +public class DomainListResult extends KapuaListResult { + + private static final long serialVersionUID = -5086830452591857912L; } diff --git a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/group/GroupFactory.java b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/group/GroupFactory.java index 01d084daf4a..2aa4e192bba 100644 --- a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/group/GroupFactory.java +++ b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/group/GroupFactory.java @@ -21,13 +21,15 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface GroupFactory extends KapuaEntityFactory { +public interface GroupFactory extends KapuaEntityFactory { /** * Instantiates a new {@link GroupCreator}. * - * @param scopeId The scope {@link KapuaId} to set into the {@link GroupCreator} - * @param name The name to set into the {@link GroupCreator} + * @param scopeId + * The scope {@link KapuaId} to set into the {@link GroupCreator} + * @param name + * The name to set into the {@link GroupCreator} * @return The newly instantatied {@link GroupCreator} * @since 1.0.0 */ diff --git a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/group/GroupListResult.java b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/group/GroupListResult.java index 024c5c0baa1..f41dbc3cbce 100644 --- a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/group/GroupListResult.java +++ b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/group/GroupListResult.java @@ -23,7 +23,9 @@ * @since 1.0.0 */ @XmlRootElement(name = "groups") -@XmlType(factoryClass = GroupXmlRegistry.class, factoryMethod = "newGroupListResult") -public interface GroupListResult extends KapuaListResult { +@XmlType +public class GroupListResult extends KapuaListResult { + + private static final long serialVersionUID = 791258978210911362L; } diff --git a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/group/GroupXmlRegistry.java b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/group/GroupXmlRegistry.java index 31f777e9ca4..60c3299bd2b 100644 --- a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/group/GroupXmlRegistry.java +++ b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/group/GroupXmlRegistry.java @@ -12,10 +12,10 @@ *******************************************************************************/ package org.eclipse.kapua.service.authorization.group; -import org.eclipse.kapua.locator.KapuaLocator; - import javax.xml.bind.annotation.XmlRegistry; +import org.eclipse.kapua.locator.KapuaLocator; + @XmlRegistry public class GroupXmlRegistry { @@ -41,16 +41,6 @@ public GroupCreator newGroupCreator() { return groupFactory.newCreator(null, null); } - /** - * Creates a new {@link GroupListResult} instance. - * - * @return The newly created {@link GroupListResult} instance. - * @since 1.0.0 - */ - public GroupListResult newGroupListResult() { - return groupFactory.newListResult(); - } - /** * Creates a new {@link GroupQuery} instance. * diff --git a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RoleFactory.java b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RoleFactory.java index 209b342c0b6..8fa873eae5c 100644 --- a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RoleFactory.java +++ b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RoleFactory.java @@ -20,7 +20,7 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface RoleFactory extends KapuaEntityFactory { +public interface RoleFactory extends KapuaEntityFactory { /** * Instantiates a new {@link RolePermission}. diff --git a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RoleListResult.java b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RoleListResult.java index 94027eff5cd..0b942bb4f05 100644 --- a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RoleListResult.java +++ b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RoleListResult.java @@ -23,7 +23,9 @@ * @since 1.0.0 */ @XmlRootElement(name = "roles") -@XmlType(factoryClass = RoleXmlRegistry.class, factoryMethod = "newRoleListResult") -public interface RoleListResult extends KapuaListResult { +@XmlType +public class RoleListResult extends KapuaListResult { + + private static final long serialVersionUID = -5902522234186399802L; } diff --git a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RolePermissionFactory.java b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RolePermissionFactory.java index e97e7177f2c..f524ba277f9 100644 --- a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RolePermissionFactory.java +++ b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RolePermissionFactory.java @@ -20,6 +20,6 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface RolePermissionFactory extends KapuaEntityFactory { +public interface RolePermissionFactory extends KapuaEntityFactory { } diff --git a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RolePermissionListResult.java b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RolePermissionListResult.java index 7bb2c6b935d..936734d4232 100644 --- a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RolePermissionListResult.java +++ b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RolePermissionListResult.java @@ -23,7 +23,9 @@ * @since 1.0.0 */ @XmlRootElement(name = "rolePermissions") -@XmlType(factoryClass = RolePermissionXmlRegistry.class, factoryMethod = "newRolePermissionListResult") -public interface RolePermissionListResult extends KapuaListResult { +@XmlType +public class RolePermissionListResult extends KapuaListResult { + + private static final long serialVersionUID = -4732941050197499090L; } diff --git a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RolePermissionXmlRegistry.java b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RolePermissionXmlRegistry.java index 583394b80c2..5595b62d70f 100644 --- a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RolePermissionXmlRegistry.java +++ b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RolePermissionXmlRegistry.java @@ -12,10 +12,10 @@ *******************************************************************************/ package org.eclipse.kapua.service.authorization.role; -import org.eclipse.kapua.locator.KapuaLocator; - import javax.xml.bind.annotation.XmlRegistry; +import org.eclipse.kapua.locator.KapuaLocator; + @XmlRegistry public class RolePermissionXmlRegistry { @@ -39,15 +39,6 @@ public RolePermissionCreator newCreator() { return rolePermissionFactory.newCreator(null); } - /** - * Creates a new {@link RolePermissionListResult} instance - * - * @return - */ - public RolePermissionListResult newRolePermissionListResult() { - return rolePermissionFactory.newListResult(); - } - public RolePermissionQuery newQuery() { return rolePermissionFactory.newQuery(null); } diff --git a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RoleXmlRegistry.java b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RoleXmlRegistry.java index b46b8aa8af1..003054d4aa2 100644 --- a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RoleXmlRegistry.java +++ b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RoleXmlRegistry.java @@ -12,10 +12,10 @@ *******************************************************************************/ package org.eclipse.kapua.service.authorization.role; -import org.eclipse.kapua.locator.KapuaLocator; - import javax.xml.bind.annotation.XmlRegistry; +import org.eclipse.kapua.locator.KapuaLocator; + @XmlRegistry public class RoleXmlRegistry { @@ -41,16 +41,6 @@ public RoleCreator newRoleCreator() { return roleFactory.newCreator(null); } - /** - * Creates a new {@link RoleListResult} instance. - * - * @return The newly created {@link RoleListResult} instance. - * @since 1.0.0 - */ - public RoleListResult newRoleListResult() { - return roleFactory.newListResult(); - } - /** * Creates a new {@link RoleQuery} instance. * diff --git a/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/CertificateFactory.java b/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/CertificateFactory.java index 0006c87a0bb..d4864bd3fe2 100644 --- a/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/CertificateFactory.java +++ b/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/CertificateFactory.java @@ -20,12 +20,13 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface CertificateFactory extends KapuaEntityFactory { +public interface CertificateFactory extends KapuaEntityFactory { /** * Instantiates a new {@link CertificateUsage}. * - * @param name The name to set into the {@link CertificateUsage} + * @param name + * The name to set into the {@link CertificateUsage} * @return The newly instantiated {@link CertificateUsage} * @since 1.0.0 */ @@ -34,9 +35,12 @@ public interface CertificateFactory extends KapuaEntityFactory { +@XmlType +public class CertificateListResult extends KapuaListResult { + } diff --git a/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/CertificateQuery.java b/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/CertificateQuery.java index bce32852b6c..a982071ec11 100644 --- a/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/CertificateQuery.java +++ b/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/CertificateQuery.java @@ -12,16 +12,16 @@ *******************************************************************************/ package org.eclipse.kapua.service.certificate; -import org.eclipse.kapua.model.query.KapuaForwardableEntityQuery; -import org.eclipse.kapua.model.query.KapuaQuery; -import org.eclipse.kapua.service.certificate.xml.CertificateXmlRegistry; - import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import org.eclipse.kapua.model.query.KapuaForwardableEntityQuery; +import org.eclipse.kapua.model.query.KapuaQuery; +import org.eclipse.kapua.service.certificate.xml.CertificateXmlRegistry; + /** * {@link Certificate} {@link KapuaQuery} definition. * @@ -35,9 +35,9 @@ public interface CertificateQuery extends KapuaForwardableEntityQuery { @Override /** - * Gets whether or not to get also inherited {@link CertificateInfo}s + * Gets whether or not to get also inherited {@link Certificate}s * - * @return {@code true} if set to get inherited {@link CertificateInfo}s, {@code false} otherwise. + * @return {@code true} if set to get inherited {@link Certificate}s, {@code false} otherwise. * @since 1.0.0 */ @XmlElement(name = "includeInherited") @@ -45,9 +45,9 @@ public interface CertificateQuery extends KapuaForwardableEntityQuery { @Override /** - * Sets whether or not to get also inherited {@link CertificateInfo}s + * Sets whether or not to get also inherited {@link Certificate}s * - * @param includeInherited {@code true} to get inherited {@link CertificateInfo}s, {@code false} otherwise. + * @param includeInherited {@code true} to get inherited {@link CertCertificateificateInfo}s, {@code false} otherwise. * @since 1.0.0 */ void setIncludeInherited(Boolean includeInherited); diff --git a/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/info/CertificateInfoFactory.java b/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/info/CertificateInfoFactory.java index e188bd24b7a..976419bbe9b 100644 --- a/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/info/CertificateInfoFactory.java +++ b/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/info/CertificateInfoFactory.java @@ -17,5 +17,6 @@ /** * @since 1.1.0 */ -public interface CertificateInfoFactory extends KapuaEntityFactory { +public interface CertificateInfoFactory extends KapuaEntityFactory { + } diff --git a/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/info/CertificateInfoListResult.java b/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/info/CertificateInfoListResult.java index 5e1c679e2ff..3c66f97bbba 100644 --- a/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/info/CertificateInfoListResult.java +++ b/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/info/CertificateInfoListResult.java @@ -12,19 +12,19 @@ *******************************************************************************/ package org.eclipse.kapua.service.certificate.info; -import org.eclipse.kapua.model.query.KapuaListResult; -import org.eclipse.kapua.service.certificate.info.xml.CertificateInfoXmlRegistry; - import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import org.eclipse.kapua.model.query.KapuaListResult; + /** * @since 1.1.0 */ @XmlRootElement(name = "certificateListResult") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = CertificateInfoXmlRegistry.class, factoryMethod = "newListResult") -public interface CertificateInfoListResult extends KapuaListResult { +@XmlType +public class CertificateInfoListResult extends KapuaListResult { + } diff --git a/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/info/xml/CertificateInfoXmlRegistry.java b/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/info/xml/CertificateInfoXmlRegistry.java index 8400f77b56f..0da71c138a1 100644 --- a/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/info/xml/CertificateInfoXmlRegistry.java +++ b/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/info/xml/CertificateInfoXmlRegistry.java @@ -12,15 +12,14 @@ *******************************************************************************/ package org.eclipse.kapua.service.certificate.info.xml; +import javax.xml.bind.annotation.XmlRegistry; + import org.eclipse.kapua.locator.KapuaLocator; import org.eclipse.kapua.service.certificate.info.CertificateInfo; import org.eclipse.kapua.service.certificate.info.CertificateInfoCreator; import org.eclipse.kapua.service.certificate.info.CertificateInfoFactory; -import org.eclipse.kapua.service.certificate.info.CertificateInfoListResult; import org.eclipse.kapua.service.certificate.info.CertificateInfoQuery; -import javax.xml.bind.annotation.XmlRegistry; - @XmlRegistry public class CertificateInfoXmlRegistry { @@ -37,8 +36,4 @@ public CertificateInfoCreator newCreator() { public CertificateInfoQuery newQuery() { return certificateInfoFactory.newQuery(null); } - - public CertificateInfoListResult newListResult() { - return certificateInfoFactory.newListResult(); - } } diff --git a/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/xml/CertificateXmlRegistry.java b/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/xml/CertificateXmlRegistry.java index 588be879c8f..52e69f3fb16 100644 --- a/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/xml/CertificateXmlRegistry.java +++ b/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/xml/CertificateXmlRegistry.java @@ -12,17 +12,16 @@ *******************************************************************************/ package org.eclipse.kapua.service.certificate.xml; +import javax.xml.bind.annotation.XmlRegistry; + import org.eclipse.kapua.locator.KapuaLocator; import org.eclipse.kapua.service.certificate.Certificate; import org.eclipse.kapua.service.certificate.CertificateCreator; import org.eclipse.kapua.service.certificate.CertificateFactory; import org.eclipse.kapua.service.certificate.CertificateGenerator; -import org.eclipse.kapua.service.certificate.CertificateListResult; import org.eclipse.kapua.service.certificate.CertificateQuery; import org.eclipse.kapua.service.certificate.CertificateUsage; -import javax.xml.bind.annotation.XmlRegistry; - @XmlRegistry public class CertificateXmlRegistry { @@ -40,10 +39,6 @@ public CertificateQuery newQuery() { return certificateFactory.newQuery(null); } - public CertificateListResult newListResult() { - return certificateFactory.newListResult(); - } - public CertificateGenerator newCertificateGenerator() { return certificateFactory.newCertificateGenerator(); } diff --git a/service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/info/internal/CertificateInfoFactoryImpl.java b/service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/info/internal/CertificateInfoFactoryImpl.java index 06d67d43e0b..8b3184f3c08 100644 --- a/service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/info/internal/CertificateInfoFactoryImpl.java +++ b/service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/info/internal/CertificateInfoFactoryImpl.java @@ -12,16 +12,15 @@ *******************************************************************************/ package org.eclipse.kapua.service.certificate.info.internal; +import javax.inject.Singleton; + import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.certificate.info.CertificateInfo; import org.eclipse.kapua.service.certificate.info.CertificateInfoCreator; import org.eclipse.kapua.service.certificate.info.CertificateInfoFactory; -import org.eclipse.kapua.service.certificate.info.CertificateInfoListResult; import org.eclipse.kapua.service.certificate.info.CertificateInfoQuery; -import javax.inject.Singleton; - @Singleton public class CertificateInfoFactoryImpl implements CertificateInfoFactory { @@ -40,11 +39,6 @@ public CertificateInfoQuery newQuery(KapuaId scopeId) { return new CertificateInfoQueryImpl(scopeId); } - @Override - public CertificateInfoListResult newListResult() { - return new CertificateInfoListResultImpl(); - } - @Override public CertificateInfo clone(CertificateInfo certificateInfo) throws KapuaEntityCloneException { try { diff --git a/service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/info/internal/CertificateInfoListResultImpl.java b/service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/info/internal/CertificateInfoListResultImpl.java deleted file mode 100644 index d1c3dc2b83a..00000000000 --- a/service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/info/internal/CertificateInfoListResultImpl.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2018, 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.service.certificate.info.internal; - -import org.eclipse.kapua.commons.model.query.KapuaListResultImpl; -import org.eclipse.kapua.service.certificate.info.CertificateInfo; -import org.eclipse.kapua.service.certificate.info.CertificateInfoListResult; - -/** - * {@link CertificateInfoListResult} implementation. - * - * @since 1.0 - */ - -public class CertificateInfoListResultImpl extends KapuaListResultImpl implements CertificateInfoListResult { - -} diff --git a/service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/info/internal/CertificateInfoServiceImpl.java b/service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/info/internal/CertificateInfoServiceImpl.java index 1d99a7c42d1..2fbd815de1a 100644 --- a/service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/info/internal/CertificateInfoServiceImpl.java +++ b/service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/info/internal/CertificateInfoServiceImpl.java @@ -12,6 +12,11 @@ *******************************************************************************/ package org.eclipse.kapua.service.certificate.info.internal; +import java.util.List; + +import javax.inject.Inject; +import javax.inject.Singleton; + import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.commons.util.ArgumentValidator; import org.eclipse.kapua.model.id.KapuaId; @@ -26,10 +31,6 @@ import org.eclipse.kapua.service.certificate.info.CertificateInfoService; import org.eclipse.kapua.service.certificate.internal.CertificateQueryImpl; -import javax.inject.Inject; -import javax.inject.Singleton; -import java.util.List; - @Singleton public class CertificateInfoServiceImpl implements CertificateInfoService { @@ -56,7 +57,7 @@ public CertificateInfoListResult query(KapuaQuery query) throws KapuaException { CertificateQuery certificateQuery = new CertificateQueryImpl(query); - CertificateInfoListResult publicCertificates = new CertificateInfoListResultImpl(); + CertificateInfoListResult publicCertificates = new CertificateInfoListResult(); publicCertificates.addItem(certificateService.query(certificateQuery).getFirstItem()); return publicCertificates; diff --git a/service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/internal/CertificateFactoryImpl.java b/service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/internal/CertificateFactoryImpl.java index 8f0e7a4bf9b..64420883810 100644 --- a/service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/internal/CertificateFactoryImpl.java +++ b/service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/internal/CertificateFactoryImpl.java @@ -12,20 +12,19 @@ *******************************************************************************/ package org.eclipse.kapua.service.certificate.internal; +import javax.inject.Singleton; + import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.certificate.Certificate; import org.eclipse.kapua.service.certificate.CertificateCreator; import org.eclipse.kapua.service.certificate.CertificateFactory; import org.eclipse.kapua.service.certificate.CertificateGenerator; -import org.eclipse.kapua.service.certificate.CertificateListResult; import org.eclipse.kapua.service.certificate.CertificateQuery; import org.eclipse.kapua.service.certificate.CertificateUsage; import org.eclipse.kapua.service.certificate.KeyUsage; import org.eclipse.kapua.service.certificate.KeyUsageSetting; -import javax.inject.Singleton; - /** * {@link CertificateFactory} implementation. * @@ -49,11 +48,6 @@ public CertificateQuery newQuery(KapuaId scopeId) { return new CertificateQueryImpl(scopeId); } - @Override - public CertificateListResult newListResult() { - return new CertificateListResultImpl(); - } - @Override public CertificateUsage newCertificateUsage(String name) { return new CertificateUsageImpl(name); diff --git a/service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/internal/CertificateListResultImpl.java b/service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/internal/CertificateListResultImpl.java deleted file mode 100644 index fb00cdb2eaa..00000000000 --- a/service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/internal/CertificateListResultImpl.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017, 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.service.certificate.internal; - -import org.eclipse.kapua.commons.model.query.KapuaListResultImpl; -import org.eclipse.kapua.service.certificate.Certificate; -import org.eclipse.kapua.service.certificate.CertificateListResult; - -/** - * {@link CertificateListResult} implementation. - * - * @since 1.0 - */ - -public class CertificateListResultImpl extends KapuaListResultImpl implements CertificateListResult { - -} diff --git a/service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/internal/CertificateServiceImpl.java b/service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/internal/CertificateServiceImpl.java index d898bc207bd..dd933060b04 100644 --- a/service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/internal/CertificateServiceImpl.java +++ b/service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/internal/CertificateServiceImpl.java @@ -12,8 +12,14 @@ *******************************************************************************/ package org.eclipse.kapua.service.certificate.internal; -import com.google.common.base.Strings; -import com.google.common.collect.Sets; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import javax.inject.Inject; +import javax.inject.Singleton; + import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.commons.configuration.metatype.EmptyTocd; import org.eclipse.kapua.commons.model.domains.Domains; @@ -43,12 +49,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.inject.Inject; -import javax.inject.Singleton; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Set; +import com.google.common.base.Strings; +import com.google.common.collect.Sets; @Singleton public class CertificateServiceImpl implements CertificateService { @@ -65,7 +67,7 @@ public class CertificateServiceImpl implements CertificateService { @Inject public CertificateServiceImpl(AuthorizationService authorizationService, PermissionFactory permissionFactory, CertificateFactory certificateFactory, - KapuaCertificateSetting kapuaCertificateSetting) throws KapuaException { + KapuaCertificateSetting kapuaCertificateSetting) throws KapuaException { this.authorizationService = authorizationService; this.permissionFactory = permissionFactory; this.certificateFactory = certificateFactory; @@ -119,7 +121,7 @@ public CertificateListResult query(KapuaQuery query) throws KapuaException { kapuaCertificate.setCertificateUsages(certificateUsages); kapuaCertificate.setPassword(kapuaCertificateSetting.getString(KapuaCertificateSettingKeys.CERTIFICATE_JWT_PRIVATE_KEY_PASSWORD)); - CertificateListResult result = certificateFactory.newListResult(); + CertificateListResult result = new CertificateListResult(); result.addItem(kapuaCertificate); return result; diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionFactoryImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionFactoryImpl.java index 71466810c72..a6b119cdeb1 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionFactoryImpl.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionFactoryImpl.java @@ -12,27 +12,21 @@ *******************************************************************************/ package org.eclipse.kapua.service.authentication.credential.mfa.shiro; +import javax.inject.Singleton; + import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.authentication.credential.mfa.MfaOption; import org.eclipse.kapua.service.authentication.credential.mfa.MfaOptionCreator; import org.eclipse.kapua.service.authentication.credential.mfa.MfaOptionFactory; -import org.eclipse.kapua.service.authentication.credential.mfa.MfaOptionListResult; import org.eclipse.kapua.service.authentication.credential.mfa.MfaOptionQuery; -import javax.inject.Singleton; - /** * {@link MfaOptionFactory} implementation. */ @Singleton public class MfaOptionFactoryImpl implements MfaOptionFactory { - @Override - public MfaOptionListResult newListResult() { - return new MfaOptionListResultImpl(); - } - @Override public MfaOption newEntity(KapuaId scopeId) { return new MfaOptionImpl(scopeId); diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionImplJpaRepository.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionImplJpaRepository.java index 653f0cd1091..450d8487558 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionImplJpaRepository.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionImplJpaRepository.java @@ -27,8 +27,9 @@ public class MfaOptionImplJpaRepository extends KapuaUpdatableEntityJpaRepository implements MfaOptionRepository { + public MfaOptionImplJpaRepository(KapuaJpaRepositoryConfiguration jpaRepoConfig) { - super(MfaOptionImpl.class, MfaOption.TYPE, MfaOptionListResultImpl::new, jpaRepoConfig); + super(MfaOptionImpl.class, MfaOption.TYPE, MfaOptionListResult::new, jpaRepoConfig); } @Override diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionListResultImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionListResultImpl.java deleted file mode 100644 index ec3582158ac..00000000000 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionListResultImpl.java +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2020, 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.service.authentication.credential.mfa.shiro; - -import org.eclipse.kapua.commons.model.query.KapuaListResultImpl; -import org.eclipse.kapua.service.authentication.credential.mfa.MfaOption; -import org.eclipse.kapua.service.authentication.credential.mfa.MfaOptionListResult; - -/** - * {@link MfaOption} list result implementation. - */ -public class MfaOptionListResultImpl extends KapuaListResultImpl implements MfaOptionListResult { - - private static final long serialVersionUID = -4204695192086365901L; -} diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionServiceImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionServiceImpl.java index e12a28124c0..9cac6d68f6a 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionServiceImpl.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionServiceImpl.java @@ -178,9 +178,8 @@ private User fetchUser(MfaOptionCreator mfaOptionCreator) throws KapuaException } /** - * Generates all the scratch codes. - * The number of generated scratch codes is decided through the {@link org.eclipse.kapua.service.authentication.mfa.MfaAuthenticator} service. - * The scratch code provided within the scratchCodeCreator parameter is ignored. + * Generates all the scratch codes. The number of generated scratch codes is decided through the {@link org.eclipse.kapua.service.authentication.mfa.MfaAuthenticator} service. The scratch code + * provided within the scratchCodeCreator parameter is ignored. * * @return * @throws KapuaException @@ -221,7 +220,7 @@ public MfaOption find(KapuaId scopeId, KapuaId mfaOptionId) throws KapuaExceptio } private MfaOption clearSecuritySensibleFields(MfaOption mfaOption) { -// Set the mfa secret key to null before returning the mfaOption, because they should never be seen again + // Set the mfa secret key to null before returning the mfaOption, because they should never be seen again mfaOption.setMfaSecretKey(null); mfaOption.setTrustKey(null); mfaOption.setScratchCodes(null); @@ -238,7 +237,7 @@ public MfaOptionListResult query(KapuaQuery query) throws KapuaException { final MfaOptionListResult res = txManager.execute(tx -> mfaOptionRepository.query(tx, query)); if (res.isEmpty() == false) { - final MfaOptionListResultImpl cleanedRes = new MfaOptionListResultImpl(); + final MfaOptionListResult cleanedRes = new MfaOptionListResult(); cleanedRes.setLimitExceeded(res.isLimitExceeded()); cleanedRes.setTotalCount(res.getTotalCount()); cleanedRes.addItems(res.getItems() @@ -471,7 +470,6 @@ private MfaOption doDisableTrust(TxContext tx, MfaOption mfaOption) throws Kapua return mfaOptionRepository.update(tx, mfaOption); } - /** * Generate the trust key string. * @@ -483,13 +481,17 @@ private String generateTrustKey() { } /** - * Produce a QR code in base64 format for the authenticator app. - * This QR code generator follows the spec detailed here for the URI format: https://github.com/google/google-authenticator/wiki/Key-Uri-Format + * Produce a QR code in base64 format for the authenticator app. This QR code generator follows the spec detailed here for the URI format: + * https://github.com/google/google-authenticator/wiki/Key-Uri-Format * - * @param organizationName the organization name to be used as issuer in the QR code - * @param accountName the account name of the account to which the user belongs - * @param username the username - * @param key the Mfa secret key in plain text + * @param organizationName + * the organization name to be used as issuer in the QR code + * @param accountName + * the account name of the account to which the user belongs + * @param username + * the username + * @param key + * the Mfa secret key in plain text * @return the QR code image in base64 format * @since 1.3.0 */ diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/ScratchCodeFactoryImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/ScratchCodeFactoryImpl.java index 2e0dfd6f57d..a3fc3c2874e 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/ScratchCodeFactoryImpl.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/ScratchCodeFactoryImpl.java @@ -12,12 +12,11 @@ *******************************************************************************/ package org.eclipse.kapua.service.authentication.credential.mfa.shiro; +import javax.inject.Singleton; + import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.authentication.credential.mfa.ScratchCode; import org.eclipse.kapua.service.authentication.credential.mfa.ScratchCodeFactory; -import org.eclipse.kapua.service.authentication.credential.mfa.ScratchCodeListResult; - -import javax.inject.Singleton; /** * {@link ScratchCodeFactory} implementation. @@ -30,11 +29,6 @@ public ScratchCode newEntity(KapuaId scopeId) { return new ScratchCodeImpl(scopeId); } - @Override - public ScratchCodeListResult newListResult() { - return new ScratchCodeListResultImpl(); - } - @Override public ScratchCode newScratchCode(KapuaId scopeId, KapuaId mfaOptionId, String code) { return new ScratchCodeImpl(scopeId, mfaOptionId, code); diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/ScratchCodeImplJpaRepository.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/ScratchCodeImplJpaRepository.java index 5f7ff836690..aa3a1251be0 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/ScratchCodeImplJpaRepository.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/ScratchCodeImplJpaRepository.java @@ -26,7 +26,7 @@ public class ScratchCodeImplJpaRepository implements ScratchCodeRepository { public ScratchCodeImplJpaRepository(KapuaJpaRepositoryConfiguration jpaRepoConfig) { - super(ScratchCodeImpl.class, ScratchCode.TYPE, () -> new ScratchCodeListResultImpl(), jpaRepoConfig); + super(ScratchCodeImpl.class, ScratchCode.TYPE, () -> new ScratchCodeListResult(), jpaRepoConfig); } @Override diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/ScratchCodeListResultImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/ScratchCodeListResultImpl.java deleted file mode 100644 index fc5133dc0dd..00000000000 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/ScratchCodeListResultImpl.java +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2020, 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.service.authentication.credential.mfa.shiro; - -import org.eclipse.kapua.commons.model.query.KapuaListResultImpl; -import org.eclipse.kapua.service.authentication.credential.mfa.ScratchCode; -import org.eclipse.kapua.service.authentication.credential.mfa.ScratchCodeListResult; - -/** - * {@link ScratchCode} list result implementation. - */ -public class ScratchCodeListResultImpl extends KapuaListResultImpl implements ScratchCodeListResult { - - private static final long serialVersionUID = -5154461760797879319L; -} diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialFactoryImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialFactoryImpl.java index 0aeb713afb7..ea51f3eb37b 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialFactoryImpl.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialFactoryImpl.java @@ -12,18 +12,18 @@ *******************************************************************************/ package org.eclipse.kapua.service.authentication.credential.shiro; +import java.util.Date; + +import javax.inject.Singleton; + import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.authentication.credential.Credential; import org.eclipse.kapua.service.authentication.credential.CredentialCreator; import org.eclipse.kapua.service.authentication.credential.CredentialFactory; -import org.eclipse.kapua.service.authentication.credential.CredentialListResult; import org.eclipse.kapua.service.authentication.credential.CredentialQuery; import org.eclipse.kapua.service.authentication.credential.CredentialStatus; -import javax.inject.Singleton; -import java.util.Date; - /** * {@link CredentialFactory} implementation. * @@ -37,11 +37,6 @@ public CredentialCreatorImpl newCreator(KapuaId scopeId, KapuaId userId, String return new CredentialCreatorImpl(scopeId, userId, credentialType, credentialKey, credentialStatus, expirationDate); } - @Override - public CredentialListResult newListResult() { - return new CredentialListResultImpl(); - } - @Override public Credential newEntity(KapuaId scopeId) { return new CredentialImpl(scopeId); @@ -62,7 +57,6 @@ public CredentialCreator newCreator(KapuaId scopeId) { return new CredentialCreatorImpl(scopeId); } - @Override public Credential clone(Credential credential) { try { diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialImplJpaRepository.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialImplJpaRepository.java index f851f1b30ff..af27a73cacd 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialImplJpaRepository.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialImplJpaRepository.java @@ -33,11 +33,12 @@ public class CredentialImplJpaRepository /** * Constructor. * - * @param jpaRepoConfig The {@link KapuaJpaRepositoryConfiguration}. + * @param jpaRepoConfig + * The {@link KapuaJpaRepositoryConfiguration}. * @since 2.0.0 */ public CredentialImplJpaRepository(KapuaJpaRepositoryConfiguration jpaRepoConfig) { - super(CredentialImpl.class, Credential.TYPE, CredentialListResultImpl::new, jpaRepoConfig); + super(CredentialImpl.class, Credential.TYPE, CredentialListResult::new, jpaRepoConfig); } @Override diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialListResultImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialListResultImpl.java deleted file mode 100644 index 28a039e71c5..00000000000 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialListResultImpl.java +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************* - * 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.service.authentication.credential.shiro; - -import org.eclipse.kapua.commons.model.query.KapuaListResultImpl; -import org.eclipse.kapua.service.authentication.credential.Credential; -import org.eclipse.kapua.service.authentication.credential.CredentialListResult; - -/** - * {@link CredentialListResult} implementation. - * - * @since 1.0.0 - */ -public class CredentialListResultImpl extends KapuaListResultImpl implements CredentialListResult { - - static final long serialVersionUID = -7949012585401032274L; - -} diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/token/shiro/AccessTokenFactoryImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/token/shiro/AccessTokenFactoryImpl.java index 4f884bc8c4e..56d100af555 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/token/shiro/AccessTokenFactoryImpl.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/token/shiro/AccessTokenFactoryImpl.java @@ -12,18 +12,18 @@ *******************************************************************************/ package org.eclipse.kapua.service.authentication.token.shiro; +import java.util.Date; + +import javax.inject.Singleton; + import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.authentication.token.AccessToken; import org.eclipse.kapua.service.authentication.token.AccessTokenCreator; import org.eclipse.kapua.service.authentication.token.AccessTokenFactory; -import org.eclipse.kapua.service.authentication.token.AccessTokenListResult; import org.eclipse.kapua.service.authentication.token.AccessTokenQuery; import org.eclipse.kapua.service.authentication.token.LoginInfo; -import javax.inject.Singleton; -import java.util.Date; - /** * {@link AccessTokenFactory} implementation. * @@ -61,11 +61,6 @@ public AccessTokenQuery newQuery(KapuaId scopeId) { return new AccessTokenQueryImpl(scopeId); } - @Override - public AccessTokenListResult newListResult() { - return new AccessTokenListResultImpl(); - } - @Override public AccessToken clone(AccessToken accessToken) { try { diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/token/shiro/AccessTokenImplJpaRepository.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/token/shiro/AccessTokenImplJpaRepository.java index 810b05c6ebe..27ba8c7ac7d 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/token/shiro/AccessTokenImplJpaRepository.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/token/shiro/AccessTokenImplJpaRepository.java @@ -12,6 +12,8 @@ *******************************************************************************/ package org.eclipse.kapua.service.authentication.token.shiro; +import java.util.Optional; + import org.eclipse.kapua.commons.jpa.KapuaJpaRepositoryConfiguration; import org.eclipse.kapua.commons.jpa.KapuaUpdatableEntityJpaRepository; import org.eclipse.kapua.model.id.KapuaId; @@ -21,13 +23,12 @@ import org.eclipse.kapua.service.authentication.token.AccessTokenRepository; import org.eclipse.kapua.storage.TxContext; -import java.util.Optional; - public class AccessTokenImplJpaRepository extends KapuaUpdatableEntityJpaRepository implements AccessTokenRepository { + public AccessTokenImplJpaRepository(KapuaJpaRepositoryConfiguration jpaRepoConfig) { - super(AccessTokenImpl.class, AccessToken.TYPE, () -> new AccessTokenListResultImpl(), jpaRepoConfig); + super(AccessTokenImpl.class, AccessToken.TYPE, () -> new AccessTokenListResult(), jpaRepoConfig); } @Override diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/token/shiro/AccessTokenListResultImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/token/shiro/AccessTokenListResultImpl.java deleted file mode 100644 index b420d1ac5e9..00000000000 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/token/shiro/AccessTokenListResultImpl.java +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************* - * 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.service.authentication.token.shiro; - -import org.eclipse.kapua.commons.model.query.KapuaListResultImpl; -import org.eclipse.kapua.service.authentication.token.AccessToken; -import org.eclipse.kapua.service.authentication.token.AccessTokenListResult; - -/** - * Access token list result implementation. - * - * @since 1.0 - * - */ -public class AccessTokenListResultImpl extends KapuaListResultImpl implements AccessTokenListResult { - private static final long serialVersionUID = -2596004122285166444L; - -} diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoFactoryImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoFactoryImpl.java index e98d2993560..0985c4cbe21 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoFactoryImpl.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoFactoryImpl.java @@ -12,16 +12,15 @@ *******************************************************************************/ package org.eclipse.kapua.service.authorization.access.shiro; +import javax.inject.Singleton; + import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.authorization.access.AccessInfo; import org.eclipse.kapua.service.authorization.access.AccessInfoCreator; import org.eclipse.kapua.service.authorization.access.AccessInfoFactory; -import org.eclipse.kapua.service.authorization.access.AccessInfoListResult; import org.eclipse.kapua.service.authorization.access.AccessInfoQuery; -import javax.inject.Singleton; - /** * {@link AccessInfoFactory} implementation. * @@ -45,11 +44,6 @@ public AccessInfoQuery newQuery(KapuaId scopeId) { return new AccessInfoQueryImpl(scopeId); } - @Override - public AccessInfoListResult newListResult() { - return new AccessInfoListResultImpl(); - } - @Override public AccessInfo clone(AccessInfo accessInfo) { try { diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoImplJpaRepository.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoImplJpaRepository.java index 0c9934bbec5..709335bcbb2 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoImplJpaRepository.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoImplJpaRepository.java @@ -12,6 +12,8 @@ *******************************************************************************/ package org.eclipse.kapua.service.authorization.access.shiro; +import java.util.Optional; + import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.commons.jpa.KapuaJpaRepositoryConfiguration; import org.eclipse.kapua.commons.jpa.KapuaUpdatableEntityJpaRepository; @@ -22,13 +24,12 @@ import org.eclipse.kapua.service.authorization.access.AccessInfoRepository; import org.eclipse.kapua.storage.TxContext; -import java.util.Optional; - public class AccessInfoImplJpaRepository extends KapuaUpdatableEntityJpaRepository implements AccessInfoRepository { + public AccessInfoImplJpaRepository(KapuaJpaRepositoryConfiguration jpaRepoConfig) { - super(AccessInfoImpl.class, AccessInfo.TYPE, () -> new AccessInfoListResultImpl(), jpaRepoConfig); + super(AccessInfoImpl.class, AccessInfo.TYPE, () -> new AccessInfoListResult(), jpaRepoConfig); } @Override diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoListResultImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoListResultImpl.java deleted file mode 100644 index 8f8cf15910a..00000000000 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoListResultImpl.java +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************* - * 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.service.authorization.access.shiro; - -import org.eclipse.kapua.commons.model.query.KapuaListResultImpl; -import org.eclipse.kapua.service.authorization.access.AccessInfo; -import org.eclipse.kapua.service.authorization.access.AccessInfoListResult; - -/** - * Access info list result implementation. - * - * @since 1.0 - * - */ -public class AccessInfoListResultImpl extends KapuaListResultImpl implements AccessInfoListResult { - - static final long serialVersionUID = 2231053707705207563L; -} diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionFactoryImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionFactoryImpl.java index 581f01ac3e4..9b870e015a7 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionFactoryImpl.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionFactoryImpl.java @@ -12,15 +12,14 @@ *******************************************************************************/ package org.eclipse.kapua.service.authorization.access.shiro; +import javax.inject.Singleton; + import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.authorization.access.AccessPermission; import org.eclipse.kapua.service.authorization.access.AccessPermissionCreator; import org.eclipse.kapua.service.authorization.access.AccessPermissionFactory; -import org.eclipse.kapua.service.authorization.access.AccessPermissionListResult; import org.eclipse.kapua.service.authorization.access.AccessPermissionQuery; -import javax.inject.Singleton; - /** * {@link AccessPermissionFactory} implementation. * @@ -44,11 +43,6 @@ public AccessPermissionQuery newQuery(KapuaId scopeId) { return new AccessPermissionQueryImpl(scopeId); } - @Override - public AccessPermissionListResult newListResult() { - return new AccessPermissionListResultImpl(); - } - @Override public AccessPermission clone(AccessPermission accessPermission) { return new AccessPermissionImpl(accessPermission); diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionImplJpaRepository.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionImplJpaRepository.java index 89b00901402..b80c2c6a4db 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionImplJpaRepository.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionImplJpaRepository.java @@ -12,6 +12,15 @@ *******************************************************************************/ package org.eclipse.kapua.service.authorization.access.shiro; +import java.util.List; +import java.util.stream.Collectors; + +import javax.persistence.EntityManager; +import javax.persistence.criteria.CriteriaBuilder; +import javax.persistence.criteria.CriteriaDelete; +import javax.persistence.criteria.CriteriaQuery; +import javax.persistence.criteria.Root; + import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.commons.jpa.JpaAwareTxContext; import org.eclipse.kapua.commons.jpa.KapuaEntityJpaRepository; @@ -27,20 +36,12 @@ import org.eclipse.kapua.service.authorization.permission.shiro.PermissionImpl_; import org.eclipse.kapua.storage.TxContext; -import javax.persistence.EntityManager; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.CriteriaDelete; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Root; -import java.util.List; -import java.util.stream.Collectors; - public class AccessPermissionImplJpaRepository extends KapuaEntityJpaRepository implements AccessPermissionRepository { public AccessPermissionImplJpaRepository(KapuaJpaRepositoryConfiguration configuration) { - super(AccessPermissionImpl.class, AccessPermission.TYPE, () -> new AccessPermissionListResultImpl(), configuration); + super(AccessPermissionImpl.class, AccessPermission.TYPE, () -> new AccessPermissionListResult(), configuration); } @Override @@ -72,7 +73,7 @@ public AccessPermissionListResult deleteAllByDomainAndAction(TxContext tx, Strin deleteQuery.where(deleteRoot.get(AccessPermissionImpl_.id).in(resultList.stream().map(r -> r.getId()).map(KapuaEid::parseKapuaId).collect(Collectors.toList()))); em.createQuery(deleteQuery).executeUpdate(); } - final AccessPermissionListResultImpl res = new AccessPermissionListResultImpl(); + final AccessPermissionListResult res = new AccessPermissionListResult(); res.addItems(resultList); return res; } diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionListResultImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionListResultImpl.java deleted file mode 100644 index 0a12dd615f8..00000000000 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionListResultImpl.java +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************* - * 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.service.authorization.access.shiro; - -import org.eclipse.kapua.commons.model.query.KapuaListResultImpl; -import org.eclipse.kapua.service.authorization.access.AccessPermission; -import org.eclipse.kapua.service.authorization.access.AccessPermissionListResult; - -/** - * {@link AccessPermission} list result implementation. - * - * @since 1.0.0 - * - */ -public class AccessPermissionListResultImpl extends KapuaListResultImpl implements AccessPermissionListResult { - - private static final long serialVersionUID = -7673771564266332772L; -} diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessRoleFactoryImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessRoleFactoryImpl.java index cb12d7f2f8c..0f69305d4ea 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessRoleFactoryImpl.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessRoleFactoryImpl.java @@ -12,16 +12,15 @@ *******************************************************************************/ package org.eclipse.kapua.service.authorization.access.shiro; +import javax.inject.Singleton; + import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.authorization.access.AccessRole; import org.eclipse.kapua.service.authorization.access.AccessRoleCreator; import org.eclipse.kapua.service.authorization.access.AccessRoleFactory; -import org.eclipse.kapua.service.authorization.access.AccessRoleListResult; import org.eclipse.kapua.service.authorization.access.AccessRoleQuery; -import javax.inject.Singleton; - /** * {@link AccessRoleFactory} implementation. * @@ -45,11 +44,6 @@ public AccessRoleQuery newQuery(KapuaId scopeId) { return new AccessRoleQueryImpl(scopeId); } - @Override - public AccessRoleListResult newListResult() { - return new AccessRoleListResultImpl(); - } - @Override public AccessRole clone(AccessRole accessRole) { try { diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessRoleImplJpaRepository.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessRoleImplJpaRepository.java index d3d208507e9..b9346e504cc 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessRoleImplJpaRepository.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessRoleImplJpaRepository.java @@ -25,8 +25,9 @@ public class AccessRoleImplJpaRepository extends KapuaEntityJpaRepository implements AccessRoleRepository { + public AccessRoleImplJpaRepository(KapuaJpaRepositoryConfiguration configuration) { - super(AccessRoleImpl.class, AccessRole.TYPE, () -> new AccessRoleListResultImpl(), configuration); + super(AccessRoleImpl.class, AccessRole.TYPE, () -> new AccessRoleListResult(), configuration); } @Override diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessRoleListResultImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessRoleListResultImpl.java deleted file mode 100644 index 34d3db38048..00000000000 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessRoleListResultImpl.java +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************* - * 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.service.authorization.access.shiro; - -import org.eclipse.kapua.commons.model.query.KapuaListResultImpl; -import org.eclipse.kapua.service.authorization.access.AccessRole; -import org.eclipse.kapua.service.authorization.access.AccessRoleListResult; - -/** - * {@link AccessRole} list result implementation. - * - * @since 1.0.0 - * - */ -public class AccessRoleListResultImpl extends KapuaListResultImpl implements AccessRoleListResult { - - private static final long serialVersionUID = 2406073775830391702L; -} diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/domain/shiro/DomainFactoryImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/domain/shiro/DomainFactoryImpl.java index 39a0344bb18..2a618267c57 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/domain/shiro/DomainFactoryImpl.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/domain/shiro/DomainFactoryImpl.java @@ -12,16 +12,15 @@ *******************************************************************************/ package org.eclipse.kapua.service.authorization.domain.shiro; +import javax.inject.Singleton; + import org.apache.commons.lang.NotImplementedException; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.authorization.domain.Domain; import org.eclipse.kapua.service.authorization.domain.DomainCreator; import org.eclipse.kapua.service.authorization.domain.DomainFactory; -import org.eclipse.kapua.service.authorization.domain.DomainListResult; import org.eclipse.kapua.service.authorization.domain.DomainQuery; -import javax.inject.Singleton; - /** * {@link DomainFactory} implementation. * @@ -35,11 +34,6 @@ public DomainCreator newCreator(String name) { return new DomainCreatorImpl(name); } - @Override - public DomainListResult newListResult() { - return new DomainListResultImpl(); - } - @Override public DomainQuery newQuery(KapuaId scopeId) { return new DomainQueryImpl(scopeId); diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/domain/shiro/DomainImplJpaRepository.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/domain/shiro/DomainImplJpaRepository.java index 26495442aa7..913362d1077 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/domain/shiro/DomainImplJpaRepository.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/domain/shiro/DomainImplJpaRepository.java @@ -12,6 +12,8 @@ *******************************************************************************/ package org.eclipse.kapua.service.authorization.domain.shiro; +import java.util.Optional; + import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.commons.jpa.KapuaEntityJpaRepository; import org.eclipse.kapua.commons.jpa.KapuaJpaRepositoryConfiguration; @@ -22,13 +24,12 @@ import org.eclipse.kapua.service.authorization.domain.DomainRepository; import org.eclipse.kapua.storage.TxContext; -import java.util.Optional; - public class DomainImplJpaRepository extends KapuaEntityJpaRepository implements DomainRepository { + public DomainImplJpaRepository(KapuaJpaRepositoryConfiguration configuration) { - super(DomainImpl.class, Domain.TYPE, () -> new DomainListResultImpl(), configuration); + super(DomainImpl.class, Domain.TYPE, () -> new DomainListResult(), configuration); } @Override diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/domain/shiro/DomainListResultImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/domain/shiro/DomainListResultImpl.java deleted file mode 100644 index f1f34c3fddf..00000000000 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/domain/shiro/DomainListResultImpl.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * 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.service.authorization.domain.shiro; - -import org.eclipse.kapua.commons.model.query.KapuaListResultImpl; -import org.eclipse.kapua.service.authorization.domain.Domain; -import org.eclipse.kapua.service.authorization.domain.DomainListResult; - -/** - * {@link DomainListResult} implementation. - * - * @since 1.0.0 - */ -public class DomainListResultImpl extends KapuaListResultImpl implements DomainListResult { - - private static final long serialVersionUID = -5086830452591857912L; -} diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/group/shiro/GroupFactoryImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/group/shiro/GroupFactoryImpl.java index a0ac8e5cdae..a13a4287fbc 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/group/shiro/GroupFactoryImpl.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/group/shiro/GroupFactoryImpl.java @@ -12,16 +12,15 @@ *******************************************************************************/ package org.eclipse.kapua.service.authorization.group.shiro; +import javax.inject.Singleton; + import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.authorization.group.Group; import org.eclipse.kapua.service.authorization.group.GroupCreator; import org.eclipse.kapua.service.authorization.group.GroupFactory; -import org.eclipse.kapua.service.authorization.group.GroupListResult; import org.eclipse.kapua.service.authorization.group.GroupQuery; -import javax.inject.Singleton; - /** * {@link GroupFactory} implementation. * @@ -44,11 +43,6 @@ public Group newEntity(KapuaId scopeId) { return new GroupImpl(scopeId); } - @Override - public GroupListResult newListResult() { - return new GroupListResultImpl(); - } - @Override public GroupQuery newQuery(KapuaId scopeId) { return new GroupQueryImpl(scopeId); diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/group/shiro/GroupImplJpaRepository.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/group/shiro/GroupImplJpaRepository.java index 5783607f062..0b33cdf6a36 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/group/shiro/GroupImplJpaRepository.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/group/shiro/GroupImplJpaRepository.java @@ -21,8 +21,9 @@ public class GroupImplJpaRepository extends KapuaNamedEntityJpaRepository implements GroupRepository { + public GroupImplJpaRepository(KapuaJpaRepositoryConfiguration jpaRepoConfig) { - super(GroupImpl.class, Group.TYPE, () -> new GroupListResultImpl(), jpaRepoConfig); + super(GroupImpl.class, Group.TYPE, () -> new GroupListResult(), jpaRepoConfig); } } diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/group/shiro/GroupListResultImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/group/shiro/GroupListResultImpl.java deleted file mode 100644 index a9b06f298ff..00000000000 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/group/shiro/GroupListResultImpl.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * 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.service.authorization.group.shiro; - -import org.eclipse.kapua.commons.model.query.KapuaListResultImpl; -import org.eclipse.kapua.service.authorization.group.Group; -import org.eclipse.kapua.service.authorization.group.GroupListResult; - -/** - * {@link GroupListResult} implementation. - * - * @since 1.0.0 - */ -public class GroupListResultImpl extends KapuaListResultImpl implements GroupListResult { - - private static final long serialVersionUID = 791258978210911362L; -} diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RoleFactoryImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RoleFactoryImpl.java index 29443481b8e..145649c3377 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RoleFactoryImpl.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RoleFactoryImpl.java @@ -12,17 +12,16 @@ *******************************************************************************/ package org.eclipse.kapua.service.authorization.role.shiro; +import javax.inject.Singleton; + import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.authorization.role.Role; import org.eclipse.kapua.service.authorization.role.RoleCreator; import org.eclipse.kapua.service.authorization.role.RoleFactory; -import org.eclipse.kapua.service.authorization.role.RoleListResult; import org.eclipse.kapua.service.authorization.role.RolePermission; import org.eclipse.kapua.service.authorization.role.RoleQuery; -import javax.inject.Singleton; - /** * {@link RoleFactory} implementation. * @@ -46,11 +45,6 @@ public RoleQuery newQuery(KapuaId scopeId) { return new RoleQueryImpl(scopeId); } - @Override - public RoleListResult newListResult() { - return new RoleListResultImpl(); - } - @Override public RolePermission newRolePermission() { return new RolePermissionImpl(); diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RoleImplJpaRepository.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RoleImplJpaRepository.java index d02d4aae0dd..cf780b0dd28 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RoleImplJpaRepository.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RoleImplJpaRepository.java @@ -21,8 +21,9 @@ public class RoleImplJpaRepository extends KapuaNamedEntityJpaRepository implements RoleRepository { + public RoleImplJpaRepository(KapuaJpaRepositoryConfiguration jpaRepoConfig) { - super(RoleImpl.class, Role.TYPE, () -> new RoleListResultImpl(), jpaRepoConfig); + super(RoleImpl.class, Role.TYPE, () -> new RoleListResult(), jpaRepoConfig); } } diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RoleListResultImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RoleListResultImpl.java deleted file mode 100644 index b61c8834bd6..00000000000 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RoleListResultImpl.java +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************* - * 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.service.authorization.role.shiro; - -import org.eclipse.kapua.commons.model.query.KapuaListResultImpl; -import org.eclipse.kapua.service.authorization.role.Role; -import org.eclipse.kapua.service.authorization.role.RoleListResult; - -/** - * Role list result implementation. - * - * @since 1.0 - * - */ -public class RoleListResultImpl extends KapuaListResultImpl implements RoleListResult { - - private static final long serialVersionUID = -5902522234186399802L; -} diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RolePermissionFactoryImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RolePermissionFactoryImpl.java index d145edff977..f2719eb11f0 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RolePermissionFactoryImpl.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RolePermissionFactoryImpl.java @@ -12,15 +12,14 @@ *******************************************************************************/ package org.eclipse.kapua.service.authorization.role.shiro; +import javax.inject.Singleton; + import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.authorization.role.RolePermission; import org.eclipse.kapua.service.authorization.role.RolePermissionCreator; import org.eclipse.kapua.service.authorization.role.RolePermissionFactory; -import org.eclipse.kapua.service.authorization.role.RolePermissionListResult; import org.eclipse.kapua.service.authorization.role.RolePermissionQuery; -import javax.inject.Singleton; - /** * {@link RolePermissionFactory} implementation. * @@ -44,11 +43,6 @@ public RolePermissionQuery newQuery(KapuaId scopeId) { return new RolePermissionQueryImpl(scopeId); } - @Override - public RolePermissionListResult newListResult() { - return new RolePermissionListResultImpl(); - } - @Override public RolePermission clone(RolePermission rolePermission) { return new RolePermissionImpl(rolePermission); diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RolePermissionImplJpaRepository.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RolePermissionImplJpaRepository.java index 28e6c5da932..dd3f1229ee5 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RolePermissionImplJpaRepository.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RolePermissionImplJpaRepository.java @@ -12,6 +12,15 @@ *******************************************************************************/ package org.eclipse.kapua.service.authorization.role.shiro; +import java.util.List; +import java.util.stream.Collectors; + +import javax.persistence.EntityManager; +import javax.persistence.criteria.CriteriaBuilder; +import javax.persistence.criteria.CriteriaDelete; +import javax.persistence.criteria.CriteriaQuery; +import javax.persistence.criteria.Root; + import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.commons.jpa.JpaAwareTxContext; import org.eclipse.kapua.commons.jpa.KapuaEntityJpaRepository; @@ -25,20 +34,12 @@ import org.eclipse.kapua.service.authorization.role.RolePermissionRepository; import org.eclipse.kapua.storage.TxContext; -import javax.persistence.EntityManager; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.CriteriaDelete; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Root; -import java.util.List; -import java.util.stream.Collectors; - public class RolePermissionImplJpaRepository extends KapuaEntityJpaRepository implements RolePermissionRepository { public RolePermissionImplJpaRepository(KapuaJpaRepositoryConfiguration configuration) { - super(RolePermissionImpl.class, RolePermission.TYPE, () -> new RolePermissionListResultImpl(), configuration); + super(RolePermissionImpl.class, RolePermission.TYPE, () -> new RolePermissionListResult(), configuration); } @Override @@ -70,7 +71,7 @@ public RolePermissionListResult deleteAllByDomainAndAction(TxContext tx, String deleteQuery.where(deleteRoot.get(RolePermissionImpl_.id).in(resultList.stream().map(r -> r.getId()).map(KapuaEid::parseKapuaId).collect(Collectors.toList()))); em.createQuery(deleteQuery).executeUpdate(); } - final RolePermissionListResultImpl res = new RolePermissionListResultImpl(); + final RolePermissionListResult res = new RolePermissionListResult(); res.addItems(resultList); return res; } diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RolePermissionListResultImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RolePermissionListResultImpl.java deleted file mode 100644 index 210f4d786ac..00000000000 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RolePermissionListResultImpl.java +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************* - * 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.service.authorization.role.shiro; - -import org.eclipse.kapua.commons.model.query.KapuaListResultImpl; -import org.eclipse.kapua.service.authorization.role.RolePermission; -import org.eclipse.kapua.service.authorization.role.RolePermissionListResult; - -/** - * {@link RolePermission} list result implementation. - * - * @since 1.0.0 - * - */ -public class RolePermissionListResultImpl extends KapuaListResultImpl implements RolePermissionListResult { - - private static final long serialVersionUID = -4732941050197499090L; -} diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionFactoryImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionFactoryImplTest.java index 46af59ccee6..7b5119fc23e 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionFactoryImplTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionFactoryImplTest.java @@ -12,13 +12,14 @@ *******************************************************************************/ package org.eclipse.kapua.service.authentication.credential.mfa.shiro; +import java.util.Date; + import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.commons.model.id.KapuaEid; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.qa.markers.junit.JUnitTests; import org.eclipse.kapua.service.authentication.credential.mfa.MfaOption; import org.eclipse.kapua.service.authentication.credential.mfa.MfaOptionCreator; -import org.eclipse.kapua.service.authentication.credential.mfa.MfaOptionListResult; import org.eclipse.kapua.service.authentication.credential.mfa.MfaOptionQuery; import org.junit.Assert; import org.junit.Before; @@ -26,9 +27,6 @@ import org.junit.experimental.categories.Category; import org.mockito.Mockito; -import java.util.Date; - - @Category(JUnitTests.class) public class MfaOptionFactoryImplTest { @@ -42,8 +40,8 @@ public class MfaOptionFactoryImplTest { @Before public void initialize() { mfaOptionFactoryImpl = new MfaOptionFactoryImpl(); - scopeIds = new KapuaId[]{null, KapuaId.ONE}; - userIds = new KapuaEid[]{null, new KapuaEid()}; + scopeIds = new KapuaId[] { null, KapuaId.ONE }; + userIds = new KapuaEid[] { null, new KapuaEid() }; mfaOption = Mockito.mock(MfaOption.class); trustExpirationDate = new Date(); modifiedOn = new Date(); @@ -60,11 +58,6 @@ public void newCreatorScopeIdUserIdMfaSecretKeyParametersTest() { } } - @Test - public void newListResultTest() { - Assert.assertTrue("Instance of MfaOptionListResult expected.", mfaOptionFactoryImpl.newListResult() instanceof MfaOptionListResult); - } - @Test public void newEntityTest() { for (KapuaId scopeId : scopeIds) { diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialFactoryImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialFactoryImplTest.java index 0261f3eb3b0..e123066baee 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialFactoryImplTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialFactoryImplTest.java @@ -12,24 +12,22 @@ *******************************************************************************/ package org.eclipse.kapua.service.authentication.credential.shiro; +import java.util.Date; + import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.commons.model.id.KapuaEid; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.qa.markers.junit.JUnitTests; -import org.eclipse.kapua.service.authentication.credential.CredentialStatus; import org.eclipse.kapua.service.authentication.credential.Credential; -import org.eclipse.kapua.service.authentication.credential.CredentialQuery; import org.eclipse.kapua.service.authentication.credential.CredentialCreator; -import org.eclipse.kapua.service.authentication.credential.CredentialListResult; +import org.eclipse.kapua.service.authentication.credential.CredentialQuery; +import org.eclipse.kapua.service.authentication.credential.CredentialStatus; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.junit.experimental.categories.Category; import org.mockito.Mockito; -import java.util.Date; - - @Category(JUnitTests.class) public class CredentialFactoryImplTest { @@ -46,12 +44,12 @@ public class CredentialFactoryImplTest { @Before public void initialize() { credentialFactoryImpl = new CredentialFactoryImpl(); - scopeIds = new KapuaId[]{null, KapuaId.ONE}; - userIds = new KapuaEid[]{null, new KapuaEid()}; - credentialKeys = new String[]{null, "", "!!credentialKey-1", "#1(credentialKey.,/Key)9--99", "!$$ 1-2 key//", "credential_K_ey(....)<00>"}; - credentialTypes = new String[] {null, "PASSWORD", "API_KEY", "JWT"}; - credentialStatuses = new CredentialStatus[]{null, CredentialStatus.ENABLED, CredentialStatus.DISABLED}; - dates = new Date[]{null, new Date()}; + scopeIds = new KapuaId[] { null, KapuaId.ONE }; + userIds = new KapuaEid[] { null, new KapuaEid() }; + credentialKeys = new String[] { null, "", "!!credentialKey-1", "#1(credentialKey.,/Key)9--99", "!$$ 1-2 key//", "credential_K_ey(....)<00>" }; + credentialTypes = new String[] { null, "PASSWORD", "API_KEY", "JWT" }; + credentialStatuses = new CredentialStatus[] { null, CredentialStatus.ENABLED, CredentialStatus.DISABLED }; + dates = new Date[] { null, new Date() }; credential = Mockito.mock(Credential.class); expirationDate = new Date(); modifiedOn = new Date(); @@ -80,11 +78,6 @@ public void newCreatorScopeIdUserIdMfaSecretKeyParametersTest() { } } - @Test - public void newListResultTest() { - Assert.assertTrue("True expected.", credentialFactoryImpl.newListResult() instanceof CredentialListResult); - } - @Test public void newEntityTest() { for (KapuaId scopeId : scopeIds) { diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/token/shiro/AccessTokenFactoryImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/token/shiro/AccessTokenFactoryImplTest.java index d1659e85aca..b3d5eb1b2fc 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/token/shiro/AccessTokenFactoryImplTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/token/shiro/AccessTokenFactoryImplTest.java @@ -12,24 +12,22 @@ *******************************************************************************/ package org.eclipse.kapua.service.authentication.token.shiro; +import java.util.Date; + import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.commons.model.id.KapuaEid; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.qa.markers.junit.JUnitTests; import org.eclipse.kapua.service.authentication.token.AccessToken; +import org.eclipse.kapua.service.authentication.token.AccessTokenCreator; import org.eclipse.kapua.service.authentication.token.AccessTokenQuery; import org.eclipse.kapua.service.authentication.token.LoginInfo; -import org.eclipse.kapua.service.authentication.token.AccessTokenListResult; -import org.eclipse.kapua.service.authentication.token.AccessTokenCreator; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.junit.experimental.categories.Category; import org.mockito.Mockito; -import java.util.Date; - - @Category(JUnitTests.class) public class AccessTokenFactoryImplTest { @@ -44,17 +42,17 @@ public class AccessTokenFactoryImplTest { @Before public void initialize() { accessTokenFactoryImpl = new AccessTokenFactoryImpl(); - scopeIds = new KapuaId[]{null, KapuaId.ONE}; - userIds = new KapuaEid[]{null, new KapuaEid()}; - tokenIds = new String[]{null, "", "!!token id-1", "#1(token.,/tokenID)9--99", "!$$ 1-2 id//", "to_ken_id(....)<00>"}; - refreshTokens = new String[]{null, "", "!!token refresh token-1", "#1(REfreSF.,/token_refresh)9--99", "!$$ 1-2 id//", "to_ken_refRESH token(....)<00>"}; - expiresOnDates = new Date[]{null, new Date()}; - refreshExpiresOnDates = new Date[]{null, new Date()}; + scopeIds = new KapuaId[] { null, KapuaId.ONE }; + userIds = new KapuaEid[] { null, new KapuaEid() }; + tokenIds = new String[] { null, "", "!!token id-1", "#1(token.,/tokenID)9--99", "!$$ 1-2 id//", "to_ken_id(....)<00>" }; + refreshTokens = new String[] { null, "", "!!token refresh token-1", "#1(REfreSF.,/token_refresh)9--99", "!$$ 1-2 id//", "to_ken_refRESH token(....)<00>" }; + expiresOnDates = new Date[] { null, new Date() }; + refreshExpiresOnDates = new Date[] { null, new Date() }; accessToken = Mockito.mock(AccessToken.class); modifiedOn = new Date(); createdOn = new Date(); invalidatedOn = new Date(); - tokenIdentifiers = new String[]{"a2fe104f-5d03-4a09-a28d-817ebbc85901", "8e075aeb-be2a-49a7-8dec-346760375d19", "e71b2f52-e02e-4e24-9147-96674e3bf599"}; + tokenIdentifiers = new String[] { "a2fe104f-5d03-4a09-a28d-817ebbc85901", "8e075aeb-be2a-49a7-8dec-346760375d19", "e71b2f52-e02e-4e24-9147-96674e3bf599" }; } @Test @@ -66,7 +64,8 @@ public void newCreatorMultipleParametersTest() { for (String refreshToken : refreshTokens) { for (Date refreshExpiresOnDate : refreshExpiresOnDates) { for (String tokenIdenfier : tokenIdentifiers) { - AccessTokenCreatorImpl accessTokenCreatorImpl = accessTokenFactoryImpl.newCreator(scopeId, userId, tokenId, expiresOnDate, refreshToken, refreshExpiresOnDate, tokenIdenfier); + AccessTokenCreatorImpl accessTokenCreatorImpl = accessTokenFactoryImpl.newCreator(scopeId, userId, tokenId, expiresOnDate, refreshToken, refreshExpiresOnDate, + tokenIdenfier); Assert.assertEquals("Expected and actual values should be the same.", scopeId, accessTokenCreatorImpl.getScopeId()); Assert.assertEquals("Expected and actual values should be the same.", userId, accessTokenCreatorImpl.getUserId()); Assert.assertEquals("Expected and actual values should be the same.", tokenId, accessTokenCreatorImpl.getTokenId()); @@ -107,11 +106,6 @@ public void newQueryTest() { } } - @Test - public void newListResultTest() { - Assert.assertTrue("True expected.", accessTokenFactoryImpl.newListResult() instanceof AccessTokenListResult); - } - @Test public void cloneTest() { Mockito.when(accessToken.getId()).thenReturn(KapuaId.ONE); diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoFactoryImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoFactoryImplTest.java index 2ce26e553a5..de5fdf1f83b 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoFactoryImplTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoFactoryImplTest.java @@ -12,12 +12,13 @@ *******************************************************************************/ package org.eclipse.kapua.service.authorization.access.shiro; +import java.util.Date; + import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.qa.markers.junit.JUnitTests; import org.eclipse.kapua.service.authorization.access.AccessInfo; import org.eclipse.kapua.service.authorization.access.AccessInfoCreator; -import org.eclipse.kapua.service.authorization.access.AccessInfoListResult; import org.eclipse.kapua.service.authorization.access.AccessInfoQuery; import org.junit.Assert; import org.junit.Before; @@ -25,17 +26,13 @@ import org.junit.experimental.categories.Category; import org.mockito.Mockito; -import java.util.Date; - - @Category(JUnitTests.class) public class AccessInfoFactoryImplTest { AccessInfoFactoryImpl accessInfoFactoryImpl; KapuaId scopeId; AccessInfo accessInfo; - Date createdOn,modifiedOn; - + Date createdOn, modifiedOn; @Before public void initialize() { @@ -97,13 +94,6 @@ public void newQueryNullTest() { Assert.assertNull("Null expected.", accessInfoQuery.getScopeId()); } - @Test - public void newListResultTest() { - AccessInfoListResult accessInfoListResult = accessInfoFactoryImpl.newListResult(); - - Assert.assertTrue("True expected.", accessInfoListResult.isEmpty()); - } - @Test public void cloneTest() { AccessInfo resultAccessInfo = accessInfoFactoryImpl.clone(accessInfo); diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionFactoryImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionFactoryImplTest.java index a7654bd3539..c4ea95a3eb2 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionFactoryImplTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionFactoryImplTest.java @@ -16,7 +16,6 @@ import org.eclipse.kapua.qa.markers.junit.JUnitTests; import org.eclipse.kapua.service.authorization.access.AccessPermission; import org.eclipse.kapua.service.authorization.access.AccessPermissionCreator; -import org.eclipse.kapua.service.authorization.access.AccessPermissionListResult; import org.eclipse.kapua.service.authorization.access.AccessPermissionQuery; import org.junit.Assert; import org.junit.Before; @@ -24,7 +23,6 @@ import org.junit.experimental.categories.Category; import org.mockito.Mockito; - @Category(JUnitTests.class) public class AccessPermissionFactoryImplTest { @@ -34,7 +32,7 @@ public class AccessPermissionFactoryImplTest { @Before public void initialize() { accessPermissionFactoryImpl = new AccessPermissionFactoryImpl(); - scopeIds = new KapuaId[]{null, KapuaId.ONE}; + scopeIds = new KapuaId[] { null, KapuaId.ONE }; } @Test @@ -58,11 +56,6 @@ public void newQueryTest() { } } - @Test - public void newListResultTest() { - Assert.assertTrue("True expected.", accessPermissionFactoryImpl.newListResult() instanceof AccessPermissionListResult); - } - @Test public void cloneTest() { AccessPermission accessPermission = Mockito.mock(AccessPermission.class); diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessRoleFactoryImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessRoleFactoryImplTest.java index 2e6eea3848f..187251c0ad8 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessRoleFactoryImplTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessRoleFactoryImplTest.java @@ -12,12 +12,13 @@ *******************************************************************************/ package org.eclipse.kapua.service.authorization.access.shiro; +import java.util.Date; + import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.qa.markers.junit.JUnitTests; import org.eclipse.kapua.service.authorization.access.AccessRole; import org.eclipse.kapua.service.authorization.access.AccessRoleCreator; -import org.eclipse.kapua.service.authorization.access.AccessRoleListResult; import org.eclipse.kapua.service.authorization.access.AccessRoleQuery; import org.junit.Assert; import org.junit.Before; @@ -25,9 +26,6 @@ import org.junit.experimental.categories.Category; import org.mockito.Mockito; -import java.util.Date; - - @Category(JUnitTests.class) public class AccessRoleFactoryImplTest { @@ -85,12 +83,6 @@ public void newQueryNullTest() { Assert.assertNull("Null expected.", accessRoleQuery.getScopeId()); } - @Test - public void newListResultTest() { - AccessRoleListResult accessRoleListResult = accessRoleFactoryImpl.newListResult(); - Assert.assertTrue("True expected.", accessRoleListResult.isEmpty()); - } - @Test public void cloneTest() { accessRoleFactoryImpl.clone(accessRole); diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/domain/shiro/DomainFactoryImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/domain/shiro/DomainFactoryImplTest.java index 6399442db7a..83d88868642 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/domain/shiro/DomainFactoryImplTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/domain/shiro/DomainFactoryImplTest.java @@ -12,13 +12,16 @@ *******************************************************************************/ package org.eclipse.kapua.service.authorization.domain.shiro; +import java.util.Date; +import java.util.HashSet; +import java.util.Set; + import org.apache.commons.lang.NotImplementedException; import org.eclipse.kapua.model.domain.Actions; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.qa.markers.junit.JUnitTests; import org.eclipse.kapua.service.authorization.domain.Domain; import org.eclipse.kapua.service.authorization.domain.DomainCreator; -import org.eclipse.kapua.service.authorization.domain.DomainListResult; import org.eclipse.kapua.service.authorization.domain.DomainQuery; import org.junit.Assert; import org.junit.Before; @@ -26,11 +29,6 @@ import org.junit.experimental.categories.Category; import org.mockito.Mockito; -import java.util.Date; -import java.util.HashSet; -import java.util.Set; - - @Category(JUnitTests.class) public class DomainFactoryImplTest { @@ -43,7 +41,8 @@ public void initialize() { @Test public void newCreatorNameParameterTest() { - String[] names = {"", " na123)(&*^&NAME <>", "Na-,,..,,Me name ---", "-&^454536 na___,,12 NAME name ", "! 2#@ na meNEMA 2323", "12&^%4 ,,,. '|<>*(", " ,,123name;;'", "12#name--765 ,.aaa!!#$%^<> "}; + String[] names = { "", " na123)(&*^&NAME <>", "Na-,,..,,Me name ---", "-&^454536 na___,,12 NAME name ", "! 2#@ na meNEMA 2323", "12&^%4 ,,,. '|<>*(", " ,,123name;;'", + "12#name--765 ,.aaa!!#$%^<> " }; for (String name : names) { DomainCreator domainCreator = domainFactoryImpl.newCreator(name); @@ -59,12 +58,6 @@ public void newCreatorNullNameParameterTest() { Assert.assertNull("Null expected.", domainCreator.getScopeId()); } - @Test - public void newListResultTest() { - DomainListResult domainListResult = domainFactoryImpl.newListResult(); - Assert.assertTrue("True expected.", domainListResult.isEmpty()); - } - @Test public void newQueryTest() { DomainQuery domainQuery = domainFactoryImpl.newQuery(KapuaId.ONE); diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/group/shiro/GroupFactoryImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/group/shiro/GroupFactoryImplTest.java index 75badcb4e9c..2615beda67f 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/group/shiro/GroupFactoryImplTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/group/shiro/GroupFactoryImplTest.java @@ -12,12 +12,13 @@ *******************************************************************************/ package org.eclipse.kapua.service.authorization.group.shiro; +import java.util.Date; + import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.qa.markers.junit.JUnitTests; import org.eclipse.kapua.service.authorization.group.Group; import org.eclipse.kapua.service.authorization.group.GroupCreator; -import org.eclipse.kapua.service.authorization.group.GroupListResult; import org.eclipse.kapua.service.authorization.group.GroupQuery; import org.junit.Assert; import org.junit.Before; @@ -25,9 +26,6 @@ import org.junit.experimental.categories.Category; import org.mockito.Mockito; -import java.util.Date; - - @Category(JUnitTests.class) public class GroupFactoryImplTest { @@ -41,7 +39,8 @@ public class GroupFactoryImplTest { public void initialize() { groupFactoryImpl = new GroupFactoryImpl(); scopeId = KapuaId.ONE; - names = new String[]{"", " na123)(&*^&NAME <>", "Na-,,..,,Me name ---", "-&^454536 na___,,12 NAME name ", "! 2#@ na meNEMA 2323", "12&^%4 ,,,. '|<>*(", " ,,123name;;'", "12#name--765 ,.aaa!!#$%^<> "}; + names = new String[] { "", " na123)(&*^&NAME <>", "Na-,,..,,Me name ---", "-&^454536 na___,,12 NAME name ", "! 2#@ na meNEMA 2323", "12&^%4 ,,,. '|<>*(", " ,,123name;;'", + "12#name--765 ,.aaa!!#$%^<> " }; group = Mockito.mock(Group.class); createdOn = new Date(); modifiedOn = new Date(); @@ -94,12 +93,6 @@ public void newEntityNullTest() { Assert.assertNull("Null expected.", group.getScopeId()); } - @Test - public void newListResultTest() { - GroupListResult groupListResult = groupFactoryImpl.newListResult(); - Assert.assertTrue("True expected.", groupListResult.isEmpty()); - } - @Test public void newQueryTest() { GroupQuery groupQuery = groupFactoryImpl.newQuery(scopeId); diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/role/shiro/RoleFactoryImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/role/shiro/RoleFactoryImplTest.java index 98b984f8866..b4fe45669e9 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/role/shiro/RoleFactoryImplTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/role/shiro/RoleFactoryImplTest.java @@ -12,22 +12,20 @@ *******************************************************************************/ package org.eclipse.kapua.service.authorization.role.shiro; +import java.util.Date; + import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.qa.markers.junit.JUnitTests; import org.eclipse.kapua.service.authorization.role.Role; import org.eclipse.kapua.service.authorization.role.RoleCreator; -import org.eclipse.kapua.service.authorization.role.RoleQuery; -import org.eclipse.kapua.service.authorization.role.RoleListResult; import org.eclipse.kapua.service.authorization.role.RolePermission; +import org.eclipse.kapua.service.authorization.role.RoleQuery; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.junit.experimental.categories.Category; import org.mockito.Mockito; -import java.util.Date; - - @Category(JUnitTests.class) public class RoleFactoryImplTest { @@ -91,12 +89,6 @@ public void newQueryNullTest() { Assert.assertNull("Null expected.", roleFactoryImpl.newQuery(null).getScopeId()); } - @Test - public void newListResultTest() { - Assert.assertTrue("True expected.", roleFactoryImpl.newListResult() instanceof RoleListResult); - Assert.assertTrue("True expected.", roleFactoryImpl.newListResult().isEmpty()); - } - @Test public void newRolePermissionTest() { Assert.assertTrue("True expected.", roleFactoryImpl.newRolePermission() instanceof RolePermission); diff --git a/service/security/test-steps/src/main/java/org/eclipse/kapua/service/authorization/steps/AuthorizationServiceSteps.java b/service/security/test-steps/src/main/java/org/eclipse/kapua/service/authorization/steps/AuthorizationServiceSteps.java index f015b1ed1b6..9092ef37565 100644 --- a/service/security/test-steps/src/main/java/org/eclipse/kapua/service/authorization/steps/AuthorizationServiceSteps.java +++ b/service/security/test-steps/src/main/java/org/eclipse/kapua/service/authorization/steps/AuthorizationServiceSteps.java @@ -12,14 +12,15 @@ *******************************************************************************/ package org.eclipse.kapua.service.authorization.steps; -import com.google.inject.Singleton; -import io.cucumber.java.After; -import io.cucumber.java.Before; -import io.cucumber.java.Scenario; -import io.cucumber.java.en.And; -import io.cucumber.java.en.Given; -import io.cucumber.java.en.Then; -import io.cucumber.java.en.When; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import javax.inject.Inject; + import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.commons.security.KapuaSecurityUtils; import org.eclipse.kapua.locator.KapuaLocator; @@ -88,13 +89,15 @@ import org.eclipse.kapua.service.user.UserService; import org.junit.Assert; -import javax.inject.Inject; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; +import com.google.inject.Singleton; + +import io.cucumber.java.After; +import io.cucumber.java.Before; +import io.cucumber.java.Scenario; +import io.cucumber.java.en.And; +import io.cucumber.java.en.Given; +import io.cucumber.java.en.Then; +import io.cucumber.java.en.When; // Implementation of Gherkin steps used to test miscellaneous Shiro // authorization functionality. @@ -524,7 +527,6 @@ public void performRoleFactorySanityChecks() { Assert.assertNotNull(roleFactory.newEntity(SYS_SCOPE_ID)); Assert.assertNotNull(roleFactory.newCreator(SYS_SCOPE_ID)); Assert.assertNotNull(roleFactory.newQuery(SYS_SCOPE_ID)); - Assert.assertNotNull(roleFactory.newListResult()); Assert.assertNotNull(roleFactory.newRolePermission()); } @@ -533,7 +535,6 @@ public void performRolePermissionFactorySanityChecks() { Assert.assertNotNull(rolePermissionFactory.newEntity(SYS_SCOPE_ID)); Assert.assertNotNull(rolePermissionFactory.newCreator(SYS_SCOPE_ID)); Assert.assertNotNull(rolePermissionFactory.newQuery(SYS_SCOPE_ID)); - Assert.assertNotNull(rolePermissionFactory.newListResult()); } @Then("The role comparator does its job") @@ -1026,21 +1027,21 @@ public void createPermissionsForDomain(String permList) { Domain curDomain = (Domain) stepData.get(DOMAIN); for (String perm : tmpList) { switch (perm.trim()) { - case "read": - permissions.add(permissionFactory.newPermission(curDomain.getDomain().getName(), Actions.read, currId)); - break; - case "write": - permissions.add(permissionFactory.newPermission(curDomain.getDomain().getName(), Actions.write, currId)); - break; - case "delete": - permissions.add(permissionFactory.newPermission(curDomain.getDomain().getName(), Actions.delete, currId)); - break; - case "connect": - permissions.add(permissionFactory.newPermission(curDomain.getDomain().getName(), Actions.connect, currId)); - break; - case "execute": - permissions.add(permissionFactory.newPermission(curDomain.getDomain().getName(), Actions.execute, currId)); - break; + case "read": + permissions.add(permissionFactory.newPermission(curDomain.getDomain().getName(), Actions.read, currId)); + break; + case "write": + permissions.add(permissionFactory.newPermission(curDomain.getDomain().getName(), Actions.write, currId)); + break; + case "delete": + permissions.add(permissionFactory.newPermission(curDomain.getDomain().getName(), Actions.delete, currId)); + break; + case "connect": + permissions.add(permissionFactory.newPermission(curDomain.getDomain().getName(), Actions.connect, currId)); + break; + case "execute": + permissions.add(permissionFactory.newPermission(curDomain.getDomain().getName(), Actions.execute, currId)); + break; } } // Make sure that there is at least one valid item @@ -1324,7 +1325,6 @@ public void accessInfoServiceSanityCheck() throws Exception { Assert.assertNotNull(accessInfoFactory.newCreator(getKapuaId())); Assert.assertNotNull(accessInfoFactory.newEntity(null)); Assert.assertNotNull(accessInfoFactory.newQuery(getKapuaId())); - Assert.assertNotNull(accessInfoFactory.newListResult()); AccessInfoCreator tmpCreator = accessInfoFactory.newCreator(getKapuaId()); Assert.assertNotNull(tmpCreator); AccessInfo tmpAccInfo = accessInfoFactory.newEntity(getKapuaId()); @@ -1342,7 +1342,6 @@ public void accessPermissionFactorySanityCheck() { Assert.assertNotNull(accessPermissionFactory.newEntity(null)); Assert.assertNotNull(accessPermissionFactory.newEntity(getKapuaId())); Assert.assertNotNull(accessPermissionFactory.newQuery(getKapuaId())); - Assert.assertNotNull(accessPermissionFactory.newListResult()); KapuaId tmpId = getKapuaId(); AccessPermissionCreator tmpCreator = accessPermissionFactory.newCreator(tmpId); Assert.assertNotNull(tmpCreator); @@ -1369,7 +1368,6 @@ public void accessRoleFactorySanityCheck() throws Exception { Assert.assertNotNull(accessRoleFactory.newCreator(getKapuaId())); Assert.assertNotNull(accessRoleFactory.newEntity(getKapuaId())); Assert.assertNotNull(accessRoleFactory.newQuery(getKapuaId())); - Assert.assertNotNull(accessRoleFactory.newListResult()); KapuaId tmpId = getKapuaId(); AccessRoleCreator tmpCreator = accessRoleFactory.newCreator(tmpId); Assert.assertNotNull(tmpCreator); diff --git a/service/tag/api/src/main/java/org/eclipse/kapua/service/tag/TagFactory.java b/service/tag/api/src/main/java/org/eclipse/kapua/service/tag/TagFactory.java index c8f36fb1aab..9f115487ef9 100644 --- a/service/tag/api/src/main/java/org/eclipse/kapua/service/tag/TagFactory.java +++ b/service/tag/api/src/main/java/org/eclipse/kapua/service/tag/TagFactory.java @@ -21,13 +21,15 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface TagFactory extends KapuaEntityFactory { +public interface TagFactory extends KapuaEntityFactory { /** * Instantiates a new {@link TagCreator}. * - * @param scopeId The scope {@link KapuaId} to set into the {@link TagCreator} - * @param name The name to set into the {@link TagCreator}. + * @param scopeId + * The scope {@link KapuaId} to set into the {@link TagCreator} + * @param name + * The name to set into the {@link TagCreator}. * @return The newly instantiated {@link TagCreator} * @since 1.0.0 */ diff --git a/service/tag/api/src/main/java/org/eclipse/kapua/service/tag/TagListResult.java b/service/tag/api/src/main/java/org/eclipse/kapua/service/tag/TagListResult.java index c8b50fe1832..d51c8dc1900 100644 --- a/service/tag/api/src/main/java/org/eclipse/kapua/service/tag/TagListResult.java +++ b/service/tag/api/src/main/java/org/eclipse/kapua/service/tag/TagListResult.java @@ -12,18 +12,20 @@ *******************************************************************************/ package org.eclipse.kapua.service.tag; -import org.eclipse.kapua.model.query.KapuaListResult; - import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import org.eclipse.kapua.model.query.KapuaListResult; + /** * {@link Tag} list result definition. * * @since 1.0.0 */ @XmlRootElement(name = "tags") -@XmlType(factoryClass = TagXmlRegistry.class, factoryMethod = "newTagListResult") -public interface TagListResult extends KapuaListResult { +@XmlType +public class TagListResult extends KapuaListResult { + + private static final long serialVersionUID = 791258978210911362L; } diff --git a/service/tag/api/src/main/java/org/eclipse/kapua/service/tag/TagXmlRegistry.java b/service/tag/api/src/main/java/org/eclipse/kapua/service/tag/TagXmlRegistry.java index e0934428188..c12356b4f6d 100644 --- a/service/tag/api/src/main/java/org/eclipse/kapua/service/tag/TagXmlRegistry.java +++ b/service/tag/api/src/main/java/org/eclipse/kapua/service/tag/TagXmlRegistry.java @@ -12,10 +12,10 @@ *******************************************************************************/ package org.eclipse.kapua.service.tag; -import org.eclipse.kapua.locator.KapuaLocator; - import javax.xml.bind.annotation.XmlRegistry; +import org.eclipse.kapua.locator.KapuaLocator; + @XmlRegistry public class TagXmlRegistry { @@ -39,15 +39,6 @@ public TagCreator newTagCreator() { return tagFactory.newCreator(null, null); } - /** - * Creates a new tag creator instance - * - * @return - */ - public TagListResult newTagListResult() { - return tagFactory.newListResult(); - } - public TagQuery newQuery() { return tagFactory.newQuery(null); } diff --git a/service/tag/internal/src/main/java/org/eclipse/kapua/service/tag/internal/TagFactoryImpl.java b/service/tag/internal/src/main/java/org/eclipse/kapua/service/tag/internal/TagFactoryImpl.java index 5931fd10e3f..49778c6df75 100644 --- a/service/tag/internal/src/main/java/org/eclipse/kapua/service/tag/internal/TagFactoryImpl.java +++ b/service/tag/internal/src/main/java/org/eclipse/kapua/service/tag/internal/TagFactoryImpl.java @@ -12,16 +12,15 @@ *******************************************************************************/ package org.eclipse.kapua.service.tag.internal; +import javax.inject.Singleton; + import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.tag.Tag; import org.eclipse.kapua.service.tag.TagCreator; import org.eclipse.kapua.service.tag.TagFactory; -import org.eclipse.kapua.service.tag.TagListResult; import org.eclipse.kapua.service.tag.TagQuery; -import javax.inject.Singleton; - /** * {@link TagFactory} implementation. * @@ -44,11 +43,6 @@ public Tag newEntity(KapuaId scopeId) { return new TagImpl(scopeId); } - @Override - public TagListResult newListResult() { - return new TagListResultImpl(); - } - @Override public TagQuery newQuery(KapuaId scopeId) { return new TagQueryImpl(scopeId); diff --git a/service/tag/internal/src/main/java/org/eclipse/kapua/service/tag/internal/TagImplJpaRepository.java b/service/tag/internal/src/main/java/org/eclipse/kapua/service/tag/internal/TagImplJpaRepository.java index ee9965fb26a..5d370bd47d3 100644 --- a/service/tag/internal/src/main/java/org/eclipse/kapua/service/tag/internal/TagImplJpaRepository.java +++ b/service/tag/internal/src/main/java/org/eclipse/kapua/service/tag/internal/TagImplJpaRepository.java @@ -12,20 +12,21 @@ *******************************************************************************/ package org.eclipse.kapua.service.tag.internal; +import javax.inject.Singleton; + import org.eclipse.kapua.commons.jpa.KapuaJpaRepositoryConfiguration; import org.eclipse.kapua.commons.jpa.KapuaNamedEntityJpaRepository; import org.eclipse.kapua.service.tag.Tag; import org.eclipse.kapua.service.tag.TagListResult; import org.eclipse.kapua.service.tag.TagRepository; -import javax.inject.Singleton; - @Singleton public class TagImplJpaRepository extends KapuaNamedEntityJpaRepository implements TagRepository { + public TagImplJpaRepository(KapuaJpaRepositoryConfiguration jpaRepoConfig) { - super(TagImpl.class, Tag.TYPE, TagListResultImpl::new, jpaRepoConfig); + super(TagImpl.class, Tag.TYPE, TagListResult::new, jpaRepoConfig); } } diff --git a/service/tag/internal/src/main/java/org/eclipse/kapua/service/tag/internal/TagListResultImpl.java b/service/tag/internal/src/main/java/org/eclipse/kapua/service/tag/internal/TagListResultImpl.java deleted file mode 100644 index 3bbf92f544c..00000000000 --- a/service/tag/internal/src/main/java/org/eclipse/kapua/service/tag/internal/TagListResultImpl.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017, 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.service.tag.internal; - -import org.eclipse.kapua.commons.model.query.KapuaListResultImpl; -import org.eclipse.kapua.service.tag.Tag; -import org.eclipse.kapua.service.tag.TagListResult; - -/** - * {@link TagListResult} implementation. - * - * @since 1.0.0 - */ -public class TagListResultImpl extends KapuaListResultImpl implements TagListResult { - - private static final long serialVersionUID = 791258978210911362L; -} diff --git a/service/user/api/src/main/java/org/eclipse/kapua/service/user/UserFactory.java b/service/user/api/src/main/java/org/eclipse/kapua/service/user/UserFactory.java index 763f88f819b..ad6f5722827 100644 --- a/service/user/api/src/main/java/org/eclipse/kapua/service/user/UserFactory.java +++ b/service/user/api/src/main/java/org/eclipse/kapua/service/user/UserFactory.java @@ -21,13 +21,15 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface UserFactory extends KapuaEntityFactory { +public interface UserFactory extends KapuaEntityFactory { /** * Instantiates a new {@link UserCreator} * - * @param scopedId The scope {@link KapuaId} to set into the {@link UserCreator}. - * @param name The name to set into the {@link UserCreator}. + * @param scopedId + * The scope {@link KapuaId} to set into the {@link UserCreator}. + * @param name + * The name to set into the {@link UserCreator}. * @return The newly instantiated {@link UserCreator} * @since 1.0.0 */ diff --git a/service/user/api/src/main/java/org/eclipse/kapua/service/user/UserListResult.java b/service/user/api/src/main/java/org/eclipse/kapua/service/user/UserListResult.java index 37dc26c836a..3f92b0e8099 100644 --- a/service/user/api/src/main/java/org/eclipse/kapua/service/user/UserListResult.java +++ b/service/user/api/src/main/java/org/eclipse/kapua/service/user/UserListResult.java @@ -23,7 +23,9 @@ * @since 1.0 */ @XmlRootElement(name = "users") -@XmlType(factoryClass = UserXmlRegistry.class, factoryMethod = "newUserListResult") -public interface UserListResult extends KapuaListResult { +@XmlType +public class UserListResult extends KapuaListResult { + + private static final long serialVersionUID = 2231053707705207563L; } diff --git a/service/user/api/src/main/java/org/eclipse/kapua/service/user/UserXmlRegistry.java b/service/user/api/src/main/java/org/eclipse/kapua/service/user/UserXmlRegistry.java index a9b33088658..04d48cb787c 100644 --- a/service/user/api/src/main/java/org/eclipse/kapua/service/user/UserXmlRegistry.java +++ b/service/user/api/src/main/java/org/eclipse/kapua/service/user/UserXmlRegistry.java @@ -12,10 +12,10 @@ *******************************************************************************/ package org.eclipse.kapua.service.user; -import org.eclipse.kapua.locator.KapuaLocator; - import javax.xml.bind.annotation.XmlRegistry; +import org.eclipse.kapua.locator.KapuaLocator; + /** * {@link User} xml factory class * @@ -44,15 +44,6 @@ public UserCreator newUserCreator() { return userFactory.newCreator(null, null); } - /** - * Creates new user list result - * - * @return - */ - public UserListResult newUserListResult() { - return userFactory.newListResult(); - } - public UserQuery newQuery() { return userFactory.newQuery(null); } diff --git a/service/user/internal/src/main/java/org/eclipse/kapua/service/user/internal/UserFactoryImpl.java b/service/user/internal/src/main/java/org/eclipse/kapua/service/user/internal/UserFactoryImpl.java index e31df74a8dd..2d04f102a5f 100644 --- a/service/user/internal/src/main/java/org/eclipse/kapua/service/user/internal/UserFactoryImpl.java +++ b/service/user/internal/src/main/java/org/eclipse/kapua/service/user/internal/UserFactoryImpl.java @@ -12,16 +12,15 @@ *******************************************************************************/ package org.eclipse.kapua.service.user.internal; +import javax.inject.Singleton; + import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.user.User; import org.eclipse.kapua.service.user.UserCreator; import org.eclipse.kapua.service.user.UserFactory; -import org.eclipse.kapua.service.user.UserListResult; import org.eclipse.kapua.service.user.UserQuery; -import javax.inject.Singleton; - /** * {@link UserFactory} implementation. * @@ -44,11 +43,6 @@ public UserQuery newQuery(KapuaId scopeId) { return new UserQueryImpl(scopeId); } - @Override - public UserListResult newListResult() { - return new UserListResultImpl(); - } - @Override public User newEntity(KapuaId scopeId) { return new UserImpl(scopeId); diff --git a/service/user/internal/src/main/java/org/eclipse/kapua/service/user/internal/UserImplJpaRepository.java b/service/user/internal/src/main/java/org/eclipse/kapua/service/user/internal/UserImplJpaRepository.java index 4b5f2c2de8c..0e88bb9457c 100644 --- a/service/user/internal/src/main/java/org/eclipse/kapua/service/user/internal/UserImplJpaRepository.java +++ b/service/user/internal/src/main/java/org/eclipse/kapua/service/user/internal/UserImplJpaRepository.java @@ -12,6 +12,8 @@ *******************************************************************************/ package org.eclipse.kapua.service.user.internal; +import java.util.Optional; + import org.eclipse.kapua.commons.jpa.KapuaJpaRepositoryConfiguration; import org.eclipse.kapua.commons.jpa.KapuaNamedEntityJpaRepository; import org.eclipse.kapua.model.id.KapuaId; @@ -21,13 +23,12 @@ import org.eclipse.kapua.service.user.UserRepository; import org.eclipse.kapua.storage.TxContext; -import java.util.Optional; - public class UserImplJpaRepository extends KapuaNamedEntityJpaRepository implements UserRepository { + public UserImplJpaRepository(KapuaJpaRepositoryConfiguration jpaRepoConfig) { - super(UserImpl.class, User.TYPE, () -> new UserListResultImpl(), jpaRepoConfig); + super(UserImpl.class, User.TYPE, () -> new UserListResult(), jpaRepoConfig); } @Override diff --git a/service/user/internal/src/main/java/org/eclipse/kapua/service/user/internal/UserListResultImpl.java b/service/user/internal/src/main/java/org/eclipse/kapua/service/user/internal/UserListResultImpl.java deleted file mode 100644 index ac333e8b44e..00000000000 --- a/service/user/internal/src/main/java/org/eclipse/kapua/service/user/internal/UserListResultImpl.java +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************* - * 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.service.user.internal; - -import org.eclipse.kapua.commons.model.query.KapuaListResultImpl; -import org.eclipse.kapua.service.user.User; -import org.eclipse.kapua.service.user.UserListResult; - -/** - * User list result implementation. - * - * @since 1.0 - * - */ -public class UserListResultImpl extends KapuaListResultImpl implements UserListResult { - - private static final long serialVersionUID = 2231053707705207563L; -} diff --git a/translator/kapua/kura/src/main/java/org/eclipse/kapua/translator/kapua/kura/TranslatorAppAssetKapuaKura.java b/translator/kapua/kura/src/main/java/org/eclipse/kapua/translator/kapua/kura/TranslatorAppAssetKapuaKura.java index 87059b422ec..c81cbf29e6f 100644 --- a/translator/kapua/kura/src/main/java/org/eclipse/kapua/translator/kapua/kura/TranslatorAppAssetKapuaKura.java +++ b/translator/kapua/kura/src/main/java/org/eclipse/kapua/translator/kapua/kura/TranslatorAppAssetKapuaKura.java @@ -12,8 +12,14 @@ *******************************************************************************/ package org.eclipse.kapua.translator.kapua.kura; -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.databind.ObjectMapper; +import java.io.IOException; +import java.io.StringWriter; +import java.io.UnsupportedEncodingException; +import java.util.Date; + +import javax.inject.Inject; +import javax.xml.bind.JAXBException; + import org.eclipse.kapua.service.device.call.kura.model.asset.AssetMetrics; import org.eclipse.kapua.service.device.call.kura.model.asset.KuraAsset; import org.eclipse.kapua.service.device.call.kura.model.asset.KuraAssetChannel; @@ -30,12 +36,8 @@ import org.eclipse.kapua.translator.exception.InvalidPayloadException; import org.xml.sax.SAXException; -import javax.inject.Inject; -import javax.xml.bind.JAXBException; -import java.io.IOException; -import java.io.StringWriter; -import java.io.UnsupportedEncodingException; -import java.util.Date; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.databind.ObjectMapper; /** * {@link org.eclipse.kapua.translator.Translator} implementation from {@link AssetRequestMessage} to {@link KuraRequestMessage} @@ -79,7 +81,7 @@ protected KuraRequestPayload translatePayload(AssetRequestPayload kapuaPayload) try { DeviceAssets deviceAssets; try { - deviceAssets = kapuaPayload.getDeviceAssets().orElse(deviceAssetFactory.newAssetListResult()); + deviceAssets = kapuaPayload.getDeviceAssets().orElse(new DeviceAssets()); } catch (UnsupportedEncodingException | JAXBException | SAXException e) { throw new InvalidPayloadException(e, kapuaPayload); } diff --git a/translator/kapua/kura/src/main/java/org/eclipse/kapua/translator/kura/kapua/TranslatorAppAssetKuraKapua.java b/translator/kapua/kura/src/main/java/org/eclipse/kapua/translator/kura/kapua/TranslatorAppAssetKuraKapua.java index 5daa8174bfa..cc9102aec9f 100644 --- a/translator/kapua/kura/src/main/java/org/eclipse/kapua/translator/kura/kapua/TranslatorAppAssetKuraKapua.java +++ b/translator/kapua/kura/src/main/java/org/eclipse/kapua/translator/kura/kapua/TranslatorAppAssetKuraKapua.java @@ -76,7 +76,7 @@ protected AssetResponsePayload translatePayload(KuraResponsePayload kuraResponse ObjectMapper mapper = new ObjectMapper(); JsonNode jsonNode = mapper.readTree(kuraResponsePayload.getBody()); - DeviceAssets deviceAssets = deviceAssetFactory.newAssetListResult(); + DeviceAssets deviceAssets = new DeviceAssets(); KuraAssets kuraAssets = KuraAssets.readJsonNode(jsonNode); kuraAssets.getAssets().forEach(kuraAsset -> { diff --git a/transport/mqtt/src/main/java/org/eclipse/kapua/transport/mqtt/MqttResponseTimeoutTimer.java b/transport/mqtt/src/main/java/org/eclipse/kapua/transport/mqtt/MqttResponseTimeoutTimer.java index 0a653270e07..12e96110102 100644 --- a/transport/mqtt/src/main/java/org/eclipse/kapua/transport/mqtt/MqttResponseTimeoutTimer.java +++ b/transport/mqtt/src/main/java/org/eclipse/kapua/transport/mqtt/MqttResponseTimeoutTimer.java @@ -12,10 +12,11 @@ *******************************************************************************/ package org.eclipse.kapua.transport.mqtt; -import javax.validation.constraints.NotNull; import java.util.Timer; import java.util.TimerTask; +import javax.validation.constraints.NotNull; + /** * The {@link Timer} to handle the timeout of {@link MqttResponseCallback}. * @@ -30,9 +31,12 @@ public class MqttResponseTimeoutTimer extends Timer { /** * Starts a {@link Timer} at the given timeout and runs {@link TimeoutTimerTask} when timeout expires. * - * @param clientId The clientId of the {@link MqttClient}. Used to set the {@link Timer} name. - * @param mqttClientCallback The {@link MqttResponseCallback} on which to wait. - * @param timeout The timeout of the waiting. + * @param clientId + * The clientId of the {@link MqttClient}. Used to set the {@link Timer} name. + * @param mqttClientCallback + * The {@link MqttResponseCallback} on which to wait. + * @param timeout + * The timeout of the waiting. * @since 1.0.0 */ public MqttResponseTimeoutTimer(@NotNull String clientId, @NotNull MqttResponseCallback mqttClientCallback, long timeout) { @@ -48,7 +52,8 @@ public MqttResponseTimeoutTimer(@NotNull String clientId, @NotNull MqttResponseC * * @since 1.0.0 */ - private class TimeoutTimerTask extends TimerTask { + public class TimeoutTimerTask extends TimerTask { + @Override public void run() { synchronized (mqttResponseCallback) { From 52a7160486d1ade571a643d149888ad80987618b Mon Sep 17 00:00:00 2001 From: dseurotech Date: Tue, 14 Jan 2025 09:29:25 +0100 Subject: [PATCH 2/4] :boom: breaking KapuaQueries down to basic bits Signed-off-by: dseurotech --- .../rest/filters/CORSResponseFilter.java | 66 +-- .../eclipse/kapua/commons/CommonsModule.java | 3 - ...puaConfigurableResourceLimitedService.java | 9 +- .../AbstractKapuaConfigurableService.java | 5 +- .../ServiceConfigImplJpaRepository.java | 3 +- .../configuration/ServiceConfigQuery.java | 24 - .../configuration/ServiceConfigQueryImpl.java | 44 -- .../ServiceConfigurationManagerImpl.java | 3 +- .../UsedEntitiesCounterImpl.java | 4 +- .../event/ServiceEventHousekeeper.java | 16 +- .../ServiceEventTransactionalHousekeeper.java | 18 +- .../commons/jpa/KapuaEntityJpaRepository.java | 6 +- .../AbstractKapuaForwardableEntityQuery.java | 61 --- .../model/query/AbstractKapuaQuery.java | 206 -------- .../model/query/FieldSortCriteriaImpl.java | 66 --- .../commons/model/query/QueryFactoryImpl.java | 33 -- .../query/predicate/AndPredicateImpl.java | 73 --- .../predicate/AttributePredicateImpl.java | 70 --- .../query/predicate/OrPredicateImpl.java | 73 --- .../event/store/api/EventStoreFactory.java | 2 +- .../store/api/EventStoreRecordQuery.java | 30 +- .../store/api/EventStoreXmlRegistry.java | 5 - .../store/internal/EventStoreFactoryImpl.java | 6 - .../store/internal/EventStoreQueryImpl.java | 45 -- .../KapuaNamedEntityServiceUtils.java | 139 +++-- .../commons/service/internal/ServiceDAO.java | 484 ++++++++++-------- .../ServiceConfigQueryImplTest.java | 32 -- ...plTest.java => FieldSortCriteriaTest.java} | 29 +- ...apuaQueryTest.java => KapuaQueryTest.java} | 90 ++-- ...ateImplTest.java => AndPredicateTest.java} | 40 +- ...lTest.java => AttributePredicateTest.java} | 54 +- ...cateImplTest.java => OrPredicateTest.java} | 32 +- .../internal/EventStoreFactoryImplTest.java | 11 - .../internal/EventStoreQueryImplTest.java | 49 -- .../account/server/GwtAccountServiceImpl.java | 67 +-- .../util/GwtKapuaAccountModelConverter.java | 11 +- .../server/GwtCredentialServiceImpl.java | 26 +- .../GwtKapuaAuthenticationModelConverter.java | 29 +- .../GwtAccessPermissionServiceImpl.java | 19 +- .../server/GwtAccessRoleServiceImpl.java | 19 +- .../server/GwtDomainRegistryServiceImpl.java | 14 +- .../server/GwtGroupServiceImpl.java | 32 +- .../server/GwtRoleServiceImpl.java | 34 +- .../GwtKapuaAuthorizationModelConverter.java | 104 ++-- .../server/GwtCertificateInfoServiceImpl.java | 8 +- .../data/server/GwtDataServiceImpl.java | 41 +- .../data/servlet/DataExporterServlet.java | 19 +- .../GwtDeviceConnectionServiceImpl.java | 31 +- ...tDeviceManagementOperationServiceImpl.java | 15 +- .../device/server/GwtDeviceServiceImpl.java | 23 +- .../servlet/DeviceEventExporterServlet.java | 20 +- .../device/servlet/DeviceExporterServlet.java | 19 +- .../util/GwtKapuaDeviceModelConverter.java | 6 +- .../server/GwtEndpointServiceImpl.java | 30 +- .../job/server/GwtJobEngineServiceImpl.java | 8 +- .../module/job/server/GwtJobServiceImpl.java | 28 +- .../GwtJobStepDefinitionServiceImpl.java | 18 +- .../job/server/GwtJobStepServiceImpl.java | 21 +- .../job/server/GwtJobTargetServiceImpl.java | 27 +- .../GwtTriggerDefinitionServiceImpl.java | 16 +- .../job/server/GwtTriggerServiceImpl.java | 23 +- .../job/servlet/JobTargetExporterCsv.java | 11 +- .../job/servlet/JobTargetExporterServlet.java | 4 +- .../util/GwtKapuaJobModelConverter.java | 40 +- .../module/tag/server/GwtTagServiceImpl.java | 30 +- .../util/GwtKapuaTagModelConverter.java | 17 +- .../user/server/GwtUserServiceImpl.java | 37 +- .../util/GwtKapuaUserModelConverter.java | 15 +- .../api/AbstractEntityAttributeMigrator.java | 5 +- .../MfaOptionAttributeMigrator.java | 7 +- .../MfaOptionMigratorQueryImpl.java | 33 -- .../job/JobStepAttributeMigrator.java | 5 - .../job/JobStepMigratorQueryImpl.java | 33 -- .../queue/QueuedJobExecutionFactory.java | 2 +- .../engine/queue/QueuedJobExecutionQuery.java | 32 -- .../queue/QueuedJobExecutionService.java | 8 +- .../queue/QueuedJobExecutionXmlRegistry.java | 3 - .../jaxb/JobEngineJAXBContextProvider.java | 6 - .../operation/DefaultTargetReader.java | 3 +- .../engine/jbatch/JobEngineServiceJbatch.java | 35 +- .../engine/jbatch/driver/JbatchDriver.java | 4 +- .../jbatch/listener/KapuaJobListener.java | 6 +- .../listener/QueuedJobExecutionCheckTask.java | 18 +- .../jbatch/QueuedJobExecutionFactoryImpl.java | 6 - .../jbatch/QueuedJobExecutionQueryImpl.java | 35 -- .../misc/RolePermissionFactoryTest.java | 13 - .../MessageStoreServiceSslTest.java | 26 +- .../resources/v1/resources/AccessInfos.java | 121 +++-- .../v1/resources/AccessPermissions.java | 145 +++--- .../resources/v1/resources/AccessRoles.java | 117 +++-- .../api/resources/v1/resources/Accounts.java | 20 +- .../resources/v1/resources/Credentials.java | 126 +++-- .../v1/resources/DeviceConnections.java | 97 ++-- .../resources/v1/resources/DeviceEvents.java | 119 +++-- ...eviceManagementOperationNotifications.java | 84 +-- .../resources/DeviceManagementOperations.java | 90 ++-- .../api/resources/v1/resources/Devices.java | 150 +++--- .../api/resources/v1/resources/Domains.java | 97 ++-- .../api/resources/v1/resources/Groups.java | 97 ++-- .../resources/v1/resources/JobExecutions.java | 83 +-- .../v1/resources/JobStepDefinitions.java | 94 ++-- .../api/resources/v1/resources/JobSteps.java | 164 +++--- .../resources/v1/resources/JobTargets.java | 145 +++--- .../v1/resources/JobTriggerDefinitions.java | 82 +-- .../resources/v1/resources/JobTriggers.java | 179 ++++--- .../v1/resources/JobTriggersFired.java | 84 +-- .../app/api/resources/v1/resources/Jobs.java | 135 +++-- .../app/api/resources/v1/resources/Roles.java | 124 +++-- .../v1/resources/RolesPermissions.java | 154 +++--- .../app/api/resources/v1/resources/Tags.java | 100 ++-- .../app/api/resources/v1/resources/Users.java | 138 +++-- .../v1/resources/UsersCredentials.java | 100 ++-- .../api/web/RestApiJAXBContextProvider.java | 26 - .../kapua/service/account/AccountFactory.java | 2 +- .../kapua/service/account/AccountQuery.java | 33 -- .../account/xml/AccountXmlRegistry.java | 11 - .../account/internal/AccountFactoryImpl.java | 6 - .../account/internal/AccountQueryImpl.java | 46 -- .../internal/AccountRelativeFinderImpl.java | 10 +- .../account/internal/AccountServiceImpl.java | 2 +- .../account/steps/AccountServiceSteps.java | 11 +- .../test/AccountLocatorConfiguration.java | 3 - .../kapua/model/KapuaEntityFactory.java | 15 +- .../model/query/AbstractKapuaNamedQuery.java | 13 +- .../kapua/model/query/FieldSortCriteria.java | 32 +- .../query/KapuaForwardableEntityQuery.java | 49 +- .../eclipse/kapua/model/query/KapuaQuery.java | 232 ++++++--- .../kapua/model/query/QueryFactory.java | 31 -- .../predicate/AbstractMatchPredicate.java | 4 +- .../model/query/predicate/AndPredicate.java | 63 ++- .../query/predicate/AttributePredicate.java | 79 ++- .../model/query/predicate/OrPredicate.java | 63 ++- .../authentication/AuthenticationLogic.java | 19 +- .../query/predicate/AndPredicateImpl.java | 19 +- .../StorablePredicateFactoryImpl.java | 4 +- .../ChannelInfoRegistryServiceImpl.java | 18 +- .../ClientInfoRegistryServiceImpl.java | 15 +- .../MetricInfoRegistryServiceImpl.java | 15 +- .../datastore/steps/DatastoreSteps.java | 245 ++++----- .../JobDeviceManagementOperationFactory.java | 2 +- .../JobDeviceManagementOperationQuery.java | 32 -- .../JobDeviceManagementOperationService.java | 3 +- ...bDeviceManagementOperationXmlRegistry.java | 3 - ...bDeviceManagementOperationFactoryImpl.java | 6 - ...JobDeviceManagementOperationQueryImpl.java | 35 -- ...bDeviceManagementOperationServiceImpl.java | 31 +- ...ManagementOperationManagerServiceImpl.java | 75 +-- ...ceManagementTriggerManagerServiceImpl.java | 20 +- .../DeviceManagementOperationFactory.java | 2 +- .../DeviceManagementOperationQuery.java | 39 +- .../DeviceManagementOperationXmlRegistry.java | 3 - ...anagementOperationNotificationFactory.java | 2 +- .../ManagementOperationNotificationQuery.java | 38 +- ...ementOperationNotificationXmlRegistry.java | 3 - ...eManagementRegistryManagerServiceImpl.java | 16 +- .../DeviceManagementOperationFactoryImpl.java | 6 - .../DeviceManagementOperationQueryImpl.java | 54 -- ...ementOperationNotificationFactoryImpl.java | 6 - ...agementOperationNotificationQueryImpl.java | 54 -- .../device/registry/DeviceFactory.java | 2 +- .../device/registry/DeviceMatchPredicate.java | 30 +- .../service/device/registry/DeviceQuery.java | 48 +- .../device/registry/DeviceXmlRegistry.java | 4 - .../connection/DeviceConnectionFactory.java | 2 +- .../connection/DeviceConnectionQuery.java | 38 +- .../DeviceConnectionXmlRegistry.java | 3 - .../option/DeviceConnectionOptionFactory.java | 2 +- .../option/DeviceConnectionOptionQuery.java | 33 -- .../DeviceConnectionOptionXmlRegistry.java | 4 - .../registry/event/DeviceEventFactory.java | 2 +- .../registry/event/DeviceEventQuery.java | 37 +- .../event/DeviceEventXmlRegistry.java | 3 - .../device/registry/DeviceRegistryModule.java | 2 - .../registry/common/DeviceValidationImpl.java | 113 ++-- .../internal/DeviceConnectionFactoryImpl.java | 6 - .../DeviceConnectionImplJpaRepository.java | 3 +- .../internal/DeviceConnectionQueryImpl.java | 53 -- .../internal/DeviceConnectionServiceImpl.java | 20 +- .../DeviceConnectionOptionFactoryImpl.java | 6 - .../DeviceConnectionOptionQueryImpl.java | 45 -- .../DeviceConnectionOptionServiceImpl.java | 15 +- .../internal/DeviceEventFactoryImpl.java | 6 - .../event/internal/DeviceEventQueryImpl.java | 53 -- .../registry/internal/DeviceFactoryImpl.java | 6 - .../internal/DeviceImplJpaRepository.java | 3 +- .../internal/DeviceMatchPredicateImpl.java | 48 -- .../registry/internal/DeviceQueryImpl.java | 59 --- .../internal/DeviceRegistryServiceImpl.java | 14 +- .../registry/steps/DeviceRegistrySteps.java | 104 ++-- .../DeviceRegistryLocatorConfiguration.java | 24 +- .../service/endpoint/EndpointInfoFactory.java | 6 +- .../endpoint/EndpointInfoMatchPredicate.java | 19 +- .../service/endpoint/EndpointInfoQuery.java | 32 +- .../internal/EndpointInfoFactoryImpl.java | 2 +- .../EndpointInfoMatchPredicateImpl.java | 37 -- .../internal/EndpointInfoQueryImpl.java | 41 -- .../internal/EndpointInfoServiceImpl.java | 65 ++- .../eclipse/kapua/service/job/JobFactory.java | 2 +- .../kapua/service/job/JobMatchPredicate.java | 20 +- .../eclipse/kapua/service/job/JobQuery.java | 34 +- .../kapua/service/job/JobXmlRegistry.java | 2 +- .../job/execution/JobExecutionFactory.java | 2 +- .../job/execution/JobExecutionQuery.java | 30 +- .../execution/JobExecutionXmlRegistry.java | 3 - .../service/job/step/JobStepFactory.java | 2 +- .../kapua/service/job/step/JobStepQuery.java | 32 -- .../service/job/step/JobStepService.java | 8 +- .../service/job/step/JobStepXmlRegistry.java | 4 - .../definition/JobStepDefinitionFactory.java | 2 +- .../definition/JobStepDefinitionQuery.java | 35 +- .../JobStepDefinitionXmlRegistry.java | 4 - .../service/job/targets/JobTargetFactory.java | 2 +- .../service/job/targets/JobTargetQuery.java | 32 -- .../service/job/targets/JobTargetService.java | 8 +- .../job/targets/JobTargetXmlRegistry.java | 3 - .../internal/JobExecutionFactoryImpl.java | 6 - .../JobExecutionImplJpaRepository.java | 2 +- .../internal/JobExecutionQueryImpl.java | 43 -- .../service/job/internal/JobFactoryImpl.java | 6 - .../job/internal/JobMatchPredicateImpl.java | 37 -- .../service/job/internal/JobQueryImpl.java | 41 -- .../internal/JobStepDefinitionAligner.java | 3 +- .../JobStepDefinitionFactoryImpl.java | 6 - .../internal/JobStepDefinitionQueryImpl.java | 48 -- .../JobStepDefinitionServiceImpl.java | 3 +- .../job/step/internal/JobStepFactoryImpl.java | 6 - .../job/step/internal/JobStepModule.java | 4 - .../job/step/internal/JobStepQueryImpl.java | 35 -- .../job/step/internal/JobStepServiceImpl.java | 59 +-- .../internal/JobTargetFactoryImpl.java | 6 - .../targets/internal/JobTargetQueryImpl.java | 35 -- .../internal/JobTargetServiceImpl.java | 16 +- .../job/steps/JobExecutionServiceSteps.java | 11 +- .../service/job/steps/JobServiceSteps.java | 18 +- .../service/job/steps/JobServiceTestBase.java | 2 +- .../steps/JobStepDefinitionServiceSteps.java | 6 +- .../job/steps/JobStepServiceSteps.java | 12 +- .../job/steps/JobTargetServiceSteps.java | 13 +- .../job/test/JobLocatorConfiguration.java | 3 - .../scheduler/trigger/TriggerFactory.java | 2 +- .../scheduler/trigger/TriggerQuery.java | 32 -- .../scheduler/trigger/TriggerService.java | 3 +- .../scheduler/trigger/TriggerXmlRegistry.java | 4 - .../definition/TriggerDefinitionFactory.java | 2 +- .../definition/TriggerDefinitionQuery.java | 21 +- .../TriggerDefinitionXmlRegistry.java | 3 - .../trigger/fired/FiredTriggerFactory.java | 2 +- .../trigger/fired/FiredTriggerQuery.java | 32 -- .../trigger/fired/FiredTriggerService.java | 3 +- .../fired/FiredTriggerXmlRegistry.java | 3 - .../quartz/TriggerDefinitionAligner.java | 29 +- .../quartz/TriggerDefinitionFactoryImpl.java | 6 - .../quartz/TriggerDefinitionQueryImpl.java | 35 -- .../fired/quartz/FiredTriggerFactoryImpl.java | 6 - .../fired/quartz/FiredTriggerQueryImpl.java | 35 -- .../trigger/quartz/TriggerFactoryImpl.java | 6 - .../trigger/quartz/TriggerQueryImpl.java | 45 -- .../steps/JobScheduleServiceSteps.java | 54 +- .../test/SchedulerLocatorConfiguration.java | 5 - .../credential/CredentialFactory.java | 2 +- .../credential/CredentialQuery.java | 32 -- .../credential/CredentialService.java | 59 ++- .../credential/CredentialXmlRegistry.java | 10 - .../credential/mfa/MfaOptionFactory.java | 2 +- .../credential/mfa/MfaOptionQuery.java | 32 -- .../credential/mfa/MfaOptionXmlRegistry.java | 10 - .../token/AccessTokenFactory.java | 2 +- .../token/AccessTokenQuery.java | 24 - .../access/AccessInfoFactory.java | 2 +- .../authorization/access/AccessInfoQuery.java | 32 -- .../access/AccessInfoService.java | 30 +- .../access/AccessInfoXmlRegistry.java | 3 - .../access/AccessPermissionFactory.java | 2 +- .../access/AccessPermissionQuery.java | 32 -- .../access/AccessPermissionService.java | 30 +- .../access/AccessPermissionXmlRegistry.java | 4 - .../access/AccessRoleFactory.java | 2 +- .../authorization/access/AccessRoleQuery.java | 32 -- .../access/AccessRoleService.java | 30 +- .../access/AccessRoleXmlRegistry.java | 3 - .../authorization/domain/DomainFactory.java | 2 +- .../authorization/domain/DomainQuery.java | 32 -- .../domain/DomainRegistryService.java | 27 +- .../domain/DomainXmlRegistry.java | 27 - .../authorization/group/GroupFactory.java | 2 +- .../group/GroupMatchPredicate.java | 20 +- .../authorization/group/GroupQuery.java | 34 +- .../authorization/group/GroupXmlRegistry.java | 10 - .../authorization/role/RoleFactory.java | 2 +- .../role/RoleMatchPredicate.java | 19 +- .../role/RolePermissionFactory.java | 2 +- .../role/RolePermissionQuery.java | 32 -- .../role/RolePermissionService.java | 30 +- .../role/RolePermissionXmlRegistry.java | 3 - .../service/authorization/role/RoleQuery.java | 41 +- .../authorization/role/RoleXmlRegistry.java | 10 - .../certificate/CertificateFactory.java | 3 +- .../service/certificate/CertificateQuery.java | 27 +- .../info/CertificateInfoFactory.java | 2 +- .../info/CertificateInfoMatchPredicate.java | 22 +- .../info/CertificateInfoQuery.java | 41 +- .../info/xml/CertificateInfoXmlRegistry.java | 4 - .../xml/CertificateXmlRegistry.java | 5 - .../internal/CertificateInfoFactoryImpl.java | 6 - .../CertificateInfoMatchPredicateImpl.java | 40 -- .../internal/CertificateInfoQueryImpl.java | 63 --- .../internal/CertificateInfoServiceImpl.java | 5 +- .../internal/CertificateFactoryImpl.java | 6 - .../internal/CertificateQueryImpl.java | 56 -- .../mfa/shiro/MfaOptionFactoryImpl.java | 6 - .../mfa/shiro/MfaOptionQueryImpl.java | 46 -- .../shiro/CredentialFactoryImpl.java | 6 - .../credential/shiro/CredentialQueryImpl.java | 44 -- .../shiro/CredentialServiceImpl.java | 58 +-- .../shiro/AuthenticationServiceShiroImpl.java | 54 +- .../realm/AccessTokenAuthenticatingRealm.java | 37 +- .../realm/AccessTokenCredentialsMatcher.java | 4 +- .../token/shiro/AccessTokenFactoryImpl.java | 6 - .../token/shiro/AccessTokenQueryImpl.java | 45 -- .../token/shiro/AccessTokenServiceImpl.java | 16 +- .../access/shiro/AccessInfoFactoryImpl.java | 6 - .../access/shiro/AccessInfoQueryImpl.java | 45 -- .../access/shiro/AccessInfoServiceImpl.java | 29 +- .../shiro/AccessPermissionFactoryImpl.java | 6 - .../AccessPermissionImplJpaRepository.java | 4 +- .../shiro/AccessPermissionQueryImpl.java | 45 -- .../shiro/AccessPermissionServiceImpl.java | 18 +- .../access/shiro/AccessRoleFactoryImpl.java | 6 - .../access/shiro/AccessRoleQueryImpl.java | 45 -- .../access/shiro/AccessRoleServiceImpl.java | 9 +- .../CachingAccessPermissionRepository.java | 5 +- .../domain/shiro/DomainFactoryImpl.java | 6 - .../domain/shiro/DomainQueryImpl.java | 44 -- .../shiro/DomainRegistryServiceImpl.java | 10 +- .../domain/shiro/DomainsAligner.java | 33 +- .../group/shiro/GroupFactoryImpl.java | 6 - .../group/shiro/GroupMatchPredicateImpl.java | 37 -- .../group/shiro/GroupQueryImpl.java | 41 -- .../group/shiro/GroupServiceImpl.java | 23 +- .../permission/shiro/PermissionValidator.java | 14 +- .../role/shiro/RoleFactoryImpl.java | 6 - .../role/shiro/RoleMatchPredicateImpl.java | 35 -- .../role/shiro/RolePermissionFactoryImpl.java | 6 - .../role/shiro/RolePermissionQueryImpl.java | 45 -- .../role/shiro/RolePermissionServiceImpl.java | 16 +- .../role/shiro/RoleQueryImpl.java | 52 -- .../role/shiro/RoleServiceImpl.java | 35 +- .../shiro/KapuaAuthorizingRealm.java | 4 +- .../mfa/shiro/MfaOptionFactoryImplTest.java | 9 - .../mfa/shiro/MfaOptionQueryImplTest.java | 44 -- .../shiro/CredentialFactoryImplTest.java | 4 +- .../shiro/CredentialQueryImplTest.java | 43 -- .../shiro/AccessTokenFactoryImplTest.java | 9 - .../token/shiro/AccessTokenQueryImplTest.java | 47 -- .../shiro/AccessInfoFactoryImplTest.java | 6 +- .../access/shiro/AccessInfoQueryImplTest.java | 45 -- .../AccessPermissionFactoryImplTest.java | 8 - .../shiro/AccessPermissionQueryImplTest.java | 48 -- .../shiro/AccessRoleFactoryImplTest.java | 13 - .../access/shiro/AccessRoleQueryImplTest.java | 40 -- .../domain/shiro/DomainFactoryImplTest.java | 17 - .../domain/shiro/DomainQueryImplTest.java | 42 -- .../group/shiro/GroupFactoryImplTest.java | 13 - .../group/shiro/GroupQueryImplTest.java | 40 -- .../role/shiro/RoleFactoryImplTest.java | 13 - .../shiro/RolePermissionQueryImplTest.java | 44 -- .../role/shiro/RoleQueryImplTest.java | 44 -- .../steps/AuthorizationServiceSteps.java | 69 ++- .../test/SecurityLocatorConfiguration.java | 25 +- .../test/SystemInfoLocatorConfiguration.java | 24 +- .../eclipse/kapua/service/tag/TagFactory.java | 2 +- .../kapua/service/tag/TagMatchPredicate.java | 21 +- .../eclipse/kapua/service/tag/TagQuery.java | 33 +- .../kapua/service/tag/TagXmlRegistry.java | 2 +- .../service/tag/internal/TagFactoryImpl.java | 6 - .../tag/internal/TagMatchPredicateImpl.java | 35 -- .../service/tag/internal/TagQueryImpl.java | 42 -- .../service/tag/steps/TagServiceSteps.java | 40 +- .../tag/test/TagLocatorConfiguration.java | 29 +- .../kapua/service/user/UserFactory.java | 2 +- .../service/user/UserMatchPredicate.java | 24 +- .../eclipse/kapua/service/user/UserQuery.java | 41 +- .../kapua/service/user/UserXmlRegistry.java | 2 +- .../user/internal/UserFactoryImpl.java | 6 - .../user/internal/UserMatchPredicateImpl.java | 42 -- .../service/user/internal/UserQueryImpl.java | 50 -- .../user/internal/UserServiceImpl.java | 11 +- .../service/user/steps/UserServiceSteps.java | 129 ++--- .../user/test/UserLocatorConfiguration.java | 4 - 389 files changed, 4945 insertions(+), 7402 deletions(-) delete mode 100644 commons/src/main/java/org/eclipse/kapua/commons/configuration/ServiceConfigQuery.java delete mode 100644 commons/src/main/java/org/eclipse/kapua/commons/configuration/ServiceConfigQueryImpl.java delete mode 100644 commons/src/main/java/org/eclipse/kapua/commons/model/query/AbstractKapuaForwardableEntityQuery.java delete mode 100644 commons/src/main/java/org/eclipse/kapua/commons/model/query/AbstractKapuaQuery.java delete mode 100644 commons/src/main/java/org/eclipse/kapua/commons/model/query/FieldSortCriteriaImpl.java delete mode 100644 commons/src/main/java/org/eclipse/kapua/commons/model/query/QueryFactoryImpl.java delete mode 100644 commons/src/main/java/org/eclipse/kapua/commons/model/query/predicate/AndPredicateImpl.java delete mode 100644 commons/src/main/java/org/eclipse/kapua/commons/model/query/predicate/AttributePredicateImpl.java delete mode 100644 commons/src/main/java/org/eclipse/kapua/commons/model/query/predicate/OrPredicateImpl.java delete mode 100644 commons/src/main/java/org/eclipse/kapua/commons/service/event/store/internal/EventStoreQueryImpl.java delete mode 100644 commons/src/test/java/org/eclipse/kapua/commons/configuration/ServiceConfigQueryImplTest.java rename commons/src/test/java/org/eclipse/kapua/commons/model/query/{FieldSortCriteriaImplTest.java => FieldSortCriteriaTest.java} (64%) rename commons/src/test/java/org/eclipse/kapua/commons/model/query/{AbstractKapuaQueryTest.java => KapuaQueryTest.java} (70%) rename commons/src/test/java/org/eclipse/kapua/commons/model/query/predicate/{AndPredicateImplTest.java => AndPredicateTest.java} (68%) rename commons/src/test/java/org/eclipse/kapua/commons/model/query/predicate/{AttributePredicateImplTest.java => AttributePredicateTest.java} (64%) rename commons/src/test/java/org/eclipse/kapua/commons/model/query/predicate/{OrPredicateImplTest.java => OrPredicateTest.java} (68%) delete mode 100644 commons/src/test/java/org/eclipse/kapua/commons/service/event/store/internal/EventStoreQueryImplTest.java delete mode 100644 extras/encryption-migrator/src/main/java/org/eclipse/kapua/extras/migrator/encryption/authentication/MfaOptionMigratorQueryImpl.java delete mode 100644 extras/encryption-migrator/src/main/java/org/eclipse/kapua/extras/migrator/encryption/job/JobStepMigratorQueryImpl.java delete mode 100644 job-engine/api/src/main/java/org/eclipse/kapua/job/engine/queue/QueuedJobExecutionQuery.java delete mode 100644 job-engine/jbatch/src/main/java/org/eclipse/kapua/job/engine/queue/jbatch/QueuedJobExecutionQueryImpl.java delete mode 100644 service/account/api/src/main/java/org/eclipse/kapua/service/account/AccountQuery.java delete mode 100644 service/account/internal/src/main/java/org/eclipse/kapua/service/account/internal/AccountQueryImpl.java rename {commons/src/main/java/org/eclipse/kapua/commons => service/api/src/main/java/org/eclipse/kapua}/model/query/AbstractKapuaNamedQuery.java (78%) delete mode 100644 service/api/src/main/java/org/eclipse/kapua/model/query/QueryFactory.java rename {commons/src/main/java/org/eclipse/kapua/commons => service/api/src/main/java/org/eclipse/kapua}/model/query/predicate/AbstractMatchPredicate.java (88%) delete mode 100644 service/device/management/job/api/src/main/java/org/eclipse/kapua/service/device/management/job/JobDeviceManagementOperationQuery.java delete mode 100644 service/device/management/job/internal/src/main/java/org/eclipse/kapua/service/device/management/job/internal/JobDeviceManagementOperationQueryImpl.java delete mode 100644 service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/internal/DeviceManagementOperationQueryImpl.java delete mode 100644 service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/internal/ManagementOperationNotificationQueryImpl.java delete mode 100644 service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/DeviceConnectionOptionQuery.java delete mode 100644 service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/internal/DeviceConnectionQueryImpl.java delete mode 100644 service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/internal/DeviceConnectionOptionQueryImpl.java delete mode 100644 service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/event/internal/DeviceEventQueryImpl.java delete mode 100644 service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/internal/DeviceMatchPredicateImpl.java delete mode 100644 service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/internal/DeviceQueryImpl.java delete mode 100644 service/endpoint/internal/src/main/java/org/eclipse/kapua/service/endpoint/internal/EndpointInfoMatchPredicateImpl.java delete mode 100644 service/endpoint/internal/src/main/java/org/eclipse/kapua/service/endpoint/internal/EndpointInfoQueryImpl.java delete mode 100644 service/job/api/src/main/java/org/eclipse/kapua/service/job/step/JobStepQuery.java delete mode 100644 service/job/api/src/main/java/org/eclipse/kapua/service/job/targets/JobTargetQuery.java delete mode 100644 service/job/internal/src/main/java/org/eclipse/kapua/service/job/execution/internal/JobExecutionQueryImpl.java delete mode 100644 service/job/internal/src/main/java/org/eclipse/kapua/service/job/internal/JobMatchPredicateImpl.java delete mode 100644 service/job/internal/src/main/java/org/eclipse/kapua/service/job/internal/JobQueryImpl.java delete mode 100644 service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/definition/internal/JobStepDefinitionQueryImpl.java delete mode 100644 service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/internal/JobStepQueryImpl.java delete mode 100644 service/job/internal/src/main/java/org/eclipse/kapua/service/job/targets/internal/JobTargetQueryImpl.java delete mode 100644 service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/TriggerQuery.java delete mode 100644 service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/fired/FiredTriggerQuery.java delete mode 100644 service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/definition/quartz/TriggerDefinitionQueryImpl.java delete mode 100644 service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/fired/quartz/FiredTriggerQueryImpl.java delete mode 100644 service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/quartz/TriggerQueryImpl.java delete mode 100644 service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/credential/CredentialQuery.java delete mode 100644 service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/MfaOptionQuery.java delete mode 100644 service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/token/AccessTokenQuery.java delete mode 100644 service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessInfoQuery.java delete mode 100644 service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessPermissionQuery.java delete mode 100644 service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessRoleQuery.java delete mode 100644 service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/domain/DomainQuery.java delete mode 100644 service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/domain/DomainXmlRegistry.java delete mode 100644 service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RolePermissionQuery.java delete mode 100644 service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/info/internal/CertificateInfoMatchPredicateImpl.java delete mode 100644 service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/info/internal/CertificateInfoQueryImpl.java delete mode 100644 service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/internal/CertificateQueryImpl.java delete mode 100644 service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionQueryImpl.java delete mode 100644 service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialQueryImpl.java delete mode 100644 service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/token/shiro/AccessTokenQueryImpl.java delete mode 100644 service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoQueryImpl.java delete mode 100644 service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionQueryImpl.java delete mode 100644 service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessRoleQueryImpl.java delete mode 100644 service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/domain/shiro/DomainQueryImpl.java delete mode 100644 service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/group/shiro/GroupMatchPredicateImpl.java delete mode 100644 service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/group/shiro/GroupQueryImpl.java delete mode 100644 service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RoleMatchPredicateImpl.java delete mode 100644 service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RolePermissionQueryImpl.java delete mode 100644 service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RoleQueryImpl.java delete mode 100644 service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionQueryImplTest.java delete mode 100644 service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialQueryImplTest.java delete mode 100644 service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/token/shiro/AccessTokenQueryImplTest.java delete mode 100644 service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoQueryImplTest.java delete mode 100644 service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionQueryImplTest.java delete mode 100644 service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessRoleQueryImplTest.java delete mode 100644 service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/domain/shiro/DomainQueryImplTest.java delete mode 100644 service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/group/shiro/GroupQueryImplTest.java delete mode 100644 service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/role/shiro/RolePermissionQueryImplTest.java delete mode 100644 service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/role/shiro/RoleQueryImplTest.java delete mode 100644 service/tag/internal/src/main/java/org/eclipse/kapua/service/tag/internal/TagMatchPredicateImpl.java delete mode 100644 service/tag/internal/src/main/java/org/eclipse/kapua/service/tag/internal/TagQueryImpl.java delete mode 100644 service/user/internal/src/main/java/org/eclipse/kapua/service/user/internal/UserMatchPredicateImpl.java delete mode 100644 service/user/internal/src/main/java/org/eclipse/kapua/service/user/internal/UserQueryImpl.java diff --git a/commons-rest/filters/src/main/java/org/eclipse/kapua/commons/rest/filters/CORSResponseFilter.java b/commons-rest/filters/src/main/java/org/eclipse/kapua/commons/rest/filters/CORSResponseFilter.java index 83bc0c0b3dc..b12fc9687e4 100644 --- a/commons-rest/filters/src/main/java/org/eclipse/kapua/commons/rest/filters/CORSResponseFilter.java +++ b/commons-rest/filters/src/main/java/org/eclipse/kapua/commons/rest/filters/CORSResponseFilter.java @@ -12,10 +12,25 @@ *******************************************************************************/ package org.eclipse.kapua.commons.rest.filters; -import com.google.common.base.Strings; -import com.google.common.collect.HashMultimap; -import com.google.common.collect.Multimap; -import com.google.common.net.HttpHeaders; +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.Collection; +import java.util.List; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ScheduledFuture; +import java.util.concurrent.TimeUnit; + +import javax.servlet.Filter; +import javax.servlet.FilterChain; +import javax.servlet.FilterConfig; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + import org.apache.shiro.web.util.WebUtils; import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.commons.rest.filters.settings.KapuaRestFiltersSetting; @@ -23,9 +38,9 @@ import org.eclipse.kapua.commons.security.KapuaSecurityUtils; import org.eclipse.kapua.locator.KapuaLocator; import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.model.query.KapuaQuery; import org.eclipse.kapua.service.account.AccountFactory; import org.eclipse.kapua.service.account.AccountListResult; -import org.eclipse.kapua.service.account.AccountQuery; import org.eclipse.kapua.service.account.AccountService; import org.eclipse.kapua.service.endpoint.EndpointInfo; import org.eclipse.kapua.service.endpoint.EndpointInfoFactory; @@ -35,23 +50,10 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.servlet.Filter; -import javax.servlet.FilterChain; -import javax.servlet.FilterConfig; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.Collection; -import java.util.List; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ScheduledFuture; -import java.util.concurrent.TimeUnit; +import com.google.common.base.Strings; +import com.google.common.collect.HashMultimap; +import com.google.common.collect.Multimap; +import com.google.common.net.HttpHeaders; /** * CORS {@link Filter} implementation. @@ -107,7 +109,8 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha String errorMessage = null; if (Strings.isNullOrEmpty(fetchSite)) { - logger.warn("Sec-Fetch-Site' header not present in request: {} {}. CORSResponseFilter may produce false positives for this request. User-Agent is: {}", httpRequest.getMethod(), httpRequest.getPathInfo(), httpRequest.getHeader(HttpHeaders.USER_AGENT)); + logger.warn("Sec-Fetch-Site' header not present in request: {} {}. CORSResponseFilter may produce false positives for this request. User-Agent is: {}", httpRequest.getMethod(), + httpRequest.getPathInfo(), httpRequest.getHeader(HttpHeaders.USER_AGENT)); } if (Strings.isNullOrEmpty(origin)) { logger.warn("'Origin' header not present in request: {} {}. User-Agent is: {}", httpRequest.getMethod(), httpRequest.getPathInfo(), httpRequest.getHeader(HttpHeaders.USER_AGENT)); @@ -130,7 +133,8 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha logger.error(errorMessage); } } else { - logger.debug("HTTP sec-fetch-site same-origin detected and allowed. Request: {} {}. User-Agent is: {}", httpRequest.getMethod(), httpRequest.getPathInfo(), httpRequest.getHeader(HttpHeaders.USER_AGENT)); + logger.debug("HTTP sec-fetch-site same-origin detected and allowed. Request: {} {}. User-Agent is: {}", httpRequest.getMethod(), httpRequest.getPathInfo(), + httpRequest.getHeader(HttpHeaders.USER_AGENT)); } } int errorCode = httpResponse.getStatus(); @@ -152,12 +156,12 @@ private String getExplicitOrigin(String origin) throws MalformedURLException { } switch (originUrl.getProtocol()) { - case "http": - return origin + ":80"; - case "https": - return origin + ":443"; - default: - return origin; + case "http": + return origin + ":80"; + case "https": + return origin + ":443"; + default: + return origin; } } @@ -191,7 +195,7 @@ private synchronized void refreshOrigins() { logger.info("Refreshing list of origins..."); Multimap newAllowedOrigins = HashMultimap.create(); - AccountQuery accounts = accountFactory.newQuery(null); + final KapuaQuery accounts = new KapuaQuery((KapuaId) null); AccountListResult accountListResult = KapuaSecurityUtils.doPrivileged(() -> accountService.query(accounts)); accountListResult.getItems().forEach(account -> { EndpointInfoQuery endpointInfoQuery = endpointInfoFactory.newQuery(account.getId()); diff --git a/commons/src/main/java/org/eclipse/kapua/commons/CommonsModule.java b/commons/src/main/java/org/eclipse/kapua/commons/CommonsModule.java index 215ad405a8f..f5534b0a241 100644 --- a/commons/src/main/java/org/eclipse/kapua/commons/CommonsModule.java +++ b/commons/src/main/java/org/eclipse/kapua/commons/CommonsModule.java @@ -32,7 +32,6 @@ import org.eclipse.kapua.commons.model.domains.Domains; import org.eclipse.kapua.commons.model.mappers.KapuaBaseMapper; import org.eclipse.kapua.commons.model.mappers.KapuaBaseMapperImpl; -import org.eclipse.kapua.commons.model.query.QueryFactoryImpl; import org.eclipse.kapua.commons.service.event.store.api.EventStoreRecordCreator; import org.eclipse.kapua.commons.service.event.store.api.EventStoreRecordRepository; import org.eclipse.kapua.commons.service.event.store.api.EventStoreService; @@ -48,7 +47,6 @@ import org.eclipse.kapua.model.domain.Actions; import org.eclipse.kapua.model.domain.Domain; import org.eclipse.kapua.model.domain.DomainEntry; -import org.eclipse.kapua.model.query.QueryFactory; import com.google.inject.Provides; import com.google.inject.multibindings.Multibinder; @@ -63,7 +61,6 @@ public class CommonsModule extends AbstractKapuaModule { @Override protected void configureModule() { - bind(QueryFactory.class).to(QueryFactoryImpl.class).in(Singleton.class); bind(CryptoSettings.class).toInstance(new CryptoSettings()); bind(CryptoUtil.class).to(CryptoUtilImpl.class).in(Singleton.class); bind(QRCodeBuilder.class).to(QRCodeBuilderImpl.class).in(Singleton.class); diff --git a/commons/src/main/java/org/eclipse/kapua/commons/configuration/AbstractKapuaConfigurableResourceLimitedService.java b/commons/src/main/java/org/eclipse/kapua/commons/configuration/AbstractKapuaConfigurableResourceLimitedService.java index 5129b904874..be11fe15047 100644 --- a/commons/src/main/java/org/eclipse/kapua/commons/configuration/AbstractKapuaConfigurableResourceLimitedService.java +++ b/commons/src/main/java/org/eclipse/kapua/commons/configuration/AbstractKapuaConfigurableResourceLimitedService.java @@ -54,8 +54,6 @@ * The {@link KapuaEntityCreator} type. * @param * The {@link KapuaEntityService} type. - * @param - * The {@link KapuaQuery} type. * @param * The {@link KapuaEntityFactory} type. * @since 1.0.0 @@ -66,8 +64,7 @@ public abstract class AbstractKapuaConfigurableResourceLimitedService< E extends KapuaEntity, C extends KapuaEntityCreator, S extends KapuaEntityService, - Q extends KapuaQuery, - F extends KapuaEntityFactory + F extends KapuaEntityFactory > extends AbstractKapuaConfigurableService implements KapuaEntityService { @@ -82,7 +79,7 @@ public abstract class AbstractKapuaConfigurableResourceLimitedService< * Constructor. * * @param pid - * The {@link KapuaConfigurableService} id. + * The {@link KapuaConfigurableService} id.KapuaEntit * @param domain * The {@link Domain} on which check access. * @param entityManagerFactory @@ -267,7 +264,7 @@ private long allowedChildEntities(KapuaId scopeId, KapuaId targetScopeId, Map { - Q countQuery = getFactory().newQuery(scopeId); + KapuaQuery countQuery = new KapuaQuery(scopeId); // Current used entities long currentUsedEntities = this.count(countQuery); diff --git a/commons/src/main/java/org/eclipse/kapua/commons/configuration/AbstractKapuaConfigurableService.java b/commons/src/main/java/org/eclipse/kapua/commons/configuration/AbstractKapuaConfigurableService.java index 3ea4dda4a94..da5af63e3c1 100644 --- a/commons/src/main/java/org/eclipse/kapua/commons/configuration/AbstractKapuaConfigurableService.java +++ b/commons/src/main/java/org/eclipse/kapua/commons/configuration/AbstractKapuaConfigurableService.java @@ -59,6 +59,7 @@ import org.eclipse.kapua.model.domain.Actions; import org.eclipse.kapua.model.domain.Domain; import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.model.query.KapuaQuery; import org.eclipse.kapua.service.account.Account; import org.eclipse.kapua.service.authorization.AuthorizationService; import org.eclipse.kapua.service.authorization.permission.PermissionFactory; @@ -527,7 +528,7 @@ protected Map getConfigValues(KapuaId scopeId, boolean excludeDi // Check access getAuthorizationService().checkPermission(getPermissionFactory().newPermission(Optional.ofNullable(domain).map(d -> d.getName()).orElse(null), Actions.read, scopeId)); // Get configuration values - ServiceConfigQueryImpl query = new ServiceConfigQueryImpl(scopeId); + KapuaQuery query = new KapuaQuery(scopeId); query.setPredicate( query.andPredicate( @@ -583,7 +584,7 @@ public void setConfigValues(KapuaId scopeId, KapuaId parentId, Map, L extends KapuaListResult, Q extends KapuaQuery, - F extends KapuaEntityFactory + F extends KapuaEntityFactory > implements UsedEntitiesCounter { private final F factory; @@ -42,7 +42,7 @@ public UsedEntitiesCounterImpl(F factory, @Override public long countEntitiesInScope(TxContext tx, KapuaId scopeId) throws KapuaException { - final Q query = factory.newQuery(scopeId); + final KapuaQuery query = new KapuaQuery(scopeId); // Do count return entityRepository.count(tx, query); } diff --git a/commons/src/main/java/org/eclipse/kapua/commons/event/ServiceEventHousekeeper.java b/commons/src/main/java/org/eclipse/kapua/commons/event/ServiceEventHousekeeper.java index b6b6363879e..4ad90d127fc 100644 --- a/commons/src/main/java/org/eclipse/kapua/commons/event/ServiceEventHousekeeper.java +++ b/commons/src/main/java/org/eclipse/kapua/commons/event/ServiceEventHousekeeper.java @@ -12,6 +12,11 @@ *******************************************************************************/ package org.eclipse.kapua.commons.event; +import java.time.Duration; +import java.time.temporal.ChronoUnit; +import java.util.Date; +import java.util.List; + import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.commons.jpa.EntityManager; import org.eclipse.kapua.commons.jpa.EntityManagerFactory; @@ -22,7 +27,6 @@ import org.eclipse.kapua.commons.service.event.store.api.EventStoreRecordQuery; import org.eclipse.kapua.commons.service.event.store.api.EventStoreService; import org.eclipse.kapua.commons.service.event.store.api.ServiceEventUtil; -import org.eclipse.kapua.commons.service.event.store.internal.EventStoreFactoryImpl; import org.eclipse.kapua.commons.setting.system.SystemSetting; import org.eclipse.kapua.commons.setting.system.SystemSettingKey; import org.eclipse.kapua.commons.util.KapuaDateUtils; @@ -35,11 +39,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.time.Duration; -import java.time.temporal.ChronoUnit; -import java.util.Date; -import java.util.List; - /** * Event bus housekeeper. It is responsible to send unsent messages or send again messages gone in error. * @@ -78,7 +77,8 @@ private enum EventsProcessType { * @param servicesEntryList * @throws KapuaException */ - public ServiceEventHousekeeper(EventStoreService eventStoreService, EntityManagerFactory entityManagerFactory, ServiceEventBus eventbus, List servicesEntryList) throws KapuaException { + public ServiceEventHousekeeper(EventStoreService eventStoreService, EntityManagerFactory entityManagerFactory, ServiceEventBus eventbus, List servicesEntryList) + throws KapuaException { this.eventbus = eventbus; this.servicesEntryList = servicesEntryList; manager = entityManagerFactory.createEntityManager(); @@ -161,7 +161,7 @@ private void findAndSendUnsentEvents(String serviceName, EventsProcessType event } private EventStoreRecordListResult getUnsentEvents(String serviceName, EventsProcessType eventsProcessType) throws KapuaException { - EventStoreRecordQuery query = new EventStoreFactoryImpl().newQuery(null); + EventStoreRecordQuery query = new EventStoreRecordQuery(null); AndPredicate andPredicate = query.andPredicate(); andPredicate.and(query.attributePredicate(EventStoreRecordAttributes.SERVICE_NAME, serviceName)); diff --git a/commons/src/main/java/org/eclipse/kapua/commons/event/ServiceEventTransactionalHousekeeper.java b/commons/src/main/java/org/eclipse/kapua/commons/event/ServiceEventTransactionalHousekeeper.java index 3895e025656..048b37ea1d4 100644 --- a/commons/src/main/java/org/eclipse/kapua/commons/event/ServiceEventTransactionalHousekeeper.java +++ b/commons/src/main/java/org/eclipse/kapua/commons/event/ServiceEventTransactionalHousekeeper.java @@ -12,6 +12,14 @@ *******************************************************************************/ package org.eclipse.kapua.commons.event; +import java.time.Duration; +import java.time.temporal.ChronoUnit; +import java.util.Date; +import java.util.List; + +import javax.persistence.EntityManager; +import javax.persistence.LockModeType; + import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.commons.jpa.JpaAwareTxContext; import org.eclipse.kapua.commons.security.KapuaSecurityUtils; @@ -21,7 +29,6 @@ import org.eclipse.kapua.commons.service.event.store.api.EventStoreRecordQuery; import org.eclipse.kapua.commons.service.event.store.api.EventStoreService; import org.eclipse.kapua.commons.service.event.store.api.ServiceEventUtil; -import org.eclipse.kapua.commons.service.event.store.internal.EventStoreFactoryImpl; import org.eclipse.kapua.commons.setting.system.SystemSetting; import org.eclipse.kapua.commons.setting.system.SystemSettingKey; import org.eclipse.kapua.commons.util.KapuaDateUtils; @@ -36,13 +43,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.persistence.EntityManager; -import javax.persistence.LockModeType; -import java.time.Duration; -import java.time.temporal.ChronoUnit; -import java.util.Date; -import java.util.List; - /** * Event bus housekeeper. It is responsible to send unsent messages or send again messages gone in error. * @@ -156,7 +156,7 @@ private void findAndSendUnsentEvents(String serviceName, EventsProcessType event } private EventStoreRecordListResult getUnsentEvents(String serviceName, EventsProcessType eventsProcessType) throws KapuaException { - EventStoreRecordQuery query = new EventStoreFactoryImpl().newQuery(null); + EventStoreRecordQuery query = new EventStoreRecordQuery(null); AndPredicate andPredicate = query.andPredicate(); andPredicate.and(query.attributePredicate(EventStoreRecordAttributes.SERVICE_NAME, serviceName)); diff --git a/commons/src/main/java/org/eclipse/kapua/commons/jpa/KapuaEntityJpaRepository.java b/commons/src/main/java/org/eclipse/kapua/commons/jpa/KapuaEntityJpaRepository.java index 429bef059b9..65fa4a44808 100644 --- a/commons/src/main/java/org/eclipse/kapua/commons/jpa/KapuaEntityJpaRepository.java +++ b/commons/src/main/java/org/eclipse/kapua/commons/jpa/KapuaEntityJpaRepository.java @@ -48,8 +48,6 @@ import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.commons.model.AbstractKapuaEntity_; import org.eclipse.kapua.commons.model.id.KapuaEid; -import org.eclipse.kapua.commons.model.query.predicate.AttributePredicateImpl; -import org.eclipse.kapua.commons.model.query.predicate.OrPredicateImpl; import org.eclipse.kapua.model.KapuaEntity; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.model.query.FieldSortCriteria; @@ -373,9 +371,9 @@ private Predicate handleKapuaQueryPredicates(@NonNull QueryPredicate queryPr predicate = handleOrPredicate(orPredicate, binds, cb, userPermissionRoot, entityType); } else if (queryPredicate instanceof MatchPredicate) { MatchPredicate matchPredicate = (MatchPredicate) queryPredicate; - OrPredicate orPredicate = new OrPredicateImpl(); + OrPredicate orPredicate = new OrPredicate(); for (String attributeName : matchPredicate.getAttributeNames()) { - orPredicate.getPredicates().add(new AttributePredicateImpl<>(attributeName, matchPredicate.getMatchTerm(), AttributePredicate.Operator.STARTS_WITH_IGNORE_CASE)); + orPredicate.getPredicates().add(new AttributePredicate<>(attributeName, matchPredicate.getMatchTerm(), AttributePredicate.Operator.STARTS_WITH_IGNORE_CASE)); } predicate = handleOrPredicate(orPredicate, binds, cb, userPermissionRoot, entityType); } diff --git a/commons/src/main/java/org/eclipse/kapua/commons/model/query/AbstractKapuaForwardableEntityQuery.java b/commons/src/main/java/org/eclipse/kapua/commons/model/query/AbstractKapuaForwardableEntityQuery.java deleted file mode 100644 index 40b0954c96c..00000000000 --- a/commons/src/main/java/org/eclipse/kapua/commons/model/query/AbstractKapuaForwardableEntityQuery.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2024, 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.model.query; - -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.model.query.KapuaForwardableEntityQuery; -import org.eclipse.kapua.model.query.KapuaQuery; - -public class AbstractKapuaForwardableEntityQuery extends AbstractKapuaNamedQuery implements KapuaForwardableEntityQuery { - - protected Boolean includeInherited = Boolean.FALSE; - - /** - * Constructor. - * - */ - public AbstractKapuaForwardableEntityQuery() { - super(); - } - - /** - * Constructor. - * - * @param scopeId The {@link #getScopeId()}. - */ - public AbstractKapuaForwardableEntityQuery(KapuaId scopeId) { - super(scopeId); - } - - /** - * Clone constructor. - * - * @param query The {@link AbstractKapuaForwardableEntityQuery} to clone. - */ - public AbstractKapuaForwardableEntityQuery(KapuaQuery query) { - super(query); - if(query instanceof KapuaForwardableEntityQuery) { - this.includeInherited = ((KapuaForwardableEntityQuery) query).getIncludeInherited(); - } - } - - @Override - public Boolean getIncludeInherited() { - return includeInherited; - } - - @Override - public void setIncludeInherited(Boolean includeInherited) { - this.includeInherited = includeInherited; - } -} diff --git a/commons/src/main/java/org/eclipse/kapua/commons/model/query/AbstractKapuaQuery.java b/commons/src/main/java/org/eclipse/kapua/commons/model/query/AbstractKapuaQuery.java deleted file mode 100644 index bcbb7588a10..00000000000 --- a/commons/src/main/java/org/eclipse/kapua/commons/model/query/AbstractKapuaQuery.java +++ /dev/null @@ -1,206 +0,0 @@ -/******************************************************************************* - * 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.model.query; - -import org.eclipse.kapua.commons.model.id.KapuaEid; -import org.eclipse.kapua.commons.model.query.predicate.AndPredicateImpl; -import org.eclipse.kapua.commons.model.query.predicate.AttributePredicateImpl; -import org.eclipse.kapua.commons.model.query.predicate.OrPredicateImpl; -import org.eclipse.kapua.model.KapuaEntityAttributes; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.model.query.FieldSortCriteria; -import org.eclipse.kapua.model.query.KapuaQuery; -import org.eclipse.kapua.model.query.KapuaSortCriteria; -import org.eclipse.kapua.model.query.SortOrder; -import org.eclipse.kapua.model.query.predicate.AndPredicate; -import org.eclipse.kapua.model.query.predicate.AttributePredicate; -import org.eclipse.kapua.model.query.predicate.OrPredicate; -import org.eclipse.kapua.model.query.predicate.QueryPredicate; - -import javax.validation.constraints.NotNull; -import java.util.ArrayList; -import java.util.List; - -/** - * {@link KapuaQuery} {@code abstract} implementation. - * - * @since 1.0.0 - */ -public abstract class AbstractKapuaQuery implements KapuaQuery { - - private KapuaId scopeId; - - private QueryPredicate predicate; - private KapuaSortCriteria sortCriteria; - private List fetchAttributes; - - private Integer offset; - private Integer limit; - private Boolean askTotalCount; - - /** - * Constructor. - * - * @since 1.0.0 - */ - public AbstractKapuaQuery() { - } - - /** - * Constructor. - * - * @param scopeId The scope {@link KapuaId} of the {@link KapuaQuery} - * @since 1.0.0 - */ - public AbstractKapuaQuery(KapuaId scopeId) { - this(); - - setScopeId(scopeId); - } - - /** - * Constructor. - *

    - * It deeply clones the given {@link KapuaQuery} - * - * @param query the query to clone. - */ - public AbstractKapuaQuery(@NotNull KapuaQuery query) { - setFetchAttributes(query.getFetchAttributes()); - setPredicate(query.getPredicate()); - setLimit(query.getLimit()); - setOffset(query.getOffset()); - setSortCriteria(query.getSortCriteria()); - setAskTotalCount(query.getAskTotalCount()); - } - - @Override - public KapuaId getScopeId() { - return scopeId; - } - - @Override - public void setScopeId(KapuaId scopeId) { - this.scopeId = KapuaEid.parseKapuaId(scopeId); - } - - @Override - public void addFetchAttributes(String fetchAttribute) { - getFetchAttributes().add(fetchAttribute); - } - - @Override - public List getFetchAttributes() { - if (fetchAttributes == null) { - fetchAttributes = new ArrayList<>(); - } - - return fetchAttributes; - } - - @Override - public void setFetchAttributes(List fetchAttributes) { - this.fetchAttributes = fetchAttributes; - } - - @Override - public QueryPredicate getPredicate() { - return this.predicate; - } - - @Override - public void setPredicate(QueryPredicate queryPredicate) { - this.predicate = queryPredicate; - } - - @Override - public KapuaSortCriteria getSortCriteria() { - return sortCriteria; - } - - @Override - public void setSortCriteria(KapuaSortCriteria sortCriteria) { - this.sortCriteria = sortCriteria; - } - - @Override - public KapuaSortCriteria getDefaultSortCriteria() { - return fieldSortCriteria(KapuaEntityAttributes.ENTITY_ID, SortOrder.ASCENDING); - } - - @Override - public Integer getOffset() { - return offset; - } - - @Override - public void setOffset(Integer offset) { - this.offset = offset; - } - - @Override - public Integer getLimit() { - return limit; - } - - @Override - public void setLimit(Integer limit) { - this.limit = limit; - } - - @Override - public Boolean getAskTotalCount() { - return askTotalCount; - } - - @Override - public void setAskTotalCount(Boolean askTotalCount) { - this.askTotalCount = askTotalCount; - } - - // Predicate factory - @Override - public AttributePredicate attributePredicate(String attributeName, T attributeValue) { - return new AttributePredicateImpl<>(attributeName, attributeValue); - } - - @Override - public AttributePredicate attributePredicate(String attributeName, T attributeValue, AttributePredicate.Operator operator) { - return new AttributePredicateImpl<>(attributeName, attributeValue, operator); - } - - @Override - public AndPredicate andPredicate() { - return new AndPredicateImpl(); - } - - @Override - public AndPredicate andPredicate(QueryPredicate... queryPredicates) { - return new AndPredicateImpl(queryPredicates); - } - - @Override - public OrPredicate orPredicate() { - return new OrPredicateImpl(); - } - - @Override - public OrPredicate orPredicate(QueryPredicate... queryPredicates) { - return new OrPredicateImpl(queryPredicates); - } - - @Override - public FieldSortCriteria fieldSortCriteria(String attributeName, SortOrder sortOrder) { - return new FieldSortCriteriaImpl(attributeName, sortOrder); - } -} diff --git a/commons/src/main/java/org/eclipse/kapua/commons/model/query/FieldSortCriteriaImpl.java b/commons/src/main/java/org/eclipse/kapua/commons/model/query/FieldSortCriteriaImpl.java deleted file mode 100644 index b5f08a94f84..00000000000 --- a/commons/src/main/java/org/eclipse/kapua/commons/model/query/FieldSortCriteriaImpl.java +++ /dev/null @@ -1,66 +0,0 @@ -/******************************************************************************* - * 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.model.query; - -import org.eclipse.kapua.model.query.FieldSortCriteria; -import org.eclipse.kapua.model.query.SortOrder; - -/** - * Field sort criteria. - * - * @since 1.0 - * - */ -public class FieldSortCriteriaImpl implements FieldSortCriteria { - - /** - * Field attribute name - */ - private String attributeName; - - /** - * Field sort order - */ - private SortOrder sortOrder; - - /** - * Constructor - * - * @param attributeName - * @param sortOrder - */ - public FieldSortCriteriaImpl(String attributeName, SortOrder sortOrder) { - this.attributeName = attributeName; - this.sortOrder = sortOrder; - } - - /** - * Get the sort attribute name - * - * @return - */ - @Override - public String getAttributeName() { - return attributeName; - } - - /** - * Get the sort attribute order - * - * @return - */ - @Override - public SortOrder getSortOrder() { - return sortOrder; - } -} diff --git a/commons/src/main/java/org/eclipse/kapua/commons/model/query/QueryFactoryImpl.java b/commons/src/main/java/org/eclipse/kapua/commons/model/query/QueryFactoryImpl.java deleted file mode 100644 index ee03bb26e2b..00000000000 --- a/commons/src/main/java/org/eclipse/kapua/commons/model/query/QueryFactoryImpl.java +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2021, 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.model.query; - -import org.eclipse.kapua.model.query.KapuaQuery; -import org.eclipse.kapua.model.query.QueryFactory; - -import javax.inject.Singleton; - -/** - * {@link QueryFactory} implementation. - * - * @since 2.0.0 - */ -@Singleton -public class QueryFactoryImpl implements QueryFactory { - - @Override - public KapuaQuery newQuery() { - return new AbstractKapuaQuery() { - }; - } -} diff --git a/commons/src/main/java/org/eclipse/kapua/commons/model/query/predicate/AndPredicateImpl.java b/commons/src/main/java/org/eclipse/kapua/commons/model/query/predicate/AndPredicateImpl.java deleted file mode 100644 index a07c30cc5a2..00000000000 --- a/commons/src/main/java/org/eclipse/kapua/commons/model/query/predicate/AndPredicateImpl.java +++ /dev/null @@ -1,73 +0,0 @@ -/******************************************************************************* - * 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.model.query.predicate; - -import com.google.common.collect.Lists; -import org.eclipse.kapua.model.query.predicate.AndPredicate; -import org.eclipse.kapua.model.query.predicate.QueryPredicate; - -import javax.validation.constraints.NotNull; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; - -/** - * {@link AndPredicate} implementation. - * - * @since 1.0.0 - */ -public class AndPredicateImpl implements AndPredicate { - - private List predicates; - - /** - * Constructor. - * - * @since 1.0.0 - */ - public AndPredicateImpl() { - setPredicates(new ArrayList<>()); - } - - /** - * Constructor which accepts a not null array of {@link QueryPredicate}s. - * - * @param predicates the {@link QueryPredicate}s to add. - * @throws NullPointerException if the given parameter is {@code null}. - * @since 1.0.0 - */ - public AndPredicateImpl(@NotNull QueryPredicate... predicates) { - Objects.requireNonNull(predicates); - - setPredicates(Lists.newArrayList(predicates)); - } - - @Override - public AndPredicateImpl and(@NotNull QueryPredicate predicate) { - Objects.requireNonNull(predicates); - - getPredicates().add(predicate); - - return this; - } - - @Override - public List getPredicates() { - return this.predicates; - } - - @Override - public void setPredicates(List predicates) { - this.predicates = predicates; - } -} diff --git a/commons/src/main/java/org/eclipse/kapua/commons/model/query/predicate/AttributePredicateImpl.java b/commons/src/main/java/org/eclipse/kapua/commons/model/query/predicate/AttributePredicateImpl.java deleted file mode 100644 index bca11012e26..00000000000 --- a/commons/src/main/java/org/eclipse/kapua/commons/model/query/predicate/AttributePredicateImpl.java +++ /dev/null @@ -1,70 +0,0 @@ -/******************************************************************************* - * 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.model.query.predicate; - -import org.eclipse.kapua.model.query.predicate.AttributePredicate; - -/** - * {@link AttributePredicate} implementation. - * - * @since 1.0.0 - */ -public class AttributePredicateImpl implements AttributePredicate { - - private String attributeName; - private T attributeValue; - private Operator operator; - - /** - * Constructor. - *

    - * Defaults ot {@link org.eclipse.kapua.model.query.predicate.AttributePredicate.Operator#EQUAL} - * - * @param attributeName The name of {@link org.eclipse.kapua.model.KapuaEntityAttributes} to set into the {@link AttributePredicate}. - * @param attributeValue The value of {@link org.eclipse.kapua.model.KapuaEntityAttributes} to set into the {@link AttributePredicate}. - * @since 1.0.0 - */ - public AttributePredicateImpl(String attributeName, T attributeValue) { - this(attributeName, attributeValue, Operator.EQUAL); - } - - /** - * Constructor. - * - * @param attributeName The name of {@link org.eclipse.kapua.model.KapuaEntityAttributes} to set into the {@link AttributePredicate}. - * @param attributeValue The value of {@link org.eclipse.kapua.model.KapuaEntityAttributes} to set into the {@link AttributePredicate}. - * @param operator The {@link org.eclipse.kapua.model.query.predicate.AttributePredicate.Operator} to set into the {@link AttributePredicate}. - * @since 1.0.0 - */ - public AttributePredicateImpl(String attributeName, T attributeValue, Operator operator) { - this.attributeName = attributeName; - this.attributeValue = attributeValue; - this.operator = operator; - } - - @Override - public String getAttributeName() { - return attributeName; - } - - @Override - public T getAttributeValue() { - return attributeValue; - } - - @Override - public Operator getOperator() { - return operator; - } - -} diff --git a/commons/src/main/java/org/eclipse/kapua/commons/model/query/predicate/OrPredicateImpl.java b/commons/src/main/java/org/eclipse/kapua/commons/model/query/predicate/OrPredicateImpl.java deleted file mode 100644 index 579e51c40de..00000000000 --- a/commons/src/main/java/org/eclipse/kapua/commons/model/query/predicate/OrPredicateImpl.java +++ /dev/null @@ -1,73 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2018, 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.model.query.predicate; - -import com.google.common.collect.Lists; -import org.eclipse.kapua.model.query.predicate.OrPredicate; -import org.eclipse.kapua.model.query.predicate.QueryPredicate; - -import javax.validation.constraints.NotNull; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; - -/** - * {@link OrPredicate} implementation. - * - * @since 1.0.0 - */ -public class OrPredicateImpl implements OrPredicate { - - private List predicates; - - /** - * Constructor. - * - * @since 1.0.0 - */ - public OrPredicateImpl() { - setPredicates(new ArrayList<>()); - } - - /** - * Constructor which accepts a not {@code null} array of {@link QueryPredicate}s. - * - * @param predicates the {@link QueryPredicate}s to add. - * @throws NullPointerException if the given parameter is {@code null}. - * @since 1.0.0 - */ - public OrPredicateImpl(@NotNull QueryPredicate... predicates) { - Objects.requireNonNull(predicates); - - setPredicates(Lists.newArrayList(predicates)); - } - - @Override - public OrPredicateImpl or(@NotNull QueryPredicate predicate) { - Objects.requireNonNull(predicates); - - getPredicates().add(predicate); - - return this; - } - - @Override - public List getPredicates() { - return this.predicates; - } - - @Override - public void setPredicates(List predicates) { - this.predicates = predicates; - } -} diff --git a/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/api/EventStoreFactory.java b/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/api/EventStoreFactory.java index 944d14d51db..b08e336761e 100644 --- a/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/api/EventStoreFactory.java +++ b/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/api/EventStoreFactory.java @@ -20,6 +20,6 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface EventStoreFactory extends KapuaEntityFactory { +public interface EventStoreFactory extends KapuaEntityFactory { } diff --git a/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/api/EventStoreRecordQuery.java b/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/api/EventStoreRecordQuery.java index 9f359cf8d18..6f05c3403c3 100644 --- a/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/api/EventStoreRecordQuery.java +++ b/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/api/EventStoreRecordQuery.java @@ -12,13 +12,14 @@ *******************************************************************************/ package org.eclipse.kapua.commons.service.event.store.api; -import org.eclipse.kapua.model.query.KapuaQuery; - import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.model.query.KapuaQuery; + /** * {@link EventStoreRecord} {@link KapuaQuery} definition. * @@ -27,6 +28,27 @@ */ @XmlRootElement(name = "query") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = EventStoreXmlRegistry.class, factoryMethod = "newQuery") -public interface EventStoreRecordQuery extends KapuaQuery { +@XmlType +public class EventStoreRecordQuery extends KapuaQuery { + + /** + * Constructor. + * + * @since 1.0.0 + */ + public EventStoreRecordQuery() { + super(); + } + + /** + * Constructor. + * + * @param scopeId + * The {@link #getScopeId()}. + * @since 1.0.0 + */ + public EventStoreRecordQuery(KapuaId scopeId) { + this(); + setScopeId(scopeId); + } } diff --git a/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/api/EventStoreXmlRegistry.java b/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/api/EventStoreXmlRegistry.java index 0ea0521588e..8969833f06e 100644 --- a/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/api/EventStoreXmlRegistry.java +++ b/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/api/EventStoreXmlRegistry.java @@ -38,9 +38,4 @@ public EventStoreRecord newEventStoreRecord() { public EventStoreRecordCreator newEventStoreRecordCreator() { return kapuaEventFactory.newCreator(null); } - - public EventStoreRecordQuery newQuery() { - return kapuaEventFactory.newQuery(null); - } - } diff --git a/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/internal/EventStoreFactoryImpl.java b/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/internal/EventStoreFactoryImpl.java index c6b25def06f..2c735c60922 100644 --- a/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/internal/EventStoreFactoryImpl.java +++ b/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/internal/EventStoreFactoryImpl.java @@ -18,7 +18,6 @@ import org.eclipse.kapua.commons.service.event.store.api.EventStoreFactory; import org.eclipse.kapua.commons.service.event.store.api.EventStoreRecord; import org.eclipse.kapua.commons.service.event.store.api.EventStoreRecordCreator; -import org.eclipse.kapua.commons.service.event.store.api.EventStoreRecordQuery; import org.eclipse.kapua.model.id.KapuaId; /** @@ -39,11 +38,6 @@ public EventStoreRecordCreator newCreator(KapuaId scopeId) { return new EventStoreRecordCreatorImpl(scopeId); } - @Override - public EventStoreRecordQuery newQuery(KapuaId scopeId) { - return new EventStoreQueryImpl(scopeId); - } - @Override public EventStoreRecord clone(EventStoreRecord eventStoreRecord) { try { diff --git a/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/internal/EventStoreQueryImpl.java b/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/internal/EventStoreQueryImpl.java deleted file mode 100644 index b50c177ccc4..00000000000 --- a/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/internal/EventStoreQueryImpl.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017, 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.service.event.store.internal; - -import org.eclipse.kapua.commons.model.query.AbstractKapuaQuery; -import org.eclipse.kapua.commons.service.event.store.api.EventStoreRecordQuery; -import org.eclipse.kapua.model.id.KapuaId; - -/** - * {@link EventStoreRecordQuery} implementation. - * - * @since 1.0.0 - */ -public class EventStoreQueryImpl extends AbstractKapuaQuery implements EventStoreRecordQuery { - - /** - * Constructor. - * - * @since 1.0.0 - */ - public EventStoreQueryImpl() { - super(); - } - - /** - * Constructor. - * - * @param scopeId The {@link #getScopeId()}. - * @since 1.0.0 - */ - public EventStoreQueryImpl(KapuaId scopeId) { - this(); - setScopeId(scopeId); - } -} diff --git a/commons/src/main/java/org/eclipse/kapua/commons/service/internal/KapuaNamedEntityServiceUtils.java b/commons/src/main/java/org/eclipse/kapua/commons/service/internal/KapuaNamedEntityServiceUtils.java index 47ab5ce0c2a..fc24cd38683 100644 --- a/commons/src/main/java/org/eclipse/kapua/commons/service/internal/KapuaNamedEntityServiceUtils.java +++ b/commons/src/main/java/org/eclipse/kapua/commons/service/internal/KapuaNamedEntityServiceUtils.java @@ -12,6 +12,11 @@ *******************************************************************************/ package org.eclipse.kapua.commons.service.internal; +import java.util.Collections; +import java.util.List; + +import javax.validation.constraints.NotNull; + import org.eclipse.kapua.KapuaDuplicateNameException; import org.eclipse.kapua.KapuaDuplicateNameInAnotherAccountError; import org.eclipse.kapua.KapuaException; @@ -21,16 +26,11 @@ import org.eclipse.kapua.model.KapuaNamedEntityAttributes; import org.eclipse.kapua.model.KapuaNamedEntityCreator; import org.eclipse.kapua.model.query.KapuaQuery; -import org.eclipse.kapua.model.query.QueryFactory; import org.eclipse.kapua.model.query.predicate.AndPredicate; import org.eclipse.kapua.model.query.predicate.AttributePredicate; import org.eclipse.kapua.model.query.predicate.QueryPredicate; import org.eclipse.kapua.service.KapuaEntityService; -import javax.validation.constraints.NotNull; -import java.util.Collections; -import java.util.List; - /** * Util class that offers checks on the {@link KapuaNamedEntity#getName()} uniqueness in different flavors. * @@ -41,7 +41,6 @@ public class KapuaNamedEntityServiceUtils { private static final KapuaLocator LOCATOR = KapuaLocator.getInstance(); - private static final QueryFactory QUERY_FACTORY = LOCATOR.getFactory(QueryFactory.class); /** * Constructor. @@ -56,36 +55,52 @@ private KapuaNamedEntityServiceUtils() { /** * Checks that the given {@link KapuaNamedEntityCreator#getName()} is unique within the {@link KapuaNamedEntityCreator#getScopeId()}. * - * @param kapuaNamedEntityService The {@link KapuaEntityService} to use. Usually it is the same service that is using this utility. - * @param creator The {@link KapuaNamedEntityCreator} to check. - * @param The {@link KapuaNamedEntity} type. - * @param The {@link KapuaNamedEntityCreator} type. - * @throws KapuaDuplicateNameException if the {@link KapuaNamedEntityCreator#getName()} is duplicated within the {@link KapuaNamedEntityCreator#getScopeId()}. - * @throws KapuaException if any other error occurs. + * @param kapuaNamedEntityService + * The {@link KapuaEntityService} to use. Usually it is the same service that is using this utility. + * @param creator + * The {@link KapuaNamedEntityCreator} to check. + * @param + * The {@link KapuaNamedEntity} type. + * @param + * The {@link KapuaNamedEntityCreator} type. + * @throws KapuaDuplicateNameException + * if the {@link KapuaNamedEntityCreator#getName()} is duplicated within the {@link KapuaNamedEntityCreator#getScopeId()}. + * @throws KapuaException + * if any other error occurs. * @since 2.0.0 * @deprecated since 2.0.0 - use {@link org.eclipse.kapua.storage.KapuaNamedEntityRepository} instead */ @Deprecated - public static > void checkEntityNameUniqueness(@NotNull KapuaEntityService kapuaNamedEntityService, @NotNull C creator) throws KapuaException { + public static > void checkEntityNameUniqueness(@NotNull KapuaEntityService kapuaNamedEntityService, @NotNull C creator) + throws KapuaException { checkEntityNameUniqueness(kapuaNamedEntityService, creator, Collections.emptyList()); } /** - * Checks that the given {@link KapuaNamedEntityCreator#getName()} is unique within the {@link KapuaNamedEntityCreator#getScopeId()} with additional {@link QueryPredicate}s to customize the check. + * Checks that the given {@link KapuaNamedEntityCreator#getName()} is unique within the {@link KapuaNamedEntityCreator#getScopeId()} with additional {@link QueryPredicate}s to customize the + * check. * - * @param kapuaNamedEntityService The {@link KapuaEntityService} to use. Usually it is the same service that is using this utility. - * @param creator The {@link KapuaNamedEntityCreator} to check. - * @param additionalPredicates The additional {@link QueryPredicate}s to customize the check - * @param The {@link KapuaNamedEntity} type. - * @param The {@link KapuaNamedEntityCreator} type. - * @throws KapuaDuplicateNameException if the {@link KapuaNamedEntityCreator#getName()} is duplicated within the {@link KapuaNamedEntityCreator#getScopeId()}. - * @throws KapuaException if any other error occurs. + * @param kapuaNamedEntityService + * The {@link KapuaEntityService} to use. Usually it is the same service that is using this utility. + * @param creator + * The {@link KapuaNamedEntityCreator} to check. + * @param additionalPredicates + * The additional {@link QueryPredicate}s to customize the check + * @param + * The {@link KapuaNamedEntity} type. + * @param + * The {@link KapuaNamedEntityCreator} type. + * @throws KapuaDuplicateNameException + * if the {@link KapuaNamedEntityCreator#getName()} is duplicated within the {@link KapuaNamedEntityCreator#getScopeId()}. + * @throws KapuaException + * if any other error occurs. * @since 2.0.0 * @deprecated since 2.0.0 - use {@link org.eclipse.kapua.storage.KapuaNamedEntityRepository} instead */ @Deprecated - public static > void checkEntityNameUniqueness(@NotNull KapuaEntityService kapuaNamedEntityService, @NotNull C creator, @NotNull List additionalPredicates) throws KapuaException { - KapuaQuery query = QUERY_FACTORY.newQuery(); + public static > void checkEntityNameUniqueness(@NotNull KapuaEntityService kapuaNamedEntityService, @NotNull C creator, + @NotNull List additionalPredicates) throws KapuaException { + KapuaQuery query = new KapuaQuery(); query.setScopeId(creator.getScopeId()); AndPredicate andPredicate = query.andPredicate(); @@ -105,11 +120,16 @@ public static > /** * Checks that the given {@link KapuaNamedEntity#getName()} is unique within the {@link KapuaNamedEntity#getScopeId()}. * - * @param kapuaNamedEntityService The {@link KapuaEntityService} to use. Usually it is the same service that is using this utility. - * @param entity The {@link KapuaNamedEntity} to check. - * @param The {@link KapuaNamedEntity} type. - * @throws KapuaDuplicateNameException if the {@link KapuaNamedEntity#getName()} is duplicated within the {@link KapuaNamedEntity#getScopeId()}. - * @throws KapuaException if any other error occurs. + * @param kapuaNamedEntityService + * The {@link KapuaEntityService} to use. Usually it is the same service that is using this utility. + * @param entity + * The {@link KapuaNamedEntity} to check. + * @param + * The {@link KapuaNamedEntity} type. + * @throws KapuaDuplicateNameException + * if the {@link KapuaNamedEntity#getName()} is duplicated within the {@link KapuaNamedEntity#getScopeId()}. + * @throws KapuaException + * if any other error occurs. * @since 2.0.0 * @deprecated since 2.0.0 - use {@link org.eclipse.kapua.storage.KapuaNamedEntityRepository} instead */ @@ -121,18 +141,25 @@ public static void checkEntityNameUniqueness(@NotNu /** * Checks that the given {@link KapuaNamedEntity#getName()} is unique within the {@link KapuaNamedEntity#getScopeId()} with additional {@link QueryPredicate}s to customize the check. * - * @param kapuaNamedEntityService The {@link KapuaEntityService} to use. Usually it is the same service that is using this utility. - * @param entity The {@link KapuaNamedEntity} to check. - * @param additionalPredicates The additional {@link QueryPredicate}s to customize the check - * @param The {@link KapuaNamedEntity} type. - * @throws KapuaDuplicateNameException if the {@link KapuaNamedEntity#getName()} is duplicated within the {@link KapuaNamedEntity#getScopeId()}. - * @throws KapuaException if any other error occurs. + * @param kapuaNamedEntityService + * The {@link KapuaEntityService} to use. Usually it is the same service that is using this utility. + * @param entity + * The {@link KapuaNamedEntity} to check. + * @param additionalPredicates + * The additional {@link QueryPredicate}s to customize the check + * @param + * The {@link KapuaNamedEntity} type. + * @throws KapuaDuplicateNameException + * if the {@link KapuaNamedEntity#getName()} is duplicated within the {@link KapuaNamedEntity#getScopeId()}. + * @throws KapuaException + * if any other error occurs. * @since 2.0.0 * @deprecated since 2.0.0 - use {@link org.eclipse.kapua.storage.KapuaNamedEntityRepository} instead */ @Deprecated - public static void checkEntityNameUniqueness(@NotNull KapuaEntityService kapuaNamedEntityService, @NotNull E entity, @NotNull List additionalPredicates) throws KapuaException { - KapuaQuery query = QUERY_FACTORY.newQuery(); + public static void checkEntityNameUniqueness(@NotNull KapuaEntityService kapuaNamedEntityService, @NotNull E entity, + @NotNull List additionalPredicates) throws KapuaException { + KapuaQuery query = new KapuaQuery(); query.setScopeId(entity.getScopeId()); AndPredicate andPredicate = query.andPredicate(); @@ -153,18 +180,25 @@ public static void checkEntityNameUniqueness(@NotNu /** * Checks that the given {@link KapuaNamedEntityCreator#getName()} is unique within all the scopes. * - * @param kapuaNamedEntityService The {@link KapuaEntityService} to use. Usually it is the same service that is using this utility. - * @param creator The {@link KapuaNamedEntityCreator} to check. - * @param The {@link KapuaNamedEntity} type. - * @param The {@link KapuaNamedEntityCreator} type. - * @throws KapuaDuplicateNameException if the {@link KapuaNamedEntityCreator#getName()} is duplicated within all the scopes - * @throws KapuaException if any other error occurs. + * @param kapuaNamedEntityService + * The {@link KapuaEntityService} to use. Usually it is the same service that is using this utility. + * @param creator + * The {@link KapuaNamedEntityCreator} to check. + * @param + * The {@link KapuaNamedEntity} type. + * @param + * The {@link KapuaNamedEntityCreator} type. + * @throws KapuaDuplicateNameException + * if the {@link KapuaNamedEntityCreator#getName()} is duplicated within all the scopes + * @throws KapuaException + * if any other error occurs. * @since 2.0.0 * @deprecated since 2.0.0 - use {@link org.eclipse.kapua.storage.KapuaNamedEntityRepository} instead */ @Deprecated - public static > void checkEntityNameUniquenessInAllScopes(@NotNull KapuaEntityService kapuaNamedEntityService, @NotNull C creator) throws KapuaException { - KapuaQuery query = QUERY_FACTORY.newQuery(); + public static > void checkEntityNameUniquenessInAllScopes(@NotNull KapuaEntityService kapuaNamedEntityService, + @NotNull C creator) throws KapuaException { + KapuaQuery query = new KapuaQuery(); query.setPredicate(query.attributePredicate(KapuaNamedEntityAttributes.NAME, creator.getName())); if (KapuaSecurityUtils.doPrivileged(() -> kapuaNamedEntityService.count(query) > 0)) { @@ -175,17 +209,22 @@ public static > /** * Checks that the given {@link KapuaNamedEntity#getName()} is unique within all the scopes. * - * @param kapuaNamedEntityService The {@link KapuaEntityService} to use. Usually it is the same service that is using this utility. - * @param entity The {@link KapuaNamedEntity} to check. - * @param The {@link KapuaNamedEntity} type. - * @throws KapuaDuplicateNameException if the {@link KapuaNamedEntity#getName()} is duplicated within all the scopes - * @throws KapuaException if any other error occurs. + * @param kapuaNamedEntityService + * The {@link KapuaEntityService} to use. Usually it is the same service that is using this utility. + * @param entity + * The {@link KapuaNamedEntity} to check. + * @param + * The {@link KapuaNamedEntity} type. + * @throws KapuaDuplicateNameException + * if the {@link KapuaNamedEntity#getName()} is duplicated within all the scopes + * @throws KapuaException + * if any other error occurs. * @since 2.0.0 * @deprecated since 2.0.0 - use {@link org.eclipse.kapua.storage.KapuaNamedEntityRepository} instead */ @Deprecated public static void checkEntityNameUniquenessInAllScopes(@NotNull KapuaEntityService kapuaNamedEntityService, @NotNull E entity) throws KapuaException { - KapuaQuery query = QUERY_FACTORY.newQuery(); + KapuaQuery query = new KapuaQuery(); query.setPredicate( query.andPredicate( query.attributePredicate(KapuaNamedEntityAttributes.NAME, entity.getName()), diff --git a/commons/src/main/java/org/eclipse/kapua/commons/service/internal/ServiceDAO.java b/commons/src/main/java/org/eclipse/kapua/commons/service/internal/ServiceDAO.java index e3febf8c3da..ee179add2f1 100644 --- a/commons/src/main/java/org/eclipse/kapua/commons/service/internal/ServiceDAO.java +++ b/commons/src/main/java/org/eclipse/kapua/commons/service/internal/ServiceDAO.java @@ -12,7 +12,32 @@ *******************************************************************************/ package org.eclipse.kapua.commons.service.internal; -import com.google.common.base.MoreObjects; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.persistence.Embedded; +import javax.persistence.EntityExistsException; +import javax.persistence.NonUniqueResultException; +import javax.persistence.PersistenceException; +import javax.persistence.TypedQuery; +import javax.persistence.criteria.CriteriaBuilder; +import javax.persistence.criteria.CriteriaQuery; +import javax.persistence.criteria.Expression; +import javax.persistence.criteria.JoinType; +import javax.persistence.criteria.Order; +import javax.persistence.criteria.ParameterExpression; +import javax.persistence.criteria.Path; +import javax.persistence.criteria.Predicate; +import javax.persistence.criteria.Root; +import javax.persistence.metamodel.Attribute; +import javax.persistence.metamodel.EntityType; +import javax.validation.constraints.Null; + import org.apache.commons.lang.ArrayUtils; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; @@ -23,8 +48,6 @@ import org.eclipse.kapua.commons.jpa.EntityManager; import org.eclipse.kapua.commons.model.AbstractKapuaUpdatableEntity; import org.eclipse.kapua.commons.model.id.KapuaEid; -import org.eclipse.kapua.commons.model.query.predicate.AttributePredicateImpl; -import org.eclipse.kapua.commons.model.query.predicate.OrPredicateImpl; import org.eclipse.kapua.commons.security.KapuaSecurityUtils; import org.eclipse.kapua.commons.security.KapuaSession; import org.eclipse.kapua.commons.setting.system.SystemSetting; @@ -69,30 +92,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.persistence.Embedded; -import javax.persistence.EntityExistsException; -import javax.persistence.NonUniqueResultException; -import javax.persistence.PersistenceException; -import javax.persistence.TypedQuery; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Expression; -import javax.persistence.criteria.JoinType; -import javax.persistence.criteria.Order; -import javax.persistence.criteria.ParameterExpression; -import javax.persistence.criteria.Path; -import javax.persistence.criteria.Predicate; -import javax.persistence.criteria.Root; -import javax.persistence.metamodel.Attribute; -import javax.persistence.metamodel.EntityType; -import javax.validation.constraints.Null; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import com.google.common.base.MoreObjects; /** * {@link ServiceDAO} utility methods. @@ -169,8 +169,10 @@ protected ServiceDAO() { *

    * This method checks for the constraint violation and, in this case, it throws a specific exception ({@link KapuaEntityExistsException}). * - * @param em The {@link EntityManager} that holds the transaction. - * @param entity The {@link KapuaEntity} to be persisted. + * @param em + * The {@link EntityManager} that holds the transaction. + * @param entity + * The {@link KapuaEntity} to be persisted. * @return The persisted {@link KapuaEntity}. * @since 1.0.0 */ @@ -199,11 +201,15 @@ public static E create(@NonNull EntityManager em, @NonNu /** * Updates the {@link KapuaUpdatableEntity}. * - * @param em The {@link EntityManager} that holds the transaction. - * @param clazz The {@link KapuaUpdatableEntity} class. This must be the implementing {@code class}. - * @param entity The {@link KapuaUpdatableEntity} to be updated. + * @param em + * The {@link EntityManager} that holds the transaction. + * @param clazz + * The {@link KapuaUpdatableEntity} class. This must be the implementing {@code class}. + * @param entity + * The {@link KapuaUpdatableEntity} to be updated. * @return The updated {@link KapuaUpdatableEntity}. - * @throws KapuaEntityNotFoundException If the {@link KapuaEntity} does not exist. + * @throws KapuaEntityNotFoundException + * If the {@link KapuaEntity} does not exist. * @since 1.0.0 */ public static E update(@NonNull EntityManager em, @NonNull Class clazz, @NonNull E entity) throws KapuaEntityNotFoundException { @@ -231,10 +237,14 @@ public static E update(@NonNull EntityManager e /** * Finds a {@link KapuaEntity}. * - * @param em The {@link EntityManager} that holds the transaction. - * @param clazz The {@link KapuaEntity} class. This must be the implementing {@code class}. - * @param scopeId The {@link KapuaEntity#getScopeId()} the entity to be found. - * @param entityId The {@link KapuaEntity#getId()} of the entity to be found. + * @param em + * The {@link EntityManager} that holds the transaction. + * @param clazz + * The {@link KapuaEntity} class. This must be the implementing {@code class}. + * @param scopeId + * The {@link KapuaEntity#getScopeId()} the entity to be found. + * @param entityId + * The {@link KapuaEntity#getId()} of the entity to be found. * @since 1.0.0 */ public static E find(@NonNull EntityManager em, @NonNull Class clazz, @Null KapuaId scopeId, @NonNull KapuaId entityId) { @@ -263,76 +273,96 @@ public static E find(@NonNull EntityManager em, @NonNull /** * Finds a {@link KapuaNamedEntity} by {@link KapuaNamedEntity#getName()}. * - * @param em The {@link EntityManager} that holds the transaction. - * @param clazz The {@link KapuaNamedEntity} class. This must be the implementing {@code class}. - * @param value The value of the {@link KapuaNamedEntity#getName()} to search. + * @param em + * The {@link EntityManager} that holds the transaction. + * @param clazz + * The {@link KapuaNamedEntity} class. This must be the implementing {@code class}. + * @param value + * The value of the {@link KapuaNamedEntity#getName()} to search. * @return The {@link KapuaNamedEntity} found, or {@code null} if not found. - * @throws NonUniqueResultException When more than one result is returned + * @throws NonUniqueResultException + * When more than one result is returned * @since 2.0.0 */ @Nullable public static E findByName(@NonNull EntityManager em, - @NonNull Class clazz, - @NonNull Object value) { + @NonNull Class clazz, + @NonNull Object value) { return findByName(em, clazz, KapuaId.ANY, value); } /** * Finds a {@link KapuaNamedEntity} by {@link KapuaNamedEntity#getName()}. * - * @param em The {@link EntityManager} that holds the transaction. - * @param clazz The {@link KapuaNamedEntity} class. This must be the implementing {@code class}. - * @param scopeId The {@link KapuaNamedEntity#getScopeId()} in which to look for results. - * @param value The value of the field from which to search. + * @param em + * The {@link EntityManager} that holds the transaction. + * @param clazz + * The {@link KapuaNamedEntity} class. This must be the implementing {@code class}. + * @param scopeId + * The {@link KapuaNamedEntity#getScopeId()} in which to look for results. + * @param value + * The value of the field from which to search. * @return The {@link KapuaNamedEntity} found, or {@code null} if not found. - * @throws NonUniqueResultException When more than one result is returned. + * @throws NonUniqueResultException + * When more than one result is returned. * @since 1.0.0 */ @Nullable public static E findByName(@NonNull EntityManager em, - @NonNull Class clazz, - @NonNull KapuaId scopeId, - @NonNull Object value) { + @NonNull Class clazz, + @NonNull KapuaId scopeId, + @NonNull Object value) { return findByField(em, clazz, scopeId, KapuaNamedEntityAttributes.NAME, value); } /** * Find a {@link KapuaEntity} by one of its fields. * - * @param em The {@link EntityManager} that holds the transaction. - * @param clazz The {@link KapuaEntity} class. This must be the implementing {@code class}. - * @param name The {@link KapuaEntity} name of the field from which to search. - * @param value The value of the field from which to search. + * @param em + * The {@link EntityManager} that holds the transaction. + * @param clazz + * The {@link KapuaEntity} class. This must be the implementing {@code class}. + * @param name + * The {@link KapuaEntity} name of the field from which to search. + * @param value + * The value of the field from which to search. * @return The {@link KapuaEntity} found, or {@code null} if not found. - * @throws NonUniqueResultException When more than one result is returned. + * @throws NonUniqueResultException + * When more than one result is returned. * @since 1.0.0 */ @Nullable public static E findByField(@NonNull EntityManager em, - @NonNull Class clazz, - @NonNull String name, - @NonNull Object value) { + @NonNull Class clazz, + @NonNull String name, + @NonNull Object value) { return findByField(em, clazz, KapuaId.ANY, name, value); } /** * Find a {@link KapuaEntity} by one of its fields. * - * @param em The {@link EntityManager} that holds the transaction. - * @param clazz The {@link KapuaEntity} class. This must be the implementing {@code class}. - * @param scopeId The {@link KapuaEntity#getScopeId()} in which to look for results. - * @param name The {@link KapuaEntity} name of the field from which to search. - * @param value The value of the field from which to search. + * @param em + * The {@link EntityManager} that holds the transaction. + * @param clazz + * The {@link KapuaEntity} class. This must be the implementing {@code class}. + * @param scopeId + * The {@link KapuaEntity#getScopeId()} in which to look for results. + * @param name + * The {@link KapuaEntity} name of the field from which to search. + * @param value + * The value of the field from which to search. * @return The {@link KapuaEntity} found, or {@code null} if not found. - * @throws NonUniqueResultException When more than one result is returned. + * @throws NonUniqueResultException + * When more than one result is returned. * @since 1.0.0 */ @Nullable public static E findByField(@NonNull EntityManager em, - @NonNull Class clazz, - @NonNull KapuaId scopeId, - @NonNull String name, - @NonNull Object value) { + @NonNull Class clazz, + @NonNull KapuaId scopeId, + @NonNull String name, + @NonNull Object value) { CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery criteriaSelectQuery = cb.createQuery(clazz); @@ -371,32 +401,38 @@ public static E findByField(@NonNull EntityManager em, // QUERY! List result = query.getResultList(); switch (result.size()) { - case 0: - return null; - case 1: - return result.get(0); - default: - throw new NonUniqueResultException(String.format("Multiple %s results found for field %s with value %s", clazz.getName(), pName, value.toString())); + case 0: + return null; + case 1: + return result.get(0); + default: + throw new NonUniqueResultException(String.format("Multiple %s results found for field %s with value %s", clazz.getName(), pName, value.toString())); } } /** * Queries the {@link KapuaEntity}es. * - * @param em The {@link EntityManager} that holds the transaction. - * @param interfaceClass {@link KapuaQuery} result entity interface class - * @param implementingClass {@link KapuaQuery} result entity implementation class - * @param resultContainer The {@link KapuaListResult} in which load the result. It must be empty. - * @param kapuaQuery The {@link KapuaQuery} to perform. + * @param em + * The {@link EntityManager} that holds the transaction. + * @param interfaceClass + * {@link KapuaQuery} result entity interface class + * @param implementingClass + * {@link KapuaQuery} result entity implementation class + * @param resultContainer + * The {@link KapuaListResult} in which load the result. It must be empty. + * @param kapuaQuery + * The {@link KapuaQuery} to perform. * @return The reference of the {@code resultContainer} parameter. Results are added to the given {@code resultContainer} parameter. - * @throws KapuaException If filter predicates in the {@link KapuaQuery} are incorrect. See {@link #handleKapuaQueryPredicates(QueryPredicate, Map, CriteriaBuilder, Root, EntityType)}. + * @throws KapuaException + * If filter predicates in the {@link KapuaQuery} are incorrect. See {@link #handleKapuaQueryPredicates(QueryPredicate, Map, CriteriaBuilder, Root, EntityType)}. * @since 1.0.0 */ public static > L query(@NonNull EntityManager em, - @NonNull Class interfaceClass, - @NonNull Class implementingClass, - @NonNull L resultContainer, - @NonNull KapuaQuery kapuaQuery) + @NonNull Class interfaceClass, + @NonNull Class implementingClass, + @NonNull L resultContainer, + @NonNull KapuaQuery kapuaQuery) throws KapuaException { CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery criteriaSelectQuery = cb.createQuery(implementingClass); @@ -506,18 +542,23 @@ public static > /** * Counts the {@link KapuaEntity}es. * - * @param em The {@link EntityManager} that holds the transaction. - * @param interfaceClass {@link KapuaQuery} result entity interface class - * @param implementingClass {@link KapuaQuery} result entity implementation class - * @param kapuaQuery The {@link KapuaQuery} to perform. + * @param em + * The {@link EntityManager} that holds the transaction. + * @param interfaceClass + * {@link KapuaQuery} result entity interface class + * @param implementingClass + * {@link KapuaQuery} result entity implementation class + * @param kapuaQuery + * The {@link KapuaQuery} to perform. * @return The number of {@link KapuaEntity}es that matched the filter predicates. - * @throws KapuaException If filter predicates in the {@link KapuaQuery} are incorrect. See {@link #handleKapuaQueryPredicates(QueryPredicate, Map, CriteriaBuilder, Root, EntityType)}. + * @throws KapuaException + * If filter predicates in the {@link KapuaQuery} are incorrect. See {@link #handleKapuaQueryPredicates(QueryPredicate, Map, CriteriaBuilder, Root, EntityType)}. * @since 1.0.0 */ public static long count(@NonNull EntityManager em, - @NonNull Class interfaceClass, - @NonNull Class implementingClass, - @NonNull KapuaQuery kapuaQuery) + @NonNull Class interfaceClass, + @NonNull Class implementingClass, + @NonNull KapuaQuery kapuaQuery) throws KapuaException { CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery criteriaSelectQuery = cb.createQuery(Long.class); @@ -573,12 +614,17 @@ public static long count(@NonNull EntityMan /** * Deletes a {@link KapuaEntity}. * - * @param em The {@link EntityManager} that holds the transaction. - * @param clazz The {@link KapuaEntity} class. This must be the implementing {@code class}. - * @param scopeId The {@link KapuaEntity#getScopeId()} of the entity to be deleted. - * @param entityId The {@link KapuaEntity#getId()} of the entity to be deleted. + * @param em + * The {@link EntityManager} that holds the transaction. + * @param clazz + * The {@link KapuaEntity} class. This must be the implementing {@code class}. + * @param scopeId + * The {@link KapuaEntity#getScopeId()} of the entity to be deleted. + * @param entityId + * The {@link KapuaEntity#getId()} of the entity to be deleted. * @return The deleted {@link KapuaEntity}. - * @throws KapuaEntityNotFoundException If the {@link KapuaEntity} does not exists. + * @throws KapuaEntityNotFoundException + * If the {@link KapuaEntity} does not exists. * @since 1.0.0 */ public static E delete(@NonNull EntityManager em, @NonNull Class clazz, @NonNull KapuaId scopeId, @NonNull KapuaId entityId) @@ -617,19 +663,25 @@ public static E delete(@NonNull EntityManager em, @NonNu *

    * It can be invoked recursively (i.e. to handle {@link AttributePredicate}s of the {@link AndPredicate}. * - * @param queryPredicate The {@link QueryPredicate} to handle. - * @param binds The {@link Map}≶{@link String}, {@link Object}> of the query values. - * @param cb The JPA {@link CriteriaBuilder} of the {@link javax.persistence.Query}. - * @param userPermissionRoot The JPA {@link Root} of the {@link javax.persistence.Query}. - * @param entityType The JPA {@link EntityType} of the {@link javax.persistence.Query}. + * @param queryPredicate + * The {@link QueryPredicate} to handle. + * @param binds + * The {@link Map}≶{@link String}, {@link Object}> of the query values. + * @param cb + * The JPA {@link CriteriaBuilder} of the {@link javax.persistence.Query}. + * @param userPermissionRoot + * The JPA {@link Root} of the {@link javax.persistence.Query}. + * @param entityType + * The JPA {@link EntityType} of the {@link javax.persistence.Query}. * @return The handled {@link Predicate} - * @throws KapuaException If any problem occurs. + * @throws KapuaException + * If any problem occurs. */ private static Predicate handleKapuaQueryPredicates(@NonNull QueryPredicate queryPredicate, - @NonNull Map binds, - @NonNull CriteriaBuilder cb, - @NonNull Root userPermissionRoot, - @NonNull EntityType entityType) + @NonNull Map binds, + @NonNull CriteriaBuilder cb, + @NonNull Root userPermissionRoot, + @NonNull EntityType entityType) throws KapuaException { Predicate predicate = null; if (queryPredicate instanceof AttributePredicate) { @@ -643,9 +695,9 @@ private static Predicate handleKapuaQueryPredicates(@NonNull QueryPredicate predicate = handleOrPredicate(orPredicate, binds, cb, userPermissionRoot, entityType); } else if (queryPredicate instanceof MatchPredicate) { MatchPredicate matchPredicate = (MatchPredicate) queryPredicate; - OrPredicate orPredicate = new OrPredicateImpl(); + OrPredicate orPredicate = new OrPredicate(); for (String attributeName : matchPredicate.getAttributeNames()) { - orPredicate.getPredicates().add(new AttributePredicateImpl<>(attributeName, matchPredicate.getMatchTerm(), Operator.STARTS_WITH_IGNORE_CASE)); + orPredicate.getPredicates().add(new AttributePredicate<>(attributeName, matchPredicate.getMatchTerm(), Operator.STARTS_WITH_IGNORE_CASE)); } predicate = handleOrPredicate(orPredicate, binds, cb, userPermissionRoot, entityType); } @@ -653,10 +705,10 @@ private static Predicate handleKapuaQueryPredicates(@NonNull QueryPredicate } private static Predicate handleAndPredicate(@NonNull AndPredicate andPredicate, - @NonNull Map binds, - @NonNull CriteriaBuilder cb, - @NonNull Root entityRoot, - @NonNull EntityType entityType) + @NonNull Map binds, + @NonNull CriteriaBuilder cb, + @NonNull Root entityRoot, + @NonNull EntityType entityType) throws KapuaException { Predicate[] jpaAndPredicates = @@ -672,10 +724,10 @@ private static Predicate handleAndPredicate(@NonNull AndPredicate andPredica } private static Predicate handleOrPredicate(@NonNull OrPredicate orPredicate, - @NonNull Map binds, - @NonNull CriteriaBuilder cb, - @NonNull Root entityRoot, - @NonNull EntityType entityType) + @NonNull Map binds, + @NonNull CriteriaBuilder cb, + @NonNull Root entityRoot, + @NonNull EntityType entityType) throws KapuaException { Predicate[] jpaOrPredicates = @@ -690,10 +742,10 @@ private static Predicate handleOrPredicate(@NonNull OrPredicate orPredicate, } private static Predicate[] handlePredicate(@NonNull List orPredicates, - @NonNull Map binds, - @NonNull CriteriaBuilder cb, - @NonNull Root entityRoot, - @NonNull EntityType entityType) throws KapuaException { + @NonNull Map binds, + @NonNull CriteriaBuilder cb, + @NonNull Root entityRoot, + @NonNull EntityType entityType) throws KapuaException { Predicate[] jpaOrPredicates = new Predicate[orPredicates.size()]; for (int i = 0; i < orPredicates.size(); i++) { @@ -704,10 +756,10 @@ private static Predicate[] handlePredicate(@NonNull List orP } private static Predicate handleAttributePredicate(@NonNull AttributePredicate attrPred, - @NonNull Map binds, - @NonNull CriteriaBuilder cb, - @NonNull Root entityRoot, - @NonNull EntityType entityType) + @NonNull Map binds, + @NonNull CriteriaBuilder cb, + @NonNull Root entityRoot, + @NonNull EntityType entityType) throws KapuaException { Predicate expr; String attrName = attrPred.getAttributeName(); @@ -753,88 +805,88 @@ private static Predicate handleAttributePredicate(@NonNull AttributePredicat } else { String strAttrValue; switch (attrPred.getOperator()) { - case LIKE: - strAttrValue = attributeValue.toString().replace(LIKE, ESCAPE + LIKE).replace(ANY, ESCAPE + ANY); - ParameterExpression pl = cb.parameter(String.class); - binds.put(pl, LIKE + strAttrValue + LIKE); - expr = cb.like(extractAttribute(entityRoot, attrName), pl); - break; - - case LIKE_IGNORE_CASE: - strAttrValue = attributeValue.toString().replace(LIKE, ESCAPE + LIKE).replace(ANY, ESCAPE + ANY).toLowerCase(); - ParameterExpression plci = cb.parameter(String.class); - binds.put(plci, LIKE + strAttrValue + LIKE); - expr = cb.like(cb.lower(extractAttribute(entityRoot, attrName)), plci); - break; - - case STARTS_WITH: - strAttrValue = attributeValue.toString().replace(LIKE, ESCAPE + LIKE).replace(ANY, ESCAPE + ANY); - ParameterExpression psw = cb.parameter(String.class); - binds.put(psw, strAttrValue + LIKE); - expr = cb.like(extractAttribute(entityRoot, attrName), psw); - break; - - case STARTS_WITH_IGNORE_CASE: - strAttrValue = attributeValue.toString().replace(LIKE, ESCAPE + LIKE).replace(ANY, ESCAPE + ANY).toLowerCase(); - ParameterExpression pswci = cb.parameter(String.class); - binds.put(pswci, strAttrValue + LIKE); - expr = cb.like(cb.lower(extractAttribute(entityRoot, attrName)), pswci); - break; - - case IS_NULL: - expr = cb.isNull(extractAttribute(entityRoot, attrName)); - break; - - case NOT_NULL: - expr = cb.isNotNull(extractAttribute(entityRoot, attrName)); - break; - - case NOT_EQUAL: - expr = cb.notEqual(extractAttribute(entityRoot, attrName), attributeValue); - break; - - case GREATER_THAN: - if (attributeValue instanceof Comparable && ArrayUtils.contains(attribute.getJavaType().getInterfaces(), Comparable.class)) { - Comparable comparableAttrValue = (Comparable) attributeValue; - Expression comparableExpression = extractAttribute(entityRoot, attrName); - expr = cb.greaterThan(comparableExpression, comparableAttrValue); - } else { - throw new KapuaException(KapuaErrorCodes.ILLEGAL_ARGUMENT, COMPARE_ERROR_MESSAGE); - } - break; - - case GREATER_THAN_OR_EQUAL: - if (attributeValue instanceof Comparable && ArrayUtils.contains(attribute.getJavaType().getInterfaces(), Comparable.class)) { - Expression comparableExpression = extractAttribute(entityRoot, attrName); - Comparable comparableAttrValue = (Comparable) attributeValue; - expr = cb.greaterThanOrEqualTo(comparableExpression, comparableAttrValue); - } else { - throw new KapuaException(KapuaErrorCodes.ILLEGAL_ARGUMENT, COMPARE_ERROR_MESSAGE); - } - break; - - case LESS_THAN: - if (attributeValue instanceof Comparable && ArrayUtils.contains(attribute.getJavaType().getInterfaces(), Comparable.class)) { - Expression comparableExpression = extractAttribute(entityRoot, attrName); - Comparable comparableAttrValue = (Comparable) attributeValue; - expr = cb.lessThan(comparableExpression, comparableAttrValue); - } else { - throw new KapuaException(KapuaErrorCodes.ILLEGAL_ARGUMENT, COMPARE_ERROR_MESSAGE); - } - break; - case LESS_THAN_OR_EQUAL: - if (attributeValue instanceof Comparable && ArrayUtils.contains(attribute.getJavaType().getInterfaces(), Comparable.class)) { - Expression comparableExpression = extractAttribute(entityRoot, attrName); - Comparable comparableAttrValue = (Comparable) attributeValue; - expr = cb.lessThanOrEqualTo(comparableExpression, comparableAttrValue); - } else { - throw new KapuaException(KapuaErrorCodes.ILLEGAL_ARGUMENT, COMPARE_ERROR_MESSAGE); - } - break; + case LIKE: + strAttrValue = attributeValue.toString().replace(LIKE, ESCAPE + LIKE).replace(ANY, ESCAPE + ANY); + ParameterExpression pl = cb.parameter(String.class); + binds.put(pl, LIKE + strAttrValue + LIKE); + expr = cb.like(extractAttribute(entityRoot, attrName), pl); + break; + + case LIKE_IGNORE_CASE: + strAttrValue = attributeValue.toString().replace(LIKE, ESCAPE + LIKE).replace(ANY, ESCAPE + ANY).toLowerCase(); + ParameterExpression plci = cb.parameter(String.class); + binds.put(plci, LIKE + strAttrValue + LIKE); + expr = cb.like(cb.lower(extractAttribute(entityRoot, attrName)), plci); + break; + + case STARTS_WITH: + strAttrValue = attributeValue.toString().replace(LIKE, ESCAPE + LIKE).replace(ANY, ESCAPE + ANY); + ParameterExpression psw = cb.parameter(String.class); + binds.put(psw, strAttrValue + LIKE); + expr = cb.like(extractAttribute(entityRoot, attrName), psw); + break; + + case STARTS_WITH_IGNORE_CASE: + strAttrValue = attributeValue.toString().replace(LIKE, ESCAPE + LIKE).replace(ANY, ESCAPE + ANY).toLowerCase(); + ParameterExpression pswci = cb.parameter(String.class); + binds.put(pswci, strAttrValue + LIKE); + expr = cb.like(cb.lower(extractAttribute(entityRoot, attrName)), pswci); + break; + + case IS_NULL: + expr = cb.isNull(extractAttribute(entityRoot, attrName)); + break; + + case NOT_NULL: + expr = cb.isNotNull(extractAttribute(entityRoot, attrName)); + break; + + case NOT_EQUAL: + expr = cb.notEqual(extractAttribute(entityRoot, attrName), attributeValue); + break; + + case GREATER_THAN: + if (attributeValue instanceof Comparable && ArrayUtils.contains(attribute.getJavaType().getInterfaces(), Comparable.class)) { + Comparable comparableAttrValue = (Comparable) attributeValue; + Expression comparableExpression = extractAttribute(entityRoot, attrName); + expr = cb.greaterThan(comparableExpression, comparableAttrValue); + } else { + throw new KapuaException(KapuaErrorCodes.ILLEGAL_ARGUMENT, COMPARE_ERROR_MESSAGE); + } + break; + + case GREATER_THAN_OR_EQUAL: + if (attributeValue instanceof Comparable && ArrayUtils.contains(attribute.getJavaType().getInterfaces(), Comparable.class)) { + Expression comparableExpression = extractAttribute(entityRoot, attrName); + Comparable comparableAttrValue = (Comparable) attributeValue; + expr = cb.greaterThanOrEqualTo(comparableExpression, comparableAttrValue); + } else { + throw new KapuaException(KapuaErrorCodes.ILLEGAL_ARGUMENT, COMPARE_ERROR_MESSAGE); + } + break; + + case LESS_THAN: + if (attributeValue instanceof Comparable && ArrayUtils.contains(attribute.getJavaType().getInterfaces(), Comparable.class)) { + Expression comparableExpression = extractAttribute(entityRoot, attrName); + Comparable comparableAttrValue = (Comparable) attributeValue; + expr = cb.lessThan(comparableExpression, comparableAttrValue); + } else { + throw new KapuaException(KapuaErrorCodes.ILLEGAL_ARGUMENT, COMPARE_ERROR_MESSAGE); + } + break; + case LESS_THAN_OR_EQUAL: + if (attributeValue instanceof Comparable && ArrayUtils.contains(attribute.getJavaType().getInterfaces(), Comparable.class)) { + Expression comparableExpression = extractAttribute(entityRoot, attrName); + Comparable comparableAttrValue = (Comparable) attributeValue; + expr = cb.lessThanOrEqualTo(comparableExpression, comparableAttrValue); + } else { + throw new KapuaException(KapuaErrorCodes.ILLEGAL_ARGUMENT, COMPARE_ERROR_MESSAGE); + } + break; - case EQUAL: - default: - expr = cb.equal(extractAttribute(entityRoot, attrName), attributeValue); + case EQUAL: + default: + expr = cb.equal(extractAttribute(entityRoot, attrName), attributeValue); } } return expr; @@ -847,8 +899,10 @@ private static Predicate handleAttributePredicate(@NonNull AttributePredicat *

    * Filter predicates takes advantage of the dot notation to access {@link Embedded} attributes and nested {@link KapuaEntity}es. * - * @param entityRoot The {@link Root} entity from which extract the attribute. - * @param attributeName The full attribute name. + * @param entityRoot + * The {@link Root} entity from which extract the attribute. + * @param attributeName + * The full attribute name. * @return The {@link Path} expression that matches the given {@code attributeName} parameter. * @since 1.0.0 */ @@ -870,9 +924,12 @@ private static Path

    extractAttribute(@NonNull Root entityRoot, @Non /** * Handles the {@link Groupable} property of the {@link KapuaEntity}. * - * @param query The {@link KapuaQuery} to manage. - * @param domain The {@link Domain} inside which the {@link KapuaQuery} param targets. - * @param groupPredicateName The name of the {@link Group} id field. + * @param query + * The {@link KapuaQuery} to manage. + * @param domain + * The {@link Domain} inside which the {@link KapuaQuery} param targets. + * @param groupPredicateName + * The name of the {@link Group} id field. * @since 1.0.0 */ protected static void handleKapuaQueryGroupPredicate(@NonNull KapuaQuery query, @NonNull Domain domain, @NonNull String groupPredicateName) throws KapuaException { @@ -971,7 +1028,8 @@ private static boolean checkGroupPermission(@NonNull Domain domain, @NonNull Lis /** * Check if the given {@link PersistenceException} is a SQL constraint violation error. * - * @param persistenceException {@link PersistenceException} to check. + * @param persistenceException + * {@link PersistenceException} to check. * @return {@code true} if it is a constraint validation error, {@code false} otherwise. * @since 1.0.0 */ diff --git a/commons/src/test/java/org/eclipse/kapua/commons/configuration/ServiceConfigQueryImplTest.java b/commons/src/test/java/org/eclipse/kapua/commons/configuration/ServiceConfigQueryImplTest.java deleted file mode 100644 index 43e8195d15c..00000000000 --- a/commons/src/test/java/org/eclipse/kapua/commons/configuration/ServiceConfigQueryImplTest.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2020, 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 org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.qa.markers.junit.JUnitTests; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; - - - -@Category(JUnitTests.class) -public class ServiceConfigQueryImplTest { - - @Test - public void createInstanceTest() { - ServiceConfigQueryImpl query = new ServiceConfigQueryImpl(KapuaId.ONE); - Assert.assertEquals(query.getScopeId(), KapuaId.ONE); - } - -} diff --git a/commons/src/test/java/org/eclipse/kapua/commons/model/query/FieldSortCriteriaImplTest.java b/commons/src/test/java/org/eclipse/kapua/commons/model/query/FieldSortCriteriaTest.java similarity index 64% rename from commons/src/test/java/org/eclipse/kapua/commons/model/query/FieldSortCriteriaImplTest.java rename to commons/src/test/java/org/eclipse/kapua/commons/model/query/FieldSortCriteriaTest.java index 0e93245f75e..64125803b90 100644 --- a/commons/src/test/java/org/eclipse/kapua/commons/model/query/FieldSortCriteriaImplTest.java +++ b/commons/src/test/java/org/eclipse/kapua/commons/model/query/FieldSortCriteriaTest.java @@ -12,6 +12,9 @@ *******************************************************************************/ package org.eclipse.kapua.commons.model.query; +import java.util.Arrays; + +import org.eclipse.kapua.model.query.FieldSortCriteria; import org.eclipse.kapua.model.query.SortOrder; import org.eclipse.kapua.qa.markers.junit.JUnitTests; import org.junit.Assert; @@ -21,40 +24,38 @@ import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; -import java.util.Arrays; - - @Category(JUnitTests.class) @RunWith(value = Parameterized.class) -public class FieldSortCriteriaImplTest { +public class FieldSortCriteriaTest { private final String attributeName; private SortOrder sortOrder; - public FieldSortCriteriaImplTest(String attributeName) { + public FieldSortCriteriaTest(String attributeName) { this.attributeName = attributeName; } @Parameters public static Iterable attributeNames() { return Arrays.asList( - new Object[]{""}, - new Object[]{"NAME"}, - new Object[]{"attributeName"}, - new Object[]{"attribute name"}, - new Object[]{"0123456789"}, - new Object[]{"!#$%&'()=?⁄@‹›€°·‚,.-;:_Èˇ¿<>«‘”’ÉØ∏{}|ÆæÒuF8FFÔÓÌÏÎÅ«»Ç◊ш¯Èˇ"}, - new Object[]{"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefg"}); + new Object[] { "" }, + new Object[] { "NAME" }, + new Object[] { "attributeName" }, + new Object[] { "attribute name" }, + new Object[] { "0123456789" }, + new Object[] { "!#$%&'()=?⁄@‹›€°·‚,.-;:_Èˇ¿<>«‘”’ÉØ∏{}|ÆæÒuF8FFÔÓÌÏÎÅ«»Ç◊ш¯Èˇ" }, + new Object[] { + "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefg" }); } @Test public void fieldSortCriteriaImplTest() { SortOrder sortOrderAscending = SortOrder.ASCENDING; - FieldSortCriteriaImpl fieldSortCriteriaAscending = new FieldSortCriteriaImpl(attributeName, sortOrderAscending); + FieldSortCriteria fieldSortCriteriaAscending = new FieldSortCriteria(attributeName, sortOrderAscending); Assert.assertEquals("Actual and expected values are not the same!", attributeName, fieldSortCriteriaAscending.getAttributeName()); Assert.assertEquals("Actual and expected values are not the same!", sortOrderAscending, fieldSortCriteriaAscending.getSortOrder()); SortOrder sortOrderDescending = SortOrder.DESCENDING; - FieldSortCriteriaImpl fieldSortCriteriaDescending = new FieldSortCriteriaImpl(attributeName, sortOrderDescending); + FieldSortCriteria fieldSortCriteriaDescending = new FieldSortCriteria(attributeName, sortOrderDescending); Assert.assertEquals("Actual and expected values are not the same!", attributeName, fieldSortCriteriaDescending.getAttributeName()); Assert.assertEquals("Actual and expected values are not the same!", sortOrderDescending, fieldSortCriteriaDescending.getSortOrder()); } diff --git a/commons/src/test/java/org/eclipse/kapua/commons/model/query/AbstractKapuaQueryTest.java b/commons/src/test/java/org/eclipse/kapua/commons/model/query/KapuaQueryTest.java similarity index 70% rename from commons/src/test/java/org/eclipse/kapua/commons/model/query/AbstractKapuaQueryTest.java rename to commons/src/test/java/org/eclipse/kapua/commons/model/query/KapuaQueryTest.java index b04a8c0fb42..69c2958adef 100644 --- a/commons/src/test/java/org/eclipse/kapua/commons/model/query/AbstractKapuaQueryTest.java +++ b/commons/src/test/java/org/eclipse/kapua/commons/model/query/KapuaQueryTest.java @@ -12,10 +12,14 @@ *******************************************************************************/ package org.eclipse.kapua.commons.model.query; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; + import org.eclipse.kapua.commons.model.id.KapuaEid; -import org.eclipse.kapua.commons.model.query.predicate.AndPredicateImpl; -import org.eclipse.kapua.commons.model.query.predicate.OrPredicateImpl; import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.model.query.FieldSortCriteria; import org.eclipse.kapua.model.query.KapuaQuery; import org.eclipse.kapua.model.query.KapuaSortCriteria; import org.eclipse.kapua.model.query.SortOrder; @@ -32,60 +36,40 @@ import org.junit.runners.Parameterized.Parameters; import org.mockito.Mockito; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.List; - - @Category(JUnitTests.class) @RunWith(value = Parameterized.class) -public class AbstractKapuaQueryTest { +public class KapuaQueryTest { private final String attributeName; private final AttributePredicate.Operator operator; - public AbstractKapuaQueryTest(String attributeName, AttributePredicate.Operator operator) { + public KapuaQueryTest(String attributeName, AttributePredicate.Operator operator) { this.attributeName = attributeName; this.operator = operator; } @Parameters public static Collection attributeNamesAndOperators() { - return Arrays.asList(new Object[][]{ - {"", AttributePredicate.Operator.EQUAL}, - {"NAME", AttributePredicate.Operator.NOT_EQUAL}, - {"attributeName", AttributePredicate.Operator.IS_NULL}, - {"attribute name", AttributePredicate.Operator.NOT_NULL}, - {"0123456789", AttributePredicate.Operator.GREATER_THAN}, - {"!#$%&'()=?⁄@‹›€°·‚,.-;:_Èˇ¿<>«‘”’ÉØ∏{}|ÆæÒuF8FFÔÓÌÏÎÅ«»Ç◊ш¯Èˇ", AttributePredicate.Operator.GREATER_THAN_OR_EQUAL}, - {"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefg", AttributePredicate.Operator.STARTS_WITH}, - {"ATTRIBUTE NAME", AttributePredicate.Operator.LIKE}, - {"name123", AttributePredicate.Operator.LESS_THAN}, - {"#$attribute", AttributePredicate.Operator.LESS_THAN_OR_EQUAL}, + return Arrays.asList(new Object[][] { + { "", AttributePredicate.Operator.EQUAL }, + { "NAME", AttributePredicate.Operator.NOT_EQUAL }, + { "attributeName", AttributePredicate.Operator.IS_NULL }, + { "attribute name", AttributePredicate.Operator.NOT_NULL }, + { "0123456789", AttributePredicate.Operator.GREATER_THAN }, + { "!#$%&'()=?⁄@‹›€°·‚,.-;:_Èˇ¿<>«‘”’ÉØ∏{}|ÆæÒuF8FFÔÓÌÏÎÅ«»Ç◊ш¯Èˇ", AttributePredicate.Operator.GREATER_THAN_OR_EQUAL }, + { "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefg", + AttributePredicate.Operator.STARTS_WITH }, + { "ATTRIBUTE NAME", AttributePredicate.Operator.LIKE }, + { "name123", AttributePredicate.Operator.LESS_THAN }, + { "#$attribute", AttributePredicate.Operator.LESS_THAN_OR_EQUAL }, }); } - private class ActualKapuaQuery extends AbstractKapuaQuery { - - public ActualKapuaQuery() { - super(); - } - - public ActualKapuaQuery(KapuaId scopeId) { - super(scopeId); - } - - public ActualKapuaQuery(KapuaQuery query) { - super(query); - } - } - @Test public void abstractKapuaQueryScopeIdTest() { KapuaId scopeId = new KapuaEid(); - AbstractKapuaQuery kapuaQuery = new ActualKapuaQuery(scopeId); + KapuaQuery kapuaQuery = new KapuaQuery(scopeId); Assert.assertEquals("Actual and expected values are not the same!", scopeId, kapuaQuery.getScopeId()); } @@ -93,18 +77,18 @@ public void abstractKapuaQueryScopeIdTest() { public void abstractKapuaQueryQueryIdTest() { KapuaId scopeId = new KapuaEid(); List fetchAttributes = new ArrayList<>(); - QueryPredicate predicate = Mockito.mock(AndPredicateImpl.class); + QueryPredicate predicate = Mockito.mock(AndPredicate.class); SortOrder sortOrder = SortOrder.ASCENDING; - KapuaSortCriteria sortCriteria = new FieldSortCriteriaImpl(attributeName, sortOrder); + KapuaSortCriteria sortCriteria = new FieldSortCriteria(attributeName, sortOrder); Integer limit = 48; Integer offset = 56; - AbstractKapuaQuery kapuaQuery = new ActualKapuaQuery(scopeId); + KapuaQuery kapuaQuery = new KapuaQuery(scopeId); kapuaQuery.setFetchAttributes(fetchAttributes); kapuaQuery.setPredicate(predicate); kapuaQuery.setLimit(limit); kapuaQuery.setOffset(offset); kapuaQuery.setSortCriteria(sortCriteria); - AbstractKapuaQuery kapuaCopyQuery = new ActualKapuaQuery(kapuaQuery); + KapuaQuery kapuaCopyQuery = new KapuaQuery(kapuaQuery); Assert.assertEquals("Actual and expected values are not the same!", kapuaQuery.getFetchAttributes(), kapuaCopyQuery.getFetchAttributes()); Assert.assertEquals("Actual and expected values are not the same!", kapuaQuery.getPredicate(), kapuaCopyQuery.getPredicate()); Assert.assertEquals("Actual and expected values are not the same!", kapuaQuery.getLimit(), kapuaCopyQuery.getLimit()); @@ -114,7 +98,7 @@ public void abstractKapuaQueryQueryIdTest() { @Test public void addFetchAttributesTest() { - AbstractKapuaQuery kapuaQuery = new ActualKapuaQuery(); + KapuaQuery kapuaQuery = new KapuaQuery(); String emptyFetchAttribute = ""; String fetchAttribute = "fetchAttribute"; kapuaQuery.addFetchAttributes(null); @@ -127,7 +111,7 @@ public void addFetchAttributesTest() { @Test public void attributePredicateTest() { - AbstractKapuaQuery kapuaQuery = new ActualKapuaQuery(); + KapuaQuery kapuaQuery = new KapuaQuery(); Object attributeValue = new Object(); AttributePredicate attributePredicate = kapuaQuery.attributePredicate(attributeName, attributeValue); Assert.assertEquals("Actual and expected values are not the same!", attributeName, attributePredicate.getAttributeName()); @@ -136,7 +120,7 @@ public void attributePredicateTest() { @Test public void attributePredicateWithOperatorTest() { - AbstractKapuaQuery kapuaQuery = new ActualKapuaQuery(); + KapuaQuery kapuaQuery = new KapuaQuery(); Object attributeValue = new Object(); AttributePredicate attributePredicate = kapuaQuery.attributePredicate(attributeName, attributeValue, operator); Assert.assertEquals("Actual and expected values are not the same!", attributeName, attributePredicate.getAttributeName()); @@ -146,7 +130,7 @@ public void attributePredicateWithOperatorTest() { @Test public void andPredicateTest() { - AbstractKapuaQuery kapuaQuery = new ActualKapuaQuery(); + KapuaQuery kapuaQuery = new KapuaQuery(); AndPredicate andPredicate = kapuaQuery.andPredicate(); ArrayList queryPredicateArray = new ArrayList<>(); Assert.assertEquals("Actual and expected values are not the same!", queryPredicateArray, andPredicate.getPredicates()); @@ -154,18 +138,18 @@ public void andPredicateTest() { @Test public void andPredicateWithQueryPredicatesTest() { - AbstractKapuaQuery kapuaQuery = new ActualKapuaQuery(); + KapuaQuery kapuaQuery = new KapuaQuery(); QueryPredicate[] queryPredicateArray = new QueryPredicate[10]; for (int i = 0; i < queryPredicateArray.length; i++) { - queryPredicateArray[i] = Mockito.mock(AndPredicateImpl.class); + queryPredicateArray[i] = Mockito.mock(AndPredicate.class); } - AndPredicate andPredicate = new AndPredicateImpl(queryPredicateArray); + AndPredicate andPredicate = new AndPredicate(queryPredicateArray); Assert.assertEquals("Actual and expected values are not the same!", andPredicate.getPredicates(), kapuaQuery.andPredicate(queryPredicateArray).getPredicates()); } @Test public void orPredicateTest() { - AbstractKapuaQuery kapuaQuery = new ActualKapuaQuery(); + KapuaQuery kapuaQuery = new KapuaQuery(); OrPredicate orPredicate = kapuaQuery.orPredicate(); ArrayList queryPredicateArray = new ArrayList<>(); Assert.assertEquals("Actual and expected values are not the same!", queryPredicateArray, orPredicate.getPredicates()); @@ -173,18 +157,18 @@ public void orPredicateTest() { @Test public void orPredicateWithQueryPredicatesTest() { - AbstractKapuaQuery kapuaQuery = new ActualKapuaQuery(); + KapuaQuery kapuaQuery = new KapuaQuery(); QueryPredicate[] queryPredicateArray = new QueryPredicate[5]; for (int i = 0; i < queryPredicateArray.length; i++) { - queryPredicateArray[i] = Mockito.mock(AndPredicateImpl.class); + queryPredicateArray[i] = Mockito.mock(AndPredicate.class); } - OrPredicate orPredicate = new OrPredicateImpl(queryPredicateArray); + OrPredicate orPredicate = new OrPredicate(queryPredicateArray); Assert.assertEquals("Actual and expected values are not the same!", orPredicate.getPredicates(), kapuaQuery.orPredicate(queryPredicateArray).getPredicates()); } @Test public void getAskTotalCountTest() { - AbstractKapuaQuery kapuaQuery = new ActualKapuaQuery(); + KapuaQuery kapuaQuery = new KapuaQuery(); kapuaQuery.setAskTotalCount(true); Assert.assertEquals("Actual and expected values are not the same!", true, kapuaQuery.getAskTotalCount()); kapuaQuery.setAskTotalCount(false); diff --git a/commons/src/test/java/org/eclipse/kapua/commons/model/query/predicate/AndPredicateImplTest.java b/commons/src/test/java/org/eclipse/kapua/commons/model/query/predicate/AndPredicateTest.java similarity index 68% rename from commons/src/test/java/org/eclipse/kapua/commons/model/query/predicate/AndPredicateImplTest.java rename to commons/src/test/java/org/eclipse/kapua/commons/model/query/predicate/AndPredicateTest.java index 8fa95c35c37..8adc5a119df 100644 --- a/commons/src/test/java/org/eclipse/kapua/commons/model/query/predicate/AndPredicateImplTest.java +++ b/commons/src/test/java/org/eclipse/kapua/commons/model/query/predicate/AndPredicateTest.java @@ -12,36 +12,36 @@ *******************************************************************************/ package org.eclipse.kapua.commons.model.query.predicate; +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.kapua.model.query.predicate.AndPredicate; import org.eclipse.kapua.model.query.predicate.QueryPredicate; import org.eclipse.kapua.qa.markers.junit.JUnitTests; import org.junit.Assert; import org.junit.Test; import org.junit.experimental.categories.Category; -import java.util.ArrayList; -import java.util.List; - - @Category(JUnitTests.class) -public class AndPredicateImplTest { +public class AndPredicateTest { @Test public void andPredicateImpl() { - AndPredicateImpl andPredicate = new AndPredicateImpl(); + AndPredicate andPredicate = new AndPredicate(); ArrayList array = new ArrayList<>(); Assert.assertEquals("Actual and expected values are not the same!", array, andPredicate.getPredicates()); } @Test public void andPredicateImplQueryPredicateId() { - QueryPredicate queryPredicate = new AndPredicateImpl(); - AndPredicateImpl andPredicate = new AndPredicateImpl(queryPredicate); + QueryPredicate queryPredicate = new AndPredicate(); + AndPredicate andPredicate = new AndPredicate(queryPredicate); Assert.assertEquals("Actual and expected values are not the same!", queryPredicate, andPredicate.getPredicates().get(0)); - QueryPredicate queryPredicate1 = new AndPredicateImpl(); - QueryPredicate queryPredicate2 = new AndPredicateImpl(); - QueryPredicate queryPredicate3 = new AndPredicateImpl(); - QueryPredicate[] queryPredicateArray = {queryPredicate1, queryPredicate2, queryPredicate3}; - AndPredicateImpl andPredicateWithMultiplePredicates = new AndPredicateImpl(queryPredicate1, queryPredicate2, queryPredicate3); + QueryPredicate queryPredicate1 = new AndPredicate(); + QueryPredicate queryPredicate2 = new AndPredicate(); + QueryPredicate queryPredicate3 = new AndPredicate(); + QueryPredicate[] queryPredicateArray = { queryPredicate1, queryPredicate2, queryPredicate3 }; + AndPredicate andPredicateWithMultiplePredicates = new AndPredicate(queryPredicate1, queryPredicate2, queryPredicate3); for (int i = 0; i < queryPredicateArray.length; i++) { Assert.assertEquals("Actual and expected values are not the same!", queryPredicateArray[i], andPredicateWithMultiplePredicates.getPredicates().get(i)); } @@ -49,26 +49,26 @@ public void andPredicateImplQueryPredicateId() { @Test public void andTest() { - AndPredicateImpl andPredicate = new AndPredicateImpl(); - QueryPredicate queryPredicate = new AndPredicateImpl(); + AndPredicate andPredicate = new AndPredicate(); + QueryPredicate queryPredicate = new AndPredicate(); andPredicate.and(queryPredicate); Assert.assertEquals("Actual and expected values are not the same!", queryPredicate, andPredicate.getPredicates().get(0)); } @Test public void andWithNullPredicateTest() { - AndPredicateImpl andPredicate = new AndPredicateImpl(); + AndPredicate andPredicate = new AndPredicate(); andPredicate.and(null); Assert.assertNull(andPredicate.getPredicates().get(0)); } @Test public void getPredicatesTest() { - AndPredicateImpl andPredicate = new AndPredicateImpl(); + AndPredicate andPredicate = new AndPredicate(); List predicates = new ArrayList<>(); - predicates.add(new AndPredicateImpl()); - predicates.add(new AndPredicateImpl()); - predicates.add(new AndPredicateImpl()); + predicates.add(new AndPredicate()); + predicates.add(new AndPredicate()); + predicates.add(new AndPredicate()); andPredicate.setPredicates(predicates); for (int i = 0; i < predicates.size(); i++) { Assert.assertEquals("Actual and expected values are not the same!", predicates.get(i), andPredicate.getPredicates().get(i)); diff --git a/commons/src/test/java/org/eclipse/kapua/commons/model/query/predicate/AttributePredicateImplTest.java b/commons/src/test/java/org/eclipse/kapua/commons/model/query/predicate/AttributePredicateTest.java similarity index 64% rename from commons/src/test/java/org/eclipse/kapua/commons/model/query/predicate/AttributePredicateImplTest.java rename to commons/src/test/java/org/eclipse/kapua/commons/model/query/predicate/AttributePredicateTest.java index 7a5f9e41180..9a5f9977ed2 100644 --- a/commons/src/test/java/org/eclipse/kapua/commons/model/query/predicate/AttributePredicateImplTest.java +++ b/commons/src/test/java/org/eclipse/kapua/commons/model/query/predicate/AttributePredicateTest.java @@ -12,6 +12,9 @@ *******************************************************************************/ package org.eclipse.kapua.commons.model.query.predicate; +import java.util.Arrays; +import java.util.Collection; + import org.eclipse.kapua.model.query.predicate.AttributePredicate; import org.eclipse.kapua.qa.markers.junit.JUnitTests; import org.junit.Assert; @@ -21,87 +24,84 @@ import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; -import java.util.Arrays; -import java.util.Collection; - - @Category(JUnitTests.class) @RunWith(value = Parameterized.class) -public class AttributePredicateImplTest { +public class AttributePredicateTest { private final String attributeName; private final AttributePredicate.Operator operator; - public AttributePredicateImplTest(String attributeName, AttributePredicate.Operator operator) { + public AttributePredicateTest(String attributeName, AttributePredicate.Operator operator) { this.attributeName = attributeName; this.operator = operator; } @Parameters public static Collection attributeNamesAndOperators() { - return Arrays.asList(new Object[][]{ - {"", AttributePredicate.Operator.EQUAL}, - {"NAME", AttributePredicate.Operator.NOT_EQUAL}, - {"attributeName", AttributePredicate.Operator.IS_NULL}, - {"attribute name", AttributePredicate.Operator.NOT_NULL}, - {"0123456789", AttributePredicate.Operator.GREATER_THAN}, - {"!#$%&'()=?⁄@‹›€°·‚,.-;:_Èˇ¿<>«‘”’ÉØ∏{}|ÆæÒuF8FFÔÓÌÏÎÅ«»Ç◊ш¯Èˇ", AttributePredicate.Operator.GREATER_THAN_OR_EQUAL}, - {"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefg", AttributePredicate.Operator.STARTS_WITH}, - {"ATTRIBUTE NAME", AttributePredicate.Operator.LIKE}, - {"name123", AttributePredicate.Operator.LESS_THAN}, - {"#$attribute", AttributePredicate.Operator.LESS_THAN_OR_EQUAL}, + return Arrays.asList(new Object[][] { + { "", AttributePredicate.Operator.EQUAL }, + { "NAME", AttributePredicate.Operator.NOT_EQUAL }, + { "attributeName", AttributePredicate.Operator.IS_NULL }, + { "attribute name", AttributePredicate.Operator.NOT_NULL }, + { "0123456789", AttributePredicate.Operator.GREATER_THAN }, + { "!#$%&'()=?⁄@‹›€°·‚,.-;:_Èˇ¿<>«‘”’ÉØ∏{}|ÆæÒuF8FFÔÓÌÏÎÅ«»Ç◊ш¯Èˇ", AttributePredicate.Operator.GREATER_THAN_OR_EQUAL }, + { "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefg", + AttributePredicate.Operator.STARTS_WITH }, + { "ATTRIBUTE NAME", AttributePredicate.Operator.LIKE }, + { "name123", AttributePredicate.Operator.LESS_THAN }, + { "#$attribute", AttributePredicate.Operator.LESS_THAN_OR_EQUAL }, }); } @Test public void attributePredicateImplTest() { String attributeValueStr = ""; - AttributePredicateImpl attributePredicateStr = new AttributePredicateImpl<>(attributeName, attributeValueStr); + AttributePredicate attributePredicateStr = new AttributePredicate<>(attributeName, attributeValueStr); Assert.assertEquals("Actual and expected values are not the same!", attributeName, attributePredicateStr.getAttributeName()); Assert.assertEquals("Actual and expected values are not the same!", attributeValueStr, attributePredicateStr.getAttributeValue()); Integer attributeValueInt = 1234567890; - AttributePredicateImpl attributePredicateInt = new AttributePredicateImpl<>(attributeName, attributeValueInt); + AttributePredicate attributePredicateInt = new AttributePredicate<>(attributeName, attributeValueInt); Assert.assertEquals("Actual and expected values are not the same!", attributeName, attributePredicateInt.getAttributeName()); Assert.assertEquals("Actual and expected values are not the same!", attributeValueInt, attributePredicateInt.getAttributeValue()); Double attributeValueDouble = 123.23d; - AttributePredicateImpl attributePredicateDouble = new AttributePredicateImpl<>(attributeName, attributeValueDouble); + AttributePredicate attributePredicateDouble = new AttributePredicate<>(attributeName, attributeValueDouble); Assert.assertEquals("Actual and expected values are not the same!", attributeName, attributePredicateDouble.getAttributeName()); Assert.assertEquals("Actual and expected values are not the same!", attributeValueDouble, attributePredicateDouble.getAttributeValue()); Character attributeValueChar = 'a'; - AttributePredicateImpl attributePredicateChar = new AttributePredicateImpl<>(attributeName, attributeValueChar); + AttributePredicate attributePredicateChar = new AttributePredicate<>(attributeName, attributeValueChar); Assert.assertEquals("Actual and expected values are not the same!", attributeName, attributePredicateChar.getAttributeName()); Assert.assertEquals("Actual and expected values are not the same!", attributeValueChar, attributePredicateChar.getAttributeValue()); Long attributeValueLong = 12345678910L; - AttributePredicateImpl attributePredicateLong = new AttributePredicateImpl<>(attributeName, attributeValueLong); + AttributePredicate attributePredicateLong = new AttributePredicate<>(attributeName, attributeValueLong); Assert.assertEquals("Actual and expected values are not the same!", attributeName, attributePredicateLong.getAttributeName()); Assert.assertEquals("Actual and expected values are not the same!", attributeValueLong, attributePredicateLong.getAttributeValue()); - AttributePredicateImpl attributePredicateBooleanTrue = new AttributePredicateImpl<>(attributeName, true); + AttributePredicate attributePredicateBooleanTrue = new AttributePredicate<>(attributeName, true); Assert.assertEquals("Actual and expected values are not the same!", attributeName, attributePredicateBooleanTrue.getAttributeName()); Assert.assertEquals("Actual and expected values are not the same!", true, attributePredicateBooleanTrue.getAttributeValue()); - AttributePredicateImpl attributePredicateBooleanFalse = new AttributePredicateImpl<>(attributeName, false); + AttributePredicate attributePredicateBooleanFalse = new AttributePredicate<>(attributeName, false); Assert.assertEquals("Actual and expected values are not the same!", attributeName, attributePredicateBooleanFalse.getAttributeName()); Assert.assertEquals("Actual and expected values are not the same!", false, attributePredicateBooleanFalse.getAttributeValue()); Short attributeValueShort = Short.MAX_VALUE; - AttributePredicateImpl attributePredicateShort = new AttributePredicateImpl<>(attributeName, attributeValueShort); + AttributePredicate attributePredicateShort = new AttributePredicate<>(attributeName, attributeValueShort); Assert.assertEquals("Actual and expected values are not the same!", attributeName, attributePredicateShort.getAttributeName()); Assert.assertEquals("Actual and expected values are not the same!", attributeValueShort, attributePredicateShort.getAttributeValue()); Float attributeValueFloat = 123.23f; - AttributePredicateImpl attributePredicateFloat = new AttributePredicateImpl<>(attributeName, attributeValueFloat); + AttributePredicate attributePredicateFloat = new AttributePredicate<>(attributeName, attributeValueFloat); Assert.assertEquals("Actual and expected values are not the same!", attributeName, attributePredicateFloat.getAttributeName()); Assert.assertEquals("Actual and expected values are not the same!", attributeValueFloat, attributePredicateFloat.getAttributeValue()); } @Test public void getOperatorTest() { - AttributePredicate attributePredicate = new AttributePredicateImpl<>(attributeName, 1234567890, operator); + AttributePredicate attributePredicate = new AttributePredicate<>(attributeName, 1234567890, operator); Assert.assertEquals("Actual and expected values are not the same!", operator, attributePredicate.getOperator()); } } diff --git a/commons/src/test/java/org/eclipse/kapua/commons/model/query/predicate/OrPredicateImplTest.java b/commons/src/test/java/org/eclipse/kapua/commons/model/query/predicate/OrPredicateTest.java similarity index 68% rename from commons/src/test/java/org/eclipse/kapua/commons/model/query/predicate/OrPredicateImplTest.java rename to commons/src/test/java/org/eclipse/kapua/commons/model/query/predicate/OrPredicateTest.java index 87bc1c4aa5d..61d5d7920d8 100644 --- a/commons/src/test/java/org/eclipse/kapua/commons/model/query/predicate/OrPredicateImplTest.java +++ b/commons/src/test/java/org/eclipse/kapua/commons/model/query/predicate/OrPredicateTest.java @@ -12,37 +12,37 @@ *******************************************************************************/ package org.eclipse.kapua.commons.model.query.predicate; +import java.util.ArrayList; + +import org.eclipse.kapua.model.query.predicate.OrPredicate; import org.eclipse.kapua.model.query.predicate.QueryPredicate; import org.eclipse.kapua.qa.markers.junit.JUnitTests; import org.junit.Assert; import org.junit.Test; import org.junit.experimental.categories.Category; -import java.util.ArrayList; - - @Category(JUnitTests.class) -public class OrPredicateImplTest { +public class OrPredicateTest { @Test public void orPredicateImplGetPredicateTest() { - OrPredicateImpl orPredicate = new OrPredicateImpl(); + OrPredicate orPredicate = new OrPredicate(); ArrayList array = new ArrayList<>(); Assert.assertEquals("Actual and expected values are not the same!", array, orPredicate.getPredicates()); } @Test(expected = NullPointerException.class) public void orPredicateImplQueryPredicateId() { - OrPredicateImpl orPredicateNull = new OrPredicateImpl(null); + OrPredicate orPredicateNull = new OrPredicate(null); Assert.assertNull(orPredicateNull.getPredicates().get(0)); - QueryPredicate queryPredicate = new OrPredicateImpl(); - OrPredicateImpl orPredicate = new OrPredicateImpl(queryPredicate); + QueryPredicate queryPredicate = new OrPredicate(); + OrPredicate orPredicate = new OrPredicate(queryPredicate); Assert.assertEquals("Actual and expected values are not the same!", queryPredicate, orPredicate.getPredicates().get(0)); - QueryPredicate queryPredicate1 = new OrPredicateImpl(); - QueryPredicate queryPredicate2 = new OrPredicateImpl(); - QueryPredicate queryPredicate3 = new OrPredicateImpl(); - QueryPredicate[] array = {queryPredicate1, queryPredicate2, queryPredicate3}; - OrPredicateImpl orPredicateWithMultiplePredicates = new OrPredicateImpl(queryPredicate1, queryPredicate2, queryPredicate3); + QueryPredicate queryPredicate1 = new OrPredicate(); + QueryPredicate queryPredicate2 = new OrPredicate(); + QueryPredicate queryPredicate3 = new OrPredicate(); + QueryPredicate[] array = { queryPredicate1, queryPredicate2, queryPredicate3 }; + OrPredicate orPredicateWithMultiplePredicates = new OrPredicate(queryPredicate1, queryPredicate2, queryPredicate3); for (int i = 0; i < array.length; i++) { Assert.assertEquals("Actual and expected values are not the same!", array[i], orPredicateWithMultiplePredicates.getPredicates().get(i)); } @@ -50,15 +50,15 @@ public void orPredicateImplQueryPredicateId() { @Test public void orTest() { - OrPredicateImpl orPredicate = new OrPredicateImpl(); - QueryPredicate queryPredicate = new OrPredicateImpl(); + OrPredicate orPredicate = new OrPredicate(); + QueryPredicate queryPredicate = new OrPredicate(); orPredicate.or(queryPredicate); Assert.assertEquals("Actual and expected values are not the same!", queryPredicate, orPredicate.getPredicates().get(0)); } @Test public void orWithNullPredicateTest() { - OrPredicateImpl orPredicate = new OrPredicateImpl(); + OrPredicate orPredicate = new OrPredicate(); orPredicate.or(null); Assert.assertNull(orPredicate.getPredicates().get(0)); } diff --git a/commons/src/test/java/org/eclipse/kapua/commons/service/event/store/internal/EventStoreFactoryImplTest.java b/commons/src/test/java/org/eclipse/kapua/commons/service/event/store/internal/EventStoreFactoryImplTest.java index e112a27e521..8b70a247bed 100644 --- a/commons/src/test/java/org/eclipse/kapua/commons/service/event/store/internal/EventStoreFactoryImplTest.java +++ b/commons/src/test/java/org/eclipse/kapua/commons/service/event/store/internal/EventStoreFactoryImplTest.java @@ -50,17 +50,6 @@ public void newCreatorTest() { } } - @Test - public void newQueryTest() { - EventStoreFactoryImpl eventStoreFactoryImpl = new EventStoreFactoryImpl(); - KapuaId[] scopeIdList = { null, new KapuaEid(BigInteger.ONE) }; - - for (KapuaId scopeId : scopeIdList) { - Assert.assertNotNull("Null not expected.", eventStoreFactoryImpl.newQuery(scopeId)); - Assert.assertThat("EventStoreQueryImpl object expected.", eventStoreFactoryImpl.newQuery(scopeId), IsInstanceOf.instanceOf(EventStoreQueryImpl.class)); - } - } - @Test public void cloneTest() { EventStoreFactoryImpl eventStoreFactoryImpl = new EventStoreFactoryImpl(); diff --git a/commons/src/test/java/org/eclipse/kapua/commons/service/event/store/internal/EventStoreQueryImplTest.java b/commons/src/test/java/org/eclipse/kapua/commons/service/event/store/internal/EventStoreQueryImplTest.java deleted file mode 100644 index 4f5eaefa8bc..00000000000 --- a/commons/src/test/java/org/eclipse/kapua/commons/service/event/store/internal/EventStoreQueryImplTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2020, 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.service.event.store.internal; - -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.model.id.KapuaIdImpl; -import org.eclipse.kapua.qa.markers.junit.JUnitTests; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -import java.math.BigInteger; - - -@Category(JUnitTests.class) -public class EventStoreQueryImplTest { - - @Test - public void eventStoreQueryImplTest1() { - EventStoreQueryImpl eventStoreQueryImpl = new EventStoreQueryImpl(); - Assert.assertNull("query.sortCriteria", eventStoreQueryImpl.getSortCriteria()); - Assert.assertNotNull("query.defaultSortCriteria", eventStoreQueryImpl.getDefaultSortCriteria()); - } - - @Test - public void eventStoreQueryImplTest2() { - KapuaId scopeId = new KapuaIdImpl(BigInteger.ONE); - - EventStoreQueryImpl eventStoreQueryImpl1 = new EventStoreQueryImpl(null); - Assert.assertNull("query.sortCriteria", eventStoreQueryImpl1.getSortCriteria()); - Assert.assertNotNull("query.defaultSortCriteria", eventStoreQueryImpl1.getDefaultSortCriteria()); - Assert.assertNull("Null expected.", eventStoreQueryImpl1.getScopeId()); - - EventStoreQueryImpl eventStoreQueryImpl2 = new EventStoreQueryImpl(scopeId); - Assert.assertNull("query.sortCriteria", eventStoreQueryImpl2.getSortCriteria()); - Assert.assertNotNull("query.defaultSortCriteria", eventStoreQueryImpl2.getDefaultSortCriteria()); - Assert.assertEquals("Expected and actual values should be the same.", scopeId, eventStoreQueryImpl2.getScopeId()); - } -} diff --git a/console/module/account/src/main/java/org/eclipse/kapua/app/console/module/account/server/GwtAccountServiceImpl.java b/console/module/account/src/main/java/org/eclipse/kapua/app/console/module/account/server/GwtAccountServiceImpl.java index 36184b8f23e..9323f407d0d 100644 --- a/console/module/account/src/main/java/org/eclipse/kapua/app/console/module/account/server/GwtAccountServiceImpl.java +++ b/console/module/account/src/main/java/org/eclipse/kapua/app/console/module/account/server/GwtAccountServiceImpl.java @@ -12,12 +12,26 @@ *******************************************************************************/ package org.eclipse.kapua.app.console.module.account.server; -import com.extjs.gxt.ui.client.data.BaseListLoadResult; -import com.extjs.gxt.ui.client.data.BasePagingLoadResult; -import com.extjs.gxt.ui.client.data.ListLoadResult; -import com.extjs.gxt.ui.client.data.PagingLoadConfig; -import com.extjs.gxt.ui.client.data.PagingLoadResult; -import com.google.common.collect.Sets; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.URL; +import java.net.URLConnection; +import java.security.MessageDigest; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Properties; +import java.util.concurrent.Callable; + +import javax.xml.namespace.QName; + import org.apache.commons.codec.binary.Base64; import org.apache.commons.imaging.ImageFormat; import org.apache.commons.imaging.ImageFormats; @@ -52,11 +66,11 @@ import org.eclipse.kapua.model.domain.Actions; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.model.query.KapuaListResult; +import org.eclipse.kapua.model.query.KapuaQuery; import org.eclipse.kapua.service.KapuaService; import org.eclipse.kapua.service.account.Account; import org.eclipse.kapua.service.account.AccountCreator; import org.eclipse.kapua.service.account.AccountFactory; -import org.eclipse.kapua.service.account.AccountQuery; import org.eclipse.kapua.service.account.AccountService; import org.eclipse.kapua.service.authorization.AuthorizationService; import org.eclipse.kapua.service.authorization.exception.SubjectUnauthorizedException; @@ -73,28 +87,17 @@ import org.eclipse.kapua.service.user.User; import org.eclipse.kapua.service.user.UserFactory; import org.eclipse.kapua.service.user.UserListResult; +import org.eclipse.kapua.service.user.UserQuery; import org.eclipse.kapua.service.user.UserService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.xml.namespace.QName; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.URL; -import java.net.URLConnection; -import java.security.MessageDigest; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Properties; -import java.util.concurrent.Callable; +import com.extjs.gxt.ui.client.data.BaseListLoadResult; +import com.extjs.gxt.ui.client.data.BasePagingLoadResult; +import com.extjs.gxt.ui.client.data.ListLoadResult; +import com.extjs.gxt.ui.client.data.PagingLoadConfig; +import com.extjs.gxt.ui.client.data.PagingLoadResult; +import com.google.common.collect.Sets; /** * The server side implementation of the RPC service. @@ -207,12 +210,12 @@ public ListLoadResult getAccountInfo(String scopeIdString, Str try { final Account account = ACCOUNT_SERVICE.find(scopeId, accountId); -//TODO: #LAYER_VIOLATION - user lookup should not be done here + //TODO: #LAYER_VIOLATION - user lookup should not be done here UserListResult userListResult = KapuaSecurityUtils.doPrivileged(new Callable() { @Override public UserListResult call() throws Exception { - return USER_SERVICE.query(USER_FACTORY.newQuery(null)); + return USER_SERVICE.query(new UserQuery(null)); } }); @@ -366,7 +369,7 @@ public ListLoadResult findAll(String scopeIdString) List gwtAccountList = new ArrayList(); KapuaId scopeId = KapuaEid.parseCompactId(scopeIdString); try { - AccountQuery query = ACCOUNT_FACTORY.newQuery(scopeId); + KapuaQuery query = new KapuaQuery(scopeId); KapuaListResult list = ACCOUNT_SERVICE.query(query); for (Account account : list.getItems()) { @@ -389,7 +392,7 @@ public ListLoadResult findChildren(String parentAccountId, boolean i if (includeSelf) { gwtAccountList.add(find(parentAccountId)); } - AccountQuery query = ACCOUNT_FACTORY.newQuery(scopeId); + KapuaQuery query = new KapuaQuery(scopeId); KapuaListResult list = ACCOUNT_SERVICE.query(query); for (Account account : list.getItems()) { @@ -490,7 +493,7 @@ public List findServiceConfigurations(String scopeId) throws strValues.add(v.toString()); } } - gwtParam.setValues(strValues.toArray(new String[]{})); + gwtParam.setValues(strValues.toArray(new String[] {})); } } } @@ -666,7 +669,7 @@ public PagingLoadResult query(PagingLoadConfig loadConfig, GwtAccoun int totalLength = 0; List gwtAccounts = new ArrayList(); try { - AccountQuery query = GwtKapuaAccountModelConverter.convertAccountQuery(loadConfig, gwtAccountQuery); + KapuaQuery query = GwtKapuaAccountModelConverter.convertAccountQuery(loadConfig, gwtAccountQuery); KapuaListResult accounts = ACCOUNT_SERVICE.query(query); totalLength = accounts.getTotalCount().intValue(); @@ -676,7 +679,7 @@ public PagingLoadResult query(PagingLoadConfig loadConfig, GwtAccoun @Override public UserListResult call() throws Exception { - return USER_SERVICE.query(USER_FACTORY.newQuery(null)); + return USER_SERVICE.query(new UserQuery(null)); } }); diff --git a/console/module/account/src/main/java/org/eclipse/kapua/app/console/module/account/shared/util/GwtKapuaAccountModelConverter.java b/console/module/account/src/main/java/org/eclipse/kapua/app/console/module/account/shared/util/GwtKapuaAccountModelConverter.java index 646263ad66b..666c0b4ef43 100644 --- a/console/module/account/src/main/java/org/eclipse/kapua/app/console/module/account/shared/util/GwtKapuaAccountModelConverter.java +++ b/console/module/account/src/main/java/org/eclipse/kapua/app/console/module/account/shared/util/GwtKapuaAccountModelConverter.java @@ -12,30 +12,31 @@ *******************************************************************************/ package org.eclipse.kapua.app.console.module.account.shared.util; -import com.extjs.gxt.ui.client.Style.SortDir; -import com.extjs.gxt.ui.client.data.PagingLoadConfig; import org.apache.commons.lang3.StringUtils; import org.eclipse.kapua.app.console.module.account.shared.model.GwtAccountQuery; import org.eclipse.kapua.app.console.module.api.shared.util.GwtKapuaCommonsModelConverter; import org.eclipse.kapua.locator.KapuaLocator; import org.eclipse.kapua.model.query.FieldSortCriteria; +import org.eclipse.kapua.model.query.KapuaQuery; import org.eclipse.kapua.model.query.SortOrder; import org.eclipse.kapua.model.query.predicate.AndPredicate; import org.eclipse.kapua.model.query.predicate.AttributePredicate.Operator; import org.eclipse.kapua.service.account.AccountAttributes; import org.eclipse.kapua.service.account.AccountFactory; -import org.eclipse.kapua.service.account.AccountQuery; + +import com.extjs.gxt.ui.client.Style.SortDir; +import com.extjs.gxt.ui.client.data.PagingLoadConfig; public class GwtKapuaAccountModelConverter { private GwtKapuaAccountModelConverter() { } - public static AccountQuery convertAccountQuery(PagingLoadConfig loadConfig, GwtAccountQuery gwtAccountQuery) { + public static KapuaQuery convertAccountQuery(PagingLoadConfig loadConfig, GwtAccountQuery gwtAccountQuery) { KapuaLocator locator = KapuaLocator.getInstance(); AccountFactory factory = locator.getFactory(AccountFactory.class); - AccountQuery query = factory.newQuery(GwtKapuaCommonsModelConverter.convertKapuaId(gwtAccountQuery.getScopeId())); + KapuaQuery query = new KapuaQuery(GwtKapuaCommonsModelConverter.convertKapuaId(gwtAccountQuery.getScopeId())); AndPredicate predicate = query.andPredicate(); diff --git a/console/module/authentication/src/main/java/org/eclipse/kapua/app/console/module/authentication/server/GwtCredentialServiceImpl.java b/console/module/authentication/src/main/java/org/eclipse/kapua/app/console/module/authentication/server/GwtCredentialServiceImpl.java index d17ec5c0d06..cf26b3cd876 100644 --- a/console/module/authentication/src/main/java/org/eclipse/kapua/app/console/module/authentication/server/GwtCredentialServiceImpl.java +++ b/console/module/authentication/src/main/java/org/eclipse/kapua/app/console/module/authentication/server/GwtCredentialServiceImpl.java @@ -12,9 +12,12 @@ *******************************************************************************/ package org.eclipse.kapua.app.console.module.authentication.server; -import com.extjs.gxt.ui.client.data.BasePagingLoadResult; -import com.extjs.gxt.ui.client.data.PagingLoadConfig; -import com.extjs.gxt.ui.client.data.PagingLoadResult; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; +import java.util.concurrent.Callable; + import org.apache.shiro.SecurityUtils; import org.apache.shiro.authc.AuthenticationException; import org.eclipse.kapua.KapuaException; @@ -32,6 +35,7 @@ import org.eclipse.kapua.commons.security.KapuaSecurityUtils; import org.eclipse.kapua.locator.KapuaLocator; import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.model.query.KapuaQuery; import org.eclipse.kapua.service.authentication.AuthenticationService; import org.eclipse.kapua.service.authentication.CredentialsFactory; import org.eclipse.kapua.service.authentication.UsernamePasswordCredentials; @@ -39,7 +43,6 @@ import org.eclipse.kapua.service.authentication.credential.CredentialCreator; import org.eclipse.kapua.service.authentication.credential.CredentialFactory; import org.eclipse.kapua.service.authentication.credential.CredentialListResult; -import org.eclipse.kapua.service.authentication.credential.CredentialQuery; import org.eclipse.kapua.service.authentication.credential.CredentialService; import org.eclipse.kapua.service.authentication.shiro.utils.AuthenticationUtils; import org.eclipse.kapua.service.authentication.user.PasswordChangeRequest; @@ -49,13 +52,12 @@ import org.eclipse.kapua.service.user.User; import org.eclipse.kapua.service.user.UserFactory; import org.eclipse.kapua.service.user.UserListResult; +import org.eclipse.kapua.service.user.UserQuery; import org.eclipse.kapua.service.user.UserService; -import java.util.ArrayList; -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; -import java.util.concurrent.Callable; +import com.extjs.gxt.ui.client.data.BasePagingLoadResult; +import com.extjs.gxt.ui.client.data.PagingLoadConfig; +import com.extjs.gxt.ui.client.data.PagingLoadResult; public class GwtCredentialServiceImpl extends KapuaRemoteServiceServlet implements GwtCredentialService { @@ -87,7 +89,7 @@ public PagingLoadResult query(PagingLoadConfig loadConfig, final try { // Convert from GWT entity - CredentialQuery credentialQuery = GwtKapuaAuthenticationModelConverter.convertCredentialQuery(loadConfig, gwtCredentialQuery); + KapuaQuery credentialQuery = GwtKapuaAuthenticationModelConverter.convertCredentialQuery(loadConfig, gwtCredentialQuery); // query CredentialListResult credentials = CREDENTIAL_SERVICE.query(credentialQuery); @@ -101,7 +103,7 @@ public PagingLoadResult query(PagingLoadConfig loadConfig, final @Override public UserListResult call() throws Exception { - return USER_SERVICE.query(USER_FACTORY.newQuery(GwtKapuaCommonsModelConverter.convertKapuaId(gwtCredentialQuery.getScopeId()))); + return USER_SERVICE.query(new UserQuery(GwtKapuaCommonsModelConverter.convertKapuaId(gwtCredentialQuery.getScopeId()))); } }); @@ -223,7 +225,6 @@ public User call() throws Exception { } } - @Override public void resetPassword(GwtXSRFToken gwtXsrfToken, String stringScopeId, String gwtCredentialId, final String newPassword) throws GwtKapuaException { checkXSRFToken(gwtXsrfToken); @@ -240,7 +241,6 @@ public void resetPassword(GwtXSRFToken gwtXsrfToken, String stringScopeId, Strin } } - @Override public void unlock(GwtXSRFToken xsrfToken, String stringScopeId, String gwtCredentialId) throws GwtKapuaException { diff --git a/console/module/authentication/src/main/java/org/eclipse/kapua/app/console/module/authentication/shared/util/GwtKapuaAuthenticationModelConverter.java b/console/module/authentication/src/main/java/org/eclipse/kapua/app/console/module/authentication/shared/util/GwtKapuaAuthenticationModelConverter.java index d895a0d4cd9..c8c8372c718 100644 --- a/console/module/authentication/src/main/java/org/eclipse/kapua/app/console/module/authentication/shared/util/GwtKapuaAuthenticationModelConverter.java +++ b/console/module/authentication/src/main/java/org/eclipse/kapua/app/console/module/authentication/shared/util/GwtKapuaAuthenticationModelConverter.java @@ -12,9 +12,6 @@ *******************************************************************************/ package org.eclipse.kapua.app.console.module.authentication.shared.util; -import com.extjs.gxt.ui.client.Style.SortDir; -import com.extjs.gxt.ui.client.data.BaseModel; -import com.extjs.gxt.ui.client.data.PagingLoadConfig; import org.apache.commons.lang3.StringUtils; import org.eclipse.kapua.app.console.module.api.shared.util.GwtKapuaCommonsModelConverter; import org.eclipse.kapua.app.console.module.authentication.shared.model.GwtCredential; @@ -26,17 +23,21 @@ import org.eclipse.kapua.model.KapuaEntity; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.model.query.FieldSortCriteria; +import org.eclipse.kapua.model.query.KapuaQuery; import org.eclipse.kapua.model.query.SortOrder; import org.eclipse.kapua.model.query.predicate.AndPredicate; import org.eclipse.kapua.service.authentication.credential.Credential; import org.eclipse.kapua.service.authentication.credential.CredentialAttributes; import org.eclipse.kapua.service.authentication.credential.CredentialCreator; import org.eclipse.kapua.service.authentication.credential.CredentialFactory; -import org.eclipse.kapua.service.authentication.credential.CredentialQuery; import org.eclipse.kapua.service.authentication.credential.CredentialStatus; import org.eclipse.kapua.service.authentication.credential.mfa.MfaOptionCreator; import org.eclipse.kapua.service.authentication.credential.mfa.MfaOptionFactory; +import com.extjs.gxt.ui.client.Style.SortDir; +import com.extjs.gxt.ui.client.data.BaseModel; +import com.extjs.gxt.ui.client.data.PagingLoadConfig; + /** * Utility class for convertKapuaId {@link BaseModel}s to {@link KapuaEntity}ies and other Kapua models */ @@ -51,16 +52,18 @@ private GwtKapuaAuthenticationModelConverter() { } /** - * Converts a {@link GwtCredentialQuery} into a {@link CredentialQuery} object for backend usage + * Converts a {@link GwtCredentialQuery} into a {@link KapuaQuery} object for backend usage * - * @param loadConfig the load configuration - * @param gwtCredentialQuery the {@link GwtCredentialQuery} to convertKapuaId - * @return the converted {@link CredentialQuery} + * @param loadConfig + * the load configuration + * @param gwtCredentialQuery + * the {@link GwtCredentialQuery} to convertKapuaId + * @return the converted {@link KapuaQuery} */ - public static CredentialQuery convertCredentialQuery(PagingLoadConfig loadConfig, GwtCredentialQuery gwtCredentialQuery) { + public static KapuaQuery convertCredentialQuery(PagingLoadConfig loadConfig, GwtCredentialQuery gwtCredentialQuery) { // Convert query - CredentialQuery query = CREDENTIAL_FACTORY.newQuery(GwtKapuaCommonsModelConverter.convertKapuaId(gwtCredentialQuery.getScopeId())); + KapuaQuery query = new KapuaQuery(GwtKapuaCommonsModelConverter.convertKapuaId(gwtCredentialQuery.getScopeId())); AndPredicate andPredicate = query.andPredicate(); if (gwtCredentialQuery.getUserId() != null && !gwtCredentialQuery.getUserId().trim().isEmpty()) { @@ -93,7 +96,8 @@ public static CredentialQuery convertCredentialQuery(PagingLoadConfig loadConfig /** * Converts a {@link GwtCredentialCreator} into a {@link CredentialCreator} object for backend usage * - * @param gwtCredentialCreator the {@link GwtCredentialCreator} to convertKapuaId + * @param gwtCredentialCreator + * the {@link GwtCredentialCreator} to convertKapuaId * @return the converted {@link CredentialCreator} */ public static CredentialCreator convertCredentialCreator(GwtCredentialCreator gwtCredentialCreator) { @@ -114,7 +118,8 @@ public static CredentialCreator convertCredentialCreator(GwtCredentialCreator gw /** * Converts a {@link GwtCredential} into a {@link Credential} object for backend usage * - * @param gwtCredential the {@link GwtCredential} to convertKapuaId + * @param gwtCredential + * the {@link GwtCredential} to convertKapuaId * @return the converted {@link Credential} */ public static Credential convertCredential(GwtCredential gwtCredential) { diff --git a/console/module/authorization/src/main/java/org/eclipse/kapua/app/console/module/authorization/server/GwtAccessPermissionServiceImpl.java b/console/module/authorization/src/main/java/org/eclipse/kapua/app/console/module/authorization/server/GwtAccessPermissionServiceImpl.java index 37221902f34..b4d7e12d3ab 100644 --- a/console/module/authorization/src/main/java/org/eclipse/kapua/app/console/module/authorization/server/GwtAccessPermissionServiceImpl.java +++ b/console/module/authorization/src/main/java/org/eclipse/kapua/app/console/module/authorization/server/GwtAccessPermissionServiceImpl.java @@ -12,10 +12,10 @@ *******************************************************************************/ package org.eclipse.kapua.app.console.module.authorization.server; -import com.extjs.gxt.ui.client.Style.SortDir; -import com.extjs.gxt.ui.client.data.BasePagingLoadResult; -import com.extjs.gxt.ui.client.data.PagingLoadConfig; -import com.extjs.gxt.ui.client.data.PagingLoadResult; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.Callable; + import org.apache.commons.lang3.StringUtils; import org.eclipse.kapua.app.console.module.api.client.GwtKapuaException; import org.eclipse.kapua.app.console.module.api.server.KapuaRemoteServiceServlet; @@ -32,6 +32,7 @@ import org.eclipse.kapua.model.KapuaEntityAttributes; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.model.query.FieldSortCriteria; +import org.eclipse.kapua.model.query.KapuaQuery; import org.eclipse.kapua.model.query.SortOrder; import org.eclipse.kapua.service.account.Account; import org.eclipse.kapua.service.account.AccountService; @@ -42,16 +43,16 @@ import org.eclipse.kapua.service.authorization.access.AccessPermissionCreator; import org.eclipse.kapua.service.authorization.access.AccessPermissionFactory; import org.eclipse.kapua.service.authorization.access.AccessPermissionListResult; -import org.eclipse.kapua.service.authorization.access.AccessPermissionQuery; import org.eclipse.kapua.service.authorization.access.AccessPermissionService; import org.eclipse.kapua.service.authorization.group.Group; import org.eclipse.kapua.service.authorization.group.GroupService; import org.eclipse.kapua.service.user.User; import org.eclipse.kapua.service.user.UserService; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.Callable; +import com.extjs.gxt.ui.client.Style.SortDir; +import com.extjs.gxt.ui.client.data.BasePagingLoadResult; +import com.extjs.gxt.ui.client.data.PagingLoadConfig; +import com.extjs.gxt.ui.client.data.PagingLoadResult; public class GwtAccessPermissionServiceImpl extends KapuaRemoteServiceServlet implements GwtAccessPermissionService { @@ -124,7 +125,7 @@ public PagingLoadResult findByUserId(PagingLoadConfig loadC AccessInfo accessInfo = ACCESS_INFO_SERVICE.findByUserId(scopeId, userId); if (accessInfo != null) { - AccessPermissionQuery query = ACCESS_PERMISSION_FACTORY.newQuery(scopeId); + final KapuaQuery query = new KapuaQuery(scopeId); query.setPredicate(query.attributePredicate(AccessPermissionAttributes.ACCESS_INFO_ID, accessInfo.getId())); query.setLimit(loadConfig.getLimit()); query.setOffset(loadConfig.getOffset()); diff --git a/console/module/authorization/src/main/java/org/eclipse/kapua/app/console/module/authorization/server/GwtAccessRoleServiceImpl.java b/console/module/authorization/src/main/java/org/eclipse/kapua/app/console/module/authorization/server/GwtAccessRoleServiceImpl.java index 54cf218c494..e71fa7d53f8 100644 --- a/console/module/authorization/src/main/java/org/eclipse/kapua/app/console/module/authorization/server/GwtAccessRoleServiceImpl.java +++ b/console/module/authorization/src/main/java/org/eclipse/kapua/app/console/module/authorization/server/GwtAccessRoleServiceImpl.java @@ -12,10 +12,10 @@ *******************************************************************************/ package org.eclipse.kapua.app.console.module.authorization.server; -import com.extjs.gxt.ui.client.Style.SortDir; -import com.extjs.gxt.ui.client.data.BasePagingLoadResult; -import com.extjs.gxt.ui.client.data.PagingLoadConfig; -import com.extjs.gxt.ui.client.data.PagingLoadResult; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.Callable; + import org.apache.commons.lang3.StringUtils; import org.eclipse.kapua.app.console.module.api.client.GwtKapuaException; import org.eclipse.kapua.app.console.module.api.server.KapuaRemoteServiceServlet; @@ -31,6 +31,7 @@ import org.eclipse.kapua.locator.KapuaLocator; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.model.query.FieldSortCriteria; +import org.eclipse.kapua.model.query.KapuaQuery; import org.eclipse.kapua.model.query.SortOrder; import org.eclipse.kapua.service.authorization.access.AccessInfo; import org.eclipse.kapua.service.authorization.access.AccessInfoService; @@ -40,16 +41,16 @@ import org.eclipse.kapua.service.authorization.access.AccessRoleCreator; import org.eclipse.kapua.service.authorization.access.AccessRoleFactory; import org.eclipse.kapua.service.authorization.access.AccessRoleListResult; -import org.eclipse.kapua.service.authorization.access.AccessRoleQuery; import org.eclipse.kapua.service.authorization.access.AccessRoleService; import org.eclipse.kapua.service.authorization.role.Role; import org.eclipse.kapua.service.authorization.role.RoleService; import org.eclipse.kapua.service.user.User; import org.eclipse.kapua.service.user.UserService; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.Callable; +import com.extjs.gxt.ui.client.Style.SortDir; +import com.extjs.gxt.ui.client.data.BasePagingLoadResult; +import com.extjs.gxt.ui.client.data.PagingLoadConfig; +import com.extjs.gxt.ui.client.data.PagingLoadResult; public class GwtAccessRoleServiceImpl extends KapuaRemoteServiceServlet implements GwtAccessRoleService { @@ -120,7 +121,7 @@ public PagingLoadResult findByUserId(PagingLoadConfig loadConfig, AccessInfo accessInfo = accessInfoService.findByUserId(scopeId, userId); if (accessInfo != null) { - AccessRoleQuery query = accessRoleFactory.newQuery(scopeId); + KapuaQuery query = new KapuaQuery(scopeId); query.setPredicate(query.attributePredicate(AccessPermissionAttributes.ACCESS_INFO_ID, accessInfo.getId())); query.setLimit(loadConfig.getLimit()); query.setOffset(loadConfig.getOffset()); diff --git a/console/module/authorization/src/main/java/org/eclipse/kapua/app/console/module/authorization/server/GwtDomainRegistryServiceImpl.java b/console/module/authorization/src/main/java/org/eclipse/kapua/app/console/module/authorization/server/GwtDomainRegistryServiceImpl.java index 3e4e58861fa..a786f466122 100644 --- a/console/module/authorization/src/main/java/org/eclipse/kapua/app/console/module/authorization/server/GwtDomainRegistryServiceImpl.java +++ b/console/module/authorization/src/main/java/org/eclipse/kapua/app/console/module/authorization/server/GwtDomainRegistryServiceImpl.java @@ -12,6 +12,10 @@ *******************************************************************************/ package org.eclipse.kapua.app.console.module.authorization.server; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + import org.eclipse.kapua.app.console.module.api.client.GwtKapuaException; import org.eclipse.kapua.app.console.module.api.server.KapuaRemoteServiceServlet; import org.eclipse.kapua.app.console.module.api.server.util.KapuaExceptionHandler; @@ -21,16 +25,13 @@ import org.eclipse.kapua.app.console.module.authorization.shared.util.KapuaGwtAuthorizationModelConverter; import org.eclipse.kapua.locator.KapuaLocator; import org.eclipse.kapua.model.domain.Actions; +import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.model.query.KapuaQuery; import org.eclipse.kapua.service.authorization.domain.Domain; import org.eclipse.kapua.service.authorization.domain.DomainFactory; import org.eclipse.kapua.service.authorization.domain.DomainListResult; -import org.eclipse.kapua.service.authorization.domain.DomainQuery; import org.eclipse.kapua.service.authorization.domain.DomainRegistryService; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - public class GwtDomainRegistryServiceImpl extends KapuaRemoteServiceServlet implements GwtDomainRegistryService { private static final long serialVersionUID = -699492835893299489L; @@ -39,12 +40,11 @@ public class GwtDomainRegistryServiceImpl extends KapuaRemoteServiceServlet impl private final DomainRegistryService domainRegistryService = locator.getService(DomainRegistryService.class); private final DomainFactory domainFactory = locator.getFactory(DomainFactory.class); - @Override public List findAll() throws GwtKapuaException { List gwtDomainList = new ArrayList(); try { - DomainQuery query = domainFactory.newQuery(null); + KapuaQuery query = new KapuaQuery((KapuaId) null); DomainListResult list = domainRegistryService.query(query); for (Domain domain : list.getItems()) { diff --git a/console/module/authorization/src/main/java/org/eclipse/kapua/app/console/module/authorization/server/GwtGroupServiceImpl.java b/console/module/authorization/src/main/java/org/eclipse/kapua/app/console/module/authorization/server/GwtGroupServiceImpl.java index 0268f08bc7e..636179e9782 100644 --- a/console/module/authorization/src/main/java/org/eclipse/kapua/app/console/module/authorization/server/GwtGroupServiceImpl.java +++ b/console/module/authorization/src/main/java/org/eclipse/kapua/app/console/module/authorization/server/GwtGroupServiceImpl.java @@ -12,11 +12,12 @@ *******************************************************************************/ package org.eclipse.kapua.app.console.module.authorization.server; -import com.extjs.gxt.ui.client.data.BaseListLoadResult; -import com.extjs.gxt.ui.client.data.BasePagingLoadResult; -import com.extjs.gxt.ui.client.data.ListLoadResult; -import com.extjs.gxt.ui.client.data.PagingLoadConfig; -import com.extjs.gxt.ui.client.data.PagingLoadResult; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.Callable; + import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.app.console.module.api.client.GwtKapuaException; import org.eclipse.kapua.app.console.module.api.server.KapuaRemoteServiceServlet; @@ -42,13 +43,14 @@ import org.eclipse.kapua.service.user.User; import org.eclipse.kapua.service.user.UserFactory; import org.eclipse.kapua.service.user.UserListResult; +import org.eclipse.kapua.service.user.UserQuery; import org.eclipse.kapua.service.user.UserService; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.Callable; +import com.extjs.gxt.ui.client.data.BaseListLoadResult; +import com.extjs.gxt.ui.client.data.BasePagingLoadResult; +import com.extjs.gxt.ui.client.data.ListLoadResult; +import com.extjs.gxt.ui.client.data.PagingLoadConfig; +import com.extjs.gxt.ui.client.data.PagingLoadResult; public class GwtGroupServiceImpl extends KapuaRemoteServiceServlet implements GwtGroupService { @@ -123,7 +125,7 @@ public GwtGroup find(String scopeShortId, String groupShortId) throws GwtKapuaEx @Override public PagingLoadResult query(PagingLoadConfig loadConfig, - final GwtGroupQuery gwtGroupQuery) throws GwtKapuaException { + final GwtGroupQuery gwtGroupQuery) throws GwtKapuaException { int totalLength = 0; List gwtGroupList = new ArrayList(); try { @@ -136,7 +138,7 @@ public PagingLoadResult query(PagingLoadConfig loadConfig, @Override public UserListResult call() throws Exception { - return USER_SERVICE.query(USER_FACTORY.newQuery(null)); + return USER_SERVICE.query(new UserQuery(null)); } }); @@ -174,7 +176,7 @@ public void delete(String scopeIdString, String groupIdString) throws GwtKapuaEx @Override public ListLoadResult getGroupDescription(String scopeShortId, - String groupShortId) throws GwtKapuaException { + String groupShortId) throws GwtKapuaException { List gwtGroupDescription = new ArrayList(); try { final KapuaId scopeId = KapuaEid.parseCompactId(scopeShortId); @@ -187,7 +189,7 @@ public ListLoadResult getGroupDescription(String scopeShortId, @Override public UserListResult call() throws Exception { - return USER_SERVICE.query(USER_FACTORY.newQuery(null)); + return USER_SERVICE.query(new UserQuery(null)); } }); @@ -216,7 +218,7 @@ public UserListResult call() throws Exception { @Override public List findAll(String scopeId) throws GwtKapuaException { List groupList = new ArrayList(); - GroupQuery query = GROUP_FACTORY.newQuery(GwtKapuaCommonsModelConverter.convertKapuaId(scopeId)); + GroupQuery query = new GroupQuery(GwtKapuaCommonsModelConverter.convertKapuaId(scopeId)); try { GroupListResult result = GROUP_SERVICE.query(query); for (Group group : result.getItems()) { diff --git a/console/module/authorization/src/main/java/org/eclipse/kapua/app/console/module/authorization/server/GwtRoleServiceImpl.java b/console/module/authorization/src/main/java/org/eclipse/kapua/app/console/module/authorization/server/GwtRoleServiceImpl.java index b9b117893fe..280df1b2100 100644 --- a/console/module/authorization/src/main/java/org/eclipse/kapua/app/console/module/authorization/server/GwtRoleServiceImpl.java +++ b/console/module/authorization/src/main/java/org/eclipse/kapua/app/console/module/authorization/server/GwtRoleServiceImpl.java @@ -12,12 +12,12 @@ *******************************************************************************/ package org.eclipse.kapua.app.console.module.authorization.server; -import com.extjs.gxt.ui.client.Style.SortDir; -import com.extjs.gxt.ui.client.data.BaseListLoadResult; -import com.extjs.gxt.ui.client.data.BasePagingLoadResult; -import com.extjs.gxt.ui.client.data.ListLoadResult; -import com.extjs.gxt.ui.client.data.PagingLoadConfig; -import com.extjs.gxt.ui.client.data.PagingLoadResult; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.Callable; + import org.apache.commons.lang3.StringUtils; import org.eclipse.kapua.app.console.module.api.client.GwtKapuaException; import org.eclipse.kapua.app.console.module.api.server.KapuaRemoteServiceServlet; @@ -40,6 +40,7 @@ import org.eclipse.kapua.model.KapuaEntityAttributes; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.model.query.FieldSortCriteria; +import org.eclipse.kapua.model.query.KapuaQuery; import org.eclipse.kapua.model.query.SortOrder; import org.eclipse.kapua.service.account.Account; import org.eclipse.kapua.service.account.AccountService; @@ -54,20 +55,21 @@ import org.eclipse.kapua.service.authorization.role.RolePermissionCreator; import org.eclipse.kapua.service.authorization.role.RolePermissionFactory; import org.eclipse.kapua.service.authorization.role.RolePermissionListResult; -import org.eclipse.kapua.service.authorization.role.RolePermissionQuery; import org.eclipse.kapua.service.authorization.role.RolePermissionService; import org.eclipse.kapua.service.authorization.role.RoleQuery; import org.eclipse.kapua.service.authorization.role.RoleService; import org.eclipse.kapua.service.user.User; import org.eclipse.kapua.service.user.UserFactory; import org.eclipse.kapua.service.user.UserListResult; +import org.eclipse.kapua.service.user.UserQuery; import org.eclipse.kapua.service.user.UserService; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.Callable; +import com.extjs.gxt.ui.client.Style.SortDir; +import com.extjs.gxt.ui.client.data.BaseListLoadResult; +import com.extjs.gxt.ui.client.data.BasePagingLoadResult; +import com.extjs.gxt.ui.client.data.ListLoadResult; +import com.extjs.gxt.ui.client.data.PagingLoadConfig; +import com.extjs.gxt.ui.client.data.PagingLoadResult; public class GwtRoleServiceImpl extends KapuaRemoteServiceServlet implements GwtRoleService { @@ -175,7 +177,7 @@ public PagingLoadResult query(PagingLoadConfig loadConfig, final GwtRol @Override public UserListResult call() throws Exception { - return USER_SERVICE.query(USER_FACTORY.newQuery(null)); + return USER_SERVICE.query(new UserQuery(null)); } }); @@ -215,7 +217,7 @@ public ListLoadResult getRoleDescription(String scopeShortId, @Override public UserListResult call() throws Exception { - return USER_SERVICE.query(USER_FACTORY.newQuery(null)); + return USER_SERVICE.query(new UserQuery(null)); } }); @@ -252,7 +254,7 @@ public PagingLoadResult getRolePermissions(PagingLoadConfig l KapuaId roleId = GwtKapuaCommonsModelConverter.convertKapuaId(roleShortId); // Get permissions assigned to the Role - RolePermissionQuery query = ROLE_PERMISSION_FACTORY.newQuery(scopeId); + KapuaQuery query = new KapuaQuery(scopeId); query.setPredicate(query.attributePredicate(RolePermissionAttributes.ROLE_ID, roleId)); query.setLimit(loadConfig.getLimit()); query.setOffset(loadConfig.getOffset()); @@ -372,7 +374,7 @@ public List findAll(String scopeIdString) throws GwtKapuaException { KapuaId scopeId = KapuaEid.parseCompactId(scopeIdString); List gwtRoleList = new ArrayList(); try { - RoleQuery query = ROLE_FACTORY.newQuery(scopeId); + RoleQuery query = new RoleQuery(scopeId); RoleListResult list = ROLE_SERVICE.query(query); for (Role role : list.getItems()) { diff --git a/console/module/authorization/src/main/java/org/eclipse/kapua/app/console/module/authorization/shared/util/GwtKapuaAuthorizationModelConverter.java b/console/module/authorization/src/main/java/org/eclipse/kapua/app/console/module/authorization/shared/util/GwtKapuaAuthorizationModelConverter.java index d692c1e08a5..8cef2834377 100644 --- a/console/module/authorization/src/main/java/org/eclipse/kapua/app/console/module/authorization/shared/util/GwtKapuaAuthorizationModelConverter.java +++ b/console/module/authorization/src/main/java/org/eclipse/kapua/app/console/module/authorization/shared/util/GwtKapuaAuthorizationModelConverter.java @@ -12,9 +12,9 @@ *******************************************************************************/ package org.eclipse.kapua.app.console.module.authorization.shared.util; -import com.extjs.gxt.ui.client.Style.SortDir; -import com.extjs.gxt.ui.client.data.BaseModel; -import com.extjs.gxt.ui.client.data.PagingLoadConfig; +import java.util.HashSet; +import java.util.Set; + import org.apache.commons.lang3.StringUtils; import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.KapuaIllegalArgumentException; @@ -22,7 +22,6 @@ import org.eclipse.kapua.app.console.module.authorization.shared.model.GwtAccessInfoCreator; import org.eclipse.kapua.app.console.module.authorization.shared.model.GwtAccessPermissionCreator; import org.eclipse.kapua.app.console.module.authorization.shared.model.GwtAccessRoleCreator; -import org.eclipse.kapua.app.console.module.authorization.shared.model.GwtAccessRoleQuery; import org.eclipse.kapua.app.console.module.authorization.shared.model.GwtDomain; import org.eclipse.kapua.app.console.module.authorization.shared.model.GwtGroupQuery; import org.eclipse.kapua.app.console.module.authorization.shared.model.GwtPermission; @@ -31,13 +30,13 @@ import org.eclipse.kapua.app.console.module.authorization.shared.model.GwtRoleCreator; import org.eclipse.kapua.app.console.module.authorization.shared.model.GwtRolePermission; import org.eclipse.kapua.app.console.module.authorization.shared.model.GwtRoleQuery; -import org.eclipse.kapua.commons.model.id.KapuaEid; import org.eclipse.kapua.locator.KapuaLocator; import org.eclipse.kapua.model.KapuaEntity; import org.eclipse.kapua.model.domain.Actions; import org.eclipse.kapua.model.domain.Domain; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.model.query.FieldSortCriteria; +import org.eclipse.kapua.model.query.KapuaQuery; import org.eclipse.kapua.model.query.SortOrder; import org.eclipse.kapua.model.query.predicate.AndPredicate; import org.eclipse.kapua.model.query.predicate.AttributePredicate.Operator; @@ -45,13 +44,10 @@ import org.eclipse.kapua.service.authorization.access.AccessInfoFactory; import org.eclipse.kapua.service.authorization.access.AccessPermissionCreator; import org.eclipse.kapua.service.authorization.access.AccessPermissionFactory; -import org.eclipse.kapua.service.authorization.access.AccessRoleAttributes; import org.eclipse.kapua.service.authorization.access.AccessRoleCreator; import org.eclipse.kapua.service.authorization.access.AccessRoleFactory; -import org.eclipse.kapua.service.authorization.access.AccessRoleQuery; import org.eclipse.kapua.service.authorization.domain.DomainFactory; import org.eclipse.kapua.service.authorization.domain.DomainListResult; -import org.eclipse.kapua.service.authorization.domain.DomainQuery; import org.eclipse.kapua.service.authorization.domain.DomainRegistryService; import org.eclipse.kapua.service.authorization.group.GroupAttributes; import org.eclipse.kapua.service.authorization.group.GroupFactory; @@ -66,8 +62,9 @@ import org.eclipse.kapua.service.authorization.role.RolePermissionFactory; import org.eclipse.kapua.service.authorization.role.RoleQuery; -import java.util.HashSet; -import java.util.Set; +import com.extjs.gxt.ui.client.Style.SortDir; +import com.extjs.gxt.ui.client.data.BaseModel; +import com.extjs.gxt.ui.client.data.PagingLoadConfig; /** * Utility class for convertKapuaId {@link BaseModel}s to {@link KapuaEntity}ies and other Kapua models @@ -83,11 +80,11 @@ private GwtKapuaAuthorizationModelConverter() { } public static GroupQuery convertGroupQuery(PagingLoadConfig loadConfig, - GwtGroupQuery gwtGroupQuery) { + GwtGroupQuery gwtGroupQuery) { KapuaLocator locator = KapuaLocator.getInstance(); GroupFactory groupFactory = locator.getFactory(GroupFactory.class); - GroupQuery query = groupFactory.newQuery(GwtKapuaCommonsModelConverter.convertKapuaId(gwtGroupQuery.getScopeId())); + GroupQuery query = new GroupQuery(GwtKapuaCommonsModelConverter.convertKapuaId(gwtGroupQuery.getScopeId())); AndPredicate predicate = query.andPredicate(); if (gwtGroupQuery.getName() != null && !gwtGroupQuery.getName().isEmpty()) { @@ -116,8 +113,10 @@ public static GroupQuery convertGroupQuery(PagingLoadConfig loadConfig, /** * Converts a {@link GwtRoleQuery} into a {@link Role} object for backend usage * - * @param loadConfig the load configuration - * @param gwtRoleQuery the {@link GwtRoleQuery} to convertKapuaId + * @param loadConfig + * the load configuration + * @param gwtRoleQuery + * the {@link GwtRoleQuery} to convertKapuaId * @return the converted {@link RoleQuery} */ public static RoleQuery convertRoleQuery(PagingLoadConfig loadConfig, GwtRoleQuery gwtRoleQuery) { @@ -127,7 +126,7 @@ public static RoleQuery convertRoleQuery(PagingLoadConfig loadConfig, GwtRoleQue RoleFactory roleFactory = locator.getFactory(RoleFactory.class); // Convert query - RoleQuery query = roleFactory.newQuery(GwtKapuaCommonsModelConverter.convertKapuaId(gwtRoleQuery.getScopeId())); + RoleQuery query = new RoleQuery(GwtKapuaCommonsModelConverter.convertKapuaId(gwtRoleQuery.getScopeId())); AndPredicate predicate = query.andPredicate(); @@ -154,25 +153,11 @@ public static RoleQuery convertRoleQuery(PagingLoadConfig loadConfig, GwtRoleQue return query; } - public static AccessRoleQuery convertAccessRoleQuery(PagingLoadConfig pagingLoadConfig, - GwtAccessRoleQuery gwtRoleQuery) { - - KapuaLocator locator = KapuaLocator.getInstance(); - AccessRoleFactory accessRoleFactory = locator.getFactory(AccessRoleFactory.class); - - AccessRoleQuery query = accessRoleFactory.newQuery(GwtKapuaCommonsModelConverter.convertKapuaId(gwtRoleQuery.getScopeId())); - query.setPredicate(query.attributePredicate(AccessRoleAttributes.ROLE_ID, KapuaEid.parseCompactId(gwtRoleQuery.getRoleId()))); - query.setOffset(pagingLoadConfig.getOffset()); - query.setLimit(pagingLoadConfig.getLimit()); - query.setAskTotalCount(gwtRoleQuery.getAskTotalCount()); - return query; - - } - /** * Converts a {@link GwtRole} into a {@link Role} object for backend usage * - * @param gwtRole the {@link GwtRole} to convertKapuaId + * @param gwtRole + * the {@link GwtRole} to convertKapuaId * @return the converted {@link Role} */ public static Role convertRole(GwtRole gwtRole) throws KapuaException { @@ -218,7 +203,8 @@ public static Role convertRole(GwtRole gwtRole) throws KapuaException { /** * Converts a {@link GwtRoleCreator} into a {@link RoleCreator} object for backend usage * - * @param gwtRoleCreator the {@link GwtRoleCreator} to convertKapuaId + * @param gwtRoleCreator + * the {@link GwtRoleCreator} to convertKapuaId * @return the converted {@link RoleCreator} */ public static RoleCreator convertRoleCreator(GwtRoleCreator gwtRoleCreator) throws KapuaException { @@ -251,7 +237,8 @@ public static RoleCreator convertRoleCreator(GwtRoleCreator gwtRoleCreator) thro /** * Converts a {@link GwtAccessRoleCreator} into a {@link AccessRoleCreator} object for backend usage * - * @param gwtAccessRoleCreator the {@link GwtAccessRoleCreator} to convertKapuaId + * @param gwtAccessRoleCreator + * the {@link GwtAccessRoleCreator} to convertKapuaId * @return the converted {@link AccessRoleCreator} * @since 1.0.0 */ @@ -277,7 +264,8 @@ public static AccessRoleCreator convertAccessRoleCreator(GwtAccessRoleCreator gw /** * Converts a {@link GwtAccessPermissionCreator} into a {@link AccessPermissionCreator} object for backend usage * - * @param gwtAccessPermissionCreator the {@link GwtAccessPermissionCreator} to convertKapuaId + * @param gwtAccessPermissionCreator + * the {@link GwtAccessPermissionCreator} to convertKapuaId * @return the converted {@link AccessPermissionCreator} * @since 1.0.0 */ @@ -318,7 +306,8 @@ public static AccessInfoCreator convertAccessInfoCreator(GwtAccessInfoCreator gw /** * Converts a {@link GwtPermission} into a {@link Permission} object for backend usage. * - * @param gwtPermission The {@link GwtPermission} to convertKapuaId. + * @param gwtPermission + * The {@link GwtPermission} to convertKapuaId. * @return The converted {@link Permission}. * @since 1.0.0 */ @@ -337,7 +326,8 @@ public static Permission convertPermission(GwtPermission gwtPermission) throws K /** * Converts a {@link GwtAction} into the related {@link Actions} * - * @param gwtAction the {@link GwtAction} to convertKapuaId + * @param gwtAction + * the {@link GwtAction} to convertKapuaId * @return the converted {@link Actions} * @since 1.0.0 */ @@ -346,24 +336,24 @@ public static Actions convertAction(GwtAction gwtAction) { Actions action = null; if (gwtAction != null) { switch (gwtAction) { - case connect: - action = Actions.connect; - break; - case delete: - action = Actions.delete; - break; - case execute: - action = Actions.execute; - break; - case read: - action = Actions.read; - break; - case write: - action = Actions.write; - break; - case ALL: - action = null; - break; + case connect: + action = Actions.connect; + break; + case delete: + action = Actions.delete; + break; + case execute: + action = Actions.execute; + break; + case read: + action = Actions.read; + break; + case write: + action = Actions.write; + break; + case ALL: + action = null; + break; } } return action; @@ -372,7 +362,8 @@ public static Actions convertAction(GwtAction gwtAction) { /** * Converts a {@link GwtDomain} into the related equivalent domain string * - * @param gwtDomain the {@link GwtDomain} to convertKapuaId + * @param gwtDomain + * the {@link GwtDomain} to convertKapuaId * @return the converted domain {@link String} * @since 1.0.0 */ @@ -384,8 +375,7 @@ public static Domain convertDomain(GwtDomain gwtDomain) throws KapuaException { return null; } - DomainQuery query = DOMAIN_FACTORY.newQuery(null); - DomainListResult list = DOMAIN_REGISTRY_SERVICE.query(query); + DomainListResult list = DOMAIN_REGISTRY_SERVICE.query(new KapuaQuery((KapuaId) null)); for (org.eclipse.kapua.service.authorization.domain.Domain domain : list.getItems()) { if (gwtDomainName.equals(domain.getName())) { diff --git a/console/module/certificate/src/main/java/org/eclipse/kapua/app/console/module/certificate/server/GwtCertificateInfoServiceImpl.java b/console/module/certificate/src/main/java/org/eclipse/kapua/app/console/module/certificate/server/GwtCertificateInfoServiceImpl.java index 5939b8a5214..8ac5802fc44 100644 --- a/console/module/certificate/src/main/java/org/eclipse/kapua/app/console/module/certificate/server/GwtCertificateInfoServiceImpl.java +++ b/console/module/certificate/src/main/java/org/eclipse/kapua/app/console/module/certificate/server/GwtCertificateInfoServiceImpl.java @@ -12,6 +12,9 @@ *******************************************************************************/ package org.eclipse.kapua.app.console.module.certificate.server; +import java.util.ArrayList; +import java.util.List; + import org.eclipse.kapua.app.console.module.api.client.GwtKapuaException; import org.eclipse.kapua.app.console.module.api.server.KapuaRemoteServiceServlet; import org.eclipse.kapua.app.console.module.api.server.util.KapuaExceptionHandler; @@ -29,9 +32,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.ArrayList; -import java.util.List; - public class GwtCertificateInfoServiceImpl extends KapuaRemoteServiceServlet implements GwtCertificateInfoService { private static final Logger LOG = LoggerFactory.getLogger(GwtCertificateInfoServiceImpl.class); @@ -48,7 +48,7 @@ public List findAll(String scopeIdString) throws GwtKapuaExc List gwtCertificateInfos = new ArrayList(); - CertificateInfoQuery query = CERTIFICATE_INFO_FACTORY.newQuery(scopeId); + CertificateInfoQuery query = new CertificateInfoQuery(scopeId); query.setIncludeInherited(true); CertificateInfoListResult certificateInfos = CERTIFICATE_INFO_SERVICE.query(query); diff --git a/console/module/data/src/main/java/org/eclipse/kapua/app/console/module/data/server/GwtDataServiceImpl.java b/console/module/data/src/main/java/org/eclipse/kapua/app/console/module/data/server/GwtDataServiceImpl.java index 23b430d4a45..7830c55d437 100644 --- a/console/module/data/src/main/java/org/eclipse/kapua/app/console/module/data/server/GwtDataServiceImpl.java +++ b/console/module/data/src/main/java/org/eclipse/kapua/app/console/module/data/server/GwtDataServiceImpl.java @@ -12,15 +12,14 @@ *******************************************************************************/ package org.eclipse.kapua.app.console.module.data.server; -import com.extjs.gxt.ui.client.Style; -import com.extjs.gxt.ui.client.data.BaseListLoadResult; -import com.extjs.gxt.ui.client.data.BasePagingLoadResult; -import com.extjs.gxt.ui.client.data.ListLoadResult; -import com.extjs.gxt.ui.client.data.LoadConfig; -import com.extjs.gxt.ui.client.data.ModelData; -import com.extjs.gxt.ui.client.data.PagingLoadConfig; -import com.extjs.gxt.ui.client.data.PagingLoadResult; -import com.google.common.base.Strings; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + import org.apache.commons.lang3.StringUtils; import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.app.console.module.api.client.GwtKapuaErrorCode; @@ -83,13 +82,15 @@ import org.eclipse.kapua.service.storable.model.query.predicate.StorablePredicate; import org.eclipse.kapua.service.storable.model.query.predicate.TermPredicate; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import com.extjs.gxt.ui.client.Style; +import com.extjs.gxt.ui.client.data.BaseListLoadResult; +import com.extjs.gxt.ui.client.data.BasePagingLoadResult; +import com.extjs.gxt.ui.client.data.ListLoadResult; +import com.extjs.gxt.ui.client.data.LoadConfig; +import com.extjs.gxt.ui.client.data.ModelData; +import com.extjs.gxt.ui.client.data.PagingLoadConfig; +import com.extjs.gxt.ui.client.data.PagingLoadResult; +import com.google.common.base.Strings; public class GwtDataServiceImpl extends KapuaRemoteServiceServlet implements GwtDataService { @@ -307,7 +308,7 @@ public PagingLoadResult findDevices(PagingLoadConfig config, for (ClientInfo client : result.getItems()) { clientIds.add(client.getClientId()); } - DeviceQuery deviceQuery = deviceFactory.newQuery(convertedScopeId); + DeviceQuery deviceQuery = new DeviceQuery(convertedScopeId); DeviceListResult deviceListResult = deviceRegistryService.query(deviceQuery); Map clientIdsMap = buildClientIdsMap(clientIds, deviceListResult); @@ -423,7 +424,8 @@ public PagingLoadResult findMessagesByDevice(PagingLoadConfig loadCo } @Override - public PagingLoadResult findMessagesByAssets(PagingLoadConfig loadConfig, String scopeId, GwtDatastoreDevice device, GwtDatastoreAsset asset, List headers, Date startDate, Date endDate) + public PagingLoadResult findMessagesByAssets(PagingLoadConfig loadConfig, String scopeId, GwtDatastoreDevice device, GwtDatastoreAsset asset, List headers, Date startDate, + Date endDate) throws GwtKapuaException { ChannelMatchPredicate assetPredicate = DATASTORE_PREDICATE_FACTORY.newChannelMatchPredicate(asset.getTopick()); TermPredicate devicePredicate = DATASTORE_PREDICATE_FACTORY.newTermPredicate(MessageField.CLIENT_ID, device.getDevice()); @@ -474,7 +476,8 @@ private PagingLoadResult findMessages(PagingLoadConfig loadConfig, S OrPredicate metricsPredicate = DATASTORE_PREDICATE_FACTORY.newOrPredicate(); for (GwtHeader header : headers) { try { - metricsPredicate.getPredicates().add(DATASTORE_PREDICATE_FACTORY.newMetricExistsPredicate(header.getName(), (Class) ObjectTypeConverter.fromString(header.getType().toLowerCase()))); + metricsPredicate.getPredicates() + .add(DATASTORE_PREDICATE_FACTORY.newMetricExistsPredicate(header.getName(), (Class) ObjectTypeConverter.fromString(header.getType().toLowerCase()))); } catch (ClassNotFoundException e) { throw new GwtKapuaException(GwtKapuaErrorCode.INTERNAL_ERROR, e); } diff --git a/console/module/data/src/main/java/org/eclipse/kapua/app/console/module/data/servlet/DataExporterServlet.java b/console/module/data/src/main/java/org/eclipse/kapua/app/console/module/data/servlet/DataExporterServlet.java index b6104829367..1dee2db3b0f 100644 --- a/console/module/data/src/main/java/org/eclipse/kapua/app/console/module/data/servlet/DataExporterServlet.java +++ b/console/module/data/src/main/java/org/eclipse/kapua/app/console/module/data/servlet/DataExporterServlet.java @@ -12,6 +12,16 @@ *******************************************************************************/ package org.eclipse.kapua.app.console.module.data.servlet; +import java.io.IOException; +import java.text.MessageFormat; +import java.util.Collections; +import java.util.Date; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + import org.eclipse.kapua.KapuaEntityNotFoundException; import org.eclipse.kapua.KapuaIllegalAccessException; import org.eclipse.kapua.KapuaUnauthenticatedException; @@ -34,15 +44,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.text.MessageFormat; -import java.util.Collections; -import java.util.Date; - public class DataExporterServlet extends HttpServlet { private static final long serialVersionUID = 226461063207179649L; diff --git a/console/module/device/src/main/java/org/eclipse/kapua/app/console/module/device/server/GwtDeviceConnectionServiceImpl.java b/console/module/device/src/main/java/org/eclipse/kapua/app/console/module/device/server/GwtDeviceConnectionServiceImpl.java index cd228fb84cf..1409f3ca7f9 100644 --- a/console/module/device/src/main/java/org/eclipse/kapua/app/console/module/device/server/GwtDeviceConnectionServiceImpl.java +++ b/console/module/device/src/main/java/org/eclipse/kapua/app/console/module/device/server/GwtDeviceConnectionServiceImpl.java @@ -12,11 +12,12 @@ *******************************************************************************/ package org.eclipse.kapua.app.console.module.device.server; -import com.extjs.gxt.ui.client.data.BaseListLoadResult; -import com.extjs.gxt.ui.client.data.BasePagingLoadResult; -import com.extjs.gxt.ui.client.data.ListLoadResult; -import com.extjs.gxt.ui.client.data.PagingLoadConfig; -import com.extjs.gxt.ui.client.data.PagingLoadResult; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.Callable; + import org.eclipse.kapua.app.console.module.api.client.GwtKapuaException; import org.eclipse.kapua.app.console.module.api.server.KapuaRemoteServiceServlet; import org.eclipse.kapua.app.console.module.api.server.util.KapuaExceptionHandler; @@ -46,16 +47,17 @@ import org.eclipse.kapua.service.user.UserQuery; import org.eclipse.kapua.service.user.UserService; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.Callable; +import com.extjs.gxt.ui.client.data.BaseListLoadResult; +import com.extjs.gxt.ui.client.data.BasePagingLoadResult; +import com.extjs.gxt.ui.client.data.ListLoadResult; +import com.extjs.gxt.ui.client.data.PagingLoadConfig; +import com.extjs.gxt.ui.client.data.PagingLoadResult; /** * The server side implementation of the RPC service. */ public class GwtDeviceConnectionServiceImpl extends KapuaRemoteServiceServlet implements GwtDeviceConnectionService { + private static final long serialVersionUID = 3314502846487119577L; private static final KapuaLocator LOCATOR = KapuaLocator.getInstance(); @@ -83,9 +85,9 @@ public PagingLoadResult query(PagingLoadConfig loadConfig, if (!deviceConnections.isEmpty()) { Map users = new HashMap(); - final UserQuery userQuery = USER_FACTORY.newQuery(GwtKapuaCommonsModelConverter.convertKapuaId(gwtDeviceConnectionQuery.getScopeId())); + final UserQuery userQuery = new UserQuery(GwtKapuaCommonsModelConverter.convertKapuaId(gwtDeviceConnectionQuery.getScopeId())); -//TODO: #LAYER_VIOLATION - user lookup logic should not be done here (fetching all users is incredibly inefficient anyway) + //TODO: #LAYER_VIOLATION - user lookup logic should not be done here (fetching all users is incredibly inefficient anyway) UserListResult userList = KapuaSecurityUtils.doPrivileged(new Callable() { @Override @@ -141,7 +143,7 @@ public ListLoadResult getConnectionInfo(String scopeIdString, List deviceConnectionPropertiesPairs = new ArrayList(); try { final DeviceConnection deviceConnection = DEVICE_CONNECTION_SERVICE.find(scopeId, deviceConnectionId); -//TODO: #LAYER_VIOLATION - user lookup logic should not be done here + //TODO: #LAYER_VIOLATION - user lookup logic should not be done here User connectionUser = KapuaSecurityUtils.doPrivileged(new Callable() { @Override @@ -190,7 +192,8 @@ public User call() throws Exception { gwtConnectionUserCouplingMode = GwtConnectionUserCouplingMode.valueOf(deviceConnection.getUserCouplingMode().name()); } deviceConnectionPropertiesPairs - .add(new GwtGroupedNVPair(CONNECTION_USER_COUPLING_MODE_INFO, "connectionUserCouplingMode", gwtConnectionUserCouplingMode != null ? gwtConnectionUserCouplingMode.getLabel() : null)); + .add(new GwtGroupedNVPair(CONNECTION_USER_COUPLING_MODE_INFO, "connectionUserCouplingMode", + gwtConnectionUserCouplingMode != null ? gwtConnectionUserCouplingMode.getLabel() : null)); if (AUTHORIZATION_SERVICE.isPermitted(PERMISSION_FACTORY.newPermission(Domains.USER, Actions.read, scopeId))) { deviceConnectionPropertiesPairs.add(new GwtGroupedNVPair(CONNECTION_USER_COUPLING_MODE_INFO, "connectionReservedUser", reservedUser != null ? reservedUser.getName() : null)); deviceConnectionPropertiesPairs.add(new GwtGroupedNVPair(CONNECTION_USER_COUPLING_MODE_INFO, "allowUserChange", deviceConnection.getAllowUserChange())); diff --git a/console/module/device/src/main/java/org/eclipse/kapua/app/console/module/device/server/GwtDeviceManagementOperationServiceImpl.java b/console/module/device/src/main/java/org/eclipse/kapua/app/console/module/device/server/GwtDeviceManagementOperationServiceImpl.java index 19615830b73..98cef3390a1 100644 --- a/console/module/device/src/main/java/org/eclipse/kapua/app/console/module/device/server/GwtDeviceManagementOperationServiceImpl.java +++ b/console/module/device/src/main/java/org/eclipse/kapua/app/console/module/device/server/GwtDeviceManagementOperationServiceImpl.java @@ -12,10 +12,9 @@ *******************************************************************************/ package org.eclipse.kapua.app.console.module.device.server; -import com.extjs.gxt.ui.client.data.BasePagingLoadResult; -import com.extjs.gxt.ui.client.data.PagingLoadConfig; -import com.extjs.gxt.ui.client.data.PagingLoadResult; -import com.google.common.base.Strings; +import java.util.ArrayList; +import java.util.List; + import org.eclipse.kapua.app.console.module.api.client.GwtKapuaException; import org.eclipse.kapua.app.console.module.api.server.KapuaRemoteServiceServlet; import org.eclipse.kapua.app.console.module.api.server.util.KapuaExceptionHandler; @@ -37,8 +36,10 @@ import org.eclipse.kapua.service.device.management.registry.operation.notification.ManagementOperationNotificationQuery; import org.eclipse.kapua.service.device.management.registry.operation.notification.ManagementOperationNotificationService; -import java.util.ArrayList; -import java.util.List; +import com.extjs.gxt.ui.client.data.BasePagingLoadResult; +import com.extjs.gxt.ui.client.data.PagingLoadConfig; +import com.extjs.gxt.ui.client.data.PagingLoadResult; +import com.google.common.base.Strings; /** * The server side implementation of the RPC service. @@ -69,7 +70,7 @@ public PagingLoadResult query(PagingLoadConfig loa if (dmo.getEndedOn() == null) { //TODO: #LAYER_VIOLATION - entity lookup should be done elsewhere - ManagementOperationNotificationQuery notificationQuery = MANAGEMENT_OPERATION_NOTIFICATION_FACTORY.newQuery(dmo.getScopeId()); + ManagementOperationNotificationQuery notificationQuery = new ManagementOperationNotificationQuery(dmo.getScopeId()); notificationQuery.setPredicate(notificationQuery.attributePredicate(ManagementOperationNotificationAttributes.OPERATION_ID, dmo.getId())); notificationQuery.setSortCriteria(notificationQuery.fieldSortCriteria(ManagementOperationNotificationAttributes.SENT_ON, SortOrder.ASCENDING)); diff --git a/console/module/device/src/main/java/org/eclipse/kapua/app/console/module/device/server/GwtDeviceServiceImpl.java b/console/module/device/src/main/java/org/eclipse/kapua/app/console/module/device/server/GwtDeviceServiceImpl.java index 7644fc0c4fe..926bb8eeec1 100644 --- a/console/module/device/src/main/java/org/eclipse/kapua/app/console/module/device/server/GwtDeviceServiceImpl.java +++ b/console/module/device/src/main/java/org/eclipse/kapua/app/console/module/device/server/GwtDeviceServiceImpl.java @@ -18,12 +18,6 @@ import java.util.Set; import java.util.concurrent.Callable; -import com.extjs.gxt.ui.client.data.BaseListLoadResult; -import com.extjs.gxt.ui.client.data.BasePagingLoadConfig; -import com.extjs.gxt.ui.client.data.BasePagingLoadResult; -import com.extjs.gxt.ui.client.data.ListLoadResult; -import com.extjs.gxt.ui.client.data.PagingLoadConfig; -import com.extjs.gxt.ui.client.data.PagingLoadResult; import org.eclipse.kapua.KapuaDuplicateNameException; import org.eclipse.kapua.app.console.module.api.client.GwtKapuaException; import org.eclipse.kapua.app.console.module.api.server.KapuaRemoteServiceServlet; @@ -78,6 +72,13 @@ import org.eclipse.kapua.service.user.User; import org.eclipse.kapua.service.user.UserService; +import com.extjs.gxt.ui.client.data.BaseListLoadResult; +import com.extjs.gxt.ui.client.data.BasePagingLoadConfig; +import com.extjs.gxt.ui.client.data.BasePagingLoadResult; +import com.extjs.gxt.ui.client.data.ListLoadResult; +import com.extjs.gxt.ui.client.data.PagingLoadConfig; +import com.extjs.gxt.ui.client.data.PagingLoadResult; + /** * The server side implementation of the Device RPC service. */ @@ -265,7 +266,7 @@ public User call() throws Exception { // GPS infos retrieval if (AUTHORIZATION_SERVICE.isPermitted(PERMISSION_FACTORY.newPermission(Domains.DEVICE_EVENT, Actions.read, device.getScopeId()))) { DeviceEventFactory deviceEventFactory = locator.getFactory(DeviceEventFactory.class); - DeviceEventQuery query = deviceEventFactory.newQuery(device.getScopeId()); + DeviceEventQuery query = new DeviceEventQuery(device.getScopeId()); query.setLimit(1); query.setSortCriteria(query.fieldSortCriteria(DeviceEventAttributes.RECEIVED_ON, SortOrder.DESCENDING)); @@ -534,9 +535,9 @@ public void deleteDeviceTag(GwtXSRFToken xsrfToken, String scopeIdString, String @Override public PagingLoadResult findDeviceEvents(PagingLoadConfig loadConfig, - GwtDevice gwtDevice, - Date startDate, - Date endDate) + GwtDevice gwtDevice, + Date startDate, + Date endDate) throws GwtKapuaException { ArrayList gwtDeviceEvents = new ArrayList(); BasePagingLoadResult gwtResults = null; @@ -549,7 +550,7 @@ public PagingLoadResult findDeviceEvents(PagingLoadConfig loadCo // prepare the query BasePagingLoadConfig bplc = (BasePagingLoadConfig) loadConfig; - DeviceEventQuery query = deviceEventFactory.newQuery(KapuaEid.parseCompactId(gwtDevice.getScopeId())); + DeviceEventQuery query = new DeviceEventQuery(KapuaEid.parseCompactId(gwtDevice.getScopeId())); AndPredicate andPredicate = query.andPredicate( query.attributePredicate(DeviceEventAttributes.DEVICE_ID, KapuaEid.parseCompactId(gwtDevice.getId())), diff --git a/console/module/device/src/main/java/org/eclipse/kapua/app/console/module/device/servlet/DeviceEventExporterServlet.java b/console/module/device/src/main/java/org/eclipse/kapua/app/console/module/device/servlet/DeviceEventExporterServlet.java index 88d80d63547..4fff7386281 100644 --- a/console/module/device/src/main/java/org/eclipse/kapua/app/console/module/device/servlet/DeviceEventExporterServlet.java +++ b/console/module/device/src/main/java/org/eclipse/kapua/app/console/module/device/servlet/DeviceEventExporterServlet.java @@ -12,6 +12,15 @@ *******************************************************************************/ package org.eclipse.kapua.app.console.module.device.servlet; +import java.io.IOException; +import java.util.Date; +import java.util.concurrent.Callable; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + import org.eclipse.kapua.KapuaEntityNotFoundException; import org.eclipse.kapua.KapuaIllegalAccessException; import org.eclipse.kapua.KapuaUnauthenticatedException; @@ -34,14 +43,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.util.Date; -import java.util.concurrent.Callable; - public class DeviceEventExporterServlet extends HttpServlet { private static final long serialVersionUID = -2533869595709953567L; @@ -94,6 +95,7 @@ private void internalDoGet(HttpServletRequest request, HttpServletResponse respo final KapuaIdFactory kif = locator.getFactory(KapuaIdFactory.class); Device device = KapuaSecurityUtils.doPrivileged(new Callable() { + @Override public Device call() throws Exception { return deviceRegistryService.find(KapuaEid.parseCompactId(scopeId), KapuaEid.parseCompactId(deviceId)); @@ -113,7 +115,7 @@ public Account call() throws Exception { int offset = 0; // paginate through the matching message - DeviceEventQuery query = def.newQuery(KapuaEid.parseCompactId(scopeId)); + DeviceEventQuery query = new DeviceEventQuery(KapuaEid.parseCompactId(scopeId)); query.setLimit(250); // Inserting filter parameter if specified diff --git a/console/module/device/src/main/java/org/eclipse/kapua/app/console/module/device/servlet/DeviceExporterServlet.java b/console/module/device/src/main/java/org/eclipse/kapua/app/console/module/device/servlet/DeviceExporterServlet.java index bad21ee8e21..f5dd0e4b02e 100644 --- a/console/module/device/src/main/java/org/eclipse/kapua/app/console/module/device/servlet/DeviceExporterServlet.java +++ b/console/module/device/src/main/java/org/eclipse/kapua/app/console/module/device/servlet/DeviceExporterServlet.java @@ -12,6 +12,14 @@ *******************************************************************************/ package org.eclipse.kapua.app.console.module.device.servlet; +import java.io.IOException; +import java.util.concurrent.Callable; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + import org.eclipse.kapua.KapuaEntityNotFoundException; import org.eclipse.kapua.KapuaIllegalAccessException; import org.eclipse.kapua.KapuaUnauthenticatedException; @@ -36,13 +44,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.util.concurrent.Callable; - public class DeviceExporterServlet extends HttpServlet { private static final long serialVersionUID = -2533869595709953567L; @@ -96,7 +97,7 @@ public Account call() throws Exception { int offset = 0; // paginate through the matching message - DeviceQuery query = drf.newQuery(KapuaEid.parseCompactId(scopeIdString)); + DeviceQuery query = new DeviceQuery(KapuaEid.parseCompactId(scopeIdString)); query.setLimit(250); // Inserting filter parameter if specified @@ -154,7 +155,7 @@ public Account call() throws Exception { String tagId = request.getParameter("tag"); if (tagId != null && !tagId.isEmpty()) { - andPred = andPred.and(query.attributePredicate(DeviceAttributes.TAG_IDS, new KapuaId[]{KapuaEid.parseCompactId(tagId)})); + andPred = andPred.and(query.attributePredicate(DeviceAttributes.TAG_IDS, new KapuaId[] { KapuaEid.parseCompactId(tagId) })); } String sortAttribute = request.getParameter("sortAttribute"); diff --git a/console/module/device/src/main/java/org/eclipse/kapua/app/console/module/device/shared/util/GwtKapuaDeviceModelConverter.java b/console/module/device/src/main/java/org/eclipse/kapua/app/console/module/device/shared/util/GwtKapuaDeviceModelConverter.java index b9c310f807d..e009281aa83 100644 --- a/console/module/device/src/main/java/org/eclipse/kapua/app/console/module/device/shared/util/GwtKapuaDeviceModelConverter.java +++ b/console/module/device/src/main/java/org/eclipse/kapua/app/console/module/device/shared/util/GwtKapuaDeviceModelConverter.java @@ -69,7 +69,7 @@ private GwtKapuaDeviceModelConverter() { } public static DeviceConnectionQuery convertConnectionQuery(PagingLoadConfig loadConfig, GwtDeviceConnectionQuery gwtDeviceConnectionQuery) { - DeviceConnectionQuery query = DEVICE_CONNECTION_FACTORY.newQuery(GwtKapuaCommonsModelConverter.convertKapuaId(gwtDeviceConnectionQuery.getScopeId())); + DeviceConnectionQuery query = new DeviceConnectionQuery(GwtKapuaCommonsModelConverter.convertKapuaId(gwtDeviceConnectionQuery.getScopeId())); AndPredicate predicate = query.andPredicate(); if (gwtDeviceConnectionQuery.getClientId() != null && !gwtDeviceConnectionQuery.getClientId().trim().isEmpty()) { @@ -163,7 +163,7 @@ public static DeviceAssetChannelMode convertDeviceAssetChannel(GwtDeviceAssetCha } public static DeviceQuery convertDeviceQuery(PagingLoadConfig loadConfig, GwtDeviceQuery gwtDeviceQuery) { - DeviceQuery query = DEVICE_FACTORY.newQuery(KapuaEid.parseCompactId(gwtDeviceQuery.getScopeId())); + DeviceQuery query = new DeviceQuery(KapuaEid.parseCompactId(gwtDeviceQuery.getScopeId())); if (loadConfig != null) { query.setLimit(loadConfig.getLimit()); @@ -243,7 +243,7 @@ public static DeviceQuery convertDeviceQuery(PagingLoadConfig loadConfig, GwtDev public static DeviceManagementOperationQuery convertDeviceManagementOperationQuery(PagingLoadConfig loadConfig, GwtDeviceManagementOperationQuery gwtQuery) { - DeviceManagementOperationQuery query = DEVICE_MANAGEMENT_OPERATION_FACTORY.newQuery(KapuaEid.parseCompactId(gwtQuery.getScopeId())); + DeviceManagementOperationQuery query = new DeviceManagementOperationQuery(KapuaEid.parseCompactId(gwtQuery.getScopeId())); String deviceId = gwtQuery.getDeviceId(); AndPredicate andPredicate = query.andPredicate(); diff --git a/console/module/endpoint/src/main/java/org/eclipse/kapua/app/console/module/endpoint/server/GwtEndpointServiceImpl.java b/console/module/endpoint/src/main/java/org/eclipse/kapua/app/console/module/endpoint/server/GwtEndpointServiceImpl.java index 23e8fd15552..6098643c90d 100644 --- a/console/module/endpoint/src/main/java/org/eclipse/kapua/app/console/module/endpoint/server/GwtEndpointServiceImpl.java +++ b/console/module/endpoint/src/main/java/org/eclipse/kapua/app/console/module/endpoint/server/GwtEndpointServiceImpl.java @@ -12,11 +12,14 @@ *******************************************************************************/ package org.eclipse.kapua.app.console.module.endpoint.server; -import com.extjs.gxt.ui.client.data.BaseListLoadResult; -import com.extjs.gxt.ui.client.data.BasePagingLoadResult; -import com.extjs.gxt.ui.client.data.ListLoadResult; -import com.extjs.gxt.ui.client.data.PagingLoadConfig; -import com.extjs.gxt.ui.client.data.PagingLoadResult; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.Callable; + import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.app.console.module.api.client.GwtKapuaException; import org.eclipse.kapua.app.console.module.api.server.KapuaRemoteServiceServlet; @@ -45,15 +48,14 @@ import org.eclipse.kapua.service.user.User; import org.eclipse.kapua.service.user.UserFactory; import org.eclipse.kapua.service.user.UserListResult; +import org.eclipse.kapua.service.user.UserQuery; import org.eclipse.kapua.service.user.UserService; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.Callable; +import com.extjs.gxt.ui.client.data.BaseListLoadResult; +import com.extjs.gxt.ui.client.data.BasePagingLoadResult; +import com.extjs.gxt.ui.client.data.ListLoadResult; +import com.extjs.gxt.ui.client.data.PagingLoadConfig; +import com.extjs.gxt.ui.client.data.PagingLoadResult; public class GwtEndpointServiceImpl extends KapuaRemoteServiceServlet implements GwtEndpointService { @@ -153,7 +155,7 @@ public PagingLoadResult query(PagingLoadConfig loadConfig, final Gw @Override public UserListResult call() throws Exception { - return USER_SERVICE.query(USER_FACTORY.newQuery(null)); + return USER_SERVICE.query(new UserQuery(null)); } }); @@ -205,7 +207,7 @@ public ListLoadResult getEndpointDescription(String scopeShort @Override public UserListResult call() throws Exception { - return USER_SERVICE.query(USER_FACTORY.newQuery(null)); + return USER_SERVICE.query(new UserQuery(null)); } }); diff --git a/console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/server/GwtJobEngineServiceImpl.java b/console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/server/GwtJobEngineServiceImpl.java index 7788a431dc5..5d7da504de0 100644 --- a/console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/server/GwtJobEngineServiceImpl.java +++ b/console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/server/GwtJobEngineServiceImpl.java @@ -12,6 +12,9 @@ *******************************************************************************/ package org.eclipse.kapua.app.console.module.job.server; +import java.util.ArrayList; +import java.util.Collections; + import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.app.console.module.api.client.GwtKapuaErrorCode; import org.eclipse.kapua.app.console.module.api.client.GwtKapuaException; @@ -33,9 +36,6 @@ import org.eclipse.kapua.service.job.execution.JobExecutionQuery; import org.eclipse.kapua.service.job.execution.JobExecutionService; -import java.util.ArrayList; -import java.util.Collections; - public class GwtJobEngineServiceImpl extends KapuaRemoteServiceServlet implements GwtJobEngineService { private static final KapuaLocator LOCATOR = KapuaLocator.getInstance(); @@ -88,7 +88,7 @@ public void stopExecution(String gwtScopeId, String gwtJobId, String gwtJobExecu try { if (jobExecutionId == null) { //TODO: #LAYER_VIOLATION - job execution lookup should not be done here (horribly inefficient) - JobExecutionQuery query = JOB_EXECUTION_FACTORY.newQuery(scopeId); + JobExecutionQuery query = new JobExecutionQuery(scopeId); query.setPredicate( query.andPredicate( diff --git a/console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/server/GwtJobServiceImpl.java b/console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/server/GwtJobServiceImpl.java index 2824b9d7f1b..94d523386ea 100644 --- a/console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/server/GwtJobServiceImpl.java +++ b/console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/server/GwtJobServiceImpl.java @@ -12,11 +12,12 @@ *******************************************************************************/ package org.eclipse.kapua.app.console.module.job.server; -import com.extjs.gxt.ui.client.data.BaseListLoadResult; -import com.extjs.gxt.ui.client.data.BasePagingLoadResult; -import com.extjs.gxt.ui.client.data.ListLoadResult; -import com.extjs.gxt.ui.client.data.PagingLoadConfig; -import com.extjs.gxt.ui.client.data.PagingLoadResult; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.Callable; + import org.eclipse.kapua.app.console.module.api.client.GwtKapuaException; import org.eclipse.kapua.app.console.module.api.server.KapuaRemoteServiceServlet; import org.eclipse.kapua.app.console.module.api.server.util.KapuaExceptionHandler; @@ -42,13 +43,14 @@ import org.eclipse.kapua.service.user.User; import org.eclipse.kapua.service.user.UserFactory; import org.eclipse.kapua.service.user.UserListResult; +import org.eclipse.kapua.service.user.UserQuery; import org.eclipse.kapua.service.user.UserService; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.Callable; +import com.extjs.gxt.ui.client.data.BaseListLoadResult; +import com.extjs.gxt.ui.client.data.BasePagingLoadResult; +import com.extjs.gxt.ui.client.data.ListLoadResult; +import com.extjs.gxt.ui.client.data.PagingLoadConfig; +import com.extjs.gxt.ui.client.data.PagingLoadResult; public class GwtJobServiceImpl extends KapuaRemoteServiceServlet implements GwtJobService { @@ -83,7 +85,7 @@ public PagingLoadResult query(PagingLoadConfig loadConfig, GwtJobQuery g @Override public UserListResult call() throws Exception { - return USER_SERVICE.query(USER_FACTORY.newQuery(null)); + return USER_SERVICE.query(new UserQuery(null)); } }); @@ -207,7 +209,7 @@ public void deleteForced(GwtXSRFToken xsrfToken, String gwtScopeId, String gwtJo @Override public ListLoadResult findJobDescription(String gwtScopeId, - String gwtJobId) throws GwtKapuaException { + String gwtJobId) throws GwtKapuaException { List gwtJobDescription = new ArrayList(); try { KapuaId scopeId = KapuaEid.parseCompactId(gwtScopeId); @@ -219,7 +221,7 @@ public ListLoadResult findJobDescription(String gwtScopeId, @Override public UserListResult call() throws Exception { - return USER_SERVICE.query(USER_FACTORY.newQuery(null)); + return USER_SERVICE.query(new UserQuery(null)); } }); diff --git a/console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/server/GwtJobStepDefinitionServiceImpl.java b/console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/server/GwtJobStepDefinitionServiceImpl.java index 6ed918244e2..d6ff7662c18 100644 --- a/console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/server/GwtJobStepDefinitionServiceImpl.java +++ b/console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/server/GwtJobStepDefinitionServiceImpl.java @@ -12,9 +12,9 @@ *******************************************************************************/ package org.eclipse.kapua.app.console.module.job.server; -import com.extjs.gxt.ui.client.data.BaseListLoadResult; -import com.extjs.gxt.ui.client.data.ListLoadResult; -import com.google.common.base.Strings; +import java.util.ArrayList; +import java.util.List; + import org.eclipse.kapua.app.console.module.api.client.GwtKapuaException; import org.eclipse.kapua.app.console.module.api.server.KapuaRemoteServiceServlet; import org.eclipse.kapua.app.console.module.api.server.util.KapuaExceptionHandler; @@ -31,10 +31,12 @@ import org.eclipse.kapua.service.job.step.definition.JobStepDefinition; import org.eclipse.kapua.service.job.step.definition.JobStepDefinitionFactory; import org.eclipse.kapua.service.job.step.definition.JobStepDefinitionListResult; +import org.eclipse.kapua.service.job.step.definition.JobStepDefinitionQuery; import org.eclipse.kapua.service.job.step.definition.JobStepDefinitionService; -import java.util.ArrayList; -import java.util.List; +import com.extjs.gxt.ui.client.data.BaseListLoadResult; +import com.extjs.gxt.ui.client.data.ListLoadResult; +import com.google.common.base.Strings; public class GwtJobStepDefinitionServiceImpl extends KapuaRemoteServiceServlet implements GwtJobStepDefinitionService { @@ -54,7 +56,7 @@ public ListLoadResult findAll(String scopeIdString) throws try { KapuaId scopeId = GwtKapuaCommonsModelConverter.convertKapuaId(scopeIdString); - JobStepDefinitionListResult result = JOB_STEP_DEFINITION_SERVICE.query(JOB_STEP_DEFINITION_FACTORY.newQuery(scopeId)); + JobStepDefinitionListResult result = JOB_STEP_DEFINITION_SERVICE.query(new JobStepDefinitionQuery(scopeId)); for (JobStepDefinition jsd : result.getItems()) { if (!Strings.isNullOrEmpty(JOB_STEP_DEFINITION_EXCLUDE_REGEX) && jsd.getName().matches(JOB_STEP_DEFINITION_EXCLUDE_REGEX)) { @@ -100,8 +102,8 @@ public GwtJobStepProperty trickGwt() { } /** - * Set the {@link GwtJobStepProperty#isEnum()} property. - * This cannot be performed in *.shared.* packages (entity converters are in that package), since `Class.forName` is not present in the JRE Emulation library. + * Set the {@link GwtJobStepProperty#isEnum()} property. This cannot be performed in *.shared.* packages (entity converters are in that package), since `Class.forName` is not present in the JRE + * Emulation library. * * @param jobStepProperties * @throws ClassNotFoundException diff --git a/console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/server/GwtJobStepServiceImpl.java b/console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/server/GwtJobStepServiceImpl.java index adfc96ed4be..80a1a6c49c7 100644 --- a/console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/server/GwtJobStepServiceImpl.java +++ b/console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/server/GwtJobStepServiceImpl.java @@ -12,9 +12,9 @@ *******************************************************************************/ package org.eclipse.kapua.app.console.module.job.server; -import com.extjs.gxt.ui.client.data.BasePagingLoadResult; -import com.extjs.gxt.ui.client.data.PagingLoadConfig; -import com.extjs.gxt.ui.client.data.PagingLoadResult; +import java.util.ArrayList; +import java.util.List; + import org.eclipse.kapua.app.console.module.api.client.GwtKapuaException; import org.eclipse.kapua.app.console.module.api.server.KapuaRemoteServiceServlet; import org.eclipse.kapua.app.console.module.api.server.util.KapuaExceptionHandler; @@ -30,18 +30,19 @@ import org.eclipse.kapua.commons.model.id.KapuaEid; import org.eclipse.kapua.locator.KapuaLocator; import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.model.query.KapuaQuery; import org.eclipse.kapua.service.job.step.JobStep; import org.eclipse.kapua.service.job.step.JobStepAttributes; import org.eclipse.kapua.service.job.step.JobStepCreator; import org.eclipse.kapua.service.job.step.JobStepFactory; import org.eclipse.kapua.service.job.step.JobStepListResult; -import org.eclipse.kapua.service.job.step.JobStepQuery; import org.eclipse.kapua.service.job.step.JobStepService; import org.eclipse.kapua.service.job.step.definition.JobStepDefinition; import org.eclipse.kapua.service.job.step.definition.JobStepDefinitionService; -import java.util.ArrayList; -import java.util.List; +import com.extjs.gxt.ui.client.data.BasePagingLoadResult; +import com.extjs.gxt.ui.client.data.PagingLoadConfig; +import com.extjs.gxt.ui.client.data.PagingLoadResult; public class GwtJobStepServiceImpl extends KapuaRemoteServiceServlet implements GwtJobStepService { @@ -60,7 +61,7 @@ public PagingLoadResult query(PagingLoadConfig loadConfig, GwtJobSte List gwtJobStepList = new ArrayList(); try { // Convert from GWT entity - JobStepQuery jobStepQuery = GwtKapuaJobModelConverter.convertJobStepQuery(gwtJobStepQuery, loadConfig); + KapuaQuery jobStepQuery = GwtKapuaJobModelConverter.convertJobStepQuery(gwtJobStepQuery, loadConfig); // query JobStepListResult jobStepList = JOB_STEP_SERVICE.query(jobStepQuery); @@ -94,7 +95,7 @@ public Integer count(String scopeIdString, String jobIdString) throws GwtKapuaEx KapuaId jobId = GwtKapuaCommonsModelConverter.convertKapuaId(jobIdString); // query - JobStepQuery jobStepQuery = JOB_STEP_FACTORY.newQuery(scopeId); + KapuaQuery jobStepQuery = new KapuaQuery(scopeId); jobStepQuery.setPredicate(jobStepQuery.attributePredicate(JobStepAttributes.JOB_ID, jobId)); return new Long(JOB_STEP_SERVICE.count(jobStepQuery)).intValue(); @@ -223,8 +224,8 @@ public int getJobStepPropertyLengthMax() throws GwtKapuaException { } /** - * Set the {@link GwtJobStepProperty#isEnum()} property. - * This cannot be performed in *.shared.* packages (entity converters are in that package), since `Class.forName` is not present in the JRE Emulation library. + * Set the {@link GwtJobStepProperty#isEnum()} property. This cannot be performed in *.shared.* packages (entity converters are in that package), since `Class.forName` is not present in the JRE + * Emulation library. * * @param jobStepProperties * @throws ClassNotFoundException diff --git a/console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/server/GwtJobTargetServiceImpl.java b/console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/server/GwtJobTargetServiceImpl.java index 4936241711e..6d33a9bf00b 100644 --- a/console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/server/GwtJobTargetServiceImpl.java +++ b/console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/server/GwtJobTargetServiceImpl.java @@ -12,9 +12,11 @@ *******************************************************************************/ package org.eclipse.kapua.app.console.module.job.server; -import com.extjs.gxt.ui.client.data.BasePagingLoadResult; -import com.extjs.gxt.ui.client.data.PagingLoadConfig; -import com.extjs.gxt.ui.client.data.PagingLoadResult; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + import org.eclipse.kapua.KapuaErrorCodes; import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.app.console.module.api.client.GwtKapuaException; @@ -31,6 +33,7 @@ import org.eclipse.kapua.commons.model.id.KapuaEid; import org.eclipse.kapua.locator.KapuaLocator; import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.model.query.KapuaQuery; import org.eclipse.kapua.service.device.registry.Device; import org.eclipse.kapua.service.device.registry.DeviceAttributes; import org.eclipse.kapua.service.device.registry.DeviceFactory; @@ -41,13 +44,11 @@ import org.eclipse.kapua.service.job.targets.JobTargetCreator; import org.eclipse.kapua.service.job.targets.JobTargetFactory; import org.eclipse.kapua.service.job.targets.JobTargetListResult; -import org.eclipse.kapua.service.job.targets.JobTargetQuery; import org.eclipse.kapua.service.job.targets.JobTargetService; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import com.extjs.gxt.ui.client.data.BasePagingLoadResult; +import com.extjs.gxt.ui.client.data.PagingLoadConfig; +import com.extjs.gxt.ui.client.data.PagingLoadResult; public class GwtJobTargetServiceImpl extends KapuaRemoteServiceServlet implements GwtJobTargetService { @@ -70,7 +71,7 @@ public PagingLoadResult query(PagingLoadConfig loadConfig, GwtJobT List gwtJobTargetList = new ArrayList(); try { // Convert from GWT entity - JobTargetQuery jobTargetQuery = GwtKapuaJobModelConverter.convertJobTargetQuery(gwtJobTargetQuery, loadConfig); + KapuaQuery jobTargetQuery = GwtKapuaJobModelConverter.convertJobTargetQuery(gwtJobTargetQuery, loadConfig); // query JobTargetListResult jobTargetList = JOB_TARGET_SERVICE.query(jobTargetQuery); @@ -83,7 +84,7 @@ public PagingLoadResult query(PagingLoadConfig loadConfig, GwtJobT //TODO: #LAYER_VIOLATION - manual device lookup - DeviceQuery query = DEVICE_FACTORY.newQuery(jobTargetQuery.getScopeId()); + DeviceQuery query = new DeviceQuery(jobTargetQuery.getScopeId()); query.setPredicate(query.attributePredicate(DeviceAttributes.ENTITY_ID, deviceIds)); DeviceListResult deviceListResult = DEVICE_REGISTRY_SERVICE.query(query); @@ -192,8 +193,10 @@ public void delete(GwtXSRFToken xsrfToken, String gwtScopeId, String gwtJobTarge /** * For each item query clientId by its foreign key and insert it into existing list. * - * @param gwtJobTarget existing target that is updated - * @param device existing device + * @param gwtJobTarget + * existing target that is updated + * @param device + * existing device * @throws KapuaException */ private void insertClientId(GwtJobTarget gwtJobTarget, Device device) { diff --git a/console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/server/GwtTriggerDefinitionServiceImpl.java b/console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/server/GwtTriggerDefinitionServiceImpl.java index f91e4c39114..58faaa12171 100644 --- a/console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/server/GwtTriggerDefinitionServiceImpl.java +++ b/console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/server/GwtTriggerDefinitionServiceImpl.java @@ -12,8 +12,9 @@ *******************************************************************************/ package org.eclipse.kapua.app.console.module.job.server; -import com.extjs.gxt.ui.client.data.BaseListLoadResult; -import com.extjs.gxt.ui.client.data.ListLoadResult; +import java.util.ArrayList; +import java.util.List; + import org.eclipse.kapua.app.console.module.api.client.GwtKapuaException; import org.eclipse.kapua.app.console.module.api.server.KapuaRemoteServiceServlet; import org.eclipse.kapua.app.console.module.api.server.util.KapuaExceptionHandler; @@ -24,13 +25,14 @@ import org.eclipse.kapua.commons.model.id.KapuaEid; import org.eclipse.kapua.locator.KapuaLocator; import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.model.query.KapuaQuery; import org.eclipse.kapua.service.scheduler.trigger.definition.TriggerDefinition; import org.eclipse.kapua.service.scheduler.trigger.definition.TriggerDefinitionFactory; import org.eclipse.kapua.service.scheduler.trigger.definition.TriggerDefinitionListResult; import org.eclipse.kapua.service.scheduler.trigger.definition.TriggerDefinitionService; -import java.util.ArrayList; -import java.util.List; +import com.extjs.gxt.ui.client.data.BaseListLoadResult; +import com.extjs.gxt.ui.client.data.ListLoadResult; public class GwtTriggerDefinitionServiceImpl extends KapuaRemoteServiceServlet implements GwtTriggerDefinitionService { @@ -43,7 +45,7 @@ public class GwtTriggerDefinitionServiceImpl extends KapuaRemoteServiceServlet i public ListLoadResult findAll() throws GwtKapuaException { List gwtTriggerDefinitionList = new ArrayList(); try { - TriggerDefinitionListResult result = TRIGGER_DEFINITION_SERVICE.query(TRIGGER_DEFINITION_FACTORY.newQuery(null)); + TriggerDefinitionListResult result = TRIGGER_DEFINITION_SERVICE.query(new KapuaQuery((KapuaId) null)); for (TriggerDefinition jsd : result.getItems()) { GwtTriggerDefinition gwtTriggerDefinition = KapuaGwtJobModelConverter.convertTriggerDefinition(jsd); @@ -84,8 +86,8 @@ public GwtTriggerProperty trickGwt() { } /** - * Set the {@link GwtTriggerProperty#isEnum()} property. - * This cannot be performed in *.shared.* packages (entity converters are in that package), since `Class.forName` is not present in the JRE Emulation library. + * Set the {@link GwtTriggerProperty#isEnum()} property. This cannot be performed in *.shared.* packages (entity converters are in that package), since `Class.forName` is not present in the JRE + * Emulation library. * * @param triggerProperties * @throws ClassNotFoundException diff --git a/console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/server/GwtTriggerServiceImpl.java b/console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/server/GwtTriggerServiceImpl.java index 9a58ca82bdb..dfccf56c7f2 100644 --- a/console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/server/GwtTriggerServiceImpl.java +++ b/console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/server/GwtTriggerServiceImpl.java @@ -12,10 +12,11 @@ *******************************************************************************/ package org.eclipse.kapua.app.console.module.job.server; -import com.extjs.gxt.ui.client.data.BasePagingLoadResult; -import com.extjs.gxt.ui.client.data.PagingLoadConfig; -import com.extjs.gxt.ui.client.data.PagingLoadResult; -import com.google.common.base.Strings; +import java.text.ParseException; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.Callable; + import org.eclipse.kapua.app.console.module.api.client.GwtKapuaErrorCode; import org.eclipse.kapua.app.console.module.api.client.GwtKapuaException; import org.eclipse.kapua.app.console.module.api.server.KapuaRemoteServiceServlet; @@ -33,11 +34,11 @@ import org.eclipse.kapua.commons.security.KapuaSecurityUtils; import org.eclipse.kapua.locator.KapuaLocator; import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.model.query.KapuaQuery; import org.eclipse.kapua.service.scheduler.trigger.Trigger; import org.eclipse.kapua.service.scheduler.trigger.TriggerCreator; import org.eclipse.kapua.service.scheduler.trigger.TriggerFactory; import org.eclipse.kapua.service.scheduler.trigger.TriggerListResult; -import org.eclipse.kapua.service.scheduler.trigger.TriggerQuery; import org.eclipse.kapua.service.scheduler.trigger.TriggerService; import org.eclipse.kapua.service.scheduler.trigger.definition.TriggerDefinition; import org.eclipse.kapua.service.scheduler.trigger.definition.TriggerDefinitionFactory; @@ -46,10 +47,10 @@ import org.eclipse.kapua.service.scheduler.trigger.definition.TriggerDefinitionService; import org.quartz.CronExpression; -import java.text.ParseException; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.Callable; +import com.extjs.gxt.ui.client.data.BasePagingLoadResult; +import com.extjs.gxt.ui.client.data.PagingLoadConfig; +import com.extjs.gxt.ui.client.data.PagingLoadResult; +import com.google.common.base.Strings; public class GwtTriggerServiceImpl extends KapuaRemoteServiceServlet implements GwtTriggerService { @@ -80,7 +81,7 @@ public class GwtTriggerServiceImpl extends KapuaRemoteServiceServlet implements @Override public TriggerDefinitionListResult call() throws Exception { - TriggerDefinitionQuery query = TRIGGER_DEFINITION_FACTORY.newQuery(null); + TriggerDefinitionQuery query = new TriggerDefinitionQuery((KapuaId) null); return TRIGGER_DEFINITION_SERVICE.query(query); } }); @@ -115,7 +116,7 @@ public PagingLoadResult findByJobId(PagingLoadConfig loadConfig, Str gwtTriggerQuery.setScopeId(gwtScopeId); gwtTriggerQuery.setJobId(gwtJobId); - TriggerQuery triggerQuery = GwtKapuaJobModelConverter.convertTriggerQuery(gwtTriggerQuery, loadConfig); + KapuaQuery triggerQuery = GwtKapuaJobModelConverter.convertTriggerQuery(gwtTriggerQuery, loadConfig); // query TriggerListResult triggerListResult = TRIGGER_SERVICE.query(triggerQuery); diff --git a/console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/servlet/JobTargetExporterCsv.java b/console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/servlet/JobTargetExporterCsv.java index 6e85f445454..15aa2728f89 100644 --- a/console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/servlet/JobTargetExporterCsv.java +++ b/console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/servlet/JobTargetExporterCsv.java @@ -12,8 +12,6 @@ *******************************************************************************/ package org.eclipse.kapua.app.console.module.job.servlet; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.OutputStreamWriter; import java.net.URLEncoder; @@ -26,6 +24,10 @@ import java.util.List; import java.util.Map; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletResponse; + +import org.apache.commons.lang3.CharEncoding; import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.locator.KapuaLocator; import org.eclipse.kapua.model.id.KapuaId; @@ -40,7 +42,6 @@ import org.eclipse.kapua.service.job.targets.JobTarget; import com.opencsv.CSVWriter; -import org.apache.commons.lang3.CharEncoding; public class JobTargetExporterCsv extends JobTargetExporter { @@ -70,7 +71,7 @@ public void init(final String scopeId, String jobId) writer = new CSVWriter(outputWriter); List cols = new ArrayList(Arrays.asList(JOB_TARGET_PROPERTIES)); - writer.writeNext(cols.toArray(new String[]{ })); + writer.writeNext(cols.toArray(new String[] {})); } @Override @@ -81,7 +82,7 @@ public void append(KapuaListResult jobTargets) final KapuaIdFactory kapuaIdFactory = locator.getFactory(KapuaIdFactory.class); final DeviceRegistryService deviceRegistryService = locator.getService(DeviceRegistryService.class); final DeviceFactory deviceFactory = locator.getFactory(DeviceFactory.class); - final DeviceQuery deviceQuery = deviceFactory.newQuery(kapuaIdFactory.newKapuaId(scopeId)); + final DeviceQuery deviceQuery = new DeviceQuery(kapuaIdFactory.newKapuaId(scopeId)); KapuaId[] targetIds = new KapuaId[jobTargets.getSize()]; int i = 0; diff --git a/console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/servlet/JobTargetExporterServlet.java b/console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/servlet/JobTargetExporterServlet.java index 763c0070c58..8fc7e71c082 100644 --- a/console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/servlet/JobTargetExporterServlet.java +++ b/console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/servlet/JobTargetExporterServlet.java @@ -25,11 +25,11 @@ import org.eclipse.kapua.locator.KapuaLocator; import org.eclipse.kapua.model.id.KapuaIdFactory; import org.eclipse.kapua.model.query.KapuaListResult; +import org.eclipse.kapua.model.query.KapuaQuery; import org.eclipse.kapua.service.job.targets.JobTarget; import org.eclipse.kapua.service.job.targets.JobTargetAttributes; import org.eclipse.kapua.service.job.targets.JobTargetFactory; import org.eclipse.kapua.service.job.targets.JobTargetListResult; -import org.eclipse.kapua.service.job.targets.JobTargetQuery; import org.eclipse.kapua.service.job.targets.JobTargetService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -84,7 +84,7 @@ private void internalDoGet(HttpServletRequest request, HttpServletResponse respo int offset = 0; - JobTargetQuery jobTargetQuery = jobTargetFactory.newQuery(kapuaIdFactory.newKapuaId(scopeId)); + KapuaQuery jobTargetQuery = new KapuaQuery(kapuaIdFactory.newKapuaId(scopeId)); jobTargetQuery.setPredicate(jobTargetQuery.attributePredicate(JobTargetAttributes.JOB_ID, kapuaIdFactory.newKapuaId(jobId))); // paginate through the matching message jobTargetQuery.setLimit(250); diff --git a/console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/shared/util/GwtKapuaJobModelConverter.java b/console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/shared/util/GwtKapuaJobModelConverter.java index 70099ff1b88..be23d90ed1d 100644 --- a/console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/shared/util/GwtKapuaJobModelConverter.java +++ b/console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/shared/util/GwtKapuaJobModelConverter.java @@ -12,8 +12,11 @@ *******************************************************************************/ package org.eclipse.kapua.app.console.module.job.shared.util; -import com.extjs.gxt.ui.client.Style.SortDir; -import com.extjs.gxt.ui.client.data.PagingLoadConfig; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + import org.apache.commons.lang3.StringUtils; import org.eclipse.kapua.app.console.module.api.shared.util.GwtKapuaCommonsModelConverter; import org.eclipse.kapua.app.console.module.job.shared.model.GwtJob; @@ -28,12 +31,12 @@ import org.eclipse.kapua.app.console.module.job.shared.model.GwtJobTargetQuery; import org.eclipse.kapua.app.console.module.job.shared.model.scheduler.GwtTriggerProperty; import org.eclipse.kapua.app.console.module.job.shared.model.scheduler.GwtTriggerQuery; -import org.eclipse.kapua.commons.model.query.FieldSortCriteriaImpl; import org.eclipse.kapua.job.engine.JobEngineFactory; import org.eclipse.kapua.job.engine.JobStartOptions; import org.eclipse.kapua.locator.KapuaLocator; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.model.query.FieldSortCriteria; +import org.eclipse.kapua.model.query.KapuaQuery; import org.eclipse.kapua.model.query.SortOrder; import org.eclipse.kapua.model.query.predicate.AndPredicate; import org.eclipse.kapua.model.query.predicate.AttributePredicate; @@ -49,22 +52,17 @@ import org.eclipse.kapua.service.job.step.JobStepAttributes; import org.eclipse.kapua.service.job.step.JobStepCreator; import org.eclipse.kapua.service.job.step.JobStepFactory; -import org.eclipse.kapua.service.job.step.JobStepQuery; import org.eclipse.kapua.service.job.step.definition.JobStepDefinitionFactory; import org.eclipse.kapua.service.job.step.definition.JobStepDefinitionQuery; import org.eclipse.kapua.service.job.step.definition.JobStepProperty; import org.eclipse.kapua.service.job.targets.JobTargetAttributes; import org.eclipse.kapua.service.job.targets.JobTargetFactory; -import org.eclipse.kapua.service.job.targets.JobTargetQuery; import org.eclipse.kapua.service.scheduler.trigger.TriggerAttributes; import org.eclipse.kapua.service.scheduler.trigger.TriggerFactory; -import org.eclipse.kapua.service.scheduler.trigger.TriggerQuery; import org.eclipse.kapua.service.scheduler.trigger.definition.TriggerProperty; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; +import com.extjs.gxt.ui.client.Style.SortDir; +import com.extjs.gxt.ui.client.data.PagingLoadConfig; public class GwtKapuaJobModelConverter { @@ -128,7 +126,7 @@ public static List convertJobStepProperties(List kapuaPropertyNameAttributePredicate = query.attributePredicate(TriggerAttributes.TRIGGER_PROPERTIES_NAME, "jobId"); AttributePredicate kapuaPropertyValueAttributePredicate = query.attributePredicate(TriggerAttributes.TRIGGER_PROPERTIES_VALUE, gwtTriggerQuery.getJobId()); @@ -297,7 +295,7 @@ public static List convertTriggerProperties(List query(PagingLoadConfig loadConfig, final GwtTagQ @Override public UserListResult call() throws Exception { - return userService.query(userFactory.newQuery(null)); + return userService.query(new UserQuery(null)); } }); @@ -186,12 +188,12 @@ public ListLoadResult getTagDescription(String scopeShortId, S final Tag tag = tagService.find(scopeId, tagId); if (tag != null) { -//TODO: #LAYER_VIOLATION - user lookup logic should not be done here (fetching all users is incredibly inefficient anyway) + //TODO: #LAYER_VIOLATION - user lookup logic should not be done here (fetching all users is incredibly inefficient anyway) UserListResult userListResult = KapuaSecurityUtils.doPrivileged(new Callable() { @Override public UserListResult call() throws Exception { - return userService.query(userFactory.newQuery(null)); + return userService.query(new UserQuery(null)); } }); @@ -220,7 +222,7 @@ public UserListResult call() throws Exception { public List findAll(String scopeId) throws GwtKapuaException { List tagList = new ArrayList(); try { - TagQuery query = tagFactory.newQuery(GwtKapuaCommonsModelConverter.convertKapuaId(scopeId)); + TagQuery query = new TagQuery(GwtKapuaCommonsModelConverter.convertKapuaId(scopeId)); TagListResult result = tagService.query(query); diff --git a/console/module/tag/src/main/java/org/eclipse/kapua/app/console/module/tag/shared/util/GwtKapuaTagModelConverter.java b/console/module/tag/src/main/java/org/eclipse/kapua/app/console/module/tag/shared/util/GwtKapuaTagModelConverter.java index c59cf43ed15..a0e1455fe8d 100644 --- a/console/module/tag/src/main/java/org/eclipse/kapua/app/console/module/tag/shared/util/GwtKapuaTagModelConverter.java +++ b/console/module/tag/src/main/java/org/eclipse/kapua/app/console/module/tag/shared/util/GwtKapuaTagModelConverter.java @@ -12,21 +12,22 @@ *******************************************************************************/ package org.eclipse.kapua.app.console.module.tag.shared.util; -import com.extjs.gxt.ui.client.Style.SortDir; -import com.extjs.gxt.ui.client.data.PagingLoadConfig; import org.apache.commons.lang3.StringUtils; import org.eclipse.kapua.app.console.module.api.shared.util.GwtKapuaCommonsModelConverter; import org.eclipse.kapua.app.console.module.tag.shared.model.GwtTagQuery; -import org.eclipse.kapua.model.query.FieldSortCriteria; -import org.eclipse.kapua.model.query.SortOrder; import org.eclipse.kapua.locator.KapuaLocator; import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.model.query.FieldSortCriteria; +import org.eclipse.kapua.model.query.SortOrder; import org.eclipse.kapua.model.query.predicate.AndPredicate; import org.eclipse.kapua.model.query.predicate.AttributePredicate.Operator; import org.eclipse.kapua.service.tag.TagAttributes; import org.eclipse.kapua.service.tag.TagFactory; import org.eclipse.kapua.service.tag.TagQuery; +import com.extjs.gxt.ui.client.Style.SortDir; +import com.extjs.gxt.ui.client.data.PagingLoadConfig; + public class GwtKapuaTagModelConverter { private static final KapuaLocator LOCATOR = KapuaLocator.getInstance(); @@ -38,13 +39,15 @@ private GwtKapuaTagModelConverter() { /** * Converts a {@link GwtTagQuery} into a {@link TagQuery} object for backend usage * - * @param loadConfig the load configuration - * @param gwtTagQuery the {@link GwtTagQuery} to convertKapuaId + * @param loadConfig + * the load configuration + * @param gwtTagQuery + * the {@link GwtTagQuery} to convertKapuaId * @return the converted {@link TagQuery} */ public static TagQuery convertTagQuery(PagingLoadConfig loadConfig, GwtTagQuery gwtTagQuery) { - TagQuery query = TAG_FACTORY.newQuery(GwtKapuaCommonsModelConverter.convertKapuaId(gwtTagQuery.getScopeId())); + TagQuery query = new TagQuery(GwtKapuaCommonsModelConverter.convertKapuaId(gwtTagQuery.getScopeId())); // Predicates conversion AndPredicate andPredicate = query.andPredicate(); diff --git a/console/module/user/src/main/java/org/eclipse/kapua/app/console/module/user/server/GwtUserServiceImpl.java b/console/module/user/src/main/java/org/eclipse/kapua/app/console/module/user/server/GwtUserServiceImpl.java index 382c328ec8f..c08e4686211 100644 --- a/console/module/user/src/main/java/org/eclipse/kapua/app/console/module/user/server/GwtUserServiceImpl.java +++ b/console/module/user/src/main/java/org/eclipse/kapua/app/console/module/user/server/GwtUserServiceImpl.java @@ -12,11 +12,12 @@ *******************************************************************************/ package org.eclipse.kapua.app.console.module.user.server; -import com.extjs.gxt.ui.client.data.BaseListLoadResult; -import com.extjs.gxt.ui.client.data.BasePagingLoadResult; -import com.extjs.gxt.ui.client.data.ListLoadResult; -import com.extjs.gxt.ui.client.data.PagingLoadConfig; -import com.extjs.gxt.ui.client.data.PagingLoadResult; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.Callable; + import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.app.console.module.api.client.GwtKapuaException; import org.eclipse.kapua.app.console.module.api.server.KapuaRemoteServiceServlet; @@ -59,11 +60,11 @@ import org.eclipse.kapua.service.user.UserService; import org.eclipse.kapua.service.user.UserType; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.Callable; +import com.extjs.gxt.ui.client.data.BaseListLoadResult; +import com.extjs.gxt.ui.client.data.BasePagingLoadResult; +import com.extjs.gxt.ui.client.data.ListLoadResult; +import com.extjs.gxt.ui.client.data.PagingLoadConfig; +import com.extjs.gxt.ui.client.data.PagingLoadResult; /** * The server side implementation of the RPC service. @@ -210,7 +211,7 @@ public ListLoadResult findAll(String scopeIdString) KapuaId scopeId = KapuaEid.parseCompactId(scopeIdString); List gwtUserList = new ArrayList(); try { - UserQuery query = USER_FACTORY.newQuery(scopeId); + UserQuery query = new UserQuery(scopeId); UserListResult list = USER_SERVICE.query(query); for (User user : list.getItems()) { @@ -244,7 +245,7 @@ public PagingLoadResult query(PagingLoadConfig loadConfig, GwtUserQuery @Override public UserListResult call() throws Exception { - return USER_SERVICE.query(USER_FACTORY.newQuery(null)); + return USER_SERVICE.query(new UserQuery(null)); } }); @@ -271,7 +272,7 @@ public UserListResult call() throws Exception { @Override public ListLoadResult getUserDescription(boolean isSsoEnabled, String shortScopeId, - String shortUserId) throws GwtKapuaException { + String shortUserId) throws GwtKapuaException { List gwtUserDescription = new ArrayList(); try { final KapuaId scopeId = KapuaEid.parseCompactId(shortScopeId); @@ -286,7 +287,7 @@ public ListLoadResult getUserDescription(boolean isSsoEnabled, @Override public UserListResult call() throws Exception { - return USER_SERVICE.query(USER_FACTORY.newQuery(null)); + return USER_SERVICE.query(new UserQuery(null)); } }); @@ -337,7 +338,7 @@ public UserListResult call() throws Exception { @Override public PagingLoadResult getUsersForRole(PagingLoadConfig pagingLoadConfig, - GwtAccessRoleQuery query) throws GwtKapuaException { + GwtAccessRoleQuery query) throws GwtKapuaException { int totalLength = 0; List list = new ArrayList(); try { @@ -361,7 +362,7 @@ public PagingLoadResult getUsersForRole(PagingLoadConfig pagingLoadConf @Override public PagingLoadResult getUsersForAccount(PagingLoadConfig loadConfig, GwtUserQuery gwtUserQuery, - String accountId) throws GwtKapuaException { + String accountId) throws GwtKapuaException { int totalLength = 0; List gwtUsers = new ArrayList(); @@ -373,7 +374,7 @@ public PagingLoadResult getUsersForAccount(PagingLoadConfig loadConfig, if (!users.isEmpty()) { //TODO: #LAYER_VIOLATION - user lookup should not be done here (horribly inefficient) - final UserQuery allUsersQuery = USER_FACTORY.newQuery(GwtKapuaCommonsModelConverter.convertKapuaId(accountId)); + final UserQuery allUsersQuery = new UserQuery(GwtKapuaCommonsModelConverter.convertKapuaId(accountId)); UserListResult allUsers = KapuaSecurityUtils.doPrivileged(new Callable() { @Override @@ -407,7 +408,7 @@ public UserListResult call() throws Exception { private DeviceListResult deviceListQuery(KapuaId scopeId) throws KapuaException { DeviceListResult devicesList = null; if (AUTHORIZATION_SERVICE.isPermitted(PERMISSION_FACTORY.newPermission(Domains.DEVICE, Actions.read, scopeId))) { - DeviceQuery deviceQuery = DEVICE_FACTORY.newQuery(scopeId); + DeviceQuery deviceQuery = new DeviceQuery(scopeId); devicesList = DEVICE_SERVICE.query(deviceQuery); } return devicesList; diff --git a/console/module/user/src/main/java/org/eclipse/kapua/app/console/module/user/shared/util/GwtKapuaUserModelConverter.java b/console/module/user/src/main/java/org/eclipse/kapua/app/console/module/user/shared/util/GwtKapuaUserModelConverter.java index bc3f91dd60a..91f9bb4ae67 100644 --- a/console/module/user/src/main/java/org/eclipse/kapua/app/console/module/user/shared/util/GwtKapuaUserModelConverter.java +++ b/console/module/user/src/main/java/org/eclipse/kapua/app/console/module/user/shared/util/GwtKapuaUserModelConverter.java @@ -12,9 +12,6 @@ *******************************************************************************/ package org.eclipse.kapua.app.console.module.user.shared.util; -import com.extjs.gxt.ui.client.Style.SortDir; -import com.extjs.gxt.ui.client.data.BaseModel; -import com.extjs.gxt.ui.client.data.PagingLoadConfig; import org.apache.commons.lang3.StringUtils; import org.eclipse.kapua.app.console.module.api.shared.util.GwtKapuaCommonsModelConverter; import org.eclipse.kapua.app.console.module.user.shared.model.GwtUser.GwtUserStatus; @@ -32,6 +29,10 @@ import org.eclipse.kapua.service.user.UserStatus; import org.eclipse.kapua.service.user.UserType; +import com.extjs.gxt.ui.client.Style.SortDir; +import com.extjs.gxt.ui.client.data.BaseModel; +import com.extjs.gxt.ui.client.data.PagingLoadConfig; + /** * Utility class for convertKapuaId {@link BaseModel}s to {@link KapuaEntity}ies and other Kapua models */ @@ -43,8 +44,10 @@ private GwtKapuaUserModelConverter() { /** * Converts a {@link GwtUserQuery} into a {@link UserQuery} object for backend usage * - * @param loadConfig the load configuration - * @param gwtUserQuery the {@link GwtUserQuery} to convertKapuaId + * @param loadConfig + * the load configuration + * @param gwtUserQuery + * the {@link GwtUserQuery} to convertKapuaId * @return the converted {@link UserQuery} */ public static UserQuery convertUserQuery(PagingLoadConfig loadConfig, GwtUserQuery gwtUserQuery) { @@ -53,7 +56,7 @@ public static UserQuery convertUserQuery(PagingLoadConfig loadConfig, GwtUserQue KapuaLocator locator = KapuaLocator.getInstance(); UserFactory userFactory = locator.getFactory(UserFactory.class); - UserQuery query = userFactory.newQuery(GwtKapuaCommonsModelConverter.convertKapuaId(gwtUserQuery.getScopeId())); + UserQuery query = new UserQuery(GwtKapuaCommonsModelConverter.convertKapuaId(gwtUserQuery.getScopeId())); AndPredicate predicate = query.andPredicate(); if (gwtUserQuery.getName() != null && !gwtUserQuery.getName().isEmpty()) { diff --git a/extras/encryption-migrator/src/main/java/org/eclipse/kapua/extras/migrator/encryption/api/AbstractEntityAttributeMigrator.java b/extras/encryption-migrator/src/main/java/org/eclipse/kapua/extras/migrator/encryption/api/AbstractEntityAttributeMigrator.java index a59da006688..48266a89e06 100644 --- a/extras/encryption-migrator/src/main/java/org/eclipse/kapua/extras/migrator/encryption/api/AbstractEntityAttributeMigrator.java +++ b/extras/encryption-migrator/src/main/java/org/eclipse/kapua/extras/migrator/encryption/api/AbstractEntityAttributeMigrator.java @@ -54,7 +54,7 @@ public void migrate(List entitiesToMigrate) throws KapuaException { @Override public List getChunk(int offset, int limit) throws KapuaException { - KapuaQuery query = newEntityQuery(); + KapuaQuery query = new KapuaQuery(); // This is the most stable sorting even if it is not always indexed query.setSortCriteria(query.fieldSortCriteria(KapuaEntityAttributes.CREATED_ON, SortOrder.ASCENDING)); @@ -67,9 +67,8 @@ public List getChunk(int offset, int limit) throws KapuaException { @Override public long getTotalCount() throws KapuaException { - KapuaQuery query = newEntityQuery(); + KapuaQuery query = new KapuaQuery(); return entityService.count(query); } - protected abstract KapuaQuery newEntityQuery(); } diff --git a/extras/encryption-migrator/src/main/java/org/eclipse/kapua/extras/migrator/encryption/authentication/MfaOptionAttributeMigrator.java b/extras/encryption-migrator/src/main/java/org/eclipse/kapua/extras/migrator/encryption/authentication/MfaOptionAttributeMigrator.java index 1b8ce0616c7..fdb81658f0e 100644 --- a/extras/encryption-migrator/src/main/java/org/eclipse/kapua/extras/migrator/encryption/authentication/MfaOptionAttributeMigrator.java +++ b/extras/encryption-migrator/src/main/java/org/eclipse/kapua/extras/migrator/encryption/authentication/MfaOptionAttributeMigrator.java @@ -16,10 +16,10 @@ import org.eclipse.kapua.commons.jpa.KapuaJpaTxManagerFactory; import org.eclipse.kapua.extras.migrator.encryption.api.AbstractEntityAttributeMigrator; import org.eclipse.kapua.extras.migrator.encryption.api.EntitySecretAttributeMigrator; -import org.eclipse.kapua.model.query.KapuaQuery; import org.eclipse.kapua.service.authentication.credential.mfa.MfaOption; public class MfaOptionAttributeMigrator extends AbstractEntityAttributeMigrator implements EntitySecretAttributeMigrator { + public MfaOptionAttributeMigrator(String persistenceUnitName, KapuaJpaTxManagerFactory jpaTxManagerFactory) { super(new MfaOptionMigratorServiceImpl( jpaTxManagerFactory.create(persistenceUnitName), @@ -31,9 +31,4 @@ public MfaOptionAttributeMigrator(String persistenceUnitName, KapuaJpaTxManagerF public String getEntityName() { return MfaOption.TYPE; } - - @Override - protected KapuaQuery newEntityQuery() { - return new MfaOptionMigratorQueryImpl(); - } } diff --git a/extras/encryption-migrator/src/main/java/org/eclipse/kapua/extras/migrator/encryption/authentication/MfaOptionMigratorQueryImpl.java b/extras/encryption-migrator/src/main/java/org/eclipse/kapua/extras/migrator/encryption/authentication/MfaOptionMigratorQueryImpl.java deleted file mode 100644 index 65d19e55d7d..00000000000 --- a/extras/encryption-migrator/src/main/java/org/eclipse/kapua/extras/migrator/encryption/authentication/MfaOptionMigratorQueryImpl.java +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - * Copyright (c) 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.extras.migrator.encryption.authentication; - -import org.eclipse.kapua.commons.model.query.AbstractKapuaNamedQuery; -import org.eclipse.kapua.service.authentication.credential.mfa.MfaOptionQuery; - -/** - * {@link MfaOptionQuery} definition. - * - * @since 1.0.0 - */ -public class MfaOptionMigratorQueryImpl extends AbstractKapuaNamedQuery implements MfaOptionQuery { - - /** - * Constructor. - * - * @since 1.0.0 - */ - public MfaOptionMigratorQueryImpl() { - super(); - } -} diff --git a/extras/encryption-migrator/src/main/java/org/eclipse/kapua/extras/migrator/encryption/job/JobStepAttributeMigrator.java b/extras/encryption-migrator/src/main/java/org/eclipse/kapua/extras/migrator/encryption/job/JobStepAttributeMigrator.java index 6b84f533c8e..e821bd2d6fe 100644 --- a/extras/encryption-migrator/src/main/java/org/eclipse/kapua/extras/migrator/encryption/job/JobStepAttributeMigrator.java +++ b/extras/encryption-migrator/src/main/java/org/eclipse/kapua/extras/migrator/encryption/job/JobStepAttributeMigrator.java @@ -16,7 +16,6 @@ import org.eclipse.kapua.commons.jpa.KapuaJpaTxManagerFactory; import org.eclipse.kapua.extras.migrator.encryption.api.AbstractEntityAttributeMigrator; import org.eclipse.kapua.extras.migrator.encryption.api.EntitySecretAttributeMigrator; -import org.eclipse.kapua.model.query.KapuaQuery; import org.eclipse.kapua.service.job.step.JobStep; public class JobStepAttributeMigrator extends AbstractEntityAttributeMigrator implements EntitySecretAttributeMigrator { @@ -33,8 +32,4 @@ public String getEntityName() { return JobStep.TYPE; } - @Override - protected KapuaQuery newEntityQuery() { - return new JobStepMigratorQueryImpl(); - } } diff --git a/extras/encryption-migrator/src/main/java/org/eclipse/kapua/extras/migrator/encryption/job/JobStepMigratorQueryImpl.java b/extras/encryption-migrator/src/main/java/org/eclipse/kapua/extras/migrator/encryption/job/JobStepMigratorQueryImpl.java deleted file mode 100644 index e9a1241dc28..00000000000 --- a/extras/encryption-migrator/src/main/java/org/eclipse/kapua/extras/migrator/encryption/job/JobStepMigratorQueryImpl.java +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - * Copyright (c) 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.extras.migrator.encryption.job; - -import org.eclipse.kapua.commons.model.query.AbstractKapuaNamedQuery; -import org.eclipse.kapua.service.job.step.JobStepQuery; - -/** - * {@link JobStepQuery} definition. - * - * @since 1.0.0 - */ -public class JobStepMigratorQueryImpl extends AbstractKapuaNamedQuery implements JobStepQuery { - - /** - * Constructor. - * - * @since 1.0.0 - */ - public JobStepMigratorQueryImpl() { - super(); - } -} diff --git a/job-engine/api/src/main/java/org/eclipse/kapua/job/engine/queue/QueuedJobExecutionFactory.java b/job-engine/api/src/main/java/org/eclipse/kapua/job/engine/queue/QueuedJobExecutionFactory.java index 88305e0d0a6..044a5de8692 100644 --- a/job-engine/api/src/main/java/org/eclipse/kapua/job/engine/queue/QueuedJobExecutionFactory.java +++ b/job-engine/api/src/main/java/org/eclipse/kapua/job/engine/queue/QueuedJobExecutionFactory.java @@ -19,6 +19,6 @@ * * @since 1.1.0 */ -public interface QueuedJobExecutionFactory extends KapuaEntityFactory { +public interface QueuedJobExecutionFactory extends KapuaEntityFactory { } diff --git a/job-engine/api/src/main/java/org/eclipse/kapua/job/engine/queue/QueuedJobExecutionQuery.java b/job-engine/api/src/main/java/org/eclipse/kapua/job/engine/queue/QueuedJobExecutionQuery.java deleted file mode 100644 index 2aaef2a32f8..00000000000 --- a/job-engine/api/src/main/java/org/eclipse/kapua/job/engine/queue/QueuedJobExecutionQuery.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2019, 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.job.engine.queue; - -import org.eclipse.kapua.model.query.KapuaQuery; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - -/** - * {@link QueuedJobExecution} {@link KapuaQuery} definition. - * - * @see KapuaQuery - * @since 1.1.0 - */ -@XmlRootElement(name = "query") -@XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = QueuedJobExecutionXmlRegistry.class, factoryMethod = "newQuery") -public interface QueuedJobExecutionQuery extends KapuaQuery { -} diff --git a/job-engine/api/src/main/java/org/eclipse/kapua/job/engine/queue/QueuedJobExecutionService.java b/job-engine/api/src/main/java/org/eclipse/kapua/job/engine/queue/QueuedJobExecutionService.java index 997d4baa5ff..51e21cd5a03 100644 --- a/job-engine/api/src/main/java/org/eclipse/kapua/job/engine/queue/QueuedJobExecutionService.java +++ b/job-engine/api/src/main/java/org/eclipse/kapua/job/engine/queue/QueuedJobExecutionService.java @@ -18,9 +18,8 @@ import org.eclipse.kapua.service.KapuaUpdatableEntityService; /** - * {@link QueuedJobExecutionService} exposes APIs to manage {@link QueuedJobExecution} objects.
    - * It includes APIs to create, update, find, list and delete {@link QueuedJobExecution}s.
    - * Instances of the {@link QueuedJobExecutionService} can be acquired through the {@link org.eclipse.kapua.locator.KapuaLocator} object. + * {@link QueuedJobExecutionService} exposes APIs to manage {@link QueuedJobExecution} objects.
    It includes APIs to create, update, find, list and delete {@link QueuedJobExecution}s.
    Instances + * of the {@link QueuedJobExecutionService} can be acquired through the {@link org.eclipse.kapua.locator.KapuaLocator} object. * * @since 1.1.0 */ @@ -30,7 +29,8 @@ public interface QueuedJobExecutionService extends KapuaEntityService runningExecutionsIds = BatchRuntime.getJobOperator().getRunningExecutions(jobName); if (runningExecutionsIds.size() > 1) { - JobExecutionQuery jobExecutionQuery = jobExecutionFactory.newQuery(scopeId); + JobExecutionQuery jobExecutionQuery = new JobExecutionQuery(scopeId); jobExecutionQuery.setPredicate( jobExecutionQuery.andPredicate( diff --git a/job-engine/jbatch/src/main/java/org/eclipse/kapua/job/engine/jbatch/listener/QueuedJobExecutionCheckTask.java b/job-engine/jbatch/src/main/java/org/eclipse/kapua/job/engine/jbatch/listener/QueuedJobExecutionCheckTask.java index 9968e4dac2c..13be4ff8532 100644 --- a/job-engine/jbatch/src/main/java/org/eclipse/kapua/job/engine/jbatch/listener/QueuedJobExecutionCheckTask.java +++ b/job-engine/jbatch/src/main/java/org/eclipse/kapua/job/engine/jbatch/listener/QueuedJobExecutionCheckTask.java @@ -12,8 +12,8 @@ *******************************************************************************/ package org.eclipse.kapua.job.engine.jbatch.listener; -import org.eclipse.kapua.commons.model.query.predicate.AndPredicateImpl; -import org.eclipse.kapua.commons.model.query.predicate.AttributePredicateImpl; +import java.util.TimerTask; + import org.eclipse.kapua.commons.security.KapuaSecurityUtils; import org.eclipse.kapua.job.engine.JobEngineService; import org.eclipse.kapua.job.engine.jbatch.setting.JobEngineSetting; @@ -22,15 +22,15 @@ import org.eclipse.kapua.job.engine.queue.QueuedJobExecutionAttributes; import org.eclipse.kapua.job.engine.queue.QueuedJobExecutionFactory; import org.eclipse.kapua.job.engine.queue.QueuedJobExecutionListResult; -import org.eclipse.kapua.job.engine.queue.QueuedJobExecutionQuery; import org.eclipse.kapua.job.engine.queue.QueuedJobExecutionService; import org.eclipse.kapua.job.engine.queue.QueuedJobExecutionStatus; import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.model.query.KapuaQuery; +import org.eclipse.kapua.model.query.predicate.AndPredicate; +import org.eclipse.kapua.model.query.predicate.AttributePredicate; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.TimerTask; - public class QueuedJobExecutionCheckTask extends TimerTask { private static final Logger LOG = LoggerFactory.getLogger(QueuedJobExecutionCheckTask.class); @@ -64,12 +64,12 @@ public void run() { LOG.info("Checking Job Execution queue for: {}...", jobExecutionId); try { - QueuedJobExecutionQuery query = queuedJobExecutionFactory.newQuery(scopeId); + KapuaQuery query = new KapuaQuery(scopeId); query.setPredicate( - new AndPredicateImpl( - new AttributePredicateImpl<>(QueuedJobExecutionAttributes.JOB_ID, jobId), - new AttributePredicateImpl<>(QueuedJobExecutionAttributes.WAIT_FOR_JOB_EXECUTION_ID, jobExecutionId) + new AndPredicate( + new AttributePredicate<>(QueuedJobExecutionAttributes.JOB_ID, jobId), + new AttributePredicate<>(QueuedJobExecutionAttributes.WAIT_FOR_JOB_EXECUTION_ID, jobExecutionId) ) ); diff --git a/job-engine/jbatch/src/main/java/org/eclipse/kapua/job/engine/queue/jbatch/QueuedJobExecutionFactoryImpl.java b/job-engine/jbatch/src/main/java/org/eclipse/kapua/job/engine/queue/jbatch/QueuedJobExecutionFactoryImpl.java index 6a9029ac52b..86d3c73800a 100644 --- a/job-engine/jbatch/src/main/java/org/eclipse/kapua/job/engine/queue/jbatch/QueuedJobExecutionFactoryImpl.java +++ b/job-engine/jbatch/src/main/java/org/eclipse/kapua/job/engine/queue/jbatch/QueuedJobExecutionFactoryImpl.java @@ -18,7 +18,6 @@ import org.eclipse.kapua.job.engine.queue.QueuedJobExecution; import org.eclipse.kapua.job.engine.queue.QueuedJobExecutionCreator; import org.eclipse.kapua.job.engine.queue.QueuedJobExecutionFactory; -import org.eclipse.kapua.job.engine.queue.QueuedJobExecutionQuery; import org.eclipse.kapua.model.id.KapuaId; /** @@ -39,11 +38,6 @@ public QueuedJobExecutionCreator newCreator(KapuaId scopeId) { return new QueuedJobExecutionCreatorImpl(scopeId); } - @Override - public QueuedJobExecutionQuery newQuery(KapuaId scopeId) { - return new QueuedJobExecutionQueryImpl(scopeId); - } - @Override public QueuedJobExecution clone(QueuedJobExecution queuedJobExecution) { try { diff --git a/job-engine/jbatch/src/main/java/org/eclipse/kapua/job/engine/queue/jbatch/QueuedJobExecutionQueryImpl.java b/job-engine/jbatch/src/main/java/org/eclipse/kapua/job/engine/queue/jbatch/QueuedJobExecutionQueryImpl.java deleted file mode 100644 index e58f97796e2..00000000000 --- a/job-engine/jbatch/src/main/java/org/eclipse/kapua/job/engine/queue/jbatch/QueuedJobExecutionQueryImpl.java +++ /dev/null @@ -1,35 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2019, 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.job.engine.queue.jbatch; - -import org.eclipse.kapua.commons.model.query.AbstractKapuaQuery; -import org.eclipse.kapua.job.engine.queue.QueuedJobExecutionQuery; -import org.eclipse.kapua.model.id.KapuaId; - -/** - * {@link QueuedJobExecutionQuery} implementation. - * - * @since 1.1.0 - */ -public class QueuedJobExecutionQueryImpl extends AbstractKapuaQuery implements QueuedJobExecutionQuery { - - /** - * Constructor. - * - * @param scopeId The {@link #getScopeId()}. - * @since 1.1.0 - */ - public QueuedJobExecutionQueryImpl(KapuaId scopeId) { - super(scopeId); - } -} diff --git a/qa/integration/src/test/java/org/eclipse/kapua/integration/misc/RolePermissionFactoryTest.java b/qa/integration/src/test/java/org/eclipse/kapua/integration/misc/RolePermissionFactoryTest.java index 6de74c1e466..e30f56787a6 100644 --- a/qa/integration/src/test/java/org/eclipse/kapua/integration/misc/RolePermissionFactoryTest.java +++ b/qa/integration/src/test/java/org/eclipse/kapua/integration/misc/RolePermissionFactoryTest.java @@ -19,7 +19,6 @@ import org.eclipse.kapua.service.authorization.permission.shiro.PermissionImpl; import org.eclipse.kapua.service.authorization.role.RolePermission; import org.eclipse.kapua.service.authorization.role.RolePermissionCreator; -import org.eclipse.kapua.service.authorization.role.RolePermissionQuery; import org.eclipse.kapua.service.authorization.role.shiro.RolePermissionFactoryImpl; import org.junit.Assert; import org.junit.Before; @@ -77,18 +76,6 @@ public void newCreatorNullTest() { Assert.assertNull("Null expected.", rolePermissionFactoryImpl.newCreator(null).getScopeId()); } - @Test - public void newQueryTest() { - Assert.assertTrue("True expected.", rolePermissionFactoryImpl.newQuery(scopeId) instanceof RolePermissionQuery); - Assert.assertEquals("Expected and actual values should be the same.", scopeId, rolePermissionFactoryImpl.newQuery(scopeId).getScopeId()); - } - - @Test - public void newQueryNullTest() { - Assert.assertTrue("True expected.", rolePermissionFactoryImpl.newQuery(null) instanceof RolePermissionQuery); - Assert.assertNull("Null expected.", rolePermissionFactoryImpl.newQuery(null).getScopeId()); - } - @Test public void cloneTest() { RolePermission resultRolePermission = rolePermissionFactoryImpl.clone(rolePermission); diff --git a/qa/integration/src/test/java/org/eclipse/kapua/integration/service/datastoreJunit/MessageStoreServiceSslTest.java b/qa/integration/src/test/java/org/eclipse/kapua/integration/service/datastoreJunit/MessageStoreServiceSslTest.java index d4fad348bea..f47b426fdf4 100644 --- a/qa/integration/src/test/java/org/eclipse/kapua/integration/service/datastoreJunit/MessageStoreServiceSslTest.java +++ b/qa/integration/src/test/java/org/eclipse/kapua/integration/service/datastoreJunit/MessageStoreServiceSslTest.java @@ -12,6 +12,16 @@ *******************************************************************************/ package org.eclipse.kapua.integration.service.datastoreJunit; +import java.text.ParseException; +import java.time.Instant; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + import org.apache.commons.lang.StringUtils; import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.commons.model.id.KapuaEid; @@ -52,16 +62,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.text.ParseException; -import java.time.Instant; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - @Category(JUnitTests.class) public class MessageStoreServiceSslTest extends AbstractMessageStoreServiceTest { @@ -82,11 +82,11 @@ public class MessageStoreServiceSslTest extends AbstractMessageStoreServiceTest /** * This method deletes all indices of the current ES instance *

    - * The method deletes all indices and resets the Kapua internal singleton state. - * This is required to ensure that each unit test, as it currently expects, starts with an empty ES setup + * The method deletes all indices and resets the Kapua internal singleton state. This is required to ensure that each unit test, as it currently expects, starts with an empty ES setup *

    * - * @throws Exception any case anything goes wrong + * @throws Exception + * any case anything goes wrong */ // @Before // public void deleteAllIndices() throws Exception { diff --git a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/AccessInfos.java b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/AccessInfos.java index e3ea828e27d..259dfe1b6e8 100644 --- a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/AccessInfos.java +++ b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/AccessInfos.java @@ -12,11 +12,25 @@ *******************************************************************************/ package org.eclipse.kapua.app.api.resources.v1.resources; +import javax.inject.Inject; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.DefaultValue; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.app.api.core.model.CountResult; import org.eclipse.kapua.app.api.core.model.EntityId; import org.eclipse.kapua.app.api.core.model.ScopeId; import org.eclipse.kapua.app.api.core.resources.AbstractKapuaResource; +import org.eclipse.kapua.model.query.KapuaQuery; import org.eclipse.kapua.model.query.predicate.AndPredicate; import org.eclipse.kapua.service.KapuaService; import org.eclipse.kapua.service.authorization.access.AccessInfo; @@ -24,23 +38,9 @@ import org.eclipse.kapua.service.authorization.access.AccessInfoCreator; import org.eclipse.kapua.service.authorization.access.AccessInfoFactory; import org.eclipse.kapua.service.authorization.access.AccessInfoListResult; -import org.eclipse.kapua.service.authorization.access.AccessInfoQuery; import org.eclipse.kapua.service.authorization.access.AccessInfoService; import org.eclipse.kapua.service.user.User; -import javax.inject.Inject; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - /** * {@link AccessInfo} REST API resource. * @@ -57,23 +57,28 @@ public class AccessInfos extends AbstractKapuaResource { /** * Gets the {@link AccessInfo} list in the scope. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param userId The optional {@link User} id to filter results. - * @param offset The result set offset. - * @param limit The result set limit. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param userId + * The optional {@link User} id to filter results. + * @param offset + * The result set offset. + * @param limit + * The result set limit. * @return The {@link AccessInfoListResult} of all the {@link AccessInfo}s associated to the current selected scope. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @GET - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public AccessInfoListResult simpleQuery( @PathParam("scopeId") ScopeId scopeId, @QueryParam("userId") EntityId userId, @QueryParam("offset") @DefaultValue("0") int offset, @QueryParam("limit") @DefaultValue("50") int limit) throws KapuaException { - AccessInfoQuery query = accessInfoFactory.newQuery(scopeId); + final KapuaQuery query = new KapuaQuery(scopeId); AndPredicate andPredicate = query.andPredicate(); if (userId != null) { @@ -88,60 +93,68 @@ public AccessInfoListResult simpleQuery( } /** - * Queries the {@link AccessInfo}s with the given {@link AccessInfoQuery} parameter. + * Queries the {@link AccessInfo}s with the given {@link KapuaQuery} parameter. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param query The {@link AccessInfoQuery} to use to filter results. - * @return The {@link AccessInfoListResult} of all the result matching the given {@link AccessInfoQuery} parameter. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param query + * The {@link KapuaQuery} to use to filter results. + * @return The {@link AccessInfoListResult} of all the result matching the given {@link KapuaQuery} parameter. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @POST @Path("_query") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public AccessInfoListResult query( @PathParam("scopeId") ScopeId scopeId, - AccessInfoQuery query) throws KapuaException { + KapuaQuery query) throws KapuaException { query.setScopeId(scopeId); return accessInfoService.query(query); } /** - * Counts the {@link AccessInfo}s with the given {@link AccessInfoQuery} parameter. + * Counts the {@link AccessInfo}s with the given {@link KapuaQuery} parameter. * - * @param scopeId The {@link ScopeId} in which to count results. - * @param query The {@link AccessInfoQuery} to use to filter count results. - * @return The count of all the result matching the given {@link AccessInfoQuery} parameter. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @param scopeId + * The {@link ScopeId} in which to count results. + * @param query + * The {@link KapuaQuery} to use to filter count results. + * @return The count of all the result matching the given {@link KapuaQuery} parameter. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @POST @Path("_count") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public CountResult count( @PathParam("scopeId") ScopeId scopeId, - AccessInfoQuery query) throws KapuaException { + KapuaQuery query) throws KapuaException { query.setScopeId(scopeId); return new CountResult(accessInfoService.count(query)); } /** - * Creates a new {@link AccessInfo} based on the information provided in {@link AccessInfoCreator} - * parameter. + * Creates a new {@link AccessInfo} based on the information provided in {@link AccessInfoCreator} parameter. * - * @param scopeId The {@link ScopeId} in which to create the {@link AccessInfo}. - * @param accessInfoCreator Provides the information for the new {@link AccessInfo} to be created. + * @param scopeId + * The {@link ScopeId} in which to create the {@link AccessInfo}. + * @param accessInfoCreator + * Provides the information for the new {@link AccessInfo} to be created. * @return The newly created {@link AccessInfo} object. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @POST - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public Response create( @PathParam("scopeId") ScopeId scopeId, // AccessInfoCreator accessInfoCreator) throws KapuaException { @@ -153,15 +166,18 @@ public Response create( /** * Gets the {@link AccessInfo} specified by the "accessInfoId" path parameter. * - * @param scopeId The {@link ScopeId} of the requested {@link AccessInfo}. - * @param accessInfoId The id of the requested {@link AccessInfo}. + * @param scopeId + * The {@link ScopeId} of the requested {@link AccessInfo}. + * @param accessInfoId + * The id of the requested {@link AccessInfo}. * @return The requested {@link AccessInfo} object. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @GET @Path("{accessInfoId}") - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public AccessInfo find( @PathParam("scopeId") ScopeId scopeId, @PathParam("accessInfoId") EntityId accessInfoId) throws KapuaException { @@ -173,10 +189,13 @@ public AccessInfo find( /** * Deletes the {@link AccessInfo} specified by the "accessInfoId" path parameter. * - * @param scopeId The {@link ScopeId} of the {@link AccessInfo} to be deleted. - * @param accessInfoId The id of the {@link AccessInfo} to be deleted. + * @param scopeId + * The {@link ScopeId} of the {@link AccessInfo} to be deleted. + * @param accessInfoId + * The id of the {@link AccessInfo} to be deleted. * @return HTTP 200 if operation has completed successfully. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @DELETE diff --git a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/AccessPermissions.java b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/AccessPermissions.java index d6953da94f3..ea7109219d2 100644 --- a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/AccessPermissions.java +++ b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/AccessPermissions.java @@ -12,13 +12,26 @@ *******************************************************************************/ package org.eclipse.kapua.app.api.resources.v1.resources; -import com.google.common.base.Strings; +import javax.inject.Inject; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.DefaultValue; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.app.api.core.model.CountResult; import org.eclipse.kapua.app.api.core.model.EntityId; import org.eclipse.kapua.app.api.core.model.ScopeId; import org.eclipse.kapua.app.api.core.resources.AbstractKapuaResource; import org.eclipse.kapua.model.KapuaEntityAttributes; +import org.eclipse.kapua.model.query.KapuaQuery; import org.eclipse.kapua.model.query.SortOrder; import org.eclipse.kapua.model.query.predicate.AndPredicate; import org.eclipse.kapua.service.KapuaService; @@ -28,21 +41,9 @@ import org.eclipse.kapua.service.authorization.access.AccessPermissionCreator; import org.eclipse.kapua.service.authorization.access.AccessPermissionFactory; import org.eclipse.kapua.service.authorization.access.AccessPermissionListResult; -import org.eclipse.kapua.service.authorization.access.AccessPermissionQuery; import org.eclipse.kapua.service.authorization.access.AccessPermissionService; -import javax.inject.Inject; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; +import com.google.common.base.Strings; /** * {@link AccessPermission} REST API resource. @@ -60,18 +61,25 @@ public class AccessPermissions extends AbstractKapuaResource { /** * Gets the {@link AccessPermission} list in the scope. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param accessInfoId The optional {@link AccessInfo} id to filter results. - * @param offset The result set offset. - * @param limit The result set limit. - * @param sortParam The name of the parameter that will be used as a sorting key - * @param sortDir The sort direction. Can be ASCENDING (default), DESCENDING. Case-insensitive. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param accessInfoId + * The optional {@link AccessInfo} id to filter results. + * @param offset + * The result set offset. + * @param limit + * The result set limit. + * @param sortParam + * The name of the parameter that will be used as a sorting key + * @param sortDir + * The sort direction. Can be ASCENDING (default), DESCENDING. Case-insensitive. * @return The {@link AccessPermissionListResult} of all the {@link AccessPermission}s associated to the current selected scope. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @GET - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public AccessPermissionListResult simpleQuery( @PathParam("scopeId") ScopeId scopeId, @PathParam("accessInfoId") EntityId accessInfoId, @@ -80,7 +88,7 @@ public AccessPermissionListResult simpleQuery( @QueryParam("sortDir") @DefaultValue("ASCENDING") SortOrder sortDir, @QueryParam("offset") @DefaultValue("0") int offset, @QueryParam("limit") @DefaultValue("50") int limit) throws KapuaException { - AccessPermissionQuery query = accessPermissionFactory.newQuery(scopeId); + KapuaQuery query = new KapuaQuery(scopeId); query.setPredicate(query.attributePredicate(AccessPermissionAttributes.ACCESS_INFO_ID, accessInfoId)); if (!Strings.isNullOrEmpty(sortParam)) { @@ -95,23 +103,27 @@ public AccessPermissionListResult simpleQuery( } /** - * Queries the {@link AccessPermission}s with the given {@link AccessPermissionQuery} parameter. + * Queries the {@link AccessPermission}s with the given {@link KapuaQuery} parameter. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param accessInfoId The {@link AccessInfo} id in which to search results. - * @param query The {@link AccessPermissionQuery} to use to filter results. - * @return The {@link AccessPermissionListResult} of all the result matching the given {@link AccessPermissionQuery} parameter. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param accessInfoId + * The {@link AccessInfo} id in which to search results. + * @param query + * The {@link KapuaQuery} to use to filter results. + * @return The {@link AccessPermissionListResult} of all the result matching the given {@link KapuaQuery} parameter. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @POST @Path("_query") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public AccessPermissionListResult query( @PathParam("scopeId") ScopeId scopeId, @PathParam("accessInfoId") EntityId accessInfoId, - AccessPermissionQuery query) throws KapuaException { + KapuaQuery query) throws KapuaException { query.setScopeId(scopeId); @@ -121,23 +133,27 @@ public AccessPermissionListResult query( } /** - * Counts the {@link AccessPermission}s with the given {@link AccessPermissionQuery} parameter. + * Counts the {@link AccessPermission}s with the given {@link KapuaQuery} parameter. * - * @param scopeId The {@link ScopeId} in which to count results. - * @param accessInfoId The {@link AccessInfo} id in which to count results. - * @param query The {@link AccessPermissionQuery} to use to filter count results. - * @return The count of all the result matching the given {@link AccessPermissionQuery} parameter. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @param scopeId + * The {@link ScopeId} in which to count results. + * @param accessInfoId + * The {@link AccessInfo} id in which to count results. + * @param query + * The {@link KapuaQuery} to use to filter count results. + * @return The count of all the result matching the given {@link KapuaQuery} parameter. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @POST @Path("_count") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public CountResult count( @PathParam("scopeId") ScopeId scopeId, @PathParam("accessInfoId") EntityId accessInfoId, - AccessPermissionQuery query) throws KapuaException { + KapuaQuery query) throws KapuaException { query.setScopeId(scopeId); query.setPredicate(query.attributePredicate(AccessPermissionAttributes.ACCESS_INFO_ID, accessInfoId)); @@ -146,19 +162,22 @@ public CountResult count( } /** - * Creates a new {@link AccessPermission} based on the information provided in {@link AccessPermissionCreator} - * parameter. + * Creates a new {@link AccessPermission} based on the information provided in {@link AccessPermissionCreator} parameter. * - * @param scopeId The {@link ScopeId} in which to create the AccessPermission. - * @param accessInfoId The {@link AccessInfo} id in which to create the AccessPermission. - * @param accessPermissionCreator Provides the information for the new {@link AccessPermission} to be created. + * @param scopeId + * The {@link ScopeId} in which to create the AccessPermission. + * @param accessInfoId + * The {@link AccessInfo} id in which to create the AccessPermission. + * @param accessPermissionCreator + * Provides the information for the new {@link AccessPermission} to be created. * @return The newly created {@link AccessPermission} object. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @POST - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public Response create( @PathParam("scopeId") ScopeId scopeId, @PathParam("accessInfoId") EntityId accessInfoId, @@ -172,21 +191,25 @@ public Response create( /** * Returns the AccessPermission specified by the "accessPermissionId" path parameter. * - * @param scopeId The {@link ScopeId} of the requested {@link AccessPermission}. - * @param accessInfoId The {@link AccessInfo} id of the requested {@link AccessPermission}. - * @param accessPermissionId The id of the requested AccessPermission. + * @param scopeId + * The {@link ScopeId} of the requested {@link AccessPermission}. + * @param accessInfoId + * The {@link AccessInfo} id of the requested {@link AccessPermission}. + * @param accessPermissionId + * The id of the requested AccessPermission. * @return The requested AccessPermission object. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @GET @Path("{accessPermissionId}") - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public AccessPermission find( @PathParam("scopeId") ScopeId scopeId, @PathParam("accessInfoId") EntityId accessInfoId, @PathParam("accessPermissionId") EntityId accessPermissionId) throws KapuaException { - AccessPermissionQuery query = accessPermissionFactory.newQuery(scopeId); + final KapuaQuery query = new KapuaQuery(scopeId); AndPredicate andPredicate = query.andPredicate( query.attributePredicate(AccessPermissionAttributes.ACCESS_INFO_ID, accessInfoId), @@ -205,11 +228,15 @@ public AccessPermission find( /** * Deletes the {@link AccessPermission} specified by the "accessPermissionId" path parameter. * - * @param scopeId The {@link ScopeId} of the {@link AccessPermission} to delete. - * @param accessInfoId The {@link AccessInfo} id of the {@link AccessPermission} to delete. - * @param accessPermissionId The id of the AccessPermission to be deleted. + * @param scopeId + * The {@link ScopeId} of the {@link AccessPermission} to delete. + * @param accessInfoId + * The {@link AccessInfo} id of the {@link AccessPermission} to delete. + * @param accessPermissionId + * The id of the AccessPermission to be deleted. * @return HTTP 200 if operation has completed successfully. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @DELETE diff --git a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/AccessRoles.java b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/AccessRoles.java index dfcebe6ad41..ea8bb283b27 100644 --- a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/AccessRoles.java +++ b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/AccessRoles.java @@ -12,12 +12,26 @@ *******************************************************************************/ package org.eclipse.kapua.app.api.resources.v1.resources; +import javax.inject.Inject; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.DefaultValue; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.app.api.core.model.CountResult; import org.eclipse.kapua.app.api.core.model.EntityId; import org.eclipse.kapua.app.api.core.model.ScopeId; import org.eclipse.kapua.app.api.core.resources.AbstractKapuaResource; import org.eclipse.kapua.model.KapuaEntityAttributes; +import org.eclipse.kapua.model.query.KapuaQuery; import org.eclipse.kapua.model.query.predicate.AndPredicate; import org.eclipse.kapua.service.KapuaService; import org.eclipse.kapua.service.authorization.access.AccessRole; @@ -25,22 +39,8 @@ import org.eclipse.kapua.service.authorization.access.AccessRoleCreator; import org.eclipse.kapua.service.authorization.access.AccessRoleFactory; import org.eclipse.kapua.service.authorization.access.AccessRoleListResult; -import org.eclipse.kapua.service.authorization.access.AccessRoleQuery; import org.eclipse.kapua.service.authorization.access.AccessRoleService; -import javax.inject.Inject; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - @Path("{scopeId}/accessinfos/{accessInfoId}/roles") public class AccessRoles extends AbstractKapuaResource { @@ -52,22 +52,26 @@ public class AccessRoles extends AbstractKapuaResource { /** * Gets the {@link AccessRole} list in the scope. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param offset The result set offset. - * @param limit The result set limit. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param offset + * The result set offset. + * @param limit + * The result set limit. * @return The {@link AccessRoleListResult} of all the accessRoles associated to the current selected scope. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @GET - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public AccessRoleListResult simpleQuery( @PathParam("scopeId") ScopeId scopeId, @PathParam("accessInfoId") EntityId accessInfoId, @QueryParam("askTotalCount") boolean askTotalCount, @QueryParam("offset") @DefaultValue("0") int offset, @QueryParam("limit") @DefaultValue("50") int limit) throws KapuaException { - AccessRoleQuery query = accessRoleFactory.newQuery(scopeId); + final KapuaQuery query = new KapuaQuery(scopeId); query.setPredicate(query.attributePredicate(AccessRoleAttributes.ACCESS_INFO_ID, accessInfoId)); @@ -79,22 +83,25 @@ public AccessRoleListResult simpleQuery( } /** - * Queries the results with the given {@link AccessRoleQuery} parameter. + * Queries the results with the given {@link KapuaQuery} parameter. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param query The {@link AccessRoleQuery} to use to filter results. - * @return The {@link AccessRoleListResult} of all the result matching the given {@link AccessRoleQuery} parameter. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param query + * The {@link KapuaQuery} to use to filter results. + * @return The {@link AccessRoleListResult} of all the result matching the given {@link KapuaQuery} parameter. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @POST @Path("_query") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public AccessRoleListResult query( @PathParam("scopeId") ScopeId scopeId, @PathParam("accessInfoId") EntityId accessInfoId, - AccessRoleQuery query) throws KapuaException { + KapuaQuery query) throws KapuaException { query.setScopeId(scopeId); query.setPredicate(query.attributePredicate(AccessRoleAttributes.ACCESS_INFO_ID, accessInfoId)); @@ -103,22 +110,25 @@ public AccessRoleListResult query( } /** - * Counts the results with the given {@link AccessRoleQuery} parameter. + * Counts the results with the given {@link KapuaQuery} parameter. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param query The {@link AccessRoleQuery} to use to filter results. - * @return The count of all the result matching the given {@link AccessRoleQuery} parameter. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param query + * The {@link KapuaQuery} to use to filter results. + * @return The count of all the result matching the given {@link KapuaQuery} parameter. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @POST @Path("_count") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public CountResult count( @PathParam("scopeId") ScopeId scopeId, @PathParam("accessInfoId") EntityId accessInfoId, - AccessRoleQuery query) throws KapuaException { + KapuaQuery query) throws KapuaException { query.setScopeId(scopeId); query.setPredicate(query.attributePredicate(AccessRoleAttributes.ACCESS_INFO_ID, accessInfoId)); @@ -127,18 +137,20 @@ public CountResult count( } /** - * Creates a new AccessRole based on the information provided in AccessRoleCreator - * parameter. + * Creates a new AccessRole based on the information provided in AccessRoleCreator parameter. * - * @param scopeId The {@link ScopeId} in which to create the {@link AccessRole}. - * @param accessRoleCreator Provides the information for the new AccessRole to be created. + * @param scopeId + * The {@link ScopeId} in which to create the {@link AccessRole}. + * @param accessRoleCreator + * Provides the information for the new AccessRole to be created. * @return The newly created {@link AccessRole} object. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @POST - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public Response create( @PathParam("scopeId") ScopeId scopeId, @PathParam("accessInfoId") EntityId accessInfoId, @@ -152,20 +164,23 @@ public Response create( /** * Returns the AccessRole specified by the "accessRoleId" path parameter. * - * @param scopeId The {@link ScopeId} of the requested {@link AccessRole}. - * @param accessRoleId The id of the requested {@link AccessRole}. + * @param scopeId + * The {@link ScopeId} of the requested {@link AccessRole}. + * @param accessRoleId + * The id of the requested {@link AccessRole}. * @return The requested {@link AccessRole} object. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @GET @Path("{accessRoleId}") - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public AccessRole find( @PathParam("scopeId") ScopeId scopeId, @PathParam("accessInfoId") EntityId accessInfoId, @PathParam("accessRoleId") EntityId accessRoleId) throws KapuaException { - AccessRoleQuery query = accessRoleFactory.newQuery(scopeId); + final KapuaQuery query = new KapuaQuery(scopeId); AndPredicate andPredicate = query.andPredicate( query.attributePredicate(AccessRoleAttributes.ACCESS_INFO_ID, accessInfoId), @@ -184,9 +199,11 @@ public AccessRole find( /** * Deletes the AccessRole specified by the "accessRoleId" path parameter. * - * @param accessRoleId The id of the AccessRole to be deleted. + * @param accessRoleId + * The id of the AccessRole to be deleted. * @return HTTP 200 if operation has completed successfully. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @DELETE diff --git a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/Accounts.java b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/Accounts.java index 4bfc274aba2..e230fbd3a42 100644 --- a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/Accounts.java +++ b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/Accounts.java @@ -32,6 +32,7 @@ import org.eclipse.kapua.app.api.core.model.ScopeId; import org.eclipse.kapua.app.api.core.resources.AbstractKapuaResource; import org.eclipse.kapua.model.KapuaNamedEntityAttributes; +import org.eclipse.kapua.model.query.KapuaQuery; import org.eclipse.kapua.model.query.SortOrder; import org.eclipse.kapua.model.query.predicate.AndPredicate; import org.eclipse.kapua.model.query.predicate.MatchPredicate; @@ -41,7 +42,6 @@ import org.eclipse.kapua.service.account.AccountCreator; import org.eclipse.kapua.service.account.AccountFactory; import org.eclipse.kapua.service.account.AccountListResult; -import org.eclipse.kapua.service.account.AccountQuery; import org.eclipse.kapua.service.account.AccountService; import com.google.common.base.Strings; @@ -93,7 +93,7 @@ public AccountListResult simpleQuery( return accountService.findChildrenRecursively(scopeId); } - AccountQuery query = accountFactory.newQuery(scopeId); + final KapuaQuery query = new KapuaQuery(scopeId); query.setAskTotalCount(askTotalCount); AndPredicate andPredicate = query.andPredicate(); @@ -126,13 +126,13 @@ public String getMatchTerm() { } /** - * Queries the results with the given {@link AccountQuery} parameter. + * Queries the results with the given {@link KapuaQuery} parameter. * * @param scopeId * The {@link ScopeId} in which to search results. * @param query - * The {@link AccountQuery} to use to filter results. - * @return The {@link AccountListResult} of all the result matching the given {@link AccountQuery} parameter. + * The {@link KapuaQuery} to use to filter results. + * @return The {@link AccountListResult} of all the result matching the given {@link KapuaQuery} parameter. * @throws KapuaException * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 @@ -143,20 +143,20 @@ public String getMatchTerm() { @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public AccountListResult query( @PathParam("scopeId") ScopeId scopeId, // - AccountQuery query) throws KapuaException { + KapuaQuery query) throws KapuaException { query.setScopeId(scopeId); return accountService.query(query); } /** - * Counts the results with the given {@link AccountQuery} parameter. + * Counts the results with the given {@link KapuaQuery} parameter. * * @param scopeId * The {@link ScopeId} in which to count results. * @param query - * The {@link AccountQuery} to use to filter results. - * @return The count of all the result matching the given {@link AccountQuery} parameter. + * The {@link KapuaQuery} to use to filter results. + * @return The count of all the result matching the given {@link KapuaQuery} parameter. * @throws KapuaException * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 @@ -168,7 +168,7 @@ public AccountListResult query( @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public CountResult count( @PathParam("scopeId") ScopeId scopeId, // - AccountQuery query) throws KapuaException { + KapuaQuery query) throws KapuaException { query.setScopeId(scopeId); return new CountResult(accountService.count(query)); diff --git a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/Credentials.java b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/Credentials.java index a40032f1612..cb9b3e50f87 100644 --- a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/Credentials.java +++ b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/Credentials.java @@ -26,13 +26,13 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import com.google.common.base.Strings; import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.app.api.core.model.CountResult; import org.eclipse.kapua.app.api.core.model.EntityId; import org.eclipse.kapua.app.api.core.model.ScopeId; import org.eclipse.kapua.app.api.core.model.SetResult; import org.eclipse.kapua.app.api.core.resources.AbstractKapuaResource; +import org.eclipse.kapua.model.query.KapuaQuery; import org.eclipse.kapua.model.query.SortOrder; import org.eclipse.kapua.model.query.predicate.AndPredicate; import org.eclipse.kapua.service.KapuaService; @@ -41,9 +41,10 @@ import org.eclipse.kapua.service.authentication.credential.CredentialCreator; import org.eclipse.kapua.service.authentication.credential.CredentialFactory; import org.eclipse.kapua.service.authentication.credential.CredentialListResult; -import org.eclipse.kapua.service.authentication.credential.CredentialQuery; import org.eclipse.kapua.service.authentication.credential.CredentialService; +import com.google.common.base.Strings; + @Path("{scopeId}/credentials") public class Credentials extends AbstractKapuaResource { @@ -53,19 +54,22 @@ public class Credentials extends AbstractKapuaResource { @Inject public CredentialFactory credentialFactory; - /** * Gets the {@link Credential} list in the scope. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param offset The result set offset. - * @param limit The result set limit. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param offset + * The result set offset. + * @param limit + * The result set limit. * @return The {@link CredentialListResult} of all the credentials associated to the current selected scope. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @GET - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public CredentialListResult simpleQuery( @PathParam("scopeId") ScopeId scopeId, @QueryParam("userId") EntityId userId, @@ -74,7 +78,7 @@ public CredentialListResult simpleQuery( @QueryParam("sortDir") @DefaultValue("ASCENDING") SortOrder sortDir, @QueryParam("offset") @DefaultValue("0") int offset, @QueryParam("limit") @DefaultValue("50") int limit) throws KapuaException { - CredentialQuery query = credentialFactory.newQuery(scopeId); + final KapuaQuery query = new KapuaQuery(scopeId); AndPredicate andPredicate = query.andPredicate(); if (userId != null) { @@ -93,60 +97,68 @@ public CredentialListResult simpleQuery( } /** - * Queries the results with the given {@link CredentialQuery} parameter. + * Queries the results with the given {@link KapuaQuery} parameter. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param query The {@link CredentialQuery} to use to filter results. - * @return The {@link CredentialListResult} of all the result matching the given {@link CredentialQuery} parameter. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param query + * The {@link KapuaQuery} to use to filter results. + * @return The {@link CredentialListResult} of all the result matching the given {@link KapuaQuery} parameter. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @POST @Path("_query") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public CredentialListResult query( @PathParam("scopeId") ScopeId scopeId, - CredentialQuery query) throws KapuaException { + KapuaQuery query) throws KapuaException { query.setScopeId(scopeId); return credentialService.query(query); } /** - * Counts the results with the given {@link CredentialQuery} parameter. + * Counts the results with the given {@link KapuaQuery} parameter. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param query The {@link CredentialQuery} to use to filter results. - * @return The count of all the result matching the given {@link CredentialQuery} parameter. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param query + * The {@link KapuaQuery} to use to filter results. + * @return The count of all the result matching the given {@link KapuaQuery} parameter. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @POST @Path("_count") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public CountResult count( @PathParam("scopeId") ScopeId scopeId, - CredentialQuery query) throws KapuaException { + KapuaQuery query) throws KapuaException { query.setScopeId(scopeId); return new CountResult(credentialService.count(query)); } /** - * Creates a new Credential based on the information provided in CredentialCreator - * parameter. + * Creates a new Credential based on the information provided in CredentialCreator parameter. * - * @param scopeId The {@link ScopeId} in which to create the {@link Credential} - * @param credentialCreator Provides the information for the new Credential to be created. + * @param scopeId + * The {@link ScopeId} in which to create the {@link Credential} + * @param credentialCreator + * Provides the information for the new Credential to be created. * @return The newly created Credential object. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @POST - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public Response create( @PathParam("scopeId") ScopeId scopeId, CredentialCreator credentialCreator) throws KapuaException { @@ -158,15 +170,18 @@ public Response create( /** * Returns the Credential specified by the "credentialId" path parameter. * - * @param scopeId The {@link ScopeId} of the requested {@link Credential}. - * @param credentialId The id of the requested Credential. + * @param scopeId + * The {@link ScopeId} of the requested {@link Credential}. + * @param credentialId + * The id of the requested Credential. * @return The requested Credential object. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @GET @Path("{credentialId}") - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public Credential find( @PathParam("scopeId") ScopeId scopeId, @PathParam("credentialId") EntityId credentialId) throws KapuaException { @@ -178,15 +193,17 @@ public Credential find( /** * Updates the Credential based on the information provided in the Credential parameter. * - * @param credential The modified Credential whose attributed need to be updated. + * @param credential + * The modified Credential whose attributed need to be updated. * @return The updated credential. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @PUT @Path("{credentialId}") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public Credential update( @PathParam("scopeId") ScopeId scopeId, @PathParam("credentialId") EntityId credentialId, @@ -200,9 +217,11 @@ public Credential update( /** * Deletes the Credential specified by the "credentialId" path parameter. * - * @param credentialId The id of the Credential to be deleted. + * @param credentialId + * The id of the Credential to be deleted. * @return HTTP 200 if operation has completed successfully. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @DELETE @@ -215,14 +234,16 @@ public Response deleteCredential( return returnNoContent(); } - /** * Unlocks a {@link Credential} that has been locked due to a lockout policy. * - * @param scopeId The {@link ScopeId} of {@link Credential} to unlock. - * @param credentialId The id of the Credential to be unlocked. + * @param scopeId + * The {@link ScopeId} of {@link Credential} to unlock. + * @param credentialId + * The id of the Credential to be unlocked. * @return HTTP 200 if operation has completed successfully. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 * @deprecated Since 2.0.0. Please make use of {@link #unlock(ScopeId, EntityId)} */ @@ -237,14 +258,16 @@ public Response unlockCredential( return returnNoContent(); } - /** * Unlocks a {@link Credential} that has been locked due to a lockout policy. * - * @param scopeId The {@link ScopeId} of {@link Credential} to unlock. - * @param credentialId The id of the Credential to be unlocked. + * @param scopeId + * The {@link ScopeId} of {@link Credential} to unlock. + * @param credentialId + * The id of the Credential to be unlocked. * @return HTTP 200 if operation has completed successfully. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 2.0.0 */ @POST @@ -257,10 +280,9 @@ public Response unlock( return returnNoContent(); } - @GET @Path("_availableCredentials") - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public SetResult getAvailableAuthAdapter() throws KapuaException { return new SetResult(credentialService.getAvailableCredentialTypes()); } diff --git a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/DeviceConnections.java b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/DeviceConnections.java index dc4bf788d2d..0235f37fc17 100644 --- a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/DeviceConnections.java +++ b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/DeviceConnections.java @@ -12,7 +12,18 @@ *******************************************************************************/ package org.eclipse.kapua.app.api.resources.v1.resources; -import com.google.common.base.Strings; +import javax.inject.Inject; +import javax.ws.rs.Consumes; +import javax.ws.rs.DefaultValue; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.app.api.core.model.CountResult; import org.eclipse.kapua.app.api.core.model.EntityId; @@ -30,17 +41,7 @@ import org.eclipse.kapua.service.device.registry.connection.DeviceConnectionService; import org.eclipse.kapua.service.device.registry.connection.DeviceConnectionStatus; -import javax.inject.Inject; -import javax.ws.rs.Consumes; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; +import com.google.common.base.Strings; @Path("{scopeId}/deviceconnections") public class DeviceConnections extends AbstractKapuaResource { @@ -53,17 +54,23 @@ public class DeviceConnections extends AbstractKapuaResource { /** * Gets the {@link DeviceConnection} list in the scope. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param clientId The id of the {@link Device} in which to search results - * @param status The {@link DeviceConnectionStatus} in which to search results - * @param offset The result set offset. - * @param limit The result set limit. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param clientId + * The id of the {@link Device} in which to search results + * @param status + * The {@link DeviceConnectionStatus} in which to search results + * @param offset + * The result set offset. + * @param limit + * The result set limit. * @return The {@link DeviceConnectionListResult} of all the deviceConnections associated to the current selected scope. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @GET - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public DeviceConnectionListResult simpleQuery( @PathParam("scopeId") ScopeId scopeId, @QueryParam("clientId") String clientId, @@ -72,7 +79,7 @@ public DeviceConnectionListResult simpleQuery( @QueryParam("status") DeviceConnectionStatus status, @QueryParam("offset") @DefaultValue("0") int offset, @QueryParam("limit") @DefaultValue("50") int limit) throws KapuaException { - DeviceConnectionQuery query = deviceConnectionFactory.newQuery(scopeId); + DeviceConnectionQuery query = new DeviceConnectionQuery(scopeId); AndPredicate andPredicate = query.andPredicate(); if (!Strings.isNullOrEmpty(clientId)) { @@ -98,16 +105,19 @@ public DeviceConnectionListResult simpleQuery( /** * Queries the results with the given {@link DeviceConnectionQuery} parameter. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param query The {@link DeviceConnectionQuery} to use to filter results. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param query + * The {@link DeviceConnectionQuery} to use to filter results. * @return The {@link DeviceConnectionListResult} of all the result matching the given {@link DeviceConnectionQuery} parameter. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @POST @Path("_query") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public DeviceConnectionListResult query( @PathParam("scopeId") ScopeId scopeId, DeviceConnectionQuery query) throws KapuaException { @@ -119,16 +129,19 @@ public DeviceConnectionListResult query( /** * Counts the results with the given {@link DeviceConnectionQuery} parameter. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param query The {@link DeviceConnectionQuery} to use to filter results. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param query + * The {@link DeviceConnectionQuery} to use to filter results. * @return The count of all the result matching the given {@link DeviceConnectionQuery} parameter. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @POST @Path("_count") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public CountResult count( @PathParam("scopeId") ScopeId scopeId, DeviceConnectionQuery query) throws KapuaException { @@ -140,15 +153,18 @@ public CountResult count( /** * Returns the DeviceConnection specified by the "deviceConnectionId" path parameter. * - * @param scopeId The {@link ScopeId} of the requested {@link DeviceConnection}. - * @param deviceConnectionId The id of the requested DeviceConnection. + * @param scopeId + * The {@link ScopeId} of the requested {@link DeviceConnection}. + * @param deviceConnectionId + * The id of the requested DeviceConnection. * @return The requested DeviceConnection object. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @GET @Path("{deviceConnectionId}") - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public DeviceConnection find( @PathParam("scopeId") ScopeId scopeId, @PathParam("deviceConnectionId") EntityId deviceConnectionId) throws KapuaException { @@ -159,7 +175,7 @@ public DeviceConnection find( @GET @Path("_availableAuth") - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public SetResult getAvailableAuthAdapter() { return new SetResult(deviceConnectionService.getAvailableAuthTypes()); } @@ -167,15 +183,18 @@ public SetResult getAvailableAuthAdapter() { /** * Request that the DeviceConnection specified by the "deviceConnectionId" is disconnected from the broker. * - * @param scopeId The {@link ScopeId} of the requested {@link DeviceConnection}. - * @param deviceConnectionId The id of the requested DeviceConnection. + * @param scopeId + * The {@link ScopeId} of the requested {@link DeviceConnection}. + * @param deviceConnectionId + * The id of the requested DeviceConnection. * @return HTTP 200 if operation has completed successfully. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 2.0.0 */ @POST @Path("{deviceConnectionId}/_disconnect") - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public Response disconnect( @PathParam("scopeId") ScopeId scopeId, @PathParam("deviceConnectionId") EntityId deviceConnectionId) throws KapuaException { diff --git a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/DeviceEvents.java b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/DeviceEvents.java index 082f3f688e4..c9a3ee957f0 100644 --- a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/DeviceEvents.java +++ b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/DeviceEvents.java @@ -12,7 +12,19 @@ *******************************************************************************/ package org.eclipse.kapua.app.api.resources.v1.resources; -import com.google.common.base.Strings; +import javax.inject.Inject; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.DefaultValue; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + import org.eclipse.kapua.KapuaEntityNotFoundException; import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.app.api.core.model.CountResult; @@ -34,18 +46,7 @@ import org.eclipse.kapua.service.device.registry.event.DeviceEventQuery; import org.eclipse.kapua.service.device.registry.event.DeviceEventService; -import javax.inject.Inject; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; +import com.google.common.base.Strings; @Path("{scopeId}/devices/{deviceId}/events") public class DeviceEvents extends AbstractKapuaResource { @@ -60,20 +61,29 @@ public class DeviceEvents extends AbstractKapuaResource { /** * Gets the {@link DeviceEvent} list in the scope. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param deviceId The id of the {@link Device} in which to search results - * @param resource The resource of the {@link DeviceEvent} in which to search results - * @param sortParam The name of the parameter that will be used as a sorting key - * @param sortDir The sort direction. Can be ASCENDING (default), DESCENDING. Case-insensitive. - * @param askTotalCount Ask for the total count of the matched entities in the result - * @param offset The result set offset. - * @param limit The result set limit. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param deviceId + * The id of the {@link Device} in which to search results + * @param resource + * The resource of the {@link DeviceEvent} in which to search results + * @param sortParam + * The name of the parameter that will be used as a sorting key + * @param sortDir + * The sort direction. Can be ASCENDING (default), DESCENDING. Case-insensitive. + * @param askTotalCount + * Ask for the total count of the matched entities in the result + * @param offset + * The result set offset. + * @param limit + * The result set limit. * @return The {@link DeviceEventListResult} of all the deviceEvents associated to the current selected scope. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @GET - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public DeviceEventListResult simpleQuery( @PathParam("scopeId") ScopeId scopeId, @PathParam("deviceId") EntityId deviceId, @@ -85,7 +95,7 @@ public DeviceEventListResult simpleQuery( @QueryParam("askTotalCount") boolean askTotalCount, @QueryParam("offset") @DefaultValue("0") int offset, @QueryParam("limit") @DefaultValue("50") int limit) throws KapuaException { - DeviceEventQuery query = deviceEventFactory.newQuery(scopeId); + DeviceEventQuery query = new DeviceEventQuery(scopeId); if (deviceRegistryService.find(scopeId, deviceId) == null) { throw new KapuaEntityNotFoundException(Device.TYPE, deviceId); @@ -119,17 +129,21 @@ public DeviceEventListResult simpleQuery( /** * Queries the results with the given {@link DeviceEventQuery} parameter. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param deviceId The id of the {@link Device} in which to search results - * @param query The {@link DeviceEventQuery} to use to filter results. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param deviceId + * The id of the {@link Device} in which to search results + * @param query + * The {@link DeviceEventQuery} to use to filter results. * @return The {@link DeviceEventListResult} of all the result matching the given {@link DeviceEventQuery} parameter. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @POST @Path("_query") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public DeviceEventListResult query( @PathParam("scopeId") ScopeId scopeId, @PathParam("deviceId") EntityId deviceId, @@ -153,17 +167,21 @@ public DeviceEventListResult query( /** * Counts the results with the given {@link DeviceEventQuery} parameter. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param deviceId The id of the {@link Device} in which to search results - * @param query The {@link DeviceEventQuery} to use to filter results. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param deviceId + * The id of the {@link Device} in which to search results + * @param query + * The {@link DeviceEventQuery} to use to filter results. * @return The count of all the result matching the given {@link DeviceEventQuery} parameter. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @POST @Path("_count") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public CountResult count( @PathParam("scopeId") ScopeId scopeId, @PathParam("deviceId") EntityId deviceId, @@ -182,16 +200,20 @@ public CountResult count( /** * Returns the DeviceEvent specified by the "deviceEventId" path parameter. * - * @param scopeId The {@link ScopeId} of the requested {@link DeviceEvent}. - * @param deviceId The {@link Device} id of the request {@link DeviceEvent}. - * @param deviceEventId The id of the requested DeviceEvent. + * @param scopeId + * The {@link ScopeId} of the requested {@link DeviceEvent}. + * @param deviceId + * The {@link Device} id of the request {@link DeviceEvent}. + * @param deviceEventId + * The id of the requested DeviceEvent. * @return The requested DeviceEvent object. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @GET @Path("{deviceEventId}") - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public DeviceEvent find( @PathParam("scopeId") ScopeId scopeId, @PathParam("deviceId") EntityId deviceId, @@ -201,7 +223,7 @@ public DeviceEvent find( throw new KapuaEntityNotFoundException(Device.TYPE, deviceId); } - DeviceEventQuery query = deviceEventFactory.newQuery(scopeId); + DeviceEventQuery query = new DeviceEventQuery(scopeId); AndPredicate andPredicate = query.andPredicate( query.attributePredicate(DeviceEventAttributes.DEVICE_ID, deviceId), @@ -220,17 +242,20 @@ public DeviceEvent find( /** * Deletes the DeviceEvent specified by the "deviceEventId" path parameter. * - * @param deviceId The id of the Device in which to delete the event - * @param deviceEventId The id of the DeviceEvent to be deleted. + * @param deviceId + * The id of the Device in which to delete the event + * @param deviceEventId + * The id of the DeviceEvent to be deleted. * @return HTTP 200 if operation has completed successfully. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @DELETE @Path("{deviceEventId}") public Response deleteDeviceEvent(@PathParam("scopeId") ScopeId scopeId, - @PathParam("deviceId") EntityId deviceId, - @PathParam("deviceEventId") EntityId deviceEventId) throws KapuaException { + @PathParam("deviceId") EntityId deviceId, + @PathParam("deviceEventId") EntityId deviceEventId) throws KapuaException { if (deviceRegistryService.find(scopeId, deviceId) == null) { throw new KapuaEntityNotFoundException(Device.TYPE, deviceId); diff --git a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/DeviceManagementOperationNotifications.java b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/DeviceManagementOperationNotifications.java index c41a0ab8933..b980ef13472 100644 --- a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/DeviceManagementOperationNotifications.java +++ b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/DeviceManagementOperationNotifications.java @@ -25,7 +25,6 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import com.google.common.base.Strings; import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.app.api.core.model.CountResult; import org.eclipse.kapua.app.api.core.model.EntityId; @@ -43,6 +42,8 @@ import org.eclipse.kapua.service.device.management.registry.operation.notification.ManagementOperationNotificationService; import org.eclipse.kapua.service.device.registry.Device; +import com.google.common.base.Strings; + @Path("{scopeId}/devices/{deviceId}/operations/{operationId}/notifications") public class DeviceManagementOperationNotifications extends AbstractKapuaResource { @@ -54,17 +55,23 @@ public class DeviceManagementOperationNotifications extends AbstractKapuaResourc /** * Gets the {@link ManagementOperationNotification} list in the scope. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param operationId The id of the {@link Device} in which to search results - * @param resource The resource of the {@link ManagementOperationNotification} in which to search results - * @param offset The result set offset. - * @param limit The result set limit. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param operationId + * The id of the {@link Device} in which to search results + * @param resource + * The resource of the {@link ManagementOperationNotification} in which to search results + * @param offset + * The result set offset. + * @param limit + * The result set limit. * @return The {@link ManagementOperationNotificationListResult} of all the ManagementOperationNotifications associated to the current selected scope. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @GET - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ManagementOperationNotificationListResult simpleQuery( @PathParam("scopeId") ScopeId scopeId, @PathParam("deviceId") EntityId deviceId, @@ -75,7 +82,7 @@ public ManagementOperationNotificationListResult simpleQuery( @QueryParam("sortDir") @DefaultValue("ASCENDING") SortOrder sortDir, @QueryParam("offset") @DefaultValue("0") int offset, @QueryParam("limit") @DefaultValue("50") int limit) throws KapuaException { - ManagementOperationNotificationQuery query = managementOperationNotificationFactory.newQuery(scopeId); + ManagementOperationNotificationQuery query = new ManagementOperationNotificationQuery(scopeId); AndPredicate andPredicate = query.andPredicate(query.attributePredicate(ManagementOperationNotificationAttributes.OPERATION_ID, operationId)); @@ -99,17 +106,21 @@ public ManagementOperationNotificationListResult simpleQuery( /** * Queries the results with the given {@link ManagementOperationNotificationQuery} parameter. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param operationId The id of the {@link Device} in which to search results - * @param query The {@link ManagementOperationNotificationQuery} to use to filter results. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param operationId + * The id of the {@link Device} in which to search results + * @param query + * The {@link ManagementOperationNotificationQuery} to use to filter results. * @return The {@link ManagementOperationNotificationListResult} of all the result matching the given {@link ManagementOperationNotificationQuery} parameter. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @POST @Path("_query") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public ManagementOperationNotificationListResult query( @PathParam("scopeId") ScopeId scopeId, @PathParam("deviceId") EntityId deviceId, @@ -127,17 +138,21 @@ public ManagementOperationNotificationListResult query( /** * Counts the results with the given {@link ManagementOperationNotificationQuery} parameter. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param operationId The id of the {@link Device} in which to search results - * @param query The {@link ManagementOperationNotificationQuery} to use to filter results. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param operationId + * The id of the {@link Device} in which to search results + * @param query + * The {@link ManagementOperationNotificationQuery} to use to filter results. * @return The count of all the result matching the given {@link ManagementOperationNotificationQuery} parameter. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @POST @Path("_count") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public CountResult count( @PathParam("scopeId") ScopeId scopeId, @PathParam("deviceId") EntityId deviceId, @@ -152,23 +167,27 @@ public CountResult count( /** * Returns the ManagementOperationNotification specified by the "ManagementOperationNotificationId" path parameter. * - * @param scopeId The {@link ScopeId} of the requested {@link ManagementOperationNotification}. - * @param operationId The {@link Device} id of the request {@link ManagementOperationNotification}. - * @param managementOperationNotificationId The id of the requested ManagementOperationNotification. + * @param scopeId + * The {@link ScopeId} of the requested {@link ManagementOperationNotification}. + * @param operationId + * The {@link Device} id of the request {@link ManagementOperationNotification}. + * @param managementOperationNotificationId + * The id of the requested ManagementOperationNotification. * @return The requested ManagementOperationNotification object. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @GET @Path("{managementOperationNotificationId}") - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public ManagementOperationNotification find( @PathParam("scopeId") ScopeId scopeId, @PathParam("deviceId") EntityId deviceId, @PathParam("operationId") EntityId operationId, @PathParam("managementOperationNotificationId") EntityId managementOperationNotificationId) throws KapuaException { -//TODO: #LAYER_VIOLATION - findFirst should be resolved in bottom layer - ManagementOperationNotificationQuery query = managementOperationNotificationFactory.newQuery(scopeId); + //TODO: #LAYER_VIOLATION - findFirst should be resolved in bottom layer + ManagementOperationNotificationQuery query = new ManagementOperationNotificationQuery(scopeId); AndPredicate andPredicate = query.andPredicate( query.attributePredicate(ManagementOperationNotificationAttributes.OPERATION_ID, operationId), @@ -187,10 +206,13 @@ public ManagementOperationNotification find( /** * Deletes the ManagementOperationNotification specified by the "ManagementOperationNotificationId" path parameter. * - * @param operationId The id of the Device in which to delete the ManagementOperation - * @param managementOperationNotificationId The id of the ManagementOperationNotification to be deleted. + * @param operationId + * The id of the Device in which to delete the ManagementOperation + * @param managementOperationNotificationId + * The id of the ManagementOperationNotification to be deleted. * @return HTTP 200 if operation has completed successfully. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @DELETE diff --git a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/DeviceManagementOperations.java b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/DeviceManagementOperations.java index 85087c62154..791da951ed3 100644 --- a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/DeviceManagementOperations.java +++ b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/DeviceManagementOperations.java @@ -25,7 +25,6 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import com.google.common.base.Strings; import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.app.api.core.model.CountResult; import org.eclipse.kapua.app.api.core.model.EntityId; @@ -44,6 +43,8 @@ import org.eclipse.kapua.service.device.management.registry.operation.DeviceManagementOperationStatus; import org.eclipse.kapua.service.device.registry.Device; +import com.google.common.base.Strings; + @Path("{scopeId}/devices/{deviceId}/operations") public class DeviceManagementOperations extends AbstractKapuaResource { @@ -55,17 +56,23 @@ public class DeviceManagementOperations extends AbstractKapuaResource { /** * Gets the {@link DeviceManagementOperation} list in the scope. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param deviceId The id of the {@link Device} in which to search results - * @param resource The resource of the {@link DeviceManagementOperation} in which to search results - * @param offset The result set offset. - * @param limit The result set limit. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param deviceId + * The id of the {@link Device} in which to search results + * @param resource + * The resource of the {@link DeviceManagementOperation} in which to search results + * @param offset + * The result set offset. + * @param limit + * The result set limit. * @return The {@link DeviceManagementOperationListResult} of all the deviceManagementOperations associated to the current selected scope. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @GET - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public DeviceManagementOperationListResult simpleQuery( @PathParam("scopeId") ScopeId scopeId, @PathParam("deviceId") EntityId deviceId, @@ -77,7 +84,7 @@ public DeviceManagementOperationListResult simpleQuery( @QueryParam("sortDir") @DefaultValue("ASCENDING") SortOrder sortDir, @QueryParam("offset") @DefaultValue("0") int offset, @QueryParam("limit") @DefaultValue("50") int limit) throws KapuaException { - DeviceManagementOperationQuery query = deviceManagementOperationFactory.newQuery(scopeId); + DeviceManagementOperationQuery query = new DeviceManagementOperationQuery(scopeId); AndPredicate andPredicate = query.andPredicate(); @@ -110,25 +117,29 @@ public DeviceManagementOperationListResult simpleQuery( /** * Queries the results with the given {@link DeviceManagementOperationQuery} parameter. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param deviceId The id of the {@link Device} in which to search results - * @param query The {@link DeviceManagementOperationQuery} to use to filter results. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param deviceId + * The id of the {@link Device} in which to search results + * @param query + * The {@link DeviceManagementOperationQuery} to use to filter results. * @return The {@link DeviceManagementOperationListResult} of all the result matching the given {@link DeviceManagementOperationQuery} parameter. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @POST @Path("_query") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public DeviceManagementOperationListResult query( @PathParam("scopeId") ScopeId scopeId, @PathParam("deviceId") EntityId deviceId, DeviceManagementOperationQuery query) throws KapuaException { if (query.getPredicate() != null) { final AndPredicate andPredicate = query.andPredicate( - query.attributePredicate(DeviceManagementOperationAttributes.DEVICE_ID, deviceId), - query.getPredicate() + query.attributePredicate(DeviceManagementOperationAttributes.DEVICE_ID, deviceId), + query.getPredicate() ); query.setPredicate(andPredicate); } else { @@ -140,17 +151,21 @@ public DeviceManagementOperationListResult query( /** * Counts the results with the given {@link DeviceManagementOperationQuery} parameter. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param deviceId The id of the {@link Device} in which to search results - * @param query The {@link DeviceManagementOperationQuery} to use to filter results. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param deviceId + * The id of the {@link Device} in which to search results + * @param query + * The {@link DeviceManagementOperationQuery} to use to filter results. * @return The count of all the result matching the given {@link DeviceManagementOperationQuery} parameter. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @POST @Path("_count") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public CountResult count( @PathParam("scopeId") ScopeId scopeId, @PathParam("deviceId") EntityId deviceId, @@ -164,21 +179,25 @@ public CountResult count( /** * Returns the DeviceManagementOperation specified by the "deviceManagementOperationId" path parameter. * - * @param scopeId The {@link ScopeId} of the requested {@link DeviceManagementOperation}. - * @param deviceId The {@link Device} id of the request {@link DeviceManagementOperation}. - * @param deviceManagementOperationId The id of the requested DeviceManagementOperation. + * @param scopeId + * The {@link ScopeId} of the requested {@link DeviceManagementOperation}. + * @param deviceId + * The {@link Device} id of the request {@link DeviceManagementOperation}. + * @param deviceManagementOperationId + * The id of the requested DeviceManagementOperation. * @return The requested DeviceManagementOperation object. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @GET @Path("{deviceManagementOperationId}") - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public DeviceManagementOperation find( @PathParam("scopeId") ScopeId scopeId, @PathParam("deviceId") EntityId deviceId, @PathParam("deviceManagementOperationId") EntityId deviceManagementOperationId) throws KapuaException { - DeviceManagementOperationQuery query = deviceManagementOperationFactory.newQuery(scopeId); + DeviceManagementOperationQuery query = new DeviceManagementOperationQuery(scopeId); AndPredicate andPredicate = query.andPredicate( query.attributePredicate(DeviceManagementOperationAttributes.DEVICE_ID, deviceId), @@ -197,17 +216,20 @@ public DeviceManagementOperation find( /** * Deletes the DeviceManagementOperation specified by the "deviceManagementOperationId" path parameter. * - * @param deviceId The id of the Device in which to delete the ManagementOperation - * @param deviceManagementOperationId The id of the DeviceManagementOperation to be deleted. + * @param deviceId + * The id of the Device in which to delete the ManagementOperation + * @param deviceManagementOperationId + * The id of the DeviceManagementOperation to be deleted. * @return HTTP 200 if operation has completed successfully. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @DELETE @Path("{deviceManagementOperationId}") public Response deleteDeviceManagementOperation(@PathParam("scopeId") ScopeId scopeId, - @PathParam("deviceId") EntityId deviceId, - @PathParam("deviceManagementOperationId") EntityId deviceManagementOperationId) throws KapuaException { + @PathParam("deviceId") EntityId deviceId, + @PathParam("deviceManagementOperationId") EntityId deviceManagementOperationId) throws KapuaException { deviceManagementOperationRegistryService.delete(scopeId, deviceManagementOperationId); return returnNoContent(); diff --git a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/Devices.java b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/Devices.java index 8bfea63283d..98f7948d111 100644 --- a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/Devices.java +++ b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/Devices.java @@ -12,7 +12,22 @@ *******************************************************************************/ package org.eclipse.kapua.app.api.resources.v1.resources; -import com.google.common.base.Strings; +import java.util.List; + +import javax.inject.Inject; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.DefaultValue; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.app.api.core.model.CountResult; import org.eclipse.kapua.app.api.core.model.EntityId; @@ -31,20 +46,7 @@ import org.eclipse.kapua.service.device.registry.connection.DeviceConnectionStatus; import org.eclipse.kapua.service.tag.Tag; -import javax.inject.Inject; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import java.util.List; +import com.google.common.base.Strings; @Path("{scopeId}/devices") public class Devices extends AbstractKapuaResource { @@ -57,23 +59,35 @@ public class Devices extends AbstractKapuaResource { /** * Gets the {@link Device} list in the scope. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param tagId The id of the {@link Tag} in which to search results - * @param clientId The id of the {@link Device} in which to search results - * @param connectionStatus The {@link DeviceConnectionStatus} in which to search results - * @param matchTerm A term to be matched in at least one of the configured fields of this entity - * @param fetchAttributes Additional attributes to be returned. Allowed values: connection, lastEvent - * @param askTotalCount Ask for the total count of the matched entities in the result - * @param sortParam The name of the parameter that will be used as a sorting key - * @param sortDir The sort direction. Can be ASCENDING (default), DESCENDING. Case-insensitive. - * @param offset The result set offset. - * @param limit The result set limit. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param tagId + * The id of the {@link Tag} in which to search results + * @param clientId + * The id of the {@link Device} in which to search results + * @param connectionStatus + * The {@link DeviceConnectionStatus} in which to search results + * @param matchTerm + * A term to be matched in at least one of the configured fields of this entity + * @param fetchAttributes + * Additional attributes to be returned. Allowed values: connection, lastEvent + * @param askTotalCount + * Ask for the total count of the matched entities in the result + * @param sortParam + * The name of the parameter that will be used as a sorting key + * @param sortDir + * The sort direction. Can be ASCENDING (default), DESCENDING. Case-insensitive. + * @param offset + * The result set offset. + * @param limit + * The result set limit. * @return The {@link DeviceListResult} of all the devices associated to the current selected scope. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @GET - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public DeviceListResult simpleQuery( @PathParam("scopeId") ScopeId scopeId, @QueryParam("tagId") EntityId tagId, @@ -86,7 +100,7 @@ public DeviceListResult simpleQuery( @QueryParam("sortDir") @DefaultValue("ASCENDING") SortOrder sortDir, @QueryParam("offset") @DefaultValue("0") int offset, @QueryParam("limit") @DefaultValue("50") int limit) throws KapuaException { - DeviceQuery query = deviceFactory.newQuery(scopeId); + DeviceQuery query = new DeviceQuery(scopeId); AndPredicate andPredicate = query.andPredicate(); if (tagId != null) { @@ -118,16 +132,19 @@ public DeviceListResult simpleQuery( /** * Queries the results with the given {@link DeviceQuery} parameter. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param query The {@link DeviceQuery} to use to filter results. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param query + * The {@link DeviceQuery} to use to filter results. * @return The {@link DeviceListResult} of all the result matching the given {@link DeviceQuery} parameter. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @POST @Path("_query") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public DeviceListResult query( @PathParam("scopeId") ScopeId scopeId, DeviceQuery query) throws KapuaException { @@ -139,16 +156,19 @@ public DeviceListResult query( /** * Counts the results with the given {@link DeviceQuery} parameter. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param query The {@link DeviceQuery} to use to filter results. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param query + * The {@link DeviceQuery} to use to filter results. * @return The count of all the result matching the given {@link DeviceQuery} parameter. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @POST @Path("_count") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public CountResult count( @PathParam("scopeId") ScopeId scopeId, DeviceQuery query) throws KapuaException { @@ -158,18 +178,20 @@ public CountResult count( } /** - * Creates a new Device based on the information provided in DeviceCreator - * parameter. + * Creates a new Device based on the information provided in DeviceCreator parameter. * - * @param scopeId The {@link ScopeId} in which to create the {@link Device} - * @param deviceCreator Provides the information for the new Device to be created. + * @param scopeId + * The {@link ScopeId} in which to create the {@link Device} + * @param deviceCreator + * Provides the information for the new Device to be created. * @return The newly created Device object. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @POST - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public Response create( @PathParam("scopeId") ScopeId scopeId, DeviceCreator deviceCreator) throws KapuaException { @@ -181,15 +203,18 @@ public Response create( /** * Returns the Device specified by the "deviceId" path parameter. * - * @param scopeId The {@link ScopeId} of the requested {@link Device}. - * @param deviceId The id of the requested Device. + * @param scopeId + * The {@link ScopeId} of the requested {@link Device}. + * @param deviceId + * The id of the requested Device. * @return The requested Device object. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @GET @Path("{deviceId}") - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public Device find( @PathParam("scopeId") ScopeId scopeId, @PathParam("deviceId") EntityId deviceId) throws KapuaException { @@ -201,17 +226,21 @@ public Device find( /** * Updates the Device based on the information provided in the Device parameter. * - * @param scopeId The ScopeId of the requested Device. - * @param deviceId The id of the requested {@link Device} - * @param device The modified Device whose attributed need to be updated. + * @param scopeId + * The ScopeId of the requested Device. + * @param deviceId + * The id of the requested {@link Device} + * @param device + * The modified Device whose attributed need to be updated. * @return The updated device. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @PUT @Path("{deviceId}") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public Device update( @PathParam("scopeId") ScopeId scopeId, @PathParam("deviceId") EntityId deviceId, @@ -225,10 +254,13 @@ public Device update( /** * Deletes the Device specified by the "deviceId" path parameter. * - * @param scopeId The ScopeId of the requested {@link Device}. - * @param deviceId The id of the Device to be deleted. + * @param scopeId + * The ScopeId of the requested {@link Device}. + * @param deviceId + * The id of the Device to be deleted. * @return HTTP 200 if operation has completed successfully. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @DELETE diff --git a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/Domains.java b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/Domains.java index 9effc5a8d46..258bc5bad55 100644 --- a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/Domains.java +++ b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/Domains.java @@ -12,59 +12,63 @@ *******************************************************************************/ package org.eclipse.kapua.app.api.resources.v1.resources; -import com.google.common.base.Strings; +import javax.inject.Inject; +import javax.ws.rs.Consumes; +import javax.ws.rs.DefaultValue; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; + import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.app.api.core.model.CountResult; import org.eclipse.kapua.app.api.core.model.EntityId; import org.eclipse.kapua.app.api.core.model.ScopeId; import org.eclipse.kapua.app.api.core.resources.AbstractKapuaResource; import org.eclipse.kapua.model.KapuaNamedEntityAttributes; +import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.model.query.KapuaQuery; import org.eclipse.kapua.model.query.predicate.AndPredicate; import org.eclipse.kapua.service.KapuaService; import org.eclipse.kapua.service.authorization.domain.Domain; -import org.eclipse.kapua.service.authorization.domain.DomainFactory; import org.eclipse.kapua.service.authorization.domain.DomainListResult; -import org.eclipse.kapua.service.authorization.domain.DomainQuery; import org.eclipse.kapua.service.authorization.domain.DomainRegistryService; -import javax.inject.Inject; -import javax.ws.rs.Consumes; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; +import com.google.common.base.Strings; @Path("{scopeId}/domains") public class Domains extends AbstractKapuaResource { @Inject public DomainRegistryService domainRegistryService; - @Inject - public DomainFactory domainFactory; /** * Gets the {@link Domain} list in the scope. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param name The {@link Domain} name in which to search results. - * @param offset The result set offset. - * @param limit The result set limit. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param name + * The {@link Domain} name in which to search results. + * @param offset + * The result set offset. + * @param limit + * The result set limit. * @return The {@link DomainListResult} of all the domains associated to the current selected scope. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @GET - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public DomainListResult simpleQuery( @PathParam("scopeId") ScopeId scopeId, @QueryParam("name") String name, @QueryParam("offset") @DefaultValue("0") int offset, @QueryParam("limit") @DefaultValue("50") int limit) throws KapuaException { - DomainQuery query = domainFactory.newQuery(null); + final KapuaQuery query = new KapuaQuery((KapuaId) null); AndPredicate andPredicate = query.andPredicate(); if (!Strings.isNullOrEmpty(name)) { @@ -79,55 +83,64 @@ public DomainListResult simpleQuery( } /** - * Queries the results with the given {@link DomainQuery} parameter. + * Queries the results with the given {@link KapuaQuery} parameter. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param query The {@link DomainQuery} to use to filter results. - * @return The {@link DomainListResult} of all the result matching the given {@link DomainQuery} parameter. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param query + * The {@link KapuaQuery} to use to filter results. + * @return The {@link DomainListResult} of all the result matching the given {@link KapuaQuery} parameter. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @POST @Path("_query") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public DomainListResult query( @PathParam("scopeId") ScopeId scopeId, - DomainQuery query) throws KapuaException { + KapuaQuery query) throws KapuaException { return domainRegistryService.query(query); } /** - * Counts the results with the given {@link DomainQuery} parameter. + * Counts the results with the given {@link KapuaQuery} parameter. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param query The {@link DomainQuery} to use to filter results. - * @return The count of all the result matching the given {@link DomainQuery} parameter. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param query + * The {@link KapuaQuery} to use to filter results. + * @return The count of all the result matching the given {@link KapuaQuery} parameter. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @POST @Path("_count") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public CountResult count( @PathParam("scopeId") ScopeId scopeId, - DomainQuery query) throws KapuaException { + KapuaQuery query) throws KapuaException { return new CountResult(domainRegistryService.count(query)); } /** * Returns the Domain specified by the "domainId" path parameter. * - * @param scopeId The {@link ScopeId} of the requested {@link Domain}. - * @param domainId The id of the requested {@link Domain}. + * @param scopeId + * The {@link ScopeId} of the requested {@link Domain}. + * @param domainId + * The id of the requested {@link Domain}. * @return The requested Domain object. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @GET @Path("{domainId}") - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public Domain find( @PathParam("scopeId") ScopeId scopeId, @PathParam("domainId") EntityId domainId) throws KapuaException { diff --git a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/Groups.java b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/Groups.java index 5eb39d15aa4..38e1f6f0124 100644 --- a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/Groups.java +++ b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/Groups.java @@ -26,7 +26,6 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import com.google.common.base.Strings; import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.app.api.core.model.CountResult; import org.eclipse.kapua.app.api.core.model.EntityId; @@ -43,6 +42,8 @@ import org.eclipse.kapua.service.authorization.group.GroupQuery; import org.eclipse.kapua.service.authorization.group.GroupService; +import com.google.common.base.Strings; + @Path("{scopeId}/groups") public class Groups extends AbstractKapuaResource { @@ -54,16 +55,21 @@ public class Groups extends AbstractKapuaResource { /** * Gets the {@link Group} list in the scope. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param name The {@link Group} name to filter results - * @param offset The result set offset. - * @param limit The result set limit. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param name + * The {@link Group} name to filter results + * @param offset + * The result set offset. + * @param limit + * The result set limit. * @return The {@link GroupListResult} of all the groups associated to the current selected scope. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @GET - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public GroupListResult simpleQuery( @PathParam("scopeId") ScopeId scopeId, @QueryParam("name") String name, @@ -73,7 +79,7 @@ public GroupListResult simpleQuery( @QueryParam("sortDir") @DefaultValue("ASCENDING") SortOrder sortDir, @QueryParam("offset") @DefaultValue("0") int offset, @QueryParam("limit") @DefaultValue("50") int limit) throws KapuaException { - GroupQuery query = groupFactory.newQuery(scopeId); + final GroupQuery query = new GroupQuery(scopeId); AndPredicate andPredicate = query.andPredicate(); if (!Strings.isNullOrEmpty(name)) { @@ -97,16 +103,19 @@ public GroupListResult simpleQuery( /** * Queries the results with the given {@link GroupQuery} parameter. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param query The {@link GroupQuery} to use to filter results. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param query + * The {@link GroupQuery} to use to filter results. * @return The {@link GroupListResult} of all the result matching the given {@link GroupQuery} parameter. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @POST @Path("_query") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public GroupListResult query( @PathParam("scopeId") ScopeId scopeId, GroupQuery query) throws KapuaException { @@ -118,16 +127,19 @@ public GroupListResult query( /** * Counts the results with the given {@link GroupQuery} parameter. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param query The {@link GroupQuery} to use to filter results. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param query + * The {@link GroupQuery} to use to filter results. * @return The count of all the result matching the given {@link GroupQuery} parameter. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @POST @Path("_count") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public CountResult count( @PathParam("scopeId") ScopeId scopeId, GroupQuery query) throws KapuaException { @@ -137,16 +149,17 @@ public CountResult count( } /** - * Creates a new Group based on the information provided in GroupCreator - * parameter. + * Creates a new Group based on the information provided in GroupCreator parameter. * - * @param scopeId The {@link ScopeId} in which to create the {@link Group} - * @param groupCreator Provides the information for the new {@link Group} to be created. + * @param scopeId + * The {@link ScopeId} in which to create the {@link Group} + * @param groupCreator + * Provides the information for the new {@link Group} to be created. * @return The newly created {@link Group} object. */ @POST - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public Response create( @PathParam("scopeId") ScopeId scopeId, GroupCreator groupCreator) throws KapuaException { @@ -158,15 +171,18 @@ public Response create( /** * Returns the Group specified by the "groupId" path parameter. * - * @param scopeId The {@link ScopeId} of the requested {@link Group}. - * @param groupId The id of the requested Group. + * @param scopeId + * The {@link ScopeId} of the requested {@link Group}. + * @param groupId + * The id of the requested Group. * @return The requested Group object. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @GET @Path("{groupId}") - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public Group find( @PathParam("scopeId") ScopeId scopeId, @PathParam("groupId") EntityId groupId) throws KapuaException { @@ -178,17 +194,21 @@ public Group find( /** * Updates the Group based on the information provided in the Group parameter. * - * @param scopeId The ScopeId of the requested {@link Group}. - * @param groupId The id of the requested {@link Group} - * @param group The modified Group whose attributed need to be updated. + * @param scopeId + * The ScopeId of the requested {@link Group}. + * @param groupId + * The id of the requested {@link Group} + * @param group + * The modified Group whose attributed need to be updated. * @return The updated group. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @PUT @Path("{groupId}") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public Group update( @PathParam("scopeId") ScopeId scopeId, @PathParam("groupId") EntityId groupId, @@ -202,10 +222,13 @@ public Group update( /** * Deletes the Group specified by the "groupId" path parameter. * - * @param scopeId The ScopeId of the requested {@link Group}. - * @param groupId The id of the Group to be deleted. + * @param scopeId + * The ScopeId of the requested {@link Group}. + * @param groupId + * The id of the Group to be deleted. * @return HTTP 200 if operation has completed successfully. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @DELETE diff --git a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/JobExecutions.java b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/JobExecutions.java index 4c0b6661783..812304a628d 100644 --- a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/JobExecutions.java +++ b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/JobExecutions.java @@ -23,7 +23,6 @@ import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; -import com.google.common.base.Strings; import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.app.api.core.model.CountResult; import org.eclipse.kapua.app.api.core.model.DateParam; @@ -31,6 +30,7 @@ import org.eclipse.kapua.app.api.core.model.ScopeId; import org.eclipse.kapua.app.api.core.resources.AbstractKapuaResource; import org.eclipse.kapua.model.KapuaEntityAttributes; +import org.eclipse.kapua.model.query.KapuaQuery; import org.eclipse.kapua.model.query.SortOrder; import org.eclipse.kapua.model.query.predicate.AndPredicate; import org.eclipse.kapua.model.query.predicate.AttributePredicate; @@ -44,9 +44,10 @@ import org.eclipse.kapua.service.job.execution.JobExecutionService; import org.eclipse.kapua.service.job.targets.JobTargetFactory; import org.eclipse.kapua.service.job.targets.JobTargetListResult; -import org.eclipse.kapua.service.job.targets.JobTargetQuery; import org.eclipse.kapua.service.job.targets.JobTargetService; +import com.google.common.base.Strings; + @Path("{scopeId}/jobs/{jobId}/executions") public class JobExecutions extends AbstractKapuaResource { @@ -62,19 +63,27 @@ public class JobExecutions extends AbstractKapuaResource { /** * Gets the {@link JobExecution} list for a given {@link Job}. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param jobId The {@link Job} id to filter results - * @param askTotalCount Ask for the total count of the matched entities in the result - * @param sortParam The name of the parameter that will be used as a sorting key - * @param sortDir The sort direction. Can be ASCENDING (default), DESCENDING. Case-insensitive. - * @param offset The result set offset. - * @param limit The result set limit. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param jobId + * The {@link Job} id to filter results + * @param askTotalCount + * Ask for the total count of the matched entities in the result + * @param sortParam + * The name of the parameter that will be used as a sorting key + * @param sortDir + * The sort direction. Can be ASCENDING (default), DESCENDING. Case-insensitive. + * @param offset + * The result set offset. + * @param limit + * The result set limit. * @return The {@link JobExecutionListResult} of all the jobs executions associated to the current selected job. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @GET - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public JobExecutionListResult simpleQuery( @PathParam("scopeId") ScopeId scopeId, @PathParam("jobId") EntityId jobId, @@ -85,7 +94,7 @@ public JobExecutionListResult simpleQuery( @QueryParam("sortDir") @DefaultValue("ASCENDING") SortOrder sortDir, @QueryParam("offset") @DefaultValue("0") int offset, @QueryParam("limit") @DefaultValue("50") int limit) throws KapuaException { - JobExecutionQuery query = jobExecutionFactory.newQuery(scopeId); + JobExecutionQuery query = new JobExecutionQuery(scopeId); AndPredicate andPredicate = query.andPredicate(query.attributePredicate(JobExecutionAttributes.JOB_ID, jobId)); @@ -112,24 +121,27 @@ public JobExecutionListResult simpleQuery( /** * Queries the results with the given {@link JobExecutionQuery} parameter. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param query The {@link JobExecutionQuery} to use to filter results. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param query + * The {@link JobExecutionQuery} to use to filter results. * @return The {@link JobExecutionListResult} of all the result matching the given {@link JobExecutionQuery} parameter. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @POST @Path("_query") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public JobExecutionListResult query( @PathParam("scopeId") ScopeId scopeId, @PathParam("jobId") EntityId jobId, JobExecutionQuery query) throws KapuaException { query.setScopeId(scopeId); final AndPredicate andPredicate = query.andPredicate( - query.attributePredicate(JobExecutionAttributes.JOB_ID, jobId), - query.getPredicate() + query.attributePredicate(JobExecutionAttributes.JOB_ID, jobId), + query.getPredicate() ); query.setPredicate(andPredicate); return jobExecutionService.query(query); @@ -138,16 +150,19 @@ public JobExecutionListResult query( /** * Counts the results with the given {@link JobExecutionQuery} parameter. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param query The {@link JobExecutionQuery} to use to filter results. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param query + * The {@link JobExecutionQuery} to use to filter results. * @return The count of all the result matching the given {@link JobExecutionQuery} parameter. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @POST @Path("_count") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public CountResult count( @PathParam("scopeId") ScopeId scopeId, @PathParam("jobId") EntityId jobId, @@ -161,21 +176,25 @@ public CountResult count( /** * Returns the Job specified by the "jobId" path parameter. * - * @param scopeId The {@link ScopeId} of the requested {@link Job}. - * @param jobId The id of the requested Job. - * @param executionId The id of the requested JobExecution. + * @param scopeId + * The {@link ScopeId} of the requested {@link Job}. + * @param jobId + * The id of the requested Job. + * @param executionId + * The id of the requested JobExecution. * @return The requested Job object. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @GET @Path("{executionId}") - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public JobExecution find( @PathParam("scopeId") ScopeId scopeId, @PathParam("jobId") EntityId jobId, @PathParam("executionId") EntityId executionId) throws KapuaException { - JobExecutionQuery jobExecutionQuery = jobExecutionFactory.newQuery(scopeId); + JobExecutionQuery jobExecutionQuery = new JobExecutionQuery(scopeId); jobExecutionQuery.setPredicate(jobExecutionQuery.andPredicate( jobExecutionQuery.attributePredicate(JobExecutionAttributes.JOB_ID, jobId), jobExecutionQuery.attributePredicate(KapuaEntityAttributes.ENTITY_ID, executionId) @@ -189,7 +208,7 @@ public JobExecution find( @GET @Path("{executionId}/targets") - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public JobTargetListResult executionsByTarget( @PathParam("scopeId") ScopeId scopeId, @PathParam("jobId") EntityId jobId, @@ -197,7 +216,7 @@ public JobTargetListResult executionsByTarget( @QueryParam("offset") @DefaultValue("0") int offset, @QueryParam("limit") @DefaultValue("50") int limit) throws KapuaException { JobExecution jobExecution = jobExecutionService.find(scopeId, executionId); - JobTargetQuery jobTargetQuery = jobTargetFactory.newQuery(scopeId); + KapuaQuery jobTargetQuery = new KapuaQuery(scopeId); jobTargetQuery.setPredicate(jobTargetQuery.attributePredicate(KapuaEntityAttributes.ENTITY_ID, jobExecution.getTargetIds())); jobTargetQuery.setLimit(limit); jobTargetQuery.setOffset(offset); diff --git a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/JobStepDefinitions.java b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/JobStepDefinitions.java index d6109fb64e3..fe5071c9ff1 100644 --- a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/JobStepDefinitions.java +++ b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/JobStepDefinitions.java @@ -12,34 +12,35 @@ *******************************************************************************/ package org.eclipse.kapua.app.api.resources.v1.resources; -import com.google.common.base.Strings; +import javax.inject.Inject; +import javax.ws.rs.Consumes; +import javax.ws.rs.DefaultValue; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; + import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.app.api.core.model.CountResult; import org.eclipse.kapua.app.api.core.model.EntityId; import org.eclipse.kapua.app.api.core.model.ScopeId; import org.eclipse.kapua.app.api.core.resources.AbstractKapuaResource; +import org.eclipse.kapua.model.query.KapuaQuery; import org.eclipse.kapua.model.query.SortOrder; import org.eclipse.kapua.service.KapuaService; import org.eclipse.kapua.service.job.Job; import org.eclipse.kapua.service.job.step.JobStep; import org.eclipse.kapua.service.job.step.JobStepListResult; -import org.eclipse.kapua.service.job.step.JobStepQuery; import org.eclipse.kapua.service.job.step.definition.JobStepDefinition; import org.eclipse.kapua.service.job.step.definition.JobStepDefinitionFactory; import org.eclipse.kapua.service.job.step.definition.JobStepDefinitionListResult; import org.eclipse.kapua.service.job.step.definition.JobStepDefinitionQuery; import org.eclipse.kapua.service.job.step.definition.JobStepDefinitionService; -import javax.inject.Inject; -import javax.ws.rs.Consumes; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; +import com.google.common.base.Strings; @Path("{scopeId}/jobStepDefinitions") public class JobStepDefinitions extends AbstractKapuaResource { @@ -52,17 +53,23 @@ public class JobStepDefinitions extends AbstractKapuaResource { /** * Gets the {@link JobStep} list for a given {@link Job}. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param sortParam The name of the parameter that will be used as a sorting key - * @param sortDir The sort direction. Can be ASCENDING (default), DESCENDING. Case-insensitive. - * @param offset The result set offset. - * @param limit The result set limit. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param sortParam + * The name of the parameter that will be used as a sorting key + * @param sortDir + * The sort direction. Can be ASCENDING (default), DESCENDING. Case-insensitive. + * @param offset + * The result set offset. + * @param limit + * The result set limit. * @return The {@link JobStepListResult} of all the jobs jobSteps associated to the current selected job. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.5.0 */ @GET - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public JobStepDefinitionListResult simpleQuery( @PathParam("scopeId") ScopeId scopeId, @QueryParam("sortParam") String sortParam, @@ -70,7 +77,7 @@ public JobStepDefinitionListResult simpleQuery( @QueryParam("offset") @DefaultValue("0") int offset, @QueryParam("limit") @DefaultValue("50") int limit) throws KapuaException { - JobStepDefinitionQuery query = jobStepDefinitionFactory.newQuery(scopeId); + JobStepDefinitionQuery query = new JobStepDefinitionQuery(scopeId); if (!Strings.isNullOrEmpty(sortParam)) { query.setSortCriteria(query.fieldSortCriteria(sortParam, sortDir)); @@ -83,18 +90,21 @@ public JobStepDefinitionListResult simpleQuery( } /** - * Queries the results with the given {@link JobStepQuery} parameter. + * Queries the results with the given {@link JobStepDefinitionQuery} parameter. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param query The {@link JobStepQuery} to use to filter results. - * @return The {@link JobStepListResult} of all the result matching the given {@link JobStepQuery} parameter. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param query + * The {@link JobStepDefinitionQuery} to use to filter results. + * @return The {@link JobStepListResult} of all the result matching the given {@link JobStepDefinitionQuery} parameter. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.5.0 */ @POST @Path("_query") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public JobStepDefinitionListResult query( @PathParam("scopeId") ScopeId scopeId, JobStepDefinitionQuery query) throws KapuaException { @@ -104,21 +114,24 @@ public JobStepDefinitionListResult query( } /** - * Counts the results with the given {@link JobStepQuery} parameter. + * Counts the results with the given {@link KapuaQuery} parameter. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param query The {@link JobStepQuery} to use to filter results. - * @return The count of all the result matching the given {@link JobStepQuery} parameter. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param query + * The {@link KapuaQuery} to use to filter results. + * @return The count of all the result matching the given {@link KapuaQuery} parameter. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.5.0 */ @POST @Path("_count") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public CountResult count( @PathParam("scopeId") ScopeId scopeId, - JobStepQuery query) throws KapuaException { + KapuaQuery query) throws KapuaException { query.setScopeId(scopeId); return new CountResult(jobStepDefinitionService.count(query)); @@ -127,15 +140,18 @@ public CountResult count( /** * Returns the Job specified by the "jobId" path parameter. * - * @param scopeId The {@link ScopeId} of the requested {@link Job}. - * @param stepDefinitionId The id of the requested JobStep. + * @param scopeId + * The {@link ScopeId} of the requested {@link Job}. + * @param stepDefinitionId + * The id of the requested JobStep. * @return The requested Job object. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.5.0 */ @GET @Path("{stepDefinitionId}") - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public JobStepDefinition find( @PathParam("scopeId") ScopeId scopeId, @PathParam("stepDefinitionId") EntityId stepDefinitionId) throws KapuaException { diff --git a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/JobSteps.java b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/JobSteps.java index e545f351bcd..cec577c28e3 100644 --- a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/JobSteps.java +++ b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/JobSteps.java @@ -12,13 +12,27 @@ *******************************************************************************/ package org.eclipse.kapua.app.api.resources.v1.resources; -import com.google.common.base.Strings; +import javax.inject.Inject; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.DefaultValue; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.app.api.core.model.CountResult; import org.eclipse.kapua.app.api.core.model.EntityId; import org.eclipse.kapua.app.api.core.model.ScopeId; import org.eclipse.kapua.app.api.core.resources.AbstractKapuaResource; import org.eclipse.kapua.model.KapuaNamedEntityAttributes; +import org.eclipse.kapua.model.query.KapuaQuery; import org.eclipse.kapua.model.query.SortOrder; import org.eclipse.kapua.model.query.predicate.AndPredicate; import org.eclipse.kapua.model.query.predicate.QueryPredicate; @@ -29,22 +43,9 @@ import org.eclipse.kapua.service.job.step.JobStepCreator; import org.eclipse.kapua.service.job.step.JobStepFactory; import org.eclipse.kapua.service.job.step.JobStepListResult; -import org.eclipse.kapua.service.job.step.JobStepQuery; import org.eclipse.kapua.service.job.step.JobStepService; -import javax.inject.Inject; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; +import com.google.common.base.Strings; @Path("{scopeId}/jobs/{jobId}/steps") public class JobSteps extends AbstractKapuaResource { @@ -57,20 +58,29 @@ public class JobSteps extends AbstractKapuaResource { /** * Gets the {@link JobStep} list for a given {@link Job}. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param jobId The {@link Job} id to filter results - * @param name The name of the {@link JobStep} to filter result - * @param sortParam The name of the parameter that will be used as a sorting key - * @param sortDir The sort direction. Can be ASCENDING (default), DESCENDING. Case-insensitive. - * @param askTotalCount Ask for the total count of the matched entities in the result - * @param offset The result set offset. - * @param limit The result set limit. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param jobId + * The {@link Job} id to filter results + * @param name + * The name of the {@link JobStep} to filter result + * @param sortParam + * The name of the parameter that will be used as a sorting key + * @param sortDir + * The sort direction. Can be ASCENDING (default), DESCENDING. Case-insensitive. + * @param askTotalCount + * Ask for the total count of the matched entities in the result + * @param offset + * The result set offset. + * @param limit + * The result set limit. * @return The {@link JobStepListResult} of all the jobs jobSteps associated to the current selected job. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @GET - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public JobStepListResult simpleQuery( @PathParam("scopeId") ScopeId scopeId, @PathParam("jobId") EntityId jobId, @@ -81,7 +91,7 @@ public JobStepListResult simpleQuery( @QueryParam("offset") @DefaultValue("0") int offset, @QueryParam("limit") @DefaultValue("50") int limit) throws KapuaException { - JobStepQuery query = jobStepFactory.newQuery(scopeId); + KapuaQuery query = new KapuaQuery(scopeId); AndPredicate andPredicate = query.andPredicate(query.attributePredicate(JobStepAttributes.JOB_ID, jobId)); @@ -103,22 +113,25 @@ public JobStepListResult simpleQuery( } /** - * Queries the results with the given {@link JobStepQuery} parameter. + * Queries the results with the given {@link KapuaQuery} parameter. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param query The {@link JobStepQuery} to use to filter results. - * @return The {@link JobStepListResult} of all the result matching the given {@link JobStepQuery} parameter. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param query + * The {@link KapuaQuery} to use to filter results. + * @return The {@link JobStepListResult} of all the result matching the given {@link KapuaQuery} parameter. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @POST @Path("_query") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public JobStepListResult query( @PathParam("scopeId") ScopeId scopeId, @PathParam("jobId") EntityId jobId, - JobStepQuery query) throws KapuaException { + KapuaQuery query) throws KapuaException { query.setScopeId(scopeId); QueryPredicate predicate; if (query.getPredicate() != null) { @@ -131,22 +144,25 @@ public JobStepListResult query( } /** - * Counts the results with the given {@link JobStepQuery} parameter. + * Counts the results with the given {@link KapuaQuery} parameter. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param query The {@link JobStepQuery} to use to filter results. - * @return The count of all the result matching the given {@link JobStepQuery} parameter. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param query + * The {@link KapuaQuery} to use to filter results. + * @return The count of all the result matching the given {@link KapuaQuery} parameter. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @POST @Path("_count") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public CountResult count( @PathParam("scopeId") ScopeId scopeId, @PathParam("jobId") EntityId jobId, - JobStepQuery query) throws KapuaException { + KapuaQuery query) throws KapuaException { query.setScopeId(scopeId); query.setPredicate(query.attributePredicate(JobStepAttributes.JOB_ID, jobId)); @@ -156,16 +172,20 @@ public CountResult count( /** * Returns the Job specified by the "jobId" path parameter. * - * @param scopeId The {@link ScopeId} of the requested {@link Job}. - * @param jobId The id of the requested Job. - * @param stepId The id of the requested JobStep. + * @param scopeId + * The {@link ScopeId} of the requested {@link Job}. + * @param jobId + * The id of the requested Job. + * @param stepId + * The id of the requested JobStep. * @return The requested Job object. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @GET @Path("{stepId}") - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public JobStep find( @PathParam("scopeId") ScopeId scopeId, @PathParam("jobId") EntityId jobId, @@ -174,19 +194,22 @@ public JobStep find( } /** - * Creates a new {@link JobStep} based on the information provided in {@link JobStepCreator} - * parameter. + * Creates a new {@link JobStep} based on the information provided in {@link JobStepCreator} parameter. * - * @param scopeId The {@link ScopeId} in which to create the {@link JobStep} - * @param jobId The ID of the {@link Job} to attach the {@link JobStep} to - * @param jobStepCreator Provides the information for the new {@link JobStep} to be created. + * @param scopeId + * The {@link ScopeId} in which to create the {@link JobStep} + * @param jobId + * The ID of the {@link Job} to attach the {@link JobStep} to + * @param jobStepCreator + * Provides the information for the new {@link JobStep} to be created. * @return The newly created {@link JobStep} object. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.5.0 */ @POST - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public Response create( @PathParam("scopeId") ScopeId scopeId, @PathParam("jobId") EntityId jobId, @@ -197,21 +220,25 @@ public Response create( } /** - * Updates a new {@link JobStep} based on the information provided in {@link JobStep} - * parameter. + * Updates a new {@link JobStep} based on the information provided in {@link JobStep} parameter. * - * @param scopeId The {@link ScopeId} in which to create the {@link JobStep} - * @param jobId The ID of the {@link Job} to attach the {@link JobStep} to - * @param jobStep Provides the information for the new {@link JobStep} to be created. - * @param jobStepId The ID of the {@link JobStep} to be updated + * @param scopeId + * The {@link ScopeId} in which to create the {@link JobStep} + * @param jobId + * The ID of the {@link Job} to attach the {@link JobStep} to + * @param jobStep + * Provides the information for the new {@link JobStep} to be created. + * @param jobStepId + * The ID of the {@link JobStep} to be updated * @return The newly created {@link JobStep} object. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.5.0 */ @PUT @Path("{stepId}") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public JobStep update( @PathParam("scopeId") ScopeId scopeId, @PathParam("jobId") EntityId jobId, @@ -226,10 +253,13 @@ public JobStep update( /** * Deletes the JobStep specified by the "stepId" path parameter. * - * @param scopeId The ScopeId of the requested {@link JobStep}. - * @param stepId The id of the JobStep to be deleted. + * @param scopeId + * The ScopeId of the requested {@link JobStep}. + * @param stepId + * The id of the JobStep to be deleted. * @return HTTP 201 if operation has completed successfully. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.5.0 */ @DELETE diff --git a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/JobTargets.java b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/JobTargets.java index 3e460bad8ee..d05800be133 100644 --- a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/JobTargets.java +++ b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/JobTargets.java @@ -12,7 +12,19 @@ *******************************************************************************/ package org.eclipse.kapua.app.api.resources.v1.resources; -import com.google.common.base.Strings; +import javax.inject.Inject; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.DefaultValue; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.app.api.core.model.CountResult; import org.eclipse.kapua.app.api.core.model.EntityId; @@ -20,6 +32,7 @@ import org.eclipse.kapua.app.api.core.resources.AbstractKapuaResource; import org.eclipse.kapua.model.KapuaEntityAttributes; import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.model.query.KapuaQuery; import org.eclipse.kapua.model.query.SortOrder; import org.eclipse.kapua.model.query.predicate.AndPredicate; import org.eclipse.kapua.service.KapuaService; @@ -34,22 +47,10 @@ import org.eclipse.kapua.service.job.targets.JobTargetCreator; import org.eclipse.kapua.service.job.targets.JobTargetFactory; import org.eclipse.kapua.service.job.targets.JobTargetListResult; -import org.eclipse.kapua.service.job.targets.JobTargetQuery; import org.eclipse.kapua.service.job.targets.JobTargetService; import org.eclipse.kapua.service.job.targets.JobTargetStatus; -import javax.inject.Inject; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; +import com.google.common.base.Strings; @Path("{scopeId}/jobs/{jobId}/targets") public class JobTargets extends AbstractKapuaResource { @@ -66,19 +67,27 @@ public class JobTargets extends AbstractKapuaResource { /** * Gets the {@link JobTarget} list for a given {@link Job}. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param jobId The {@link Job} id to filter results - * @param sortParam The name of the parameter that will be used as a sorting key - * @param sortDir The sort direction. Can be ASCENDING (default), DESCENDING. Case-insensitive. - * @param askTotalCount Ask for the total count of the matched entities in the result - * @param offset The result set offset. - * @param limit The result set limit. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param jobId + * The {@link Job} id to filter results + * @param sortParam + * The name of the parameter that will be used as a sorting key + * @param sortDir + * The sort direction. Can be ASCENDING (default), DESCENDING. Case-insensitive. + * @param askTotalCount + * Ask for the total count of the matched entities in the result + * @param offset + * The result set offset. + * @param limit + * The result set limit. * @return The {@link JobTargetListResult} of all the jobs targets associated to the current selected job. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @GET - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public JobTargetListResult simpleQuery( @PathParam("scopeId") ScopeId scopeId, @PathParam("jobId") EntityId jobId, @@ -88,7 +97,7 @@ public JobTargetListResult simpleQuery( @QueryParam("askTotalCount") boolean askTotalCount, @QueryParam("offset") @DefaultValue("0") int offset, @QueryParam("limit") @DefaultValue("50") int limit) throws KapuaException { - JobTargetQuery query = jobTargetFactory.newQuery(scopeId); + KapuaQuery query = new KapuaQuery(scopeId); AndPredicate andPredicate = query.andPredicate(query.attributePredicate(JobExecutionAttributes.JOB_ID, jobId)); @@ -110,44 +119,50 @@ public JobTargetListResult simpleQuery( } /** - * Queries the results with the given {@link JobTargetQuery} parameter. + * Queries the results with the given {@link KapuaQuery} parameter. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param query The {@link JobTargetQuery} to use to filter results. - * @return The {@link JobTargetListResult} of all the result matching the given {@link JobTargetQuery} parameter. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param query + * The {@link KapuaQuery} to use to filter results. + * @return The {@link JobTargetListResult} of all the result matching the given {@link KapuaQuery} parameter. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @POST @Path("_query") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public JobTargetListResult query( @PathParam("scopeId") ScopeId scopeId, @PathParam("jobId") EntityId jobId, - JobTargetQuery query) throws KapuaException { + KapuaQuery query) throws KapuaException { query.setScopeId(scopeId); query.setPredicate(query.attributePredicate(JobTargetAttributes.JOB_ID, jobId)); return jobTargetService.query(query); } /** - * Counts the results with the given {@link JobTargetQuery} parameter. + * Counts the results with the given {@link KapuaQuery} parameter. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param query The {@link JobTargetQuery} to use to filter results. - * @return The count of all the result matching the given {@link JobTargetQuery} parameter. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param query + * The {@link KapuaQuery} to use to filter results. + * @return The count of all the result matching the given {@link KapuaQuery} parameter. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @POST @Path("_count") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public CountResult count( @PathParam("scopeId") ScopeId scopeId, @PathParam("jobId") EntityId jobId, - JobTargetQuery query) throws KapuaException { + KapuaQuery query) throws KapuaException { query.setScopeId(scopeId); query.setPredicate(query.attributePredicate(JobTargetAttributes.JOB_ID, jobId)); @@ -157,21 +172,25 @@ public CountResult count( /** * Returns the Job specified by the "jobId" path parameter. * - * @param scopeId The {@link ScopeId} of the requested {@link Job}. - * @param jobId The id of the requested Job. - * @param targetId The id of the requested JobTarget. + * @param scopeId + * The {@link ScopeId} of the requested {@link Job}. + * @param jobId + * The id of the requested Job. + * @param targetId + * The id of the requested JobTarget. * @return The requested Job object. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @GET @Path("{targetId}") - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public JobTarget find( @PathParam("scopeId") ScopeId scopeId, @PathParam("jobId") EntityId jobId, @PathParam("targetId") EntityId targetId) throws KapuaException { - JobTargetQuery jobTargetQuery = jobTargetFactory.newQuery(scopeId); + KapuaQuery jobTargetQuery = new KapuaQuery(scopeId); jobTargetQuery.setPredicate(jobTargetQuery.andPredicate( jobTargetQuery.attributePredicate(JobTargetAttributes.JOB_ID, jobId), jobTargetQuery.attributePredicate(KapuaEntityAttributes.ENTITY_ID, targetId) @@ -185,15 +204,15 @@ public JobTarget find( @GET @Path("{targetId}/executions") - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public JobExecutionListResult executionsByTarget( @PathParam("scopeId") ScopeId scopeId, @PathParam("jobId") EntityId jobId, @PathParam("targetId") EntityId targetId, @QueryParam("offset") @DefaultValue("0") int offset, @QueryParam("limit") @DefaultValue("50") int limit) throws KapuaException { - JobExecutionQuery jobExecutionQuery = jobExecutionFactory.newQuery(scopeId); - jobExecutionQuery.setPredicate(jobExecutionQuery.attributePredicate(JobExecutionAttributes.TARGET_IDS, new KapuaId[]{targetId})); + JobExecutionQuery jobExecutionQuery = new JobExecutionQuery(scopeId); + jobExecutionQuery.setPredicate(jobExecutionQuery.attributePredicate(JobExecutionAttributes.TARGET_IDS, new KapuaId[] { targetId })); JobExecutionListResult jobExecutionListResult = jobExecutionService.query(jobExecutionQuery); jobExecutionQuery.setOffset(offset); @@ -203,20 +222,23 @@ public JobExecutionListResult executionsByTarget( } /** - * Creates a new {@link JobTarget} based on the information provided in {@link JobTargetCreator} - * parameter. + * Creates a new {@link JobTarget} based on the information provided in {@link JobTargetCreator} parameter. * - * @param scopeId The {@link ScopeId} in which to create the {@link JobTarget} - * @param jobId The ID of the {@link Job} to attach the {@link JobTarget} to - * @param jobTargetCreator Provides the information for the new {@link JobTarget} to be created. + * @param scopeId + * The {@link ScopeId} in which to create the {@link JobTarget} + * @param jobId + * The ID of the {@link Job} to attach the {@link JobTarget} to + * @param jobTargetCreator + * Provides the information for the new {@link JobTarget} to be created. * @return The newly created {@link JobTarget} object. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.5.0 */ @POST - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public Response create( @PathParam("scopeId") ScopeId scopeId, @PathParam("jobId") EntityId jobId, @@ -230,10 +252,13 @@ public Response create( /** * Deletes the JobTarget specified by the "targetId" path parameter. * - * @param scopeId The ScopeId of the requested {@link JobTarget}. - * @param targetId The id of the JobTarget to be deleted. + * @param scopeId + * The ScopeId of the requested {@link JobTarget}. + * @param targetId + * The id of the JobTarget to be deleted. * @return HTTP 201 if operation has completed successfully. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.5.0 */ diff --git a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/JobTriggerDefinitions.java b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/JobTriggerDefinitions.java index c6c2bb867b2..ac33e964370 100644 --- a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/JobTriggerDefinitions.java +++ b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/JobTriggerDefinitions.java @@ -12,7 +12,17 @@ *******************************************************************************/ package org.eclipse.kapua.app.api.resources.v1.resources; -import com.google.common.base.Strings; +import javax.inject.Inject; +import javax.ws.rs.Consumes; +import javax.ws.rs.DefaultValue; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; + import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.app.api.core.model.CountResult; import org.eclipse.kapua.app.api.core.model.EntityId; @@ -27,16 +37,7 @@ import org.eclipse.kapua.service.scheduler.trigger.definition.TriggerDefinitionQuery; import org.eclipse.kapua.service.scheduler.trigger.definition.TriggerDefinitionService; -import javax.inject.Inject; -import javax.ws.rs.Consumes; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; +import com.google.common.base.Strings; @Path("{scopeId}/triggerDefinitions") public class JobTriggerDefinitions extends AbstractKapuaResource { @@ -49,17 +50,23 @@ public class JobTriggerDefinitions extends AbstractKapuaResource { /** * Gets the {@link TriggerDefinition} list for a given {@link Job}. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param sortParam The name of the parameter that will be used as a sorting key - * @param sortDir The sort direction. Can be ASCENDING (default), DESCENDING. Case-insensitive. - * @param offset The result set offset. - * @param limit The result set limit. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param sortParam + * The name of the parameter that will be used as a sorting key + * @param sortDir + * The sort direction. Can be ASCENDING (default), DESCENDING. Case-insensitive. + * @param offset + * The result set offset. + * @param limit + * The result set limit. * @return The {@link TriggerDefinitionListResult} of all the jobs triggers associated to the current selected job. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.5.0 */ @GET - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public TriggerDefinitionListResult simpleQuery( @PathParam("scopeId") ScopeId scopeId, @QueryParam("sortParam") String sortParam, @@ -67,7 +74,7 @@ public TriggerDefinitionListResult simpleQuery( @QueryParam("offset") @DefaultValue("0") int offset, @QueryParam("limit") @DefaultValue("50") int limit) throws KapuaException { - TriggerDefinitionQuery query = triggerDefinitionFactory.newQuery(null); + TriggerDefinitionQuery query = new TriggerDefinitionQuery(); if (!Strings.isNullOrEmpty(sortParam)) { query.setSortCriteria(query.fieldSortCriteria(sortParam, sortDir)); @@ -82,16 +89,19 @@ public TriggerDefinitionListResult simpleQuery( /** * Queries the results with the given {@link TriggerDefinitionQuery} parameter. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param query The {@link TriggerDefinitionQuery} to use to filter results. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param query + * The {@link TriggerDefinitionQuery} to use to filter results. * @return The {@link TriggerDefinitionListResult} of all the result matching the given {@link TriggerDefinitionQuery} parameter. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.5.0 */ @POST @Path("_query") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public TriggerDefinitionListResult query( @PathParam("scopeId") ScopeId scopeId, TriggerDefinitionQuery query) throws KapuaException { @@ -102,16 +112,19 @@ public TriggerDefinitionListResult query( /** * Counts the results with the given {@link TriggerDefinitionQuery} parameter. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param query The {@link TriggerDefinitionQuery} to use to filter results. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param query + * The {@link TriggerDefinitionQuery} to use to filter results. * @return The count of all the result matching the given {@link TriggerDefinitionQuery} parameter. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.5.0 */ @POST @Path("_count") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public CountResult count( @PathParam("scopeId") ScopeId scopeId, TriggerDefinitionQuery query) throws KapuaException { @@ -123,15 +136,18 @@ public CountResult count( /** * Returns the Job specified by the "jobId" path parameter. * - * @param scopeId The {@link ScopeId} of the requested {@link Job}. - * @param triggerDefinitionId The id of the requested Trigger Definition. + * @param scopeId + * The {@link ScopeId} of the requested {@link Job}. + * @param triggerDefinitionId + * The id of the requested Trigger Definition. * @return The requested Job object. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.5.0 */ @GET @Path("{triggerDefinitionId}") - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public TriggerDefinition find( @PathParam("scopeId") ScopeId scopeId, @PathParam("triggerDefinitionId") EntityId triggerDefinitionId) throws KapuaException { diff --git a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/JobTriggers.java b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/JobTriggers.java index 67a87649e15..56f86874ba6 100644 --- a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/JobTriggers.java +++ b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/JobTriggers.java @@ -12,7 +12,24 @@ *******************************************************************************/ package org.eclipse.kapua.app.api.resources.v1.resources; -import com.google.common.base.Strings; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import javax.inject.Inject; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.DefaultValue; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.app.api.core.model.CountResult; import org.eclipse.kapua.app.api.core.model.EntityId; @@ -21,6 +38,7 @@ import org.eclipse.kapua.model.KapuaEntityAttributes; import org.eclipse.kapua.model.KapuaNamedEntityAttributes; import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.model.query.KapuaQuery; import org.eclipse.kapua.model.query.SortOrder; import org.eclipse.kapua.model.query.predicate.AndPredicate; import org.eclipse.kapua.model.query.predicate.AttributePredicate; @@ -32,26 +50,10 @@ import org.eclipse.kapua.service.scheduler.trigger.TriggerCreator; import org.eclipse.kapua.service.scheduler.trigger.TriggerFactory; import org.eclipse.kapua.service.scheduler.trigger.TriggerListResult; -import org.eclipse.kapua.service.scheduler.trigger.TriggerQuery; import org.eclipse.kapua.service.scheduler.trigger.TriggerService; import org.eclipse.kapua.service.scheduler.trigger.definition.TriggerProperty; -import javax.inject.Inject; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; +import com.google.common.base.Strings; @Path("{scopeId}/jobs/{jobId}/triggers") public class JobTriggers extends AbstractKapuaResource { @@ -64,20 +66,29 @@ public class JobTriggers extends AbstractKapuaResource { /** * Gets the {@link Trigger} list for a given {@link Job}. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param jobId The {@link Job} id to filter results - * @param name The name of the {@link Trigger} to filter result - * @param sortParam The name of the parameter that will be used as a sorting key - * @param sortDir The sort direction. Can be ASCENDING (default), DESCENDING. Case-insensitive. - * @param askTotalCount Ask for the total count of the matched entities in the result - * @param offset The result set offset. - * @param limit The result set limit. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param jobId + * The {@link Job} id to filter results + * @param name + * The name of the {@link Trigger} to filter result + * @param sortParam + * The name of the parameter that will be used as a sorting key + * @param sortDir + * The sort direction. Can be ASCENDING (default), DESCENDING. Case-insensitive. + * @param askTotalCount + * Ask for the total count of the matched entities in the result + * @param offset + * The result set offset. + * @param limit + * The result set limit. * @return The {@link TriggerListResult} of all the jobs triggers associated to the current selected job. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @GET - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public TriggerListResult simpleQuery( @PathParam("scopeId") ScopeId scopeId, @PathParam("jobId") EntityId jobId, @@ -88,7 +99,7 @@ public TriggerListResult simpleQuery( @QueryParam("offset") @DefaultValue("0") int offset, @QueryParam("limit") @DefaultValue("50") int limit) throws KapuaException { - TriggerQuery query = triggerFactory.newQuery(scopeId); + KapuaQuery query = new KapuaQuery(scopeId); AndPredicate andPredicate = query.andPredicate(returnJobIdPredicate(jobId, query)); @@ -109,22 +120,25 @@ public TriggerListResult simpleQuery( } /** - * Queries the results with the given {@link TriggerQuery} parameter. + * Queries the results with the given {@link KapuaQuery} parameter. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param query The {@link TriggerQuery} to use to filter results. - * @return The {@link TriggerListResult} of all the result matching the given {@link TriggerQuery} parameter. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param query + * The {@link KapuaQuery} to use to filter results. + * @return The {@link TriggerListResult} of all the result matching the given {@link KapuaQuery} parameter. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @POST @Path("_query") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public TriggerListResult query( @PathParam("scopeId") ScopeId scopeId, @PathParam("jobId") EntityId jobId, - TriggerQuery query) throws KapuaException { + KapuaQuery query) throws KapuaException { query.setScopeId(scopeId); QueryPredicate predicate; if (query.getPredicate() != null) { @@ -137,22 +151,25 @@ public TriggerListResult query( } /** - * Counts the results with the given {@link TriggerQuery} parameter. + * Counts the results with the given {@link KapuaQuery} parameter. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param query The {@link TriggerQuery} to use to filter results. - * @return The count of all the result matching the given {@link TriggerQuery} parameter. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param query + * The {@link KapuaQuery} to use to filter results. + * @return The count of all the result matching the given {@link KapuaQuery} parameter. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @POST @Path("_count") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public CountResult count( @PathParam("scopeId") ScopeId scopeId, @PathParam("jobId") EntityId jobId, - TriggerQuery query) throws KapuaException { + KapuaQuery query) throws KapuaException { query.setScopeId(scopeId); query.setPredicate(returnJobIdPredicate(jobId, query)); @@ -162,21 +179,25 @@ public CountResult count( /** * Returns the Job specified by the "jobId" path parameter. * - * @param scopeId The {@link ScopeId} of the requested {@link Job}. - * @param jobId The id of the requested Job. - * @param triggerId The id of the requested Trigger. + * @param scopeId + * The {@link ScopeId} of the requested {@link Job}. + * @param jobId + * The id of the requested Job. + * @param triggerId + * The id of the requested Trigger. * @return The requested Job object. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @GET @Path("{triggerId}") - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public Trigger find( @PathParam("scopeId") ScopeId scopeId, @PathParam("jobId") EntityId jobId, @PathParam("triggerId") EntityId triggerId) throws KapuaException { - TriggerQuery triggerQuery = triggerFactory.newQuery(scopeId); + KapuaQuery triggerQuery = new KapuaQuery(scopeId); triggerQuery.setPredicate(triggerQuery.andPredicate( returnJobIdPredicate(jobId, triggerQuery), triggerQuery.attributePredicate(KapuaEntityAttributes.ENTITY_ID, triggerId) @@ -188,7 +209,7 @@ public Trigger find( return returnNotNullEntity(triggerListResult.getFirstItem(), Trigger.TYPE, triggerId); } - private AndPredicate returnJobIdPredicate(KapuaId jobId, TriggerQuery query) { + private AndPredicate returnJobIdPredicate(KapuaId jobId, KapuaQuery query) { AttributePredicate kapuaPropertyNameAttributePredicate = query.attributePredicate(TriggerAttributes.TRIGGER_PROPERTIES_NAME, "jobId"); AttributePredicate kapuaPropertyValueAttributePredicate = query.attributePredicate(TriggerAttributes.TRIGGER_PROPERTIES_VALUE, jobId.toCompactId()); AttributePredicate kapuaPropertyTypeAttributePredicate = query.attributePredicate(TriggerAttributes.TRIGGER_PROPERTIES_TYPE, KapuaId.class.getName()); @@ -201,20 +222,23 @@ private AndPredicate returnJobIdPredicate(KapuaId jobId, TriggerQuery query) { } /** - * Creates a new {@link Trigger} based on the information provided in {@link TriggerCreator} - * parameter. + * Creates a new {@link Trigger} based on the information provided in {@link TriggerCreator} parameter. * - * @param scopeId The {@link ScopeId} in which to create the {@link Trigger} - * @param triggerCreator Provides the information for the new {@link Trigger} to be created. - * @param jobId The ID of the {@link Job} to attach the {@link Trigger} to + * @param scopeId + * The {@link ScopeId} in which to create the {@link Trigger} + * @param triggerCreator + * Provides the information for the new {@link Trigger} to be created. + * @param jobId + * The ID of the {@link Job} to attach the {@link Trigger} to * @return The newly created {@link Trigger} object. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.5.0 */ @POST - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public Response create( @PathParam("scopeId") ScopeId scopeId, @PathParam("jobId") EntityId jobId, @@ -225,29 +249,33 @@ public Response create( triggerProperties = new ArrayList<>(); triggerCreator.setTriggerProperties(triggerProperties); } - triggerProperties.removeIf(triggerProperty -> Arrays.stream(new String[]{"scopeId", "jobId"}).anyMatch(propertyToRemove -> propertyToRemove.equals(triggerProperty.getName()))); + triggerProperties.removeIf(triggerProperty -> Arrays.stream(new String[] { "scopeId", "jobId" }).anyMatch(propertyToRemove -> propertyToRemove.equals(triggerProperty.getName()))); triggerProperties.add(triggerFactory.newTriggerProperty("scopeId", KapuaId.class.getCanonicalName(), scopeId.toCompactId())); triggerProperties.add(triggerFactory.newTriggerProperty("jobId", KapuaId.class.getCanonicalName(), jobId.toCompactId())); return returnCreated(triggerService.create(triggerCreator)); } /** - * Updates a {@link Trigger} based on the information provided in the provided {@link Trigger} - * parameter. + * Updates a {@link Trigger} based on the information provided in the provided {@link Trigger} parameter. * - * @param scopeId The {@link ScopeId} in which to create the {@link Trigger} - * @param triggerId The ID of the {@link Trigger} to update - * @param trigger Provides the information for the new {@link Trigger} to be updated. - * @param jobId The ID of the {@link Job} to attach the {@link Trigger} to + * @param scopeId + * The {@link ScopeId} in which to create the {@link Trigger} + * @param triggerId + * The ID of the {@link Trigger} to update + * @param trigger + * Provides the information for the new {@link Trigger} to be updated. + * @param jobId + * The ID of the {@link Job} to attach the {@link Trigger} to * @return The updated {@link Trigger} object. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.5.0 */ @PUT @Path("{triggerId}") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public Trigger update( @PathParam("scopeId") ScopeId scopeId, @PathParam("jobId") EntityId jobId, @@ -258,7 +286,7 @@ public Trigger update( triggerProperties = new ArrayList<>(); trigger.setTriggerProperties(triggerProperties); } - triggerProperties.removeIf(triggerProperty -> Arrays.stream(new String[]{"scopeId", "jobId"}).anyMatch(propertyToRemove -> propertyToRemove.equals(triggerProperty.getName()))); + triggerProperties.removeIf(triggerProperty -> Arrays.stream(new String[] { "scopeId", "jobId" }).anyMatch(propertyToRemove -> propertyToRemove.equals(triggerProperty.getName()))); triggerProperties.add(triggerFactory.newTriggerProperty("scopeId", KapuaId.class.getCanonicalName(), scopeId.toCompactId())); triggerProperties.add(triggerFactory.newTriggerProperty("jobId", KapuaId.class.getCanonicalName(), jobId.toCompactId())); trigger.setScopeId(scopeId); @@ -269,10 +297,13 @@ public Trigger update( /** * Deletes the Trigger specified by the "triggerId" path parameter. * - * @param scopeId The ScopeId of the requested {@link Trigger}. - * @param triggerId The id of the Trigger to be deleted. + * @param scopeId + * The ScopeId of the requested {@link Trigger}. + * @param triggerId + * The id of the Trigger to be deleted. * @return HTTP 201 if operation has completed successfully. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.5.0 */ diff --git a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/JobTriggersFired.java b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/JobTriggersFired.java index 120501db918..45107a0d5c8 100644 --- a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/JobTriggersFired.java +++ b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/JobTriggersFired.java @@ -12,11 +12,23 @@ *******************************************************************************/ package org.eclipse.kapua.app.api.resources.v1.resources; +import javax.inject.Inject; +import javax.ws.rs.Consumes; +import javax.ws.rs.DefaultValue; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; + import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.app.api.core.model.CountResult; import org.eclipse.kapua.app.api.core.model.EntityId; import org.eclipse.kapua.app.api.core.model.ScopeId; import org.eclipse.kapua.app.api.core.resources.AbstractKapuaResource; +import org.eclipse.kapua.model.query.KapuaQuery; import org.eclipse.kapua.model.query.SortOrder; import org.eclipse.kapua.model.query.predicate.AndPredicate; import org.eclipse.kapua.service.KapuaService; @@ -25,21 +37,9 @@ import org.eclipse.kapua.service.scheduler.trigger.fired.FiredTriggerAttributes; import org.eclipse.kapua.service.scheduler.trigger.fired.FiredTriggerFactory; import org.eclipse.kapua.service.scheduler.trigger.fired.FiredTriggerListResult; -import org.eclipse.kapua.service.scheduler.trigger.fired.FiredTriggerQuery; import org.eclipse.kapua.service.scheduler.trigger.fired.FiredTriggerService; import org.eclipse.kapua.service.scheduler.trigger.fired.FiredTriggerStatus; -import javax.inject.Inject; -import javax.ws.rs.Consumes; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; - @Path("{scopeId}/jobs/{jobId}/triggers/{triggerId}/fired") public class JobTriggersFired extends AbstractKapuaResource { @@ -51,17 +51,23 @@ public class JobTriggersFired extends AbstractKapuaResource { /** * Gets the {@link Trigger} list for a given {@link Job}. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param jobId The {@link Job} id to filter results. - * @param offset The result set offset. - * @param limit The result set limit. - * @param askTotalCount Whether or not to fetch the total count of elements. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param jobId + * The {@link Job} id to filter results. + * @param offset + * The result set offset. + * @param limit + * The result set limit. + * @param askTotalCount + * Whether or not to fetch the total count of elements. * @return The {@link FiredTriggerListResult} of all the jobs triggers associated to the current selected job. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.5.0 */ @GET - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public FiredTriggerListResult simpleQuery( @PathParam("scopeId") ScopeId scopeId, @PathParam("jobId") EntityId jobId, @@ -71,7 +77,7 @@ public FiredTriggerListResult simpleQuery( @QueryParam("offset") @DefaultValue("0") int offset, @QueryParam("limit") @DefaultValue("50") int limit) throws KapuaException { - FiredTriggerQuery query = firedTriggerFactory.newQuery(scopeId); + KapuaQuery query = new KapuaQuery(scopeId); AndPredicate andPredicate = query.andPredicate( query.attributePredicate(FiredTriggerAttributes.TRIGGER_ID, triggerId) @@ -92,23 +98,26 @@ public FiredTriggerListResult simpleQuery( } /** - * Queries the results with the given {@link FiredTriggerQuery} parameter. + * Queries the results with the given {@link KapuaQuery} parameter. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param query The {@link FiredTriggerQuery} to use to filter results. - * @return The {@link FiredTriggerListResult} of all the result matching the given {@link FiredTriggerQuery} parameter. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param query + * The {@link KapuaQuery} to use to filter results. + * @return The {@link FiredTriggerListResult} of all the result matching the given {@link KapuaQuery} parameter. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.5.0 */ @POST @Path("_query") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public FiredTriggerListResult query( @PathParam("scopeId") ScopeId scopeId, @PathParam("jobId") EntityId jobId, @PathParam("triggerId") EntityId triggerId, - FiredTriggerQuery query) throws KapuaException { + KapuaQuery query) throws KapuaException { query.setScopeId(scopeId); AndPredicate andPredicate = query.andPredicate( @@ -125,23 +134,26 @@ public FiredTriggerListResult query( } /** - * Counts the results with the given {@link FiredTriggerQuery} parameter. + * Counts the results with the given {@link KapuaQuery} parameter. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param query The {@link FiredTriggerQuery} to use to filter results. - * @return The count of all the result matching the given {@link FiredTriggerQuery} parameter. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param query + * The {@link KapuaQuery} to use to filter results. + * @return The count of all the result matching the given {@link KapuaQuery} parameter. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.5.0 */ @POST @Path("_count") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public CountResult count( @PathParam("scopeId") ScopeId scopeId, @PathParam("jobId") EntityId jobId, @PathParam("triggerId") EntityId triggerId, - FiredTriggerQuery query) throws KapuaException { + KapuaQuery query) throws KapuaException { query.setScopeId(scopeId); AndPredicate andPredicate = query.andPredicate( diff --git a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/Jobs.java b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/Jobs.java index 093e92a473e..59d626b7cb1 100644 --- a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/Jobs.java +++ b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/Jobs.java @@ -12,7 +12,20 @@ *******************************************************************************/ package org.eclipse.kapua.app.api.resources.v1.resources; -import com.google.common.base.Strings; +import javax.inject.Inject; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.DefaultValue; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.app.api.core.model.CountResult; import org.eclipse.kapua.app.api.core.model.EntityId; @@ -29,19 +42,7 @@ import org.eclipse.kapua.service.job.JobQuery; import org.eclipse.kapua.service.job.JobService; -import javax.inject.Inject; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; +import com.google.common.base.Strings; @Path("{scopeId}/jobs") public class Jobs extends AbstractKapuaResource { @@ -54,19 +55,27 @@ public class Jobs extends AbstractKapuaResource { /** * Gets the {@link Job} list in the scope. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param name The {@link Job} name to filter results - * @param sortParam The name of the parameter that will be used as a sorting key - * @param sortDir The sort direction. Can be ASCENDING (default), DESCENDING. Case-insensitive. - * @param askTotalCount Ask for the total count of the matched entities in the result - * @param offset The result set offset. - * @param limit The result set limit. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param name + * The {@link Job} name to filter results + * @param sortParam + * The name of the parameter that will be used as a sorting key + * @param sortDir + * The sort direction. Can be ASCENDING (default), DESCENDING. Case-insensitive. + * @param askTotalCount + * Ask for the total count of the matched entities in the result + * @param offset + * The result set offset. + * @param limit + * The result set limit. * @return The {@link JobListResult} of all the jobs associated to the current selected scope. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @GET - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public JobListResult simpleQuery( @PathParam("scopeId") ScopeId scopeId, @QueryParam("name") String name, @@ -76,7 +85,7 @@ public JobListResult simpleQuery( @QueryParam("askTotalCount") boolean askTotalCount, @QueryParam("offset") @DefaultValue("0") int offset, @QueryParam("limit") @DefaultValue("50") int limit) throws KapuaException { - JobQuery query = jobFactory.newQuery(scopeId); + JobQuery query = new JobQuery(scopeId); AndPredicate andPredicate = query.andPredicate(); if (!Strings.isNullOrEmpty(name)) { @@ -101,16 +110,19 @@ public JobListResult simpleQuery( /** * Queries the results with the given {@link JobQuery} parameter. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param query The {@link JobQuery} to use to filter results. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param query + * The {@link JobQuery} to use to filter results. * @return The {@link JobListResult} of all the result matching the given {@link JobQuery} parameter. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @POST @Path("_query") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public JobListResult query( @PathParam("scopeId") ScopeId scopeId, JobQuery query) throws KapuaException { @@ -122,16 +134,19 @@ public JobListResult query( /** * Counts the results with the given {@link JobQuery} parameter. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param query The {@link JobQuery} to use to filter results. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param query + * The {@link JobQuery} to use to filter results. * @return The count of all the result matching the given {@link JobQuery} parameter. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @POST @Path("_count") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public CountResult count( @PathParam("scopeId") ScopeId scopeId, JobQuery query) throws KapuaException { @@ -143,15 +158,18 @@ public CountResult count( /** * Returns the Job specified by the "jobId" path parameter. * - * @param scopeId The {@link ScopeId} of the requested {@link Job}. - * @param jobId The id of the requested Job. + * @param scopeId + * The {@link ScopeId} of the requested {@link Job}. + * @param jobId + * The id of the requested Job. * @return The requested Job object. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @GET @Path("{jobId}") - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public Job find( @PathParam("scopeId") ScopeId scopeId, @PathParam("jobId") EntityId jobId) throws KapuaException { @@ -161,18 +179,20 @@ public Job find( } /** - * Creates a new {@link Job} based on the information provided in {@link JobCreator} - * parameter. + * Creates a new {@link Job} based on the information provided in {@link JobCreator} parameter. * - * @param scopeId The {@link ScopeId} in which to create the {@link Job} - * @param jobCreator Provides the information for the new {@link Job} to be created. + * @param scopeId + * The {@link ScopeId} in which to create the {@link Job} + * @param jobCreator + * Provides the information for the new {@link Job} to be created. * @return The newly created {@link Job} object. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.5.0 */ @POST - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public Response create( @PathParam("scopeId") ScopeId scopeId, JobCreator jobCreator) throws KapuaException { @@ -184,17 +204,21 @@ public Response create( /** * Updates the Job based on the information provided in the Job parameter. * - * @param scopeId The ScopeId of the requested {@link Job}. - * @param jobId The id of the requested {@link Job} - * @param job The modified Job whose attributed need to be updated. + * @param scopeId + * The ScopeId of the requested {@link Job}. + * @param jobId + * The id of the requested {@link Job} + * @param job + * The modified Job whose attributed need to be updated. * @return The updated job. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.5.0 */ @PUT @Path("{jobId}") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public Job update( @PathParam("scopeId") ScopeId scopeId, @PathParam("jobId") EntityId jobId, @@ -208,10 +232,13 @@ public Job update( /** * Deletes the Job specified by the "jobId" path parameter. * - * @param scopeId The ScopeId of the requested {@link Job}. - * @param jobId The id of the Job to be deleted. + * @param scopeId + * The ScopeId of the requested {@link Job}. + * @param jobId + * The id of the Job to be deleted. * @return HTTP 201 if operation has completed successfully. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.5.0 */ @DELETE diff --git a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/Roles.java b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/Roles.java index a1e453f87ad..aa5f47a175a 100644 --- a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/Roles.java +++ b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/Roles.java @@ -13,6 +13,7 @@ package org.eclipse.kapua.app.api.resources.v1.resources; import java.util.List; + import javax.inject.Inject; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; @@ -27,7 +28,6 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import com.google.common.base.Strings; import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.app.api.core.model.CountResult; import org.eclipse.kapua.app.api.core.model.EntityId; @@ -51,6 +51,8 @@ import org.eclipse.kapua.service.user.UserQuery; import org.eclipse.kapua.service.user.UserService; +import com.google.common.base.Strings; + @Path("{scopeId}/roles") public class Roles extends AbstractKapuaResource { @@ -66,16 +68,21 @@ public class Roles extends AbstractKapuaResource { /** * Gets the {@link Role} list in the scope. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param name The {@link Role} name in which to search results. - * @param offset The result set offset. - * @param limit The result set limit. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param name + * The {@link Role} name in which to search results. + * @param offset + * The result set offset. + * @param limit + * The result set limit. * @return The {@link RoleListResult} of all the roles associated to the current selected scope. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @GET - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public RoleListResult simpleQuery( @PathParam("scopeId") ScopeId scopeId, @QueryParam("name") String name, @@ -85,7 +92,7 @@ public RoleListResult simpleQuery( @QueryParam("sortDir") @DefaultValue("ASCENDING") SortOrder sortDir, @QueryParam("offset") @DefaultValue("0") int offset, @QueryParam("limit") @DefaultValue("50") int limit) throws KapuaException { - RoleQuery query = roleFactory.newQuery(scopeId); + RoleQuery query = new RoleQuery(scopeId); AndPredicate andPredicate = query.andPredicate(); if (!Strings.isNullOrEmpty(name)) { @@ -109,16 +116,19 @@ public RoleListResult simpleQuery( /** * Queries the results with the given {@link RoleQuery} parameter. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param query The {@link RoleQuery} to use to filter results. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param query + * The {@link RoleQuery} to use to filter results. * @return The {@link RoleListResult} of all the result matching the given {@link RoleQuery} parameter. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @POST @Path("_query") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public RoleListResult query( @PathParam("scopeId") ScopeId scopeId, RoleQuery query) throws KapuaException { @@ -130,16 +140,19 @@ public RoleListResult query( /** * Counts the results with the given {@link RoleQuery} parameter. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param query The {@link RoleQuery} to use to filter results. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param query + * The {@link RoleQuery} to use to filter results. * @return The count of all the result matching the given {@link RoleQuery} parameter. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @POST @Path("_count") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public CountResult count( @PathParam("scopeId") ScopeId scopeId, RoleQuery query) throws KapuaException { @@ -149,18 +162,20 @@ public CountResult count( } /** - * Creates a new Role based on the information provided in RoleCreator - * parameter. + * Creates a new Role based on the information provided in RoleCreator parameter. * - * @param scopeId The {@link ScopeId} in which to create the {@link Role} - * @param roleCreator Provides the information for the new {@link Role} to be created. + * @param scopeId + * The {@link ScopeId} in which to create the {@link Role} + * @param roleCreator + * Provides the information for the new {@link Role} to be created. * @return The newly created {@link Role} object. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @POST - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public Response create( @PathParam("scopeId") ScopeId scopeId, RoleCreator roleCreator) throws KapuaException { @@ -172,15 +187,18 @@ public Response create( /** * Returns the Role specified by the "roleId" path parameter. * - * @param scopeId The {@link ScopeId} of the requested {@link Role}. - * @param roleId The id of the requested {@link Role}. + * @param scopeId + * The {@link ScopeId} of the requested {@link Role}. + * @param roleId + * The id of the requested {@link Role}. * @return The requested {@link Role} object. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @GET @Path("{roleId}") - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public Role find( @PathParam("scopeId") ScopeId scopeId, @PathParam("roleId") EntityId roleId) throws KapuaException { @@ -192,17 +210,21 @@ public Role find( /** * Updates the Role based on the information provided in the Role parameter. * - * @param scopeId The ScopeId of the requested {@link Role}. - * @param roleId The id of the requested {@link Role} - * @param role The modified Role whose attributed need to be updated. + * @param scopeId + * The ScopeId of the requested {@link Role}. + * @param roleId + * The id of the requested {@link Role} + * @param role + * The modified Role whose attributed need to be updated. * @return The updated {@link Role}. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @PUT @Path("{roleId}") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public Role update( @PathParam("scopeId") ScopeId scopeId, @PathParam("roleId") EntityId roleId, @@ -216,10 +238,13 @@ public Role update( /** * Deletes the Role specified by the "roleId" path parameter. * - * @param scopeId The ScopeId of the requested {@link Role}. - * @param roleId The id of the Role to be deleted. + * @param scopeId + * The ScopeId of the requested {@link Role}. + * @param roleId + * The id of the Role to be deleted. * @return HTTP 200 if operation has completed successfully. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @DELETE @@ -235,14 +260,21 @@ public Response deleteRole( /** * Gets all the {@link User}s for a given {@link Role} * - * @param scopeId The ScopeId of the requested {@link Role}. - * @param roleId The id of the Role to be deleted. - * @param offset The result set offset. - * @param limit The result set limit. - * @param sortParam The name of the parameter that will be used as a sorting key for the users - * @param sortDir The sort direction. Can be ASCENDING (default), DESCENDING. Case-insensitive. + * @param scopeId + * The ScopeId of the requested {@link Role}. + * @param roleId + * The id of the Role to be deleted. + * @param offset + * The result set offset. + * @param limit + * The result set limit. + * @param sortParam + * The name of the parameter that will be used as a sorting key for the users + * @param sortDir + * The sort direction. Can be ASCENDING (default), DESCENDING. Case-insensitive. * @return An {@link UserListResult} containing the {@link User}s for the given {@link Role} - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.2.0 */ @GET @@ -256,7 +288,7 @@ public UserListResult usersForRole( @QueryParam("limit") @DefaultValue("50") int limit) throws KapuaException { List usersIds = roleService.userIdsByRoleId(scopeId, roleId); - UserQuery userQuery = userFactory.newQuery(scopeId); + UserQuery userQuery = new UserQuery(scopeId); userQuery.setPredicate(userQuery.attributePredicate(KapuaEntityAttributes.ENTITY_ID, usersIds)); userQuery.setLimit(limit); userQuery.setOffset(offset); diff --git a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/RolesPermissions.java b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/RolesPermissions.java index 04ad770ba77..af42c32c8bb 100644 --- a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/RolesPermissions.java +++ b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/RolesPermissions.java @@ -12,7 +12,19 @@ *******************************************************************************/ package org.eclipse.kapua.app.api.resources.v1.resources; -import com.google.common.base.Strings; +import javax.inject.Inject; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.DefaultValue; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.app.api.core.model.CountResult; import org.eclipse.kapua.app.api.core.model.EntityId; @@ -20,6 +32,7 @@ import org.eclipse.kapua.app.api.core.resources.AbstractKapuaResource; import org.eclipse.kapua.model.KapuaEntityAttributes; import org.eclipse.kapua.model.domain.Actions; +import org.eclipse.kapua.model.query.KapuaQuery; import org.eclipse.kapua.model.query.SortOrder; import org.eclipse.kapua.model.query.predicate.AndPredicate; import org.eclipse.kapua.service.KapuaService; @@ -27,49 +40,43 @@ import org.eclipse.kapua.service.authorization.role.RolePermission; import org.eclipse.kapua.service.authorization.role.RolePermissionAttributes; import org.eclipse.kapua.service.authorization.role.RolePermissionCreator; -import org.eclipse.kapua.service.authorization.role.RolePermissionFactory; import org.eclipse.kapua.service.authorization.role.RolePermissionListResult; -import org.eclipse.kapua.service.authorization.role.RolePermissionQuery; import org.eclipse.kapua.service.authorization.role.RolePermissionService; -import javax.inject.Inject; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; +import com.google.common.base.Strings; @Path("{scopeId}/roles/{roleId}/permissions") public class RolesPermissions extends AbstractKapuaResource { @Inject public RolePermissionService rolePermissionService; - @Inject - public RolePermissionFactory rolePermissionFactory; /** * Gets the {@link RolePermission} list in the scope. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param roleId The id of the {@link Role} in which to search results. - * @param domain The domain name to filter results. - * @param action The action to filter results. - * @param sortParam The name of the parameter that will be used as a sorting key - * @param sortDir The sort direction. Can be ASCENDING (default), DESCENDING. Case-insensitive. - * @param offset The result set offset. - * @param limit The result set limit. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param roleId + * The id of the {@link Role} in which to search results. + * @param domain + * The domain name to filter results. + * @param action + * The action to filter results. + * @param sortParam + * The name of the parameter that will be used as a sorting key + * @param sortDir + * The sort direction. Can be ASCENDING (default), DESCENDING. Case-insensitive. + * @param offset + * The result set offset. + * @param limit + * The result set limit. * @return The {@link RolePermissionListResult} of all the rolePermissions associated to the current selected scope. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @GET - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public RolePermissionListResult simpleQuery( @PathParam("scopeId") ScopeId scopeId, @PathParam("roleId") EntityId roleId, @@ -80,7 +87,7 @@ public RolePermissionListResult simpleQuery( @QueryParam("sortDir") @DefaultValue("ASCENDING") SortOrder sortDir, @QueryParam("offset") @DefaultValue("0") int offset, @QueryParam("limit") @DefaultValue("50") int limit) throws KapuaException { - RolePermissionQuery query = rolePermissionFactory.newQuery(scopeId); + KapuaQuery query = new KapuaQuery(scopeId); AndPredicate andPredicate = query.andPredicate(); query.setPredicate(query.attributePredicate(RolePermissionAttributes.ROLE_ID, roleId)); @@ -103,23 +110,27 @@ public RolePermissionListResult simpleQuery( } /** - * Queries the results with the given {@link RolePermissionQuery} parameter. + * Queries the results with the given {@link KapuaQuery} parameter. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param roleId The {@link Role} id in which to search results. - * @param query The {@link RolePermissionQuery} to use to filter results. - * @return The {@link RolePermissionListResult} of all the result matching the given {@link RolePermissionQuery} parameter. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param roleId + * The {@link Role} id in which to search results. + * @param query + * The {@link KapuaQuery} to use to filter results. + * @return The {@link RolePermissionListResult} of all the result matching the given {@link KapuaQuery} parameter. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @POST @Path("_query") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public RolePermissionListResult query( @PathParam("scopeId") ScopeId scopeId, @PathParam("roleId") EntityId roleId, - RolePermissionQuery query) throws KapuaException { + KapuaQuery query) throws KapuaException { query.setScopeId(scopeId); AndPredicate andPredicate = query.andPredicate(); @@ -133,23 +144,27 @@ public RolePermissionListResult query( } /** - * Counts the results with the given {@link RolePermissionQuery} parameter. + * Counts the results with the given {@link KapuaQuery} parameter. * - * @param scopeId The {@link ScopeId} in which to count results. - * @param roleId The {@link Role} id in which to count results. - * @param query The {@link RolePermissionQuery} to use to filter results. - * @return The count of all the result matching the given {@link RolePermissionQuery} parameter. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @param scopeId + * The {@link ScopeId} in which to count results. + * @param roleId + * The {@link Role} id in which to count results. + * @param query + * The {@link KapuaQuery} to use to filter results. + * @return The count of all the result matching the given {@link KapuaQuery} parameter. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @POST @Path("_count") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public CountResult count( @PathParam("scopeId") ScopeId scopeId, @PathParam("roleId") EntityId roleId, - RolePermissionQuery query) throws KapuaException { + KapuaQuery query) throws KapuaException { query.setScopeId(scopeId); query.setPredicate(query.attributePredicate(RolePermissionAttributes.ROLE_ID, roleId)); @@ -157,19 +172,22 @@ public CountResult count( } /** - * Creates a new RolePermission based on the information provided in RolePermissionCreator - * parameter. + * Creates a new RolePermission based on the information provided in RolePermissionCreator parameter. * - * @param scopeId The {@link ScopeId} in which to create the {@link RolePermission} - * @param roleId The {@link Role} id in which to create the RolePermission. - * @param rolePermissionCreator Provides the information for the new RolePermission to be created. + * @param scopeId + * The {@link ScopeId} in which to create the {@link RolePermission} + * @param roleId + * The {@link Role} id in which to create the RolePermission. + * @param rolePermissionCreator + * Provides the information for the new RolePermission to be created. * @return The newly created RolePermission object. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @POST - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public Response create( @PathParam("scopeId") ScopeId scopeId, @PathParam("roleId") EntityId roleId, @@ -183,21 +201,25 @@ public Response create( /** * Returns the RolePermission specified by the "rolePermissionId" path parameter. * - * @param scopeId The {@link ScopeId} of the requested {@link RolePermission}. - * @param roleId The {@link Role} id of the requested {@link RolePermission}. - * @param rolePermissionId The id of the requested RolePermission. + * @param scopeId + * The {@link ScopeId} of the requested {@link RolePermission}. + * @param roleId + * The {@link Role} id of the requested {@link RolePermission}. + * @param rolePermissionId + * The id of the requested RolePermission. * @return The requested RolePermission object. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @GET @Path("{rolePermissionId}") - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public RolePermission find( @PathParam("scopeId") ScopeId scopeId, @PathParam("roleId") EntityId roleId, @PathParam("rolePermissionId") EntityId rolePermissionId) throws KapuaException { - RolePermissionQuery query = rolePermissionFactory.newQuery(scopeId); + KapuaQuery query = new KapuaQuery(scopeId); AndPredicate andPredicate = query.andPredicate( query.attributePredicate(RolePermissionAttributes.ROLE_ID, roleId), @@ -216,11 +238,15 @@ public RolePermission find( /** * Deletes the RolePermission specified by the "rolePermissionId" path parameter. * - * @param scopeId The {@link ScopeId} of the {@link RolePermission} to delete. - * @param roleId The {@link Role} id of the {@link RolePermission} to delete. - * @param rolePermissionId The id of the RolePermission to be deleted. + * @param scopeId + * The {@link ScopeId} of the {@link RolePermission} to delete. + * @param roleId + * The {@link Role} id of the {@link RolePermission} to delete. + * @param rolePermissionId + * The id of the RolePermission to be deleted. * @return HTTP 200 if operation has completed successfully. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @DELETE diff --git a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/Tags.java b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/Tags.java index c09e9c34a17..2e288e42b01 100644 --- a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/Tags.java +++ b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/Tags.java @@ -26,7 +26,6 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import com.google.common.base.Strings; import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.app.api.core.model.CountResult; import org.eclipse.kapua.app.api.core.model.EntityId; @@ -43,6 +42,8 @@ import org.eclipse.kapua.service.tag.TagQuery; import org.eclipse.kapua.service.tag.TagService; +import com.google.common.base.Strings; + @Path("{scopeId}/tags") public class Tags extends AbstractKapuaResource { @@ -54,17 +55,22 @@ public class Tags extends AbstractKapuaResource { /** * Gets the {@link Tag} list in the scope. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param name The {@link Tag} name to filter results - * @param offset The result set offset. - * @param limit The result set limit. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param name + * The {@link Tag} name to filter results + * @param offset + * The result set offset. + * @param limit + * The result set limit. * @return The {@link TagListResult} of all the tags associated to the current selected scope. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @GET - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public TagListResult simpleQuery( @PathParam("scopeId") ScopeId scopeId, @QueryParam("name") String name, @@ -74,7 +80,7 @@ public TagListResult simpleQuery( @QueryParam("sortDir") @DefaultValue("ASCENDING") SortOrder sortDir, @QueryParam("offset") @DefaultValue("0") int offset, @QueryParam("limit") @DefaultValue("50") int limit) throws KapuaException { - TagQuery query = tagFactory.newQuery(scopeId); + TagQuery query = new TagQuery(scopeId); AndPredicate andPredicate = query.andPredicate(); if (!Strings.isNullOrEmpty(name)) { @@ -98,17 +104,20 @@ public TagListResult simpleQuery( /** * Queries the results with the given {@link TagQuery} parameter. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param query The {@link TagQuery} to use to filter results. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param query + * The {@link TagQuery} to use to filter results. * @return The {@link TagListResult} of all the result matching the given {@link TagQuery} parameter. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @POST @Path("_query") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public TagListResult query( @PathParam("scopeId") ScopeId scopeId, TagQuery query) throws KapuaException { @@ -120,17 +129,20 @@ public TagListResult query( /** * Counts the results with the given {@link TagQuery} parameter. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param query The {@link TagQuery} to use to filter results. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param query + * The {@link TagQuery} to use to filter results. * @return The count of all the result matching the given {@link TagQuery} parameter. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @POST @Path("_count") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public CountResult count( @PathParam("scopeId") ScopeId scopeId, TagQuery query) throws KapuaException { @@ -140,19 +152,21 @@ public CountResult count( } /** - * Creates a new Tag based on the information provided in TagCreator - * parameter. + * Creates a new Tag based on the information provided in TagCreator parameter. * - * @param scopeId The {@link ScopeId} in which to create the {@link Tag} - * @param tagCreator Provides the information for the new {@link Tag} to be created. + * @param scopeId + * The {@link ScopeId} in which to create the {@link Tag} + * @param tagCreator + * Provides the information for the new {@link Tag} to be created. * @return The newly created {@link Tag} object. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @POST - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public Response create( @PathParam("scopeId") ScopeId scopeId, TagCreator tagCreator) throws KapuaException { @@ -164,16 +178,19 @@ public Response create( /** * Returns the Tag specified by the "tagId" path parameter. * - * @param scopeId The {@link ScopeId} of the requested {@link Tag}. - * @param tagId The id of the requested Tag. + * @param scopeId + * The {@link ScopeId} of the requested {@link Tag}. + * @param tagId + * The id of the requested Tag. * @return The requested Tag object. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @GET @Path("{tagId}") - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public Tag find( @PathParam("scopeId") ScopeId scopeId, @PathParam("tagId") EntityId tagId) throws KapuaException { @@ -185,18 +202,22 @@ public Tag find( /** * Updates the Tag based on the information provided in the Tag parameter. * - * @param scopeId The ScopeId of the requested {@link Tag}. - * @param tagId The id of the requested {@link Tag} - * @param tag The modified Tag whose attributed need to be updated. + * @param scopeId + * The ScopeId of the requested {@link Tag}. + * @param tagId + * The id of the requested {@link Tag} + * @param tag + * The modified Tag whose attributed need to be updated. * @return The updated tag. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @PUT @Path("{tagId}") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public Tag update( @PathParam("scopeId") ScopeId scopeId, @PathParam("tagId") EntityId tagId, @@ -210,10 +231,13 @@ public Tag update( /** * Deletes the Tag specified by the "tagId" path parameter. * - * @param scopeId The ScopeId of the requested {@link Tag}. - * @param tagId The id of the Tag to be deleted. + * @param scopeId + * The ScopeId of the requested {@link Tag}. + * @param tagId + * The id of the Tag to be deleted. * @return HTTP 200 if operation has completed successfully. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ diff --git a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/Users.java b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/Users.java index 0da1215e9ce..597b6a0cdcd 100644 --- a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/Users.java +++ b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/Users.java @@ -12,7 +12,20 @@ *******************************************************************************/ package org.eclipse.kapua.app.api.resources.v1.resources; -import com.google.common.base.Strings; +import javax.inject.Inject; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.DefaultValue; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.app.api.core.model.CountResult; import org.eclipse.kapua.app.api.core.model.EntityId; @@ -29,19 +42,7 @@ import org.eclipse.kapua.service.user.UserQuery; import org.eclipse.kapua.service.user.UserService; -import javax.inject.Inject; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; +import com.google.common.base.Strings; @Path("{scopeId}/users") public class Users extends AbstractKapuaResource { @@ -54,20 +55,29 @@ public class Users extends AbstractKapuaResource { /** * Gets the {@link User} list in the scope. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param name The {@link User} name in which to search results. - * @param sortParam The name of the parameter that will be used as a sorting key - * @param sortDir The sort direction. Can be ASCENDING (default), DESCENDING. Case-insensitive. - * @param matchTerm A term to be matched in at least one of the configured fields of this entity - * @param askTotalCount Ask for the total count of the matched entities in the result - * @param offset The result set offset. - * @param limit The result set limit. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param name + * The {@link User} name in which to search results. + * @param sortParam + * The name of the parameter that will be used as a sorting key + * @param sortDir + * The sort direction. Can be ASCENDING (default), DESCENDING. Case-insensitive. + * @param matchTerm + * A term to be matched in at least one of the configured fields of this entity + * @param askTotalCount + * Ask for the total count of the matched entities in the result + * @param offset + * The result set offset. + * @param limit + * The result set limit. * @return The {@link UserListResult} of all the users associated to the current selected scope. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @GET - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public UserListResult simpleQuery( @PathParam("scopeId") ScopeId scopeId, @QueryParam("name") String name, @@ -77,7 +87,7 @@ public UserListResult simpleQuery( @QueryParam("askTotalCount") boolean askTotalCount, @QueryParam("offset") @DefaultValue("0") int offset, @QueryParam("limit") @DefaultValue("50") int limit) throws KapuaException { - UserQuery query = userFactory.newQuery(scopeId); + UserQuery query = new UserQuery(scopeId); AndPredicate andPredicate = query.andPredicate(); if (!Strings.isNullOrEmpty(name)) { @@ -102,16 +112,19 @@ public UserListResult simpleQuery( /** * Queries the results with the given {@link UserQuery} parameter. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param query The {@link UserQuery} to use to filter results. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param query + * The {@link UserQuery} to use to filter results. * @return The {@link UserListResult} of all the result matching the given {@link UserQuery} parameter. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @POST @Path("_query") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public UserListResult query( @PathParam("scopeId") ScopeId scopeId, UserQuery query) throws KapuaException { @@ -123,16 +136,19 @@ public UserListResult query( /** * Counts the results with the given {@link UserQuery} parameter. * - * @param scopeId The {@link ScopeId} in which to count results. - * @param query The {@link UserQuery} to use to filter results. + * @param scopeId + * The {@link ScopeId} in which to count results. + * @param query + * The {@link UserQuery} to use to filter results. * @return The count of all the result matching the given {@link UserQuery} parameter. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @POST @Path("_count") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public CountResult count( @PathParam("scopeId") ScopeId scopeId, UserQuery query) throws KapuaException { @@ -142,18 +158,20 @@ public CountResult count( } /** - * Creates a new User based on the information provided in UserCreator - * parameter. + * Creates a new User based on the information provided in UserCreator parameter. * - * @param scopeId The {@link ScopeId} in which to create the {@link User} - * @param userCreator Provides the information for the new User to be created. + * @param scopeId + * The {@link ScopeId} in which to create the {@link User} + * @param userCreator + * Provides the information for the new User to be created. * @return The newly created User object. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @POST - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public Response create( @PathParam("scopeId") ScopeId scopeId, UserCreator userCreator) throws KapuaException { @@ -165,15 +183,18 @@ public Response create( /** * Returns the User specified by the "userId" path parameter. * - * @param scopeId The {@link ScopeId} of the requested {@link User}. - * @param userId The id of the requested User. + * @param scopeId + * The {@link ScopeId} of the requested {@link User}. + * @param userId + * The id of the requested User. * @return The requested User object. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @GET @Path("{userId}") - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public User find( @PathParam("scopeId") ScopeId scopeId, @PathParam("userId") EntityId userId) throws KapuaException { @@ -185,17 +206,21 @@ public User find( /** * Updates the User based on the information provided in the User parameter. * - * @param scopeId The ScopeId of the requested {@link User}. - * @param userId The id of the requested {@link User} - * @param user The modified User whose attributed need to be updated. + * @param scopeId + * The ScopeId of the requested {@link User}. + * @param userId + * The id of the requested {@link User} + * @param user + * The modified User whose attributed need to be updated. * @return The updated user. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @PUT @Path("{userId}") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public User update( @PathParam("scopeId") ScopeId scopeId, @PathParam("userId") EntityId userId, @@ -209,10 +234,13 @@ public User update( /** * Deletes the User specified by the "userId" path parameter. * - * @param scopeId The ScopeId of the requested {@link User}. - * @param userId The id of the User to be deleted. + * @param scopeId + * The ScopeId of the requested {@link User}. + * @param userId + * The id of the User to be deleted. * @return HTTP 200 if operation has completed successfully. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @DELETE diff --git a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/UsersCredentials.java b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/UsersCredentials.java index 3b3bc9d3597..4537e7df5a9 100644 --- a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/UsersCredentials.java +++ b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/UsersCredentials.java @@ -12,11 +12,24 @@ *******************************************************************************/ package org.eclipse.kapua.app.api.resources.v1.resources; +import javax.inject.Inject; +import javax.ws.rs.Consumes; +import javax.ws.rs.DefaultValue; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.app.api.core.model.CountResult; import org.eclipse.kapua.app.api.core.model.EntityId; import org.eclipse.kapua.app.api.core.model.ScopeId; import org.eclipse.kapua.app.api.core.resources.AbstractKapuaResource; +import org.eclipse.kapua.model.query.KapuaQuery; import org.eclipse.kapua.model.query.predicate.AndPredicate; import org.eclipse.kapua.service.KapuaService; import org.eclipse.kapua.service.authentication.credential.Credential; @@ -24,22 +37,9 @@ import org.eclipse.kapua.service.authentication.credential.CredentialCreator; import org.eclipse.kapua.service.authentication.credential.CredentialFactory; import org.eclipse.kapua.service.authentication.credential.CredentialListResult; -import org.eclipse.kapua.service.authentication.credential.CredentialQuery; import org.eclipse.kapua.service.authentication.credential.CredentialService; import org.eclipse.kapua.service.authentication.user.PasswordResetRequest; -import javax.inject.Inject; -import javax.ws.rs.Consumes; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - /* @deprecated accidentally exposed under: @@ -59,22 +59,27 @@ public class UsersCredentials extends AbstractKapuaResource { /** * Gets the {@link Credential} list in the scope. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param userId The {@link EntityId} for which search results. - * @param offset The result set offset. - * @param limit The result set limit. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param userId + * The {@link EntityId} for which search results. + * @param offset + * The result set offset. + * @param limit + * The result set limit. * @return The {@link CredentialListResult} of all the credentials associated to the current selected scope. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @GET - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public CredentialListResult getAll( @PathParam("scopeId") ScopeId scopeId, @PathParam("userId") EntityId userId, @QueryParam("offset") @DefaultValue("0") int offset, @QueryParam("limit") @DefaultValue("50") int limit) throws KapuaException { - CredentialQuery query = credentialFactory.newQuery(scopeId); + KapuaQuery query = new KapuaQuery(scopeId); AndPredicate andPredicate = query.andPredicate(); andPredicate.and(query.attributePredicate(CredentialAttributes.USER_ID, userId)); @@ -86,25 +91,28 @@ public CredentialListResult getAll( return credentialService.query(query); } - /** - * Counts the results with the given {@link CredentialQuery} parameter. + * Counts the results with the given {@link KapuaQuery} parameter. * - * @param scopeId The {@link ScopeId} in which to count results. - * @param userId The {@link EntityId} for which count results. - * @param query The {@link CredentialQuery} to use to filter results. - * @return The count of all the result matching the given {@link CredentialQuery} parameter. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @param scopeId + * The {@link ScopeId} in which to count results. + * @param userId + * The {@link EntityId} for which count results. + * @param query + * The {@link KapuaQuery} to use to filter results. + * @return The count of all the result matching the given {@link KapuaQuery} parameter. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @POST @Path("_count") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public CountResult count( @PathParam("scopeId") ScopeId scopeId, @PathParam("userId") EntityId userId, - CredentialQuery query) throws KapuaException { + KapuaQuery query) throws KapuaException { AndPredicate andPredicate = query.andPredicate(); andPredicate.and(query.attributePredicate(CredentialAttributes.USER_ID, userId)); query.setPredicate(andPredicate); @@ -112,21 +120,23 @@ public CountResult count( return new CountResult(credentialService.count(query)); } - /** - * Creates a new Credential based on the information provided in CredentialCreator - * parameter. + * Creates a new Credential based on the information provided in CredentialCreator parameter. * - * @param scopeId The {@link ScopeId} in which to create the {@link Credential}. - * @param userId The {@link EntityId} for which create the {@link Credential}. - * @param credentialCreator Provides the information for the new Credential to be created. + * @param scopeId + * The {@link ScopeId} in which to create the {@link Credential}. + * @param userId + * The {@link EntityId} for which create the {@link Credential}. + * @param credentialCreator + * Provides the information for the new Credential to be created. * @return The newly created Credential object. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @POST - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public Response create( @PathParam("scopeId") ScopeId scopeId, @PathParam("userId") EntityId userId, @@ -140,11 +150,15 @@ public Response create( /** * Reset the password for the specific user * - * @param scopeId The {@link ScopeId} of the {@link Credential} to reset. - * @param userId The {@link EntityId} for which to reset the password credential. - * @param passwordResetRequest Request for resetting credential password + * @param scopeId + * The {@link ScopeId} of the {@link Credential} to reset. + * @param userId + * The {@link EntityId} for which to reset the password credential. + * @param passwordResetRequest + * Request for resetting credential password * @return The updated credential. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 2.0.0 * @deprecated since 2.0.0 - use POST POST /{scopeId}/users/{userId}/password/_reset instead (see {@link UsersCredentials}) */ diff --git a/rest-api/web/src/main/java/org/eclipse/kapua/app/api/web/RestApiJAXBContextProvider.java b/rest-api/web/src/main/java/org/eclipse/kapua/app/api/web/RestApiJAXBContextProvider.java index 0203a1f1c31..2bb3fa39ee8 100644 --- a/rest-api/web/src/main/java/org/eclipse/kapua/app/api/web/RestApiJAXBContextProvider.java +++ b/rest-api/web/src/main/java/org/eclipse/kapua/app/api/web/RestApiJAXBContextProvider.java @@ -81,7 +81,6 @@ import org.eclipse.kapua.service.account.Account; import org.eclipse.kapua.service.account.AccountCreator; import org.eclipse.kapua.service.account.AccountListResult; -import org.eclipse.kapua.service.account.AccountQuery; import org.eclipse.kapua.service.account.AccountUpdateRequest; import org.eclipse.kapua.service.account.CurrentAccountUpdateRequest; import org.eclipse.kapua.service.account.xml.AccountParentPathXmlAdapter; @@ -95,13 +94,11 @@ import org.eclipse.kapua.service.authentication.credential.Credential; import org.eclipse.kapua.service.authentication.credential.CredentialCreator; import org.eclipse.kapua.service.authentication.credential.CredentialListResult; -import org.eclipse.kapua.service.authentication.credential.CredentialQuery; import org.eclipse.kapua.service.authentication.credential.CredentialType; import org.eclipse.kapua.service.authentication.credential.CredentialXmlRegistry; import org.eclipse.kapua.service.authentication.credential.mfa.MfaOption; import org.eclipse.kapua.service.authentication.credential.mfa.MfaOptionCreator; import org.eclipse.kapua.service.authentication.credential.mfa.MfaOptionListResult; -import org.eclipse.kapua.service.authentication.credential.mfa.MfaOptionQuery; import org.eclipse.kapua.service.authentication.credential.mfa.MfaOptionXmlRegistry; import org.eclipse.kapua.service.authentication.credential.mfa.ScratchCode; import org.eclipse.kapua.service.authentication.credential.mfa.ScratchCodeListResult; @@ -114,22 +111,17 @@ import org.eclipse.kapua.service.authorization.access.AccessInfo; import org.eclipse.kapua.service.authorization.access.AccessInfoCreator; import org.eclipse.kapua.service.authorization.access.AccessInfoListResult; -import org.eclipse.kapua.service.authorization.access.AccessInfoQuery; import org.eclipse.kapua.service.authorization.access.AccessInfoXmlRegistry; import org.eclipse.kapua.service.authorization.access.AccessPermission; import org.eclipse.kapua.service.authorization.access.AccessPermissionCreator; import org.eclipse.kapua.service.authorization.access.AccessPermissionListResult; -import org.eclipse.kapua.service.authorization.access.AccessPermissionQuery; import org.eclipse.kapua.service.authorization.access.AccessPermissionXmlRegistry; import org.eclipse.kapua.service.authorization.access.AccessRole; import org.eclipse.kapua.service.authorization.access.AccessRoleCreator; import org.eclipse.kapua.service.authorization.access.AccessRoleListResult; -import org.eclipse.kapua.service.authorization.access.AccessRoleQuery; import org.eclipse.kapua.service.authorization.access.AccessRoleXmlRegistry; import org.eclipse.kapua.service.authorization.domain.Domain; import org.eclipse.kapua.service.authorization.domain.DomainListResult; -import org.eclipse.kapua.service.authorization.domain.DomainQuery; -import org.eclipse.kapua.service.authorization.domain.DomainXmlRegistry; import org.eclipse.kapua.service.authorization.group.Group; import org.eclipse.kapua.service.authorization.group.GroupCreator; import org.eclipse.kapua.service.authorization.group.GroupListResult; @@ -142,7 +134,6 @@ import org.eclipse.kapua.service.authorization.role.RolePermission; import org.eclipse.kapua.service.authorization.role.RolePermissionCreator; import org.eclipse.kapua.service.authorization.role.RolePermissionListResult; -import org.eclipse.kapua.service.authorization.role.RolePermissionQuery; import org.eclipse.kapua.service.authorization.role.RolePermissionXmlRegistry; import org.eclipse.kapua.service.authorization.role.RoleQuery; import org.eclipse.kapua.service.authorization.role.RoleXmlRegistry; @@ -285,7 +276,6 @@ import org.eclipse.kapua.service.job.step.JobStep; import org.eclipse.kapua.service.job.step.JobStepCreator; import org.eclipse.kapua.service.job.step.JobStepListResult; -import org.eclipse.kapua.service.job.step.JobStepQuery; import org.eclipse.kapua.service.job.step.JobStepXmlRegistry; import org.eclipse.kapua.service.job.step.definition.JobStepDefinition; import org.eclipse.kapua.service.job.step.definition.JobStepDefinitionListResult; @@ -295,11 +285,9 @@ import org.eclipse.kapua.service.job.targets.JobTarget; import org.eclipse.kapua.service.job.targets.JobTargetCreator; import org.eclipse.kapua.service.job.targets.JobTargetListResult; -import org.eclipse.kapua.service.job.targets.JobTargetQuery; import org.eclipse.kapua.service.scheduler.trigger.Trigger; import org.eclipse.kapua.service.scheduler.trigger.TriggerCreator; import org.eclipse.kapua.service.scheduler.trigger.TriggerListResult; -import org.eclipse.kapua.service.scheduler.trigger.TriggerQuery; import org.eclipse.kapua.service.scheduler.trigger.TriggerXmlRegistry; import org.eclipse.kapua.service.scheduler.trigger.definition.TriggerDefinition; import org.eclipse.kapua.service.scheduler.trigger.definition.TriggerDefinitionListResult; @@ -308,7 +296,6 @@ import org.eclipse.kapua.service.scheduler.trigger.definition.TriggerProperty; import org.eclipse.kapua.service.scheduler.trigger.fired.FiredTrigger; import org.eclipse.kapua.service.scheduler.trigger.fired.FiredTriggerListResult; -import org.eclipse.kapua.service.scheduler.trigger.fired.FiredTriggerQuery; import org.eclipse.kapua.service.scheduler.trigger.fired.FiredTriggerXmlRegistry; import org.eclipse.kapua.service.storable.model.id.StorableId; import org.eclipse.kapua.service.storable.model.query.SortField; @@ -410,7 +397,6 @@ public JAXBContext getJAXBContext() throws KapuaException { Account.class, AccountCreator.class, AccountListResult.class, - AccountQuery.class, AccountParentPathXmlAdapter.class, AccountXmlRegistry.class, @@ -608,14 +594,12 @@ public JAXBContext getJAXBContext() throws KapuaException { CredentialListResult.class, CredentialCreator.class, CredentialType.class, - CredentialQuery.class, CredentialXmlRegistry.class, // Multi Factor Authentication MfaOption.class, MfaOptionListResult.class, MfaOptionCreator.class, - MfaOptionQuery.class, MfaOptionXmlRegistry.class, ScratchCode.class, ScratchCodeListResult.class, @@ -643,14 +627,11 @@ public JAXBContext getJAXBContext() throws KapuaException { RolePermission.class, RolePermissionListResult.class, RolePermissionCreator.class, - RolePermissionQuery.class, RolePermissionXmlRegistry.class, // Domains Domain.class, DomainListResult.class, - DomainQuery.class, - DomainXmlRegistry.class, // Groups Group.class, @@ -663,21 +644,18 @@ public JAXBContext getJAXBContext() throws KapuaException { AccessInfo.class, AccessInfoListResult.class, AccessInfoCreator.class, - AccessInfoQuery.class, AccessInfoXmlRegistry.class, // Access Permissions AccessPermission.class, AccessPermissionListResult.class, AccessPermissionCreator.class, - AccessPermissionQuery.class, AccessPermissionXmlRegistry.class, // Access Roles AccessRole.class, AccessRoleListResult.class, AccessRoleCreator.class, - AccessRoleQuery.class, AccessRoleXmlRegistry.class, // System Info @@ -734,7 +712,6 @@ public JAXBContext getJAXBContext() throws KapuaException { JobStep.class, JobStepCreator.class, JobStepListResult.class, - JobStepQuery.class, JobStepXmlRegistry.class, JobStepProperty.class, @@ -746,14 +723,12 @@ public JAXBContext getJAXBContext() throws KapuaException { JobTarget.class, JobTargetCreator.class, JobTargetListResult.class, - JobTargetQuery.class, JobExecutionXmlRegistry.class, // Trigger Trigger.class, TriggerCreator.class, TriggerListResult.class, - TriggerQuery.class, TriggerProperty.class, TriggerXmlRegistry.class, @@ -764,7 +739,6 @@ public JAXBContext getJAXBContext() throws KapuaException { FiredTrigger.class, FiredTriggerListResult.class, - FiredTriggerQuery.class, FiredTriggerXmlRegistry.class, JobStepDefinition.class, diff --git a/service/account/api/src/main/java/org/eclipse/kapua/service/account/AccountFactory.java b/service/account/api/src/main/java/org/eclipse/kapua/service/account/AccountFactory.java index 9e2a0d806ad..5abbe9cee1c 100644 --- a/service/account/api/src/main/java/org/eclipse/kapua/service/account/AccountFactory.java +++ b/service/account/api/src/main/java/org/eclipse/kapua/service/account/AccountFactory.java @@ -21,7 +21,7 @@ * @see KapuaEntityFactory * @since 1.0.0 */ -public interface AccountFactory extends KapuaEntityFactory { +public interface AccountFactory extends KapuaEntityFactory { /** * Instantiates a new {@link AccountCreator} with the given name. diff --git a/service/account/api/src/main/java/org/eclipse/kapua/service/account/AccountQuery.java b/service/account/api/src/main/java/org/eclipse/kapua/service/account/AccountQuery.java deleted file mode 100644 index 5e320976b3d..00000000000 --- a/service/account/api/src/main/java/org/eclipse/kapua/service/account/AccountQuery.java +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - * 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.service.account; - -import org.eclipse.kapua.model.query.KapuaQuery; -import org.eclipse.kapua.service.account.xml.AccountXmlRegistry; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - -/** - * {@link Account} {@link KapuaQuery} definition. - * - * @see KapuaQuery - * @since 1.0.0 - */ -@XmlRootElement(name = "query") -@XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = AccountXmlRegistry.class, factoryMethod = "newQuery") -public interface AccountQuery extends KapuaQuery { -} diff --git a/service/account/api/src/main/java/org/eclipse/kapua/service/account/xml/AccountXmlRegistry.java b/service/account/api/src/main/java/org/eclipse/kapua/service/account/xml/AccountXmlRegistry.java index 08ea6672fee..52b5bae1095 100644 --- a/service/account/api/src/main/java/org/eclipse/kapua/service/account/xml/AccountXmlRegistry.java +++ b/service/account/api/src/main/java/org/eclipse/kapua/service/account/xml/AccountXmlRegistry.java @@ -18,7 +18,6 @@ import org.eclipse.kapua.service.account.Account; import org.eclipse.kapua.service.account.AccountCreator; import org.eclipse.kapua.service.account.AccountFactory; -import org.eclipse.kapua.service.account.AccountQuery; import org.eclipse.kapua.service.account.Organization; /** @@ -52,16 +51,6 @@ public AccountCreator newAccountCreator() { return factory.newCreator(null); } - /** - * Instantiates a new {@link AccountQuery}. - * - * @return The newly instantiated {@link AccountQuery}. - * @since 1.0.0 - */ - public AccountQuery newQuery() { - return factory.newQuery(null); - } - /** * Instantiates a new {@link Organization}. * diff --git a/service/account/internal/src/main/java/org/eclipse/kapua/service/account/internal/AccountFactoryImpl.java b/service/account/internal/src/main/java/org/eclipse/kapua/service/account/internal/AccountFactoryImpl.java index 39a2399496f..778a9f02c48 100644 --- a/service/account/internal/src/main/java/org/eclipse/kapua/service/account/internal/AccountFactoryImpl.java +++ b/service/account/internal/src/main/java/org/eclipse/kapua/service/account/internal/AccountFactoryImpl.java @@ -19,7 +19,6 @@ import org.eclipse.kapua.service.account.Account; import org.eclipse.kapua.service.account.AccountCreator; import org.eclipse.kapua.service.account.AccountFactory; -import org.eclipse.kapua.service.account.AccountQuery; import org.eclipse.kapua.service.account.Organization; /** @@ -52,11 +51,6 @@ public Organization newOrganization() { return new OrganizationImpl(); } - @Override - public AccountQuery newQuery(KapuaId scopeId) { - return new AccountQueryImpl(scopeId); - } - @Override public Account clone(Account account) { try { diff --git a/service/account/internal/src/main/java/org/eclipse/kapua/service/account/internal/AccountQueryImpl.java b/service/account/internal/src/main/java/org/eclipse/kapua/service/account/internal/AccountQueryImpl.java deleted file mode 100644 index 1c4531a6d2d..00000000000 --- a/service/account/internal/src/main/java/org/eclipse/kapua/service/account/internal/AccountQueryImpl.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * 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.service.account.internal; - -import org.eclipse.kapua.commons.model.query.AbstractKapuaNamedQuery; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.service.account.AccountQuery; - -/** - * {@link AccountQuery} implementation. - * - * @since 1.0.0 - */ -public class AccountQueryImpl extends AbstractKapuaNamedQuery implements AccountQuery { - - /** - * Constructor. - * - * @since 1.0.0 - */ - private AccountQueryImpl() { - super(); - } - - /** - * Constructor. - * - * @param scopeId The {@link AccountQuery#getScopeId()}. - * @since 1.0.0 - */ - public AccountQueryImpl(KapuaId scopeId) { - this(); - - setScopeId(scopeId); - } -} diff --git a/service/account/internal/src/main/java/org/eclipse/kapua/service/account/internal/AccountRelativeFinderImpl.java b/service/account/internal/src/main/java/org/eclipse/kapua/service/account/internal/AccountRelativeFinderImpl.java index d187ccab8d8..ce0c2c4bf2e 100644 --- a/service/account/internal/src/main/java/org/eclipse/kapua/service/account/internal/AccountRelativeFinderImpl.java +++ b/service/account/internal/src/main/java/org/eclipse/kapua/service/account/internal/AccountRelativeFinderImpl.java @@ -26,12 +26,12 @@ import org.eclipse.kapua.commons.security.KapuaSecurityUtils; import org.eclipse.kapua.model.KapuaEntityAttributes; import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.model.query.KapuaQuery; import org.eclipse.kapua.model.query.predicate.AttributePredicate; import org.eclipse.kapua.service.KapuaService; import org.eclipse.kapua.service.account.Account; import org.eclipse.kapua.service.account.AccountFactory; import org.eclipse.kapua.service.account.AccountListResult; -import org.eclipse.kapua.service.account.AccountQuery; import org.eclipse.kapua.service.account.AccountService; public class AccountRelativeFinderImpl implements AccountRelativeFinder, KapuaService { @@ -47,7 +47,7 @@ public AccountRelativeFinderImpl(AccountFactory accountFactory, AccountService a @Override public AccountListResult findChildren(KapuaId scopeId, Optional excludeTargetScopeId) throws KapuaException { - final AccountQuery childAccountsQuery = accountFactory.newQuery(scopeId); + final KapuaQuery childAccountsQuery = new KapuaQuery(scopeId); // Exclude the scope that is under config update if (excludeTargetScopeId.isPresent()) { childAccountsQuery.setPredicate( @@ -65,7 +65,7 @@ public AccountListResult findChildren(KapuaId scopeId, Optional exclude public List findParentIds(KapuaId accountId) throws KapuaException { Account account = KapuaSecurityUtils.doPrivileged(() -> accountService.find(accountId)); - if(account == null || account.getParentAccountPath() == null) { + if (account == null || account.getParentAccountPath() == null) { return Collections.emptyList(); } @@ -75,10 +75,10 @@ public List findParentIds(KapuaId accountId) throws KapuaException { String accountIdStr = accountId.getId().toString(); // Iterate in reverse order to get parent first, then grandparent, etc - for(int i = splitIds.length - 1; i >= 0; i--) { + for (int i = splitIds.length - 1; i >= 0; i--) { String id = splitIds[i]; - if(id != null && !id.isEmpty() && !id.equals(accountIdStr)) { + if (id != null && !id.isEmpty() && !id.equals(accountIdStr)) { parentAccountIds.add(new KapuaEid(new BigInteger(id))); } } diff --git a/service/account/internal/src/main/java/org/eclipse/kapua/service/account/internal/AccountServiceImpl.java b/service/account/internal/src/main/java/org/eclipse/kapua/service/account/internal/AccountServiceImpl.java index bac7692c02f..9dc097f4d5b 100644 --- a/service/account/internal/src/main/java/org/eclipse/kapua/service/account/internal/AccountServiceImpl.java +++ b/service/account/internal/src/main/java/org/eclipse/kapua/service/account/internal/AccountServiceImpl.java @@ -412,7 +412,7 @@ private AccountListResult findChildAccountsTrusted(KapuaId accountId) ArgumentValidator.notNull(accountId, KapuaEntityAttributes.ENTITY_ID); ArgumentValidator.notNull(accountId.getId(), "accountId.id"); // Do find - return txManager.execute(tx -> accountRepository.query(tx, new AccountQueryImpl(accountId))); + return txManager.execute(tx -> accountRepository.query(tx, new KapuaQuery(accountId))); } private void checkAccountPermission(KapuaId scopeId, KapuaId accountId, Actions action) throws KapuaException { diff --git a/service/account/test-steps/src/main/java/org/eclipse/kapua/service/account/steps/AccountServiceSteps.java b/service/account/test-steps/src/main/java/org/eclipse/kapua/service/account/steps/AccountServiceSteps.java index 29b66908557..46e2d4293b0 100755 --- a/service/account/test-steps/src/main/java/org/eclipse/kapua/service/account/steps/AccountServiceSteps.java +++ b/service/account/test-steps/src/main/java/org/eclipse/kapua/service/account/steps/AccountServiceSteps.java @@ -47,7 +47,6 @@ import org.eclipse.kapua.service.account.AccountCreator; import org.eclipse.kapua.service.account.AccountFactory; import org.eclipse.kapua.service.account.AccountListResult; -import org.eclipse.kapua.service.account.AccountQuery; import org.eclipse.kapua.service.account.AccountService; import org.eclipse.kapua.service.account.Organization; import org.junit.Assert; @@ -523,7 +522,7 @@ public void addUnknownIntegerConfigurationValue(String name, int value) throws E @When("I query for all accounts that have the system account as parent") public void queryForNumberOfTopLevelAccounts() throws Exception { - AccountQuery query = accountFactory.newQuery(SYS_SCOPE_ID); + KapuaQuery query = new KapuaQuery(SYS_SCOPE_ID); stepData.remove(INT_VALUE); try { primeException(); @@ -593,7 +592,7 @@ public void checkForAccountModifications(String name) throws KapuaException { @Then("The account with name {string} has {int} subaccount(s)") public void checkNumberOfAccounts(String accountName, int num) throws KapuaException { - KapuaQuery query = accountFactory.newQuery(getCurrentScopeId()); + final KapuaQuery query = new KapuaQuery(getCurrentScopeId()); Account account = accountService.find(getCurrentScopeId()); Assert.assertEquals(accountName, account.getName()); @@ -606,7 +605,7 @@ public void checkNumberOfChildrenForNamedAccount(String name, int num) throws Ex try { primeException(); Account tmpAcc = accountService.findByName(name); - KapuaQuery query = accountFactory.newQuery(tmpAcc.getId()); + final KapuaQuery query = new KapuaQuery(tmpAcc.getId()); long accountCnt = accountService.count(query); Assert.assertEquals(num, accountCnt); @@ -783,7 +782,7 @@ private AccountCreator accountCreatorCreator(String name, BigInteger scopeId, Da @And("I find account with name {string}") public void iFindAccountWithName(String accountName) throws Exception { - AccountQuery accountQuery = accountFactory.newQuery(getCurrentScopeId()); + final KapuaQuery accountQuery = new KapuaQuery(getCurrentScopeId()); accountQuery.setPredicate(accountQuery.attributePredicate(AccountAttributes.NAME, accountName)); AccountListResult accountListResult = accountService.query(accountQuery); Assert.assertTrue(accountListResult.getSize() > 0); @@ -869,7 +868,7 @@ public void iCreateAccountWithNameOrganizationNameAndEmailaddressAndChildAccount @When("I query for all sub-accounts in {string}") public void queryForAllAccountsInCurrentScopeId(String accountName) throws Exception { Account tmpAccount = accountService.findByName(accountName); - AccountQuery query = accountFactory.newQuery(tmpAccount.getId()); + final KapuaQuery query = new KapuaQuery(tmpAccount.getId()); try { primeException(); AccountListResult accList = accountService.query(query); 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 27e46090c29..8abb771e865 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 @@ -29,14 +29,12 @@ import org.eclipse.kapua.commons.metric.MetricsService; import org.eclipse.kapua.commons.metric.MetricsServiceImpl; import org.eclipse.kapua.commons.model.mappers.KapuaBaseMapperImpl; -import org.eclipse.kapua.commons.model.query.QueryFactoryImpl; import org.eclipse.kapua.commons.service.event.store.internal.EventStoreRecordImplJpaRepository; import org.eclipse.kapua.commons.service.internal.cache.CacheManagerProvider; import org.eclipse.kapua.commons.setting.system.SystemSetting; import org.eclipse.kapua.commons.util.xml.XmlUtil; import org.eclipse.kapua.locator.KapuaLocator; import org.eclipse.kapua.model.config.metatype.KapuaMetatypeFactory; -import org.eclipse.kapua.model.query.QueryFactory; import org.eclipse.kapua.qa.common.MockedLocator; import org.eclipse.kapua.qa.common.TestJAXBContextProvider; import org.eclipse.kapua.service.account.AccountFactory; @@ -99,7 +97,6 @@ protected void configure() { // skip } - bind(QueryFactory.class).toInstance(new QueryFactoryImpl()); bind(KapuaJpaRepositoryConfiguration.class).toInstance(new KapuaJpaRepositoryConfiguration()); bind(AuthorizationService.class).toInstance(mockedAuthorization); diff --git a/service/api/src/main/java/org/eclipse/kapua/model/KapuaEntityFactory.java b/service/api/src/main/java/org/eclipse/kapua/model/KapuaEntityFactory.java index c2475140c7b..bcd810e1204 100644 --- a/service/api/src/main/java/org/eclipse/kapua/model/KapuaEntityFactory.java +++ b/service/api/src/main/java/org/eclipse/kapua/model/KapuaEntityFactory.java @@ -14,7 +14,6 @@ import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.model.query.KapuaQuery; /** * {@link KapuaEntityFactory} definition. @@ -23,11 +22,9 @@ * The {@link KapuaEntity} for which this {@link KapuaEntityFactory} is for. * @param * The {@link KapuaEntityCreator} for which this {@link KapuaEntityFactory} is for. - * @param - * The {@link KapuaQuery} for which this {@link KapuaEntityFactory} is for. * @since 1.0.0 */ -public interface KapuaEntityFactory, Q extends KapuaQuery> extends KapuaObjectFactory { +public interface KapuaEntityFactory> extends KapuaObjectFactory { /** * Instantiates a new {@link KapuaEntity}. @@ -49,16 +46,6 @@ public interface KapuaEntityFactory fetchAttributes; + + private Integer offset; + private Integer limit; + private Boolean askTotalCount; + + /** + * Constructor. + * + * @since 1.0.0 + */ + public KapuaQuery() { + } + + /** + * Constructor. + * + * @param scopeId + * The scope {@link KapuaId} of the {@link KapuaQuery} + * @since 1.0.0 + */ + public KapuaQuery(KapuaId scopeId) { + this(); + + setScopeId(scopeId); + } + + /** + * Constructor. + *

    + * It deeply clones the given {@link KapuaQuery} + * + * @param query + * the query to clone. + */ + public KapuaQuery(@NotNull KapuaQuery query) { + setFetchAttributes(query.getFetchAttributes()); + setPredicate(query.getPredicate()); + setLimit(query.getLimit()); + setOffset(query.getOffset()); + setSortCriteria(query.getSortCriteria()); + setAskTotalCount(query.getAskTotalCount()); + } /** * Gets the fetch attribute names list. @@ -40,24 +91,35 @@ public interface KapuaQuery { */ @XmlElementWrapper(name = "fetchAttributeName") @XmlElement(name = "fetchAttributeName") - List getFetchAttributes(); + public List getFetchAttributes() { + if (fetchAttributes == null) { + fetchAttributes = new ArrayList<>(); + } + + return fetchAttributes; + } /** * Adds an attribute to the fetch attribute names list * - * @param fetchAttribute The fetch attribute to add to the list. + * @param fetchAttribute + * The fetch attribute to add to the list. * @since 1.0.0 */ - void addFetchAttributes(@NotNull String fetchAttribute); + public void addFetchAttributes(String fetchAttribute) { + getFetchAttributes().add(fetchAttribute); + } /** - * Sets the fetch attribute names list.
    - * This list is a list of optional attributes of a {@link KapuaEntity} that can be fetched when querying. + * Sets the fetch attribute names list.
    This list is a list of optional attributes of a {@link KapuaEntity} that can be fetched when querying. * - * @param fetchAttributeNames The fetch attribute names list. + * @param fetchAttributeNames + * The fetch attribute names list. * @since 1.0.0 */ - void setFetchAttributes(@NotNull List fetchAttributeNames); + public void setFetchAttributes(List fetchAttributeNames) { + this.fetchAttributes = fetchAttributeNames; + } /** * Get the scope {@link KapuaId} in which to query. @@ -67,15 +129,20 @@ public interface KapuaQuery { */ @XmlElement(name = "scopeId") @XmlJavaTypeAdapter(KapuaIdAdapter.class) - KapuaId getScopeId(); + public KapuaId getScopeId() { + return scopeId; + } /** * Set the scope {@link KapuaId} in which to query. * - * @param scopeId The scope {@link KapuaId} in which to query. + * @param scopeId + * The scope {@link KapuaId} in which to query. * @since 1.0.0 */ - void setScopeId(KapuaId scopeId); + public void setScopeId(KapuaId scopeId) { + this.scopeId = scopeId; + } /** * Gets the {@link KapuaQuery} {@link QueryPredicate}s. @@ -84,17 +151,20 @@ public interface KapuaQuery { * @since 1.0.0 */ @XmlTransient - QueryPredicate getPredicate(); + public QueryPredicate getPredicate() { + return this.predicate; + } /** - * Sets the {@link KapuaQuery} {@link QueryPredicate}s.
    - * The {@link QueryPredicate} can be a simple {@link AttributePredicate} or a combination - * of them by using the {@link AndPredicate} + * Sets the {@link KapuaQuery} {@link QueryPredicate}s.
    The {@link QueryPredicate} can be a simple {@link AttributePredicate} or a combination of them by using the {@link AndPredicate} * - * @param queryPredicate The {@link KapuaQuery} {@link QueryPredicate}s. + * @param queryPredicate + * The {@link KapuaQuery} {@link QueryPredicate}s. * @since 1.0.0 */ - void setPredicate(@NotNull QueryPredicate queryPredicate); + public void setPredicate(QueryPredicate queryPredicate) { + this.predicate = queryPredicate; + } /** * Gets the {@link KapuaQuery} {@link KapuaSortCriteria} @@ -103,7 +173,9 @@ public interface KapuaQuery { * @since 1.0.0 */ @XmlTransient - KapuaSortCriteria getSortCriteria(); + public KapuaSortCriteria getSortCriteria() { + return sortCriteria; + } /** * Sets the {@link KapuaQuery} {@link KapuaSortCriteria}. @@ -112,7 +184,9 @@ public interface KapuaQuery { * The {@link KapuaQuery} {@link KapuaSortCriteria}. * @since 1.0.0 */ - void setSortCriteria(@NotNull KapuaSortCriteria sortCriteria); + public void setSortCriteria(KapuaSortCriteria sortCriteria) { + this.sortCriteria = sortCriteria; + } /** * Gets whether to include not scoped {@link KapuaEntity}es in the result set. @@ -122,7 +196,7 @@ public interface KapuaQuery { * @return Whether to include not scoped {@link KapuaEntity}es in the result set. * @since 2.0.0 */ - default boolean getNotScopedEntities() { + public boolean getNotScopedEntities() { return false; } @@ -133,7 +207,9 @@ default boolean getNotScopedEntities() { * @since 1.5.0 */ @XmlTransient - KapuaSortCriteria getDefaultSortCriteria(); + public KapuaSortCriteria getDefaultSortCriteria() { + return fieldSortCriteria(KapuaEntityAttributes.ENTITY_ID, SortOrder.ASCENDING); + } /** * Gets the {@link KapuaQuery} offset. @@ -142,20 +218,25 @@ default boolean getNotScopedEntities() { * @since 1.0.0 */ @XmlElement(name = "offset") - Integer getOffset(); + public Integer getOffset() { + return offset; + } /** * Set the {@link KapuaQuery} offset in the result set from which start query. *

    - * If set to {@code null} the {@link KapuaQuery} will start from the first result found. - * This also mean that {@link #setOffset(Integer)} with {@code 0} or {@code null} will produce the same result. + * If set to {@code null} the {@link KapuaQuery} will start from the first result found. This also mean that {@link #setOffset(Integer)} with {@code 0} or {@code null} will produce the same + * result. *

    * This method and {@link #setLimit(Integer)} are meant to be used to paginate through the result set. * - * @param offset The {@link KapuaQuery} offset. + * @param offset + * The {@link KapuaQuery} offset. * @since 1.0.0 */ - void setOffset(Integer offset); + public void setOffset(Integer offset) { + this.offset = offset; + } /** * Gets the {@link KapuaQuery} limit. @@ -164,7 +245,9 @@ default boolean getNotScopedEntities() { * @since 1.0.0 */ @XmlElement(name = "limit") - Integer getLimit(); + public Integer getLimit() { + return limit; + } /** * Sets max number of result that will be fetched by this {@link KapuaEntity}. @@ -173,20 +256,24 @@ default boolean getNotScopedEntities() { *

    * This method and {@link #setOffset(Integer)} are meant to be used to paginate through the result set. * - * @param limit The max number of result that will be fetched by this {@link KapuaEntity}. + * @param limit + * The max number of result that will be fetched by this {@link KapuaEntity}. * @since 1.0.0 */ - void setLimit(Integer limit); + public void setLimit(Integer limit) { + this.limit = limit; + } /** - * Get the {@code askTotalCount} flag. If {@literal true}, the returning {@link KapuaListResult} will also return a value in - * the {@code totalCount} field, indicating how many entries matched the query regardless of {@code limit} and - * {@code offset}. If {@literal false}, {@code totalCount} will be {@literal null}. + * Get the {@code askTotalCount} flag. If {@literal true}, the returning {@link KapuaListResult} will also return a value in the {@code totalCount} field, indicating how many entries matched the + * query regardless of {@code limit} and {@code offset}. If {@literal false}, {@code totalCount} will be {@literal null}. * * @return The value of {@code askTotalCount} * @since 1.2.0 */ - Boolean getAskTotalCount(); + public Boolean getAskTotalCount() { + return askTotalCount; + } /** * Set the {@code askTotalCount} flag. @@ -194,67 +281,94 @@ default boolean getNotScopedEntities() { * @param askTotalCount * @since 1.2.0 */ - void setAskTotalCount(Boolean askTotalCount); + public void setAskTotalCount(Boolean askTotalCount) { + this.askTotalCount = askTotalCount; + } // Predicates factory /** * Creates a new {@link AttributePredicate} * - * @param attributeName The name of the attribute - * @param attributeValue The value of the attribute - * @param The type of {@code attributeValue} + * @param attributeName + * The name of the attribute + * @param attributeValue + * The value of the attribute + * @param + * The type of {@code attributeValue} * @return A new {@link AttributePredicate} for the given parameters */ - AttributePredicate attributePredicate(String attributeName, T attributeValue); + public AttributePredicate attributePredicate(String attributeName, T attributeValue) { + return new AttributePredicate<>(attributeName, attributeValue); + } /** * Creates a new {@link AttributePredicate} * - * @param attributeName The name of the attribute - * @param attributeValue The value of the attribute - * @param operator The operator to apply - * @param The type of {@code attributeValue} + * @param attributeName + * The name of the attribute + * @param attributeValue + * The value of the attribute + * @param operator + * The operator to apply + * @param + * The type of {@code attributeValue} * @return A new {@link AttributePredicate} for the given parameters */ - AttributePredicate attributePredicate(String attributeName, T attributeValue, AttributePredicate.Operator operator); + public AttributePredicate attributePredicate(String attributeName, T attributeValue, AttributePredicate.Operator operator) { + return new AttributePredicate<>(attributeName, attributeValue, operator); + } /** * Creates a new, empty {@link AndPredicate} * * @return A new, empty {@link AndPredicate} */ - AndPredicate andPredicate(); + public AndPredicate andPredicate() { + return new AndPredicate(); + } /** * Creates a new {@link AndPredicate} creating a logical AND with all the provided {@link QueryPredicate} * - * @param queryPredicates A list of {@link QueryPredicate}s to create the {@link AndPredicate} + * @param queryPredicates + * A list of {@link QueryPredicate}s to create the {@link AndPredicate} * @return A new {@link AndPredicate} */ - AndPredicate andPredicate(QueryPredicate... queryPredicates); + public AndPredicate andPredicate(QueryPredicate... queryPredicates) { + return new AndPredicate(queryPredicates); + } /** * Creates a new, empty {@link OrPredicate} * * @return A new, empty {@link OrPredicate} */ - OrPredicate orPredicate(); + public OrPredicate orPredicate() { + return new OrPredicate(); + } /** * Creates a new {@link OrPredicate} creating a logical OR with all the provided {@link QueryPredicate} * - * @param queryPredicates A list of {@link QueryPredicate}s to create the {@link OrPredicate} + * @param queryPredicates + * A list of {@link QueryPredicate}s to create the {@link OrPredicate} * @return A new {@link OrPredicate} */ - OrPredicate orPredicate(QueryPredicate... queryPredicates); + public OrPredicate orPredicate(QueryPredicate... queryPredicates) { + return new OrPredicate(queryPredicates); + } /** * Creates a new {@link FieldSortCriteria} * - * @param attributeName The name of the attribute - * @param sortOrder The {@link SortOrder} + * @param attributeName + * The name of the attribute + * @param sortOrder + * The {@link SortOrder} * @return */ - FieldSortCriteria fieldSortCriteria(String attributeName, SortOrder sortOrder); + public FieldSortCriteria fieldSortCriteria(String attributeName, SortOrder sortOrder) { + return new FieldSortCriteria(attributeName, sortOrder); + } } diff --git a/service/api/src/main/java/org/eclipse/kapua/model/query/QueryFactory.java b/service/api/src/main/java/org/eclipse/kapua/model/query/QueryFactory.java deleted file mode 100644 index adc9c83b1d1..00000000000 --- a/service/api/src/main/java/org/eclipse/kapua/model/query/QueryFactory.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2021, 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.model.query; - -import org.eclipse.kapua.model.KapuaObjectFactory; - -/** - * {@link KapuaQuery} {@link KapuaObjectFactory} definition. - * - * @since 2.0.0 - */ -public interface QueryFactory extends KapuaObjectFactory { - - /** - * Instantiates a new {@link KapuaQuery}. - * - * @return The newly instantiated {@link KapuaQuery}. - * @since 2.0.0 - */ - KapuaQuery newQuery(); -} diff --git a/commons/src/main/java/org/eclipse/kapua/commons/model/query/predicate/AbstractMatchPredicate.java b/service/api/src/main/java/org/eclipse/kapua/model/query/predicate/AbstractMatchPredicate.java similarity index 88% rename from commons/src/main/java/org/eclipse/kapua/commons/model/query/predicate/AbstractMatchPredicate.java rename to service/api/src/main/java/org/eclipse/kapua/model/query/predicate/AbstractMatchPredicate.java index 40f4fe530a4..f5e2e6fd5c2 100644 --- a/commons/src/main/java/org/eclipse/kapua/commons/model/query/predicate/AbstractMatchPredicate.java +++ b/service/api/src/main/java/org/eclipse/kapua/model/query/predicate/AbstractMatchPredicate.java @@ -10,12 +10,10 @@ * Contributors: * Eurotech - initial API and implementation *******************************************************************************/ -package org.eclipse.kapua.commons.model.query.predicate; +package org.eclipse.kapua.model.query.predicate; import java.util.List; -import org.eclipse.kapua.model.query.predicate.MatchPredicate; - /** * {@link MatchPredicate} implementation. * diff --git a/service/api/src/main/java/org/eclipse/kapua/model/query/predicate/AndPredicate.java b/service/api/src/main/java/org/eclipse/kapua/model/query/predicate/AndPredicate.java index 1104ad0aaf0..81f03b26960 100644 --- a/service/api/src/main/java/org/eclipse/kapua/model/query/predicate/AndPredicate.java +++ b/service/api/src/main/java/org/eclipse/kapua/model/query/predicate/AndPredicate.java @@ -12,8 +12,13 @@ *******************************************************************************/ package org.eclipse.kapua.model.query.predicate; -import javax.validation.constraints.NotNull; +import java.util.ArrayList; import java.util.List; +import java.util.Objects; + +import javax.validation.constraints.NotNull; + +import com.google.common.collect.Lists; /** * {@link AndPredicate} definition. @@ -22,17 +27,51 @@ * * @since 1.0.0 */ -public interface AndPredicate extends QueryPredicate { +public class AndPredicate implements QueryPredicate { + + private List predicates; + + /** + * Constructor. + * + * @since 1.0.0 + */ + public AndPredicate() { + setPredicates(new ArrayList<>()); + } + + /** + * Constructor which accepts a not null array of {@link QueryPredicate}s. + * + * @param predicates + * the {@link QueryPredicate}s to add. + * @throws NullPointerException + * if the given parameter is {@code null}. + * @since 1.0.0 + */ + public AndPredicate(@NotNull QueryPredicate... predicates) { + Objects.requireNonNull(predicates); + + setPredicates(Lists.newArrayList(predicates)); + } /** * Adds the given {@link QueryPredicate} to the {@link AndPredicate}. * - * @param predicate The {@link AndPredicate} to concatenate + * @param predicate + * The {@link AndPredicate} to concatenate * @return {@code this} {@link AndPredicate}. - * @throws NullPointerException if the given parameter is {@code null}. + * @throws NullPointerException + * if the given parameter is {@code null}. * @since 1.0.0 */ - AndPredicate and(@NotNull QueryPredicate predicate); + public AndPredicate and(@NotNull QueryPredicate predicate) { + Objects.requireNonNull(predicates); + + getPredicates().add(predicate); + + return this; + } /** * Gets all {@link QueryPredicate} set for this {@link AndPredicate} @@ -40,14 +79,20 @@ public interface AndPredicate extends QueryPredicate { * @return The {@link List} of {@link QueryPredicate}s * @since 1.0.0 */ - List getPredicates(); + public List getPredicates() { + return this.predicates; + } /** * Sets a {@link List} of {@link QueryPredicate}s in AND clause * - * @param predicates The {@link List} of {@link QueryPredicate}s - * @throws NullPointerException if the given parameter is {@code null}. + * @param predicates + * The {@link List} of {@link QueryPredicate}s + * @throws NullPointerException + * if the given parameter is {@code null}. * @since 1.1.0 */ - void setPredicates(@NotNull List predicates); + public void setPredicates(List predicates) { + this.predicates = predicates; + } } diff --git a/service/api/src/main/java/org/eclipse/kapua/model/query/predicate/AttributePredicate.java b/service/api/src/main/java/org/eclipse/kapua/model/query/predicate/AttributePredicate.java index 79fde273391..172ac756db2 100644 --- a/service/api/src/main/java/org/eclipse/kapua/model/query/predicate/AttributePredicate.java +++ b/service/api/src/main/java/org/eclipse/kapua/model/query/predicate/AttributePredicate.java @@ -15,10 +15,11 @@ /** * {@link AttributePredicate} definition. * - * @param Attribute value type. + * @param + * Attribute value type. * @since 1.3.0 */ -public interface AttributePredicate extends QueryPredicate { +public class AttributePredicate implements QueryPredicate { /** * {@link AttributePredicate}s operators @@ -27,7 +28,7 @@ public interface AttributePredicate extends QueryPredicate { * * @since 1.3.0 */ - enum Operator { + public static enum Operator { /** * {@literal #EQUAL} {@link Operator} *

    @@ -66,8 +67,7 @@ enum Operator { /** * {@literal #STARTS_WITH} {@link Operator} *

    - * Matches results with value that starts with the given value. - * To be used with {@link String} {@link org.eclipse.kapua.model.KapuaEntityAttributes}. + * Matches results with value that starts with the given value. To be used with {@link String} {@link org.eclipse.kapua.model.KapuaEntityAttributes}. * * @since 1.3.0 */ @@ -76,8 +76,7 @@ enum Operator { /** * The same of {@link #STARTS_WITH} {@link Operator} but case insensitive *

    - * Matches results with value that starts with the given value, case insensitive. - * To be used with {@link String} {@link org.eclipse.kapua.model.KapuaEntityAttributes}. + * Matches results with value that starts with the given value, case insensitive. To be used with {@link String} {@link org.eclipse.kapua.model.KapuaEntityAttributes}. * * @since 1.3.0 */ @@ -86,8 +85,7 @@ enum Operator { /** * {@literal #LIKE} {@link Operator} *

    - * Matches results with value that are like (in SQL fashion) the given value. - * To be used with {@link String} {@link org.eclipse.kapua.model.KapuaEntityAttributes}. + * Matches results with value that are like (in SQL fashion) the given value. To be used with {@link String} {@link org.eclipse.kapua.model.KapuaEntityAttributes}. *

    * If you want to match only the beginning of the {@link String} please consider using {@link #STARTS_WITH}. * @@ -98,8 +96,7 @@ enum Operator { /** * {@link #LIKE} {@link Operator} but case insensitive *

    - * Matches results with value that are like (in SQL fashion) the given value case insensitive. - * To be used with {@link String} {@link org.eclipse.kapua.model.KapuaEntityAttributes}. + * Matches results with value that are like (in SQL fashion) the given value case insensitive. To be used with {@link String} {@link org.eclipse.kapua.model.KapuaEntityAttributes}. *

    * If you want to match only the beginning of the {@link String} please consider using {@link #STARTS_WITH_IGNORE_CASE}. * @@ -110,8 +107,7 @@ enum Operator { /** * {@literal #GREATER_THAN} {@link Operator} *

    - * Matches result with value that is greater but not equal. - * To be used with {@link Comparable} types. + * Matches result with value that is greater but not equal. To be used with {@link Comparable} types. * * @since 1.3.0 */ @@ -120,8 +116,7 @@ enum Operator { /** * {@literal #GREATER_THAN_OR_EQUAL} {@link Operator} *

    - * Matches result with value that is greater or equal. - * To be used with {@link Comparable} types. + * Matches result with value that is greater or equal. To be used with {@link Comparable} types. * * @since 1.3.0 */ @@ -130,8 +125,7 @@ enum Operator { /** * {@literal #LESS_THAN} {@link Operator} *

    - * Matches result with value that is less but not equal. - * To be used with {@link Comparable} types. + * Matches result with value that is less but not equal. To be used with {@link Comparable} types. * * @since 1.3.0 */ @@ -140,21 +134,58 @@ enum Operator { /** * {@literal #LESS_THAN_OR_EQUAL} {@link Operator} *

    - * Matches result with value that is less or equal. - * To be used with {@link Comparable} types. + * Matches result with value that is less or equal. To be used with {@link Comparable} types. * * @since 1.3.0 */ LESS_THAN_OR_EQUAL } + private String attributeName; + private T attributeValue; + private Operator operator; + + /** + * Constructor. + *

    + * Defaults ot {@link org.eclipse.kapua.model.query.predicate.AttributePredicate.Operator#EQUAL} + * + * @param attributeName + * The name of {@link org.eclipse.kapua.model.KapuaEntityAttributes} to set into the {@link AttributePredicate}. + * @param attributeValue + * The value of {@link org.eclipse.kapua.model.KapuaEntityAttributes} to set into the {@link AttributePredicate}. + * @since 1.0.0 + */ + public AttributePredicate(String attributeName, T attributeValue) { + this(attributeName, attributeValue, Operator.EQUAL); + } + + /** + * Constructor. + * + * @param attributeName + * The name of {@link org.eclipse.kapua.model.KapuaEntityAttributes} to set into the {@link AttributePredicate}. + * @param attributeValue + * The value of {@link org.eclipse.kapua.model.KapuaEntityAttributes} to set into the {@link AttributePredicate}. + * @param operator + * The {@link org.eclipse.kapua.model.query.predicate.AttributePredicate.Operator} to set into the {@link AttributePredicate}. + * @since 1.0.0 + */ + public AttributePredicate(String attributeName, T attributeValue, Operator operator) { + this.attributeName = attributeName; + this.attributeValue = attributeValue; + this.operator = operator; + } + /** * Gets the name of the {@link org.eclipse.kapua.model.KapuaEntityAttributes} to compare. * * @return The name name of the {@link org.eclipse.kapua.model.KapuaEntityAttributes} to compare. * @since 1.3.0 */ - String getAttributeName(); + public String getAttributeName() { + return attributeName; + } /** * Gets the value to compare the results. @@ -162,7 +193,9 @@ enum Operator { * @return The value to compare the results. * @since 1.3.0 */ - T getAttributeValue(); + public T getAttributeValue() { + return attributeValue; + } /** * Get the {@link Operator} used to compare results. @@ -170,5 +203,7 @@ enum Operator { * @return The {@link Operator} used to compare results. * @since 1.3.0 */ - Operator getOperator(); + public Operator getOperator() { + return operator; + } } diff --git a/service/api/src/main/java/org/eclipse/kapua/model/query/predicate/OrPredicate.java b/service/api/src/main/java/org/eclipse/kapua/model/query/predicate/OrPredicate.java index 2cc4c8a36dc..58c5bb5640a 100644 --- a/service/api/src/main/java/org/eclipse/kapua/model/query/predicate/OrPredicate.java +++ b/service/api/src/main/java/org/eclipse/kapua/model/query/predicate/OrPredicate.java @@ -12,8 +12,13 @@ *******************************************************************************/ package org.eclipse.kapua.model.query.predicate; -import javax.validation.constraints.NotNull; +import java.util.ArrayList; import java.util.List; +import java.util.Objects; + +import javax.validation.constraints.NotNull; + +import com.google.common.collect.Lists; /** * {@link OrPredicate} definition. @@ -22,17 +27,51 @@ * * @since 1.0.0 */ -public interface OrPredicate extends QueryPredicate { +public class OrPredicate implements QueryPredicate { + + private List predicates; + + /** + * Constructor. + * + * @since 1.0.0 + */ + public OrPredicate() { + setPredicates(new ArrayList<>()); + } + + /** + * Constructor which accepts a not {@code null} array of {@link QueryPredicate}s. + * + * @param predicates + * the {@link QueryPredicate}s to add. + * @throws NullPointerException + * if the given parameter is {@code null}. + * @since 1.0.0 + */ + public OrPredicate(@NotNull QueryPredicate... predicates) { + Objects.requireNonNull(predicates); + + setPredicates(Lists.newArrayList(predicates)); + } /** * Adds the given {@link QueryPredicate} to the {@link OrPredicate}. * - * @param predicate The {@link OrPredicate} to concatenate + * @param predicate + * The {@link OrPredicate} to concatenate * @return {@code this} {@link OrPredicate}. - * @throws NullPointerException if the given parameter is {@code null}. + * @throws NullPointerException + * if the given parameter is {@code null}. * @since 1.0.0 */ - OrPredicate or(@NotNull QueryPredicate predicate); + public OrPredicate or(@NotNull QueryPredicate predicate) { + Objects.requireNonNull(predicates); + + getPredicates().add(predicate); + + return this; + } /** * Gets all {@link QueryPredicate} set for this {@link OrPredicate} @@ -40,15 +79,21 @@ public interface OrPredicate extends QueryPredicate { * @return The {@link List} of {@link QueryPredicate}s * @since 1.0.0 */ - List getPredicates(); + public List getPredicates() { + return this.predicates; + } /** * Sets a {@link List} of {@link QueryPredicate}s in OR clause * - * @param predicates The {@link List} of {@link QueryPredicate}s - * @throws NullPointerException if the given parameter is {@code null}. + * @param predicates + * The {@link List} of {@link QueryPredicate}s + * @throws NullPointerException + * if the given parameter is {@code null}. * @since 1.1.0 */ - void setPredicates(@NotNull List predicates); + public void setPredicates(List predicates) { + this.predicates = predicates; + } } diff --git a/service/authentication/src/main/java/org/eclipse/kapua/service/authentication/authentication/AuthenticationLogic.java b/service/authentication/src/main/java/org/eclipse/kapua/service/authentication/authentication/AuthenticationLogic.java index c505cabf576..6733b65d31c 100644 --- a/service/authentication/src/main/java/org/eclipse/kapua/service/authentication/authentication/AuthenticationLogic.java +++ b/service/authentication/src/main/java/org/eclipse/kapua/service/authentication/authentication/AuthenticationLogic.java @@ -12,6 +12,10 @@ *******************************************************************************/ package org.eclipse.kapua.service.authentication.authentication; +import java.text.MessageFormat; +import java.util.List; +import java.util.Map; + import org.apache.shiro.ShiroException; import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.client.security.bean.AclUtils; @@ -22,6 +26,7 @@ import org.eclipse.kapua.commons.model.id.KapuaEid; import org.eclipse.kapua.commons.security.KapuaSecurityUtils; import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.model.query.KapuaQuery; import org.eclipse.kapua.service.authorization.AuthorizationService; import org.eclipse.kapua.service.authorization.permission.PermissionFactory; import org.eclipse.kapua.service.device.registry.ConnectionUserCouplingMode; @@ -32,15 +37,10 @@ import org.eclipse.kapua.service.device.registry.connection.DeviceConnectionStatus; import org.eclipse.kapua.service.device.registry.connection.option.DeviceConnectionOptionAttributes; import org.eclipse.kapua.service.device.registry.connection.option.DeviceConnectionOptionFactory; -import org.eclipse.kapua.service.device.registry.connection.option.DeviceConnectionOptionQuery; import org.eclipse.kapua.service.device.registry.connection.option.DeviceConnectionOptionService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.text.MessageFormat; -import java.util.List; -import java.util.Map; - /** * Authentication logic definition * @@ -98,8 +98,8 @@ public abstract List connect(AuthContext authContext) * Execute the disconnection logic * * @param authContext - * @return true send disconnect message (if the disconnection is a clean disconnection) - * false don't send disconnect message (the disconnection is caused by a stealing link or the device is currently connected to another node) + * @return true send disconnect message (if the disconnection is a clean disconnection) false don't send disconnect message (the disconnection is caused by a stealing link or the device is + * currently connected to another node) */ public abstract boolean disconnect(AuthContext authContext); @@ -224,7 +224,7 @@ protected void enforceDeviceUserBound(ConnectionUserCouplingMode connectionUserC */ protected void checkConnectionCountByReservedUserId(KapuaId scopeId, KapuaId userId, long count) throws KapuaException { // check that no devices have this user as strict user - DeviceConnectionOptionQuery query = deviceConnectionOptionFactory.newQuery(scopeId); + final KapuaQuery query = new KapuaQuery(scopeId); query.setPredicate(query.attributePredicate(DeviceConnectionOptionAttributes.RESERVED_USER_ID, userId)); query.setLimit(1); @@ -286,7 +286,8 @@ protected DeviceConnection createDeviceConnection(AuthContext authContext) throw * Updates a {@link DeviceConnection} using the info provided. * * @param authContext - * @param deviceConnection The {@link DeviceConnection} to update, or null if it needs to be created + * @param deviceConnection + * The {@link DeviceConnection} to update, or null if it needs to be created * @return The updated {@link DeviceConnection} * @throws KapuaException */ diff --git a/service/commons/storable/internal/src/main/java/org/eclipse/kapua/service/storable/model/query/predicate/AndPredicateImpl.java b/service/commons/storable/internal/src/main/java/org/eclipse/kapua/service/storable/model/query/predicate/AndPredicateImpl.java index a4ef55373db..8e747afdbab 100644 --- a/service/commons/storable/internal/src/main/java/org/eclipse/kapua/service/storable/model/query/predicate/AndPredicateImpl.java +++ b/service/commons/storable/internal/src/main/java/org/eclipse/kapua/service/storable/model/query/predicate/AndPredicateImpl.java @@ -12,16 +12,17 @@ *******************************************************************************/ package org.eclipse.kapua.service.storable.model.query.predicate; +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.kapua.service.storable.exception.MappingException; + import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.google.common.collect.Lists; -import org.eclipse.kapua.service.storable.exception.MappingException; - -import java.util.ArrayList; -import java.util.List; /** - * {@link AndPredicate} implementation. + * {@link AndPredicateImpl} implementation. * * @since 1.0.0 */ @@ -40,7 +41,8 @@ public AndPredicateImpl() { /** * Constructor. * - * @param storablePredicates The {@link StorablePredicate}s to add. + * @param storablePredicates + * The {@link StorablePredicate}s to add. * @since 1.0.0 */ public AndPredicateImpl(StorablePredicate... storablePredicates) { @@ -49,7 +51,6 @@ public AndPredicateImpl(StorablePredicate... storablePredicates) { setPredicates(Lists.newArrayList(storablePredicates)); } - @Override public List getPredicates() { if (predicates == null) { predicates = new ArrayList<>(); @@ -58,13 +59,11 @@ public List getPredicates() { return this.predicates; } - @Override - public AndPredicate addPredicate(StorablePredicate storablePredicate) { + public AndPredicateImpl addPredicate(StorablePredicate storablePredicate) { getPredicates().add(storablePredicate); return this; } - @Override public void setPredicates(List predicates) { this.predicates = predicates; } diff --git a/service/commons/storable/internal/src/main/java/org/eclipse/kapua/service/storable/model/query/predicate/StorablePredicateFactoryImpl.java b/service/commons/storable/internal/src/main/java/org/eclipse/kapua/service/storable/model/query/predicate/StorablePredicateFactoryImpl.java index 1c53c801060..28bfca84d3f 100644 --- a/service/commons/storable/internal/src/main/java/org/eclipse/kapua/service/storable/model/query/predicate/StorablePredicateFactoryImpl.java +++ b/service/commons/storable/internal/src/main/java/org/eclipse/kapua/service/storable/model/query/predicate/StorablePredicateFactoryImpl.java @@ -12,10 +12,10 @@ *******************************************************************************/ package org.eclipse.kapua.service.storable.model.query.predicate; -import org.eclipse.kapua.service.storable.model.query.StorableField; - import javax.inject.Singleton; +import org.eclipse.kapua.service.storable.model.query.StorableField; + @Singleton public class StorablePredicateFactoryImpl implements StorablePredicateFactory { diff --git a/service/datastore/internal/src/main/java/org/eclipse/kapua/service/datastore/internal/ChannelInfoRegistryServiceImpl.java b/service/datastore/internal/src/main/java/org/eclipse/kapua/service/datastore/internal/ChannelInfoRegistryServiceImpl.java index d780327d982..36d54456cb7 100644 --- a/service/datastore/internal/src/main/java/org/eclipse/kapua/service/datastore/internal/ChannelInfoRegistryServiceImpl.java +++ b/service/datastore/internal/src/main/java/org/eclipse/kapua/service/datastore/internal/ChannelInfoRegistryServiceImpl.java @@ -13,6 +13,14 @@ *******************************************************************************/ package org.eclipse.kapua.service.datastore.internal; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Optional; + +import javax.inject.Inject; +import javax.inject.Singleton; + import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.commons.model.domains.Domains; import org.eclipse.kapua.commons.service.internal.KapuaServiceDisabledException; @@ -46,13 +54,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.inject.Inject; -import javax.inject.Singleton; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Optional; - /** * Channel info registry implementation * @@ -217,8 +218,7 @@ private void checkDataAccess(KapuaId scopeId, Actions action) /** * Update the last published date and last published message identifier for the specified channel info, so it gets the timestamp and the message id of the last published message for the - * account/clientId in the - * channel info + * account/clientId in the channel info * * @param channelInfo * @throws KapuaException diff --git a/service/datastore/internal/src/main/java/org/eclipse/kapua/service/datastore/internal/ClientInfoRegistryServiceImpl.java b/service/datastore/internal/src/main/java/org/eclipse/kapua/service/datastore/internal/ClientInfoRegistryServiceImpl.java index d2ca458e475..1c4df4080ac 100644 --- a/service/datastore/internal/src/main/java/org/eclipse/kapua/service/datastore/internal/ClientInfoRegistryServiceImpl.java +++ b/service/datastore/internal/src/main/java/org/eclipse/kapua/service/datastore/internal/ClientInfoRegistryServiceImpl.java @@ -13,6 +13,14 @@ *******************************************************************************/ package org.eclipse.kapua.service.datastore.internal; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Optional; + +import javax.inject.Inject; +import javax.inject.Singleton; + import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.commons.model.domains.Domains; import org.eclipse.kapua.commons.service.internal.KapuaServiceDisabledException; @@ -47,13 +55,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.inject.Inject; -import javax.inject.Singleton; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Optional; - /** * Client information registry implementation. * diff --git a/service/datastore/internal/src/main/java/org/eclipse/kapua/service/datastore/internal/MetricInfoRegistryServiceImpl.java b/service/datastore/internal/src/main/java/org/eclipse/kapua/service/datastore/internal/MetricInfoRegistryServiceImpl.java index 8063b15f995..c7b56d7dbd1 100644 --- a/service/datastore/internal/src/main/java/org/eclipse/kapua/service/datastore/internal/MetricInfoRegistryServiceImpl.java +++ b/service/datastore/internal/src/main/java/org/eclipse/kapua/service/datastore/internal/MetricInfoRegistryServiceImpl.java @@ -13,6 +13,14 @@ *******************************************************************************/ package org.eclipse.kapua.service.datastore.internal; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Optional; + +import javax.inject.Inject; +import javax.inject.Singleton; + import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.commons.model.domains.Domains; import org.eclipse.kapua.commons.service.internal.KapuaServiceDisabledException; @@ -47,13 +55,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.inject.Inject; -import javax.inject.Singleton; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Optional; - /** * Metric information registry implementation. * diff --git a/service/datastore/test-steps/src/main/java/org/eclipse/kapua/service/datastore/steps/DatastoreSteps.java b/service/datastore/test-steps/src/main/java/org/eclipse/kapua/service/datastore/steps/DatastoreSteps.java index dbcef294c9a..c1e747114b0 100755 --- a/service/datastore/test-steps/src/main/java/org/eclipse/kapua/service/datastore/steps/DatastoreSteps.java +++ b/service/datastore/test-steps/src/main/java/org/eclipse/kapua/service/datastore/steps/DatastoreSteps.java @@ -12,15 +12,27 @@ *******************************************************************************/ package org.eclipse.kapua.service.datastore.steps; -import com.google.inject.Singleton; -import io.cucumber.java.After; -import io.cucumber.java.Before; -import io.cucumber.java.DataTableType; -import io.cucumber.java.Scenario; -import io.cucumber.java.en.And; -import io.cucumber.java.en.Given; -import io.cucumber.java.en.Then; -import io.cucumber.java.en.When; +import java.io.IOException; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.time.Instant; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Calendar; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.TimeZone; +import java.util.function.Function; +import java.util.stream.Collectors; + +import javax.inject.Inject; + import org.apache.commons.lang.ArrayUtils; import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.commons.util.KapuaDateUtils; @@ -108,25 +120,16 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.inject.Inject; -import java.io.IOException; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.time.Instant; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Calendar; -import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.TimeZone; -import java.util.function.Function; -import java.util.stream.Collectors; +import com.google.inject.Singleton; + +import io.cucumber.java.After; +import io.cucumber.java.Before; +import io.cucumber.java.DataTableType; +import io.cucumber.java.Scenario; +import io.cucumber.java.en.And; +import io.cucumber.java.en.Given; +import io.cucumber.java.en.Then; +import io.cucumber.java.en.When; @Singleton public class DatastoreSteps extends TestBase { @@ -167,26 +170,26 @@ public void iSetTheFollowingMetricsFromTheList(String lstKey, List me tmpMsg.setPayload(dataMessageFactory.newKapuaDataPayload()); switch (tmpMet.getType().trim().toLowerCase()) { - case "string": { - tmpMsg.getPayload().getMetrics().put(tmpMet.getMetric(), tmpMet.getValue()); - break; - } - case "int": { - tmpMsg.getPayload().getMetrics().put(tmpMet.getMetric(), Integer.valueOf(tmpMet.getValue())); - break; - } - case DOUBLE: { - tmpMsg.getPayload().getMetrics().put(tmpMet.getMetric(), Double.valueOf(tmpMet.getValue())); - break; - } - case "bool": { - tmpMsg.getPayload().getMetrics().put(tmpMet.getMetric(), Boolean.valueOf(tmpMet.getValue().trim().toUpperCase())); - break; - } - default: { - Assert.fail(String.format("Unknown metric type [%s]", tmpMet.getType())); - break; - } + case "string": { + tmpMsg.getPayload().getMetrics().put(tmpMet.getMetric(), tmpMet.getValue()); + break; + } + case "int": { + tmpMsg.getPayload().getMetrics().put(tmpMet.getMetric(), Integer.valueOf(tmpMet.getValue())); + break; + } + case DOUBLE: { + tmpMsg.getPayload().getMetrics().put(tmpMet.getMetric(), Double.valueOf(tmpMet.getValue())); + break; + } + case "bool": { + tmpMsg.getPayload().getMetrics().put(tmpMet.getMetric(), Boolean.valueOf(tmpMet.getValue().trim().toUpperCase())); + break; + } + default: { + Assert.fail(String.format("Unknown metric type [%s]", tmpMet.getType())); + break; + } } } } @@ -518,26 +521,26 @@ public void appendMetricsToSelectedMessage(int idx, String lstKey, List toData(List metrics) { final String type = entry.getType(); switch (type.toUpperCase()) { - case "STRING": - data.put(key, stringValue); - break; - case "INT32": - data.put(key, Integer.valueOf(stringValue)); - break; - case "INT64": - data.put(key, Long.valueOf(stringValue)); - break; - case "DOUBLE": - data.put(key, Double.parseDouble(stringValue)); - break; - case "BOOLEAN": - data.put(key, Boolean.valueOf(stringValue)); - break; - default: - throw new IllegalArgumentException(String.format("Unknown type: %s", type)); + case "STRING": + data.put(key, stringValue); + break; + case "INT32": + data.put(key, Integer.valueOf(stringValue)); + break; + case "INT64": + data.put(key, Long.valueOf(stringValue)); + break; + case "DOUBLE": + data.put(key, Double.parseDouble(stringValue)); + break; + case "BOOLEAN": + data.put(key, Boolean.valueOf(stringValue)); + break; + default: + throw new IllegalArgumentException(String.format("Unknown type: %s", type)); } } return data; @@ -2156,8 +2160,7 @@ private static T getValue(Object object, String field, Class clazz) { } /** - * Return the suffix field name to compose (in a different method) the getter name. - * It removes the _ and append the remaining part capitalizing the first letter (if capitalizeFirstLetter = true) + * Return the suffix field name to compose (in a different method) the getter name. It removes the _ and append the remaining part capitalizing the first letter (if capitalizeFirstLetter = true) * * @param field * @return @@ -2251,7 +2254,8 @@ private static Field getField(Class objectClass, final String field) { * @param storageEnabled * @throws KapuaException */ - private void updateConfiguration(MessageStoreService messageStoreService, KapuaId scopeId, KapuaId parentId, DataIndexBy dataIndexBy, MetricsIndexBy metricsIndexBy, int dataTTL, boolean storageEnabled) + private void updateConfiguration(MessageStoreService messageStoreService, KapuaId scopeId, KapuaId parentId, DataIndexBy dataIndexBy, MetricsIndexBy metricsIndexBy, int dataTTL, + boolean storageEnabled) throws KapuaException { Map config = messageStoreService.getConfigValues(scopeId); @@ -2285,8 +2289,10 @@ private void theListHaveLimitExceedValue(Class /** * Creating query for data messages with reasonable defaults. * - * @param scopeId scope - * @param limit limit results + * @param scopeId + * scope + * @param limit + * limit results * @return query */ public MessageQuery createBaseMessageQuery(KapuaId scopeId, int limit) { @@ -2307,9 +2313,12 @@ public MessageQuery createBaseMessageQuery(KapuaId scopeId, int limit) { /** * Creating query for data messages with reasonable defaults and user specified ordering. * - * @param scopeId scope - * @param limit limit results - * @param order the required result ordering + * @param scopeId + * scope + * @param limit + * limit results + * @param order + * the required result ordering * @return query */ public MessageQuery createBaseMessageQuery(KapuaId scopeId, int limit, List order) { @@ -2327,8 +2336,10 @@ public MessageQuery createBaseMessageQuery(KapuaId scopeId, int limit, List { +public interface JobDeviceManagementOperationFactory extends KapuaEntityFactory { } diff --git a/service/device/management/job/api/src/main/java/org/eclipse/kapua/service/device/management/job/JobDeviceManagementOperationQuery.java b/service/device/management/job/api/src/main/java/org/eclipse/kapua/service/device/management/job/JobDeviceManagementOperationQuery.java deleted file mode 100644 index 35d1f7f4557..00000000000 --- a/service/device/management/job/api/src/main/java/org/eclipse/kapua/service/device/management/job/JobDeviceManagementOperationQuery.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2019, 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.service.device.management.job; - -import org.eclipse.kapua.model.query.KapuaQuery; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - -/** - * {@link JobDeviceManagementOperation} {@link KapuaQuery} definition. - * - * @see KapuaQuery - * @since 1.1.0 - */ -@XmlRootElement(name = "query") -@XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = JobDeviceManagementOperationXmlRegistry.class, factoryMethod = "newQuery") -public interface JobDeviceManagementOperationQuery extends KapuaQuery { -} diff --git a/service/device/management/job/api/src/main/java/org/eclipse/kapua/service/device/management/job/JobDeviceManagementOperationService.java b/service/device/management/job/api/src/main/java/org/eclipse/kapua/service/device/management/job/JobDeviceManagementOperationService.java index bb2617b5aac..9772c463537 100644 --- a/service/device/management/job/api/src/main/java/org/eclipse/kapua/service/device/management/job/JobDeviceManagementOperationService.java +++ b/service/device/management/job/api/src/main/java/org/eclipse/kapua/service/device/management/job/JobDeviceManagementOperationService.java @@ -26,7 +26,8 @@ public interface JobDeviceManagementOperationService extends KapuaEntityService< /** * Returns the {@link JobDeviceManagementOperationListResult} with elements matching the provided query. * - * @param query The {@link JobDeviceManagementOperationQuery} used to filter results. + * @param query + * The {@link KapuaQuery} used to filter results. * @return The {@link JobDeviceManagementOperationListResult} with elements matching the query parameter. * @throws KapuaException * @since 1.1.0 diff --git a/service/device/management/job/api/src/main/java/org/eclipse/kapua/service/device/management/job/JobDeviceManagementOperationXmlRegistry.java b/service/device/management/job/api/src/main/java/org/eclipse/kapua/service/device/management/job/JobDeviceManagementOperationXmlRegistry.java index f9b2513eb14..eb23385a81b 100644 --- a/service/device/management/job/api/src/main/java/org/eclipse/kapua/service/device/management/job/JobDeviceManagementOperationXmlRegistry.java +++ b/service/device/management/job/api/src/main/java/org/eclipse/kapua/service/device/management/job/JobDeviceManagementOperationXmlRegistry.java @@ -34,7 +34,4 @@ public JobDeviceManagementOperationCreator newJobDeviceManagementOperationCreato return jobDeviceManagementOperationFactory.newCreator(null); } - public JobDeviceManagementOperationQuery newQuery() { - return jobDeviceManagementOperationFactory.newQuery(null); - } } diff --git a/service/device/management/job/internal/src/main/java/org/eclipse/kapua/service/device/management/job/internal/JobDeviceManagementOperationFactoryImpl.java b/service/device/management/job/internal/src/main/java/org/eclipse/kapua/service/device/management/job/internal/JobDeviceManagementOperationFactoryImpl.java index 3db27bf80c4..32c2868962a 100644 --- a/service/device/management/job/internal/src/main/java/org/eclipse/kapua/service/device/management/job/internal/JobDeviceManagementOperationFactoryImpl.java +++ b/service/device/management/job/internal/src/main/java/org/eclipse/kapua/service/device/management/job/internal/JobDeviceManagementOperationFactoryImpl.java @@ -19,7 +19,6 @@ import org.eclipse.kapua.service.device.management.job.JobDeviceManagementOperation; import org.eclipse.kapua.service.device.management.job.JobDeviceManagementOperationCreator; import org.eclipse.kapua.service.device.management.job.JobDeviceManagementOperationFactory; -import org.eclipse.kapua.service.device.management.job.JobDeviceManagementOperationQuery; /** * {@link JobDeviceManagementOperationFactory} implementation. @@ -39,11 +38,6 @@ public JobDeviceManagementOperationCreator newCreator(KapuaId scopeId) { return new JobDeviceManagementOperationCreatorImpl(scopeId); } - @Override - public JobDeviceManagementOperationQuery newQuery(KapuaId scopeId) { - return new JobDeviceManagementOperationQueryImpl(scopeId); - } - @Override public JobDeviceManagementOperation clone(JobDeviceManagementOperation jobDeviceManagementOperation) { try { diff --git a/service/device/management/job/internal/src/main/java/org/eclipse/kapua/service/device/management/job/internal/JobDeviceManagementOperationQueryImpl.java b/service/device/management/job/internal/src/main/java/org/eclipse/kapua/service/device/management/job/internal/JobDeviceManagementOperationQueryImpl.java deleted file mode 100644 index 2f0b27f35d8..00000000000 --- a/service/device/management/job/internal/src/main/java/org/eclipse/kapua/service/device/management/job/internal/JobDeviceManagementOperationQueryImpl.java +++ /dev/null @@ -1,35 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2019, 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.service.device.management.job.internal; - -import org.eclipse.kapua.commons.model.query.AbstractKapuaQuery; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.service.device.management.job.JobDeviceManagementOperationQuery; - -/** - * {@link JobDeviceManagementOperationQuery} definition. - * - * @since 1.1.0 - */ -public class JobDeviceManagementOperationQueryImpl extends AbstractKapuaQuery implements JobDeviceManagementOperationQuery { - - /** - * Constructor. - * - * @param scopeId The {@link #getScopeId()}. - * @since 1.1.0 - */ - public JobDeviceManagementOperationQueryImpl(KapuaId scopeId) { - super(scopeId); - } -} diff --git a/service/device/management/job/internal/src/main/java/org/eclipse/kapua/service/device/management/job/internal/JobDeviceManagementOperationServiceImpl.java b/service/device/management/job/internal/src/main/java/org/eclipse/kapua/service/device/management/job/internal/JobDeviceManagementOperationServiceImpl.java index 9a63d5a979a..36fc997740a 100644 --- a/service/device/management/job/internal/src/main/java/org/eclipse/kapua/service/device/management/job/internal/JobDeviceManagementOperationServiceImpl.java +++ b/service/device/management/job/internal/src/main/java/org/eclipse/kapua/service/device/management/job/internal/JobDeviceManagementOperationServiceImpl.java @@ -12,15 +12,23 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.management.job.internal; +import java.util.AbstractMap; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import javax.inject.Inject; +import javax.inject.Singleton; + import org.eclipse.kapua.KapuaEntityUniquenessException; import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.commons.model.domains.Domains; -import org.eclipse.kapua.commons.model.query.predicate.AndPredicateImpl; -import org.eclipse.kapua.commons.model.query.predicate.AttributePredicateImpl; import org.eclipse.kapua.commons.util.ArgumentValidator; import org.eclipse.kapua.model.domain.Actions; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.model.query.KapuaQuery; +import org.eclipse.kapua.model.query.predicate.AndPredicate; +import org.eclipse.kapua.model.query.predicate.AttributePredicate; import org.eclipse.kapua.service.authorization.AuthorizationService; import org.eclipse.kapua.service.authorization.permission.PermissionFactory; import org.eclipse.kapua.service.device.management.job.JobDeviceManagementOperation; @@ -28,18 +36,10 @@ import org.eclipse.kapua.service.device.management.job.JobDeviceManagementOperationCreator; import org.eclipse.kapua.service.device.management.job.JobDeviceManagementOperationFactory; import org.eclipse.kapua.service.device.management.job.JobDeviceManagementOperationListResult; -import org.eclipse.kapua.service.device.management.job.JobDeviceManagementOperationQuery; import org.eclipse.kapua.service.device.management.job.JobDeviceManagementOperationRepository; import org.eclipse.kapua.service.device.management.job.JobDeviceManagementOperationService; import org.eclipse.kapua.storage.TxManager; -import javax.inject.Inject; -import javax.inject.Singleton; -import java.util.AbstractMap; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - /** * {@link JobDeviceManagementOperationService} implementation * @@ -79,11 +79,11 @@ public JobDeviceManagementOperation create(JobDeviceManagementOperationCreator j // Check access authorizationService.checkPermission(permissionFactory.newPermission(Domains.JOB, Actions.write, null)); // Check duplicate - JobDeviceManagementOperationQuery query = new JobDeviceManagementOperationQueryImpl(jobDeviceManagementOperationCreator.getScopeId()); + KapuaQuery query = new KapuaQuery(jobDeviceManagementOperationCreator.getScopeId()); query.setPredicate( - new AndPredicateImpl( - new AttributePredicateImpl<>(JobDeviceManagementOperationAttributes.JOB_ID, jobDeviceManagementOperationCreator.getJobId()), - new AttributePredicateImpl<>(JobDeviceManagementOperationAttributes.DEVICE_MANAGEMENT_OPERATION_ID, jobDeviceManagementOperationCreator.getDeviceManagementOperationId()) + new AndPredicate( + new AttributePredicate<>(JobDeviceManagementOperationAttributes.JOB_ID, jobDeviceManagementOperationCreator.getJobId()), + new AttributePredicate<>(JobDeviceManagementOperationAttributes.DEVICE_MANAGEMENT_OPERATION_ID, jobDeviceManagementOperationCreator.getDeviceManagementOperationId()) ) ); @@ -92,7 +92,8 @@ public JobDeviceManagementOperation create(JobDeviceManagementOperationCreator j List> uniqueAttributes = new ArrayList<>(); uniqueAttributes.add(new AbstractMap.SimpleEntry<>(JobDeviceManagementOperationAttributes.JOB_ID, jobDeviceManagementOperationCreator.getJobId())); - uniqueAttributes.add(new AbstractMap.SimpleEntry<>(JobDeviceManagementOperationAttributes.DEVICE_MANAGEMENT_OPERATION_ID, jobDeviceManagementOperationCreator.getDeviceManagementOperationId())); + uniqueAttributes.add( + new AbstractMap.SimpleEntry<>(JobDeviceManagementOperationAttributes.DEVICE_MANAGEMENT_OPERATION_ID, jobDeviceManagementOperationCreator.getDeviceManagementOperationId())); throw new KapuaEntityUniquenessException(JobDeviceManagementOperation.TYPE, uniqueAttributes); } diff --git a/service/device/management/job/internal/src/main/java/org/eclipse/kapua/service/device/management/job/manager/internal/JobDeviceManagementOperationManagerServiceImpl.java b/service/device/management/job/internal/src/main/java/org/eclipse/kapua/service/device/management/job/manager/internal/JobDeviceManagementOperationManagerServiceImpl.java index aad30fefc6c..ea2a01fee65 100644 --- a/service/device/management/job/internal/src/main/java/org/eclipse/kapua/service/device/management/job/manager/internal/JobDeviceManagementOperationManagerServiceImpl.java +++ b/service/device/management/job/internal/src/main/java/org/eclipse/kapua/service/device/management/job/manager/internal/JobDeviceManagementOperationManagerServiceImpl.java @@ -12,17 +12,22 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.management.job.manager.internal; +import java.util.Date; + +import javax.inject.Inject; +import javax.inject.Singleton; + import org.eclipse.kapua.KapuaEntityNotFoundException; import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.job.engine.JobEngineFactory; import org.eclipse.kapua.job.engine.JobEngineService; import org.eclipse.kapua.job.engine.JobStartOptions; import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.model.query.KapuaQuery; import org.eclipse.kapua.service.device.management.job.JobDeviceManagementOperation; import org.eclipse.kapua.service.device.management.job.JobDeviceManagementOperationAttributes; import org.eclipse.kapua.service.device.management.job.JobDeviceManagementOperationFactory; import org.eclipse.kapua.service.device.management.job.JobDeviceManagementOperationListResult; -import org.eclipse.kapua.service.device.management.job.JobDeviceManagementOperationQuery; import org.eclipse.kapua.service.device.management.job.JobDeviceManagementOperationService; import org.eclipse.kapua.service.device.management.job.manager.JobDeviceManagementOperationManagerService; import org.eclipse.kapua.service.device.management.message.notification.NotifyStatus; @@ -34,16 +39,11 @@ import org.eclipse.kapua.service.job.targets.JobTargetAttributes; import org.eclipse.kapua.service.job.targets.JobTargetFactory; import org.eclipse.kapua.service.job.targets.JobTargetListResult; -import org.eclipse.kapua.service.job.targets.JobTargetQuery; import org.eclipse.kapua.service.job.targets.JobTargetService; import org.eclipse.kapua.service.job.targets.JobTargetStatus; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.inject.Inject; -import javax.inject.Singleton; -import java.util.Date; - /** * {@link JobDeviceManagementOperationManagerService} implementation. * @@ -100,7 +100,7 @@ public void processJobTargetOnNotification(KapuaId scopeId, KapuaId operationId, return; } - JobTargetQuery jobTargetQuery = jobTargetFactory.newQuery(scopeId); + KapuaQuery jobTargetQuery = new KapuaQuery(scopeId); jobTargetQuery.setPredicate( jobTargetQuery.andPredicate( jobTargetQuery.attributePredicate(JobTargetAttributes.JOB_ID, jobDeviceManagementOperation.getJobId()), @@ -118,20 +118,21 @@ public void processJobTargetOnNotification(KapuaId scopeId, KapuaId operationId, jobTarget = jobTargets.getFirstItem(); if (jobTarget == null) { - LOG.warn("JobTarget with targetId {} for Job {} not found! This is something strange that happened and needs some checking! Reference JobDeviceManagementOperation: {}", deviceManagementOperation.getDeviceId(), jobDeviceManagementOperation.getJobId(), jobDeviceManagementOperation.getId()); + LOG.warn("JobTarget with targetId {} for Job {} not found! This is something strange that happened and needs some checking! Reference JobDeviceManagementOperation: {}", + deviceManagementOperation.getDeviceId(), jobDeviceManagementOperation.getJobId(), jobDeviceManagementOperation.getId()); return; } switch (status) { - case COMPLETED: - jobTarget.setStatus(JobTargetStatus.NOTIFIED_COMPLETION); - break; - case FAILED: - jobTarget.setStatus(JobTargetStatus.PROCESS_FAILED); - break; - case STALE: - default: - break; + case COMPLETED: + jobTarget.setStatus(JobTargetStatus.NOTIFIED_COMPLETION); + break; + case FAILED: + jobTarget.setStatus(JobTargetStatus.PROCESS_FAILED); + break; + case STALE: + default: + break; } jobTargetService.update(jobTarget); @@ -166,14 +167,17 @@ public void processJobTargetOnNotification(KapuaId scopeId, KapuaId operationId, } /** - * This fixes the double {@link NotifyStatus#COMPLETED} {@link ManagementOperationNotification} set from Kura - * when performing a Device package download with the 'install' flag is set to {@code true}. + * This fixes the double {@link NotifyStatus#COMPLETED} {@link ManagementOperationNotification} set from Kura when performing a Device package download with the 'install' flag is set to + * {@code true}. *

    * If this is not the last {@link ManagementOperationNotification} the processing must stop. * - * @param deviceManagementOperation The current {@link DeviceManagementOperation} which the {@link ManagementOperationNotification} refers to. - * @param status The {@link ManagementOperationNotification} {@link NotifyStatus}. - * @param resource The {@link ManagementOperationNotification} resource. + * @param deviceManagementOperation + * The current {@link DeviceManagementOperation} which the {@link ManagementOperationNotification} refers to. + * @param status + * The {@link ManagementOperationNotification} {@link NotifyStatus}. + * @param resource + * The {@link ManagementOperationNotification} resource. * @return {@code true} if this is the last {@link ManagementOperationNotification} for the {@link DeviceManagementOperation}, {@code false} otherwise. * @since 1.1.0 */ @@ -199,18 +203,22 @@ private boolean checkLastNotification(DeviceManagementOperation deviceManagement /** * Gets the {@link JobDeviceManagementOperation} associated with the given {@link DeviceManagementOperation#getOperationId()}. * - * @param scopeId The scope {@link KapuaId} of the {@link JobDeviceManagementOperation}. - * @param operationId The {@link DeviceManagementOperation#getOperationId()} to match. + * @param scopeId + * The scope {@link KapuaId} of the {@link JobDeviceManagementOperation}. + * @param operationId + * The {@link DeviceManagementOperation#getOperationId()} to match. * @return The matched {@link JobDeviceManagementOperation} - * @throws KapuaEntityNotFoundException if there is no {@link JobDeviceManagementOperation} with the given {@code operationId}. - * @throws KapuaException If something goes bad. + * @throws KapuaEntityNotFoundException + * if there is no {@link JobDeviceManagementOperation} with the given {@code operationId}. + * @throws KapuaException + * If something goes bad. * @since 1.1.0 */ private JobDeviceManagementOperation getJobDeviceManagementOperation(KapuaId scopeId, KapuaId operationId) throws KapuaException { DeviceManagementOperation deviceManagementOperation = getDeviceManagementOperation(scopeId, operationId); - JobDeviceManagementOperationQuery query = jobDeviceManagementOperationFactory.newQuery(scopeId); + KapuaQuery query = new KapuaQuery(scopeId); query.setPredicate(query.attributePredicate(JobDeviceManagementOperationAttributes.DEVICE_MANAGEMENT_OPERATION_ID, deviceManagementOperation.getId())); JobDeviceManagementOperationListResult operations = jobDeviceManagementOperationService.query(query); @@ -223,15 +231,18 @@ private JobDeviceManagementOperation getJobDeviceManagementOperation(KapuaId sco return jobDeviceManagementOperation; } - /** * Gets the {@link DeviceManagementOperation} that matches the given {@code operationId}. * - * @param scopeId The scope {@link KapuaId} of the {@link DeviceManagementOperation}. - * @param operationId The {@link DeviceManagementOperation#getOperationId()} to match. + * @param scopeId + * The scope {@link KapuaId} of the {@link DeviceManagementOperation}. + * @param operationId + * The {@link DeviceManagementOperation#getOperationId()} to match. * @return The matched {@link DeviceManagementOperation}. - * @throws KapuaEntityNotFoundException if there is no {@link DeviceManagementOperation} with the given {@code operationId}. - * @throws KapuaException If something goes bad. + * @throws KapuaEntityNotFoundException + * if there is no {@link DeviceManagementOperation} with the given {@code operationId}. + * @throws KapuaException + * If something goes bad. * @since 1.1.0 */ private DeviceManagementOperation getDeviceManagementOperation(KapuaId scopeId, KapuaId operationId) throws KapuaException { diff --git a/service/device/management/job/internal/src/main/java/org/eclipse/kapua/service/device/management/job/scheduler/internal/JobDeviceManagementTriggerManagerServiceImpl.java b/service/device/management/job/internal/src/main/java/org/eclipse/kapua/service/device/management/job/scheduler/internal/JobDeviceManagementTriggerManagerServiceImpl.java index f2b1d51cdec..293205d1bf1 100644 --- a/service/device/management/job/internal/src/main/java/org/eclipse/kapua/service/device/management/job/scheduler/internal/JobDeviceManagementTriggerManagerServiceImpl.java +++ b/service/device/management/job/internal/src/main/java/org/eclipse/kapua/service/device/management/job/scheduler/internal/JobDeviceManagementTriggerManagerServiceImpl.java @@ -12,41 +12,40 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.management.job.scheduler.internal; +import java.util.Date; + +import javax.inject.Inject; +import javax.inject.Singleton; + import org.eclipse.kapua.KapuaEntityNotFoundException; import org.eclipse.kapua.commons.security.KapuaSecurityUtils; import org.eclipse.kapua.job.engine.JobEngineFactory; import org.eclipse.kapua.job.engine.JobEngineService; import org.eclipse.kapua.job.engine.JobStartOptions; import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.model.query.KapuaQuery; import org.eclipse.kapua.model.query.predicate.AttributePredicate; import org.eclipse.kapua.service.device.management.job.scheduler.manager.JobDeviceManagementTriggerManagerService; import org.eclipse.kapua.service.device.management.job.scheduler.manager.exception.ProcessOnConnectException; import org.eclipse.kapua.service.job.step.JobStepAttributes; import org.eclipse.kapua.service.job.step.JobStepFactory; -import org.eclipse.kapua.service.job.step.JobStepQuery; import org.eclipse.kapua.service.job.step.JobStepService; import org.eclipse.kapua.service.job.targets.JobTarget; import org.eclipse.kapua.service.job.targets.JobTargetAttributes; import org.eclipse.kapua.service.job.targets.JobTargetFactory; import org.eclipse.kapua.service.job.targets.JobTargetListResult; -import org.eclipse.kapua.service.job.targets.JobTargetQuery; import org.eclipse.kapua.service.job.targets.JobTargetService; import org.eclipse.kapua.service.job.targets.JobTargetStatus; import org.eclipse.kapua.service.scheduler.trigger.Trigger; import org.eclipse.kapua.service.scheduler.trigger.TriggerAttributes; import org.eclipse.kapua.service.scheduler.trigger.TriggerFactory; import org.eclipse.kapua.service.scheduler.trigger.TriggerListResult; -import org.eclipse.kapua.service.scheduler.trigger.TriggerQuery; import org.eclipse.kapua.service.scheduler.trigger.TriggerService; import org.eclipse.kapua.service.scheduler.trigger.definition.TriggerDefinition; import org.eclipse.kapua.service.scheduler.trigger.definition.TriggerDefinitionService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.inject.Inject; -import javax.inject.Singleton; -import java.util.Date; - /** * {@link JobDeviceManagementTriggerManagerService} implementation. * @@ -89,14 +88,13 @@ public JobDeviceManagementTriggerManagerServiceImpl( this.triggerFactory = triggerFactory; } - @Override public void processOnConnect(KapuaId scopeId, KapuaId deviceId) throws ProcessOnConnectException { Date now = new Date(); try { - JobTargetQuery jobTargetQuery = jobTargetFactory.newQuery(scopeId); + KapuaQuery jobTargetQuery = new KapuaQuery(scopeId); jobTargetQuery.setPredicate( jobTargetQuery.attributePredicate(JobTargetAttributes.JOB_TARGET_ID, deviceId) @@ -105,7 +103,7 @@ public void processOnConnect(KapuaId scopeId, KapuaId deviceId) throws ProcessOn JobTargetListResult jobTargetListResult = KapuaSecurityUtils.doPrivileged(() -> jobTargetService.query(jobTargetQuery)); for (JobTarget jt : jobTargetListResult.getItems()) { - JobStepQuery jobStepQuery = jobStepFactory.newQuery(jt.getScopeId()); + KapuaQuery jobStepQuery = new KapuaQuery(jt.getScopeId()); jobStepQuery.setPredicate( jobStepQuery.attributePredicate(JobStepAttributes.JOB_ID, jt.getJobId()) @@ -118,7 +116,7 @@ public void processOnConnect(KapuaId scopeId, KapuaId deviceId) throws ProcessOn continue; } - TriggerQuery triggerQuery = triggerFactory.newQuery(scopeId); + KapuaQuery triggerQuery = new KapuaQuery(scopeId); triggerQuery.setPredicate( triggerQuery.andPredicate( diff --git a/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/DeviceManagementOperationFactory.java b/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/DeviceManagementOperationFactory.java index bb1a7c27f9f..d42678c6005 100644 --- a/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/DeviceManagementOperationFactory.java +++ b/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/DeviceManagementOperationFactory.java @@ -20,7 +20,7 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface DeviceManagementOperationFactory extends KapuaEntityFactory { +public interface DeviceManagementOperationFactory extends KapuaEntityFactory { /** * Instantiates a new {@link DeviceManagementOperationProperty}. diff --git a/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/DeviceManagementOperationQuery.java b/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/DeviceManagementOperationQuery.java index fd82bbd6242..c82becf2fcf 100644 --- a/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/DeviceManagementOperationQuery.java +++ b/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/DeviceManagementOperationQuery.java @@ -12,13 +12,16 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.management.registry.operation; -import org.eclipse.kapua.model.query.KapuaQuery; - import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.model.query.KapuaQuery; +import org.eclipse.kapua.model.query.KapuaSortCriteria; +import org.eclipse.kapua.model.query.SortOrder; + /** * {@link DeviceManagementOperation} {@link KapuaQuery} definition. * @@ -27,6 +30,34 @@ */ @XmlRootElement(name = "query") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = DeviceManagementOperationXmlRegistry.class, factoryMethod = "newQuery") -public interface DeviceManagementOperationQuery extends KapuaQuery { +@XmlType +public class DeviceManagementOperationQuery extends KapuaQuery { + + /** + * Constructor. + * + * @since 1.1.0 + */ + private DeviceManagementOperationQuery() { + super(); + } + + /** + * Constructor. + * + * @param scopeId + * The {@link #getScopeId()}. + * @since 1.1.0 + */ + public DeviceManagementOperationQuery(KapuaId scopeId) { + this(); + + setScopeId(scopeId); + } + + @Override + public KapuaSortCriteria getDefaultSortCriteria() { + return fieldSortCriteria(DeviceManagementOperationAttributes.STARTED_ON, SortOrder.ASCENDING); + } + } diff --git a/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/DeviceManagementOperationXmlRegistry.java b/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/DeviceManagementOperationXmlRegistry.java index 827c836a9ac..dae33e20998 100644 --- a/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/DeviceManagementOperationXmlRegistry.java +++ b/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/DeviceManagementOperationXmlRegistry.java @@ -35,7 +35,4 @@ DeviceManagementOperationCreator newDeviceManagementOperationCreator() { return factory.newCreator(null); } - DeviceManagementOperationQuery newQuery() { - return factory.newQuery(null); - } } diff --git a/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/ManagementOperationNotificationFactory.java b/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/ManagementOperationNotificationFactory.java index 8e8a3761efb..46e1515076c 100644 --- a/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/ManagementOperationNotificationFactory.java +++ b/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/ManagementOperationNotificationFactory.java @@ -20,6 +20,6 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface ManagementOperationNotificationFactory extends KapuaEntityFactory { +public interface ManagementOperationNotificationFactory extends KapuaEntityFactory { } diff --git a/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/ManagementOperationNotificationQuery.java b/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/ManagementOperationNotificationQuery.java index 6c2c03930c4..c3d3520a710 100644 --- a/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/ManagementOperationNotificationQuery.java +++ b/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/ManagementOperationNotificationQuery.java @@ -12,13 +12,16 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.management.registry.operation.notification; -import org.eclipse.kapua.model.query.KapuaQuery; - import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.model.query.KapuaQuery; +import org.eclipse.kapua.model.query.KapuaSortCriteria; +import org.eclipse.kapua.model.query.SortOrder; + /** * {@link ManagementOperationNotification} {@link KapuaQuery} definition. * @@ -27,6 +30,33 @@ */ @XmlRootElement(name = "query") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = ManagementOperationNotificationXmlRegistry.class, factoryMethod = "newQuery") -public interface ManagementOperationNotificationQuery extends KapuaQuery { +@XmlType +public class ManagementOperationNotificationQuery extends KapuaQuery { + + /** + * Constructor. + * + * @since 1.0.0 + */ + private ManagementOperationNotificationQuery() { + super(); + } + + /** + * Constructor. + * + * @param scopeId + * The {@link #getScopeId()}. + * @since 1.0.0 + */ + public ManagementOperationNotificationQuery(KapuaId scopeId) { + this(); + + setScopeId(scopeId); + } + + @Override + public KapuaSortCriteria getDefaultSortCriteria() { + return fieldSortCriteria(ManagementOperationNotificationAttributes.SENT_ON, SortOrder.ASCENDING); + } } diff --git a/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/ManagementOperationNotificationXmlRegistry.java b/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/ManagementOperationNotificationXmlRegistry.java index f98b3685674..6e4b125a51a 100644 --- a/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/ManagementOperationNotificationXmlRegistry.java +++ b/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/ManagementOperationNotificationXmlRegistry.java @@ -34,7 +34,4 @@ ManagementOperationNotificationCreator newManagementOperationNotificationCreator return managementOperationNotificationFactory.newCreator(null); } - ManagementOperationNotificationQuery newQuery() { - return managementOperationNotificationFactory.newQuery(null); - } } diff --git a/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/manager/internal/DeviceManagementRegistryManagerServiceImpl.java b/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/manager/internal/DeviceManagementRegistryManagerServiceImpl.java index 4491da0e2fe..d8af6c324ae 100644 --- a/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/manager/internal/DeviceManagementRegistryManagerServiceImpl.java +++ b/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/manager/internal/DeviceManagementRegistryManagerServiceImpl.java @@ -12,7 +12,11 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.management.registry.manager.internal; -import com.google.common.base.Strings; +import java.util.Date; + +import javax.inject.Inject; +import javax.inject.Singleton; + import org.eclipse.kapua.KapuaEntityNotFoundException; import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.model.id.KapuaId; @@ -34,9 +38,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.inject.Inject; -import javax.inject.Singleton; -import java.util.Date; +import com.google.common.base.Strings; @Singleton public class DeviceManagementRegistryManagerServiceImpl implements DeviceManagementRegistryManagerService { @@ -60,7 +62,8 @@ public DeviceManagementRegistryManagerServiceImpl( } @Override - public void processOperationNotification(KapuaId scopeId, KapuaId operationId, Date updateOn, String resource, NotifyStatus status, Integer progress, String message) throws ManagementOperationNotificationProcessingException { + public void processOperationNotification(KapuaId scopeId, KapuaId operationId, Date updateOn, String resource, NotifyStatus status, Integer progress, String message) + throws ManagementOperationNotificationProcessingException { try { storeManagementNotification(scopeId, operationId, updateOn, status, resource, progress, message); @@ -76,7 +79,6 @@ public void processOperationNotification(KapuaId scopeId, KapuaId operationId, D } } - public void processFailedNotification(KapuaId scopeId, KapuaId operationId, Date updateOn, String resource, String message) throws KapuaException { closeDeviceManagementOperation(scopeId, operationId, updateOn, NotifyStatus.FAILED, message); } @@ -148,7 +150,7 @@ public void closeDeviceManagementOperation(KapuaId scopeId, KapuaId operationId, } while (failed); { - ManagementOperationNotificationQuery query = managementOperationNotificationFactory.newQuery(scopeId); + ManagementOperationNotificationQuery query = new ManagementOperationNotificationQuery(scopeId); query.setPredicate(query.attributePredicate(ManagementOperationNotificationAttributes.OPERATION_ID, deviceManagementOperation.getId())); query.setSortCriteria(query.fieldSortCriteria(ManagementOperationNotificationAttributes.SENT_ON, SortOrder.ASCENDING)); diff --git a/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/internal/DeviceManagementOperationFactoryImpl.java b/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/internal/DeviceManagementOperationFactoryImpl.java index d9a977b8528..ecd84b9f59a 100644 --- a/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/internal/DeviceManagementOperationFactoryImpl.java +++ b/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/internal/DeviceManagementOperationFactoryImpl.java @@ -20,7 +20,6 @@ import org.eclipse.kapua.service.device.management.registry.operation.DeviceManagementOperationCreator; import org.eclipse.kapua.service.device.management.registry.operation.DeviceManagementOperationFactory; import org.eclipse.kapua.service.device.management.registry.operation.DeviceManagementOperationProperty; -import org.eclipse.kapua.service.device.management.registry.operation.DeviceManagementOperationQuery; /** * {@link DeviceManagementOperationFactory} implementation @@ -40,11 +39,6 @@ public DeviceManagementOperationCreator newCreator(KapuaId scopeId) { return new DeviceManagementOperationCreatorImpl(scopeId); } - @Override - public DeviceManagementOperationQuery newQuery(KapuaId scopeId) { - return new DeviceManagementOperationQueryImpl(scopeId); - } - @Override public DeviceManagementOperationProperty newStepProperty(String name, String propertyType, String propertyValue) { return new DeviceManagementOperationPropertyImpl(name, propertyType, propertyValue); diff --git a/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/internal/DeviceManagementOperationQueryImpl.java b/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/internal/DeviceManagementOperationQueryImpl.java deleted file mode 100644 index cbc9aa3054d..00000000000 --- a/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/internal/DeviceManagementOperationQueryImpl.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017, 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.service.device.management.registry.operation.internal; - -import org.eclipse.kapua.commons.model.query.AbstractKapuaQuery; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.model.query.KapuaSortCriteria; -import org.eclipse.kapua.model.query.SortOrder; -import org.eclipse.kapua.service.device.management.registry.operation.DeviceManagementOperationAttributes; -import org.eclipse.kapua.service.device.management.registry.operation.DeviceManagementOperationQuery; - -/** - * {@link DeviceManagementOperationQuery} implementation. - * - * @since 1.1.0 - */ -public class DeviceManagementOperationQueryImpl extends AbstractKapuaQuery implements DeviceManagementOperationQuery { - - /** - * Constructor. - * - * @since 1.1.0 - */ - private DeviceManagementOperationQueryImpl() { - super(); - } - - /** - * Constructor. - * - * @param scopeId The {@link #getScopeId()}. - * @since 1.1.0 - */ - public DeviceManagementOperationQueryImpl(KapuaId scopeId) { - this(); - - setScopeId(scopeId); - } - - @Override - public KapuaSortCriteria getDefaultSortCriteria() { - return fieldSortCriteria(DeviceManagementOperationAttributes.STARTED_ON, SortOrder.ASCENDING); - } -} diff --git a/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/internal/ManagementOperationNotificationFactoryImpl.java b/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/internal/ManagementOperationNotificationFactoryImpl.java index 5140ad1768b..180b8ee32cc 100644 --- a/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/internal/ManagementOperationNotificationFactoryImpl.java +++ b/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/internal/ManagementOperationNotificationFactoryImpl.java @@ -18,7 +18,6 @@ import org.eclipse.kapua.service.device.management.registry.operation.notification.ManagementOperationNotification; import org.eclipse.kapua.service.device.management.registry.operation.notification.ManagementOperationNotificationCreator; import org.eclipse.kapua.service.device.management.registry.operation.notification.ManagementOperationNotificationFactory; -import org.eclipse.kapua.service.device.management.registry.operation.notification.ManagementOperationNotificationQuery; /** * {@link ManagementOperationNotificationFactory} implementation. @@ -38,11 +37,6 @@ public ManagementOperationNotificationCreator newCreator(KapuaId scopeId) { return new ManagementOperationNotificationCreatorImpl(scopeId); } - @Override - public ManagementOperationNotificationQuery newQuery(KapuaId scopeId) { - return new ManagementOperationNotificationQueryImpl(scopeId); - } - @Override public ManagementOperationNotification clone(ManagementOperationNotification managementOperationNotification) { return new ManagementOperationNotificationImpl(managementOperationNotification); diff --git a/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/internal/ManagementOperationNotificationQueryImpl.java b/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/internal/ManagementOperationNotificationQueryImpl.java deleted file mode 100644 index eb34a1c1bfb..00000000000 --- a/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/internal/ManagementOperationNotificationQueryImpl.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017, 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.service.device.management.registry.operation.notification.internal; - -import org.eclipse.kapua.commons.model.query.AbstractKapuaQuery; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.model.query.KapuaSortCriteria; -import org.eclipse.kapua.model.query.SortOrder; -import org.eclipse.kapua.service.device.management.registry.operation.notification.ManagementOperationNotificationAttributes; -import org.eclipse.kapua.service.device.management.registry.operation.notification.ManagementOperationNotificationQuery; - -/** - * {@link ManagementOperationNotificationQuery} implementation. - * - * @since 1.0.0 - */ -public class ManagementOperationNotificationQueryImpl extends AbstractKapuaQuery implements ManagementOperationNotificationQuery { - - /** - * Constructor. - * - * @since 1.0.0 - */ - private ManagementOperationNotificationQueryImpl() { - super(); - } - - /** - * Constructor. - * - * @param scopeId The {@link #getScopeId()}. - * @since 1.0.0 - */ - public ManagementOperationNotificationQueryImpl(KapuaId scopeId) { - this(); - - setScopeId(scopeId); - } - - @Override - public KapuaSortCriteria getDefaultSortCriteria() { - return fieldSortCriteria(ManagementOperationNotificationAttributes.SENT_ON, SortOrder.ASCENDING); - } -} diff --git a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/DeviceFactory.java b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/DeviceFactory.java index 6960844892b..a26482a45a9 100644 --- a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/DeviceFactory.java +++ b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/DeviceFactory.java @@ -21,7 +21,7 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface DeviceFactory extends KapuaEntityFactory { +public interface DeviceFactory extends KapuaEntityFactory { /** * Instantiates a new {@link DeviceCreator} diff --git a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/DeviceMatchPredicate.java b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/DeviceMatchPredicate.java index 7f2611aed25..33b23c9785d 100644 --- a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/DeviceMatchPredicate.java +++ b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/DeviceMatchPredicate.java @@ -12,8 +12,34 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.registry; -import org.eclipse.kapua.model.query.predicate.MatchPredicate; +import java.util.Arrays; -public interface DeviceMatchPredicate extends MatchPredicate { +import org.eclipse.kapua.model.query.predicate.AbstractMatchPredicate; +public class DeviceMatchPredicate extends AbstractMatchPredicate { + + /** + * Constructor. + * + * @param matchTerm + * @since 1.3.0 + */ + public DeviceMatchPredicate(T matchTerm) { + this.attributeNames = Arrays.asList( + DeviceAttributes.CLIENT_ID, + DeviceAttributes.DISPLAY_NAME, + DeviceAttributes.SERIAL_NUMBER, + DeviceAttributes.MODEL_ID, + DeviceAttributes.MODEL_NAME, + DeviceAttributes.BIOS_VERSION, + DeviceAttributes.FIRMWARE_VERSION, + DeviceAttributes.OS_VERSION, + DeviceAttributes.JVM_VERSION, + DeviceAttributes.OSGI_FRAMEWORK_VERSION, + DeviceAttributes.APPLICATION_FRAMEWORK_VERSION, + DeviceAttributes.CONNECTION_INTERFACE, + DeviceAttributes.CONNECTION_IP + ); + this.matchTerm = matchTerm; + } } diff --git a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/DeviceQuery.java b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/DeviceQuery.java index 69a0ed1f79c..8a7eff8c774 100644 --- a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/DeviceQuery.java +++ b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/DeviceQuery.java @@ -12,13 +12,16 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.registry; -import org.eclipse.kapua.model.query.KapuaQuery; - import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.model.query.KapuaQuery; +import org.eclipse.kapua.model.query.KapuaSortCriteria; +import org.eclipse.kapua.model.query.SortOrder; + /** * {@link Device} {@link KapuaQuery} definition. * @@ -27,16 +30,47 @@ */ @XmlRootElement(name = "query") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = DeviceXmlRegistry.class, factoryMethod = "newQuery") -public interface DeviceQuery extends KapuaQuery { +@XmlType +public class DeviceQuery extends KapuaQuery { + + /** + * Constructor. + * + * @since 1.0.0 + */ + private DeviceQuery() { + super(); + } + + /** + * Constructor. + * + * @param scopeId + * The {@link #getScopeId()}. + * @since 1.0.0 + */ + public DeviceQuery(KapuaId scopeId) { + this(); + setScopeId(scopeId); + } + + @Override + public KapuaSortCriteria getDefaultSortCriteria() { + return fieldSortCriteria(DeviceAttributes.CLIENT_ID, SortOrder.ASCENDING); + } /** * Instantiates a new {@link DeviceMatchPredicate}. * - * @param matchTerm The term to use to match. - * @param The type of the term + * @param matchTerm + * The term to use to match. + * @param + * The type of the term * @return The newly instantiated {@link DeviceMatchPredicate}. * @since 1.3.0 */ - DeviceMatchPredicate matchPredicate(T matchTerm); + public DeviceMatchPredicate matchPredicate(T matchTerm) { + return new DeviceMatchPredicate<>(matchTerm); + } + } diff --git a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/DeviceXmlRegistry.java b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/DeviceXmlRegistry.java index 36f44928f1d..e5b43d14d30 100644 --- a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/DeviceXmlRegistry.java +++ b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/DeviceXmlRegistry.java @@ -46,10 +46,6 @@ public DeviceCreator newDeviceCreator() { return deviceFactory.newCreator(null, null); } - public DeviceQuery newQuery() { - return deviceFactory.newQuery(null); - } - /** * Instantiates a new {@link DeviceExtendedProperty}. * diff --git a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/DeviceConnectionFactory.java b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/DeviceConnectionFactory.java index a19a31be804..260dd0cee25 100644 --- a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/DeviceConnectionFactory.java +++ b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/DeviceConnectionFactory.java @@ -20,6 +20,6 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface DeviceConnectionFactory extends KapuaEntityFactory { +public interface DeviceConnectionFactory extends KapuaEntityFactory { } diff --git a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/DeviceConnectionQuery.java b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/DeviceConnectionQuery.java index bed3e6c6c51..0f239d2effd 100644 --- a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/DeviceConnectionQuery.java +++ b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/DeviceConnectionQuery.java @@ -12,13 +12,17 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.registry.connection; -import org.eclipse.kapua.model.query.KapuaQuery; - import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.model.query.KapuaQuery; +import org.eclipse.kapua.model.query.KapuaSortCriteria; +import org.eclipse.kapua.model.query.SortOrder; +import org.eclipse.kapua.service.device.registry.DeviceAttributes; + /** * {@link DeviceConnection} {@link KapuaQuery} definition. * @@ -27,6 +31,32 @@ */ @XmlRootElement(name = "query") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = DeviceConnectionXmlRegistry.class, factoryMethod = "newQuery") -public interface DeviceConnectionQuery extends KapuaQuery { +@XmlType +public class DeviceConnectionQuery extends KapuaQuery { + + /** + * Constructor. + * + * @since 1.0.0 + */ + private DeviceConnectionQuery() { + super(); + } + + /** + * Constructor. + * + * @param scopeId + * The {@link #getScopeId()}. + * @since 1.0.0 + */ + public DeviceConnectionQuery(KapuaId scopeId) { + this(); + setScopeId(scopeId); + } + + @Override + public KapuaSortCriteria getDefaultSortCriteria() { + return fieldSortCriteria(DeviceAttributes.CLIENT_ID, SortOrder.ASCENDING); + } } diff --git a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/DeviceConnectionXmlRegistry.java b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/DeviceConnectionXmlRegistry.java index d9b01446c9f..903d35de1b5 100644 --- a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/DeviceConnectionXmlRegistry.java +++ b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/DeviceConnectionXmlRegistry.java @@ -35,7 +35,4 @@ public DeviceConnection newDeviceConnection() { return deviceConnectionFactory.newEntity(null); } - public DeviceConnectionQuery newQuery() { - return deviceConnectionFactory.newQuery(null); - } } diff --git a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/DeviceConnectionOptionFactory.java b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/DeviceConnectionOptionFactory.java index 2c5ee017b0a..1235da32793 100644 --- a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/DeviceConnectionOptionFactory.java +++ b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/DeviceConnectionOptionFactory.java @@ -20,6 +20,6 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface DeviceConnectionOptionFactory extends KapuaEntityFactory { +public interface DeviceConnectionOptionFactory extends KapuaEntityFactory { } diff --git a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/DeviceConnectionOptionQuery.java b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/DeviceConnectionOptionQuery.java deleted file mode 100644 index bae0cbe9cb8..00000000000 --- a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/DeviceConnectionOptionQuery.java +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - * 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.service.device.registry.connection.option; - -import org.eclipse.kapua.model.query.KapuaQuery; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - -/** - * {@link DeviceConnectionOption} {@link KapuaQuery} definition. - * - * @see KapuaQuery - * @since 1.0.0 - */ -@XmlRootElement(name = "query") -@XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = DeviceConnectionOptionXmlRegistry.class, factoryMethod = "newQuery") -public interface DeviceConnectionOptionQuery extends KapuaQuery { - -} diff --git a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/DeviceConnectionOptionXmlRegistry.java b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/DeviceConnectionOptionXmlRegistry.java index 39c5b6fbf7d..054217e2de3 100644 --- a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/DeviceConnectionOptionXmlRegistry.java +++ b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/DeviceConnectionOptionXmlRegistry.java @@ -34,8 +34,4 @@ public class DeviceConnectionOptionXmlRegistry { public DeviceConnectionOption newDeviceConnectionOption() { return deviceConnectionOptionFactory.newEntity(null); } - - public DeviceConnectionOptionQuery newQuery() { - return deviceConnectionOptionFactory.newQuery(null); - } } diff --git a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/event/DeviceEventFactory.java b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/event/DeviceEventFactory.java index 8ec7d44c5a8..77e03ff7784 100644 --- a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/event/DeviceEventFactory.java +++ b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/event/DeviceEventFactory.java @@ -23,7 +23,7 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface DeviceEventFactory extends KapuaEntityFactory { +public interface DeviceEventFactory extends KapuaEntityFactory { /** * Instantiates a new {@link DeviceEventCreator} diff --git a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/event/DeviceEventQuery.java b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/event/DeviceEventQuery.java index 3882d9c4392..9b0bd746300 100644 --- a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/event/DeviceEventQuery.java +++ b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/event/DeviceEventQuery.java @@ -12,13 +12,16 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.registry.event; -import org.eclipse.kapua.model.query.KapuaQuery; - import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.model.query.KapuaQuery; +import org.eclipse.kapua.model.query.KapuaSortCriteria; +import org.eclipse.kapua.model.query.SortOrder; + /** * {@link DeviceEvent} {@link KapuaQuery} definition. * @@ -27,6 +30,32 @@ */ @XmlRootElement(name = "query") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = DeviceEventXmlRegistry.class, factoryMethod = "newQuery") -public interface DeviceEventQuery extends KapuaQuery { +@XmlType +public class DeviceEventQuery extends KapuaQuery { + + /** + * Constructor. + * + * @since 1.0.0 + */ + private DeviceEventQuery() { + super(); + } + + /** + * Constructor. + * + * @param scopeId + * The {@link #getScopeId()}. + * @since 1.0.0 + */ + public DeviceEventQuery(KapuaId scopeId) { + this(); + setScopeId(scopeId); + } + + @Override + public KapuaSortCriteria getDefaultSortCriteria() { + return fieldSortCriteria(DeviceEventAttributes.RECEIVED_ON, SortOrder.DESCENDING); + } } diff --git a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/event/DeviceEventXmlRegistry.java b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/event/DeviceEventXmlRegistry.java index aff51f6f7ef..9e27e692688 100644 --- a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/event/DeviceEventXmlRegistry.java +++ b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/event/DeviceEventXmlRegistry.java @@ -35,7 +35,4 @@ public DeviceEvent newDeviceEvent() { return deviceEventFactory.newEntity(null); } - public DeviceEventQuery newQuery() { - return deviceEventFactory.newQuery(null); - } } diff --git a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/DeviceRegistryModule.java b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/DeviceRegistryModule.java index bd018a85761..2dab06adbf7 100644 --- a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/DeviceRegistryModule.java +++ b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/DeviceRegistryModule.java @@ -168,7 +168,6 @@ DeviceValidation deviceValidation(KapuaDeviceRegistrySettings deviceRegistrySett DeviceConnectionService deviceConnectionService, DeviceEventService deviceEventService, DeviceRepository deviceRepository, - DeviceFactory deviceFactory, TagService tagService) { return new DeviceValidationImpl(deviceRegistrySettings.getInt(KapuaDeviceRegistrySettingKeys.DEVICE_LIFECYCLE_BIRTH_VAR_FIELDS_LENGTH_MAX), deviceRegistrySettings.getInt(KapuaDeviceRegistrySettingKeys.DEVICE_LIFECYCLE_BIRTH_EXTENDED_PROPERTIES_LENGTH_MAX), @@ -178,7 +177,6 @@ DeviceValidation deviceValidation(KapuaDeviceRegistrySettings deviceRegistrySett deviceConnectionService, deviceEventService, deviceRepository, - deviceFactory, tagService); } diff --git a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/common/DeviceValidationImpl.java b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/common/DeviceValidationImpl.java index 0cf7699141c..f836e166894 100644 --- a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/common/DeviceValidationImpl.java +++ b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/common/DeviceValidationImpl.java @@ -13,7 +13,8 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.registry.common; -import com.google.common.base.Strings; +import java.util.List; + import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.commons.model.domains.Domains; import org.eclipse.kapua.commons.security.KapuaSecurityUtils; @@ -31,7 +32,6 @@ import org.eclipse.kapua.service.device.registry.Device; import org.eclipse.kapua.service.device.registry.DeviceCreator; import org.eclipse.kapua.service.device.registry.DeviceExtendedProperty; -import org.eclipse.kapua.service.device.registry.DeviceFactory; import org.eclipse.kapua.service.device.registry.DeviceListResult; import org.eclipse.kapua.service.device.registry.DeviceQuery; import org.eclipse.kapua.service.device.registry.DeviceRegistryService; @@ -43,7 +43,7 @@ import org.eclipse.kapua.service.user.User; import org.eclipse.kapua.storage.TxContext; -import java.util.List; +import com.google.common.base.Strings; /** * Logic used to validate preconditions required to execute the {@link DeviceRegistryServiceImpl} operations. @@ -60,7 +60,6 @@ public final class DeviceValidationImpl implements DeviceValidation { private final DeviceConnectionService deviceConnectionService; private final DeviceEventService deviceEventService; private final DeviceRepository deviceRepository; - private final DeviceFactory deviceFactory; private final TagService tagService; public DeviceValidationImpl( @@ -72,7 +71,6 @@ public DeviceValidationImpl( DeviceConnectionService deviceConnectionService, DeviceEventService deviceEventService, DeviceRepository deviceRepository, - DeviceFactory deviceFactory, TagService tagService) { this.birthFieldsClobMaxLength = birthFieldsClobMaxLength; this.birthFieldsExtendedPropertyValueMaxLength = birthFieldsExtendedPropertyValueMaxLength; @@ -82,17 +80,20 @@ public DeviceValidationImpl( this.deviceConnectionService = deviceConnectionService; this.deviceEventService = deviceEventService; this.deviceRepository = deviceRepository; - this.deviceFactory = deviceFactory; this.tagService = tagService; } /** * Validates the {@link DeviceCreator}. * - * @param deviceCreator The {@link DeviceCreator} to validate. - * @throws org.eclipse.kapua.KapuaIllegalArgumentException if one of the {@link DeviceCreator} fields is invalid. - * @throws org.eclipse.kapua.service.authorization.exception.SubjectUnauthorizedException if current {@link User} does not have sufficient {@link Permission}s - * @throws KapuaException if there are other errors. + * @param deviceCreator + * The {@link DeviceCreator} to validate. + * @throws org.eclipse.kapua.KapuaIllegalArgumentException + * if one of the {@link DeviceCreator} fields is invalid. + * @throws org.eclipse.kapua.service.authorization.exception.SubjectUnauthorizedException + * if current {@link User} does not have sufficient {@link Permission}s + * @throws KapuaException + * if there are other errors. * @since 1.0.0 */ @Override @@ -265,10 +266,14 @@ public void validateCreatePreconditions(DeviceCreator deviceCreator) throws Kapu /** * Validates the {@link Device} for {@link DeviceRegistryService#update(KapuaUpdatableEntity)} operation. * - * @param device The {@link Device} to validate. - * @throws org.eclipse.kapua.KapuaIllegalArgumentException if one of the {@link Device} fields is invalid. - * @throws org.eclipse.kapua.service.authorization.exception.SubjectUnauthorizedException if current {@link User} does not have sufficient {@link Permission}s - * @throws KapuaException if there are other errors. + * @param device + * The {@link Device} to validate. + * @throws org.eclipse.kapua.KapuaIllegalArgumentException + * if one of the {@link Device} fields is invalid. + * @throws org.eclipse.kapua.service.authorization.exception.SubjectUnauthorizedException + * if current {@link User} does not have sufficient {@link Permission}s + * @throws KapuaException + * if there are other errors. * @since 1.0.0 */ @Override @@ -455,11 +460,16 @@ public void validateUpdatePreconditions(TxContext txContext, Device device) thro /** * Validates the parameters for {@link DeviceRegistryService#find(KapuaId, KapuaId)} operation. * - * @param scopeId The {@link Device#getScopeId()} - * @param deviceId The {@link Device#getId()} - * @throws org.eclipse.kapua.KapuaIllegalArgumentException if one of the parameters is invalid. - * @throws org.eclipse.kapua.service.authorization.exception.SubjectUnauthorizedException if current {@link User} does not have sufficient {@link Permission}s - * @throws KapuaException if there are other errors. + * @param scopeId + * The {@link Device#getScopeId()} + * @param deviceId + * The {@link Device#getId()} + * @throws org.eclipse.kapua.KapuaIllegalArgumentException + * if one of the parameters is invalid. + * @throws org.eclipse.kapua.service.authorization.exception.SubjectUnauthorizedException + * if current {@link User} does not have sufficient {@link Permission}s + * @throws KapuaException + * if there are other errors. * @since 1.0.0 */ @Override @@ -475,10 +485,14 @@ public void validateFindPreconditions(TxContext txContext, KapuaId scopeId, Kapu /** * Validates the {@link KapuaQuery} for {@link DeviceRegistryService#query(KapuaQuery)} operation. * - * @param query The {@link KapuaQuery} to validate. - * @throws org.eclipse.kapua.KapuaIllegalArgumentException if one of the {@link KapuaQuery} fields is invalid. - * @throws org.eclipse.kapua.service.authorization.exception.SubjectUnauthorizedException if current {@link User} does not have sufficient {@link Permission}s - * @throws KapuaException if there are other errors. + * @param query + * The {@link KapuaQuery} to validate. + * @throws org.eclipse.kapua.KapuaIllegalArgumentException + * if one of the {@link KapuaQuery} fields is invalid. + * @throws org.eclipse.kapua.service.authorization.exception.SubjectUnauthorizedException + * if current {@link User} does not have sufficient {@link Permission}s + * @throws KapuaException + * if there are other errors. * @since 1.0.0 */ @Override @@ -500,10 +514,14 @@ public void validateQueryPreconditions(KapuaQuery query) throws KapuaException { /** * Validates the {@link KapuaQuery} for {@link DeviceRegistryService#count(KapuaQuery)} operation. * - * @param query The {@link KapuaQuery} to validate. - * @throws org.eclipse.kapua.KapuaIllegalArgumentException if one of the {@link KapuaQuery} fields is invalid. - * @throws org.eclipse.kapua.service.authorization.exception.SubjectUnauthorizedException if current {@link User} does not have sufficient {@link Permission}s - * @throws KapuaException if there are other errors. + * @param query + * The {@link KapuaQuery} to validate. + * @throws org.eclipse.kapua.KapuaIllegalArgumentException + * if one of the {@link KapuaQuery} fields is invalid. + * @throws org.eclipse.kapua.service.authorization.exception.SubjectUnauthorizedException + * if current {@link User} does not have sufficient {@link Permission}s + * @throws KapuaException + * if there are other errors. * @since 1.0.0 */ @Override @@ -517,11 +535,16 @@ public void validateCountPreconditions(KapuaQuery query) throws KapuaException { /** * Validates the parameters for {@link DeviceRegistryService#delete(KapuaId, KapuaId)} operation. * - * @param scopeId The {@link Device#getScopeId()} - * @param deviceId The {@link Device#getId()} - * @throws org.eclipse.kapua.KapuaIllegalArgumentException if one of the parameters is invalid. - * @throws org.eclipse.kapua.service.authorization.exception.SubjectUnauthorizedException if current {@link User} does not have sufficient {@link Permission}s - * @throws KapuaException if there are other errors. + * @param scopeId + * The {@link Device#getScopeId()} + * @param deviceId + * The {@link Device#getId()} + * @throws org.eclipse.kapua.KapuaIllegalArgumentException + * if one of the parameters is invalid. + * @throws org.eclipse.kapua.service.authorization.exception.SubjectUnauthorizedException + * if current {@link User} does not have sufficient {@link Permission}s + * @throws KapuaException + * if there are other errors. * @since 1.0.0 */ @Override @@ -537,11 +560,16 @@ public void validateDeletePreconditions(TxContext txContext, KapuaId scopeId, Ka /** * Validates the parameters for {@link DeviceRegistryService#findByClientId(KapuaId, String)} operation. * - * @param scopeId The {@link Device#getScopeId()} - * @param clientId The {@link Device#getClientId()} - * @throws org.eclipse.kapua.KapuaIllegalArgumentException if one of the parameters is invalid. - * @throws org.eclipse.kapua.service.authorization.exception.SubjectUnauthorizedException if current {@link User} does not have sufficient {@link Permission}s - * @throws KapuaException if there are other errors. + * @param scopeId + * The {@link Device#getScopeId()} + * @param clientId + * The {@link Device#getClientId()} + * @throws org.eclipse.kapua.KapuaIllegalArgumentException + * if one of the parameters is invalid. + * @throws org.eclipse.kapua.service.authorization.exception.SubjectUnauthorizedException + * if current {@link User} does not have sufficient {@link Permission}s + * @throws KapuaException + * if there are other errors. * @since 1.0.0 */ @Override @@ -555,14 +583,17 @@ public void validateFindByClientIdPreconditions(KapuaId scopeId, String clientId /** * Finds the current {@link Group} id assigned to the given {@link Device#getId()}. * - * @param scopeId The {@link Device#getScopeId()} - * @param entityId The {@link Device#getId()} + * @param scopeId + * The {@link Device#getScopeId()} + * @param entityId + * The {@link Device#getId()} * @return The {@link Group} id found. - * @throws KapuaException if any error occurs while looking for the Group. + * @throws KapuaException + * if any error occurs while looking for the Group. * @since 1.0.0 */ private KapuaId findCurrentGroupId(TxContext tx, KapuaId scopeId, KapuaId entityId) throws KapuaException { - DeviceQuery query = deviceFactory.newQuery(scopeId); + DeviceQuery query = new DeviceQuery(scopeId); query.setPredicate(query.attributePredicate(KapuaEntityAttributes.ENTITY_ID, entityId)); DeviceListResult results; diff --git a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/internal/DeviceConnectionFactoryImpl.java b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/internal/DeviceConnectionFactoryImpl.java index d1c1f083156..734022e1f10 100644 --- a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/internal/DeviceConnectionFactoryImpl.java +++ b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/internal/DeviceConnectionFactoryImpl.java @@ -19,7 +19,6 @@ import org.eclipse.kapua.service.device.registry.connection.DeviceConnection; import org.eclipse.kapua.service.device.registry.connection.DeviceConnectionCreator; import org.eclipse.kapua.service.device.registry.connection.DeviceConnectionFactory; -import org.eclipse.kapua.service.device.registry.connection.DeviceConnectionQuery; /** * {@link DeviceConnectionFactory} implementation. @@ -34,11 +33,6 @@ public DeviceConnectionCreator newCreator(KapuaId scopeId) { return new DeviceConnectionCreatorImpl(scopeId); } - @Override - public DeviceConnectionQuery newQuery(KapuaId scopeId) { - return new DeviceConnectionQueryImpl(scopeId); - } - @Override public DeviceConnection newEntity(KapuaId scopeId) { return new DeviceConnectionImpl(scopeId); diff --git a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/internal/DeviceConnectionImplJpaRepository.java b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/internal/DeviceConnectionImplJpaRepository.java index 2dd44dedb61..8af1a2ae703 100644 --- a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/internal/DeviceConnectionImplJpaRepository.java +++ b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/internal/DeviceConnectionImplJpaRepository.java @@ -16,6 +16,7 @@ import org.eclipse.kapua.commons.jpa.KapuaJpaRepositoryConfiguration; import org.eclipse.kapua.commons.jpa.KapuaUpdatableEntityJpaRepository; import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.model.query.KapuaQuery; import org.eclipse.kapua.service.device.registry.connection.DeviceConnection; import org.eclipse.kapua.service.device.registry.connection.DeviceConnectionAttributes; import org.eclipse.kapua.service.device.registry.connection.DeviceConnectionListResult; @@ -33,7 +34,7 @@ public DeviceConnectionImplJpaRepository(KapuaJpaRepositoryConfiguration jpaRepo @Override public long countByClientId(TxContext tx, KapuaId scopeId, String clientId) throws KapuaException { - final DeviceConnectionQuery query = new DeviceConnectionQueryImpl(scopeId); + final KapuaQuery query = new DeviceConnectionQuery(scopeId); query.setPredicate(query.attributePredicate(DeviceConnectionAttributes.CLIENT_ID, clientId)); return this.count(tx, query); } diff --git a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/internal/DeviceConnectionQueryImpl.java b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/internal/DeviceConnectionQueryImpl.java deleted file mode 100644 index 2cbbd225ee1..00000000000 --- a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/internal/DeviceConnectionQueryImpl.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * 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.service.device.registry.connection.internal; - -import org.eclipse.kapua.commons.model.query.AbstractKapuaQuery; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.model.query.KapuaSortCriteria; -import org.eclipse.kapua.model.query.SortOrder; -import org.eclipse.kapua.service.device.registry.DeviceAttributes; -import org.eclipse.kapua.service.device.registry.connection.DeviceConnectionQuery; - -/** - * {@link DeviceConnectionQuery} implementation. - * - * @since 1.0.0 - */ -public class DeviceConnectionQueryImpl extends AbstractKapuaQuery implements DeviceConnectionQuery { - - /** - * Constructor. - * - * @since 1.0.0 - */ - private DeviceConnectionQueryImpl() { - super(); - } - - /** - * Constructor. - * - * @param scopeId The {@link #getScopeId()}. - * @since 1.0.0 - */ - public DeviceConnectionQueryImpl(KapuaId scopeId) { - this(); - setScopeId(scopeId); - } - - @Override - public KapuaSortCriteria getDefaultSortCriteria() { - return fieldSortCriteria(DeviceAttributes.CLIENT_ID, SortOrder.ASCENDING); - } -} diff --git a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/internal/DeviceConnectionServiceImpl.java b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/internal/DeviceConnectionServiceImpl.java index a1c5744bae6..3b30d5994e1 100644 --- a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/internal/DeviceConnectionServiceImpl.java +++ b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/internal/DeviceConnectionServiceImpl.java @@ -12,6 +12,13 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.registry.connection.internal; +import java.util.Map; +import java.util.Set; + +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; + import org.apache.commons.lang.NotImplementedException; import org.eclipse.kapua.KapuaDuplicateNameException; import org.eclipse.kapua.KapuaEntityNotFoundException; @@ -43,12 +50,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; -import java.util.Map; -import java.util.Set; - /** * {@link DeviceConnectionService} implementation. * @@ -67,7 +68,8 @@ public class DeviceConnectionServiceImpl extends KapuaConfigurableServiceBase im /** * Constructor. * - * @param serviceConfigurationManager The {@link ServiceConfigurationManager} instance. + * @param serviceConfigurationManager + * The {@link ServiceConfigurationManager} instance. * @since 2.0.0 */ @Inject @@ -172,7 +174,7 @@ public DeviceConnection findByClientId(KapuaId scopeId, String clientId) ArgumentValidator.notEmptyOrNull(clientId, "clientId"); // Build query - DeviceConnectionQueryImpl query = new DeviceConnectionQueryImpl(scopeId); + DeviceConnectionQuery query = new DeviceConnectionQuery(scopeId); query.setPredicate(query.attributePredicate(DeviceConnectionAttributes.CLIENT_ID, clientId)); // Do find @@ -267,7 +269,7 @@ public void onKapuaEvent(ServiceEvent kapuaEvent) throws KapuaException { // Private methods private void deleteConnectionByAccountId(KapuaId scopeId, KapuaId accountId) throws KapuaException { - DeviceConnectionQuery query = entityFactory.newQuery(accountId); + DeviceConnectionQuery query = new DeviceConnectionQuery(accountId); txManager.execute(tx -> { final DeviceConnectionListResult deviceConnectionsToDelete = repository.query(tx, query); diff --git a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/internal/DeviceConnectionOptionFactoryImpl.java b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/internal/DeviceConnectionOptionFactoryImpl.java index fb9249787ad..fb02d6595dd 100644 --- a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/internal/DeviceConnectionOptionFactoryImpl.java +++ b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/internal/DeviceConnectionOptionFactoryImpl.java @@ -19,7 +19,6 @@ import org.eclipse.kapua.service.device.registry.connection.option.DeviceConnectionOption; import org.eclipse.kapua.service.device.registry.connection.option.DeviceConnectionOptionCreator; import org.eclipse.kapua.service.device.registry.connection.option.DeviceConnectionOptionFactory; -import org.eclipse.kapua.service.device.registry.connection.option.DeviceConnectionOptionQuery; /** * {@link DeviceConnectionOptionFactory} implementation. @@ -34,11 +33,6 @@ public DeviceConnectionOptionCreator newCreator(KapuaId scopeId) { return new DeviceConnectionOptionCreatorImpl(scopeId); } - @Override - public DeviceConnectionOptionQuery newQuery(KapuaId scopeId) { - return new DeviceConnectionOptionQueryImpl(scopeId); - } - @Override public DeviceConnectionOption newEntity(KapuaId scopeId) { return new DeviceConnectionOptionImpl(scopeId); diff --git a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/internal/DeviceConnectionOptionQueryImpl.java b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/internal/DeviceConnectionOptionQueryImpl.java deleted file mode 100644 index fd4ca1102d1..00000000000 --- a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/internal/DeviceConnectionOptionQueryImpl.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * 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.service.device.registry.connection.option.internal; - -import org.eclipse.kapua.commons.model.query.AbstractKapuaQuery; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.service.device.registry.connection.option.DeviceConnectionOptionQuery; - -/** - * {@link DeviceConnectionOptionQuery} implementation. - * - * @since 1.0.0 - */ -public class DeviceConnectionOptionQueryImpl extends AbstractKapuaQuery implements DeviceConnectionOptionQuery { - - /** - * Constructor. - * - * @since 1.0.0 - */ - private DeviceConnectionOptionQueryImpl() { - super(); - } - - /** - * Constructor. - * - * @param scopeId The {@link #getScopeId()}. - * @since 1.0.0 - */ - public DeviceConnectionOptionQueryImpl(KapuaId scopeId) { - this(); - setScopeId(scopeId); - } -} diff --git a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/internal/DeviceConnectionOptionServiceImpl.java b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/internal/DeviceConnectionOptionServiceImpl.java index b3a15a5c37e..0cbaa1e382c 100644 --- a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/internal/DeviceConnectionOptionServiceImpl.java +++ b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/internal/DeviceConnectionOptionServiceImpl.java @@ -12,6 +12,11 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.registry.connection.option.internal; +import java.util.Map; + +import javax.inject.Inject; +import javax.inject.Singleton; + import org.eclipse.kapua.KapuaEntityNotFoundException; import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.KapuaIllegalArgumentException; @@ -29,7 +34,6 @@ import org.eclipse.kapua.service.device.authentication.api.DeviceConnectionCredentialAdapter; import org.eclipse.kapua.service.device.registry.connection.DeviceConnectionAttributes; import org.eclipse.kapua.service.device.registry.connection.DeviceConnectionFactory; -import org.eclipse.kapua.service.device.registry.connection.DeviceConnectionQuery; import org.eclipse.kapua.service.device.registry.connection.DeviceConnectionRepository; import org.eclipse.kapua.service.device.registry.connection.option.DeviceConnectionOption; import org.eclipse.kapua.service.device.registry.connection.option.DeviceConnectionOptionCreator; @@ -39,13 +43,8 @@ import org.eclipse.kapua.service.device.registry.connection.option.UserAlreadyReservedException; import org.eclipse.kapua.storage.TxManager; -import javax.inject.Inject; -import javax.inject.Singleton; -import java.util.Map; - /** - * DeviceConnectionService exposes APIs to retrieve Device connections under a scope. - * It includes APIs to find, list, and update devices connections associated with a scope. + * DeviceConnectionService exposes APIs to retrieve Device connections under a scope. It includes APIs to find, list, and update devices connections associated with a scope. * * @since 1.0 */ @@ -98,7 +97,7 @@ public DeviceConnectionOption update(DeviceConnectionOption deviceConnectionOpti authorizationService.checkPermission(permissionFactory.newPermission(Domains.DEVICE_CONNECTION, Actions.write, deviceConnectionOptions.getScopeId())); return txManager.execute(tx -> { if (deviceConnectionOptions.getReservedUserId() != null) { - DeviceConnectionQuery query = entityFactory.newQuery(deviceConnectionOptions.getScopeId()); + final KapuaQuery query = new KapuaQuery(deviceConnectionOptions.getScopeId()); AndPredicate deviceAndPredicate = query.andPredicate( query.attributePredicate(DeviceConnectionAttributes.RESERVED_USER_ID, deviceConnectionOptions.getReservedUserId()), diff --git a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/event/internal/DeviceEventFactoryImpl.java b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/event/internal/DeviceEventFactoryImpl.java index 1011a7d50f4..0d7df1645b7 100644 --- a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/event/internal/DeviceEventFactoryImpl.java +++ b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/event/internal/DeviceEventFactoryImpl.java @@ -21,7 +21,6 @@ import org.eclipse.kapua.service.device.registry.event.DeviceEvent; import org.eclipse.kapua.service.device.registry.event.DeviceEventCreator; import org.eclipse.kapua.service.device.registry.event.DeviceEventFactory; -import org.eclipse.kapua.service.device.registry.event.DeviceEventQuery; /** * {@link DeviceEventFactory} implementation. @@ -43,11 +42,6 @@ public DeviceEventCreator newCreator(KapuaId scopeId, KapuaId deviceId, Date rec return creator; } - @Override - public DeviceEventQuery newQuery(KapuaId scopeId) { - return new DeviceEventQueryImpl(scopeId); - } - @Override public DeviceEvent newEntity(KapuaId scopeId) { return new DeviceEventImpl(scopeId); diff --git a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/event/internal/DeviceEventQueryImpl.java b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/event/internal/DeviceEventQueryImpl.java deleted file mode 100644 index a4b95d55674..00000000000 --- a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/event/internal/DeviceEventQueryImpl.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * 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.service.device.registry.event.internal; - -import org.eclipse.kapua.commons.model.query.AbstractKapuaQuery; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.model.query.KapuaSortCriteria; -import org.eclipse.kapua.model.query.SortOrder; -import org.eclipse.kapua.service.device.registry.event.DeviceEventAttributes; -import org.eclipse.kapua.service.device.registry.event.DeviceEventQuery; - -/** - * {@link DeviceEventQuery} implementation. - * - * @since 1.0.0 - */ -public class DeviceEventQueryImpl extends AbstractKapuaQuery implements DeviceEventQuery { - - /** - * Constructor. - * - * @since 1.0.0 - */ - private DeviceEventQueryImpl() { - super(); - } - - /** - * Constructor. - * - * @param scopeId The {@link #getScopeId()}. - * @since 1.0.0 - */ - public DeviceEventQueryImpl(KapuaId scopeId) { - this(); - setScopeId(scopeId); - } - - @Override - public KapuaSortCriteria getDefaultSortCriteria() { - return fieldSortCriteria(DeviceEventAttributes.RECEIVED_ON, SortOrder.DESCENDING); - } -} diff --git a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/internal/DeviceFactoryImpl.java b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/internal/DeviceFactoryImpl.java index b4483e0f333..31eabc7398c 100644 --- a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/internal/DeviceFactoryImpl.java +++ b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/internal/DeviceFactoryImpl.java @@ -20,7 +20,6 @@ import org.eclipse.kapua.service.device.registry.DeviceCreator; import org.eclipse.kapua.service.device.registry.DeviceExtendedProperty; import org.eclipse.kapua.service.device.registry.DeviceFactory; -import org.eclipse.kapua.service.device.registry.DeviceQuery; /** * {@link DeviceFactory} implementation. @@ -37,11 +36,6 @@ public DeviceCreator newCreator(KapuaId scopeId, String clientId) { return deviceCreator; } - @Override - public DeviceQuery newQuery(KapuaId scopeId) { - return new DeviceQueryImpl(scopeId); - } - @Override public Device newEntity(KapuaId scopeId) { return new DeviceImpl(scopeId); diff --git a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/internal/DeviceImplJpaRepository.java b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/internal/DeviceImplJpaRepository.java index 503a877deb1..ef67ed8483b 100644 --- a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/internal/DeviceImplJpaRepository.java +++ b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/internal/DeviceImplJpaRepository.java @@ -25,6 +25,7 @@ import org.eclipse.kapua.service.device.registry.Device; import org.eclipse.kapua.service.device.registry.DeviceAttributes; import org.eclipse.kapua.service.device.registry.DeviceListResult; +import org.eclipse.kapua.service.device.registry.DeviceQuery; import org.eclipse.kapua.service.device.registry.DeviceRepository; import org.eclipse.kapua.storage.TxContext; @@ -40,7 +41,7 @@ public DeviceImplJpaRepository(KapuaJpaRepositoryConfiguration jpaRepoConfig) { @Override public Optional findByClientId(TxContext tx, KapuaId scopeId, String clientId) throws KapuaException { - DeviceQueryImpl query = new DeviceQueryImpl(scopeId); + DeviceQuery query = new DeviceQuery(scopeId); query.setPredicate(query.attributePredicate(DeviceAttributes.CLIENT_ID, clientId)); query.setFetchAttributes(Lists.newArrayList(DeviceAttributes.CONNECTION, DeviceAttributes.LAST_EVENT)); return Optional.ofNullable(this.query(tx, query).getFirstItem()); diff --git a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/internal/DeviceMatchPredicateImpl.java b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/internal/DeviceMatchPredicateImpl.java deleted file mode 100644 index 6d3d69ee361..00000000000 --- a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/internal/DeviceMatchPredicateImpl.java +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2020, 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.service.device.registry.internal; - -import java.util.Arrays; - -import org.eclipse.kapua.commons.model.query.predicate.AbstractMatchPredicate; -import org.eclipse.kapua.service.device.registry.DeviceAttributes; -import org.eclipse.kapua.service.device.registry.DeviceMatchPredicate; - -public class DeviceMatchPredicateImpl extends AbstractMatchPredicate implements DeviceMatchPredicate { - - /** - * Constructor. - * - * @param matchTerm - * @since 1.3.0 - */ - public DeviceMatchPredicateImpl(T matchTerm) { - this.attributeNames = Arrays.asList( - DeviceAttributes.CLIENT_ID, - DeviceAttributes.DISPLAY_NAME, - DeviceAttributes.SERIAL_NUMBER, - DeviceAttributes.MODEL_ID, - DeviceAttributes.MODEL_NAME, - DeviceAttributes.BIOS_VERSION, - DeviceAttributes.FIRMWARE_VERSION, - DeviceAttributes.OS_VERSION, - DeviceAttributes.JVM_VERSION, - DeviceAttributes.OSGI_FRAMEWORK_VERSION, - DeviceAttributes.APPLICATION_FRAMEWORK_VERSION, - DeviceAttributes.CONNECTION_INTERFACE, - DeviceAttributes.CONNECTION_IP - ); - this.matchTerm = matchTerm; - } - -} diff --git a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/internal/DeviceQueryImpl.java b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/internal/DeviceQueryImpl.java deleted file mode 100644 index d1695ccb916..00000000000 --- a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/internal/DeviceQueryImpl.java +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************* - * 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.service.device.registry.internal; - -import org.eclipse.kapua.commons.model.query.AbstractKapuaQuery; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.model.query.KapuaSortCriteria; -import org.eclipse.kapua.model.query.SortOrder; -import org.eclipse.kapua.service.device.registry.DeviceAttributes; -import org.eclipse.kapua.service.device.registry.DeviceQuery; - -/** - * {@link DeviceQuery} implementation. - * - * @since 1.0.0 - */ -public class DeviceQueryImpl extends AbstractKapuaQuery implements DeviceQuery { - - /** - * Constructor. - * - * @since 1.0.0 - */ - private DeviceQueryImpl() { - super(); - } - - /** - * Constructor. - * - * @param scopeId The {@link #getScopeId()}. - * @since 1.0.0 - */ - public DeviceQueryImpl(KapuaId scopeId) { - this(); - setScopeId(scopeId); - } - - @Override - public KapuaSortCriteria getDefaultSortCriteria() { - return fieldSortCriteria(DeviceAttributes.CLIENT_ID, SortOrder.ASCENDING); - } - - @Override - public DeviceMatchPredicateImpl matchPredicate(T matchTerm) { - return new DeviceMatchPredicateImpl<>(matchTerm); - } - -} diff --git a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/internal/DeviceRegistryServiceImpl.java b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/internal/DeviceRegistryServiceImpl.java index 1020ecaed77..1c0c5ce75be 100644 --- a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/internal/DeviceRegistryServiceImpl.java +++ b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/internal/DeviceRegistryServiceImpl.java @@ -12,6 +12,10 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.registry.internal; +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; + import org.eclipse.kapua.KapuaDuplicateNameException; import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.commons.configuration.KapuaConfigurableServiceBase; @@ -37,10 +41,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; - /** * {@link DeviceRegistryService} implementation. * @@ -85,7 +85,7 @@ public Device create(DeviceCreator deviceCreator) // Check entity limit serviceConfigurationManager.checkAllowedEntities(tx, deviceCreator.getScopeId(), "Devices"); // Check duplicate clientId - DeviceQuery query = entityFactory.newQuery(deviceCreator.getScopeId()); + DeviceQuery query = new DeviceQuery(deviceCreator.getScopeId()); query.setPredicate(query.attributePredicate(DeviceAttributes.CLIENT_ID, deviceCreator.getClientId())); //TODO: check whether this is anywhere efficient if (deviceRepository.count(tx, query) > 0) { @@ -210,7 +210,7 @@ public void onKapuaEvent(ServiceEvent kapuaEvent) throws KapuaException { // Private methods private void deleteDeviceByGroupId(KapuaId scopeId, KapuaId groupId) throws KapuaException { - DeviceQuery query = entityFactory.newQuery(scopeId); + DeviceQuery query = new DeviceQuery(scopeId); query.setPredicate(query.attributePredicate(DeviceAttributes.GROUP_ID, groupId)); txManager.execute(tx -> { @@ -225,7 +225,7 @@ private void deleteDeviceByGroupId(KapuaId scopeId, KapuaId groupId) throws Kapu } private void deleteDeviceByAccountId(KapuaId scopeId, KapuaId accountId) throws KapuaException { - DeviceQuery query = entityFactory.newQuery(accountId); + DeviceQuery query = new DeviceQuery(accountId); txManager.execute(tx -> { DeviceListResult devicesToDelete = deviceRepository.query(tx, query); diff --git a/service/device/registry/test-steps/src/main/java/org/eclipse/kapua/service/device/registry/steps/DeviceRegistrySteps.java b/service/device/registry/test-steps/src/main/java/org/eclipse/kapua/service/device/registry/steps/DeviceRegistrySteps.java index 0f70b334561..ed59d9a3b03 100644 --- a/service/device/registry/test-steps/src/main/java/org/eclipse/kapua/service/device/registry/steps/DeviceRegistrySteps.java +++ b/service/device/registry/test-steps/src/main/java/org/eclipse/kapua/service/device/registry/steps/DeviceRegistrySteps.java @@ -467,13 +467,13 @@ public void setDeviceIdToNull() { @Given("A regular query") public void createRegularQuery() { - DeviceQuery query = deviceFactory.newQuery(getCurrentScopeId()); + DeviceQuery query = new DeviceQuery(getCurrentScopeId()); stepData.put(DEVICE_QUERY, query); } @Given("A query with a null Scope ID") public void createQueryWithNullScopeId() { - DeviceQuery query = deviceFactory.newQuery(null); + DeviceQuery query = new DeviceQuery(null); stepData.put(DEVICE_QUERY, query); } @@ -638,7 +638,7 @@ public void queryForDevices() throws Exception { @When("I query for devices with BIOS version {string}") public void queryForDevicesBasedOnBiosVersion(String version) throws Exception { - DeviceQuery tmpQuery = deviceFactory.newQuery(getCurrentScopeId()); + DeviceQuery tmpQuery = new DeviceQuery(getCurrentScopeId()); // Search for the known bios version string tmpQuery.setPredicate(tmpQuery.attributePredicate(DeviceAttributes.BIOS_VERSION, version, AttributePredicate.Operator.EQUAL)); primeException(); @@ -653,7 +653,7 @@ public void queryForDevicesBasedOnBiosVersion(String version) throws Exception { @When("I query for devices with BIOS different from {string}") public void queryForDevicesWithDifferentBiosVersion(String version) throws Exception { - DeviceQuery tmpQuery = deviceFactory.newQuery(getCurrentScopeId()); + DeviceQuery tmpQuery = new DeviceQuery(getCurrentScopeId()); // Search for the known bios version string tmpQuery.setPredicate(tmpQuery.attributePredicate(DeviceAttributes.BIOS_VERSION, version, AttributePredicate.Operator.EQUAL)); primeException(); @@ -668,7 +668,7 @@ public void queryForDevicesWithDifferentBiosVersion(String version) throws Excep @When("I query for devices with Client Id {string}") public void queryForDevicesBasedOnClientId(String id) throws Exception { - DeviceQuery tmpQuery = deviceFactory.newQuery(getCurrentScopeId()); + DeviceQuery tmpQuery = new DeviceQuery(getCurrentScopeId()); // Search for the known bios version string tmpQuery.setPredicate(tmpQuery.attributePredicate(DeviceAttributes.CLIENT_ID, id, AttributePredicate.Operator.EQUAL)); primeException(); @@ -696,12 +696,12 @@ public void countForDevices() throws Exception { @When("I count the devices in scope {int}") public void countDevicesInScope(int scope) throws Exception { - updateCount(() -> (int) deviceRegistryService.count(deviceFactory.newQuery(getKapuaId(scope)))); + updateCount(() -> (int) deviceRegistryService.count(new DeviceQuery(getKapuaId(scope)))); } @When("I count devices with BIOS version {string}") public void countDevicesWithBIOSVersion(String version) throws Exception { - DeviceQuery tmpQuery = deviceFactory.newQuery(getCurrentScopeId()); + DeviceQuery tmpQuery = new DeviceQuery(getCurrentScopeId()); tmpQuery.setPredicate(tmpQuery.attributePredicate(DeviceAttributes.BIOS_VERSION, version, AttributePredicate.Operator.EQUAL)); updateCount(() -> (int) deviceRegistryService.count(tmpQuery)); } @@ -761,7 +761,7 @@ public void deleteDeviceWithRememberedId() throws Exception { public void deleteDeviceWithClientId(String clientId) throws Exception { try { primeException(); - DeviceQuery tmpQuery = deviceFactory.newQuery(getCurrentScopeId()); + DeviceQuery tmpQuery = new DeviceQuery(getCurrentScopeId()); tmpQuery.setPredicate(tmpQuery.attributePredicate(DeviceAttributes.CLIENT_ID, clientId, AttributePredicate.Operator.EQUAL)); DeviceListResult deviceList = deviceRegistryService.query(tmpQuery); Device device = deviceList.getFirstItem(); @@ -1002,7 +1002,7 @@ public void exerciseAllDeviceFactoryFunctions() { DeviceListResult tmpListRes; tmpDevice = deviceFactory.newEntity(SYS_SCOPE_ID); tmpCreator = deviceFactory.newCreator(SYS_SCOPE_ID); - tmpQuery = deviceFactory.newQuery(SYS_SCOPE_ID); + tmpQuery = new DeviceQuery(SYS_SCOPE_ID); tmpListRes = new DeviceListResult(); Assert.assertNotNull(tmpDevice); Assert.assertNotNull(tmpCreator); @@ -1216,7 +1216,7 @@ public void checkDeviceConnectionStatus(String status) { @Then("I count {int} connections in scope {int}") public void countConnectioncInScope(int target, int scope) throws Exception { - updateCountAndCheck(() -> (int) deviceConnectionService.count(deviceConnectionFactory.newQuery(getKapuaId(scope))), target); + updateCountAndCheck(() -> (int) deviceConnectionService.count(new DeviceConnectionQuery(getKapuaId(scope))), target); } @When("I search for a connection by scope and connection IDs") @@ -1282,7 +1282,7 @@ public void deleteRandomConnection() throws Exception { @When("I query for all connections with the parameter {string} set to {string}") public void queryForConnections(String parameter, String value) throws Exception { - DeviceConnectionQuery query = deviceConnectionFactory.newQuery(getCurrentScopeId()); + DeviceConnectionQuery query = new DeviceConnectionQuery(getCurrentScopeId()); query.setPredicate(query.attributePredicate(parameter, value, AttributePredicate.Operator.EQUAL)); primeException(); try { @@ -1341,7 +1341,7 @@ public void exerciseAllConnectionFactoryFunctions() { DeviceConnectionCreator tmpCreator = null; DeviceConnectionQuery tmpQuery = null; tmpCreator = deviceConnectionFactory.newCreator(SYS_SCOPE_ID); - tmpQuery = deviceConnectionFactory.newQuery(SYS_SCOPE_ID); + tmpQuery = new DeviceConnectionQuery(SYS_SCOPE_ID); Assert.assertNotNull(tmpCreator); Assert.assertNotNull(tmpQuery); } @@ -1463,12 +1463,12 @@ public void deleteEventWithRandomId() throws Exception { @When("I count events for scope {int}") public void countEventsInScope(int scpId) throws Exception { - updateCount(() -> (int) eventService.count(eventFactory.newQuery(getKapuaId(scpId)))); + updateCount(() -> (int) eventService.count(new DeviceEventQuery(getKapuaId(scpId)))); } @When("I query for {string} events") public void queryForSpecificEvents(String eventType) throws Exception { - DeviceEventQuery tmpQuery = eventFactory.newQuery(getCurrentScopeId()); + DeviceEventQuery tmpQuery = new DeviceEventQuery(getCurrentScopeId()); Assert.assertNotNull(tmpQuery); KapuaMethod tmpMeth = getMethodFromString(eventType); Assert.assertNotNull(tmpMeth); @@ -1510,7 +1510,7 @@ public void searchForEventsGreaterFromDeviceWithClientID(String clientId, String Assert.assertNotNull(account); Device device = deviceRegistryService.findByClientId(account.getId(), clientId); Assert.assertNotNull(device); - DeviceEventQuery eventQuery = eventFactory.newQuery(account.getId()); + DeviceEventQuery eventQuery = new DeviceEventQuery(account.getId()); eventQuery.setPredicate(eventQuery.attributePredicate(DeviceEventAttributes.DEVICE_ID, device.getId(), AttributePredicate.Operator.EQUAL)); eventQuery.setSortCriteria(eventQuery.fieldSortCriteria(DeviceEventAttributes.RECEIVED_ON, SortOrder.ASCENDING)); DeviceEventListResult deviceEventList = eventService.query(eventQuery); @@ -1550,7 +1550,7 @@ private void searchForEventsFromDeviceWithClientIDInternal(String clientId, Stri private boolean searchForEventsFromDeviceWithClientID(Account account, Device device, int events, boolean timeoutOccurred, boolean greater) throws Exception { DeviceEventListResult deviceEventList = null; try { - DeviceEventQuery eventQuery = eventFactory.newQuery(account.getId()); + DeviceEventQuery eventQuery = new DeviceEventQuery(account.getId()); eventQuery.setPredicate(eventQuery.attributePredicate(DeviceEventAttributes.DEVICE_ID, device.getId(), AttributePredicate.Operator.EQUAL)); eventQuery.setSortCriteria(eventQuery.fieldSortCriteria(DeviceEventAttributes.RECEIVED_ON, SortOrder.ASCENDING)); deviceEventList = eventService.query(eventQuery); @@ -1636,7 +1636,7 @@ public void exerciseAllEventFactoryFunctions() { DeviceEventListResult tmpList = null; tmpEvent = eventFactory.newEntity(SYS_SCOPE_ID); tmpCreator = eventFactory.newCreator(SYS_SCOPE_ID, getKapuaId(), new Date(), ""); - tmpQuery = eventFactory.newQuery(SYS_SCOPE_ID); + tmpQuery = new DeviceEventQuery(SYS_SCOPE_ID); tmpList = new DeviceEventListResult(); Assert.assertNotNull(tmpEvent); Assert.assertNotNull(tmpCreator); @@ -1704,8 +1704,8 @@ public void iTagDeviceWithTag(String deviceTagName) throws Exception { @When("I search for device with tag {string}") public void iSearchForDeviceWithTag(String deviceTagName) throws Exception { Account lastAcc = (Account) stepData.get(LAST_ACCOUNT); - DeviceQuery deviceQuery = deviceFactory.newQuery(lastAcc.getId()); - TagQuery tagQuery = tagFactory.newQuery(lastAcc.getId()); + DeviceQuery deviceQuery = new DeviceQuery(lastAcc.getId()); + TagQuery tagQuery = new TagQuery(lastAcc.getId()); tagQuery.setPredicate(tagQuery.attributePredicate(TagAttributes.NAME, deviceTagName, AttributePredicate.Operator.EQUAL)); primeException(); try { @@ -2252,7 +2252,7 @@ private KapuaMethod getMethodFromString(String name) { } private Device getDeviceWithClientId(String clientId) throws KapuaException { - DeviceQuery tmpQuery = deviceFactory.newQuery(getCurrentScopeId()); + DeviceQuery tmpQuery = new DeviceQuery(getCurrentScopeId()); tmpQuery.setPredicate(tmpQuery.attributePredicate(DeviceAttributes.CLIENT_ID, clientId)); DeviceListResult deviceList = deviceRegistryService.query(tmpQuery); @@ -2562,7 +2562,7 @@ public void iSearchForEventsFromDevicesInAccount(String account, int eventsNum) tmpDev = deviceRegistryService.findByClientId(tmpAcc.getId(), device.getClientId()); Assert.assertNotNull(tmpDev); Assert.assertNotNull(tmpDev.getId()); - tmpQuery = eventFactory.newQuery(tmpAcc.getId()); + tmpQuery = new DeviceEventQuery(tmpAcc.getId()); tmpQuery.setPredicate(tmpQuery.attributePredicate(DeviceEventAttributes.DEVICE_ID, tmpDev.getId(), AttributePredicate.Operator.EQUAL)); tmpQuery.setSortCriteria(tmpQuery.fieldSortCriteria(DeviceEventAttributes.RECEIVED_ON, SortOrder.ASCENDING)); tmpList = eventService.query(tmpQuery); @@ -2594,11 +2594,11 @@ public void iAssignTagToDevice() throws Exception { @And("I assign tag {string} to device {string}") public void iAssignTagNamedToDevice(String tagName, String deviceName) throws Exception { try { - DeviceQuery tmpQuery = deviceFactory.newQuery(getCurrentScopeId()); + DeviceQuery tmpQuery = new DeviceQuery(getCurrentScopeId()); tmpQuery.setPredicate(tmpQuery.attributePredicate(DeviceAttributes.CLIENT_ID, deviceName, AttributePredicate.Operator.EQUAL)); DeviceListResult deviceList = deviceRegistryService.query(tmpQuery); Device device = deviceList.getFirstItem(); - TagQuery tagQuery = tagFactory.newQuery(getCurrentScopeId()); + TagQuery tagQuery = new TagQuery(getCurrentScopeId()); tagQuery.setPredicate(tagQuery.attributePredicate(TagAttributes.NAME, tagName, AttributePredicate.Operator.EQUAL)); TagListResult tagList = tagService.query(tagQuery); Tag tag = tagList.getFirstItem(); @@ -2615,10 +2615,10 @@ public void iAssignTagNamedToDevice(String tagName, String deviceName) throws Ex @And("I add device {string} to group {string}") public void iAddDeviceToGroup(String deviceName, String groupName) throws Exception { try { - GroupQuery query = groupFactory.newQuery(getCurrentScopeId()); + GroupQuery query = new GroupQuery(getCurrentScopeId()); query.setPredicate(query.attributePredicate(GroupAttributes.NAME, groupName, AttributePredicate.Operator.EQUAL)); Group foundGroup = groupService.query(query).getFirstItem(); - DeviceQuery tmpQuery = deviceFactory.newQuery(getCurrentScopeId()); + DeviceQuery tmpQuery = new DeviceQuery(getCurrentScopeId()); tmpQuery.setPredicate(tmpQuery.attributePredicate(DeviceAttributes.CLIENT_ID, deviceName, AttributePredicate.Operator.EQUAL)); Device device = deviceRegistryService.query(tmpQuery).getFirstItem(); KapuaId groupId = foundGroup.getId(); @@ -2645,11 +2645,11 @@ public void iTryToEditDevicesDisplayNameTo(String displayName) throws Exception @Given("Tag {string} is assigned to device {string}") public void tagIsAssignedToDevice(String tagName, String deviceName) throws Throwable { try { - DeviceQuery tmpQuery = deviceFactory.newQuery(getCurrentScopeId()); + DeviceQuery tmpQuery = new DeviceQuery(getCurrentScopeId()); tmpQuery.setPredicate(tmpQuery.attributePredicate(DeviceAttributes.CLIENT_ID, deviceName, AttributePredicate.Operator.EQUAL)); DeviceListResult deviceList = deviceRegistryService.query(tmpQuery); Device device = deviceList.getFirstItem(); - TagQuery tagQuery = tagFactory.newQuery(getCurrentScopeId()); + TagQuery tagQuery = new TagQuery(getCurrentScopeId()); tagQuery.setPredicate(tagQuery.attributePredicate(TagAttributes.NAME, tagName, AttributePredicate.Operator.EQUAL)); TagListResult tagList = tagService.query(tagQuery); Tag tag = tagList.getFirstItem(); @@ -2663,7 +2663,7 @@ public void tagIsAssignedToDevice(String tagName, String deviceName) throws Thro @When("I remove device {string} from all groups") public void iChangeDevicesGroupToNoGroup(String deviceName) throws Exception { try { - DeviceQuery tmpQuery = deviceFactory.newQuery(getCurrentScopeId()); + DeviceQuery tmpQuery = new DeviceQuery(getCurrentScopeId()); tmpQuery.setPredicate(tmpQuery.attributePredicate(DeviceAttributes.CLIENT_ID, deviceName, AttributePredicate.Operator.EQUAL)); Device device = deviceRegistryService.query(tmpQuery).getFirstItem(); device.setGroupId(null); @@ -2706,11 +2706,11 @@ public void iCreateDevicesAndAddThemToGroup(int numberOfDevices, String groupNam @Given("I unassign tag {string} from device {string}") public void iUnassignTagNamedFromDevice(String tagName, String deviceName) throws Exception { try { - DeviceQuery tmpQuery = deviceFactory.newQuery(getCurrentScopeId()); + DeviceQuery tmpQuery = new DeviceQuery(getCurrentScopeId()); tmpQuery.setPredicate(tmpQuery.attributePredicate(DeviceAttributes.CLIENT_ID, deviceName, AttributePredicate.Operator.EQUAL)); DeviceListResult deviceList = deviceRegistryService.query(tmpQuery); Device device = deviceList.getFirstItem(); - TagQuery tagQuery = tagFactory.newQuery(getCurrentScopeId()); + TagQuery tagQuery = new TagQuery(getCurrentScopeId()); tagQuery.setPredicate(tagQuery.attributePredicate(TagAttributes.NAME, tagName, AttributePredicate.Operator.EQUAL)); TagListResult tagList = tagService.query(tagQuery); Tag tag = tagList.getFirstItem(); @@ -2727,10 +2727,10 @@ public void iUnassignTagNamedFromDevice(String tagName, String deviceName) throw @Then("Device {string} is in Assigned Devices of group {string}") public void deviceIsInGroupsAssignedDevices(String deviceName, String groupName) throws Exception { try { - GroupQuery query = groupFactory.newQuery(getCurrentScopeId()); + GroupQuery query = new GroupQuery(getCurrentScopeId()); query.setPredicate(query.attributePredicate(GroupAttributes.NAME, groupName, AttributePredicate.Operator.EQUAL)); Group foundGroup = groupService.query(query).getFirstItem(); - DeviceQuery tmpQuery = deviceFactory.newQuery(getCurrentScopeId()); + DeviceQuery tmpQuery = new DeviceQuery(getCurrentScopeId()); tmpQuery.setPredicate(tmpQuery.attributePredicate(DeviceAttributes.CLIENT_ID, deviceName, AttributePredicate.Operator.EQUAL)); Device device = deviceRegistryService.query(tmpQuery).getFirstItem(); KapuaId expectedGroupId = foundGroup.getId(); @@ -3181,11 +3181,11 @@ public void iChangeDeviceExtendedPropertiesTo(List cu @Given("Tag {string} is not assigned to device {string}") public void tagWithNameIsNotAssignedToDevice(String tagName, String deviceName) throws Throwable { try { - DeviceQuery tmpQuery = deviceFactory.newQuery(getCurrentScopeId()); + DeviceQuery tmpQuery = new DeviceQuery(getCurrentScopeId()); tmpQuery.setPredicate(tmpQuery.attributePredicate(DeviceAttributes.CLIENT_ID, deviceName, AttributePredicate.Operator.EQUAL)); DeviceListResult deviceList = deviceRegistryService.query(tmpQuery); Device device = deviceList.getFirstItem(); - TagQuery tagQuery = tagFactory.newQuery(getCurrentScopeId()); + TagQuery tagQuery = new TagQuery(getCurrentScopeId()); tagQuery.setPredicate(tagQuery.attributePredicate(TagAttributes.NAME, tagName, AttributePredicate.Operator.EQUAL)); TagListResult tagList = tagService.query(tagQuery); Tag tag = tagList.getFirstItem(); @@ -3199,10 +3199,10 @@ public void tagWithNameIsNotAssignedToDevice(String tagName, String deviceName) @Then("Device {string} is not in Assigned Devices of group {string}") public void deviceIsNotInGroupsAssignedDevices(String deviceName, String groupName) throws Exception { try { - GroupQuery query = groupFactory.newQuery(getCurrentScopeId()); + GroupQuery query = new GroupQuery(getCurrentScopeId()); query.setPredicate(query.attributePredicate(GroupAttributes.NAME, groupName, AttributePredicate.Operator.EQUAL)); Group foundGroup = groupService.query(query).getFirstItem(); - DeviceQuery tmpQuery = deviceFactory.newQuery(getCurrentScopeId()); + DeviceQuery tmpQuery = new DeviceQuery(getCurrentScopeId()); tmpQuery.setPredicate(tmpQuery.attributePredicate(DeviceAttributes.CLIENT_ID, deviceName, AttributePredicate.Operator.EQUAL)); Device device = deviceRegistryService.query(tmpQuery).getFirstItem(); KapuaId expectedGroupId = foundGroup.getId(); @@ -3218,91 +3218,91 @@ public void iFilterDevices(List parameters) throws Exception { DeviceListResult devices; stepData.remove("DeviceList"); if (deviceParams.getClientId() != null && deviceParams.getDisplayName() == null && deviceParams.getSerialNumber() == null && deviceParams.getStatus() == null) { - DeviceQuery tmpQuery = deviceFactory.newQuery(getCurrentScopeId()); + DeviceQuery tmpQuery = new DeviceQuery(getCurrentScopeId()); tmpQuery.setPredicate(tmpQuery.attributePredicate(DeviceAttributes.CLIENT_ID, deviceParams.getClientId(), AttributePredicate.Operator.LIKE)); devices = deviceRegistryService.query(tmpQuery); stepData.put("DeviceList", devices); } else if (deviceParams.getClientId() == null && deviceParams.getDisplayName() != null && deviceParams.getSerialNumber() == null && deviceParams.getStatus() == null) { - DeviceQuery tmpQuery = deviceFactory.newQuery(getCurrentScopeId()); + DeviceQuery tmpQuery = new DeviceQuery(getCurrentScopeId()); tmpQuery.setPredicate(tmpQuery.attributePredicate(DeviceAttributes.DISPLAY_NAME, deviceParams.getDisplayName(), AttributePredicate.Operator.LIKE)); devices = deviceRegistryService.query(tmpQuery); stepData.put("DeviceList", devices); } else if (deviceParams.getClientId() == null && deviceParams.getDisplayName() == null && deviceParams.getSerialNumber() != null && deviceParams.getStatus() == null) { - DeviceQuery tmpQuery = deviceFactory.newQuery(getCurrentScopeId()); + DeviceQuery tmpQuery = new DeviceQuery(getCurrentScopeId()); tmpQuery.setPredicate(tmpQuery.attributePredicate(DeviceAttributes.SERIAL_NUMBER, deviceParams.getSerialNumber(), AttributePredicate.Operator.LIKE)); devices = deviceRegistryService.query(tmpQuery); stepData.put("DeviceList", devices); } else if (deviceParams.getClientId() == null && deviceParams.getDisplayName() == null && deviceParams.getSerialNumber() == null && deviceParams.getStatus() != null) { - DeviceQuery tmpQuery = deviceFactory.newQuery(getCurrentScopeId()); + DeviceQuery tmpQuery = new DeviceQuery(getCurrentScopeId()); tmpQuery.setPredicate(tmpQuery.attributePredicate(DeviceAttributes.STATUS, deviceParams.getStatus(), AttributePredicate.Operator.LIKE)); devices = deviceRegistryService.query(tmpQuery); stepData.put("DeviceList", devices); } else if (deviceParams.getClientId() != null && deviceParams.getDisplayName() != null && deviceParams.getSerialNumber() == null && deviceParams.getStatus() == null) { - DeviceQuery tmpQuery = deviceFactory.newQuery(getCurrentScopeId()); + DeviceQuery tmpQuery = new DeviceQuery(getCurrentScopeId()); tmpQuery.setPredicate(tmpQuery.andPredicate(tmpQuery.attributePredicate(DeviceAttributes.CLIENT_ID, deviceParams.getClientId(), AttributePredicate.Operator.LIKE), tmpQuery.attributePredicate(DeviceAttributes.DISPLAY_NAME, deviceParams.getDisplayName(), AttributePredicate.Operator.LIKE))); devices = deviceRegistryService.query(tmpQuery); stepData.put("DeviceList", devices); } else if (deviceParams.getClientId() != null && deviceParams.getDisplayName() == null && deviceParams.getSerialNumber() != null && deviceParams.getStatus() == null) { - DeviceQuery tmpQuery = deviceFactory.newQuery(getCurrentScopeId()); + DeviceQuery tmpQuery = new DeviceQuery(getCurrentScopeId()); tmpQuery.setPredicate(tmpQuery.andPredicate(tmpQuery.attributePredicate(DeviceAttributes.CLIENT_ID, deviceParams.getClientId(), AttributePredicate.Operator.LIKE), tmpQuery.attributePredicate(DeviceAttributes.SERIAL_NUMBER, deviceParams.getSerialNumber(), AttributePredicate.Operator.LIKE))); devices = deviceRegistryService.query(tmpQuery); stepData.put("DeviceList", devices); } else if (deviceParams.getClientId() != null && deviceParams.getDisplayName() == null && deviceParams.getSerialNumber() == null && deviceParams.getStatus() != null) { - DeviceQuery tmpQuery = deviceFactory.newQuery(getCurrentScopeId()); + DeviceQuery tmpQuery = new DeviceQuery(getCurrentScopeId()); tmpQuery.setPredicate(tmpQuery.andPredicate(tmpQuery.attributePredicate(DeviceAttributes.CLIENT_ID, deviceParams.getClientId(), AttributePredicate.Operator.LIKE), tmpQuery.attributePredicate(DeviceAttributes.STATUS, deviceParams.getStatus(), AttributePredicate.Operator.LIKE))); devices = deviceRegistryService.query(tmpQuery); stepData.put("DeviceList", devices); } else if (deviceParams.getClientId() == null && deviceParams.getDisplayName() != null && deviceParams.getSerialNumber() != null && deviceParams.getStatus() == null) { - DeviceQuery tmpQuery = deviceFactory.newQuery(getCurrentScopeId()); + DeviceQuery tmpQuery = new DeviceQuery(getCurrentScopeId()); tmpQuery.setPredicate(tmpQuery.andPredicate(tmpQuery.attributePredicate(DeviceAttributes.SERIAL_NUMBER, deviceParams.getSerialNumber(), AttributePredicate.Operator.LIKE), tmpQuery.attributePredicate(DeviceAttributes.DISPLAY_NAME, deviceParams.getDisplayName(), AttributePredicate.Operator.LIKE))); devices = deviceRegistryService.query(tmpQuery); stepData.put("DeviceList", devices); } else if (deviceParams.getClientId() == null && deviceParams.getDisplayName() != null && deviceParams.getSerialNumber() == null && deviceParams.getStatus() != null) { - DeviceQuery tmpQuery = deviceFactory.newQuery(getCurrentScopeId()); + DeviceQuery tmpQuery = new DeviceQuery(getCurrentScopeId()); tmpQuery.setPredicate(tmpQuery.andPredicate(tmpQuery.attributePredicate(DeviceAttributes.STATUS, deviceParams.getStatus(), AttributePredicate.Operator.LIKE), tmpQuery.attributePredicate(DeviceAttributes.DISPLAY_NAME, deviceParams.getDisplayName(), AttributePredicate.Operator.LIKE))); devices = deviceRegistryService.query(tmpQuery); stepData.put("DeviceList", devices); } else if (deviceParams.getClientId() == null && deviceParams.getDisplayName() == null && deviceParams.getSerialNumber() != null && deviceParams.getStatus() != null) { - DeviceQuery tmpQuery = deviceFactory.newQuery(getCurrentScopeId()); + DeviceQuery tmpQuery = new DeviceQuery(getCurrentScopeId()); tmpQuery.setPredicate(tmpQuery.andPredicate(tmpQuery.attributePredicate(DeviceAttributes.SERIAL_NUMBER, deviceParams.getSerialNumber(), AttributePredicate.Operator.LIKE), tmpQuery.attributePredicate(DeviceAttributes.STATUS, deviceParams.getStatus(), AttributePredicate.Operator.LIKE))); devices = deviceRegistryService.query(tmpQuery); stepData.put("DeviceList", devices); } else if (deviceParams.getClientId() != null && deviceParams.getDisplayName() != null && deviceParams.getSerialNumber() != null && deviceParams.getStatus() == null) { - DeviceQuery tmpQuery = deviceFactory.newQuery(getCurrentScopeId()); + DeviceQuery tmpQuery = new DeviceQuery(getCurrentScopeId()); tmpQuery.setPredicate(tmpQuery.andPredicate(tmpQuery.attributePredicate(DeviceAttributes.CLIENT_ID, deviceParams.getClientId(), AttributePredicate.Operator.LIKE), tmpQuery.attributePredicate(DeviceAttributes.DISPLAY_NAME, deviceParams.getDisplayName(), AttributePredicate.Operator.LIKE), tmpQuery.attributePredicate(DeviceAttributes.SERIAL_NUMBER, deviceParams.getSerialNumber(), AttributePredicate.Operator.LIKE))); devices = deviceRegistryService.query(tmpQuery); stepData.put("DeviceList", devices); } else if (deviceParams.getClientId() != null && deviceParams.getDisplayName() != null && deviceParams.getSerialNumber() == null && deviceParams.getStatus() != null) { - DeviceQuery tmpQuery = deviceFactory.newQuery(getCurrentScopeId()); + DeviceQuery tmpQuery = new DeviceQuery(getCurrentScopeId()); tmpQuery.setPredicate(tmpQuery.andPredicate(tmpQuery.attributePredicate(DeviceAttributes.CLIENT_ID, deviceParams.getClientId(), AttributePredicate.Operator.LIKE), tmpQuery.attributePredicate(DeviceAttributes.DISPLAY_NAME, deviceParams.getDisplayName(), AttributePredicate.Operator.LIKE), tmpQuery.attributePredicate(DeviceAttributes.STATUS, deviceParams.getStatus(), AttributePredicate.Operator.LIKE))); devices = deviceRegistryService.query(tmpQuery); stepData.put("DeviceList", devices); } else if (deviceParams.getClientId() != null && deviceParams.getDisplayName() == null && deviceParams.getSerialNumber() != null && deviceParams.getStatus() != null) { - DeviceQuery tmpQuery = deviceFactory.newQuery(getCurrentScopeId()); + DeviceQuery tmpQuery = new DeviceQuery(getCurrentScopeId()); tmpQuery.setPredicate(tmpQuery.andPredicate(tmpQuery.attributePredicate(DeviceAttributes.CLIENT_ID, deviceParams.getClientId(), AttributePredicate.Operator.LIKE), tmpQuery.attributePredicate(DeviceAttributes.SERIAL_NUMBER, deviceParams.getSerialNumber(), AttributePredicate.Operator.LIKE), tmpQuery.attributePredicate(DeviceAttributes.STATUS, deviceParams.getStatus(), AttributePredicate.Operator.LIKE))); devices = deviceRegistryService.query(tmpQuery); stepData.put("DeviceList", devices); } else if (deviceParams.getClientId() == null && deviceParams.getDisplayName() != null && deviceParams.getSerialNumber() != null && deviceParams.getStatus() != null) { - DeviceQuery tmpQuery = deviceFactory.newQuery(getCurrentScopeId()); + DeviceQuery tmpQuery = new DeviceQuery(getCurrentScopeId()); tmpQuery.setPredicate(tmpQuery.andPredicate(tmpQuery.attributePredicate(DeviceAttributes.SERIAL_NUMBER, deviceParams.getSerialNumber(), AttributePredicate.Operator.LIKE), tmpQuery.attributePredicate(DeviceAttributes.DISPLAY_NAME, deviceParams.getDisplayName(), AttributePredicate.Operator.LIKE), tmpQuery.attributePredicate(DeviceAttributes.STATUS, deviceParams.getStatus(), AttributePredicate.Operator.LIKE))); devices = deviceRegistryService.query(tmpQuery); stepData.put("DeviceList", devices); } else if (deviceParams.getClientId() != null && deviceParams.getDisplayName() != null && deviceParams.getSerialNumber() != null && deviceParams.getStatus() != null) { - DeviceQuery tmpQuery = deviceFactory.newQuery(getCurrentScopeId()); + DeviceQuery tmpQuery = new DeviceQuery(getCurrentScopeId()); tmpQuery.setPredicate(tmpQuery.andPredicate(tmpQuery.attributePredicate(DeviceAttributes.SERIAL_NUMBER, deviceParams.getSerialNumber(), AttributePredicate.Operator.LIKE), tmpQuery.attributePredicate(DeviceAttributes.DISPLAY_NAME, deviceParams.getDisplayName(), AttributePredicate.Operator.LIKE), tmpQuery.attributePredicate(DeviceAttributes.CLIENT_ID, deviceParams.getClientId(), AttributePredicate.Operator.LIKE), @@ -3317,7 +3317,7 @@ public void iSearchForADeviceWithName(String clientID) throws Throwable { try { stepData.remove(DEVICE); primeException(); - DeviceQuery query = deviceFactory.newQuery(SYS_SCOPE_ID); + DeviceQuery query = new DeviceQuery(SYS_SCOPE_ID); query.setPredicate(query.attributePredicate(DeviceAttributes.CLIENT_ID, clientID, AttributePredicate.Operator.EQUAL)); DeviceListResult queryResult = deviceRegistryService.query(query); Device foundDevice = queryResult.getFirstItem(); diff --git a/service/device/registry/test/src/test/java/org/eclipse/kapua/service/device/registry/test/DeviceRegistryLocatorConfiguration.java b/service/device/registry/test/src/test/java/org/eclipse/kapua/service/device/registry/test/DeviceRegistryLocatorConfiguration.java index 8064339b11b..f3438a2b069 100644 --- a/service/device/registry/test/src/test/java/org/eclipse/kapua/service/device/registry/test/DeviceRegistryLocatorConfiguration.java +++ b/service/device/registry/test/src/test/java/org/eclipse/kapua/service/device/registry/test/DeviceRegistryLocatorConfiguration.java @@ -12,13 +12,9 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.registry.test; -import com.codahale.metrics.MetricRegistry; -import com.google.inject.AbstractModule; -import com.google.inject.Guice; -import com.google.inject.Injector; -import com.google.inject.Singleton; -import com.google.inject.name.Names; -import io.cucumber.java.Before; +import java.util.HashMap; +import java.util.Map; + import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.commons.configuration.AccountRelativeFinder; import org.eclipse.kapua.commons.configuration.RootUserTester; @@ -87,8 +83,14 @@ import org.mockito.Matchers; import org.mockito.Mockito; -import java.util.HashMap; -import java.util.Map; +import com.codahale.metrics.MetricRegistry; +import com.google.inject.AbstractModule; +import com.google.inject.Guice; +import com.google.inject.Injector; +import com.google.inject.Singleton; +import com.google.inject.name.Names; + +import io.cucumber.java.Before; @Singleton public class DeviceRegistryLocatorConfiguration { @@ -180,7 +182,8 @@ protected void configure() { bind(DeviceEventFactory.class).toInstance(new DeviceEventFactoryImpl()); bind(KapuaMessageFactory.class).toInstance(new KapuaMessageFactoryImpl()); - final DeviceValidation deviceValidation = new DeviceValidationImpl(new KapuaDeviceRegistrySettings().getInt(KapuaDeviceRegistrySettingKeys.DEVICE_LIFECYCLE_BIRTH_VAR_FIELDS_LENGTH_MAX), + final DeviceValidation deviceValidation = new DeviceValidationImpl( + new KapuaDeviceRegistrySettings().getInt(KapuaDeviceRegistrySettingKeys.DEVICE_LIFECYCLE_BIRTH_VAR_FIELDS_LENGTH_MAX), new KapuaDeviceRegistrySettings().getInt(KapuaDeviceRegistrySettingKeys.DEVICE_LIFECYCLE_BIRTH_EXTENDED_PROPERTIES_LENGTH_MAX), mockedAuthorization, permissionFactory, @@ -188,7 +191,6 @@ protected void configure() { deviceConnectionService, deviceEventService, new DeviceImplJpaRepository(jpaRepoConfig), - new DeviceFactoryImpl(), new TagServiceImpl( permissionFactory, mockedAuthorization, diff --git a/service/endpoint/api/src/main/java/org/eclipse/kapua/service/endpoint/EndpointInfoFactory.java b/service/endpoint/api/src/main/java/org/eclipse/kapua/service/endpoint/EndpointInfoFactory.java index 73f8dd57b48..60e9b2515f0 100644 --- a/service/endpoint/api/src/main/java/org/eclipse/kapua/service/endpoint/EndpointInfoFactory.java +++ b/service/endpoint/api/src/main/java/org/eclipse/kapua/service/endpoint/EndpointInfoFactory.java @@ -13,13 +13,14 @@ package org.eclipse.kapua.service.endpoint; import org.eclipse.kapua.model.KapuaEntityFactory; +import org.eclipse.kapua.model.id.KapuaId; /** * {@link EndpointInfoFactory} definition. * * @since 1.0.0 */ -public interface EndpointInfoFactory extends KapuaEntityFactory { +public interface EndpointInfoFactory extends KapuaEntityFactory { /** * Instantiates a new {@link EndpointUsage}. @@ -30,4 +31,7 @@ public interface EndpointInfoFactory extends KapuaEntityFactory extends MatchPredicate { +import org.eclipse.kapua.model.query.predicate.AbstractMatchPredicate; +public class EndpointInfoMatchPredicate extends AbstractMatchPredicate { + + /** + * Constructor. + * + * @param matchTerm + * @since 2.1.0 + */ + public EndpointInfoMatchPredicate(T matchTerm) { + this.attributeNames = Arrays.asList( + EndpointInfoAttributes.SCHEMA, + EndpointInfoAttributes.DNS + ); + this.matchTerm = matchTerm; + } } diff --git a/service/endpoint/api/src/main/java/org/eclipse/kapua/service/endpoint/EndpointInfoQuery.java b/service/endpoint/api/src/main/java/org/eclipse/kapua/service/endpoint/EndpointInfoQuery.java index 8e0fcf05e6d..583509cedfd 100644 --- a/service/endpoint/api/src/main/java/org/eclipse/kapua/service/endpoint/EndpointInfoQuery.java +++ b/service/endpoint/api/src/main/java/org/eclipse/kapua/service/endpoint/EndpointInfoQuery.java @@ -12,13 +12,14 @@ *******************************************************************************/ package org.eclipse.kapua.service.endpoint; -import org.eclipse.kapua.model.query.KapuaQuery; - import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.model.query.KapuaQuery; + /** * {@link EndpointInfo} {@link KapuaQuery} definition. * @@ -28,14 +29,33 @@ @XmlRootElement(name = "query") @XmlAccessorType(XmlAccessType.PROPERTY) @XmlType(factoryClass = EndpointInfoXmlRegistry.class, factoryMethod = "newQuery") -public interface EndpointInfoQuery extends KapuaQuery { +public class EndpointInfoQuery extends KapuaQuery { + + public EndpointInfoQuery() { + } + + /** + * Constructor. + * + * @param scopeId + * The {@link #getScopeId()}. + * @since 1.0.0 + */ + public EndpointInfoQuery(KapuaId scopeId) { + super(scopeId); + } + /** * Instantiates a new {@link EndpointInfoMatchPredicate}. * - * @param matchTerm The term to use to match. - * @param The type of the term + * @param matchTerm + * The term to use to match. + * @param + * The type of the term * @return The newly instantiated {@link EndpointInfoMatchPredicate}. * @since 2.1.0 */ - EndpointInfoMatchPredicate matchPredicate(T matchTerm); + public EndpointInfoMatchPredicate matchPredicate(T matchTerm) { + return new EndpointInfoMatchPredicate<>(matchTerm); + } } diff --git a/service/endpoint/internal/src/main/java/org/eclipse/kapua/service/endpoint/internal/EndpointInfoFactoryImpl.java b/service/endpoint/internal/src/main/java/org/eclipse/kapua/service/endpoint/internal/EndpointInfoFactoryImpl.java index 4b2d655a7b8..619afaa71fe 100644 --- a/service/endpoint/internal/src/main/java/org/eclipse/kapua/service/endpoint/internal/EndpointInfoFactoryImpl.java +++ b/service/endpoint/internal/src/main/java/org/eclipse/kapua/service/endpoint/internal/EndpointInfoFactoryImpl.java @@ -37,7 +37,7 @@ public EndpointInfo newEntity(KapuaId scopeId) { @Override public EndpointInfoQuery newQuery(KapuaId scopeId) { - return new EndpointInfoQueryImpl(scopeId); + return new EndpointInfoQuery(scopeId); } @Override diff --git a/service/endpoint/internal/src/main/java/org/eclipse/kapua/service/endpoint/internal/EndpointInfoMatchPredicateImpl.java b/service/endpoint/internal/src/main/java/org/eclipse/kapua/service/endpoint/internal/EndpointInfoMatchPredicateImpl.java deleted file mode 100644 index f239431346f..00000000000 --- a/service/endpoint/internal/src/main/java/org/eclipse/kapua/service/endpoint/internal/EndpointInfoMatchPredicateImpl.java +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017, 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.service.endpoint.internal; - -import org.eclipse.kapua.commons.model.query.predicate.AbstractMatchPredicate; -import org.eclipse.kapua.service.endpoint.EndpointInfoAttributes; -import org.eclipse.kapua.service.endpoint.EndpointInfoMatchPredicate; - -import java.util.Arrays; - -public class EndpointInfoMatchPredicateImpl extends AbstractMatchPredicate implements EndpointInfoMatchPredicate { - - /** - * Constructor. - * - * @param matchTerm - * @since 2.1.0 - */ - public EndpointInfoMatchPredicateImpl(T matchTerm) { - this.attributeNames = Arrays.asList( - EndpointInfoAttributes.SCHEMA, - EndpointInfoAttributes.DNS - ); - this.matchTerm = matchTerm; - } - -} diff --git a/service/endpoint/internal/src/main/java/org/eclipse/kapua/service/endpoint/internal/EndpointInfoQueryImpl.java b/service/endpoint/internal/src/main/java/org/eclipse/kapua/service/endpoint/internal/EndpointInfoQueryImpl.java deleted file mode 100644 index 7ceed548388..00000000000 --- a/service/endpoint/internal/src/main/java/org/eclipse/kapua/service/endpoint/internal/EndpointInfoQueryImpl.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017, 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.service.endpoint.internal; - -import org.eclipse.kapua.commons.model.query.AbstractKapuaQuery; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.service.endpoint.EndpointInfoMatchPredicate; -import org.eclipse.kapua.service.endpoint.EndpointInfoQuery; - -/** - * {@link EndpointInfoQuery} implementation. - * - * @since 1.0.0 - */ -public class EndpointInfoQueryImpl extends AbstractKapuaQuery implements EndpointInfoQuery { - - /** - * Constructor. - * - * @param scopeId The {@link #getScopeId()}. - * @since 1.0.0 - */ - public EndpointInfoQueryImpl(KapuaId scopeId) { - super(scopeId); - } - - @Override - public EndpointInfoMatchPredicate matchPredicate(T matchTerm) { - return new EndpointInfoMatchPredicateImpl<>(matchTerm); - } -} diff --git a/service/endpoint/internal/src/main/java/org/eclipse/kapua/service/endpoint/internal/EndpointInfoServiceImpl.java b/service/endpoint/internal/src/main/java/org/eclipse/kapua/service/endpoint/internal/EndpointInfoServiceImpl.java index 11a4a8bc75a..ab6cd8f5b5c 100644 --- a/service/endpoint/internal/src/main/java/org/eclipse/kapua/service/endpoint/internal/EndpointInfoServiceImpl.java +++ b/service/endpoint/internal/src/main/java/org/eclipse/kapua/service/endpoint/internal/EndpointInfoServiceImpl.java @@ -12,6 +12,15 @@ *******************************************************************************/ package org.eclipse.kapua.service.endpoint.internal; +import java.util.AbstractMap; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.function.Predicate; + +import javax.inject.Inject; +import javax.inject.Singleton; + import org.eclipse.kapua.KapuaEntityNotFoundException; import org.eclipse.kapua.KapuaEntityUniquenessException; import org.eclipse.kapua.KapuaException; @@ -41,14 +50,6 @@ import org.eclipse.kapua.storage.TxContext; import org.eclipse.kapua.storage.TxManager; -import javax.inject.Inject; -import javax.inject.Singleton; -import java.util.AbstractMap; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.function.Predicate; - /** * {@link EndpointInfoService} implementation. * @@ -57,6 +58,7 @@ @Singleton public class EndpointInfoServiceImpl implements EndpointInfoService { + private final AuthorizationService authorizationService; private final PermissionFactory permissionFactory; private final EndpointInfoFactory endpointInfoFactory; @@ -207,7 +209,8 @@ public EndpointInfo find(KapuaId scopeId, KapuaId endpointInfoId) EndpointInfoQuery query = endpointInfoFactory.newQuery(scopeId); EndpointInfoListResult nearestUsableEndpoints = doQuery(tx, query, type); - if (nearestUsableEndpoints.isEmpty() || !nearestUsableEndpoints.getFirstItem().getScopeId().equals(endpointInfoToFind.getScopeId())) { //the second condition is equivalent to verify if the searched endpoint is in this list + if (nearestUsableEndpoints.isEmpty() || !nearestUsableEndpoints.getFirstItem().getScopeId() + .equals(endpointInfoToFind.getScopeId())) { //the second condition is equivalent to verify if the searched endpoint is in this list throw new KapuaEntityNotFoundException(EndpointInfo.TYPE, endpointInfoId); } else { return endpointInfoToFind; @@ -266,7 +269,6 @@ private EndpointInfoListResult doQuery(TxContext tx, KapuaQuery query, String se ); } - // // Private methods and interfaces // @@ -275,19 +277,23 @@ private EndpointInfoListResult doQuery(TxContext tx, KapuaQuery query, String se //to overcome this, I created this interface which is a custom form of a Bifunction throwing the checked KapuaException @FunctionalInterface public interface kapuaBiFunction { + R apply(A input1, B input2) throws KapuaException; } - /** - * Traverse the account hierarchy bottom-up to search for {@link EndpointInfo} respecting the given query, - * performing for each layer the given queryExecutor until the given isEmptyResult dictates to stop OR when endpoints of the same section are found in one layer - * In other terms, this method applies a given function to the "nearest usable endpoints", aka the ones that I see in a given scopeID + * Traverse the account hierarchy bottom-up to search for {@link EndpointInfo} respecting the given query, performing for each layer the given queryExecutor until the given isEmptyResult dictates + * to stop OR when endpoints of the same section are found in one layer In other terms, this method applies a given function to the "nearest usable endpoints", aka the ones that I see in a given + * scopeID * - * @param query The query to filter the {@link EndpointInfo}s. - * @param section section of {@link EndpointInfo} where we want to search the information - * @param queryExecutor function to apply at each layer - * @param isEmptyResult predicate that dictates to stop the traversal when false + * @param query + * The query to filter the {@link EndpointInfo}s. + * @param section + * section of {@link EndpointInfo} where we want to search the information + * @param queryExecutor + * function to apply at each layer + * @param isEmptyResult + * predicate that dictates to stop the traversal when false */ protected R traverse( TxContext tx, @@ -337,18 +343,25 @@ protected R traverse( /** * Checks whether another {@link EndpointInfo} already exists with the given values. * - * @param scopeId The ScopeId of the {@link EndpointInfo} - * @param entityId The entity id, if exists. On update you need to exclude the same entity. - * @param schema The {@link EndpointInfo#getSchema()} value. - * @param dns The {@link EndpointInfo#getDns()} value. - * @param port The {@link EndpointInfo#getPort()} value. - * @param type The {@link EndpointInfo#getEndpointType()} value. - * @throws KapuaException if the values provided matches another {@link EndpointInfo} + * @param scopeId + * The ScopeId of the {@link EndpointInfo} + * @param entityId + * The entity id, if exists. On update you need to exclude the same entity. + * @param schema + * The {@link EndpointInfo#getSchema()} value. + * @param dns + * The {@link EndpointInfo#getDns()} value. + * @param port + * The {@link EndpointInfo#getPort()} value. + * @param type + * The {@link EndpointInfo#getEndpointType()} value. + * @throws KapuaException + * if the values provided matches another {@link EndpointInfo} * @since 1.0.0 */ private void checkDuplicateEndpointInfo(KapuaId scopeId, KapuaId entityId, String schema, String dns, int port, String type) throws KapuaException { - EndpointInfoQuery query = new EndpointInfoQueryImpl(scopeId); + EndpointInfoQuery query = new EndpointInfoQuery(scopeId); AndPredicate andPredicate = query.andPredicate( query.attributePredicate(EndpointInfoAttributes.SCHEMA, schema), diff --git a/service/job/api/src/main/java/org/eclipse/kapua/service/job/JobFactory.java b/service/job/api/src/main/java/org/eclipse/kapua/service/job/JobFactory.java index 7b985707f04..cf2f8e13a25 100644 --- a/service/job/api/src/main/java/org/eclipse/kapua/service/job/JobFactory.java +++ b/service/job/api/src/main/java/org/eclipse/kapua/service/job/JobFactory.java @@ -20,6 +20,6 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface JobFactory extends KapuaEntityFactory { +public interface JobFactory extends KapuaEntityFactory { } diff --git a/service/job/api/src/main/java/org/eclipse/kapua/service/job/JobMatchPredicate.java b/service/job/api/src/main/java/org/eclipse/kapua/service/job/JobMatchPredicate.java index 36c38f2d7a1..d11329a8c7b 100644 --- a/service/job/api/src/main/java/org/eclipse/kapua/service/job/JobMatchPredicate.java +++ b/service/job/api/src/main/java/org/eclipse/kapua/service/job/JobMatchPredicate.java @@ -12,8 +12,24 @@ *******************************************************************************/ package org.eclipse.kapua.service.job; -import org.eclipse.kapua.model.query.predicate.MatchPredicate; +import java.util.Arrays; -public interface JobMatchPredicate extends MatchPredicate { +import org.eclipse.kapua.model.query.predicate.AbstractMatchPredicate; + +public class JobMatchPredicate extends AbstractMatchPredicate { + + /** + * Constructor. + * + * @param matchTerm + * @since 2.0.0 + */ + public JobMatchPredicate(T matchTerm) { + this.attributeNames = Arrays.asList( + JobAttributes.NAME, + JobAttributes.DESCRIPTION + ); + this.matchTerm = matchTerm; + } } \ No newline at end of file diff --git a/service/job/api/src/main/java/org/eclipse/kapua/service/job/JobQuery.java b/service/job/api/src/main/java/org/eclipse/kapua/service/job/JobQuery.java index cc8af6b377d..ffbd4da3a6c 100644 --- a/service/job/api/src/main/java/org/eclipse/kapua/service/job/JobQuery.java +++ b/service/job/api/src/main/java/org/eclipse/kapua/service/job/JobQuery.java @@ -12,13 +12,15 @@ *******************************************************************************/ package org.eclipse.kapua.service.job; -import org.eclipse.kapua.model.query.KapuaQuery; - import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.model.query.AbstractKapuaNamedQuery; +import org.eclipse.kapua.model.query.KapuaQuery; + /** * {@link Job} {@link KapuaQuery} definition. * @@ -27,17 +29,35 @@ */ @XmlRootElement(name = "query") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = JobXmlRegistry.class, factoryMethod = "newQuery") -public interface JobQuery extends KapuaQuery { +@XmlType +public class JobQuery extends AbstractKapuaNamedQuery { + + public JobQuery() { + } + + /** + * Constructor. + * + * @param scopeId + * The {@link #getScopeId()}. + * @since 1.0.0 + */ + public JobQuery(KapuaId scopeId) { + super(scopeId); + } /** * Instantiates a new {@link JobMatchPredicate}. * - * @param matchTerm The term to use to match. - * @param The type of the term + * @param matchTerm + * The term to use to match. + * @param + * The type of the term * @return The newly instantiated {@link JobMatchPredicate}. * @since 2.0.0 */ - JobMatchPredicate matchPredicate(T matchTerm); + public JobMatchPredicate matchPredicate(T matchTerm) { + return new JobMatchPredicate<>(matchTerm); + } } diff --git a/service/job/api/src/main/java/org/eclipse/kapua/service/job/JobXmlRegistry.java b/service/job/api/src/main/java/org/eclipse/kapua/service/job/JobXmlRegistry.java index 74abe55360f..3b09636e7e0 100644 --- a/service/job/api/src/main/java/org/eclipse/kapua/service/job/JobXmlRegistry.java +++ b/service/job/api/src/main/java/org/eclipse/kapua/service/job/JobXmlRegistry.java @@ -45,6 +45,6 @@ public JobCreator newJobCreator() { } public JobQuery newQuery() { - return jobFactory.newQuery(null); + return new JobQuery(null); } } diff --git a/service/job/api/src/main/java/org/eclipse/kapua/service/job/execution/JobExecutionFactory.java b/service/job/api/src/main/java/org/eclipse/kapua/service/job/execution/JobExecutionFactory.java index 9a73594b5b1..5b89204448f 100644 --- a/service/job/api/src/main/java/org/eclipse/kapua/service/job/execution/JobExecutionFactory.java +++ b/service/job/api/src/main/java/org/eclipse/kapua/service/job/execution/JobExecutionFactory.java @@ -20,6 +20,6 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface JobExecutionFactory extends KapuaEntityFactory { +public interface JobExecutionFactory extends KapuaEntityFactory { } diff --git a/service/job/api/src/main/java/org/eclipse/kapua/service/job/execution/JobExecutionQuery.java b/service/job/api/src/main/java/org/eclipse/kapua/service/job/execution/JobExecutionQuery.java index 74e68ba2e40..4c3be4c644e 100644 --- a/service/job/api/src/main/java/org/eclipse/kapua/service/job/execution/JobExecutionQuery.java +++ b/service/job/api/src/main/java/org/eclipse/kapua/service/job/execution/JobExecutionQuery.java @@ -12,13 +12,16 @@ *******************************************************************************/ package org.eclipse.kapua.service.job.execution; -import org.eclipse.kapua.model.query.KapuaQuery; - import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.model.query.KapuaQuery; +import org.eclipse.kapua.model.query.KapuaSortCriteria; +import org.eclipse.kapua.model.query.SortOrder; + /** * {@link JobExecution} {@link KapuaQuery} definition. * @@ -27,6 +30,25 @@ */ @XmlRootElement(name = "query") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = JobExecutionXmlRegistry.class, factoryMethod = "newQuery") -public interface JobExecutionQuery extends KapuaQuery { +@XmlType +public class JobExecutionQuery extends KapuaQuery { + + public JobExecutionQuery() { + } + + /** + * Constructor. + * + * @param scopeId + * The {@link #getScopeId()}. + * @since 1.0.0 + */ + public JobExecutionQuery(KapuaId scopeId) { + super(scopeId); + } + + @Override + public KapuaSortCriteria getDefaultSortCriteria() { + return fieldSortCriteria(JobExecutionAttributes.STARTED_ON, SortOrder.DESCENDING); + } } diff --git a/service/job/api/src/main/java/org/eclipse/kapua/service/job/execution/JobExecutionXmlRegistry.java b/service/job/api/src/main/java/org/eclipse/kapua/service/job/execution/JobExecutionXmlRegistry.java index 0de567b3408..650dd4c8219 100644 --- a/service/job/api/src/main/java/org/eclipse/kapua/service/job/execution/JobExecutionXmlRegistry.java +++ b/service/job/api/src/main/java/org/eclipse/kapua/service/job/execution/JobExecutionXmlRegistry.java @@ -44,7 +44,4 @@ public JobExecutionCreator newJobExecutionCreator() { return jobExecutionFactory.newCreator(null); } - public JobExecutionQuery newQuery() { - return jobExecutionFactory.newQuery(null); - } } diff --git a/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/JobStepFactory.java b/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/JobStepFactory.java index fa3b3a8bf5c..8f0f680d81b 100644 --- a/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/JobStepFactory.java +++ b/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/JobStepFactory.java @@ -21,7 +21,7 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface JobStepFactory extends KapuaEntityFactory { +public interface JobStepFactory extends KapuaEntityFactory { /** * Instantiates a new {@link JobStepProperty}. diff --git a/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/JobStepQuery.java b/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/JobStepQuery.java deleted file mode 100644 index 464319a1fab..00000000000 --- a/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/JobStepQuery.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017, 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.service.job.step; - -import org.eclipse.kapua.model.query.KapuaQuery; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - -/** - * {@link JobStep} {@link KapuaQuery} definition. - * - * @see KapuaQuery - * @since 1.0.0 - */ -@XmlRootElement(name = "query") -@XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = JobStepXmlRegistry.class, factoryMethod = "newQuery") -public interface JobStepQuery extends KapuaQuery { -} diff --git a/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/JobStepService.java b/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/JobStepService.java index 1f05f980635..76b2653fd29 100644 --- a/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/JobStepService.java +++ b/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/JobStepService.java @@ -19,9 +19,8 @@ import org.eclipse.kapua.service.job.step.definition.JobStepProperty; /** - * {@link JobStepService} exposes APIs to manage JobStep objects.
    - * It includes APIs to create, update, find, list and delete Jobs.
    - * Instances of the JobStepService can be acquired through the ServiceLocator object. + * {@link JobStepService} exposes APIs to manage JobStep objects.
    It includes APIs to create, update, find, list and delete Jobs.
    Instances of the JobStepService can be acquired through the + * ServiceLocator object. * * @since 1.0 */ @@ -31,7 +30,8 @@ public interface JobStepService extends KapuaEntityService { +public interface JobStepDefinitionFactory extends KapuaEntityFactory { /** * Instantiates a new {@link JobStepProperty}. diff --git a/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/definition/JobStepDefinitionQuery.java b/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/definition/JobStepDefinitionQuery.java index be9874b0465..6bc361be1f8 100644 --- a/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/definition/JobStepDefinitionQuery.java +++ b/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/definition/JobStepDefinitionQuery.java @@ -12,13 +12,15 @@ *******************************************************************************/ package org.eclipse.kapua.service.job.step.definition; -import org.eclipse.kapua.model.query.KapuaQuery; - import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.model.query.AbstractKapuaNamedQuery; +import org.eclipse.kapua.model.query.KapuaQuery; + /** * {@link JobStepDefinition} {@link KapuaQuery} definition. * @@ -27,6 +29,31 @@ */ @XmlRootElement(name = "query") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = JobStepDefinitionXmlRegistry.class, factoryMethod = "newQuery") -public interface JobStepDefinitionQuery extends KapuaQuery { +@XmlType +public class JobStepDefinitionQuery extends AbstractKapuaNamedQuery { + + public JobStepDefinitionQuery() { + } + + /** + * Constructor. + * + * @param scopeId + * The {@link #getScopeId()}. + * @since 1.0.0 + */ + public JobStepDefinitionQuery(KapuaId scopeId) { + super(scopeId); + } + + /** + * This enables {@link JobStepDefinitionQuery} to retrieve also not scoped {@link JobStepDefinition}s since they are public. + * + * @return {@code true} + * @since 2.0.0 + */ + @Override + public boolean getNotScopedEntities() { + return true; + } } diff --git a/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/definition/JobStepDefinitionXmlRegistry.java b/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/definition/JobStepDefinitionXmlRegistry.java index 1ec589e7d1e..ab20432afc9 100644 --- a/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/definition/JobStepDefinitionXmlRegistry.java +++ b/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/definition/JobStepDefinitionXmlRegistry.java @@ -43,8 +43,4 @@ public JobStepDefinition newJobStepDefinition() { public JobStepDefinitionCreator newJobStepDefinitionCreator() { return jobStepDefinitionFactory.newCreator(null); } - - public JobStepDefinitionQuery newQuery() { - return jobStepDefinitionFactory.newQuery(null); - } } diff --git a/service/job/api/src/main/java/org/eclipse/kapua/service/job/targets/JobTargetFactory.java b/service/job/api/src/main/java/org/eclipse/kapua/service/job/targets/JobTargetFactory.java index 6e6870017c1..953e0690de9 100644 --- a/service/job/api/src/main/java/org/eclipse/kapua/service/job/targets/JobTargetFactory.java +++ b/service/job/api/src/main/java/org/eclipse/kapua/service/job/targets/JobTargetFactory.java @@ -20,6 +20,6 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface JobTargetFactory extends KapuaEntityFactory { +public interface JobTargetFactory extends KapuaEntityFactory { } diff --git a/service/job/api/src/main/java/org/eclipse/kapua/service/job/targets/JobTargetQuery.java b/service/job/api/src/main/java/org/eclipse/kapua/service/job/targets/JobTargetQuery.java deleted file mode 100644 index 237d12699fa..00000000000 --- a/service/job/api/src/main/java/org/eclipse/kapua/service/job/targets/JobTargetQuery.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017, 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.service.job.targets; - -import org.eclipse.kapua.model.query.KapuaQuery; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - -/** - * {@link JobTarget} {@link KapuaQuery} definition. - * - * @see KapuaQuery - * @since 1.0.0 - */ -@XmlRootElement(name = "query") -@XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = JobTargetXmlRegistry.class, factoryMethod = "newQuery") -public interface JobTargetQuery extends KapuaQuery { -} diff --git a/service/job/api/src/main/java/org/eclipse/kapua/service/job/targets/JobTargetService.java b/service/job/api/src/main/java/org/eclipse/kapua/service/job/targets/JobTargetService.java index 91612a3c200..f5e859eb4f6 100644 --- a/service/job/api/src/main/java/org/eclipse/kapua/service/job/targets/JobTargetService.java +++ b/service/job/api/src/main/java/org/eclipse/kapua/service/job/targets/JobTargetService.java @@ -18,9 +18,8 @@ import org.eclipse.kapua.service.KapuaUpdatableEntityService; /** - * {@link JobTargetService} exposes APIs to manage JobTarget objects.
    - * It includes APIs to create, update, find, list and delete Jobs.
    - * Instances of the JobTargetService can be acquired through the ServiceLocator object. + * {@link JobTargetService} exposes APIs to manage JobTarget objects.
    It includes APIs to create, update, find, list and delete Jobs.
    Instances of the JobTargetService can be acquired through + * the ServiceLocator object. * * @since 1.0 */ @@ -30,7 +29,8 @@ public interface JobTargetService extends KapuaEntityService extends AbstractMatchPredicate implements JobMatchPredicate { - - /** - * Constructor. - * - * @param matchTerm - * @since 2.0.0 - */ - public JobMatchPredicateImpl(T matchTerm) { - this.attributeNames = Arrays.asList( - JobAttributes.NAME, - JobAttributes.DESCRIPTION - ); - this.matchTerm = matchTerm; - } - -} \ No newline at end of file diff --git a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/internal/JobQueryImpl.java b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/internal/JobQueryImpl.java deleted file mode 100644 index 4d9b095a7ca..00000000000 --- a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/internal/JobQueryImpl.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017, 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.service.job.internal; - -import org.eclipse.kapua.commons.model.query.AbstractKapuaNamedQuery; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.service.job.JobMatchPredicate; -import org.eclipse.kapua.service.job.JobQuery; - -/** - * {@link JobQuery} implementation. - * - * @since 1.0.0 - */ -public class JobQueryImpl extends AbstractKapuaNamedQuery implements JobQuery { - - /** - * Constructor. - * - * @param scopeId The {@link #getScopeId()}. - * @since 1.0.0 - */ - public JobQueryImpl(KapuaId scopeId) { - super(scopeId); - } - - @Override - public JobMatchPredicate matchPredicate(T matchTerm) { - return new JobMatchPredicateImpl<>(matchTerm); - } -} diff --git a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/definition/internal/JobStepDefinitionAligner.java b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/definition/internal/JobStepDefinitionAligner.java index 30c7818bc74..6357f515446 100644 --- a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/definition/internal/JobStepDefinitionAligner.java +++ b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/definition/internal/JobStepDefinitionAligner.java @@ -30,6 +30,7 @@ import org.eclipse.kapua.locator.initializers.KapuaInitializingMethod; import org.eclipse.kapua.model.KapuaNamedEntity; import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.model.query.KapuaQuery; import org.eclipse.kapua.service.job.step.definition.JobStepDefinition; import org.eclipse.kapua.service.job.step.definition.JobStepDefinitionRepository; import org.eclipse.kapua.service.job.step.definition.JobStepProperty; @@ -100,7 +101,7 @@ public void populate() { KapuaSecurityUtils.doPrivileged(() -> { txManager.execute(tx -> { // Retrieve all JobStepDefinition from the database - List dbJobStepDefinitions = jobStepDefinitionRepository.query(tx, new JobStepDefinitionQueryImpl(null)).getItems() + List dbJobStepDefinitions = jobStepDefinitionRepository.query(tx, new KapuaQuery((KapuaId) null)).getItems() .stream() .map(dbJobStepDefinition -> (JobStepDefinitionImpl) dbJobStepDefinition) .collect(Collectors.toList()); diff --git a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/definition/internal/JobStepDefinitionFactoryImpl.java b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/definition/internal/JobStepDefinitionFactoryImpl.java index 120038b64ca..3774d45e89a 100644 --- a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/definition/internal/JobStepDefinitionFactoryImpl.java +++ b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/definition/internal/JobStepDefinitionFactoryImpl.java @@ -19,7 +19,6 @@ import org.eclipse.kapua.service.job.step.definition.JobStepDefinition; import org.eclipse.kapua.service.job.step.definition.JobStepDefinitionCreator; import org.eclipse.kapua.service.job.step.definition.JobStepDefinitionFactory; -import org.eclipse.kapua.service.job.step.definition.JobStepDefinitionQuery; import org.eclipse.kapua.service.job.step.definition.JobStepProperty; /** @@ -40,11 +39,6 @@ public JobStepDefinitionCreator newCreator(KapuaId scopeId) { return new JobStepDefinitionCreatorImpl(scopeId); } - @Override - public JobStepDefinitionQuery newQuery(KapuaId scopeId) { - return new JobStepDefinitionQueryImpl(scopeId); - } - @Override public JobStepProperty newStepProperty(String name, String type, String value) { return new JobStepPropertyImpl(name, type, value, null); diff --git a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/definition/internal/JobStepDefinitionQueryImpl.java b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/definition/internal/JobStepDefinitionQueryImpl.java deleted file mode 100644 index 300924d51e7..00000000000 --- a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/definition/internal/JobStepDefinitionQueryImpl.java +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017, 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.service.job.step.definition.internal; - -import org.eclipse.kapua.commons.model.query.AbstractKapuaNamedQuery; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.service.job.step.definition.JobStepDefinition; -import org.eclipse.kapua.service.job.step.definition.JobStepDefinitionQuery; - -/** - * {@link JobStepDefinitionQuery} definition. - * - * @since 1.0.0 - */ -public class JobStepDefinitionQueryImpl extends AbstractKapuaNamedQuery implements JobStepDefinitionQuery { - - /** - * Constructor. - * - * @param scopeId - * The {@link #getScopeId()}. - * @since 1.0.0 - */ - public JobStepDefinitionQueryImpl(KapuaId scopeId) { - super(scopeId); - } - - /** - * This enables {@link JobStepDefinitionQuery} to retrieve also not scoped {@link JobStepDefinition}s since they are public. - * - * @return {@code true} - * @since 2.0.0 - */ - @Override - public boolean getNotScopedEntities() { - return true; - } -} diff --git a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/definition/internal/JobStepDefinitionServiceImpl.java b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/definition/internal/JobStepDefinitionServiceImpl.java index 2458ec68fbf..e61c9d03a2b 100755 --- a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/definition/internal/JobStepDefinitionServiceImpl.java +++ b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/definition/internal/JobStepDefinitionServiceImpl.java @@ -13,6 +13,7 @@ package org.eclipse.kapua.service.job.step.definition.internal; import java.util.Optional; + import javax.inject.Singleton; import org.eclipse.kapua.KapuaDuplicateNameInAnotherAccountError; @@ -120,7 +121,7 @@ public JobStepDefinition find(KapuaId scopeId, KapuaId stepDefinitionId) throws // Check Access authorizationService.checkPermission(permissionFactory.newPermission(Domains.JOB, Actions.read, scopeId)); - final JobStepDefinitionQuery query = new JobStepDefinitionQueryImpl(scopeId); + final JobStepDefinitionQuery query = new JobStepDefinitionQuery(scopeId); query.setPredicate(query.attributePredicate(JobStepDefinitionAttributes.ENTITY_ID, stepDefinitionId)); // Do find diff --git a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/internal/JobStepFactoryImpl.java b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/internal/JobStepFactoryImpl.java index ad8f9356333..36c9062a8b2 100644 --- a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/internal/JobStepFactoryImpl.java +++ b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/internal/JobStepFactoryImpl.java @@ -18,7 +18,6 @@ import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.job.step.JobStepCreator; import org.eclipse.kapua.service.job.step.JobStepFactory; -import org.eclipse.kapua.service.job.step.JobStepQuery; import org.eclipse.kapua.service.job.step.definition.JobStepProperty; import org.eclipse.kapua.service.job.step.definition.internal.JobStepPropertyImpl; @@ -40,11 +39,6 @@ public JobStepCreator newCreator(KapuaId scopeId) { return new JobStepCreatorImpl(scopeId); } - @Override - public JobStepQuery newQuery(KapuaId scopeId) { - return new JobStepQueryImpl(scopeId); - } - @Override public JobStepProperty newStepProperty(String name, String propertyType, String propertyValue) { return new JobStepPropertyImpl(name, propertyType, propertyValue, null); diff --git a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/internal/JobStepModule.java b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/internal/JobStepModule.java index feef46165be..ae0070d5bbc 100644 --- a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/internal/JobStepModule.java +++ b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/internal/JobStepModule.java @@ -17,9 +17,7 @@ import org.eclipse.kapua.commons.core.AbstractKapuaModule; import org.eclipse.kapua.commons.jpa.KapuaJpaRepositoryConfiguration; -import org.eclipse.kapua.commons.jpa.KapuaJpaTxManagerFactory; import org.eclipse.kapua.commons.util.xml.XmlUtil; -import org.eclipse.kapua.model.query.QueryFactory; import org.eclipse.kapua.service.authorization.AuthorizationService; import org.eclipse.kapua.service.authorization.permission.PermissionFactory; import org.eclipse.kapua.service.job.execution.JobExecutionFactory; @@ -55,8 +53,6 @@ JobStepService jobStepService(AuthorizationService authorizationService, JobExecutionService jobExecutionService, JobExecutionFactory jobExecutionFactory, JobStepDefinitionRepository jobStepDefinitionRepository, - QueryFactory queryFactory, - KapuaJpaTxManagerFactory jpaTxManagerFactory, XmlUtil xmlUtil) { return new JobStepServiceImpl(authorizationService, permissionFactory, diff --git a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/internal/JobStepQueryImpl.java b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/internal/JobStepQueryImpl.java deleted file mode 100644 index 1f1123f3877..00000000000 --- a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/internal/JobStepQueryImpl.java +++ /dev/null @@ -1,35 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017, 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.service.job.step.internal; - -import org.eclipse.kapua.commons.model.query.AbstractKapuaNamedQuery; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.service.job.step.JobStepQuery; - -/** - * {@link JobStepQuery} definition. - * - * @since 1.0.0 - */ -public class JobStepQueryImpl extends AbstractKapuaNamedQuery implements JobStepQuery { - - /** - * Constructor. - * - * @param scopeId The {@link #getScopeId()}. - * @since 1.0.0 - */ - public JobStepQueryImpl(KapuaId scopeId) { - super(scopeId); - } -} diff --git a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/internal/JobStepServiceImpl.java b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/internal/JobStepServiceImpl.java index ead07713317..f811249472f 100644 --- a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/internal/JobStepServiceImpl.java +++ b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/internal/JobStepServiceImpl.java @@ -14,10 +14,10 @@ import java.util.List; import java.util.regex.Pattern; + import javax.inject.Singleton; import javax.xml.bind.DatatypeConverter; -import com.google.common.base.Strings; import org.eclipse.kapua.KapuaDuplicateNameException; import org.eclipse.kapua.KapuaEntityNotFoundException; import org.eclipse.kapua.KapuaException; @@ -47,7 +47,6 @@ import org.eclipse.kapua.service.job.step.JobStepFactory; import org.eclipse.kapua.service.job.step.JobStepIndex; import org.eclipse.kapua.service.job.step.JobStepListResult; -import org.eclipse.kapua.service.job.step.JobStepQuery; import org.eclipse.kapua.service.job.step.JobStepRepository; import org.eclipse.kapua.service.job.step.JobStepService; import org.eclipse.kapua.service.job.step.definition.JobStepDefinition; @@ -57,6 +56,8 @@ import org.eclipse.kapua.storage.TxManager; import org.slf4j.LoggerFactory; +import com.google.common.base.Strings; + /** * {@link JobStepService} implementation. * @@ -143,7 +144,7 @@ public JobStep create(JobStepCreator jobStepCreator) throws KapuaException { throw new CannotModifyJobStepsException(jobStepCreator.getJobId()); } // Populate JobStepCreator.stepIndex if not specified - final JobStepQuery query = new JobStepQueryImpl(jobStepCreator.getScopeId()); + final KapuaQuery query = new KapuaQuery(jobStepCreator.getScopeId()); if (jobStepCreator.getStepIndex() == null) { query.setPredicate(query.attributePredicate(JobStepAttributes.JOB_ID, jobStepCreator.getJobId())); query.setSortCriteria(query.fieldSortCriteria(JobStepAttributes.STEP_INDEX, SortOrder.DESCENDING)); @@ -155,7 +156,7 @@ public JobStep create(JobStepCreator jobStepCreator) throws KapuaException { jobStepCreator.setStepIndex(lastJobStep != null ? lastJobStep.getStepIndex() + 1 : JobStepIndex.FIRST); } // Check if JobStep.stepIndex is duplicate. - JobStepQuery jobStepQuery = new JobStepQueryImpl(jobStepCreator.getScopeId()); + KapuaQuery jobStepQuery = new KapuaQuery(jobStepCreator.getScopeId()); jobStepQuery.setPredicate( jobStepQuery.andPredicate( jobStepQuery.attributePredicate(JobStepAttributes.JOB_ID, jobStepCreator.getJobId()), @@ -168,15 +169,15 @@ public JobStep create(JobStepCreator jobStepCreator) throws KapuaException { if (jobStepAtIndex != null) { // JobStepCreator inserted between existing JobSteps. // Moving existing JobSteps + 1 - JobStepQuery selectorJobStepQuery = new JobStepQueryImpl(jobStepAtIndex.getScopeId()); - selectorJobStepQuery.setPredicate( - selectorJobStepQuery.andPredicate( - selectorJobStepQuery.attributePredicate(JobStepAttributes.JOB_ID, jobStepAtIndex.getJobId()), - selectorJobStepQuery.attributePredicate(JobStepAttributes.STEP_INDEX, jobStepAtIndex.getStepIndex(), Operator.GREATER_THAN_OR_EQUAL) + KapuaQuery selectorKapuaQuery = new KapuaQuery(jobStepAtIndex.getScopeId()); + selectorKapuaQuery.setPredicate( + selectorKapuaQuery.andPredicate( + selectorKapuaQuery.attributePredicate(JobStepAttributes.JOB_ID, jobStepAtIndex.getJobId()), + selectorKapuaQuery.attributePredicate(JobStepAttributes.STEP_INDEX, jobStepAtIndex.getStepIndex(), Operator.GREATER_THAN_OR_EQUAL) ) ); - shiftJobStepPosition(tx, selectorJobStepQuery, +1); + shiftJobStepPosition(tx, selectorKapuaQuery, +1); } // Create JobStep JobStep jobStep = jobStepFactory.newEntity(jobStepCreator.getScopeId()); @@ -240,29 +241,29 @@ public JobStep update(JobStep jobStep) throws KapuaException { if (jobStep.getStepIndex() < currentJobStep.getStepIndex()) { // Moved before current position. // Shift JobSteps +1 - JobStepQuery selectorJobStepQuery = new JobStepQueryImpl(jobStep.getScopeId()); - selectorJobStepQuery.setPredicate( - selectorJobStepQuery.andPredicate( - selectorJobStepQuery.attributePredicate(JobStepAttributes.JOB_ID, jobStep.getJobId()), - selectorJobStepQuery.attributePredicate(JobStepAttributes.STEP_INDEX, jobStep.getStepIndex(), Operator.GREATER_THAN_OR_EQUAL), - selectorJobStepQuery.attributePredicate(JobStepAttributes.STEP_INDEX, currentJobStep.getStepIndex(), Operator.LESS_THAN) + KapuaQuery selectorKapuaQuery = new KapuaQuery(jobStep.getScopeId()); + selectorKapuaQuery.setPredicate( + selectorKapuaQuery.andPredicate( + selectorKapuaQuery.attributePredicate(JobStepAttributes.JOB_ID, jobStep.getJobId()), + selectorKapuaQuery.attributePredicate(JobStepAttributes.STEP_INDEX, jobStep.getStepIndex(), Operator.GREATER_THAN_OR_EQUAL), + selectorKapuaQuery.attributePredicate(JobStepAttributes.STEP_INDEX, currentJobStep.getStepIndex(), Operator.LESS_THAN) ) ); - shiftJobStepPosition(tx, selectorJobStepQuery, +1); + shiftJobStepPosition(tx, selectorKapuaQuery, +1); } else { // Moved after current position. // Shift JobSteps -1 - JobStepQuery selectorJobStepQuery = new JobStepQueryImpl(jobStep.getScopeId()); - selectorJobStepQuery.setPredicate( - selectorJobStepQuery.andPredicate( - selectorJobStepQuery.attributePredicate(JobStepAttributes.JOB_ID, jobStep.getJobId()), - selectorJobStepQuery.attributePredicate(JobStepAttributes.STEP_INDEX, currentJobStep.getStepIndex(), Operator.GREATER_THAN), - selectorJobStepQuery.attributePredicate(JobStepAttributes.STEP_INDEX, jobStep.getStepIndex(), Operator.LESS_THAN_OR_EQUAL) + KapuaQuery selectorKapuaQuery = new KapuaQuery(jobStep.getScopeId()); + selectorKapuaQuery.setPredicate( + selectorKapuaQuery.andPredicate( + selectorKapuaQuery.attributePredicate(JobStepAttributes.JOB_ID, jobStep.getJobId()), + selectorKapuaQuery.attributePredicate(JobStepAttributes.STEP_INDEX, currentJobStep.getStepIndex(), Operator.GREATER_THAN), + selectorKapuaQuery.attributePredicate(JobStepAttributes.STEP_INDEX, jobStep.getStepIndex(), Operator.LESS_THAN_OR_EQUAL) ) ); - shiftJobStepPosition(tx, selectorJobStepQuery, -1); + shiftJobStepPosition(tx, selectorKapuaQuery, -1); } } @@ -316,7 +317,7 @@ public void delete(KapuaId scopeId, KapuaId jobStepId) throws KapuaException { final JobStep jobStep = jobStepRepository.find(tx, scopeId, jobStepId) .orElseThrow(() -> new KapuaEntityNotFoundException(JobStep.TYPE, jobStepId)); // Check Job Executions - final JobExecutionQuery jobExecutionQuery = jobExecutionFactory.newQuery(scopeId); + final JobExecutionQuery jobExecutionQuery = new JobExecutionQuery(scopeId); jobExecutionQuery.setPredicate( jobExecutionQuery.attributePredicate(JobExecutionAttributes.JOB_ID, jobStep.getJobId()) ); @@ -330,7 +331,7 @@ public void delete(KapuaId scopeId, KapuaId jobStepId) throws KapuaException { jobStepRepository.delete(tx, scopeId, jobStepId); // Shift following steps of one position in the step index - JobStepQuery query = new JobStepQueryImpl(scopeId); + KapuaQuery query = new KapuaQuery(scopeId); query.setPredicate( query.andPredicate( @@ -362,18 +363,18 @@ public int getJobStepPropertyMaxLength() throws KapuaException { // Private methods /** - * Shifts {@link JobStep} matched by the given {@link JobStepQuery} according to the given increment. + * Shifts {@link JobStep} matched by the given {@link KapuaQuery} according to the given increment. * * @param tx * The {@link TxContext} which is owning the transaction. * @param selectorQuery - * The selector {@link JobStepQuery}. + * The selector {@link KapuaQuery}. * @param increment * The increment o apply to the matched {@link JobStep}s * @throws KapuaException * @since 2.0.0 */ - private void shiftJobStepPosition(TxContext tx, JobStepQuery selectorQuery, int increment) throws KapuaException { + private void shiftJobStepPosition(TxContext tx, KapuaQuery selectorQuery, int increment) throws KapuaException { selectorQuery.setSortCriteria(selectorQuery.fieldSortCriteria(JobStepAttributes.STEP_INDEX, SortOrder.ASCENDING)); JobStepListResult followingJobStepListResult = jobStepRepository.query(tx, selectorQuery); diff --git a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/targets/internal/JobTargetFactoryImpl.java b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/targets/internal/JobTargetFactoryImpl.java index cfd25291c12..44b929c4548 100644 --- a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/targets/internal/JobTargetFactoryImpl.java +++ b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/targets/internal/JobTargetFactoryImpl.java @@ -19,7 +19,6 @@ import org.eclipse.kapua.service.job.targets.JobTarget; import org.eclipse.kapua.service.job.targets.JobTargetCreator; import org.eclipse.kapua.service.job.targets.JobTargetFactory; -import org.eclipse.kapua.service.job.targets.JobTargetQuery; /** * {@link JobTargetFactory} implementation. @@ -39,11 +38,6 @@ public JobTargetCreator newCreator(KapuaId scopeId) { return new JobTargetCreatorImpl(scopeId); } - @Override - public JobTargetQuery newQuery(KapuaId scopeId) { - return new JobTargetQueryImpl(scopeId); - } - @Override public JobTarget clone(JobTarget jobTarget) { try { diff --git a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/targets/internal/JobTargetQueryImpl.java b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/targets/internal/JobTargetQueryImpl.java deleted file mode 100644 index 4c8892c829e..00000000000 --- a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/targets/internal/JobTargetQueryImpl.java +++ /dev/null @@ -1,35 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017, 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.service.job.targets.internal; - -import org.eclipse.kapua.commons.model.query.AbstractKapuaQuery; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.service.job.targets.JobTargetQuery; - -/** - * {@link JobTargetQuery} implementation. - * - * @since 1.0.0 - */ -public class JobTargetQueryImpl extends AbstractKapuaQuery implements JobTargetQuery { - - /** - * Constructor. - * - * @param scopeId The {@link #getScopeId()}. - * @since 1.0.0 - */ - public JobTargetQueryImpl(KapuaId scopeId) { - super(scopeId); - } -} diff --git a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/targets/internal/JobTargetServiceImpl.java b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/targets/internal/JobTargetServiceImpl.java index 001df696bd9..5d53cfdc278 100644 --- a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/targets/internal/JobTargetServiceImpl.java +++ b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/targets/internal/JobTargetServiceImpl.java @@ -12,6 +12,13 @@ *******************************************************************************/ package org.eclipse.kapua.service.job.targets.internal; +import java.util.AbstractMap; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import javax.inject.Singleton; + import org.eclipse.kapua.KapuaEntityNotFoundException; import org.eclipse.kapua.KapuaEntityUniquenessException; import org.eclipse.kapua.KapuaException; @@ -29,18 +36,11 @@ import org.eclipse.kapua.service.job.targets.JobTargetCreator; import org.eclipse.kapua.service.job.targets.JobTargetFactory; import org.eclipse.kapua.service.job.targets.JobTargetListResult; -import org.eclipse.kapua.service.job.targets.JobTargetQuery; import org.eclipse.kapua.service.job.targets.JobTargetRepository; import org.eclipse.kapua.service.job.targets.JobTargetService; import org.eclipse.kapua.service.job.targets.JobTargetStatus; import org.eclipse.kapua.storage.TxManager; -import javax.inject.Singleton; -import java.util.AbstractMap; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - /** * {@link JobTargetService} implementation. * @@ -84,7 +84,7 @@ public JobTarget create(JobTargetCreator jobTargetCreator) throws KapuaException final Job job = jobRepository.find(tx, jobTargetCreator.getScopeId(), jobTargetCreator.getJobId()) .orElseThrow(() -> new KapuaEntityNotFoundException(Job.TYPE, jobTargetCreator.getJobId())); // Check duplicate - JobTargetQuery jobTargetQuery = new JobTargetQueryImpl(jobTargetCreator.getScopeId()); + KapuaQuery jobTargetQuery = new KapuaQuery(jobTargetCreator.getScopeId()); jobTargetQuery.setPredicate( jobTargetQuery.andPredicate( jobTargetQuery.attributePredicate(JobTargetAttributes.JOB_ID, jobTargetCreator.getJobId()), diff --git a/service/job/test-steps/src/main/java/org/eclipse/kapua/service/job/steps/JobExecutionServiceSteps.java b/service/job/test-steps/src/main/java/org/eclipse/kapua/service/job/steps/JobExecutionServiceSteps.java index 8315e9a5d02..6eba218e487 100644 --- a/service/job/test-steps/src/main/java/org/eclipse/kapua/service/job/steps/JobExecutionServiceSteps.java +++ b/service/job/test-steps/src/main/java/org/eclipse/kapua/service/job/steps/JobExecutionServiceSteps.java @@ -200,7 +200,7 @@ private void checkJobHasExecution(Job job, int expectedNumberOfExecution) throws @When("I count the execution items for the current job") public void countExecutionsForJob() throws Exception { Job job = (Job) stepData.get("Job"); - JobExecutionQuery tmpQuery = jobExecutionFactory.newQuery(getCurrentScopeId()); + JobExecutionQuery tmpQuery = new JobExecutionQuery(getCurrentScopeId()); tmpQuery.setPredicate(tmpQuery.attributePredicate(JobExecutionAttributes.JOB_ID, job.getId(), AttributePredicate.Operator.EQUAL)); updateCount(() -> (int) jobExecutionService.count(tmpQuery)); } @@ -208,7 +208,7 @@ public void countExecutionsForJob() throws Exception { @Then("I query for the execution items for the current job") public void queryExecutionsForJobWithPackages() throws Exception { Job job = (Job) stepData.get("Job"); - JobExecutionQuery tmpQuery = jobExecutionFactory.newQuery(getCurrentScopeId()); + JobExecutionQuery tmpQuery = new JobExecutionQuery(getCurrentScopeId()); tmpQuery.setPredicate(tmpQuery.attributePredicate(JobExecutionAttributes.JOB_ID, job.getId(), AttributePredicate.Operator.EQUAL)); primeException(); try { @@ -235,7 +235,7 @@ public void queryExecutionsForJobWithStartDateInPast() throws Exception { private void queryExecutionsForJobWithStartDate(Date startDate) throws Exception { final Job job = (Job) stepData.get("Job"); - final JobExecutionQuery tmpQuery = jobExecutionFactory.newQuery(getCurrentScopeId()); + final JobExecutionQuery tmpQuery = new JobExecutionQuery(getCurrentScopeId()); final AndPredicate andPredicate = tmpQuery.andPredicate(tmpQuery.attributePredicate(JobExecutionAttributes.JOB_ID, job.getId())); andPredicate.and(tmpQuery.attributePredicate(JobExecutionAttributes.STARTED_ON, startDate, AttributePredicate.Operator.GREATER_THAN_OR_EQUAL)); tmpQuery.setPredicate(andPredicate); @@ -305,7 +305,7 @@ private void iQueryForTheExecutionItemsForTheCurrentJobAndICountOrMoreInternal(i } private JobExecutionListResult getExecutionsForJob(Job job) throws Exception { - JobExecutionQuery tmpQuery = jobExecutionFactory.newQuery(getCurrentScopeId()); + JobExecutionQuery tmpQuery = new JobExecutionQuery(getCurrentScopeId()); tmpQuery.setPredicate(tmpQuery.attributePredicate(JobExecutionAttributes.JOB_ID, job.getId(), AttributePredicate.Operator.EQUAL)); return jobExecutionService.query(tmpQuery); } @@ -370,7 +370,7 @@ private void iQueryForTheJobWithTheNameAndJobExecutionCountInternal(String jobNa } private Job getJobAndUpdateStepData(String jobName) throws Exception { - JobQuery tmpQuery = jobFactory.newQuery(getCurrentScopeId()); + JobQuery tmpQuery = new JobQuery(getCurrentScopeId()); tmpQuery.setPredicate(tmpQuery.attributePredicate(JobAttributes.NAME, jobName)); stepData.remove("Job"); @@ -450,7 +450,6 @@ public void checkThatNoExecutionWasFound() { public void testTheJobExecutionFactory() { Assert.assertNotNull(jobExecutionFactory.newCreator(SYS_SCOPE_ID)); Assert.assertNotNull(jobExecutionFactory.newEntity(SYS_SCOPE_ID)); - Assert.assertNotNull(jobExecutionFactory.newQuery(SYS_SCOPE_ID)); } // Private methods diff --git a/service/job/test-steps/src/main/java/org/eclipse/kapua/service/job/steps/JobServiceSteps.java b/service/job/test-steps/src/main/java/org/eclipse/kapua/service/job/steps/JobServiceSteps.java index 71e02233eaa..f650eea81c3 100644 --- a/service/job/test-steps/src/main/java/org/eclipse/kapua/service/job/steps/JobServiceSteps.java +++ b/service/job/test-steps/src/main/java/org/eclipse/kapua/service/job/steps/JobServiceSteps.java @@ -263,24 +263,24 @@ public void findJobInDatabase() throws Exception { @When("I count the jobs in the database") public void countJobsInDatabase() throws Exception { - updateCount(() -> (int) jobService.count(jobFactory.newQuery(getCurrentScopeId()))); + updateCount(() -> (int) jobService.count(new JobQuery(getCurrentScopeId()))); } @When("I query for jobs in scope {int}") public void countJobsInScope(int id) throws Exception { - updateCount(() -> jobService.query(jobFactory.newQuery(getKapuaId(id))).getSize()); + updateCount(() -> jobService.query(new JobQuery(getKapuaId(id))).getSize()); } @When("I count the jobs with the name starting with {string}") public void countJobsWithName(String name) throws Exception { - JobQuery tmpQuery = jobFactory.newQuery(getCurrentScopeId()); + JobQuery tmpQuery = new JobQuery(getCurrentScopeId()); tmpQuery.setPredicate(tmpQuery.attributePredicate(JobAttributes.NAME, name, Operator.STARTS_WITH)); updateCount(() -> jobService.query(tmpQuery).getSize()); } @When("I query for the job with the name {string}") public void queryForJobWithName(String name) throws Exception { - JobQuery tmpQuery = jobFactory.newQuery(getCurrentScopeId()); + JobQuery tmpQuery = new JobQuery(getCurrentScopeId()); tmpQuery.setPredicate(tmpQuery.attributePredicate(JobAttributes.NAME, name)); primeException(); try { @@ -341,7 +341,7 @@ public void testJobFactorySanity() { primeException(); Assert.assertNotNull("The job factory returned a null creator!", jobFactory.newCreator(SYS_SCOPE_ID)); Assert.assertNotNull("The job factory returned a null job object!", jobFactory.newEntity(SYS_SCOPE_ID)); - Assert.assertNotNull("The job factory returned a null job query!", jobFactory.newQuery(SYS_SCOPE_ID)); + Assert.assertNotNull("The job factory returned a null job query!", new JobQuery(SYS_SCOPE_ID)); } @Then("I find a job with name {string}") @@ -378,7 +378,7 @@ public void iTryToEditJobToName(String jobName) throws Throwable { @When("I query for the job with the name {string} and I find it") public void iQueryForTheJobWithTheNameAndIFoundIt(String jobName) throws Exception { - JobQuery tmpQuery = jobFactory.newQuery(getCurrentScopeId()); + JobQuery tmpQuery = new JobQuery(getCurrentScopeId()); tmpQuery.setPredicate(tmpQuery.attributePredicate(JobAttributes.NAME, jobName)); primeException(); try { @@ -393,7 +393,7 @@ public void iQueryForTheJobWithTheNameAndIFoundIt(String jobName) throws Excepti @When("I query for the job with term match {string}") public void iQueryForTheJobMatchTerm(String matchTerm) throws Exception { - JobQuery tmpQuery = jobFactory.newQuery(getCurrentScopeId()); + JobQuery tmpQuery = new JobQuery(getCurrentScopeId()); tmpQuery.setPredicate(tmpQuery.matchPredicate(matchTerm)); @@ -437,7 +437,7 @@ public void iTryToUpdateJobNameWithInvalidSymbolsInName(String invalidCharacters @Then("I change name of job from {string} to {string}") public void iChangeNameOfJobFromTo(String oldName, String newName) throws Throwable { try { - JobQuery query = jobFactory.newQuery(getCurrentScopeId()); + JobQuery query = new JobQuery(getCurrentScopeId()); query.setPredicate(query.attributePredicate(JobAttributes.NAME, oldName, Operator.EQUAL)); JobListResult queryResult = jobService.query(query); Job job = queryResult.getFirstItem(); @@ -458,7 +458,7 @@ public void thereIsNoJobWithNameInDatabase(String jobName) { @When("I change the job description from {string} to {string}") public void iChangeTheJobDescriptionFromTo(String oldDescription, String newDescription) throws Throwable { try { - JobQuery query = jobFactory.newQuery(getCurrentScopeId()); + JobQuery query = new JobQuery(getCurrentScopeId()); query.setPredicate(query.attributePredicate(JobAttributes.DESCRIPTION, oldDescription, Operator.EQUAL)); JobListResult queryResult = jobService.query(query); Job job = queryResult.getFirstItem(); diff --git a/service/job/test-steps/src/main/java/org/eclipse/kapua/service/job/steps/JobServiceTestBase.java b/service/job/test-steps/src/main/java/org/eclipse/kapua/service/job/steps/JobServiceTestBase.java index c6c75a0cce8..08ee0e540e5 100644 --- a/service/job/test-steps/src/main/java/org/eclipse/kapua/service/job/steps/JobServiceTestBase.java +++ b/service/job/test-steps/src/main/java/org/eclipse/kapua/service/job/steps/JobServiceTestBase.java @@ -67,7 +67,7 @@ protected JobServiceTestBase(StepData stepData) { } public Job findJob(String jobName) throws Exception { - JobQuery jobQuery = jobFactory.newQuery(getCurrentScopeId()); + JobQuery jobQuery = new JobQuery(getCurrentScopeId()); jobQuery.setPredicate( jobQuery.attributePredicate(JobAttributes.NAME, jobName) ); diff --git a/service/job/test-steps/src/main/java/org/eclipse/kapua/service/job/steps/JobStepDefinitionServiceSteps.java b/service/job/test-steps/src/main/java/org/eclipse/kapua/service/job/steps/JobStepDefinitionServiceSteps.java index 96a18e4f432..9ce506eb522 100644 --- a/service/job/test-steps/src/main/java/org/eclipse/kapua/service/job/steps/JobStepDefinitionServiceSteps.java +++ b/service/job/test-steps/src/main/java/org/eclipse/kapua/service/job/steps/JobStepDefinitionServiceSteps.java @@ -25,6 +25,7 @@ import org.eclipse.kapua.service.job.step.definition.JobStepDefinition; import org.eclipse.kapua.service.job.step.definition.JobStepDefinitionCreator; import org.eclipse.kapua.service.job.step.definition.JobStepDefinitionFactory; +import org.eclipse.kapua.service.job.step.definition.JobStepDefinitionQuery; import org.eclipse.kapua.service.job.step.definition.JobStepDefinitionService; import org.eclipse.kapua.service.job.step.definition.JobStepProperty; import org.eclipse.kapua.service.job.step.definition.JobStepType; @@ -218,12 +219,12 @@ public void searchForStepDefinitionWithTheName(List list) throws Excepti @When("I count the step definition in the database") public void countStepDefinitionInDatabase() throws Exception { - updateCount(() -> (int) jobStepDefinitionService.count(jobStepDefinitionFactory.newQuery(KapuaId.ANY))); + updateCount(() -> (int) jobStepDefinitionService.count(new JobStepDefinitionQuery(KapuaId.ANY))); } @When("I query for step definitions in scope {int}") public void countStepDefinitijonsInScope(Integer id) throws Exception { - updateCount(() -> jobStepDefinitionService.query(jobStepDefinitionFactory.newQuery(KapuaId.ANY)).getSize()); + updateCount(() -> jobStepDefinitionService.query(new JobStepDefinitionQuery(KapuaId.ANY)).getSize()); } @When("I delete the step definition") @@ -327,7 +328,6 @@ public void checkStepDefinitionProcessorName(String name) { public void testTheStepDefinitionFactory() { Assert.assertNotNull(jobStepDefinitionFactory.newCreator(SYS_SCOPE_ID)); Assert.assertNotNull(jobStepDefinitionFactory.newEntity(SYS_SCOPE_ID)); - Assert.assertNotNull(jobStepDefinitionFactory.newQuery(SYS_SCOPE_ID)); Assert.assertNotNull(jobStepDefinitionFactory.newStepProperty("TestName", "TestType", "TestValue", "TestExampleValue")); } diff --git a/service/job/test-steps/src/main/java/org/eclipse/kapua/service/job/steps/JobStepServiceSteps.java b/service/job/test-steps/src/main/java/org/eclipse/kapua/service/job/steps/JobStepServiceSteps.java index 219e528ffef..ea17fc5d7ce 100644 --- a/service/job/test-steps/src/main/java/org/eclipse/kapua/service/job/steps/JobStepServiceSteps.java +++ b/service/job/test-steps/src/main/java/org/eclipse/kapua/service/job/steps/JobStepServiceSteps.java @@ -23,6 +23,7 @@ import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.locator.KapuaLocator; import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.model.query.KapuaQuery; import org.eclipse.kapua.model.query.predicate.AttributePredicate; import org.eclipse.kapua.qa.common.StepData; import org.eclipse.kapua.qa.common.cucumber.CucJobStepProperty; @@ -32,7 +33,6 @@ import org.eclipse.kapua.service.job.step.JobStepCreator; import org.eclipse.kapua.service.job.step.JobStepFactory; import org.eclipse.kapua.service.job.step.JobStepListResult; -import org.eclipse.kapua.service.job.step.JobStepQuery; import org.eclipse.kapua.service.job.step.JobStepService; import org.eclipse.kapua.service.job.step.definition.JobStepDefinition; import org.eclipse.kapua.service.job.step.definition.JobStepProperty; @@ -271,7 +271,7 @@ public void iLookForLastJobStep() throws Exception { @When("I look for the JobStep with name {string}") public void iLookForJobStepWithName(String name) throws Exception { - JobStepQuery tmpQuery = jobStepFactory.newQuery(getCurrentScopeId()); + KapuaQuery tmpQuery = new KapuaQuery(getCurrentScopeId()); tmpQuery.setPredicate(tmpQuery.attributePredicate(JobStepAttributes.NAME, name)); primeException(); @@ -286,7 +286,7 @@ public void iLookForJobStepWithName(String name) throws Exception { @When("I query for a JobStep with the name {string}") public void iQueryForJobStepWithName(String name) throws Exception { - JobStepQuery tmpQuery = jobStepFactory.newQuery(getCurrentScopeId()); + KapuaQuery tmpQuery = new KapuaQuery(getCurrentScopeId()); tmpQuery.setPredicate(tmpQuery.attributePredicate(JobStepAttributes.NAME, name)); primeException(); @@ -325,7 +325,7 @@ public void iCountJobStepAndCheck(int count, int timeout) throws Exception { } private JobStepListResult getJobStepListResult(KapuaId currentJobId) throws KapuaException { - JobStepQuery jobStepQuery = jobStepFactory.newQuery(getCurrentScopeId()); + KapuaQuery jobStepQuery = new KapuaQuery(getCurrentScopeId()); jobStepQuery.setPredicate(jobStepQuery.attributePredicate(JobStepAttributes.JOB_ID, currentJobId, AttributePredicate.Operator.EQUAL)); return jobStepService.query(jobStepQuery); @@ -333,7 +333,7 @@ private JobStepListResult getJobStepListResult(KapuaId currentJobId) throws Kapu @When("I count the JobSteps in the current scope") public void iCountJobStepInCurrentScope() throws Exception { - updateCount(() -> (int) jobStepService.count(jobStepFactory.newQuery(getCurrentScopeId()))); + updateCount(() -> (int) jobStepService.count(new KapuaQuery(getCurrentScopeId()))); } // Delete @@ -380,7 +380,7 @@ public void checkJobStepNotFound() { public void testTheStepFactory() { Assert.assertNotNull(jobStepFactory.newCreator(SYS_SCOPE_ID)); Assert.assertNotNull(jobStepFactory.newEntity(SYS_SCOPE_ID)); - Assert.assertNotNull(jobStepFactory.newQuery(SYS_SCOPE_ID)); + Assert.assertNotNull(new KapuaQuery(SYS_SCOPE_ID)); Assert.assertNotNull(jobStepFactory.newStepProperty("TestName", "TestType", "TestValue")); } // Private methods diff --git a/service/job/test-steps/src/main/java/org/eclipse/kapua/service/job/steps/JobTargetServiceSteps.java b/service/job/test-steps/src/main/java/org/eclipse/kapua/service/job/steps/JobTargetServiceSteps.java index 5f3a7f60349..82ed30dd114 100644 --- a/service/job/test-steps/src/main/java/org/eclipse/kapua/service/job/steps/JobTargetServiceSteps.java +++ b/service/job/test-steps/src/main/java/org/eclipse/kapua/service/job/steps/JobTargetServiceSteps.java @@ -23,6 +23,7 @@ import org.eclipse.kapua.locator.KapuaLocator; import org.eclipse.kapua.model.KapuaEntity; import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.model.query.KapuaQuery; import org.eclipse.kapua.model.query.predicate.AttributePredicate; import org.eclipse.kapua.qa.common.StepData; import org.eclipse.kapua.service.device.registry.Device; @@ -37,7 +38,6 @@ import org.eclipse.kapua.service.job.targets.JobTargetCreator; import org.eclipse.kapua.service.job.targets.JobTargetFactory; import org.eclipse.kapua.service.job.targets.JobTargetListResult; -import org.eclipse.kapua.service.job.targets.JobTargetQuery; import org.eclipse.kapua.service.job.targets.JobTargetService; import org.eclipse.kapua.service.job.targets.JobTargetStatus; import org.junit.Assert; @@ -152,7 +152,7 @@ public void iSearchForTheJobTargetsInDatabase() { */ @And("I add device target(s) to job") public void addDeviceTargetsToJob(List clientIds) throws Exception { - DeviceQuery deviceQuery = deviceFactory.newQuery(getCurrentScopeId()); + DeviceQuery deviceQuery = new DeviceQuery(getCurrentScopeId()); deviceQuery.setPredicate( deviceQuery.attributePredicate(DeviceAttributes.CLIENT_ID, clientIds) ); @@ -290,13 +290,13 @@ public void setTargetStepExceptionMessage(String text) throws Exception { @When("I count the targets in the current scope") public void countTargetsForJob() throws Exception { - updateCount(() -> (int) jobTargetService.count(jobTargetFactory.newQuery(getCurrentScopeId()))); + updateCount(() -> (int) jobTargetService.count(new KapuaQuery(getCurrentScopeId()))); } @When("I query the targets for the current job") public void queryTargetsForJob() throws Exception { Job job = (Job) stepData.get("Job"); - JobTargetQuery tmpQuery = jobTargetFactory.newQuery(getCurrentScopeId()); + KapuaQuery tmpQuery = new KapuaQuery(getCurrentScopeId()); tmpQuery.setPredicate(tmpQuery.attributePredicate(JobTargetAttributes.JOB_ID, job.getId(), AttributePredicate.Operator.EQUAL)); primeException(); try { @@ -334,7 +334,7 @@ public void iConfirmJobTargetHasStatus(int stepIndex, String jobStatus, int time @When("I count the targets in the current scope and I count {int}") public void iCountTheTargetsInTheCurrentScopeAndICount(int targetNum) throws Exception { - updateCountAndCheck(() -> (int) jobTargetService.count(jobTargetFactory.newQuery(getCurrentScopeId())), targetNum); + updateCountAndCheck(() -> (int) jobTargetService.count(new KapuaQuery(getCurrentScopeId())), targetNum); } @Then("The target step index is indeed {int}") @@ -373,7 +373,6 @@ public void checkThatNoTargetWasFound() { public void testTheJobTargetFactory() { Assert.assertNotNull(jobTargetFactory.newCreator(SYS_SCOPE_ID)); Assert.assertNotNull(jobTargetFactory.newEntity(SYS_SCOPE_ID)); - Assert.assertNotNull(jobTargetFactory.newQuery(SYS_SCOPE_ID)); } // Check Job Targets @@ -419,7 +418,7 @@ public void checkJobTargetByNameForJobHas(String clientId, int expectedStepIndex Job job = (Job) stepData.get(JOB); - JobTargetQuery jobTargetQuery = jobTargetFactory.newQuery(job.getScopeId()); + KapuaQuery jobTargetQuery = new KapuaQuery(job.getScopeId()); jobTargetQuery.setPredicate( jobTargetQuery.andPredicate( jobTargetQuery.attributePredicate(JobTargetAttributes.JOB_ID, job.getId()), diff --git a/service/job/test/src/test/java/org/eclipse/kapua/service/job/test/JobLocatorConfiguration.java b/service/job/test/src/test/java/org/eclipse/kapua/service/job/test/JobLocatorConfiguration.java index f3498d75669..0d785368796 100644 --- a/service/job/test/src/test/java/org/eclipse/kapua/service/job/test/JobLocatorConfiguration.java +++ b/service/job/test/src/test/java/org/eclipse/kapua/service/job/test/JobLocatorConfiguration.java @@ -24,14 +24,12 @@ import org.eclipse.kapua.commons.metric.CommonsMetric; import org.eclipse.kapua.commons.metric.MetricsService; import org.eclipse.kapua.commons.metric.MetricsServiceImpl; -import org.eclipse.kapua.commons.model.query.QueryFactoryImpl; import org.eclipse.kapua.commons.service.internal.cache.CacheManagerProvider; import org.eclipse.kapua.commons.setting.system.SystemSetting; import org.eclipse.kapua.commons.util.xml.XmlUtil; import org.eclipse.kapua.job.engine.JobEngineService; import org.eclipse.kapua.locator.KapuaLocator; import org.eclipse.kapua.model.config.metatype.KapuaMetatypeFactory; -import org.eclipse.kapua.model.query.QueryFactory; import org.eclipse.kapua.qa.common.MockedLocator; import org.eclipse.kapua.qa.common.TestJAXBContextProvider; import org.eclipse.kapua.service.account.AccountFactory; @@ -122,7 +120,6 @@ protected void configure() { // Commons bind(KapuaMetatypeFactory.class).toInstance(new KapuaMetatypeFactoryImpl()); - bind(QueryFactory.class).toInstance(new QueryFactoryImpl()); // Account bind(AccountRelativeFinder.class).toInstance(Mockito.mock(AccountRelativeFinder.class)); diff --git a/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/TriggerFactory.java b/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/TriggerFactory.java index 728fa9a8813..f02c3784664 100644 --- a/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/TriggerFactory.java +++ b/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/TriggerFactory.java @@ -21,7 +21,7 @@ * @see KapuaEntityFactory * @since 1.0.0 */ -public interface TriggerFactory extends KapuaEntityFactory { +public interface TriggerFactory extends KapuaEntityFactory { /** * Instantiates a new {@link TriggerProperty} diff --git a/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/TriggerQuery.java b/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/TriggerQuery.java deleted file mode 100644 index e07a98ba0be..00000000000 --- a/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/TriggerQuery.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017, 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.service.scheduler.trigger; - -import org.eclipse.kapua.model.query.KapuaQuery; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - -/** - * {@link Trigger} {@link KapuaQuery} definition. - * - * @see KapuaQuery - * @since 1.0.0 - */ -@XmlRootElement(name = "query") -@XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = TriggerXmlRegistry.class, factoryMethod = "newQuery") -public interface TriggerQuery extends KapuaQuery { -} diff --git a/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/TriggerService.java b/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/TriggerService.java index 18be0ccb49d..75e305a6a4f 100644 --- a/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/TriggerService.java +++ b/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/TriggerService.java @@ -31,7 +31,8 @@ public interface TriggerService extends KapuaEntityService { +public interface TriggerDefinitionFactory extends KapuaEntityFactory { /** * Instantiates a new {@link TriggerProperty}. diff --git a/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/definition/TriggerDefinitionQuery.java b/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/definition/TriggerDefinitionQuery.java index 1d7b2c6dea7..d6ff5d7e069 100644 --- a/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/definition/TriggerDefinitionQuery.java +++ b/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/definition/TriggerDefinitionQuery.java @@ -12,13 +12,15 @@ *******************************************************************************/ package org.eclipse.kapua.service.scheduler.trigger.definition; -import org.eclipse.kapua.model.query.KapuaQuery; - import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.model.query.AbstractKapuaNamedQuery; +import org.eclipse.kapua.model.query.KapuaQuery; + /** * {@link TriggerDefinition} {@link KapuaQuery} definition. * @@ -27,6 +29,17 @@ */ @XmlRootElement(name = "query") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = TriggerDefinitionXmlRegistry.class, factoryMethod = "newQuery") -public interface TriggerDefinitionQuery extends KapuaQuery { +@XmlType +public class TriggerDefinitionQuery extends AbstractKapuaNamedQuery { + + public TriggerDefinitionQuery() { + } + + public TriggerDefinitionQuery(KapuaId scopeId) { + super(scopeId); + } + + public TriggerDefinitionQuery(KapuaQuery query) { + super(query); + } } diff --git a/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/definition/TriggerDefinitionXmlRegistry.java b/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/definition/TriggerDefinitionXmlRegistry.java index 24994cfc93b..d231589c09c 100644 --- a/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/definition/TriggerDefinitionXmlRegistry.java +++ b/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/definition/TriggerDefinitionXmlRegistry.java @@ -34,7 +34,4 @@ public TriggerDefinitionCreator newCreator() { return triggerDefinitionFactory.newCreator(null); } - public TriggerDefinitionQuery newQuery() { - return triggerDefinitionFactory.newQuery(null); - } } diff --git a/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/fired/FiredTriggerFactory.java b/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/fired/FiredTriggerFactory.java index a666528f17e..3bf723e5376 100644 --- a/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/fired/FiredTriggerFactory.java +++ b/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/fired/FiredTriggerFactory.java @@ -20,6 +20,6 @@ * @see KapuaEntityFactory * @since 1.5.0 */ -public interface FiredTriggerFactory extends KapuaEntityFactory { +public interface FiredTriggerFactory extends KapuaEntityFactory { } diff --git a/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/fired/FiredTriggerQuery.java b/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/fired/FiredTriggerQuery.java deleted file mode 100644 index 931f70d3a7c..00000000000 --- a/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/fired/FiredTriggerQuery.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2021, 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.service.scheduler.trigger.fired; - -import org.eclipse.kapua.model.query.KapuaQuery; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - -/** - * {@link FiredTrigger} {@link KapuaQuery} definition. - * - * @see KapuaQuery - * @since 1.5.0 - */ -@XmlRootElement(name = "query") -@XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = FiredTriggerXmlRegistry.class, factoryMethod = "newQuery") -public interface FiredTriggerQuery extends KapuaQuery { -} diff --git a/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/fired/FiredTriggerService.java b/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/fired/FiredTriggerService.java index 4b1b46d6db9..c0f7684b0aa 100644 --- a/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/fired/FiredTriggerService.java +++ b/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/fired/FiredTriggerService.java @@ -27,7 +27,8 @@ public interface FiredTriggerService extends KapuaEntityService { txManager.execute(tx -> { // Retrieve all TriggerDefinition from the database - List dbTriggerDefinitions = triggerDefinitionRepository.query(tx, new TriggerDefinitionQueryImpl(null)).getItems() + List dbTriggerDefinitions = triggerDefinitionRepository.query(tx, new KapuaQuery((KapuaId) null)).getItems() .stream() .map(dbTriggrDefinition -> (TriggerDefinitionImpl) dbTriggrDefinition) .collect(Collectors.toList()); @@ -242,8 +244,7 @@ private void alignTriggerDefinitions(TxContext txContext, TriggerDefinitionImpl if (triggerProperty == null) { LOG.info("Database TriggerProperty '{}' is not wired... Removing from database", dbTriggerPropertyEntity.getTriggerProperty().getName()); return true; - } - else { + } else { return false; } }); diff --git a/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/definition/quartz/TriggerDefinitionFactoryImpl.java b/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/definition/quartz/TriggerDefinitionFactoryImpl.java index 4e85f48cbe6..85a3c027b4d 100644 --- a/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/definition/quartz/TriggerDefinitionFactoryImpl.java +++ b/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/definition/quartz/TriggerDefinitionFactoryImpl.java @@ -19,7 +19,6 @@ import org.eclipse.kapua.service.scheduler.trigger.definition.TriggerDefinition; import org.eclipse.kapua.service.scheduler.trigger.definition.TriggerDefinitionCreator; import org.eclipse.kapua.service.scheduler.trigger.definition.TriggerDefinitionFactory; -import org.eclipse.kapua.service.scheduler.trigger.definition.TriggerDefinitionQuery; import org.eclipse.kapua.service.scheduler.trigger.definition.TriggerProperty; /** @@ -40,11 +39,6 @@ public TriggerDefinitionCreator newCreator(KapuaId scopeId) { return new TriggerDefinitionCreatorImpl(scopeId); } - @Override - public TriggerDefinitionQuery newQuery(KapuaId scopeId) { - return new TriggerDefinitionQueryImpl(scopeId); - } - @Override public TriggerProperty newTriggerProperty(String name, String type, String value) { return new TriggerPropertyImpl(name, type, value); diff --git a/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/definition/quartz/TriggerDefinitionQueryImpl.java b/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/definition/quartz/TriggerDefinitionQueryImpl.java deleted file mode 100644 index 75167dee26e..00000000000 --- a/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/definition/quartz/TriggerDefinitionQueryImpl.java +++ /dev/null @@ -1,35 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2019, 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.service.scheduler.trigger.definition.quartz; - -import org.eclipse.kapua.commons.model.query.AbstractKapuaNamedQuery; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.service.scheduler.trigger.definition.TriggerDefinitionQuery; - -/** - * {@link TriggerDefinitionQuery} implementation. - * - * @since 1.1.0 - */ -public class TriggerDefinitionQueryImpl extends AbstractKapuaNamedQuery implements TriggerDefinitionQuery { - - /** - * Constructor. - * - * @param scopeId The {@link #getScopeId()}. - * @since 1.1.0 - */ - public TriggerDefinitionQueryImpl(KapuaId scopeId) { - super(scopeId); - } -} diff --git a/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/fired/quartz/FiredTriggerFactoryImpl.java b/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/fired/quartz/FiredTriggerFactoryImpl.java index 74812094769..bba556f7007 100644 --- a/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/fired/quartz/FiredTriggerFactoryImpl.java +++ b/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/fired/quartz/FiredTriggerFactoryImpl.java @@ -19,7 +19,6 @@ import org.eclipse.kapua.service.scheduler.trigger.fired.FiredTrigger; import org.eclipse.kapua.service.scheduler.trigger.fired.FiredTriggerCreator; import org.eclipse.kapua.service.scheduler.trigger.fired.FiredTriggerFactory; -import org.eclipse.kapua.service.scheduler.trigger.fired.FiredTriggerQuery; /** * {@link FiredTriggerFactory} implementation. @@ -39,11 +38,6 @@ public FiredTriggerCreator newCreator(KapuaId scopeId) { return new FiredTriggerCreatorImpl(scopeId); } - @Override - public FiredTriggerQuery newQuery(KapuaId scopeId) { - return new FiredTriggerQueryImpl(scopeId); - } - @Override public FiredTrigger clone(FiredTrigger firedTrigger) { try { diff --git a/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/fired/quartz/FiredTriggerQueryImpl.java b/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/fired/quartz/FiredTriggerQueryImpl.java deleted file mode 100644 index 001948044d0..00000000000 --- a/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/fired/quartz/FiredTriggerQueryImpl.java +++ /dev/null @@ -1,35 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2021, 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.service.scheduler.trigger.fired.quartz; - -import org.eclipse.kapua.commons.model.query.AbstractKapuaQuery; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.service.scheduler.trigger.fired.FiredTriggerQuery; - -/** - * {@link FiredTriggerQuery} implementation. - * - * @since 1.5.0 - */ -public class FiredTriggerQueryImpl extends AbstractKapuaQuery implements FiredTriggerQuery { - - /** - * Constructor. - * - * @param scopeId The scope {@link KapuaId}. - * @since 1.5.0 - */ - public FiredTriggerQueryImpl(KapuaId scopeId) { - super(scopeId); - } -} diff --git a/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/quartz/TriggerFactoryImpl.java b/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/quartz/TriggerFactoryImpl.java index 399b2f141f8..83b9bb4f03e 100644 --- a/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/quartz/TriggerFactoryImpl.java +++ b/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/quartz/TriggerFactoryImpl.java @@ -19,7 +19,6 @@ import org.eclipse.kapua.service.scheduler.trigger.Trigger; import org.eclipse.kapua.service.scheduler.trigger.TriggerCreator; import org.eclipse.kapua.service.scheduler.trigger.TriggerFactory; -import org.eclipse.kapua.service.scheduler.trigger.TriggerQuery; import org.eclipse.kapua.service.scheduler.trigger.definition.TriggerProperty; import org.eclipse.kapua.service.scheduler.trigger.definition.quartz.TriggerPropertyImpl; @@ -41,11 +40,6 @@ public Trigger newEntity(KapuaId scopeId) { return new TriggerImpl(scopeId); } - @Override - public TriggerQuery newQuery(KapuaId scopeId) { - return new TriggerQueryImpl(scopeId); - } - @Override public TriggerProperty newTriggerProperty(String name, String type, String value) { return new TriggerPropertyImpl(name, type, value); diff --git a/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/quartz/TriggerQueryImpl.java b/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/quartz/TriggerQueryImpl.java deleted file mode 100644 index 0cc4f03f154..00000000000 --- a/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/quartz/TriggerQueryImpl.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017, 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.service.scheduler.trigger.quartz; - -import org.eclipse.kapua.commons.model.query.AbstractKapuaNamedQuery; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.service.scheduler.trigger.TriggerQuery; - -/** - * {@link TriggerQuery} implementation. - * - * @since 1.0.0 - */ -public class TriggerQueryImpl extends AbstractKapuaNamedQuery implements TriggerQuery { - - /** - * Constructor. - * - * @since 1.0.0 - */ - private TriggerQueryImpl() { - super(); - } - - /** - * Constructor. - * - * @param scopeId The {@link #getScopeId()}. - * @since 1.0.0 - */ - public TriggerQueryImpl(KapuaId scopeId) { - this(); - setScopeId(scopeId); - } -} diff --git a/service/scheduler/test-steps/src/main/java/org/eclipse/kapua/service/scheduler/steps/JobScheduleServiceSteps.java b/service/scheduler/test-steps/src/main/java/org/eclipse/kapua/service/scheduler/steps/JobScheduleServiceSteps.java index 97889210fc3..542d6d7e833 100644 --- a/service/scheduler/test-steps/src/main/java/org/eclipse/kapua/service/scheduler/steps/JobScheduleServiceSteps.java +++ b/service/scheduler/test-steps/src/main/java/org/eclipse/kapua/service/scheduler/steps/JobScheduleServiceSteps.java @@ -12,9 +12,19 @@ *******************************************************************************/ package org.eclipse.kapua.service.scheduler.steps; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +import javax.inject.Inject; + import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.locator.KapuaLocator; import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.model.query.KapuaQuery; import org.eclipse.kapua.model.query.predicate.AttributePredicate; import org.eclipse.kapua.qa.common.StepData; import org.eclipse.kapua.qa.common.TestBase; @@ -24,9 +34,14 @@ import org.eclipse.kapua.service.scheduler.trigger.TriggerCreator; import org.eclipse.kapua.service.scheduler.trigger.TriggerFactory; import org.eclipse.kapua.service.scheduler.trigger.TriggerListResult; -import org.eclipse.kapua.service.scheduler.trigger.TriggerQuery; import org.eclipse.kapua.service.scheduler.trigger.TriggerService; import org.eclipse.kapua.service.scheduler.trigger.definition.TriggerDefinition; +import org.eclipse.kapua.service.scheduler.trigger.definition.TriggerDefinitionAttributes; +import org.eclipse.kapua.service.scheduler.trigger.definition.TriggerDefinitionFactory; +import org.eclipse.kapua.service.scheduler.trigger.definition.TriggerDefinitionQuery; +import org.eclipse.kapua.service.scheduler.trigger.definition.TriggerDefinitionService; +import org.eclipse.kapua.service.scheduler.trigger.definition.TriggerProperty; +import org.junit.Assert; import com.google.inject.Singleton; @@ -36,21 +51,6 @@ import io.cucumber.java.en.And; import io.cucumber.java.en.Then; -import org.eclipse.kapua.service.scheduler.trigger.definition.TriggerDefinitionAttributes; -import org.eclipse.kapua.service.scheduler.trigger.definition.TriggerDefinitionFactory; -import org.eclipse.kapua.service.scheduler.trigger.definition.TriggerDefinitionQuery; -import org.eclipse.kapua.service.scheduler.trigger.definition.TriggerDefinitionService; -import org.eclipse.kapua.service.scheduler.trigger.definition.TriggerProperty; -import org.junit.Assert; - -import javax.inject.Inject; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Date; -import java.util.List; - @Singleton public class JobScheduleServiceSteps extends TestBase { @@ -67,13 +67,13 @@ public class JobScheduleServiceSteps extends TestBase { private static final String TRIGGER_START_DATE = "TriggerStartDate"; private static final String TRIGGER_END_DATE = "TriggerEndDate"; -// **************************************************************************************** -// * Implementation of Gherkin steps used in JobService.feature scenarios. * -// * * -// * MockedLocator is used for Location Service. Mockito is used to mock other * -// * services that the Account services dependent on. Dependent services are: * -// * - Authorization Service * -// **************************************************************************************** + // **************************************************************************************** + // * Implementation of Gherkin steps used in JobService.feature scenarios. * + // * * + // * MockedLocator is used for Location Service. Mockito is used to mock other * + // * services that the Account services dependent on. Dependent services are: * + // * - Authorization Service * + // **************************************************************************************** private static final String KAPUA_ID_CLASS_NAME = "org.eclipse.kapua.model.id.KapuaId"; @@ -83,7 +83,7 @@ public JobScheduleServiceSteps(StepData stepData) { super(stepData); } - @After(value="@setup") + @After(value = "@setup") public void setServices() { KapuaLocator locator = KapuaLocator.getInstance(); triggerFactory = locator.getFactory(TriggerFactory.class); @@ -134,7 +134,7 @@ public void iTryToCreateSchedulerWithName(String schedulerName) throws Exception public void iFindTriggerPropertiesWithName(String triggerDefinitionName) throws Exception { primeException(); try { - TriggerDefinitionQuery triggerDefinitionQuery = triggerDefinitionFactory.newQuery(getCurrentScopeId()); + TriggerDefinitionQuery triggerDefinitionQuery = new TriggerDefinitionQuery(getCurrentScopeId()); triggerDefinitionQuery.setPredicate(triggerDefinitionQuery.attributePredicate(TriggerDefinitionAttributes.NAME, triggerDefinitionName, AttributePredicate.Operator.EQUAL)); TriggerDefinition triggerDefinition = triggerDefinitionService.query(triggerDefinitionQuery).getFirstItem(); stepData.put("TriggerDefinition", triggerDefinition); @@ -412,7 +412,7 @@ public void iDeleteTriggerWithName(String arg0) throws Throwable { @And("I search for the trigger with name {string} in the database") public void iSearchForTheTriggerWithNameInTheDatabase(String triggerName) throws Throwable { - TriggerQuery triggerQuery = triggerFactory.newQuery(getCurrentScopeId()); + KapuaQuery triggerQuery = new KapuaQuery(getCurrentScopeId()); triggerQuery.setPredicate(triggerQuery.attributePredicate(TriggerAttributes.NAME, triggerName, AttributePredicate.Operator.EQUAL)); primeException(); try { @@ -435,7 +435,7 @@ public void iTryToEditSchedulerPropertyTo(String trigerDefinition) throws Except Trigger trigger = (Trigger) stepData.get(TRIGGER); primeException(); try { - TriggerDefinitionQuery triggerDefinitionQuery = triggerDefinitionFactory.newQuery(getCurrentScopeId()); + TriggerDefinitionQuery triggerDefinitionQuery = new TriggerDefinitionQuery(getCurrentScopeId()); triggerDefinitionQuery.setPredicate(triggerDefinitionQuery.attributePredicate(TriggerDefinitionAttributes.NAME, trigerDefinition, AttributePredicate.Operator.EQUAL)); TriggerDefinition triggerDefinition = triggerDefinitionService.query(triggerDefinitionQuery).getFirstItem(); trigger.setTriggerDefinitionId(triggerDefinition.getId()); diff --git a/service/scheduler/test/src/test/java/org/eclipse/kapua/service/scheduler/test/SchedulerLocatorConfiguration.java b/service/scheduler/test/src/test/java/org/eclipse/kapua/service/scheduler/test/SchedulerLocatorConfiguration.java index 02e6c8c4fb0..16a46e9a568 100644 --- a/service/scheduler/test/src/test/java/org/eclipse/kapua/service/scheduler/test/SchedulerLocatorConfiguration.java +++ b/service/scheduler/test/src/test/java/org/eclipse/kapua/service/scheduler/test/SchedulerLocatorConfiguration.java @@ -25,7 +25,6 @@ import org.eclipse.kapua.commons.metric.CommonsMetric; import org.eclipse.kapua.commons.metric.MetricsService; import org.eclipse.kapua.commons.metric.MetricsServiceImpl; -import org.eclipse.kapua.commons.model.query.QueryFactoryImpl; import org.eclipse.kapua.commons.service.internal.cache.CacheManagerProvider; import org.eclipse.kapua.commons.setting.system.SystemSetting; import org.eclipse.kapua.commons.util.xml.XmlUtil; @@ -33,7 +32,6 @@ import org.eclipse.kapua.job.engine.client.settings.JobEngineClientSetting; import org.eclipse.kapua.locator.KapuaLocator; import org.eclipse.kapua.model.config.metatype.KapuaMetatypeFactory; -import org.eclipse.kapua.model.query.QueryFactory; import org.eclipse.kapua.qa.common.MockedLocator; import org.eclipse.kapua.qa.common.TestJAXBContextProvider; import org.eclipse.kapua.service.account.AccountFactory; @@ -158,9 +156,6 @@ protected void configure() { triggerDefinitionRepository, triggerDefinitionFactory)); bind(TriggerDefinitionFactory.class).toInstance(triggerDefinitionFactory); - - // bind Query related services - bind(QueryFactory.class).toInstance(new QueryFactoryImpl()); } }; diff --git a/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/credential/CredentialFactory.java b/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/credential/CredentialFactory.java index 1e31dab6b5a..f533c052327 100644 --- a/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/credential/CredentialFactory.java +++ b/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/credential/CredentialFactory.java @@ -22,7 +22,7 @@ * * @since 1.0.0 */ -public interface CredentialFactory extends KapuaEntityFactory { +public interface CredentialFactory extends KapuaEntityFactory { /** * Instantiates a new {@link Credential}. diff --git a/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/credential/CredentialQuery.java b/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/credential/CredentialQuery.java deleted file mode 100644 index 9e235aba25c..00000000000 --- a/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/credential/CredentialQuery.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * 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.service.authentication.credential; - -import org.eclipse.kapua.model.query.KapuaQuery; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - -/** - * {@link Credential} {@link KapuaQuery} definition. - * - * @see KapuaQuery - * @since 1.0.0 - */ -@XmlRootElement(name = "query") -@XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = CredentialXmlRegistry.class, factoryMethod = "newCredentialQuery") -public interface CredentialQuery extends KapuaQuery { -} diff --git a/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/credential/CredentialService.java b/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/credential/CredentialService.java index 852888961d4..a83a22f34a6 100644 --- a/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/credential/CredentialService.java +++ b/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/credential/CredentialService.java @@ -12,6 +12,8 @@ *******************************************************************************/ package org.eclipse.kapua.service.authentication.credential; +import java.util.Set; + import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.model.query.KapuaQuery; @@ -21,8 +23,6 @@ import org.eclipse.kapua.service.config.KapuaConfigurableService; import org.eclipse.kapua.service.user.User; -import java.util.Set; - /** * {@link Credential} {@link KapuaEntityService} definition. * @@ -35,8 +35,10 @@ public interface CredentialService extends KapuaEntityService { +public interface MfaOptionFactory extends KapuaEntityFactory { /** * Instantiates a new {@link MfaOptionCreator}. diff --git a/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/MfaOptionQuery.java b/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/MfaOptionQuery.java deleted file mode 100644 index 33cc42ad3b7..00000000000 --- a/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/MfaOptionQuery.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2020, 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.service.authentication.credential.mfa; - -import org.eclipse.kapua.model.query.KapuaQuery; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - -/** - * {@link MfaOption} {@link KapuaQuery} definition. - * - * @see KapuaQuery - * @since 1.3.0 - */ -@XmlRootElement(name = "query") -@XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = MfaOptionXmlRegistry.class, factoryMethod = "newQuery") -public interface MfaOptionQuery extends KapuaQuery { -} diff --git a/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/MfaOptionXmlRegistry.java b/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/MfaOptionXmlRegistry.java index 773adea771e..9ad503a6534 100644 --- a/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/MfaOptionXmlRegistry.java +++ b/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/MfaOptionXmlRegistry.java @@ -40,14 +40,4 @@ public MfaOptionCreator newMfaOptionCreator() { public MfaOption newMfaOption() { return mfaOptionFactory.newEntity(null); } - - /** - * Instantiates a new {@link MfaOptionQuery} instance. - * - * @return The newly instantiated {@link MfaOptionQuery} - * @since 1.3.0 - */ - public MfaOptionQuery newQuery() { - return mfaOptionFactory.newQuery(null); - } } diff --git a/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/token/AccessTokenFactory.java b/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/token/AccessTokenFactory.java index 376817c9d1d..cb277276e4b 100644 --- a/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/token/AccessTokenFactory.java +++ b/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/token/AccessTokenFactory.java @@ -23,7 +23,7 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface AccessTokenFactory extends KapuaEntityFactory { +public interface AccessTokenFactory extends KapuaEntityFactory { /** * Instantiates a new {@link AccessTokenCreator}. diff --git a/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/token/AccessTokenQuery.java b/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/token/AccessTokenQuery.java deleted file mode 100644 index fb49ebcd280..00000000000 --- a/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/token/AccessTokenQuery.java +++ /dev/null @@ -1,24 +0,0 @@ -/******************************************************************************* - * 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.service.authentication.token; - -import org.eclipse.kapua.model.query.KapuaQuery; - -/** - * {@link AccessToken} {@link KapuaQuery} definition. - * - * @see KapuaQuery - * @since 1.0.0 - */ -public interface AccessTokenQuery extends KapuaQuery { -} diff --git a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessInfoFactory.java b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessInfoFactory.java index 941d00df0bc..784adb9493f 100644 --- a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessInfoFactory.java +++ b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessInfoFactory.java @@ -20,6 +20,6 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface AccessInfoFactory extends KapuaEntityFactory { +public interface AccessInfoFactory extends KapuaEntityFactory { } diff --git a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessInfoQuery.java b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessInfoQuery.java deleted file mode 100644 index 29f9534835f..00000000000 --- a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessInfoQuery.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * 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.service.authorization.access; - -import org.eclipse.kapua.model.query.KapuaQuery; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - -/** - * {@link AccessInfo} {@link KapuaQuery} definition. - * - * @see KapuaQuery - * @since 1.0.0 - */ -@XmlRootElement(name = "query") -@XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = AccessInfoXmlRegistry.class, factoryMethod = "newQuery") -public interface AccessInfoQuery extends KapuaQuery { -} diff --git a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessInfoService.java b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessInfoService.java index 843726e13b3..3a647f61b15 100644 --- a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessInfoService.java +++ b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessInfoService.java @@ -26,10 +26,10 @@ public interface AccessInfoService extends KapuaEntityService { /** - * Creates a new {@link AccessInfo} entity.
    - * Is up to the implementation whether or not to check the existence of the referred {@link User} entity. + * Creates a new {@link AccessInfo} entity.
    Is up to the implementation whether or not to check the existence of the referred {@link User} entity. * - * @param accessInfoCreator The {@link AccessInfoCreator} form which create the {@link AccessInfo} + * @param accessInfoCreator + * The {@link AccessInfoCreator} form which create the {@link AccessInfo} * @return The created {@link AccessInfo} entity. * @throws KapuaException * @since 1.0.0 @@ -41,8 +41,10 @@ AccessInfo create(AccessInfoCreator accessInfoCreator) /** * Finds the {@link AccessInfo} by scope identifier and {@link AccessInfo} id. * - * @param scopeId The scope id in which to search. - * @param userId The {@link User} id to search. + * @param scopeId + * The scope id in which to search. + * @param userId + * The {@link User} id to search. * @return The {@link AccessInfo} found or {@code null} if no entity was found. * @throws KapuaException * @since 1.0.0 @@ -53,8 +55,10 @@ AccessInfo findByUserId(KapuaId scopeId, KapuaId userId) /** * Finds the {@link AccessInfo} by scope identifier and {@link User} id. * - * @param scopeId The scope id in which to search. - * @param accessInfoId The {@link AccessInfo} id to search. + * @param scopeId + * The scope id in which to search. + * @param accessInfoId + * The {@link AccessInfo} id to search. * @return The {@link AccessInfo} found or {@code null} if no entity was found. * @throws KapuaException * @since 1.0.0 @@ -66,7 +70,8 @@ AccessInfo find(KapuaId scopeId, KapuaId accessInfoId) /** * Returns the {@link AccessInfoListResult} with elements matching the provided query. * - * @param query The {@link AccessInfoQuery} used to filter results. + * @param query + * The {@link KapuaQuery} used to filter results. * @return The {@link AccessInfoListResult} with elements matching the query parameter. * @throws KapuaException * @since 1.0.0 @@ -78,7 +83,8 @@ AccessInfoListResult query(KapuaQuery query) /** * Returns the count of the {@link AccessInfo} elements matching the provided query. * - * @param query The {@link AccessInfoQuery} used to filter results. + * @param query + * The {@link KapuaQuery} used to filter results. * @return The count of the {@link AccessInfo} elements matching the provided query. * @throws KapuaException * @since 1.0.0 @@ -90,8 +96,10 @@ long count(KapuaQuery query) /** * Delete the {@link AccessInfo} by scope id and {@link AccessInfo} id. * - * @param scopeId The scope id in which to delete. - * @param accessInfoId The {@link AccessInfo} id to delete. + * @param scopeId + * The scope id in which to delete. + * @param accessInfoId + * The {@link AccessInfo} id to delete. * @throws KapuaException * @since 1.0.0 */ diff --git a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessInfoXmlRegistry.java b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessInfoXmlRegistry.java index 78a7a8e4732..f95778c0540 100644 --- a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessInfoXmlRegistry.java +++ b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessInfoXmlRegistry.java @@ -39,7 +39,4 @@ public AccessInfoCreator newAccessInfoCreator() { return accessInfoFactory.newCreator(null); } - public AccessInfoQuery newQuery() { - return accessInfoFactory.newQuery(null); - } } diff --git a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessPermissionFactory.java b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessPermissionFactory.java index f8958976955..7841bb0e710 100644 --- a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessPermissionFactory.java +++ b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessPermissionFactory.java @@ -20,6 +20,6 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface AccessPermissionFactory extends KapuaEntityFactory { +public interface AccessPermissionFactory extends KapuaEntityFactory { } diff --git a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessPermissionQuery.java b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessPermissionQuery.java deleted file mode 100644 index 45bf90708e8..00000000000 --- a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessPermissionQuery.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * 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.service.authorization.access; - -import org.eclipse.kapua.model.query.KapuaQuery; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - -/** - * {@link AccessPermission} {@link KapuaQuery} definition. - * - * @see KapuaQuery - * @since 1.0.0 - */ -@XmlRootElement(name = "query") -@XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = AccessPermissionXmlRegistry.class, factoryMethod = "newQuery") -public interface AccessPermissionQuery extends KapuaQuery { -} diff --git a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessPermissionService.java b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessPermissionService.java index 8b41b1812e6..1d95f69f3e7 100644 --- a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessPermissionService.java +++ b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessPermissionService.java @@ -25,10 +25,10 @@ public interface AccessPermissionService extends KapuaEntityService { /** - * Creates a new {@link AccessPermission} based on the parameters provided in the {@link AccessPermissionCreator}.
    - * {@link AccessPermission} must have a unique name within the scope. + * Creates a new {@link AccessPermission} based on the parameters provided in the {@link AccessPermissionCreator}.
    {@link AccessPermission} must have a unique name within the scope. * - * @param accessPermissionCreator The creator object from which to create the {@link AccessPermission}. + * @param accessPermissionCreator + * The creator object from which to create the {@link AccessPermission}. * @throws KapuaException * @since 1.0.0 */ @@ -38,8 +38,10 @@ public interface AccessPermissionService extends KapuaEntityService { +public interface AccessRoleFactory extends KapuaEntityFactory { } diff --git a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessRoleQuery.java b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessRoleQuery.java deleted file mode 100644 index 5f0276e686d..00000000000 --- a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessRoleQuery.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * 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.service.authorization.access; - -import org.eclipse.kapua.model.query.KapuaQuery; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - -/** - * {@link AccessRole} {@link KapuaQuery} definition. - * - * @see KapuaQuery - * @since 1.0.0 - */ -@XmlRootElement(name = "query") -@XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = AccessRoleXmlRegistry.class, factoryMethod = "newQuery") -public interface AccessRoleQuery extends KapuaQuery { -} diff --git a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessRoleService.java b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessRoleService.java index 25225c4b97a..0316fceee6b 100644 --- a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessRoleService.java +++ b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessRoleService.java @@ -25,10 +25,10 @@ public interface AccessRoleService extends KapuaEntityService { /** - * Creates a new {@link AccessRole} based on the parameters provided in the {@link AccessRoleCreator}.
    - * {@link AccessRole} must have a unique name within the scope. + * Creates a new {@link AccessRole} based on the parameters provided in the {@link AccessRoleCreator}.
    {@link AccessRole} must have a unique name within the scope. * - * @param accessRoleCreator The creator object from which to create the {@link AccessRole}. + * @param accessRoleCreator + * The creator object from which to create the {@link AccessRole}. * @throws KapuaException * @since 1.0.0 */ @@ -38,8 +38,10 @@ public interface AccessRoleService extends KapuaEntityService { +public interface DomainFactory extends KapuaEntityFactory { /** * Instantiates a new {@link DomainCreator} diff --git a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/domain/DomainQuery.java b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/domain/DomainQuery.java deleted file mode 100644 index fd3361f781f..00000000000 --- a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/domain/DomainQuery.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * 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.service.authorization.domain; - -import org.eclipse.kapua.model.query.KapuaQuery; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - -/** - * {@link Domain} {@link KapuaQuery} definition. - * - * @see KapuaQuery - * @since 1.0.0 - */ -@XmlRootElement(name = "query") -@XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = DomainXmlRegistry.class, factoryMethod = "newQuery") -public interface DomainQuery extends KapuaQuery { -} diff --git a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/domain/DomainRegistryService.java b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/domain/DomainRegistryService.java index d67abb8eca5..86c77483b21 100644 --- a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/domain/DomainRegistryService.java +++ b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/domain/DomainRegistryService.java @@ -25,12 +25,13 @@ public interface DomainRegistryService extends KapuaEntityService { /** - * Creates a new {@link Domain} based on the parameters provided in the {@link DomainCreator}.
    - * {@link Domain} must have a unique name. + * Creates a new {@link Domain} based on the parameters provided in the {@link DomainCreator}.
    {@link Domain} must have a unique name. * - * @param domainCreator The creator object from which to create the {@link Domain}. + * @param domainCreator + * The creator object from which to create the {@link Domain}. * @return The created {@link Domain} - * @throws KapuaException When there is an oeror22 + * @throws KapuaException + * When there is an oeror22 * @since 1.0.0 */ @Override @@ -39,8 +40,10 @@ public interface DomainRegistryService extends KapuaEntityService { +public interface GroupFactory extends KapuaEntityFactory { /** * Instantiates a new {@link GroupCreator}. diff --git a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/group/GroupMatchPredicate.java b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/group/GroupMatchPredicate.java index 23afb4f1acc..4b9c6f39761 100644 --- a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/group/GroupMatchPredicate.java +++ b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/group/GroupMatchPredicate.java @@ -12,8 +12,24 @@ *******************************************************************************/ package org.eclipse.kapua.service.authorization.group; -import org.eclipse.kapua.model.query.predicate.MatchPredicate; +import java.util.Arrays; -public interface GroupMatchPredicate extends MatchPredicate { +import org.eclipse.kapua.model.query.predicate.AbstractMatchPredicate; + +public class GroupMatchPredicate extends AbstractMatchPredicate { + + /** + * Constructor. + * + * @param matchTerm + * @since 2.1.0 + */ + public GroupMatchPredicate(T matchTerm) { + this.attributeNames = Arrays.asList( + GroupAttributes.DESCRIPTION, + GroupAttributes.NAME + ); + this.matchTerm = matchTerm; + } } diff --git a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/group/GroupQuery.java b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/group/GroupQuery.java index 94b9a53d183..be23ba6290a 100644 --- a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/group/GroupQuery.java +++ b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/group/GroupQuery.java @@ -12,13 +12,14 @@ *******************************************************************************/ package org.eclipse.kapua.service.authorization.group; -import org.eclipse.kapua.model.query.KapuaQuery; - import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.model.query.KapuaQuery; + /** * {@link Group} {@link KapuaQuery} definition. * @@ -27,15 +28,34 @@ */ @XmlRootElement(name = "query") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = GroupXmlRegistry.class, factoryMethod = "newQuery") -public interface GroupQuery extends KapuaQuery { +@XmlType +public class GroupQuery extends KapuaQuery { + + public GroupQuery() { + } + + /** + * Constructor. + * + * @param scopeId + * The {@link #getScopeId()}. + * @since 1.0.0 + */ + public GroupQuery(KapuaId scopeId) { + super(scopeId); + } + /** * Instantiates a new {@link GroupMatchPredicate}. * - * @param matchTerm The term to use to match. - * @param The type of the term + * @param matchTerm + * The term to use to match. + * @param + * The type of the term * @return The newly instantiated {@link GroupMatchPredicate}. * @since 2.1.0 */ - GroupMatchPredicate matchPredicate(T matchTerm); + public GroupMatchPredicate matchPredicate(T matchTerm) { + return new GroupMatchPredicate<>(matchTerm); + } } diff --git a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/group/GroupXmlRegistry.java b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/group/GroupXmlRegistry.java index 60c3299bd2b..58d75b19f3f 100644 --- a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/group/GroupXmlRegistry.java +++ b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/group/GroupXmlRegistry.java @@ -40,14 +40,4 @@ public Group newGroup() { public GroupCreator newGroupCreator() { return groupFactory.newCreator(null, null); } - - /** - * Creates a new {@link GroupQuery} instance. - * - * @return The newly created {@link GroupQuery} instance. - * @since 1.0.0 - */ - public GroupQuery newQuery() { - return groupFactory.newQuery(null); - } } diff --git a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RoleFactory.java b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RoleFactory.java index 8fa873eae5c..44b89b7e46e 100644 --- a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RoleFactory.java +++ b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RoleFactory.java @@ -20,7 +20,7 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface RoleFactory extends KapuaEntityFactory { +public interface RoleFactory extends KapuaEntityFactory { /** * Instantiates a new {@link RolePermission}. diff --git a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RoleMatchPredicate.java b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RoleMatchPredicate.java index 5f1e7edbfc6..f7b00050624 100644 --- a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RoleMatchPredicate.java +++ b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RoleMatchPredicate.java @@ -12,8 +12,23 @@ *******************************************************************************/ package org.eclipse.kapua.service.authorization.role; -import org.eclipse.kapua.model.query.predicate.MatchPredicate; +import java.util.Arrays; -public interface RoleMatchPredicate extends MatchPredicate { +import org.eclipse.kapua.model.query.predicate.AbstractMatchPredicate; +public class RoleMatchPredicate extends AbstractMatchPredicate { + + /** + * Constructor. + * + * @param matchTerm + * @since 2.1.0 + */ + public RoleMatchPredicate(T matchTerm) { + this.attributeNames = Arrays.asList( + RoleAttributes.DESCRIPTION, + RoleAttributes.NAME + ); + this.matchTerm = matchTerm; + } } diff --git a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RolePermissionFactory.java b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RolePermissionFactory.java index f524ba277f9..3f22b6ff052 100644 --- a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RolePermissionFactory.java +++ b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RolePermissionFactory.java @@ -20,6 +20,6 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface RolePermissionFactory extends KapuaEntityFactory { +public interface RolePermissionFactory extends KapuaEntityFactory { } diff --git a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RolePermissionQuery.java b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RolePermissionQuery.java deleted file mode 100644 index 5de910b2579..00000000000 --- a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RolePermissionQuery.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * 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.service.authorization.role; - -import org.eclipse.kapua.model.query.KapuaQuery; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - -/** - * {@link RolePermission} {@link KapuaQuery} definition. - * - * @see KapuaQuery - * @since 1.0.0 - */ -@XmlRootElement(name = "query") -@XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = RolePermissionXmlRegistry.class, factoryMethod = "newQuery") -public interface RolePermissionQuery extends KapuaQuery { -} diff --git a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RolePermissionService.java b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RolePermissionService.java index 6af0eaee8c8..952ef173e41 100644 --- a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RolePermissionService.java +++ b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RolePermissionService.java @@ -25,10 +25,10 @@ public interface RolePermissionService extends KapuaEntityService { /** - * Creates a new {@link RolePermission} based on the parameters provided in the {@link RolePermissionCreator}.
    - * {@link RolePermission} must have a unique name within the scope. + * Creates a new {@link RolePermission} based on the parameters provided in the {@link RolePermissionCreator}.
    {@link RolePermission} must have a unique name within the scope. * - * @param rolePermissionCreator The creator object from which to create the {@link RolePermission}. + * @param rolePermissionCreator + * The creator object from which to create the {@link RolePermission}. * @throws KapuaException * @since 1.0.0 */ @@ -38,8 +38,10 @@ public interface RolePermissionService extends KapuaEntityService The type of the term + * @param matchTerm + * The term to use to match. + * @param + * The type of the term * @return The newly instantiated {@link RoleMatchPredicate}. * @since 2.1.0 */ - RoleMatchPredicate matchPredicate(T matchTerm); + public RoleMatchPredicate matchPredicate(T matchTerm) { + return new RoleMatchPredicate<>(matchTerm); + } } diff --git a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RoleXmlRegistry.java b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RoleXmlRegistry.java index 003054d4aa2..982975a8dca 100644 --- a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RoleXmlRegistry.java +++ b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RoleXmlRegistry.java @@ -40,14 +40,4 @@ public Role newRole() { public RoleCreator newRoleCreator() { return roleFactory.newCreator(null); } - - /** - * Creates a new {@link RoleQuery} instance. - * - * @return The newly created {@link RoleQuery} instance. - * @since 1.0.0 - */ - public RoleQuery newQuery() { - return roleFactory.newQuery(null); - } } diff --git a/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/CertificateFactory.java b/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/CertificateFactory.java index d4864bd3fe2..ad5d0549dc5 100644 --- a/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/CertificateFactory.java +++ b/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/CertificateFactory.java @@ -20,7 +20,7 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface CertificateFactory extends KapuaEntityFactory { +public interface CertificateFactory extends KapuaEntityFactory { /** * Instantiates a new {@link CertificateUsage}. @@ -53,5 +53,4 @@ public interface CertificateFactory extends KapuaEntityFactory { +public interface CertificateInfoFactory extends KapuaEntityFactory { } diff --git a/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/info/CertificateInfoMatchPredicate.java b/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/info/CertificateInfoMatchPredicate.java index 80d1166cb16..92036c50b41 100644 --- a/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/info/CertificateInfoMatchPredicate.java +++ b/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/info/CertificateInfoMatchPredicate.java @@ -12,8 +12,26 @@ *******************************************************************************/ package org.eclipse.kapua.service.certificate.info; -import org.eclipse.kapua.model.query.predicate.MatchPredicate; +import java.util.Arrays; -public interface CertificateInfoMatchPredicate extends MatchPredicate { +import org.eclipse.kapua.model.query.predicate.AbstractMatchPredicate; +public class CertificateInfoMatchPredicate extends AbstractMatchPredicate { + + /** + * Constructor. + * + * @param matchTerm + * @since 2.1.0 + */ + public CertificateInfoMatchPredicate(T matchTerm) { + this.attributeNames = Arrays.asList( + CertificateInfoAttributes.NAME, + CertificateInfoAttributes.SERIAL, + CertificateInfoAttributes.SIGNATURE, + CertificateInfoAttributes.ALGORITHM, + CertificateInfoAttributes.SUBJECT + ); + this.matchTerm = matchTerm; + } } \ No newline at end of file diff --git a/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/info/CertificateInfoQuery.java b/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/info/CertificateInfoQuery.java index 1bf1f33dee5..531001c5790 100644 --- a/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/info/CertificateInfoQuery.java +++ b/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/info/CertificateInfoQuery.java @@ -12,16 +12,16 @@ *******************************************************************************/ package org.eclipse.kapua.service.certificate.info; -import org.eclipse.kapua.model.query.KapuaForwardableEntityQuery; -import org.eclipse.kapua.model.query.KapuaQuery; -import org.eclipse.kapua.service.certificate.info.xml.CertificateInfoXmlRegistry; - import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.model.query.KapuaForwardableEntityQuery; +import org.eclipse.kapua.model.query.KapuaQuery; + /** * {@link CertificateInfo} {@link KapuaQuery} definition. * @@ -30,8 +30,19 @@ */ @XmlRootElement(name = "query") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = CertificateInfoXmlRegistry.class, factoryMethod = "newQuery") -public interface CertificateInfoQuery extends KapuaForwardableEntityQuery { +@XmlType +public class CertificateInfoQuery extends KapuaForwardableEntityQuery { + + public CertificateInfoQuery() { + } + + public CertificateInfoQuery(KapuaId scopeId) { + super(scopeId); + } + + public CertificateInfoQuery(KapuaQuery query) { + super(query); + } @Override /** @@ -41,7 +52,9 @@ public interface CertificateInfoQuery extends KapuaForwardableEntityQuery { * @since 1.1.0 */ @XmlElement(name = "includeInherited") - Boolean getIncludeInherited(); + public Boolean getIncludeInherited() { + return includeInherited; + } @Override /** @@ -50,15 +63,21 @@ public interface CertificateInfoQuery extends KapuaForwardableEntityQuery { * @param includeInherited {@code true} to get inherited {@link CertificateInfo}s, {@code false} otherwise. * @since 1.1.0 */ - void setIncludeInherited(Boolean includeInherited); + public void setIncludeInherited(Boolean includeInherited) { + this.includeInherited = includeInherited; + } /** * Instantiates a new {@link CertificateInfoMatchPredicate}. * - * @param matchTerm The term to use to match. - * @param The type of the term + * @param matchTerm + * The term to use to match. + * @param + * The type of the term * @return The newly instantiated {@link CertificateInfoMatchPredicate}. * @since 2.1.0 */ - CertificateInfoMatchPredicate matchPredicate(T matchTerm); + public CertificateInfoMatchPredicate matchPredicate(T matchTerm) { + return new CertificateInfoMatchPredicate<>(matchTerm); + } } diff --git a/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/info/xml/CertificateInfoXmlRegistry.java b/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/info/xml/CertificateInfoXmlRegistry.java index 0da71c138a1..cd4d810065c 100644 --- a/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/info/xml/CertificateInfoXmlRegistry.java +++ b/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/info/xml/CertificateInfoXmlRegistry.java @@ -18,7 +18,6 @@ import org.eclipse.kapua.service.certificate.info.CertificateInfo; import org.eclipse.kapua.service.certificate.info.CertificateInfoCreator; import org.eclipse.kapua.service.certificate.info.CertificateInfoFactory; -import org.eclipse.kapua.service.certificate.info.CertificateInfoQuery; @XmlRegistry public class CertificateInfoXmlRegistry { @@ -33,7 +32,4 @@ public CertificateInfoCreator newCreator() { return certificateInfoFactory.newCreator(null); } - public CertificateInfoQuery newQuery() { - return certificateInfoFactory.newQuery(null); - } } diff --git a/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/xml/CertificateXmlRegistry.java b/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/xml/CertificateXmlRegistry.java index 52e69f3fb16..7e3ab86d667 100644 --- a/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/xml/CertificateXmlRegistry.java +++ b/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/xml/CertificateXmlRegistry.java @@ -19,7 +19,6 @@ import org.eclipse.kapua.service.certificate.CertificateCreator; import org.eclipse.kapua.service.certificate.CertificateFactory; import org.eclipse.kapua.service.certificate.CertificateGenerator; -import org.eclipse.kapua.service.certificate.CertificateQuery; import org.eclipse.kapua.service.certificate.CertificateUsage; @XmlRegistry @@ -35,10 +34,6 @@ public CertificateCreator newCreator() { return certificateFactory.newCreator(null); } - public CertificateQuery newQuery() { - return certificateFactory.newQuery(null); - } - public CertificateGenerator newCertificateGenerator() { return certificateFactory.newCertificateGenerator(); } diff --git a/service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/info/internal/CertificateInfoFactoryImpl.java b/service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/info/internal/CertificateInfoFactoryImpl.java index 8b3184f3c08..e5a2cd7c0e3 100644 --- a/service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/info/internal/CertificateInfoFactoryImpl.java +++ b/service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/info/internal/CertificateInfoFactoryImpl.java @@ -19,7 +19,6 @@ import org.eclipse.kapua.service.certificate.info.CertificateInfo; import org.eclipse.kapua.service.certificate.info.CertificateInfoCreator; import org.eclipse.kapua.service.certificate.info.CertificateInfoFactory; -import org.eclipse.kapua.service.certificate.info.CertificateInfoQuery; @Singleton public class CertificateInfoFactoryImpl implements CertificateInfoFactory { @@ -34,11 +33,6 @@ public CertificateInfoCreator newCreator(KapuaId scopeId) { throw new UnsupportedOperationException(); } - @Override - public CertificateInfoQuery newQuery(KapuaId scopeId) { - return new CertificateInfoQueryImpl(scopeId); - } - @Override public CertificateInfo clone(CertificateInfo certificateInfo) throws KapuaEntityCloneException { try { diff --git a/service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/info/internal/CertificateInfoMatchPredicateImpl.java b/service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/info/internal/CertificateInfoMatchPredicateImpl.java deleted file mode 100644 index 4d42434e7a5..00000000000 --- a/service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/info/internal/CertificateInfoMatchPredicateImpl.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2018, 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.service.certificate.info.internal; - -import org.eclipse.kapua.commons.model.query.predicate.AbstractMatchPredicate; -import org.eclipse.kapua.service.certificate.info.CertificateInfoAttributes; -import org.eclipse.kapua.service.certificate.info.CertificateInfoMatchPredicate; - -import java.util.Arrays; - -public class CertificateInfoMatchPredicateImpl extends AbstractMatchPredicate implements CertificateInfoMatchPredicate { - - /** - * Constructor. - * - * @param matchTerm - * @since 2.1.0 - */ - public CertificateInfoMatchPredicateImpl(T matchTerm) { - this.attributeNames = Arrays.asList( - CertificateInfoAttributes.NAME, - CertificateInfoAttributes.SERIAL, - CertificateInfoAttributes.SIGNATURE, - CertificateInfoAttributes.ALGORITHM, - CertificateInfoAttributes.SUBJECT - ); - this.matchTerm = matchTerm; - } - -} diff --git a/service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/info/internal/CertificateInfoQueryImpl.java b/service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/info/internal/CertificateInfoQueryImpl.java deleted file mode 100644 index 3c64874d30f..00000000000 --- a/service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/info/internal/CertificateInfoQueryImpl.java +++ /dev/null @@ -1,63 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2018, 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.service.certificate.info.internal; - -import org.eclipse.kapua.commons.model.query.AbstractKapuaNamedQuery; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.service.certificate.info.CertificateInfoMatchPredicate; -import org.eclipse.kapua.service.certificate.info.CertificateInfoQuery; - -/** - * {@link CertificateInfoQuery} implementation. - * - * @since 1.0.0 - */ -public class CertificateInfoQueryImpl extends AbstractKapuaNamedQuery implements CertificateInfoQuery { - - private Boolean includeInherited = Boolean.FALSE; - - /** - * Constructor. - * - * @since 1.0.0 - */ - private CertificateInfoQueryImpl() { - super(); - } - - /** - * Constructor. - * - * @param scopeId The {@link #getScopeId()}. - * @since 1.0.0 - */ - public CertificateInfoQueryImpl(KapuaId scopeId) { - this(); - setScopeId(scopeId); - } - - @Override - public Boolean getIncludeInherited() { - return includeInherited; - } - - @Override - public void setIncludeInherited(Boolean includeInherited) { - this.includeInherited = includeInherited; - } - - @Override - public CertificateInfoMatchPredicate matchPredicate(T matchTerm) { - return new CertificateInfoMatchPredicateImpl<>(matchTerm); - } -} diff --git a/service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/info/internal/CertificateInfoServiceImpl.java b/service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/info/internal/CertificateInfoServiceImpl.java index 2fbd815de1a..0d248c93046 100644 --- a/service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/info/internal/CertificateInfoServiceImpl.java +++ b/service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/info/internal/CertificateInfoServiceImpl.java @@ -29,7 +29,6 @@ import org.eclipse.kapua.service.certificate.info.CertificateInfoListResult; import org.eclipse.kapua.service.certificate.info.CertificateInfoQuery; import org.eclipse.kapua.service.certificate.info.CertificateInfoService; -import org.eclipse.kapua.service.certificate.internal.CertificateQueryImpl; @Singleton public class CertificateInfoServiceImpl implements CertificateInfoService { @@ -55,7 +54,7 @@ public CertificateInfo find(KapuaId scopeId, KapuaId entityId) { public CertificateInfoListResult query(KapuaQuery query) throws KapuaException { ArgumentValidator.notNull(query, "query"); - CertificateQuery certificateQuery = new CertificateQueryImpl(query); + CertificateQuery certificateQuery = new CertificateQuery(query); CertificateInfoListResult publicCertificates = new CertificateInfoListResult(); publicCertificates.addItem(certificateService.query(certificateQuery).getFirstItem()); @@ -67,7 +66,7 @@ public CertificateInfoListResult query(KapuaQuery query) throws KapuaException { public long count(KapuaQuery query) throws KapuaException { ArgumentValidator.notNull(query, "query"); - CertificateQuery privateQuery = new CertificateQueryImpl(query); + CertificateQuery privateQuery = new CertificateQuery(query); privateQuery.setIncludeInherited(((CertificateInfoQuery) query).getIncludeInherited()); return certificateService.count(privateQuery); diff --git a/service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/internal/CertificateFactoryImpl.java b/service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/internal/CertificateFactoryImpl.java index 64420883810..5dad8bd6097 100644 --- a/service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/internal/CertificateFactoryImpl.java +++ b/service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/internal/CertificateFactoryImpl.java @@ -20,7 +20,6 @@ import org.eclipse.kapua.service.certificate.CertificateCreator; import org.eclipse.kapua.service.certificate.CertificateFactory; import org.eclipse.kapua.service.certificate.CertificateGenerator; -import org.eclipse.kapua.service.certificate.CertificateQuery; import org.eclipse.kapua.service.certificate.CertificateUsage; import org.eclipse.kapua.service.certificate.KeyUsage; import org.eclipse.kapua.service.certificate.KeyUsageSetting; @@ -43,11 +42,6 @@ public CertificateCreator newCreator(KapuaId scopeId) { throw new UnsupportedOperationException(); } - @Override - public CertificateQuery newQuery(KapuaId scopeId) { - return new CertificateQueryImpl(scopeId); - } - @Override public CertificateUsage newCertificateUsage(String name) { return new CertificateUsageImpl(name); diff --git a/service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/internal/CertificateQueryImpl.java b/service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/internal/CertificateQueryImpl.java deleted file mode 100644 index 5a7fc108e9a..00000000000 --- a/service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/internal/CertificateQueryImpl.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017, 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.service.certificate.internal; - -import org.eclipse.kapua.commons.model.query.AbstractKapuaForwardableEntityQuery; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.model.query.KapuaQuery; -import org.eclipse.kapua.service.certificate.CertificateQuery; - -/** - * {@link CertificateQuery} implementation. - * - * @since 1.0.0 - */ -public class CertificateQueryImpl extends AbstractKapuaForwardableEntityQuery implements CertificateQuery { - - /** - * Constructor. - * - * @since 1.0.0 - */ - private CertificateQueryImpl() { - super(); - } - - /** - * Constructor. - * - * @param scopeId The {@link #getScopeId()}. - * @since 1.0.0 - */ - public CertificateQueryImpl(KapuaId scopeId) { - this(); - setScopeId(scopeId); - } - - /** - * Clone constructor. - * - * @param query The {@link CertificateQuery} to clone. - * @since 1.0.0 - */ - public CertificateQueryImpl(KapuaQuery query) { - super(query); - } -} diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionFactoryImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionFactoryImpl.java index a6b119cdeb1..1deced40bf4 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionFactoryImpl.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionFactoryImpl.java @@ -19,7 +19,6 @@ import org.eclipse.kapua.service.authentication.credential.mfa.MfaOption; import org.eclipse.kapua.service.authentication.credential.mfa.MfaOptionCreator; import org.eclipse.kapua.service.authentication.credential.mfa.MfaOptionFactory; -import org.eclipse.kapua.service.authentication.credential.mfa.MfaOptionQuery; /** * {@link MfaOptionFactory} implementation. @@ -32,11 +31,6 @@ public MfaOption newEntity(KapuaId scopeId) { return new MfaOptionImpl(scopeId); } - @Override - public MfaOptionQuery newQuery(KapuaId scopeId) { - return new MfaOptionQueryImpl(scopeId); - } - @Override public MfaOptionCreator newCreator(KapuaId scopeId) { return new MfaOptionCreatorImpl(scopeId); diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionQueryImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionQueryImpl.java deleted file mode 100644 index e1a52d227b0..00000000000 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionQueryImpl.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2020, 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.service.authentication.credential.mfa.shiro; - -import org.eclipse.kapua.commons.model.query.AbstractKapuaQuery; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.service.authentication.credential.mfa.MfaOption; -import org.eclipse.kapua.service.authentication.credential.mfa.MfaOptionQuery; - -/** - * {@link MfaOption} query implementation. - * - * @since 1.3.0 - */ -public class MfaOptionQueryImpl extends AbstractKapuaQuery implements MfaOptionQuery { - - /** - * Constructor. - * - * @since 1.3.0 - */ - public MfaOptionQueryImpl() { - super(); - } - - /** - * Constructor. - * - * @param scopeId The {@link #getScopeId()}. - * @since 1.3.0 - */ - public MfaOptionQueryImpl(KapuaId scopeId) { - this(); - setScopeId(scopeId); - } -} diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialFactoryImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialFactoryImpl.java index ea51f3eb37b..1f309b75fc1 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialFactoryImpl.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialFactoryImpl.java @@ -21,7 +21,6 @@ import org.eclipse.kapua.service.authentication.credential.Credential; import org.eclipse.kapua.service.authentication.credential.CredentialCreator; import org.eclipse.kapua.service.authentication.credential.CredentialFactory; -import org.eclipse.kapua.service.authentication.credential.CredentialQuery; import org.eclipse.kapua.service.authentication.credential.CredentialStatus; /** @@ -47,11 +46,6 @@ public Credential newCredential(KapuaId scopeId, KapuaId userId, String credenti return new CredentialImpl(scopeId, userId, credentialType, credentialKey, credentialStatus, expirationDate); } - @Override - public CredentialQuery newQuery(KapuaId scopeId) { - return new CredentialQueryImpl(scopeId); - } - @Override public CredentialCreator newCreator(KapuaId scopeId) { return new CredentialCreatorImpl(scopeId); diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialQueryImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialQueryImpl.java deleted file mode 100644 index 43a4cd87e62..00000000000 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialQueryImpl.java +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * 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.service.authentication.credential.shiro; - -import org.eclipse.kapua.commons.model.query.AbstractKapuaQuery; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.service.authentication.credential.CredentialQuery; - -/** - * {@link CredentialQuery} implementation. - * - * @since 1.0.0 - */ -public class CredentialQueryImpl extends AbstractKapuaQuery implements CredentialQuery { - - /** - * Constructor. - * - * @since 1.0.0 - */ - public CredentialQueryImpl() { - super(); - } - - /** - * Constructor. - * - * @param scopeId The {@link #getScopeId()}. - * @since 1.0.0 - */ - public CredentialQueryImpl(KapuaId scopeId) { - super(scopeId); - } -} diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialServiceImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialServiceImpl.java index 3907e7faa3e..ead13e1d321 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialServiceImpl.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialServiceImpl.java @@ -14,7 +14,12 @@ import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; +import java.util.Map; +import java.util.Set; import java.util.concurrent.atomic.AtomicReference; +import java.util.function.Function; +import java.util.stream.Collectors; + import javax.inject.Singleton; import org.eclipse.kapua.KapuaEntityNotFoundException; @@ -33,13 +38,12 @@ import org.eclipse.kapua.model.query.predicate.AttributePredicate; import org.eclipse.kapua.service.authentication.credential.Credential; import org.eclipse.kapua.service.authentication.credential.CredentialAttributes; -import org.eclipse.kapua.service.authentication.credential.handler.CredentialTypeHandler; import org.eclipse.kapua.service.authentication.credential.CredentialCreator; import org.eclipse.kapua.service.authentication.credential.CredentialFactory; import org.eclipse.kapua.service.authentication.credential.CredentialListResult; -import org.eclipse.kapua.service.authentication.credential.CredentialQuery; import org.eclipse.kapua.service.authentication.credential.CredentialRepository; import org.eclipse.kapua.service.authentication.credential.CredentialService; +import org.eclipse.kapua.service.authentication.credential.handler.CredentialTypeHandler; import org.eclipse.kapua.service.authentication.shiro.CredentialServiceConfigurationManager; import org.eclipse.kapua.service.authentication.shiro.setting.KapuaAuthenticationSetting; import org.eclipse.kapua.service.authentication.shiro.setting.KapuaAuthenticationSettingKeys; @@ -50,11 +54,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.Map; -import java.util.Set; -import java.util.function.Function; -import java.util.stream.Collectors; - /** * {@link CredentialService} implementation. * @@ -138,12 +137,12 @@ public Credential create(CredentialCreator credentialCreator) // Convert creator to entity Credential newCredential = new CredentialImpl( - credentialCreator.getScopeId(), - credentialCreator.getUserId(), - credentialCreator.getCredentialType(), - encryptedKey, - credentialCreator.getCredentialStatus(), - credentialCreator.getExpirationDate() + credentialCreator.getScopeId(), + credentialCreator.getUserId(), + credentialCreator.getCredentialType(), + encryptedKey, + credentialCreator.getCredentialStatus(), + credentialCreator.getExpirationDate() ); // Do create @@ -272,13 +271,13 @@ public CredentialListResult findByUserId(KapuaId scopeId, KapuaId userId, String authorizationService.checkPermission(permissionFactory.newPermission(Domains.CREDENTIAL, Actions.read, scopeId)); // Do find - CredentialQuery credentialQuery = new CredentialQueryImpl(scopeId); + KapuaQuery credentialQuery = new KapuaQuery(scopeId); credentialQuery.setPredicate( - credentialQuery.andPredicate( - credentialQuery.attributePredicate(CredentialAttributes.USER_ID, userId), - credentialQuery.attributePredicate(CredentialAttributes.CREDENTIAL_TYPE, credentialType) - ) + credentialQuery.andPredicate( + credentialQuery.attributePredicate(CredentialAttributes.USER_ID, userId), + credentialQuery.attributePredicate(CredentialAttributes.CREDENTIAL_TYPE, credentialType) + ) ); CredentialListResult credentials = txManager.execute(tx -> credentialRepository.query(tx, credentialQuery)); @@ -286,8 +285,6 @@ public CredentialListResult findByUserId(KapuaId scopeId, KapuaId userId, String return credentials; } - - @Override public Credential findByApiKey(String apiKey) throws KapuaException { int preLength = kapuaAuthenticationSetting.getInt(KapuaAuthenticationSettingKeys.AUTHENTICATION_CREDENTIAL_APIKEY_PRE_LENGTH); @@ -301,13 +298,13 @@ public Credential findByApiKey(String apiKey) throws KapuaException { String apiKeyPreValue = apiKey.substring(0, preLength).concat(preSeparator); // Build query - KapuaQuery query = new CredentialQueryImpl(); + KapuaQuery query = new KapuaQuery(); query.setPredicate( - query.andPredicate( - query.attributePredicate(CredentialAttributes.CREDENTIAL_TYPE, "API_KEY"), - query.attributePredicate(CredentialAttributes.CREDENTIAL_KEY, apiKeyPreValue, AttributePredicate.Operator.STARTS_WITH) - ) + query.andPredicate( + query.attributePredicate(CredentialAttributes.CREDENTIAL_TYPE, "API_KEY"), + query.attributePredicate(CredentialAttributes.CREDENTIAL_KEY, apiKeyPreValue, AttributePredicate.Operator.STARTS_WITH) + ) ); // Query @@ -368,7 +365,7 @@ private void deleteCredentialByUserId(KapuaId scopeId, KapuaId userId) throws Ka KapuaLocator locator = KapuaLocator.getInstance(); CredentialFactory credentialFactory = locator.getFactory(CredentialFactory.class); - CredentialQuery query = credentialFactory.newQuery(scopeId); + KapuaQuery query = new KapuaQuery(scopeId); query.setPredicate(query.attributePredicate(CredentialAttributes.USER_ID, userId)); CredentialListResult credentialsToDelete = query(query); @@ -382,7 +379,7 @@ private void deleteCredentialByAccountId(KapuaId scopeId, KapuaId accountId) thr KapuaLocator locator = KapuaLocator.getInstance(); CredentialFactory credentialFactory = locator.getFactory(CredentialFactory.class); - CredentialQuery query = credentialFactory.newQuery(accountId); + final KapuaQuery query = new KapuaQuery(accountId); CredentialListResult credentialsToDelete = query(query); @@ -426,7 +423,6 @@ public Credential adminResetUserPassword(KapuaId scopeId, KapuaId userId, Passwo return txManager.execute(tx -> passwordResetter.resetPassword(tx, scopeId, userId, false, passwordResetRequest)); } - @Override public Set getAvailableCredentialTypes() { return availableCredentialAuthenticationType.keySet(); @@ -434,8 +430,8 @@ public Set getAvailableCredentialTypes() { private boolean tryEditAdminFields(Credential updated, Credential current) { return updated.getLoginFailures() != current.getLoginFailures() || - updated.getFirstLoginFailure() != current.getFirstLoginFailure() || - updated.getLoginFailuresReset() != current.getLoginFailuresReset() || - updated.getLockoutReset() != current.getLockoutReset(); + updated.getFirstLoginFailure() != current.getFirstLoginFailure() || + updated.getLoginFailuresReset() != current.getLoginFailuresReset() || + updated.getLockoutReset() != current.getLockoutReset(); } } diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/shiro/AuthenticationServiceShiroImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/shiro/AuthenticationServiceShiroImpl.java index 4d26e755b39..ad8534dd38d 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/shiro/AuthenticationServiceShiroImpl.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/shiro/AuthenticationServiceShiroImpl.java @@ -17,10 +17,10 @@ import java.util.Set; import java.util.UUID; import java.util.stream.Collectors; + import javax.inject.Inject; import javax.inject.Singleton; -import com.google.common.collect.Sets; import org.apache.shiro.SecurityUtils; import org.apache.shiro.ShiroException; import org.apache.shiro.authc.AuthenticationException; @@ -42,6 +42,8 @@ import org.eclipse.kapua.commons.security.KapuaSecurityUtils; import org.eclipse.kapua.commons.security.KapuaSession; import org.eclipse.kapua.commons.util.KapuaDelayUtil; +import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.model.query.KapuaQuery; import org.eclipse.kapua.model.query.predicate.AndPredicate; import org.eclipse.kapua.model.query.predicate.AttributePredicate; import org.eclipse.kapua.service.authentication.AuthenticationCredentials; @@ -65,7 +67,6 @@ import org.eclipse.kapua.service.authentication.token.AccessTokenAttributes; import org.eclipse.kapua.service.authentication.token.AccessTokenCreator; import org.eclipse.kapua.service.authentication.token.AccessTokenFactory; -import org.eclipse.kapua.service.authentication.token.AccessTokenQuery; import org.eclipse.kapua.service.authentication.token.AccessTokenService; import org.eclipse.kapua.service.authentication.token.LoginInfo; import org.eclipse.kapua.service.authorization.access.AccessInfo; @@ -73,18 +74,15 @@ import org.eclipse.kapua.service.authorization.access.AccessPermissionAttributes; import org.eclipse.kapua.service.authorization.access.AccessPermissionFactory; import org.eclipse.kapua.service.authorization.access.AccessPermissionListResult; -import org.eclipse.kapua.service.authorization.access.AccessPermissionQuery; import org.eclipse.kapua.service.authorization.access.AccessPermissionService; import org.eclipse.kapua.service.authorization.access.AccessRole; import org.eclipse.kapua.service.authorization.access.AccessRoleAttributes; import org.eclipse.kapua.service.authorization.access.AccessRoleFactory; import org.eclipse.kapua.service.authorization.access.AccessRoleListResult; -import org.eclipse.kapua.service.authorization.access.AccessRoleQuery; import org.eclipse.kapua.service.authorization.access.AccessRoleService; import org.eclipse.kapua.service.authorization.role.RolePermissionAttributes; import org.eclipse.kapua.service.authorization.role.RolePermissionFactory; import org.eclipse.kapua.service.authorization.role.RolePermissionListResult; -import org.eclipse.kapua.service.authorization.role.RolePermissionQuery; import org.eclipse.kapua.service.authorization.role.RolePermissionService; import org.eclipse.kapua.service.certificate.Certificate; import org.eclipse.kapua.service.certificate.CertificateAttributes; @@ -109,6 +107,8 @@ import org.slf4j.LoggerFactory; import org.slf4j.MDC; +import com.google.common.collect.Sets; + /** * {@link AuthenticationService} implementation. * @@ -371,7 +371,7 @@ public AccessToken findAccessToken(String jwt) throws KapuaException { @Override public AccessToken findRefreshableAccessToken(String tokenId) throws KapuaException { - AccessTokenQuery accessTokenQuery = accessTokenFactory.newQuery(null); + KapuaQuery accessTokenQuery = new KapuaQuery((KapuaId) null); AndPredicate andPredicate = accessTokenQuery.andPredicate( accessTokenQuery.attributePredicate(AccessTokenAttributes.REFRESH_EXPIRES_ON, new java.sql.Timestamp(new Date().getTime()), AttributePredicate.Operator.GREATER_THAN_OR_EQUAL), accessTokenQuery.attributePredicate(AccessTokenAttributes.INVALIDATED_ON, null, AttributePredicate.Operator.IS_NULL), @@ -423,18 +423,19 @@ public LoginInfo getLoginInfo() throws KapuaException { AccessInfo accessInfo = KapuaSecurityUtils.doPrivileged(() -> accessInfoService.findByUserId(accessToken.getScopeId(), accessToken.getUserId())); // AccessRole - AccessRoleQuery accessRoleQuery = accessRoleFactory.newQuery(accessToken.getScopeId()); + final KapuaQuery accessRoleQuery = new KapuaQuery(accessToken.getScopeId()); accessRoleQuery.setPredicate(accessRoleQuery.attributePredicate(AccessRoleAttributes.ACCESS_INFO_ID, accessInfo.getId())); AccessRoleListResult accessRoleListResult = KapuaSecurityUtils.doPrivileged(() -> accessRoleService.query(accessRoleQuery)); // RolePermission - RolePermissionQuery rolePermissionQuery = rolePermissionFactory.newQuery(accessToken.getScopeId()); - rolePermissionQuery.setPredicate(rolePermissionQuery.attributePredicate(RolePermissionAttributes.ROLE_ID, accessRoleListResult.getItems().stream().map(AccessRole::getRoleId).collect(Collectors.toList()))); + final KapuaQuery rolePermissionQuery = new KapuaQuery(accessToken.getScopeId()); + rolePermissionQuery.setPredicate( + rolePermissionQuery.attributePredicate(RolePermissionAttributes.ROLE_ID, accessRoleListResult.getItems().stream().map(AccessRole::getRoleId).collect(Collectors.toList()))); RolePermissionListResult rolePermissions = KapuaSecurityUtils.doPrivileged(() -> rolePermissionService.query(rolePermissionQuery)); loginInfo.setRolePermission(Sets.newHashSet(rolePermissions.getItems())); // AccessPermission - AccessPermissionQuery accessPermissionQuery = accessPermissionFactory.newQuery(accessToken.getScopeId()); + final KapuaQuery accessPermissionQuery = new KapuaQuery(accessToken.getScopeId()); accessPermissionQuery.setPredicate(accessPermissionQuery.attributePredicate(AccessPermissionAttributes.ACCESS_INFO_ID, accessInfo.getId())); AccessPermissionListResult accessPermissions = KapuaSecurityUtils.doPrivileged(() -> accessPermissionService.query(accessPermissionQuery)); loginInfo.setAccessPermission(Sets.newHashSet(accessPermissions.getItems())); @@ -459,10 +460,10 @@ public boolean isAuthenticated() // /** - * Checks if the Shiro {@link Subject} is authenticated or not. - * If {@link Subject#isAuthenticated()} {@code equals true}, {@link KapuaAuthenticationException} is raised. + * Checks if the Shiro {@link Subject} is authenticated or not. If {@link Subject#isAuthenticated()} {@code equals true}, {@link KapuaAuthenticationException} is raised. * - * @throws KapuaAuthenticationException If {@link Subject#isAuthenticated()} {@code equals true} + * @throws KapuaAuthenticationException + * If {@link Subject#isAuthenticated()} {@code equals true} * @since 1.0 */ private void checkCurrentSubjectNotAuthenticated() @@ -478,9 +479,11 @@ private void checkCurrentSubjectNotAuthenticated() /** * Converts am instance of {@link AuthenticationCredentials} to the compatible {@link KapuaAuthenticationToken} to be used in Apache Shiro. * - * @param authenticationCredentials The {@link AuthenticationCredentials} to convert + * @param authenticationCredentials + * The {@link AuthenticationCredentials} to convert * @return The converted {@link KapuaAuthenticationToken}. - * @throws KapuaAuthenticationException if the instance of {@link AuthenticationCredentials} cannot be handled or is are invalid. + * @throws KapuaAuthenticationException + * if the instance of {@link AuthenticationCredentials} cannot be handled or is are invalid. * @since 2.0.0 */ private KapuaAuthenticationToken doMapToShiro(AuthenticationCredentials authenticationCredentials) throws KapuaAuthenticationException { @@ -529,7 +532,8 @@ private void handleTokenLoginException(ShiroException se, Subject currentSubject /** * Create and persist a {@link AccessToken} from the data contained in the Shiro {@link Session} * - * @param session The Shiro {@link Session} from which extract data + * @param session + * The Shiro {@link Session} from which extract data * @return The persisted {@link AccessToken} * @throws KapuaException * @since 1.0 @@ -545,8 +549,10 @@ private AccessToken createAccessToken(Session session) throws KapuaException { /** * Create and persist a {@link AccessToken} from a scopeId and a userId * - * @param scopeId The scopeID - * @param userId The userID + * @param scopeId + * The scopeID + * @param userId + * The userID * @return The persisted {@link AccessToken} * @throws KapuaException * @since 1.0.0 @@ -583,8 +589,10 @@ private AccessToken createAccessToken(KapuaEid scopeId, KapuaEid userId) throws /** * Creates a trust key if given {@link AuthenticationToken} is a {@link UsernamePasswordCredentials} and if {@link UsernamePasswordCredentials#getTrustMe()} is {@code true} * - * @param shiroAuthenticationToken The {@link AuthenticationToken} extracted {@link LoginCredentials} - * @param accessToken The {@link AccessToken} of this login. + * @param shiroAuthenticationToken + * The {@link AuthenticationToken} extracted {@link LoginCredentials} + * @param accessToken + * The {@link AccessToken} of this login. * @throws KapuaException * @since 2.0.0 */ @@ -639,7 +647,7 @@ private String generateJwt(KapuaEid scopeId, KapuaEid userId, Date now, long ttl String jwt = null; try { - CertificateQuery certificateQuery = certificateFactory.newQuery(scopeId); + CertificateQuery certificateQuery = new CertificateQuery(scopeId); certificateQuery.setPredicate( certificateQuery.andPredicate( certificateQuery.attributePredicate(CertificateAttributes.USAGE_NAME, "JWT"), @@ -670,8 +678,8 @@ private String generateJwt(KapuaEid scopeId, KapuaEid userId, Date now, long ttl *

    * As of 2.1.0, only PASSWORD credentials can be locked. * - * @param authenticationToken The {@link AuthenticationToken} for the login attempt. - * + * @param authenticationToken + * The {@link AuthenticationToken} for the login attempt. * @since 1.1.0 */ private Boolean checkIfCredentialHasJustBeenLocked(AuthenticationToken authenticationToken) throws KapuaException { diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/shiro/realm/AccessTokenAuthenticatingRealm.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/shiro/realm/AccessTokenAuthenticatingRealm.java index 4f44e823018..54ad5241ade 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/shiro/realm/AccessTokenAuthenticatingRealm.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/shiro/realm/AccessTokenAuthenticatingRealm.java @@ -110,12 +110,12 @@ protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authent } // Set validator final JwtConsumer jwtConsumer = new JwtConsumerBuilder() - .setVerificationKey(CertificateUtils.stringToCertificate(certificateInfo.getCertificate()).getPublicKey()) // Set public key - .setExpectedIssuer(issuer) // Set expected issuer - .setRequireIssuedAt() // Set require reserved claim: iatp - .setRequireExpirationTime() // Set require reserved claim: exp - .setRequireSubject() // // Set require reserved claim: sub - .build(); + .setVerificationKey(CertificateUtils.stringToCertificate(certificateInfo.getCertificate()).getPublicKey()) // Set public key + .setExpectedIssuer(issuer) // Set expected issuer + .setRequireIssuedAt() // Set require reserved claim: iatp + .setRequireExpirationTime() // Set require reserved claim: exp + .setRequireSubject() // // Set require reserved claim: sub + .build(); // This validates JWT final JwtContext jwtContext = jwtConsumer.process(jwt); jwtClaims = jwtContext.getJwtClaims(); @@ -178,7 +178,6 @@ protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authent accessToken); } - @Override protected void assertCredentialsMatch(AuthenticationToken authcToken, AuthenticationInfo info) throws AuthenticationException { @@ -199,14 +198,13 @@ public boolean supports(AuthenticationToken authenticationToken) { return authenticationToken instanceof AccessTokenCredentialsImpl; } - private CertificateInfo getNearestCertificate(AuthenticationToken authenticationToken) - throws KapuaException, InvalidJwtException, MalformedClaimException { + throws KapuaException, InvalidJwtException, MalformedClaimException { final JwtConsumer jwtConsumerNoValidation = new JwtConsumerBuilder() - .setSkipAllValidators() - .setDisableRequireSignature() - .setSkipSignatureVerification() - .build(); + .setSkipAllValidators() + .setDisableRequireSignature() + .setSkipSignatureVerification() + .build(); final String principal = (String) authenticationToken.getPrincipal(); final String username = jwtConsumerNoValidation.process(principal).getJwtClaims().getSubject(); final String account = jwtConsumerNoValidation.process(principal).getJwtClaims().getClaimValueAsString("sId"); @@ -214,12 +212,12 @@ private CertificateInfo getNearestCertificate(AuthenticationToken authentication final KapuaId accountId = KapuaEid.parseCompactId(account); final User user = KapuaSecurityUtils.doPrivileged(() -> userService.find(accountId, userId)); - final CertificateInfoQuery certificateInfoQuery = certificateInfoFactory.newQuery(user.getScopeId()); + final CertificateInfoQuery certificateInfoQuery = new CertificateInfoQuery(user.getScopeId()); certificateInfoQuery.setPredicate( - certificateInfoQuery.andPredicate( - certificateInfoQuery.attributePredicate(CertificateAttributes.USAGE_NAME, "JWT"), - certificateInfoQuery.attributePredicate(CertificateAttributes.STATUS, CertificateStatus.VALID) - ) + certificateInfoQuery.andPredicate( + certificateInfoQuery.attributePredicate(CertificateAttributes.USAGE_NAME, "JWT"), + certificateInfoQuery.attributePredicate(CertificateAttributes.STATUS, CertificateStatus.VALID) + ) ); certificateInfoQuery.setIncludeInherited(true); @@ -227,7 +225,6 @@ private CertificateInfo getNearestCertificate(AuthenticationToken authentication return getNearestCertificateFromList(certificateInfoList); } - private CertificateInfo getNearestCertificateFromList(CertificateInfoListResult certificateInfoList) throws KapuaException { CertificateInfo result = certificateInfoList.getFirstItem(); for (CertificateInfo certificateInfo : certificateInfoList.getItems()) { @@ -238,14 +235,12 @@ private CertificateInfo getNearestCertificateFromList(CertificateInfoListResult return result; } - private boolean isNearestThat(CertificateInfo certificateInfo, CertificateInfo result) throws KapuaException { final KapuaId certificateInfoScopeId = certificateInfo.getScopeId(); final KapuaId resultScopeId = result.getScopeId(); return isChildOf(certificateInfoScopeId, resultScopeId); } - private boolean isChildOf(KapuaId certificateInfoScopeId, KapuaId resultScopeId) throws KapuaException { final Account certificateInfoAccount = KapuaSecurityUtils.doPrivileged(() -> accountService.find(certificateInfoScopeId)); final Account resultAccount = KapuaSecurityUtils.doPrivileged(() -> accountService.find(resultScopeId)); diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/shiro/realm/AccessTokenCredentialsMatcher.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/shiro/realm/AccessTokenCredentialsMatcher.java index 2d182d7d659..6ad2172e746 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/shiro/realm/AccessTokenCredentialsMatcher.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/shiro/realm/AccessTokenCredentialsMatcher.java @@ -26,7 +26,6 @@ import org.eclipse.kapua.service.certificate.CertificateAttributes; import org.eclipse.kapua.service.certificate.CertificateStatus; import org.eclipse.kapua.service.certificate.info.CertificateInfo; -import org.eclipse.kapua.service.certificate.info.CertificateInfoFactory; import org.eclipse.kapua.service.certificate.info.CertificateInfoQuery; import org.eclipse.kapua.service.certificate.info.CertificateInfoService; import org.eclipse.kapua.service.certificate.util.CertificateUtils; @@ -46,7 +45,6 @@ public class AccessTokenCredentialsMatcher implements CredentialsMatcher { private static final Logger LOG = LoggerFactory.getLogger(AccessTokenCredentialsMatcher.class); private final CertificateInfoService certificateInfoService = KapuaLocator.getInstance().getService(CertificateInfoService.class); - private final CertificateInfoFactory certificateInfoFactory = KapuaLocator.getInstance().getFactory(CertificateInfoFactory.class); private final KapuaAuthenticationSetting kapuaAuthenticationSetting = KapuaLocator.getInstance().getComponent(KapuaAuthenticationSetting.class); @Override @@ -57,7 +55,7 @@ public boolean doCredentialsMatch(AuthenticationToken authenticationToken, Authe try { String issuer = kapuaAuthenticationSetting.getString(KapuaAuthenticationSettingKeys.AUTHENTICATION_SESSION_JWT_ISSUER); - CertificateInfoQuery certificateInfoQuery = certificateInfoFactory.newQuery(null); + CertificateInfoQuery certificateInfoQuery = new CertificateInfoQuery(); certificateInfoQuery.setPredicate( certificateInfoQuery.andPredicate( certificateInfoQuery.attributePredicate(CertificateAttributes.USAGE_NAME, "JWT"), diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/token/shiro/AccessTokenFactoryImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/token/shiro/AccessTokenFactoryImpl.java index 56d100af555..d23c792391f 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/token/shiro/AccessTokenFactoryImpl.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/token/shiro/AccessTokenFactoryImpl.java @@ -21,7 +21,6 @@ import org.eclipse.kapua.service.authentication.token.AccessToken; import org.eclipse.kapua.service.authentication.token.AccessTokenCreator; import org.eclipse.kapua.service.authentication.token.AccessTokenFactory; -import org.eclipse.kapua.service.authentication.token.AccessTokenQuery; import org.eclipse.kapua.service.authentication.token.LoginInfo; /** @@ -56,11 +55,6 @@ public AccessTokenCreator newCreator(KapuaId scopeId) { return new AccessTokenCreatorImpl(scopeId); } - @Override - public AccessTokenQuery newQuery(KapuaId scopeId) { - return new AccessTokenQueryImpl(scopeId); - } - @Override public AccessToken clone(AccessToken accessToken) { try { diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/token/shiro/AccessTokenQueryImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/token/shiro/AccessTokenQueryImpl.java deleted file mode 100644 index 2b7d7f7c9aa..00000000000 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/token/shiro/AccessTokenQueryImpl.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * 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.service.authentication.token.shiro; - -import org.eclipse.kapua.commons.model.query.AbstractKapuaQuery; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.service.authentication.token.AccessTokenQuery; - -/** - * {@link AccessTokenQuery} implementation. - * - * @since 1.0.0 - */ -public class AccessTokenQueryImpl extends AbstractKapuaQuery implements AccessTokenQuery { - - /** - * Constructor. - * - * @since 1.0.0 - */ - private AccessTokenQueryImpl() { - super(); - } - - /** - * Constructor. - * - * @param scopeId The {@link #getScopeId()}. - * @since 1.0.0 - */ - public AccessTokenQueryImpl(KapuaId scopeId) { - this(); - setScopeId(scopeId); - } -} diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/token/shiro/AccessTokenServiceImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/token/shiro/AccessTokenServiceImpl.java index 1a4c4d1d105..7652107e330 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/token/shiro/AccessTokenServiceImpl.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/token/shiro/AccessTokenServiceImpl.java @@ -12,6 +12,11 @@ *******************************************************************************/ package org.eclipse.kapua.service.authentication.token.shiro; +import java.util.Date; +import java.util.Optional; + +import javax.inject.Singleton; + import org.eclipse.kapua.KapuaEntityNotFoundException; import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.commons.model.domains.Domains; @@ -26,7 +31,6 @@ import org.eclipse.kapua.service.authentication.token.AccessTokenCreator; import org.eclipse.kapua.service.authentication.token.AccessTokenFactory; import org.eclipse.kapua.service.authentication.token.AccessTokenListResult; -import org.eclipse.kapua.service.authentication.token.AccessTokenQuery; import org.eclipse.kapua.service.authentication.token.AccessTokenRepository; import org.eclipse.kapua.service.authentication.token.AccessTokenService; import org.eclipse.kapua.service.authorization.AuthorizationService; @@ -35,10 +39,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.inject.Singleton; -import java.util.Date; -import java.util.Optional; - /** * {@link AccessTokenService} implementation. * @@ -168,7 +168,7 @@ public AccessTokenListResult findByUserId(KapuaId scopeId, KapuaId userId) throw // Check Access authorizationService.checkPermission(permissionFactory.newPermission(Domains.ACCESS_TOKEN, Actions.read, scopeId)); // Build query - AccessTokenQuery query = new AccessTokenQueryImpl(scopeId); + final KapuaQuery query = new KapuaQuery(scopeId); query.setPredicate(query.attributePredicate(AccessTokenAttributes.USER_ID, userId)); // Do query return query(query); @@ -223,7 +223,7 @@ public void onKapuaEvent(ServiceEvent kapuaEvent) throws KapuaException { private void deleteAccessTokenByUserId(KapuaId scopeId, KapuaId userId) throws KapuaException { - AccessTokenQuery query = new AccessTokenQueryImpl(scopeId); + final KapuaQuery query = new KapuaQuery(scopeId); query.setPredicate(query.attributePredicate(AccessTokenAttributes.USER_ID, userId)); AccessTokenListResult accessTokensToDelete = query(query); @@ -235,7 +235,7 @@ private void deleteAccessTokenByUserId(KapuaId scopeId, KapuaId userId) throws K private void deleteAccessTokenByAccountId(KapuaId scopeId, KapuaId accountId) throws KapuaException { - AccessTokenQuery query = new AccessTokenQueryImpl(accountId); + final KapuaQuery query = new KapuaQuery(scopeId); AccessTokenListResult accessTokensToDelete = query(query); diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoFactoryImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoFactoryImpl.java index 0985c4cbe21..d14100952d7 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoFactoryImpl.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoFactoryImpl.java @@ -19,7 +19,6 @@ import org.eclipse.kapua.service.authorization.access.AccessInfo; import org.eclipse.kapua.service.authorization.access.AccessInfoCreator; import org.eclipse.kapua.service.authorization.access.AccessInfoFactory; -import org.eclipse.kapua.service.authorization.access.AccessInfoQuery; /** * {@link AccessInfoFactory} implementation. @@ -39,11 +38,6 @@ public AccessInfoCreator newCreator(KapuaId scopeId) { return new AccessInfoCreatorImpl(scopeId); } - @Override - public AccessInfoQuery newQuery(KapuaId scopeId) { - return new AccessInfoQueryImpl(scopeId); - } - @Override public AccessInfo clone(AccessInfo accessInfo) { try { diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoQueryImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoQueryImpl.java deleted file mode 100644 index 2bf8c254ce0..00000000000 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoQueryImpl.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * 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.service.authorization.access.shiro; - -import org.eclipse.kapua.commons.model.query.AbstractKapuaQuery; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.service.authorization.access.AccessInfoQuery; - -/** - * {@link AccessInfoQuery} implementation. - * - * @since 1.0.0 - */ -public class AccessInfoQueryImpl extends AbstractKapuaQuery implements AccessInfoQuery { - - /** - * Constructor. - * - * @since 1.0.0 - */ - public AccessInfoQueryImpl() { - super(); - } - - /** - * Constructor. - * - * @param scopeId The {@link #getScopeId()}. - * @since 1.0.0 - */ - public AccessInfoQueryImpl(KapuaId scopeId) { - this(); - setScopeId(scopeId); - } -} diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoServiceImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoServiceImpl.java index cd226537484..02ae11ab102 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoServiceImpl.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoServiceImpl.java @@ -12,6 +12,8 @@ *******************************************************************************/ package org.eclipse.kapua.service.authorization.access.shiro; +import javax.inject.Singleton; + import org.eclipse.kapua.KapuaEntityNotFoundException; import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.commons.model.domains.Domains; @@ -26,7 +28,6 @@ import org.eclipse.kapua.service.authorization.access.AccessInfoCreator; import org.eclipse.kapua.service.authorization.access.AccessInfoFactory; import org.eclipse.kapua.service.authorization.access.AccessInfoListResult; -import org.eclipse.kapua.service.authorization.access.AccessInfoQuery; import org.eclipse.kapua.service.authorization.access.AccessInfoRepository; import org.eclipse.kapua.service.authorization.access.AccessInfoService; import org.eclipse.kapua.service.authorization.access.AccessPermission; @@ -46,8 +47,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.inject.Singleton; - /** * {@link AccessInfoService} implementation based on JPA. * @@ -70,16 +69,16 @@ public class AccessInfoServiceImpl implements AccessInfoService { private final PermissionValidator permissionValidator; public AccessInfoServiceImpl(AuthorizationService authorizationService, - PermissionFactory permissionFactory, - TxManager txManager, - RoleRepository roleRepository, - AccessRoleFactory accessRoleFactory, - AccessRoleRepository accessRoleRepository, - AccessInfoRepository accessInfoRepository, - AccessInfoFactory accessInfoFactory, - AccessPermissionRepository accessPermissionRepository, - AccessPermissionFactory accessPermissionFactory, - PermissionValidator permissionValidator) { + PermissionFactory permissionFactory, + TxManager txManager, + RoleRepository roleRepository, + AccessRoleFactory accessRoleFactory, + AccessRoleRepository accessRoleRepository, + AccessInfoRepository accessInfoRepository, + AccessInfoFactory accessInfoFactory, + AccessPermissionRepository accessPermissionRepository, + AccessPermissionFactory accessPermissionFactory, + PermissionValidator permissionValidator) { this.authorizationService = authorizationService; this.permissionFactory = permissionFactory; this.txManager = txManager; @@ -223,7 +222,7 @@ public void onKapuaEvent(ServiceEvent kapuaEvent) throws KapuaException { } private void deleteAccessInfoByUserId(KapuaId scopeId, KapuaId userId) throws KapuaException { - AccessInfoQuery query = accessInfoFactory.newQuery(scopeId); + final KapuaQuery query = new KapuaQuery(scopeId); query.setPredicate(query.attributePredicate(AccessInfoAttributes.USER_ID, userId)); AccessInfoListResult accessInfosToDelete = query(query); @@ -234,7 +233,7 @@ private void deleteAccessInfoByUserId(KapuaId scopeId, KapuaId userId) throws Ka } private void deleteAccessInfoByAccountId(KapuaId scopeId, KapuaId accountId) throws KapuaException { - AccessInfoQuery query = accessInfoFactory.newQuery(accountId); + final KapuaQuery query = new KapuaQuery(scopeId); AccessInfoListResult accessInfosToDelete = query(query); diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionFactoryImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionFactoryImpl.java index 9b870e015a7..28fe911811f 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionFactoryImpl.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionFactoryImpl.java @@ -18,7 +18,6 @@ import org.eclipse.kapua.service.authorization.access.AccessPermission; import org.eclipse.kapua.service.authorization.access.AccessPermissionCreator; import org.eclipse.kapua.service.authorization.access.AccessPermissionFactory; -import org.eclipse.kapua.service.authorization.access.AccessPermissionQuery; /** * {@link AccessPermissionFactory} implementation. @@ -38,11 +37,6 @@ public AccessPermissionCreator newCreator(KapuaId scopeId) { return new AccessPermissionCreatorImpl(scopeId); } - @Override - public AccessPermissionQuery newQuery(KapuaId scopeId) { - return new AccessPermissionQueryImpl(scopeId); - } - @Override public AccessPermission clone(AccessPermission accessPermission) { return new AccessPermissionImpl(accessPermission); diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionImplJpaRepository.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionImplJpaRepository.java index b80c2c6a4db..9d0c9d8f17c 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionImplJpaRepository.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionImplJpaRepository.java @@ -28,10 +28,10 @@ import org.eclipse.kapua.commons.model.id.KapuaEid; import org.eclipse.kapua.model.domain.Actions; import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.model.query.KapuaQuery; import org.eclipse.kapua.service.authorization.access.AccessPermission; import org.eclipse.kapua.service.authorization.access.AccessPermissionAttributes; import org.eclipse.kapua.service.authorization.access.AccessPermissionListResult; -import org.eclipse.kapua.service.authorization.access.AccessPermissionQuery; import org.eclipse.kapua.service.authorization.access.AccessPermissionRepository; import org.eclipse.kapua.service.authorization.permission.shiro.PermissionImpl_; import org.eclipse.kapua.storage.TxContext; @@ -46,7 +46,7 @@ public AccessPermissionImplJpaRepository(KapuaJpaRepositoryConfiguration configu @Override public AccessPermissionListResult findByAccessInfoId(TxContext tx, KapuaId scopeId, KapuaId accessInfoId) throws KapuaException { - AccessPermissionQuery query = new AccessPermissionQueryImpl(scopeId); + final KapuaQuery query = new KapuaQuery(scopeId); query.setPredicate(query.attributePredicate(AccessPermissionAttributes.ACCESS_INFO_ID, accessInfoId)); return this.query(tx, query); } diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionQueryImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionQueryImpl.java deleted file mode 100644 index bd8bfaf7d0e..00000000000 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionQueryImpl.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * 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.service.authorization.access.shiro; - -import org.eclipse.kapua.commons.model.query.AbstractKapuaQuery; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.service.authorization.access.AccessPermissionQuery; - -/** - * {@link AccessPermissionQuery} implementation. - * - * @since 1.0.0 - */ -public class AccessPermissionQueryImpl extends AbstractKapuaQuery implements AccessPermissionQuery { - - /** - * Constructor. - * - * @since 1.0.0 - */ - public AccessPermissionQueryImpl() { - super(); - } - - /** - * Constructor. - * - * @param scopeId The {@link #getScopeId()}. - * @since 1.0.0 - */ - public AccessPermissionQueryImpl(KapuaId scopeId) { - this(); - setScopeId(scopeId); - } -} diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionServiceImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionServiceImpl.java index 95831541558..7b2fe12515b 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionServiceImpl.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionServiceImpl.java @@ -12,6 +12,14 @@ *******************************************************************************/ package org.eclipse.kapua.service.authorization.access.shiro; +import java.util.AbstractMap; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import javax.inject.Inject; +import javax.inject.Singleton; + import org.eclipse.kapua.KapuaEntityNotFoundException; import org.eclipse.kapua.KapuaEntityUniquenessException; import org.eclipse.kapua.KapuaException; @@ -28,7 +36,6 @@ import org.eclipse.kapua.service.authorization.access.AccessPermissionAttributes; import org.eclipse.kapua.service.authorization.access.AccessPermissionCreator; import org.eclipse.kapua.service.authorization.access.AccessPermissionListResult; -import org.eclipse.kapua.service.authorization.access.AccessPermissionQuery; import org.eclipse.kapua.service.authorization.access.AccessPermissionRepository; import org.eclipse.kapua.service.authorization.access.AccessPermissionService; import org.eclipse.kapua.service.authorization.permission.Permission; @@ -36,13 +43,6 @@ import org.eclipse.kapua.service.authorization.permission.shiro.PermissionValidator; import org.eclipse.kapua.storage.TxManager; -import javax.inject.Inject; -import javax.inject.Singleton; -import java.util.AbstractMap; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - /** * {@link AccessPermission} service implementation. * @@ -93,7 +93,7 @@ public AccessPermission create(AccessPermissionCreator accessPermissionCreator) return txManager.execute(tx -> { // Check duplicates - AccessPermissionQuery query = new AccessPermissionQueryImpl(accessPermissionCreator.getScopeId()); + KapuaQuery query = new KapuaQuery(accessPermissionCreator.getScopeId()); query.setPredicate( query.andPredicate( query.attributePredicate(KapuaEntityAttributes.SCOPE_ID, accessPermissionCreator.getScopeId()), diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessRoleFactoryImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessRoleFactoryImpl.java index 0f69305d4ea..d104f53185f 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessRoleFactoryImpl.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessRoleFactoryImpl.java @@ -19,7 +19,6 @@ import org.eclipse.kapua.service.authorization.access.AccessRole; import org.eclipse.kapua.service.authorization.access.AccessRoleCreator; import org.eclipse.kapua.service.authorization.access.AccessRoleFactory; -import org.eclipse.kapua.service.authorization.access.AccessRoleQuery; /** * {@link AccessRoleFactory} implementation. @@ -39,11 +38,6 @@ public AccessRoleCreator newCreator(KapuaId scopeId) { return new AccessRoleCreatorImpl(scopeId); } - @Override - public AccessRoleQuery newQuery(KapuaId scopeId) { - return new AccessRoleQueryImpl(scopeId); - } - @Override public AccessRole clone(AccessRole accessRole) { try { diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessRoleQueryImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessRoleQueryImpl.java deleted file mode 100644 index 30d4a79ca4c..00000000000 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessRoleQueryImpl.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * 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.service.authorization.access.shiro; - -import org.eclipse.kapua.commons.model.query.AbstractKapuaQuery; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.service.authorization.access.AccessRoleQuery; - -/** - * {@link AccessRoleQuery} implementation. - * - * @since 1.0.0 - */ -public class AccessRoleQueryImpl extends AbstractKapuaQuery implements AccessRoleQuery { - - /** - * Constructor. - * - * @since 1.0.0 - */ - public AccessRoleQueryImpl() { - super(); - } - - /** - * Constructor. - * - * @param scopeId The {@link #getScopeId()}. - * @since 1.0.0 - */ - public AccessRoleQueryImpl(KapuaId scopeId) { - this(); - setScopeId(scopeId); - } -} diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessRoleServiceImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessRoleServiceImpl.java index bd32f1e561e..32e051158b3 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessRoleServiceImpl.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessRoleServiceImpl.java @@ -12,6 +12,9 @@ *******************************************************************************/ package org.eclipse.kapua.service.authorization.access.shiro; +import javax.inject.Inject; +import javax.inject.Singleton; + import org.eclipse.kapua.KapuaDuplicateNameException; import org.eclipse.kapua.KapuaEntityNotFoundException; import org.eclipse.kapua.KapuaException; @@ -28,7 +31,6 @@ import org.eclipse.kapua.service.authorization.access.AccessRoleAttributes; import org.eclipse.kapua.service.authorization.access.AccessRoleCreator; import org.eclipse.kapua.service.authorization.access.AccessRoleListResult; -import org.eclipse.kapua.service.authorization.access.AccessRoleQuery; import org.eclipse.kapua.service.authorization.access.AccessRoleRepository; import org.eclipse.kapua.service.authorization.access.AccessRoleService; import org.eclipse.kapua.service.authorization.permission.PermissionFactory; @@ -37,9 +39,6 @@ import org.eclipse.kapua.service.authorization.role.RoleRepository; import org.eclipse.kapua.storage.TxManager; -import javax.inject.Inject; -import javax.inject.Singleton; - /** * {@link AccessRoleService} implementation. * @@ -90,7 +89,7 @@ public AccessRole create(AccessRoleCreator accessRoleCreator) .orElseThrow(() -> new KapuaEntityNotFoundException(Role.TYPE, accessRoleCreator.getRoleId())); // Check that Role is not already assigned - AccessRoleQuery query = new AccessRoleQueryImpl(accessRoleCreator.getScopeId()); + final KapuaQuery query = new KapuaQuery(accessRoleCreator.getScopeId()); query.setPredicate( query.andPredicate( query.attributePredicate(AccessRoleAttributes.ACCESS_INFO_ID, accessRoleCreator.getAccessInfoId()), diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/CachingAccessPermissionRepository.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/CachingAccessPermissionRepository.java index 1bd6c57aaf3..c03e7e96c34 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/CachingAccessPermissionRepository.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/CachingAccessPermissionRepository.java @@ -17,16 +17,17 @@ import org.eclipse.kapua.commons.storage.KapuaEntityRepositoryCachingWrapper; import org.eclipse.kapua.model.domain.Actions; import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.model.query.KapuaQuery; import org.eclipse.kapua.service.authorization.access.AccessPermission; import org.eclipse.kapua.service.authorization.access.AccessPermissionAttributes; import org.eclipse.kapua.service.authorization.access.AccessPermissionListResult; -import org.eclipse.kapua.service.authorization.access.AccessPermissionQuery; import org.eclipse.kapua.service.authorization.access.AccessPermissionRepository; import org.eclipse.kapua.storage.TxContext; public class CachingAccessPermissionRepository extends KapuaEntityRepositoryCachingWrapper implements AccessPermissionRepository { + private final AccessPermissionRepository wrapped; public CachingAccessPermissionRepository(AccessPermissionRepository wrapped, EntityCache entityCache) { @@ -56,7 +57,7 @@ public AccessPermissionListResult findByAccessInfoId(TxContext tx, KapuaId scope AccessPermissionListResult listResult = (AccessPermissionListResult) entityCache.getList(scopeId, accessInfoId); if (listResult == null) { // Build query - AccessPermissionQuery query = new AccessPermissionQueryImpl(scopeId); + final KapuaQuery query = new KapuaQuery(scopeId); query.setPredicate(query.attributePredicate(AccessPermissionAttributes.ACCESS_INFO_ID, accessInfoId)); listResult = wrapped.findByAccessInfoId(tx, scopeId, accessInfoId); diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/domain/shiro/DomainFactoryImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/domain/shiro/DomainFactoryImpl.java index 2a618267c57..81cdedd3a3b 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/domain/shiro/DomainFactoryImpl.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/domain/shiro/DomainFactoryImpl.java @@ -19,7 +19,6 @@ import org.eclipse.kapua.service.authorization.domain.Domain; import org.eclipse.kapua.service.authorization.domain.DomainCreator; import org.eclipse.kapua.service.authorization.domain.DomainFactory; -import org.eclipse.kapua.service.authorization.domain.DomainQuery; /** * {@link DomainFactory} implementation. @@ -34,11 +33,6 @@ public DomainCreator newCreator(String name) { return new DomainCreatorImpl(name); } - @Override - public DomainQuery newQuery(KapuaId scopeId) { - return new DomainQueryImpl(scopeId); - } - @Override public Domain newEntity(KapuaId scopeId) { return new DomainImpl(scopeId); diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/domain/shiro/DomainQueryImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/domain/shiro/DomainQueryImpl.java deleted file mode 100644 index 4c0b3e8d134..00000000000 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/domain/shiro/DomainQueryImpl.java +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * 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.service.authorization.domain.shiro; - -import org.eclipse.kapua.commons.model.query.AbstractKapuaNamedQuery; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.service.authorization.domain.DomainQuery; - -/** - * {@link DomainQuery} implementation. - * - * @since 1.0.0 - */ -public class DomainQueryImpl extends AbstractKapuaNamedQuery implements DomainQuery { - - /** - * Constructor. - * - * @since 1.0.0 - */ - public DomainQueryImpl() { - super(); - } - - /** - * Constructor. - * - * @param scopeId The {@link #getScopeId()}. - * @since 1.5.0 - */ - public DomainQueryImpl(KapuaId scopeId) { - super(scopeId); - } -} diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/domain/shiro/DomainRegistryServiceImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/domain/shiro/DomainRegistryServiceImpl.java index cb72c92222f..1ebe8a8be41 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/domain/shiro/DomainRegistryServiceImpl.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/domain/shiro/DomainRegistryServiceImpl.java @@ -12,6 +12,10 @@ *******************************************************************************/ package org.eclipse.kapua.service.authorization.domain.shiro; +import java.util.Optional; + +import javax.inject.Singleton; + import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.commons.model.domains.Domains; import org.eclipse.kapua.commons.util.ArgumentValidator; @@ -24,7 +28,6 @@ import org.eclipse.kapua.service.authorization.domain.DomainCreator; import org.eclipse.kapua.service.authorization.domain.DomainFactory; import org.eclipse.kapua.service.authorization.domain.DomainListResult; -import org.eclipse.kapua.service.authorization.domain.DomainQuery; import org.eclipse.kapua.service.authorization.domain.DomainRegistryService; import org.eclipse.kapua.service.authorization.domain.DomainRepository; import org.eclipse.kapua.service.authorization.permission.PermissionFactory; @@ -32,9 +35,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.inject.Singleton; -import java.util.Optional; - /** * {@link DomainRegistryService} implementation. * @@ -152,7 +152,7 @@ public void onKapuaEvent(ServiceEvent kapuaEvent) throws KapuaException { } private void deleteDomainByAccountId(KapuaId accountId) throws KapuaException { - DomainQuery query = domainFactory.newQuery(accountId); + KapuaQuery query = new KapuaQuery(accountId); DomainListResult domainsToDelete = query(query); diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/domain/shiro/DomainsAligner.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/domain/shiro/DomainsAligner.java index 9b4bf945953..01c20935ee0 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/domain/shiro/DomainsAligner.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/domain/shiro/DomainsAligner.java @@ -12,11 +12,22 @@ *******************************************************************************/ package org.eclipse.kapua.service.authorization.domain.shiro; +import java.util.ArrayList; +import java.util.EnumSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +import javax.inject.Inject; +import javax.inject.Named; + import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.commons.security.KapuaSecurityUtils; import org.eclipse.kapua.locator.initializers.KapuaInitializingMethod; import org.eclipse.kapua.model.domain.Actions; import org.eclipse.kapua.model.domain.Domain; +import org.eclipse.kapua.model.query.KapuaQuery; import org.eclipse.kapua.service.authorization.access.AccessPermissionRepository; import org.eclipse.kapua.service.authorization.domain.DomainRepository; import org.eclipse.kapua.service.authorization.role.RolePermissionRepository; @@ -25,16 +36,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.inject.Inject; -import javax.inject.Named; -import java.util.ArrayList; -import java.util.EnumSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; - public class DomainsAligner { + private final TxManager txManager; private final DomainRepository domainRepository; private final AccessPermissionRepository accessPermissionRepository; @@ -44,10 +47,10 @@ public class DomainsAligner { @Inject public DomainsAligner(@Named("authorizationTxManager") - TxManager txManager, - DomainRepository domainRepository, - AccessPermissionRepository accessPermissionRepository, RolePermissionRepository rolePermissionRepository, - Set knownDomains) { + TxManager txManager, + DomainRepository domainRepository, + AccessPermissionRepository accessPermissionRepository, RolePermissionRepository rolePermissionRepository, + Set knownDomains) { this.txManager = txManager; this.domainRepository = domainRepository; this.accessPermissionRepository = accessPermissionRepository; @@ -65,7 +68,7 @@ public void populate() { try { KapuaSecurityUtils.doPrivileged(() -> { txManager.execute(tx -> { - final List dbDomainEntries = domainRepository.query(tx, new DomainQueryImpl()).getItems(); + final List dbDomainEntries = domainRepository.query(tx, new KapuaQuery()).getItems(); logger.info("Found {} domain declarations in database", dbDomainEntries.size()); for (final org.eclipse.kapua.service.authorization.domain.Domain dbDomainEntry : dbDomainEntries) { @@ -87,7 +90,7 @@ public void populate() { //Align them! alignDomains(tx, dbDomainEntry, wiredDomain); } -// createMissingDomains(tx, declaredDomainsNotInDb, knownDomainsByName); + // createMissingDomains(tx, declaredDomainsNotInDb, knownDomainsByName); logger.info("Domain alignment complete!"); return null; }); diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/group/shiro/GroupFactoryImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/group/shiro/GroupFactoryImpl.java index a13a4287fbc..63e7d3ca80b 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/group/shiro/GroupFactoryImpl.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/group/shiro/GroupFactoryImpl.java @@ -19,7 +19,6 @@ import org.eclipse.kapua.service.authorization.group.Group; import org.eclipse.kapua.service.authorization.group.GroupCreator; import org.eclipse.kapua.service.authorization.group.GroupFactory; -import org.eclipse.kapua.service.authorization.group.GroupQuery; /** * {@link GroupFactory} implementation. @@ -43,11 +42,6 @@ public Group newEntity(KapuaId scopeId) { return new GroupImpl(scopeId); } - @Override - public GroupQuery newQuery(KapuaId scopeId) { - return new GroupQueryImpl(scopeId); - } - @Override public GroupCreator newCreator(KapuaId scopeId) { return new GroupCreatorImpl(scopeId); diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/group/shiro/GroupMatchPredicateImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/group/shiro/GroupMatchPredicateImpl.java deleted file mode 100644 index d99618d07a1..00000000000 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/group/shiro/GroupMatchPredicateImpl.java +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017, 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.service.authorization.group.shiro; - -import org.eclipse.kapua.commons.model.query.predicate.AbstractMatchPredicate; -import org.eclipse.kapua.service.authorization.group.GroupAttributes; -import org.eclipse.kapua.service.authorization.group.GroupMatchPredicate; - -import java.util.Arrays; - -public class GroupMatchPredicateImpl extends AbstractMatchPredicate implements GroupMatchPredicate { - - /** - * Constructor. - * - * @param matchTerm - * @since 2.1.0 - */ - public GroupMatchPredicateImpl(T matchTerm) { - this.attributeNames = Arrays.asList( - GroupAttributes.DESCRIPTION, - GroupAttributes.NAME - ); - this.matchTerm = matchTerm; - } - -} diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/group/shiro/GroupQueryImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/group/shiro/GroupQueryImpl.java deleted file mode 100644 index 809a08a6564..00000000000 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/group/shiro/GroupQueryImpl.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * 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.service.authorization.group.shiro; - -import org.eclipse.kapua.commons.model.query.AbstractKapuaNamedQuery; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.service.authorization.group.GroupMatchPredicate; -import org.eclipse.kapua.service.authorization.group.GroupQuery; - -/** - * {@link GroupQuery} implementation. - * - * @since 1.0.0 - */ -public class GroupQueryImpl extends AbstractKapuaNamedQuery implements GroupQuery { - - /** - * Constructor. - * - * @param scopeId The {@link #getScopeId()}. - * @since 1.0.0 - */ - public GroupQueryImpl(KapuaId scopeId) { - super(scopeId); - } - - @Override - public GroupMatchPredicate matchPredicate(T matchTerm) { - return new GroupMatchPredicateImpl<>(matchTerm); - } -} diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/group/shiro/GroupServiceImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/group/shiro/GroupServiceImpl.java index 4b64a1ae5c6..88538bf8f95 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/group/shiro/GroupServiceImpl.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/group/shiro/GroupServiceImpl.java @@ -12,6 +12,9 @@ *******************************************************************************/ package org.eclipse.kapua.service.authorization.group.shiro; +import javax.inject.Inject; +import javax.inject.Singleton; + import org.eclipse.kapua.KapuaDuplicateNameException; import org.eclipse.kapua.KapuaEntityNotFoundException; import org.eclipse.kapua.KapuaException; @@ -35,9 +38,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.inject.Inject; -import javax.inject.Singleton; - /** * {@link GroupService} implementation. * @@ -55,18 +55,21 @@ public class GroupServiceImpl extends KapuaConfigurableServiceBase implements Gr /** * Injectable constructor * - * @param permissionFactory The {@link PermissionFactory} instance. - * @param authorizationService The {@link AuthorizationService} instance. - * @param serviceConfigurationManager The {@link ServiceConfigurationManager} instance. + * @param permissionFactory + * The {@link PermissionFactory} instance. + * @param authorizationService + * The {@link AuthorizationService} instance. + * @param serviceConfigurationManager + * The {@link ServiceConfigurationManager} instance. * @param txManager * @param groupRepository * @since 2.0.0 */ @Inject public GroupServiceImpl(PermissionFactory permissionFactory, - AuthorizationService authorizationService, - ServiceConfigurationManager serviceConfigurationManager, - TxManager txManager, GroupRepository groupRepository) { + AuthorizationService authorizationService, + ServiceConfigurationManager serviceConfigurationManager, + TxManager txManager, GroupRepository groupRepository) { super(txManager, serviceConfigurationManager, Domains.GROUP, authorizationService, permissionFactory); this.permissionFactory = permissionFactory; this.authorizationService = authorizationService; @@ -176,7 +179,7 @@ public void onKapuaEvent(ServiceEvent kapuaEvent) throws KapuaException { } private void deleteGroupByAccountId(KapuaId scopeId, KapuaId accountId) throws KapuaException { - GroupQuery query = new GroupQueryImpl(accountId); + GroupQuery query = new GroupQuery(accountId); GroupListResult groupsToDelete = query(query); diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/permission/shiro/PermissionValidator.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/permission/shiro/PermissionValidator.java index 8bf3d742c02..1999f264982 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/permission/shiro/PermissionValidator.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/permission/shiro/PermissionValidator.java @@ -12,9 +12,15 @@ *******************************************************************************/ package org.eclipse.kapua.service.authorization.permission.shiro; -import com.google.common.collect.Sets; +import java.util.Set; + +import javax.inject.Inject; +import javax.validation.constraints.NotNull; + import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.KapuaIllegalArgumentException; +import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.model.query.KapuaQuery; import org.eclipse.kapua.service.authorization.domain.Domain; import org.eclipse.kapua.service.authorization.domain.DomainFactory; import org.eclipse.kapua.service.authorization.domain.DomainListResult; @@ -22,9 +28,7 @@ import org.eclipse.kapua.service.authorization.permission.Permission; import org.eclipse.kapua.service.authorization.permission.PermissionAttributes; -import javax.inject.Inject; -import javax.validation.constraints.NotNull; -import java.util.Set; +import com.google.common.collect.Sets; public class PermissionValidator { @@ -43,7 +47,7 @@ public void validatePermission(@NotNull Permission permission) throws KapuaExcep public void validatePermissions(@NotNull Set permissions) throws KapuaException { if (!permissions.isEmpty()) { - DomainListResult domains = domainService.query(domainFactory.newQuery(null)); + DomainListResult domains = domainService.query(new KapuaQuery((KapuaId) null)); for (Permission p : permissions) { if (p.getDomain() != null) { diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RoleFactoryImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RoleFactoryImpl.java index 145649c3377..0b0715573d5 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RoleFactoryImpl.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RoleFactoryImpl.java @@ -20,7 +20,6 @@ import org.eclipse.kapua.service.authorization.role.RoleCreator; import org.eclipse.kapua.service.authorization.role.RoleFactory; import org.eclipse.kapua.service.authorization.role.RolePermission; -import org.eclipse.kapua.service.authorization.role.RoleQuery; /** * {@link RoleFactory} implementation. @@ -40,11 +39,6 @@ public RoleCreator newCreator(KapuaId scopeId) { return new RoleCreatorImpl(scopeId); } - @Override - public RoleQuery newQuery(KapuaId scopeId) { - return new RoleQueryImpl(scopeId); - } - @Override public RolePermission newRolePermission() { return new RolePermissionImpl(); diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RoleMatchPredicateImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RoleMatchPredicateImpl.java deleted file mode 100644 index a9d67a14ce7..00000000000 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RoleMatchPredicateImpl.java +++ /dev/null @@ -1,35 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017, 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.service.authorization.role.shiro; - -import org.eclipse.kapua.commons.model.query.predicate.AbstractMatchPredicate; -import org.eclipse.kapua.service.authorization.role.RoleAttributes; -import org.eclipse.kapua.service.authorization.role.RoleMatchPredicate; -import java.util.Arrays; - -public class RoleMatchPredicateImpl extends AbstractMatchPredicate implements RoleMatchPredicate { - - /** - * Constructor. - * - * @param matchTerm - * @since 2.1.0 - */ - public RoleMatchPredicateImpl(T matchTerm) { - this.attributeNames = Arrays.asList( - RoleAttributes.DESCRIPTION, - RoleAttributes.NAME - ); - this.matchTerm = matchTerm; - } -} diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RolePermissionFactoryImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RolePermissionFactoryImpl.java index f2719eb11f0..28c63e38a7c 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RolePermissionFactoryImpl.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RolePermissionFactoryImpl.java @@ -18,7 +18,6 @@ import org.eclipse.kapua.service.authorization.role.RolePermission; import org.eclipse.kapua.service.authorization.role.RolePermissionCreator; import org.eclipse.kapua.service.authorization.role.RolePermissionFactory; -import org.eclipse.kapua.service.authorization.role.RolePermissionQuery; /** * {@link RolePermissionFactory} implementation. @@ -38,11 +37,6 @@ public RolePermissionCreator newCreator(KapuaId scopeId) { return new RolePermissionCreatorImpl(scopeId); } - @Override - public RolePermissionQuery newQuery(KapuaId scopeId) { - return new RolePermissionQueryImpl(scopeId); - } - @Override public RolePermission clone(RolePermission rolePermission) { return new RolePermissionImpl(rolePermission); diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RolePermissionQueryImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RolePermissionQueryImpl.java deleted file mode 100644 index babba275acf..00000000000 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RolePermissionQueryImpl.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * 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.service.authorization.role.shiro; - -import org.eclipse.kapua.commons.model.query.AbstractKapuaQuery; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.service.authorization.role.RolePermissionQuery; - -/** - * {@link RolePermissionQuery} implementation. - * - * @since 1.0.0 - */ -public class RolePermissionQueryImpl extends AbstractKapuaQuery implements RolePermissionQuery { - - /** - * Constructor. - * - * @since 1.0.0 - */ - public RolePermissionQueryImpl() { - super(); - } - - /** - * Constructor. - * - * @param scopeId The {@link #getScopeId()}. - * @since 1.0.0 - */ - public RolePermissionQueryImpl(KapuaId scopeId) { - this(); - setScopeId(scopeId); - } -} diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RolePermissionServiceImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RolePermissionServiceImpl.java index d1a5e863dcd..b06a0add4ec 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RolePermissionServiceImpl.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RolePermissionServiceImpl.java @@ -12,6 +12,13 @@ *******************************************************************************/ package org.eclipse.kapua.service.authorization.role.shiro; +import java.util.AbstractMap; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import javax.inject.Singleton; + import org.eclipse.kapua.KapuaEntityNotFoundException; import org.eclipse.kapua.KapuaEntityUniquenessException; import org.eclipse.kapua.KapuaErrorCodes; @@ -31,18 +38,11 @@ import org.eclipse.kapua.service.authorization.role.RolePermissionAttributes; import org.eclipse.kapua.service.authorization.role.RolePermissionCreator; import org.eclipse.kapua.service.authorization.role.RolePermissionListResult; -import org.eclipse.kapua.service.authorization.role.RolePermissionQuery; import org.eclipse.kapua.service.authorization.role.RolePermissionRepository; import org.eclipse.kapua.service.authorization.role.RolePermissionService; import org.eclipse.kapua.service.authorization.role.RoleRepository; import org.eclipse.kapua.storage.TxManager; -import javax.inject.Singleton; -import java.util.AbstractMap; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - /** * {@link RolePermission} service implementation. * @@ -92,7 +92,7 @@ public RolePermission create(RolePermissionCreator rolePermissionCreator) authorizationService.checkPermission(permission); } // Check duplicates - RolePermissionQuery query = new RolePermissionQueryImpl(rolePermissionCreator.getScopeId()); + KapuaQuery query = new KapuaQuery(rolePermissionCreator.getScopeId()); query.setPredicate( query.andPredicate( query.attributePredicate(KapuaEntityAttributes.SCOPE_ID, rolePermissionCreator.getScopeId()), diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RoleQueryImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RoleQueryImpl.java deleted file mode 100644 index 45a19a65914..00000000000 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RoleQueryImpl.java +++ /dev/null @@ -1,52 +0,0 @@ -/******************************************************************************* - * 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.service.authorization.role.shiro; - -import org.eclipse.kapua.commons.model.query.AbstractKapuaNamedQuery; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.service.authorization.role.RoleMatchPredicate; -import org.eclipse.kapua.service.authorization.role.RoleQuery; - -/** - * {@link RoleQuery} implementation. - * - * @since 1.0.0 - */ -public class RoleQueryImpl extends AbstractKapuaNamedQuery implements RoleQuery { - - /** - * Constructor. - * - * @since 1.0.0 - */ - public RoleQueryImpl() { - super(); - } - - /** - * Constructor. - * - * @param scopeId The {@link #getScopeId()}. - * @since 1.0.0 - */ - public RoleQueryImpl(KapuaId scopeId) { - this(); - setScopeId(scopeId); - } - - @Override - public RoleMatchPredicate matchPredicate(T matchTerm) { - return new RoleMatchPredicateImpl<>(matchTerm); - } - -} diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RoleServiceImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RoleServiceImpl.java index 3fac5c50337..51b1db3e6fd 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RoleServiceImpl.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RoleServiceImpl.java @@ -12,6 +12,12 @@ *******************************************************************************/ package org.eclipse.kapua.service.authorization.role.shiro; +import java.util.List; +import java.util.stream.Collectors; + +import javax.inject.Inject; +import javax.inject.Singleton; + import org.eclipse.kapua.KapuaDuplicateNameException; import org.eclipse.kapua.KapuaEntityNotFoundException; import org.eclipse.kapua.KapuaErrorCodes; @@ -29,13 +35,11 @@ import org.eclipse.kapua.service.authorization.access.AccessInfo; import org.eclipse.kapua.service.authorization.access.AccessInfoFactory; import org.eclipse.kapua.service.authorization.access.AccessInfoListResult; -import org.eclipse.kapua.service.authorization.access.AccessInfoQuery; import org.eclipse.kapua.service.authorization.access.AccessInfoService; import org.eclipse.kapua.service.authorization.access.AccessRole; import org.eclipse.kapua.service.authorization.access.AccessRoleAttributes; import org.eclipse.kapua.service.authorization.access.AccessRoleFactory; import org.eclipse.kapua.service.authorization.access.AccessRoleListResult; -import org.eclipse.kapua.service.authorization.access.AccessRoleQuery; import org.eclipse.kapua.service.authorization.access.AccessRoleService; import org.eclipse.kapua.service.authorization.permission.Permission; import org.eclipse.kapua.service.authorization.permission.PermissionFactory; @@ -54,11 +58,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.inject.Inject; -import javax.inject.Singleton; -import java.util.List; -import java.util.stream.Collectors; - /** * {@link RoleService} implementation. * @@ -80,14 +79,17 @@ public class RoleServiceImpl extends KapuaConfigurableServiceBase implements Rol public AccessInfoService accessInfoService; - /** * Injectable constructor * - * @param permissionFactory The {@link PermissionFactory} instance. - * @param authorizationService The {@link AuthorizationService} instance. - * @param rolePermissionFactory The {@link RolePermissionFactory} instance. - * @param serviceConfigurationManager The {@link ServiceConfigurationManager} instance. + * @param permissionFactory + * The {@link PermissionFactory} instance. + * @param authorizationService + * The {@link AuthorizationService} instance. + * @param rolePermissionFactory + * The {@link RolePermissionFactory} instance. + * @param serviceConfigurationManager + * The {@link ServiceConfigurationManager} instance. * @param txManager * @param roleRepository * @param rolePermissionRepository @@ -259,7 +261,7 @@ public void onKapuaEvent(ServiceEvent kapuaEvent) throws KapuaException { private void deleteRoleByAccountId(KapuaId scopeId, KapuaId accountId) throws KapuaException { - RoleQuery query = new RoleQueryImpl(accountId); + RoleQuery query = new RoleQuery(accountId); RoleListResult rolesToDelete = query(query); @@ -269,12 +271,13 @@ private void deleteRoleByAccountId(KapuaId scopeId, KapuaId accountId) throws Ka } public List userIdsByRoleId(KapuaId scopeId, KapuaId roleId) throws KapuaException { - AccessRoleQuery accessRoleQuery = accessRoleFactory.newQuery(scopeId); + KapuaQuery accessRoleQuery = new KapuaQuery(scopeId); accessRoleQuery.setPredicate(accessRoleQuery.attributePredicate(AccessRoleAttributes.ROLE_ID, roleId)); AccessRoleListResult accessRoleListResult = accessRoleService.query(accessRoleQuery); - AccessInfoQuery accessInfoQuery = accessInfoFactory.newQuery(scopeId); - accessInfoQuery.setPredicate(accessInfoQuery.attributePredicate(KapuaEntityAttributes.ENTITY_ID, accessRoleListResult.getItems().stream().map(AccessRole::getAccessInfoId).collect(Collectors.toList()))); + KapuaQuery accessInfoQuery = new KapuaQuery(scopeId); + accessInfoQuery.setPredicate( + accessInfoQuery.attributePredicate(KapuaEntityAttributes.ENTITY_ID, accessRoleListResult.getItems().stream().map(AccessRole::getAccessInfoId).collect(Collectors.toList()))); AccessInfoListResult accessInfoListResult = accessInfoService.query(accessInfoQuery); return accessInfoListResult.getItems().stream().map(AccessInfo::getUserId).collect(Collectors.toList()); diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/shiro/KapuaAuthorizingRealm.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/shiro/KapuaAuthorizingRealm.java index fb0ceb47430..206a3c71e3c 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/shiro/KapuaAuthorizingRealm.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/shiro/KapuaAuthorizingRealm.java @@ -27,10 +27,10 @@ import org.eclipse.kapua.locator.KapuaLocator; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.model.query.KapuaListResult; +import org.eclipse.kapua.model.query.KapuaQuery; import org.eclipse.kapua.service.authorization.access.AccessInfo; import org.eclipse.kapua.service.authorization.access.AccessInfoAttributes; import org.eclipse.kapua.service.authorization.access.AccessInfoFactory; -import org.eclipse.kapua.service.authorization.access.AccessInfoQuery; import org.eclipse.kapua.service.authorization.access.AccessInfoService; import org.eclipse.kapua.service.authorization.access.AccessPermission; import org.eclipse.kapua.service.authorization.access.AccessPermissionListResult; @@ -97,7 +97,7 @@ protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principal throw new AuthenticationException(); } // Get user access infos - AccessInfoQuery accessInfoQuery = accessInfoFactory.newQuery(user.getScopeId()); + KapuaQuery accessInfoQuery = new KapuaQuery(user.getScopeId()); accessInfoQuery.setPredicate(accessInfoQuery.attributePredicate(AccessInfoAttributes.USER_ID, user.getId())); final KapuaListResult accessInfos; diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionFactoryImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionFactoryImplTest.java index 7b5119fc23e..87767faaf19 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionFactoryImplTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionFactoryImplTest.java @@ -20,7 +20,6 @@ import org.eclipse.kapua.qa.markers.junit.JUnitTests; import org.eclipse.kapua.service.authentication.credential.mfa.MfaOption; import org.eclipse.kapua.service.authentication.credential.mfa.MfaOptionCreator; -import org.eclipse.kapua.service.authentication.credential.mfa.MfaOptionQuery; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -66,14 +65,6 @@ public void newEntityTest() { } } - @Test - public void newQueryTest() { - for (KapuaId scopeId : scopeIds) { - MfaOptionQuery mfaOptionQuery = mfaOptionFactoryImpl.newQuery(scopeId); - Assert.assertEquals("Expected and actual values should be the same.", scopeId, mfaOptionQuery.getScopeId()); - } - } - @Test public void newCreatorScopeIdParameterTest() { for (KapuaId scopeId : scopeIds) { diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionQueryImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionQueryImplTest.java deleted file mode 100644 index 51f23ca3f59..00000000000 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionQueryImplTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2021, 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.service.authentication.credential.mfa.shiro; - -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.qa.markers.junit.JUnitTests; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; - - -@Category(JUnitTests.class) -public class MfaOptionQueryImplTest { - - @Test - public void mfaOptionQueryImplTest() { - MfaOptionQueryImpl mfaOptionQueryImpl = new MfaOptionQueryImpl(); - Assert.assertNull("Null expected.", mfaOptionQueryImpl.getScopeId()); - Assert.assertNull("mfaOptionQueryImpl.sortCriteria", mfaOptionQueryImpl.getSortCriteria()); - Assert.assertNotNull("mfaOptionQueryImpl.defaultSortCriteria", mfaOptionQueryImpl.getDefaultSortCriteria()); - } - - @Test - public void mfaOptionQueryImplScopeIdParameterTest() { - KapuaId[] scopeIds = {null, KapuaId.ONE}; - - for (KapuaId scopeId : scopeIds) { - MfaOptionQueryImpl mfaOptionQueryImpl = new MfaOptionQueryImpl(scopeId); - Assert.assertEquals("Expected and actual values should be the same.", scopeId, mfaOptionQueryImpl.getScopeId()); - Assert.assertNull("mfaOptionQueryImpl.sortCriteria", mfaOptionQueryImpl.getSortCriteria()); - Assert.assertNotNull("mfaOptionQueryImpl.defaultSortCriteria", mfaOptionQueryImpl.getDefaultSortCriteria()); - } - } -} \ No newline at end of file diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialFactoryImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialFactoryImplTest.java index e123066baee..b34595873e2 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialFactoryImplTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialFactoryImplTest.java @@ -17,10 +17,10 @@ import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.commons.model.id.KapuaEid; import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.model.query.KapuaQuery; import org.eclipse.kapua.qa.markers.junit.JUnitTests; import org.eclipse.kapua.service.authentication.credential.Credential; import org.eclipse.kapua.service.authentication.credential.CredentialCreator; -import org.eclipse.kapua.service.authentication.credential.CredentialQuery; import org.eclipse.kapua.service.authentication.credential.CredentialStatus; import org.junit.Assert; import org.junit.Before; @@ -113,7 +113,7 @@ public void newMfaOptionTest() { @Test public void newQueryTest() { for (KapuaId scopeId : scopeIds) { - CredentialQuery credentialQuery = credentialFactoryImpl.newQuery(scopeId); + final KapuaQuery credentialQuery = new KapuaQuery(scopeId); Assert.assertEquals("Expected and actual values should be the same.", scopeId, credentialQuery.getScopeId()); } } diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialQueryImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialQueryImplTest.java deleted file mode 100644 index 7192854baa1..00000000000 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialQueryImplTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2021, 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.service.authentication.credential.shiro; - -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.qa.markers.junit.JUnitTests; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; - - -@Category(JUnitTests.class) -public class CredentialQueryImplTest { - - @Test - public void credentialQueryImplWithoutParameterTest() { - CredentialQueryImpl credentialQueryImpl = new CredentialQueryImpl(); - Assert.assertNull("Null expected.", credentialQueryImpl.getScopeId()); - Assert.assertNull("credentialQueryImpl.sortCriteria", credentialQueryImpl.getSortCriteria()); - Assert.assertNotNull("credentialQueryImpl.defaultSortCriteria", credentialQueryImpl.getDefaultSortCriteria()); - } - - @Test - public void credentialQueryImplScopeIdTest() { - KapuaId[] scopeIds = {null, KapuaId.ONE}; - for (KapuaId scopeId : scopeIds) { - CredentialQueryImpl credentialQueryImpl = new CredentialQueryImpl(scopeId); - Assert.assertEquals("Expected and actual values should be the same.", scopeId, credentialQueryImpl.getScopeId()); - Assert.assertNull("credentialQueryImpl.sortCriteria", credentialQueryImpl.getSortCriteria()); - Assert.assertNotNull("credentialQueryImpl.defaultSortCriteria", credentialQueryImpl.getDefaultSortCriteria()); - } - } -} \ No newline at end of file diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/token/shiro/AccessTokenFactoryImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/token/shiro/AccessTokenFactoryImplTest.java index b3d5eb1b2fc..1c95d23db85 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/token/shiro/AccessTokenFactoryImplTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/token/shiro/AccessTokenFactoryImplTest.java @@ -20,7 +20,6 @@ import org.eclipse.kapua.qa.markers.junit.JUnitTests; import org.eclipse.kapua.service.authentication.token.AccessToken; import org.eclipse.kapua.service.authentication.token.AccessTokenCreator; -import org.eclipse.kapua.service.authentication.token.AccessTokenQuery; import org.eclipse.kapua.service.authentication.token.LoginInfo; import org.junit.Assert; import org.junit.Before; @@ -98,14 +97,6 @@ public void newCreatorScopeIdParameterTest() { } } - @Test - public void newQueryTest() { - for (KapuaId scopeId : scopeIds) { - AccessTokenQuery accessTokenQuery = accessTokenFactoryImpl.newQuery(scopeId); - Assert.assertEquals("Expected and actual values should be the same.", scopeId, accessTokenQuery.getScopeId()); - } - } - @Test public void cloneTest() { Mockito.when(accessToken.getId()).thenReturn(KapuaId.ONE); diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/token/shiro/AccessTokenQueryImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/token/shiro/AccessTokenQueryImplTest.java deleted file mode 100644 index 1bb5a584d51..00000000000 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/token/shiro/AccessTokenQueryImplTest.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2021, 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.service.authentication.token.shiro; - -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.qa.markers.junit.JUnitTests; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -import java.lang.reflect.Constructor; -import java.lang.reflect.Modifier; - - -@Category(JUnitTests.class) -public class AccessTokenQueryImplTest { - - @Test - public void accessTokenQueryImplTest() throws Exception { - Constructor accessTokenQueryImpl = AccessTokenQueryImpl.class.getDeclaredConstructor(); - accessTokenQueryImpl.setAccessible(true); - accessTokenQueryImpl.newInstance(); - Assert.assertTrue("True expected.", Modifier.isPrivate(accessTokenQueryImpl.getModifiers())); - } - - @Test - public void accessTokenQueryImplTestScopeIdParameterTest() { - AccessTokenQueryImpl accessTokenQueryImpl = new AccessTokenQueryImpl(KapuaId.ONE); - Assert.assertEquals("Expected and actual values should be the same.", KapuaId.ONE, accessTokenQueryImpl.getScopeId()); - } - - @Test - public void accessTokenQueryImplTestNullScopeIdParameterTest() { - AccessTokenQueryImpl accessTokenQueryImpl = new AccessTokenQueryImpl(null); - Assert.assertNull("Null expected.", accessTokenQueryImpl.getScopeId()); - } -} \ No newline at end of file diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoFactoryImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoFactoryImplTest.java index de5fdf1f83b..6310df8bbba 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoFactoryImplTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoFactoryImplTest.java @@ -16,10 +16,10 @@ import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.model.query.KapuaQuery; import org.eclipse.kapua.qa.markers.junit.JUnitTests; import org.eclipse.kapua.service.authorization.access.AccessInfo; import org.eclipse.kapua.service.authorization.access.AccessInfoCreator; -import org.eclipse.kapua.service.authorization.access.AccessInfoQuery; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -82,14 +82,14 @@ public void newCreatorNullTest() { @Test public void newQueryTest() { - AccessInfoQuery accessInfoQuery = accessInfoFactoryImpl.newQuery(scopeId); + KapuaQuery accessInfoQuery = new KapuaQuery(scopeId); Assert.assertEquals("Expected and actual values should be the same.", scopeId, accessInfoQuery.getScopeId()); } @Test public void newQueryNullTest() { - AccessInfoQuery accessInfoQuery = accessInfoFactoryImpl.newQuery(null); + KapuaQuery accessInfoQuery = new KapuaQuery((KapuaId) null); Assert.assertNull("Null expected.", accessInfoQuery.getScopeId()); } diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoQueryImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoQueryImplTest.java deleted file mode 100644 index 30be73ea269..00000000000 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoQueryImplTest.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2021, 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.service.authorization.access.shiro; - -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.qa.markers.junit.JUnitTests; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; - - -@Category(JUnitTests.class) -public class AccessInfoQueryImplTest { - - @Test - public void accessInfoQueryImplWithoutParameterTest() { - AccessInfoQueryImpl accessInfoQueryImpl = new AccessInfoQueryImpl(); - - Assert.assertNull("Null expected.", accessInfoQueryImpl.getScopeId()); - } - - @Test - public void accessInfoQueryImplScopeIdParameterTest() { - AccessInfoQueryImpl accessInfoQueryImpl = new AccessInfoQueryImpl(KapuaId.ONE); - - Assert.assertEquals("Expected and actual values should be the same.", KapuaId.ONE, accessInfoQueryImpl.getScopeId()); - } - - @Test - public void accessInfoQueryImplNullScopeIdParameterTest() { - AccessInfoQueryImpl accessInfoQueryImpl = new AccessInfoQueryImpl(null); - - Assert.assertNull("Null expected.", accessInfoQueryImpl.getScopeId()); - } -} \ No newline at end of file diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionFactoryImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionFactoryImplTest.java index c4ea95a3eb2..cca38d81e72 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionFactoryImplTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionFactoryImplTest.java @@ -16,7 +16,6 @@ import org.eclipse.kapua.qa.markers.junit.JUnitTests; import org.eclipse.kapua.service.authorization.access.AccessPermission; import org.eclipse.kapua.service.authorization.access.AccessPermissionCreator; -import org.eclipse.kapua.service.authorization.access.AccessPermissionQuery; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -49,13 +48,6 @@ public void newCreatorTest() { } } - @Test - public void newQueryTest() { - for (KapuaId scopeId : scopeIds) { - Assert.assertTrue("True expected.", accessPermissionFactoryImpl.newQuery(scopeId) instanceof AccessPermissionQuery); - } - } - @Test public void cloneTest() { AccessPermission accessPermission = Mockito.mock(AccessPermission.class); diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionQueryImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionQueryImplTest.java deleted file mode 100644 index ee1fb61f155..00000000000 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionQueryImplTest.java +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2021, 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.service.authorization.access.shiro; - -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.qa.markers.junit.JUnitTests; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; - - -@Category(JUnitTests.class) -public class AccessPermissionQueryImplTest { - - @Test - public void accessPermissionQueryImplWithoutParametersTest() { - AccessPermissionQueryImpl accessPermissionQueryImpl = new AccessPermissionQueryImpl(); - Assert.assertNull("Null expected.", accessPermissionQueryImpl.getScopeId()); - Assert.assertNull("accessPermissionQueryImpl.sortCriteria", accessPermissionQueryImpl.getSortCriteria()); - Assert.assertNotNull("accessPermissionQueryImpl.defaultSortCriteria", accessPermissionQueryImpl.getDefaultSortCriteria()); - } - - @Test - public void accessPermissionQueryImplScopeIdParameterTest() { - AccessPermissionQueryImpl accessPermissionQueryImpl = new AccessPermissionQueryImpl(KapuaId.ONE); - Assert.assertEquals("Expected and actual values should be the same.", KapuaId.ONE, accessPermissionQueryImpl.getScopeId()); - Assert.assertNull("accessPermissionQueryImpl.sortCriteria", accessPermissionQueryImpl.getSortCriteria()); - Assert.assertNotNull("accessPermissionQueryImpl.defaultSortCriteria", accessPermissionQueryImpl.getDefaultSortCriteria()); - } - - @Test - public void accessPermissionQueryImplNullScopeIdParameterTest() { - AccessPermissionQueryImpl accessPermissionQueryImpl = new AccessPermissionQueryImpl(null); - Assert.assertNull("Null expected.", accessPermissionQueryImpl.getScopeId()); - Assert.assertNull("accessPermissionQueryImpl.sortCriteria", accessPermissionQueryImpl.getSortCriteria()); - Assert.assertNotNull("accessPermissionQueryImpl.defaultSortCriteria", accessPermissionQueryImpl.getDefaultSortCriteria()); - } -} \ No newline at end of file diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessRoleFactoryImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessRoleFactoryImplTest.java index 187251c0ad8..07aa0e22aef 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessRoleFactoryImplTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessRoleFactoryImplTest.java @@ -19,7 +19,6 @@ import org.eclipse.kapua.qa.markers.junit.JUnitTests; import org.eclipse.kapua.service.authorization.access.AccessRole; import org.eclipse.kapua.service.authorization.access.AccessRoleCreator; -import org.eclipse.kapua.service.authorization.access.AccessRoleQuery; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -71,18 +70,6 @@ public void newCreatorNullTest() { Assert.assertNull("Null expected.", accessRoleCreator.getScopeId()); } - @Test - public void newQueryTest() { - AccessRoleQuery accessRoleQuery = accessRoleFactoryImpl.newQuery(KapuaId.ONE); - Assert.assertEquals("Expected and actual values should be the same.", KapuaId.ONE, accessRoleQuery.getScopeId()); - } - - @Test - public void newQueryNullTest() { - AccessRoleQuery accessRoleQuery = accessRoleFactoryImpl.newQuery(null); - Assert.assertNull("Null expected.", accessRoleQuery.getScopeId()); - } - @Test public void cloneTest() { accessRoleFactoryImpl.clone(accessRole); diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessRoleQueryImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessRoleQueryImplTest.java deleted file mode 100644 index 4f6601d333e..00000000000 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessRoleQueryImplTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2021, 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.service.authorization.access.shiro; - -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.qa.markers.junit.JUnitTests; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; - - -@Category(JUnitTests.class) -public class AccessRoleQueryImplTest { - - @Test - public void accessRoleQueryImplWithoutParametersTest() { - AccessRoleQueryImpl accessRoleQueryImpl = new AccessRoleQueryImpl(); - Assert.assertNull("Null expected.", accessRoleQueryImpl.getScopeId()); - Assert.assertNull("accessRoleQueryImpl.sortCriteria", accessRoleQueryImpl.getSortCriteria()); - Assert.assertNotNull("accessRoleQueryImpl.defaultSortCriteria", accessRoleQueryImpl.getDefaultSortCriteria()); - } - - @Test - public void accessRoleQueryImplScopeIdParameterTest() { - AccessRoleQueryImpl accessRoleQueryImpl = new AccessRoleQueryImpl(KapuaId.ONE); - Assert.assertEquals("Expected and actual values should be the same.", KapuaId.ONE, accessRoleQueryImpl.getScopeId()); - Assert.assertNull("accessRoleQueryImpl.sortCriteria", accessRoleQueryImpl.getSortCriteria()); - Assert.assertNotNull("accessRoleQueryImpl.defaultSortCriteria", accessRoleQueryImpl.getDefaultSortCriteria()); - } -} \ No newline at end of file diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/domain/shiro/DomainFactoryImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/domain/shiro/DomainFactoryImplTest.java index 83d88868642..6dffdc20b93 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/domain/shiro/DomainFactoryImplTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/domain/shiro/DomainFactoryImplTest.java @@ -22,7 +22,6 @@ import org.eclipse.kapua.qa.markers.junit.JUnitTests; import org.eclipse.kapua.service.authorization.domain.Domain; import org.eclipse.kapua.service.authorization.domain.DomainCreator; -import org.eclipse.kapua.service.authorization.domain.DomainQuery; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -58,22 +57,6 @@ public void newCreatorNullNameParameterTest() { Assert.assertNull("Null expected.", domainCreator.getScopeId()); } - @Test - public void newQueryTest() { - DomainQuery domainQuery = domainFactoryImpl.newQuery(KapuaId.ONE); - Assert.assertEquals("Expected and actual values should be the same.", KapuaId.ONE, domainQuery.getScopeId()); - Assert.assertNull("domainQuery.sortCriteria", domainQuery.getSortCriteria()); - Assert.assertNotNull("domainQuery.defaultSortCriteria", domainQuery.getDefaultSortCriteria()); - } - - @Test - public void newQueryNullTest() { - DomainQuery domainQuery = domainFactoryImpl.newQuery(null); - Assert.assertNull("Null expected.", domainQuery.getScopeId()); - Assert.assertNull("domainQuery.sortCriteria", domainQuery.getSortCriteria()); - Assert.assertNotNull("domainQuery.defaultSortCriteria", domainQuery.getDefaultSortCriteria()); - } - @Test public void newEntityTest() { Domain domain = domainFactoryImpl.newEntity(KapuaId.ONE); diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/domain/shiro/DomainQueryImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/domain/shiro/DomainQueryImplTest.java deleted file mode 100644 index e3be25cd1e3..00000000000 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/domain/shiro/DomainQueryImplTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2021, 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.service.authorization.domain.shiro; - -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.qa.markers.junit.JUnitTests; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; - - -@Category(JUnitTests.class) -public class DomainQueryImplTest { - - @Test - public void domainQueryImplWithoutParametersTest() { - DomainQueryImpl domainQueryImpl = new DomainQueryImpl(); - Assert.assertNull("Null expected.", domainQueryImpl.getScopeId()); - } - - @Test - public void domainQueryImplScopeIdParameterTest() { - DomainQueryImpl domainQueryImpl = new DomainQueryImpl(KapuaId.ONE); - Assert.assertEquals("Expected and actual values should be the same.", KapuaId.ONE, domainQueryImpl.getScopeId()); - } - - @Test - public void domainQueryImplNullScopeIdParameterTest() { - DomainQueryImpl domainQueryImpl = new DomainQueryImpl(null); - Assert.assertNull("Null expected.", domainQueryImpl.getScopeId()); - } -} \ No newline at end of file diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/group/shiro/GroupFactoryImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/group/shiro/GroupFactoryImplTest.java index 2615beda67f..1749b5c0181 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/group/shiro/GroupFactoryImplTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/group/shiro/GroupFactoryImplTest.java @@ -19,7 +19,6 @@ import org.eclipse.kapua.qa.markers.junit.JUnitTests; import org.eclipse.kapua.service.authorization.group.Group; import org.eclipse.kapua.service.authorization.group.GroupCreator; -import org.eclipse.kapua.service.authorization.group.GroupQuery; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -93,18 +92,6 @@ public void newEntityNullTest() { Assert.assertNull("Null expected.", group.getScopeId()); } - @Test - public void newQueryTest() { - GroupQuery groupQuery = groupFactoryImpl.newQuery(scopeId); - Assert.assertEquals("Expected and actual values should be the same.", scopeId, groupQuery.getScopeId()); - } - - @Test - public void newQueryNullTest() { - GroupQuery groupQuery = groupFactoryImpl.newQuery(null); - Assert.assertNull("Null expected.", groupQuery.getScopeId()); - } - @Test public void newCreatorTest() { GroupCreator groupCreator = groupFactoryImpl.newCreator(scopeId); diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/group/shiro/GroupQueryImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/group/shiro/GroupQueryImplTest.java deleted file mode 100644 index 0d60b149cbe..00000000000 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/group/shiro/GroupQueryImplTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2021, 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.service.authorization.group.shiro; - -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.qa.markers.junit.JUnitTests; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; - - -@Category(JUnitTests.class) -public class GroupQueryImplTest { - - @Test - public void groupQueryImplTest() { - GroupQueryImpl groupQueryImpl = new GroupQueryImpl(KapuaId.ONE); - Assert.assertEquals("Expected and actual values should be the same.", KapuaId.ONE, groupQueryImpl.getScopeId()); - Assert.assertNull("groupQueryImpl.sortCriteria", groupQueryImpl.getSortCriteria()); - Assert.assertNotNull("groupQueryImpl.defaultSortCriteria", groupQueryImpl.getDefaultSortCriteria()); - } - - @Test - public void groupQueryImplNullTest() { - GroupQueryImpl groupQueryImpl = new GroupQueryImpl(null); - Assert.assertNull("Null expected.", groupQueryImpl.getScopeId()); - Assert.assertNull("groupQueryImpl.sortCriteria", groupQueryImpl.getSortCriteria()); - Assert.assertNotNull("groupQueryImpl.defaultSortCriteria", groupQueryImpl.getDefaultSortCriteria()); - } -} \ No newline at end of file diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/role/shiro/RoleFactoryImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/role/shiro/RoleFactoryImplTest.java index b4fe45669e9..38f079e9a71 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/role/shiro/RoleFactoryImplTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/role/shiro/RoleFactoryImplTest.java @@ -19,7 +19,6 @@ import org.eclipse.kapua.service.authorization.role.Role; import org.eclipse.kapua.service.authorization.role.RoleCreator; import org.eclipse.kapua.service.authorization.role.RolePermission; -import org.eclipse.kapua.service.authorization.role.RoleQuery; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -77,18 +76,6 @@ public void newCreatorNullTest() { Assert.assertNull("Null expected.", roleFactoryImpl.newCreator(null).getScopeId()); } - @Test - public void newQueryTest() { - Assert.assertTrue("True expected.", roleFactoryImpl.newQuery(scopeId) instanceof RoleQuery); - Assert.assertEquals("Expected and actual values should be the same.", scopeId, roleFactoryImpl.newQuery(scopeId).getScopeId()); - } - - @Test - public void newQueryNullTest() { - Assert.assertTrue("True expected.", roleFactoryImpl.newQuery(null) instanceof RoleQuery); - Assert.assertNull("Null expected.", roleFactoryImpl.newQuery(null).getScopeId()); - } - @Test public void newRolePermissionTest() { Assert.assertTrue("True expected.", roleFactoryImpl.newRolePermission() instanceof RolePermission); diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/role/shiro/RolePermissionQueryImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/role/shiro/RolePermissionQueryImplTest.java deleted file mode 100644 index 42cd8f69d16..00000000000 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/role/shiro/RolePermissionQueryImplTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2021, 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.service.authorization.role.shiro; - -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.qa.markers.junit.JUnitTests; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; - - -@Category(JUnitTests.class) -public class RolePermissionQueryImplTest { - - @Test - public void rolePermissionQueryImplWithoutParametersTest() { - RolePermissionQueryImpl rolePermissionQueryImpl = new RolePermissionQueryImpl(); - Assert.assertNull("Null expected.", rolePermissionQueryImpl.getScopeId()); - Assert.assertNull("rolePermissionQueryImpl.sortCriteria", rolePermissionQueryImpl.getSortCriteria()); - Assert.assertNotNull("rolePermissionQueryImpl.defaultSortCriteria", rolePermissionQueryImpl.getDefaultSortCriteria()); - } - - @Test - public void rolePermissionQueryImpScopeIdTest() { - KapuaId[] scopeIds = {null, KapuaId.ANY}; - - for (KapuaId scopeId : scopeIds) { - RolePermissionQueryImpl rolePermissionQueryImpl = new RolePermissionQueryImpl(scopeId); - Assert.assertEquals("Expected and actual values should be the same.", scopeId, rolePermissionQueryImpl.getScopeId()); - Assert.assertNull("rolePermissionQueryImpl.sortCriteria", rolePermissionQueryImpl.getSortCriteria()); - Assert.assertNotNull("rolePermissionQueryImpl.defaultSortCriteria", rolePermissionQueryImpl.getDefaultSortCriteria()); - } - } -} \ No newline at end of file diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/role/shiro/RoleQueryImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/role/shiro/RoleQueryImplTest.java deleted file mode 100644 index 929af6c9a56..00000000000 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/role/shiro/RoleQueryImplTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2021, 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.service.authorization.role.shiro; - -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.qa.markers.junit.JUnitTests; -import org.junit.Assert; -import org.junit.Test; -import org.junit.experimental.categories.Category; - - -@Category(JUnitTests.class) -public class RoleQueryImplTest { - - @Test - public void rolePermissionQueryImplWithoutParametersTest() { - RoleQueryImpl roleQueryImpl = new RoleQueryImpl(); - Assert.assertNull("Null expected.", roleQueryImpl.getScopeId()); - Assert.assertNull("roleQueryImpl.sortCriteria", roleQueryImpl.getSortCriteria()); - Assert.assertNotNull("roleQueryImpl.defaultSortCriteria", roleQueryImpl.getDefaultSortCriteria()); - } - - @Test - public void rolePermissionQueryImpScopeIdTest() { - KapuaId[] scopeIds = {null, KapuaId.ANY}; - - for (KapuaId scopeId : scopeIds) { - RoleQueryImpl roleQueryImpl = new RoleQueryImpl(scopeId); - Assert.assertEquals("Expected and actual values should be the same.", scopeId, roleQueryImpl.getScopeId()); - Assert.assertNull("roleQueryImpl.sortCriteria", roleQueryImpl.getSortCriteria()); - Assert.assertNotNull("roleQueryImpl.defaultSortCriteria", roleQueryImpl.getDefaultSortCriteria()); - } - } -} \ No newline at end of file diff --git a/service/security/test-steps/src/main/java/org/eclipse/kapua/service/authorization/steps/AuthorizationServiceSteps.java b/service/security/test-steps/src/main/java/org/eclipse/kapua/service/authorization/steps/AuthorizationServiceSteps.java index 9092ef37565..20e4e347ecb 100644 --- a/service/security/test-steps/src/main/java/org/eclipse/kapua/service/authorization/steps/AuthorizationServiceSteps.java +++ b/service/security/test-steps/src/main/java/org/eclipse/kapua/service/authorization/steps/AuthorizationServiceSteps.java @@ -27,6 +27,7 @@ import org.eclipse.kapua.model.KapuaNamedEntityAttributes; import org.eclipse.kapua.model.domain.Actions; import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.model.query.KapuaQuery; import org.eclipse.kapua.model.query.predicate.AttributePredicate; import org.eclipse.kapua.qa.common.StepData; import org.eclipse.kapua.qa.common.TestBase; @@ -43,7 +44,6 @@ import org.eclipse.kapua.service.authorization.access.AccessInfoCreator; import org.eclipse.kapua.service.authorization.access.AccessInfoFactory; import org.eclipse.kapua.service.authorization.access.AccessInfoListResult; -import org.eclipse.kapua.service.authorization.access.AccessInfoQuery; import org.eclipse.kapua.service.authorization.access.AccessInfoService; import org.eclipse.kapua.service.authorization.access.AccessPermission; import org.eclipse.kapua.service.authorization.access.AccessPermissionCreator; @@ -55,19 +55,16 @@ import org.eclipse.kapua.service.authorization.access.AccessRoleCreator; import org.eclipse.kapua.service.authorization.access.AccessRoleFactory; import org.eclipse.kapua.service.authorization.access.AccessRoleListResult; -import org.eclipse.kapua.service.authorization.access.AccessRoleQuery; import org.eclipse.kapua.service.authorization.access.AccessRoleService; import org.eclipse.kapua.service.authorization.domain.Domain; import org.eclipse.kapua.service.authorization.domain.DomainCreator; import org.eclipse.kapua.service.authorization.domain.DomainFactory; import org.eclipse.kapua.service.authorization.domain.DomainListResult; -import org.eclipse.kapua.service.authorization.domain.DomainQuery; import org.eclipse.kapua.service.authorization.domain.DomainRegistryService; import org.eclipse.kapua.service.authorization.group.Group; import org.eclipse.kapua.service.authorization.group.GroupCreator; import org.eclipse.kapua.service.authorization.group.GroupFactory; import org.eclipse.kapua.service.authorization.group.GroupListResult; -import org.eclipse.kapua.service.authorization.group.GroupQuery; import org.eclipse.kapua.service.authorization.group.GroupService; import org.eclipse.kapua.service.authorization.permission.Permission; import org.eclipse.kapua.service.authorization.permission.PermissionFactory; @@ -80,7 +77,6 @@ import org.eclipse.kapua.service.authorization.role.RolePermissionCreator; import org.eclipse.kapua.service.authorization.role.RolePermissionFactory; import org.eclipse.kapua.service.authorization.role.RolePermissionListResult; -import org.eclipse.kapua.service.authorization.role.RolePermissionQuery; import org.eclipse.kapua.service.authorization.role.RolePermissionService; import org.eclipse.kapua.service.authorization.role.RoleQuery; import org.eclipse.kapua.service.authorization.role.RoleService; @@ -385,18 +381,18 @@ public void deleteLastCreatedRolePermission() throws Exception { @When("I count the roles in scope {int}") public void countRolesInScope(int scope) throws Exception { - updateCount(() -> (int) roleService.count(roleFactory.newQuery(getKapuaId(scope)))); + updateCount(() -> (int) roleService.count(new KapuaQuery(getKapuaId(scope)))); } @When("I count the role permissions in scope {int}") public void countRolePermissionsInScope(Integer scope) throws Exception { - updateCount(() -> (int) rolePermissionService.count(rolePermissionFactory.newQuery(getKapuaId(scope)))); + updateCount(() -> (int) rolePermissionService.count(new KapuaQuery(getKapuaId(scope)))); } @When("I query for the role {string} in scope {int}") public void queryForRoleInScope(String name, Integer scope) throws Exception { KapuaId tmpId = getKapuaId(scope); - RoleQuery tmpQuery = roleFactory.newQuery(tmpId); + KapuaQuery tmpQuery = new KapuaQuery(tmpId); tmpQuery.setPredicate(tmpQuery.attributePredicate(KapuaNamedEntityAttributes.NAME, name, AttributePredicate.Operator.EQUAL)); stepData.remove(ROLE_LIST); stepData.remove(ROLE_FOUND); @@ -526,7 +522,6 @@ public void checkRoleForUpdates() { public void performRoleFactorySanityChecks() { Assert.assertNotNull(roleFactory.newEntity(SYS_SCOPE_ID)); Assert.assertNotNull(roleFactory.newCreator(SYS_SCOPE_ID)); - Assert.assertNotNull(roleFactory.newQuery(SYS_SCOPE_ID)); Assert.assertNotNull(roleFactory.newRolePermission()); } @@ -534,7 +529,6 @@ public void performRoleFactorySanityChecks() { public void performRolePermissionFactorySanityChecks() { Assert.assertNotNull(rolePermissionFactory.newEntity(SYS_SCOPE_ID)); Assert.assertNotNull(rolePermissionFactory.newCreator(SYS_SCOPE_ID)); - Assert.assertNotNull(rolePermissionFactory.newQuery(SYS_SCOPE_ID)); } @Then("The role comparator does its job") @@ -628,7 +622,7 @@ public void createAListOfDomains(List domains) throws Exception { @Given("I select the domain {string}") public void selectExistingDomain(String name) throws Exception { - DomainQuery query = domainFactory.newQuery(KapuaId.ANY); + final KapuaQuery query = new KapuaQuery(KapuaId.ANY); query.setPredicate(query.attributePredicate(KapuaNamedEntityAttributes.NAME, name, AttributePredicate.Operator.EQUAL)); try { primeException(); @@ -675,12 +669,12 @@ public void deleteRandomDomainId() throws Exception { @When("I count the domain entries in the database") public void countDomainEntries() throws Exception { - updateCount(() -> (int) domainRegistryService.count(domainFactory.newQuery(null))); + updateCount(() -> (int) domainRegistryService.count(new KapuaQuery((KapuaId) null))); } @When("I query for domains with the name {string}") public void queryForNamedDomain(String name) throws Exception { - DomainQuery query = domainFactory.newQuery(null); + final KapuaQuery query = new KapuaQuery((KapuaId) null); query.setPredicate(query.attributePredicate(KapuaNamedEntityAttributes.NAME, name, AttributePredicate.Operator.EQUAL)); stepData.remove("DomainList"); try { @@ -822,7 +816,7 @@ public void setGroupConfigurationValue(List cucConfigs) throws Except @When("I count the group entries in the database") public void countGroupEntries() throws Exception { - updateCount(() -> (int) groupService.count(groupFactory.newQuery(SYS_SCOPE_ID))); + updateCount(() -> (int) groupService.count(new KapuaQuery(SYS_SCOPE_ID))); } @Given("I create the group(s)") @@ -878,7 +872,7 @@ public void updateGroupWithFalseId() throws Exception { public void deleteGroupWithName(String groupName) throws Exception { primeException(); try { - GroupQuery tmpQuery = groupFactory.newQuery(getCurrentScopeId()); + final KapuaQuery tmpQuery = new KapuaQuery(getCurrentScopeId()); tmpQuery.setPredicate(tmpQuery.attributePredicate(KapuaNamedEntityAttributes.NAME, groupName, AttributePredicate.Operator.EQUAL)); Group group = groupService.query(tmpQuery).getFirstItem(); groupService.delete(group.getScopeId(), group.getId()); @@ -924,13 +918,13 @@ public void findGroupByRememberedId(String groupName) throws Exception { @When("I count all the groups in scope {int}") public void countGroupsInScope(int scope) throws Exception { - updateCount(() -> (int) groupService.count(groupFactory.newQuery(getKapuaId(scope)))); + updateCount(() -> (int) groupService.count(new KapuaQuery(getKapuaId(scope)))); } @When("I query for the group {string} in scope {int}") public void queryForGroup(String name, int scope) throws Exception { KapuaId tmpId = getKapuaId(scope); - GroupQuery tmpQuery = groupFactory.newQuery(tmpId); + final KapuaQuery tmpQuery = new KapuaQuery(tmpId); tmpQuery.setPredicate(tmpQuery.attributePredicate(KapuaNamedEntityAttributes.NAME, name, AttributePredicate.Operator.EQUAL)); stepData.remove("GroupList"); stepData.remove(GROUP); @@ -1214,7 +1208,7 @@ public void findLastCreatedAccessRole() throws Exception { @When("I count the access roles in scope {int}") public void countAccesRolesInScope(Integer scope) throws Exception { - updateCount(() -> (int) accessRoleService.count(accessRoleFactory.newQuery(getKapuaId(scope)))); + updateCount(() -> (int) accessRoleService.count(new KapuaQuery(getKapuaId(scope)))); } @When("I delete the last created access role entry") @@ -1243,14 +1237,14 @@ public void deleteLastCreatedAccessInfoEntity() throws Exception { @When("I count the access info entities for scope {int}") public void countAccessInfoEntitiesInScope(Integer scope) throws Exception { - updateCount(() -> (int) accessInfoService.count(accessInfoFactory.newQuery(getKapuaId(scope)))); + updateCount(() -> (int) accessInfoService.count(new KapuaQuery(getKapuaId(scope)))); } @When("I query for the access info entities for the last user") public void queryForLastUserAccessInfoEntities() throws Exception { KapuaId currScope = (KapuaId) stepData.get(LAST_ACCOUNT_ID); User user = (User) stepData.get("User"); - AccessInfoQuery tmpQuery = accessInfoFactory.newQuery(currScope); + final KapuaQuery tmpQuery = new KapuaQuery(currScope); tmpQuery.setPredicate(tmpQuery.attributePredicate(AccessInfoAttributes.USER_ID, user.getId(), AttributePredicate.Operator.EQUAL)); try { primeException(); @@ -1315,7 +1309,7 @@ public void deleteLastCreatedPermission() throws Exception { @When("I count the permissions in scope {int}") public void countPermissionsForScope(Integer scope) throws Exception { - updateCount(() -> (int) accessPermissionService.count(accessPermissionFactory.newQuery(getKapuaId(scope)))); + updateCount(() -> (int) accessPermissionService.count(new KapuaQuery(getKapuaId(scope)))); } @When("I check the sanity of the access info factory") @@ -1324,7 +1318,6 @@ public void accessInfoServiceSanityCheck() throws Exception { primeException(); Assert.assertNotNull(accessInfoFactory.newCreator(getKapuaId())); Assert.assertNotNull(accessInfoFactory.newEntity(null)); - Assert.assertNotNull(accessInfoFactory.newQuery(getKapuaId())); AccessInfoCreator tmpCreator = accessInfoFactory.newCreator(getKapuaId()); Assert.assertNotNull(tmpCreator); AccessInfo tmpAccInfo = accessInfoFactory.newEntity(getKapuaId()); @@ -1341,7 +1334,6 @@ public void accessPermissionFactorySanityCheck() { Assert.assertNotNull(accessPermissionFactory.newCreator(getKapuaId())); Assert.assertNotNull(accessPermissionFactory.newEntity(null)); Assert.assertNotNull(accessPermissionFactory.newEntity(getKapuaId())); - Assert.assertNotNull(accessPermissionFactory.newQuery(getKapuaId())); KapuaId tmpId = getKapuaId(); AccessPermissionCreator tmpCreator = accessPermissionFactory.newCreator(tmpId); Assert.assertNotNull(tmpCreator); @@ -1367,7 +1359,6 @@ public void accessRoleFactorySanityCheck() throws Exception { primeException(); Assert.assertNotNull(accessRoleFactory.newCreator(getKapuaId())); Assert.assertNotNull(accessRoleFactory.newEntity(getKapuaId())); - Assert.assertNotNull(accessRoleFactory.newQuery(getKapuaId())); KapuaId tmpId = getKapuaId(); AccessRoleCreator tmpCreator = accessRoleFactory.newCreator(tmpId); Assert.assertNotNull(tmpCreator); @@ -1617,10 +1608,10 @@ public void checkPermissionComparison() { public void accessRoleWithNameIsFinded(String roleName) throws Exception { try { primeException(); - RoleQuery roleQuery = roleFactory.newQuery(getCurrentScopeId()); + final KapuaQuery roleQuery = new KapuaQuery(getCurrentScopeId()); roleQuery.setPredicate(roleQuery.attributePredicate(KapuaNamedEntityAttributes.NAME, roleName)); RoleListResult roleList = roleService.query(roleQuery); - AccessRoleQuery accessRoleQuery = accessRoleFactory.newQuery(getCurrentScopeId()); + final KapuaQuery accessRoleQuery = new KapuaQuery(getCurrentScopeId()); accessRoleQuery.setPredicate(accessRoleQuery.attributePredicate(AccessRoleAttributes.ROLE_ID, roleList.getFirstItem().getId())); AccessRoleListResult searchAccessRole = accessRoleService.query(accessRoleQuery); Assert.assertTrue(searchAccessRole.getSize() > 0); @@ -1721,7 +1712,7 @@ public void iFindLastCreatedGroup(String groupName) throws Exception { public void iFindRoleWithName(String roleName) throws Exception { try { primeException(); - RoleQuery roleQuery = roleFactory.newQuery(getCurrentScopeId()); + final RoleQuery roleQuery = new RoleQuery(getCurrentScopeId()); roleQuery.setPredicate(roleQuery.attributePredicate(KapuaNamedEntityAttributes.NAME, roleName, AttributePredicate.Operator.EQUAL)); stepData.remove(ROLE_LIST_RESULT); stepData.remove("Role"); @@ -1784,7 +1775,7 @@ public void iSearchForThePermissionsOfTheRole(String roleName) throws Exception Role role = (Role) stepData.get("Role"); ArrayList rolePermissionList = new ArrayList<>(); Assert.assertEquals(roleName, role.getName()); - RolePermissionQuery rolePermissionQuery = rolePermissionFactory.newQuery(getCurrentScopeId()); + final KapuaQuery rolePermissionQuery = new KapuaQuery(getCurrentScopeId()); rolePermissionQuery.setPredicate(rolePermissionQuery.attributePredicate(RolePermissionAttributes.ROLE_ID, role.getId(), AttributePredicate.Operator.EQUAL)); RolePermissionListResult rolePermissions = rolePermissionService.query(rolePermissionQuery); stepData.remove(ROLE_PERMISSIONS); @@ -1832,7 +1823,7 @@ public void iDeleteTheLastCreatedAdminRolePermissions() throws Exception { public void iCountTheAccessRolesFromUser(String userName) throws Exception { User lastUser = (User) stepData.get("User"); AccessInfo accessInfo = (AccessInfo) stepData.get(ACCESS_INFO); - AccessRoleQuery tmpQuery = accessRoleFactory.newQuery(getCurrentScopeId()); + final KapuaQuery tmpQuery = new KapuaQuery(getCurrentScopeId()); tmpQuery.setPredicate(tmpQuery.attributePredicate(AccessRoleAttributes.ACCESS_INFO_ID, accessInfo.getId(), AttributePredicate.Operator.EQUAL)); Assert.assertEquals(userName, lastUser.getName()); updateCount(() -> (int) accessRoleService.count(tmpQuery)); @@ -1844,7 +1835,7 @@ public void iSearchGrantedUserToRole() throws Exception { int grantedUsersCount = 0; try { primeException(); - AccessRoleQuery accessRoleQuery = accessRoleFactory.newQuery(getCurrentScopeId()); + final KapuaQuery accessRoleQuery = new KapuaQuery(getCurrentScopeId()); AccessRoleListResult accessRoleList = accessRoleService.query(accessRoleQuery); for (AccessRole a : accessRoleList.getItems()) { AccessInfo accessInfo = accessInfoService.find(getCurrentScopeId(), a.getAccessInfoId()); @@ -1878,7 +1869,7 @@ public void iFindGrantedUsersWithName(List grantedUsers) throws Excepti public void iFindSpecificRoleInChildAccount(String roleName, String accountName) throws Exception { Account account = (Account) stepData.get(LAST_ACCOUNT); Assert.assertEquals(accountName, account.getName()); - RoleQuery roleQuery = roleFactory.newQuery(account.getId()); + final RoleQuery roleQuery = new RoleQuery(account.getId()); roleQuery.setPredicate(roleQuery.attributePredicate(KapuaNamedEntityAttributes.NAME, roleName, AttributePredicate.Operator.EQUAL)); RoleListResult childRolesList = roleService.query(roleQuery); stepData.put("ChildRolesList", childRolesList); @@ -1936,7 +1927,7 @@ public void iSearchForThePermissionsOfFoundedRoleInSubaccount(String roleName, S Account account = (Account) stepData.get(LAST_ACCOUNT); Assert.assertEquals(accountName, account.getName()); ArrayList rolePermissionList = new ArrayList<>(); - RolePermissionQuery rolePermissionQuery = rolePermissionFactory.newQuery(account.getId()); + final KapuaQuery rolePermissionQuery = new KapuaQuery(account.getId()); rolePermissionQuery.setPredicate(rolePermissionQuery.attributePredicate(RolePermissionAttributes.ROLE_ID, role.getId(), AttributePredicate.Operator.EQUAL)); RolePermissionListResult rolePermissions = rolePermissionService.query(rolePermissionQuery); stepData.remove(CHILD_ACCOUNT_ROLE_PERMISSION); @@ -2019,7 +2010,7 @@ public void iSearchForAccessRolesFromTheLastUser(String userName) throws Excepti AccessInfo accessInfo = (AccessInfo) stepData.get(ACCESS_INFO); User user = (User) stepData.get("User"); Assert.assertEquals(userName, user.getName()); - AccessRoleQuery accessRoleQuery = accessRoleFactory.newQuery(getCurrentScopeId()); + final KapuaQuery accessRoleQuery = new KapuaQuery(getCurrentScopeId()); accessRoleQuery.setPredicate(accessRoleQuery.attributePredicate(AccessRoleAttributes.ACCESS_INFO_ID, accessInfo.getId(), AttributePredicate.Operator.EQUAL)); try { primeException(); @@ -2050,7 +2041,7 @@ public void iCountTheAccessRolesFromUserInChildAccount(String accountName) throw Account account = (Account) stepData.get(LAST_ACCOUNT); AccessInfo accessInfo = (AccessInfo) stepData.get(CHILD_ACCOUNT_ACCESS_INFO); Assert.assertEquals(accountName, account.getName()); - AccessRoleQuery tmpQuery = accessRoleFactory.newQuery(account.getId()); + final KapuaQuery tmpQuery = new KapuaQuery(account.getId()); tmpQuery.setPredicate(tmpQuery.attributePredicate(AccessRoleAttributes.ACCESS_INFO_ID, accessInfo.getId(), AttributePredicate.Operator.EQUAL)); updateCount(() -> (int) accessRoleService.count(tmpQuery)); } @@ -2142,7 +2133,7 @@ public void iCreateRoles(int num) throws Exception { @When("I count the roles in the database") public void iCountTheRolesInTheDatabase() throws Exception { - updateCount(() -> (int) (roleService.count(roleFactory.newQuery(getCurrentScopeId())) - 1)); + updateCount(() -> (int) (roleService.count(new RoleQuery(getCurrentScopeId())) - 1)); } @And("I update the role description to {string}") @@ -2177,7 +2168,7 @@ public void iDeleteTheRoleWithNameAndDescription(String roleName, String roleDes public void iFindARoleWithDescription(String roleDesc) throws Throwable { try { primeException(); - RoleQuery roleQuery = roleFactory.newQuery(getCurrentScopeId()); + RoleQuery roleQuery = new RoleQuery(getCurrentScopeId()); roleQuery.setPredicate(roleQuery.attributePredicate(KapuaNamedEntityAttributes.DESCRIPTION, roleDesc, AttributePredicate.Operator.EQUAL)); stepData.remove(ROLE_LIST_RESULT); stepData.remove(ROLE_FOUND); @@ -2246,7 +2237,7 @@ public void iUpdateTheRoleNameWithSpecialCharacters(String invalidSymbols) throw @And("I change the group name from {string} to {string}") public void iChangeTheGroupNameTo(String groupName, String newGroupName) throws Exception { try { - GroupQuery query = groupFactory.newQuery(SYS_SCOPE_ID); + final KapuaQuery query = new KapuaQuery(SYS_SCOPE_ID); query.setPredicate(query.attributePredicate(KapuaNamedEntityAttributes.NAME, groupName, AttributePredicate.Operator.EQUAL)); GroupListResult queryResult = groupService.query(query); Group group = queryResult.getFirstItem(); @@ -2261,7 +2252,7 @@ public void iChangeTheGroupNameTo(String groupName, String newGroupName) throws @And("I change the description of group with name {string} to {string}") public void iChangeTheGroupDescriptionTo(String groupName, String groupDescription) throws Exception { try { - GroupQuery query = groupFactory.newQuery(SYS_SCOPE_ID); + final KapuaQuery query = new KapuaQuery(SYS_SCOPE_ID); query.setPredicate(query.attributePredicate(KapuaNamedEntityAttributes.NAME, groupName, AttributePredicate.Operator.EQUAL)); GroupListResult queryResult = groupService.query(query); Group group = queryResult.getFirstItem(); @@ -2276,7 +2267,7 @@ public void iChangeTheGroupDescriptionTo(String groupName, String groupDescripti public void iSearchForAGroupNamed(String groupName) throws Exception { try { stepData.remove(GROUP_SECOND); - GroupQuery query = groupFactory.newQuery(SYS_SCOPE_ID); + final KapuaQuery query = new KapuaQuery(SYS_SCOPE_ID); query.setPredicate(query.attributePredicate(KapuaNamedEntityAttributes.NAME, groupName, AttributePredicate.Operator.EQUAL)); GroupListResult queryResult = groupService.query(query); Group foundGroup = queryResult.getFirstItem(); 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 720f8c78b5e..bea6be1ae5c 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 @@ -32,25 +32,23 @@ import org.eclipse.kapua.commons.metric.CommonsMetric; import org.eclipse.kapua.commons.metric.MetricsService; import org.eclipse.kapua.commons.metric.MetricsServiceImpl; -import org.eclipse.kapua.commons.model.query.QueryFactoryImpl; import org.eclipse.kapua.commons.service.event.store.internal.EventStoreRecordImplJpaRepository; import org.eclipse.kapua.commons.service.internal.cache.CacheManagerProvider; import org.eclipse.kapua.commons.setting.system.SystemSetting; import org.eclipse.kapua.commons.util.xml.XmlUtil; import org.eclipse.kapua.locator.KapuaLocator; import org.eclipse.kapua.model.config.metatype.KapuaMetatypeFactory; -import org.eclipse.kapua.model.query.QueryFactory; import org.eclipse.kapua.qa.common.MockedLocator; import org.eclipse.kapua.qa.common.TestJAXBContextProvider; -import org.eclipse.kapua.service.authentication.credential.handler.CredentialTypeHandler; import org.eclipse.kapua.service.authentication.credential.CredentialFactory; import org.eclipse.kapua.service.authentication.credential.CredentialService; +import org.eclipse.kapua.service.authentication.credential.handler.CredentialTypeHandler; import org.eclipse.kapua.service.authentication.credential.handler.shiro.ApiKeyCredentialTypeHandler; +import org.eclipse.kapua.service.authentication.credential.handler.shiro.JwtCredentialTypeHandler; +import org.eclipse.kapua.service.authentication.credential.handler.shiro.PasswordCredentialTypeHandler; import org.eclipse.kapua.service.authentication.credential.shiro.CredentialFactoryImpl; import org.eclipse.kapua.service.authentication.credential.shiro.CredentialImplJpaRepository; import org.eclipse.kapua.service.authentication.credential.shiro.CredentialServiceImpl; -import org.eclipse.kapua.service.authentication.credential.handler.shiro.JwtCredentialTypeHandler; -import org.eclipse.kapua.service.authentication.credential.handler.shiro.PasswordCredentialTypeHandler; import org.eclipse.kapua.service.authentication.credential.shiro.PasswordResetterImpl; import org.eclipse.kapua.service.authentication.credential.shiro.PasswordValidator; import org.eclipse.kapua.service.authentication.credential.shiro.PasswordValidatorImpl; @@ -135,7 +133,6 @@ protected void configure() { // skip } - bind(QueryFactory.class).toInstance(new QueryFactoryImpl()); bind(KapuaJpaRepositoryConfiguration.class).toInstance(new KapuaJpaRepositoryConfiguration()); bind(AuthorizationService.class).toInstance(mockedAuthorization); @@ -202,16 +199,16 @@ protected void configure() { new PasswordValidatorImpl(credentialServiceConfigurationManager)), new HashSet() {{ add( - new PasswordCredentialTypeHandler( - new KapuaJpaTxManagerFactory(maxInsertAttempts).create("kapua-authorization"), - credentialRepository, - authenticationUtils, - passwordValidator) + new PasswordCredentialTypeHandler( + new KapuaJpaTxManagerFactory(maxInsertAttempts).create("kapua-authorization"), + credentialRepository, + authenticationUtils, + passwordValidator) ); add( - new ApiKeyCredentialTypeHandler( - new KapuaAuthenticationSetting(), - authenticationUtils) + new ApiKeyCredentialTypeHandler( + new KapuaAuthenticationSetting(), + authenticationUtils) ); add(new JwtCredentialTypeHandler(authenticationUtils)); }} diff --git a/service/system/test/src/test/java/org/eclipse/kapua/service/systeminfo/test/SystemInfoLocatorConfiguration.java b/service/system/test/src/test/java/org/eclipse/kapua/service/systeminfo/test/SystemInfoLocatorConfiguration.java index 6d472a6a28c..68dad7fe576 100644 --- a/service/system/test/src/test/java/org/eclipse/kapua/service/systeminfo/test/SystemInfoLocatorConfiguration.java +++ b/service/system/test/src/test/java/org/eclipse/kapua/service/systeminfo/test/SystemInfoLocatorConfiguration.java @@ -12,13 +12,6 @@ *******************************************************************************/ package org.eclipse.kapua.service.systeminfo.test; -import com.codahale.metrics.MetricRegistry; -import com.google.inject.AbstractModule; -import com.google.inject.Guice; -import com.google.inject.Injector; -import com.google.inject.Singleton; -import com.google.inject.name.Names; -import io.cucumber.java.Before; import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.commons.configuration.metatype.KapuaMetatypeFactoryImpl; import org.eclipse.kapua.commons.crypto.CryptoUtil; @@ -27,12 +20,10 @@ import org.eclipse.kapua.commons.metric.CommonsMetric; import org.eclipse.kapua.commons.metric.MetricsService; import org.eclipse.kapua.commons.metric.MetricsServiceImpl; -import org.eclipse.kapua.commons.model.query.QueryFactoryImpl; import org.eclipse.kapua.commons.service.internal.cache.CacheManagerProvider; import org.eclipse.kapua.commons.setting.system.SystemSetting; import org.eclipse.kapua.locator.KapuaLocator; import org.eclipse.kapua.model.config.metatype.KapuaMetatypeFactory; -import org.eclipse.kapua.model.query.QueryFactory; import org.eclipse.kapua.qa.common.MockedLocator; import org.eclipse.kapua.service.account.AccountFactory; import org.eclipse.kapua.service.account.AccountService; @@ -51,13 +42,20 @@ import org.mockito.Matchers; import org.mockito.Mockito; +import com.codahale.metrics.MetricRegistry; +import com.google.inject.AbstractModule; +import com.google.inject.Guice; +import com.google.inject.Injector; +import com.google.inject.Singleton; +import com.google.inject.name.Names; + +import io.cucumber.java.Before; + @Singleton public class SystemInfoLocatorConfiguration { /** - * Setup DI with Google Guice DI. - * Create mocked and non mocked service under test and bind them with Guice. - * It is based on custom MockedLocator locator that is meant for service unit tests. + * Setup DI with Google Guice DI. Create mocked and non mocked service under test and bind them with Guice. It is based on custom MockedLocator locator that is meant for service unit tests. */ @Before(value = "@setup", order = 1) public void setupDI() { @@ -87,8 +85,6 @@ protected void configure() { // skip } - bind(QueryFactory.class).toInstance(new QueryFactoryImpl()); - bind(AuthorizationService.class).toInstance(mockedAuthorization); // Inject mocked Permission Factory bind(PermissionFactory.class).toInstance(Mockito.mock(PermissionFactory.class)); diff --git a/service/tag/api/src/main/java/org/eclipse/kapua/service/tag/TagFactory.java b/service/tag/api/src/main/java/org/eclipse/kapua/service/tag/TagFactory.java index 9f115487ef9..5e5ef6d9ed5 100644 --- a/service/tag/api/src/main/java/org/eclipse/kapua/service/tag/TagFactory.java +++ b/service/tag/api/src/main/java/org/eclipse/kapua/service/tag/TagFactory.java @@ -21,7 +21,7 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface TagFactory extends KapuaEntityFactory { +public interface TagFactory extends KapuaEntityFactory { /** * Instantiates a new {@link TagCreator}. diff --git a/service/tag/api/src/main/java/org/eclipse/kapua/service/tag/TagMatchPredicate.java b/service/tag/api/src/main/java/org/eclipse/kapua/service/tag/TagMatchPredicate.java index a1df13b4279..f28794fb894 100644 --- a/service/tag/api/src/main/java/org/eclipse/kapua/service/tag/TagMatchPredicate.java +++ b/service/tag/api/src/main/java/org/eclipse/kapua/service/tag/TagMatchPredicate.java @@ -12,7 +12,24 @@ *******************************************************************************/ package org.eclipse.kapua.service.tag; -import org.eclipse.kapua.model.query.predicate.MatchPredicate; -public interface TagMatchPredicate extends MatchPredicate { +import java.util.Arrays; + +import org.eclipse.kapua.model.query.predicate.AbstractMatchPredicate; + +public class TagMatchPredicate extends AbstractMatchPredicate { + + /** + * Constructor. + * + * @param matchTerm + * @since 2.1.0 + */ + public TagMatchPredicate(T matchTerm) { + this.attributeNames = Arrays.asList( + TagAttributes.DESCRIPTION, + TagAttributes.NAME + ); + this.matchTerm = matchTerm; + } } diff --git a/service/tag/api/src/main/java/org/eclipse/kapua/service/tag/TagQuery.java b/service/tag/api/src/main/java/org/eclipse/kapua/service/tag/TagQuery.java index 0bbfc29faeb..dea8bfbf590 100644 --- a/service/tag/api/src/main/java/org/eclipse/kapua/service/tag/TagQuery.java +++ b/service/tag/api/src/main/java/org/eclipse/kapua/service/tag/TagQuery.java @@ -12,13 +12,14 @@ *******************************************************************************/ package org.eclipse.kapua.service.tag; -import org.eclipse.kapua.model.query.KapuaQuery; - import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.model.query.KapuaQuery; + /** * {@link Tag} {@link KapuaQuery} definition. * @@ -27,17 +28,35 @@ */ @XmlRootElement(name = "query") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = TagXmlRegistry.class, factoryMethod = "newQuery") -public interface TagQuery extends KapuaQuery { +@XmlType +public class TagQuery extends KapuaQuery { + + public TagQuery() { + } + + /** + * Constructor. + * + * @param scopeId + * The {@link #getScopeId()}. + * @since 1.0.0 + */ + public TagQuery(KapuaId scopeId) { + super(scopeId); + } /** * Instantiates a new {@link TagMatchPredicate}. * - * @param matchTerm The term to use to match. - * @param The type of the term + * @param matchTerm + * The term to use to match. + * @param + * The type of the term * @return The newly instantiated {@link TagMatchPredicate}. * @since 2.1.0 */ - TagMatchPredicate matchPredicate(T matchTerm); + public TagMatchPredicate matchPredicate(T matchTerm) { + return new TagMatchPredicate<>(matchTerm); + } } diff --git a/service/tag/api/src/main/java/org/eclipse/kapua/service/tag/TagXmlRegistry.java b/service/tag/api/src/main/java/org/eclipse/kapua/service/tag/TagXmlRegistry.java index c12356b4f6d..3b5f285ab93 100644 --- a/service/tag/api/src/main/java/org/eclipse/kapua/service/tag/TagXmlRegistry.java +++ b/service/tag/api/src/main/java/org/eclipse/kapua/service/tag/TagXmlRegistry.java @@ -40,6 +40,6 @@ public TagCreator newTagCreator() { } public TagQuery newQuery() { - return tagFactory.newQuery(null); + return new TagQuery(null); } } diff --git a/service/tag/internal/src/main/java/org/eclipse/kapua/service/tag/internal/TagFactoryImpl.java b/service/tag/internal/src/main/java/org/eclipse/kapua/service/tag/internal/TagFactoryImpl.java index 49778c6df75..bbec50b8bff 100644 --- a/service/tag/internal/src/main/java/org/eclipse/kapua/service/tag/internal/TagFactoryImpl.java +++ b/service/tag/internal/src/main/java/org/eclipse/kapua/service/tag/internal/TagFactoryImpl.java @@ -19,7 +19,6 @@ import org.eclipse.kapua.service.tag.Tag; import org.eclipse.kapua.service.tag.TagCreator; import org.eclipse.kapua.service.tag.TagFactory; -import org.eclipse.kapua.service.tag.TagQuery; /** * {@link TagFactory} implementation. @@ -43,11 +42,6 @@ public Tag newEntity(KapuaId scopeId) { return new TagImpl(scopeId); } - @Override - public TagQuery newQuery(KapuaId scopeId) { - return new TagQueryImpl(scopeId); - } - @Override public TagCreator newCreator(KapuaId scopeId) { return new TagCreatorImpl(scopeId); diff --git a/service/tag/internal/src/main/java/org/eclipse/kapua/service/tag/internal/TagMatchPredicateImpl.java b/service/tag/internal/src/main/java/org/eclipse/kapua/service/tag/internal/TagMatchPredicateImpl.java deleted file mode 100644 index e785c278463..00000000000 --- a/service/tag/internal/src/main/java/org/eclipse/kapua/service/tag/internal/TagMatchPredicateImpl.java +++ /dev/null @@ -1,35 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017, 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.service.tag.internal; - -import org.eclipse.kapua.commons.model.query.predicate.AbstractMatchPredicate; -import org.eclipse.kapua.service.tag.TagAttributes; -import org.eclipse.kapua.service.tag.TagMatchPredicate; -import java.util.Arrays; - -public class TagMatchPredicateImpl extends AbstractMatchPredicate implements TagMatchPredicate { - -/** - * Constructor. - * - * @param matchTerm - * @since 2.1.0 - */ - public TagMatchPredicateImpl(T matchTerm) { - this.attributeNames = Arrays.asList( - TagAttributes.DESCRIPTION, - TagAttributes.NAME - ); - this.matchTerm = matchTerm; - } -} diff --git a/service/tag/internal/src/main/java/org/eclipse/kapua/service/tag/internal/TagQueryImpl.java b/service/tag/internal/src/main/java/org/eclipse/kapua/service/tag/internal/TagQueryImpl.java deleted file mode 100644 index 612e77fe43f..00000000000 --- a/service/tag/internal/src/main/java/org/eclipse/kapua/service/tag/internal/TagQueryImpl.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017, 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.service.tag.internal; - -import org.eclipse.kapua.commons.model.query.AbstractKapuaNamedQuery; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.service.tag.TagMatchPredicate; -import org.eclipse.kapua.service.tag.TagQuery; - -/** - * {@link TagQuery} implementation. - * - * @since 1.0.0 - */ -public class TagQueryImpl extends AbstractKapuaNamedQuery implements TagQuery { - - /** - * Constructor. - * - * @param scopeId The {@link #getScopeId()}. - * @since 1.0.0 - */ - public TagQueryImpl(KapuaId scopeId) { - super(scopeId); - } - - @Override - public TagMatchPredicate matchPredicate(T matchTerm) { - return new TagMatchPredicateImpl<>(matchTerm); - } - -} diff --git a/service/tag/test-steps/src/main/java/org/eclipse/kapua/service/tag/steps/TagServiceSteps.java b/service/tag/test-steps/src/main/java/org/eclipse/kapua/service/tag/steps/TagServiceSteps.java index bb7750467d1..09b73a6a831 100644 --- a/service/tag/test-steps/src/main/java/org/eclipse/kapua/service/tag/steps/TagServiceSteps.java +++ b/service/tag/test-steps/src/main/java/org/eclipse/kapua/service/tag/steps/TagServiceSteps.java @@ -12,14 +12,13 @@ *******************************************************************************/ package org.eclipse.kapua.service.tag.steps; -import com.google.inject.Singleton; -import io.cucumber.java.After; -import io.cucumber.java.Before; -import io.cucumber.java.Scenario; -import io.cucumber.java.en.And; -import io.cucumber.java.en.Given; -import io.cucumber.java.en.Then; -import io.cucumber.java.en.When; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import javax.inject.Inject; + import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.locator.KapuaLocator; import org.eclipse.kapua.model.id.KapuaId; @@ -38,11 +37,15 @@ import org.eclipse.kapua.service.tag.TagService; import org.junit.Assert; -import javax.inject.Inject; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; +import com.google.inject.Singleton; + +import io.cucumber.java.After; +import io.cucumber.java.Before; +import io.cucumber.java.Scenario; +import io.cucumber.java.en.And; +import io.cucumber.java.en.Given; +import io.cucumber.java.en.Then; +import io.cucumber.java.en.When; /** * Implementation of Gherkin steps used in TagService.feature scenarios. @@ -170,7 +173,7 @@ public void tagWithNameIfSearched(String tagName) throws Throwable { try { stepData.remove("tag"); primeException(); - TagQuery query = tagFactory.newQuery(SYS_SCOPE_ID); + TagQuery query = new TagQuery(SYS_SCOPE_ID); query.setPredicate(query.attributePredicate(TagAttributes.NAME, tagName, AttributePredicate.Operator.EQUAL)); //TODO: #LAYER_VIOLATION - isn't this a find by name? TagListResult queryResult = tagService.query(query); @@ -186,7 +189,7 @@ public void tagWithNameIfSearched(String tagName) throws Throwable { public void deleteTagWithName(String tagName) throws Throwable { try { primeException(); - TagQuery query = tagFactory.newQuery(getCurrentScopeId()); + TagQuery query = new TagQuery(getCurrentScopeId()); query.setPredicate(query.attributePredicate(TagAttributes.NAME, tagName, AttributePredicate.Operator.EQUAL)); //TODO: #LAYER_VIOLATION - isn't this a find by name? TagListResult queryResult = tagService.query(query); @@ -232,7 +235,8 @@ public void tagWithNameIsDeleted(String tagName) throws Throwable { /** * Create TagCreator for creating tag with specified name. * - * @param tagName name of tag + * @param tagName + * name of tag * @return tag creator for tag with specified name */ private TagCreator tagCreatorCreatorWithoutDescription(String tagName) { @@ -266,7 +270,7 @@ public void tagNameIsChangedIntoName(String tagName) throws Exception { public void nameOfTagIsChangedInto(String tagName, String newTagName) throws Exception { try { primeException(); - TagQuery query = tagFactory.newQuery(getCurrentScopeId()); + TagQuery query = new TagQuery(getCurrentScopeId()); query.setPredicate(query.attributePredicate(TagAttributes.NAME, tagName, AttributePredicate.Operator.EQUAL)); TagListResult queryResult = tagService.query(query); Tag foundTag = queryResult.getFirstItem(); @@ -296,7 +300,7 @@ public void tagDescriptionIsChangedInto(String description) throws Exception { @And("Description of tag {string} is changed into {string}") public void descriptionOfTagIsChangedInto(String tagName, String newDescription) throws Exception { try { - TagQuery query = tagFactory.newQuery(getCurrentScopeId()); + TagQuery query = new TagQuery(getCurrentScopeId()); query.setPredicate(query.attributePredicate(TagAttributes.NAME, tagName, AttributePredicate.Operator.EQUAL)); TagListResult queryResult = tagService.query(query); Tag foundTag = queryResult.getFirstItem(); diff --git a/service/tag/test/src/test/java/org/eclipse/kapua/service/tag/test/TagLocatorConfiguration.java b/service/tag/test/src/test/java/org/eclipse/kapua/service/tag/test/TagLocatorConfiguration.java index f867da80f3f..0f128e9d65a 100644 --- a/service/tag/test/src/test/java/org/eclipse/kapua/service/tag/test/TagLocatorConfiguration.java +++ b/service/tag/test/src/test/java/org/eclipse/kapua/service/tag/test/TagLocatorConfiguration.java @@ -12,13 +12,8 @@ *******************************************************************************/ package org.eclipse.kapua.service.tag.test; -import com.codahale.metrics.MetricRegistry; -import com.google.inject.AbstractModule; -import com.google.inject.Guice; -import com.google.inject.Injector; -import com.google.inject.Singleton; -import com.google.inject.name.Names; -import io.cucumber.java.Before; +import java.util.Collections; + import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.commons.configuration.AccountRelativeFinder; import org.eclipse.kapua.commons.configuration.RootUserTester; @@ -34,7 +29,6 @@ import org.eclipse.kapua.commons.metric.CommonsMetric; import org.eclipse.kapua.commons.metric.MetricsService; import org.eclipse.kapua.commons.metric.MetricsServiceImpl; -import org.eclipse.kapua.commons.model.query.QueryFactoryImpl; import org.eclipse.kapua.commons.service.event.store.internal.EventStoreRecordImplJpaRepository; import org.eclipse.kapua.commons.service.internal.cache.CacheManagerProvider; import org.eclipse.kapua.commons.setting.system.SystemSetting; @@ -42,7 +36,6 @@ import org.eclipse.kapua.message.KapuaMessageFactory; import org.eclipse.kapua.message.internal.KapuaMessageFactoryImpl; import org.eclipse.kapua.model.config.metatype.KapuaMetatypeFactory; -import org.eclipse.kapua.model.query.QueryFactory; import org.eclipse.kapua.qa.common.MockedLocator; import org.eclipse.kapua.service.account.AccountFactory; import org.eclipse.kapua.service.account.AccountService; @@ -87,15 +80,20 @@ import org.mockito.Matchers; import org.mockito.Mockito; -import java.util.Collections; +import com.codahale.metrics.MetricRegistry; +import com.google.inject.AbstractModule; +import com.google.inject.Guice; +import com.google.inject.Injector; +import com.google.inject.Singleton; +import com.google.inject.name.Names; + +import io.cucumber.java.Before; @Singleton public class TagLocatorConfiguration { /** - * Setup DI with Google Guice DI. - * Create mocked and non mocked service under test and bind them with Guice. - * It is based on custom MockedLocator locator that is meant for service unit tests. + * Setup DI with Google Guice DI. Create mocked and non mocked service under test and bind them with Guice. It is based on custom MockedLocator locator that is meant for service unit tests. */ @Before(value = "@setup", order = 1) public void setupDI() { @@ -131,7 +129,6 @@ protected void configure() { } catch (KapuaException e) { // skip } - bind(QueryFactory.class).toInstance(new QueryFactoryImpl()); // Set KapuaMetatypeFactory for Metatype configuration bind(KapuaMetatypeFactory.class).toInstance(new KapuaMetatypeFactoryImpl()); @@ -170,7 +167,8 @@ protected void configure() { new DeviceEventImplJpaRepository(jpaRepoConfig) ); - final DeviceValidation deviceValidation = new DeviceValidationImpl(new KapuaDeviceRegistrySettings().getInt(KapuaDeviceRegistrySettingKeys.DEVICE_LIFECYCLE_BIRTH_VAR_FIELDS_LENGTH_MAX), + final DeviceValidation deviceValidation = new DeviceValidationImpl( + new KapuaDeviceRegistrySettings().getInt(KapuaDeviceRegistrySettingKeys.DEVICE_LIFECYCLE_BIRTH_VAR_FIELDS_LENGTH_MAX), new KapuaDeviceRegistrySettings().getInt(KapuaDeviceRegistrySettingKeys.DEVICE_LIFECYCLE_BIRTH_EXTENDED_PROPERTIES_LENGTH_MAX), mockedAuthorization, permissionFactory, @@ -178,7 +176,6 @@ protected void configure() { deviceConnectionService, deviceEventService, new DeviceImplJpaRepository(jpaRepoConfig), - new DeviceFactoryImpl(), new TagServiceImpl( permissionFactory, mockedAuthorization, diff --git a/service/user/api/src/main/java/org/eclipse/kapua/service/user/UserFactory.java b/service/user/api/src/main/java/org/eclipse/kapua/service/user/UserFactory.java index ad6f5722827..eb22907b255 100644 --- a/service/user/api/src/main/java/org/eclipse/kapua/service/user/UserFactory.java +++ b/service/user/api/src/main/java/org/eclipse/kapua/service/user/UserFactory.java @@ -21,7 +21,7 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface UserFactory extends KapuaEntityFactory { +public interface UserFactory extends KapuaEntityFactory { /** * Instantiates a new {@link UserCreator} diff --git a/service/user/api/src/main/java/org/eclipse/kapua/service/user/UserMatchPredicate.java b/service/user/api/src/main/java/org/eclipse/kapua/service/user/UserMatchPredicate.java index 22739e77ed8..185bd4afbfb 100644 --- a/service/user/api/src/main/java/org/eclipse/kapua/service/user/UserMatchPredicate.java +++ b/service/user/api/src/main/java/org/eclipse/kapua/service/user/UserMatchPredicate.java @@ -12,8 +12,28 @@ *******************************************************************************/ package org.eclipse.kapua.service.user; -import org.eclipse.kapua.model.query.predicate.MatchPredicate; +import java.util.Arrays; -public interface UserMatchPredicate extends MatchPredicate { +import org.eclipse.kapua.model.query.predicate.AbstractMatchPredicate; +public class UserMatchPredicate extends AbstractMatchPredicate { + + /** + * Constructor. + * + * @param matchTerm + * @since 1.3.0 + */ + public UserMatchPredicate(T matchTerm) { + this.attributeNames = Arrays.asList( + UserAttributes.NAME, + UserAttributes.EMAIL, + UserAttributes.PHONE_NUMBER, + UserAttributes.DISPLAY_NAME, + UserAttributes.EXTERNAL_ID, + UserAttributes.DESCRIPTION, + UserAttributes.EXTERNAL_USERNAME + ); + this.matchTerm = matchTerm; + } } diff --git a/service/user/api/src/main/java/org/eclipse/kapua/service/user/UserQuery.java b/service/user/api/src/main/java/org/eclipse/kapua/service/user/UserQuery.java index aba06704af3..95d24a3246d 100644 --- a/service/user/api/src/main/java/org/eclipse/kapua/service/user/UserQuery.java +++ b/service/user/api/src/main/java/org/eclipse/kapua/service/user/UserQuery.java @@ -12,13 +12,14 @@ *******************************************************************************/ package org.eclipse.kapua.service.user; -import org.eclipse.kapua.model.query.KapuaQuery; - import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.model.query.KapuaQuery; + /** * {@link User} {@link KapuaQuery} definition. * @@ -27,17 +28,41 @@ */ @XmlRootElement(name = "query") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = UserXmlRegistry.class, factoryMethod = "newQuery") -public interface UserQuery extends KapuaQuery { +@XmlType +public class UserQuery extends KapuaQuery { + + /** + * Constructor. + * + * @since 1.0.0 + */ + private UserQuery() { + super(); + } + + /** + * Constructor + * + * @param scopeId + * The {@link #getScopeId()}. + * @since 1.0.0 + */ + public UserQuery(KapuaId scopeId) { + this(); + setScopeId(scopeId); + } /** * Instantiates a new {@link UserMatchPredicate}. * - * @param matchTerm The term to use to match. - * @param The type of the term + * @param matchTerm + * The term to use to match. + * @param + * The type of the term * @return The newly instantiated {@link UserMatchPredicate}. * @since 1.3.0 */ - UserMatchPredicate matchPredicate(T matchTerm); - + public UserMatchPredicate matchPredicate(T matchTerm) { + return new UserMatchPredicate<>(matchTerm); + } } diff --git a/service/user/api/src/main/java/org/eclipse/kapua/service/user/UserXmlRegistry.java b/service/user/api/src/main/java/org/eclipse/kapua/service/user/UserXmlRegistry.java index 04d48cb787c..c3ae1a184a6 100644 --- a/service/user/api/src/main/java/org/eclipse/kapua/service/user/UserXmlRegistry.java +++ b/service/user/api/src/main/java/org/eclipse/kapua/service/user/UserXmlRegistry.java @@ -45,6 +45,6 @@ public UserCreator newUserCreator() { } public UserQuery newQuery() { - return userFactory.newQuery(null); + return new UserQuery(null); } } diff --git a/service/user/internal/src/main/java/org/eclipse/kapua/service/user/internal/UserFactoryImpl.java b/service/user/internal/src/main/java/org/eclipse/kapua/service/user/internal/UserFactoryImpl.java index 2d04f102a5f..6f4d9d609da 100644 --- a/service/user/internal/src/main/java/org/eclipse/kapua/service/user/internal/UserFactoryImpl.java +++ b/service/user/internal/src/main/java/org/eclipse/kapua/service/user/internal/UserFactoryImpl.java @@ -19,7 +19,6 @@ import org.eclipse.kapua.service.user.User; import org.eclipse.kapua.service.user.UserCreator; import org.eclipse.kapua.service.user.UserFactory; -import org.eclipse.kapua.service.user.UserQuery; /** * {@link UserFactory} implementation. @@ -38,11 +37,6 @@ public UserCreator newCreator(KapuaId scopeId, String name) { return creator; } - @Override - public UserQuery newQuery(KapuaId scopeId) { - return new UserQueryImpl(scopeId); - } - @Override public User newEntity(KapuaId scopeId) { return new UserImpl(scopeId); diff --git a/service/user/internal/src/main/java/org/eclipse/kapua/service/user/internal/UserMatchPredicateImpl.java b/service/user/internal/src/main/java/org/eclipse/kapua/service/user/internal/UserMatchPredicateImpl.java deleted file mode 100644 index 4c7d940880a..00000000000 --- a/service/user/internal/src/main/java/org/eclipse/kapua/service/user/internal/UserMatchPredicateImpl.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2020, 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.service.user.internal; - -import org.eclipse.kapua.commons.model.query.predicate.AbstractMatchPredicate; -import org.eclipse.kapua.service.user.UserAttributes; -import org.eclipse.kapua.service.user.UserMatchPredicate; - -import java.util.Arrays; - -public class UserMatchPredicateImpl extends AbstractMatchPredicate implements UserMatchPredicate { - - /** - * Constructor. - * - * @param matchTerm - * @since 1.3.0 - */ - public UserMatchPredicateImpl(T matchTerm) { - this.attributeNames = Arrays.asList( - UserAttributes.NAME, - UserAttributes.EMAIL, - UserAttributes.PHONE_NUMBER, - UserAttributes.DISPLAY_NAME, - UserAttributes.EXTERNAL_ID, - UserAttributes.DESCRIPTION, - UserAttributes.EXTERNAL_USERNAME - ); - this.matchTerm = matchTerm; - } - -} diff --git a/service/user/internal/src/main/java/org/eclipse/kapua/service/user/internal/UserQueryImpl.java b/service/user/internal/src/main/java/org/eclipse/kapua/service/user/internal/UserQueryImpl.java deleted file mode 100644 index b7ad5afa1a6..00000000000 --- a/service/user/internal/src/main/java/org/eclipse/kapua/service/user/internal/UserQueryImpl.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************* - * 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.service.user.internal; - -import org.eclipse.kapua.commons.model.query.AbstractKapuaNamedQuery; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.service.user.UserQuery; - -/** - * {@link UserQuery} implementation. - * - * @since 1.0.0 - */ -public class UserQueryImpl extends AbstractKapuaNamedQuery implements UserQuery { - - /** - * Constructor. - * - * @since 1.0.0 - */ - private UserQueryImpl() { - super(); - } - - /** - * Constructor - * - * @param scopeId The {@link #getScopeId()}. - * @since 1.0.0 - */ - public UserQueryImpl(KapuaId scopeId) { - this(); - setScopeId(scopeId); - } - - @Override - public UserMatchPredicateImpl matchPredicate(T matchTerm) { - return new UserMatchPredicateImpl<>(matchTerm); - } -} diff --git a/service/user/internal/src/main/java/org/eclipse/kapua/service/user/internal/UserServiceImpl.java b/service/user/internal/src/main/java/org/eclipse/kapua/service/user/internal/UserServiceImpl.java index ffcce384bd4..c35e6d5c0ea 100644 --- a/service/user/internal/src/main/java/org/eclipse/kapua/service/user/internal/UserServiceImpl.java +++ b/service/user/internal/src/main/java/org/eclipse/kapua/service/user/internal/UserServiceImpl.java @@ -13,6 +13,11 @@ *******************************************************************************/ package org.eclipse.kapua.service.user.internal; +import java.util.Objects; +import java.util.Optional; + +import javax.inject.Singleton; + import org.eclipse.kapua.KapuaDuplicateExternalIdException; import org.eclipse.kapua.KapuaDuplicateExternalUsernameException; import org.eclipse.kapua.KapuaDuplicateNameException; @@ -48,10 +53,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.inject.Singleton; -import java.util.Objects; -import java.util.Optional; - /** * {@link UserService} implementation. * @@ -366,7 +367,7 @@ public void onKapuaEvent(ServiceEvent kapuaEvent) throws KapuaException { } private void deleteUserByAccountId(KapuaId scopeId, KapuaId accountId) throws KapuaException { - UserQuery query = new UserQueryImpl(accountId); + UserQuery query = new UserQuery(accountId); UserListResult usersToDelete = query(query); for (User u : usersToDelete.getItems()) { diff --git a/service/user/test-steps/src/main/java/org/eclipse/kapua/service/user/steps/UserServiceSteps.java b/service/user/test-steps/src/main/java/org/eclipse/kapua/service/user/steps/UserServiceSteps.java index 645205764f2..3745138c31d 100644 --- a/service/user/test-steps/src/main/java/org/eclipse/kapua/service/user/steps/UserServiceSteps.java +++ b/service/user/test-steps/src/main/java/org/eclipse/kapua/service/user/steps/UserServiceSteps.java @@ -12,14 +12,21 @@ *******************************************************************************/ package org.eclipse.kapua.service.user.steps; -import com.google.inject.Singleton; -import io.cucumber.java.After; -import io.cucumber.java.Before; -import io.cucumber.java.Scenario; -import io.cucumber.java.en.And; -import io.cucumber.java.en.Given; -import io.cucumber.java.en.Then; -import io.cucumber.java.en.When; +import java.math.BigInteger; +import java.text.MessageFormat; +import java.time.LocalDate; +import java.time.ZoneId; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import javax.inject.Inject; + import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.commons.model.id.KapuaEid; import org.eclipse.kapua.commons.security.KapuaSecurityUtils; @@ -46,7 +53,6 @@ import org.eclipse.kapua.service.authentication.credential.CredentialCreator; import org.eclipse.kapua.service.authentication.credential.CredentialFactory; import org.eclipse.kapua.service.authentication.credential.CredentialListResult; -import org.eclipse.kapua.service.authentication.credential.CredentialQuery; import org.eclipse.kapua.service.authentication.credential.CredentialService; import org.eclipse.kapua.service.authentication.credential.CredentialStatus; import org.eclipse.kapua.service.authentication.credential.mfa.MfaOption; @@ -54,15 +60,12 @@ import org.eclipse.kapua.service.authentication.credential.mfa.MfaOptionFactory; import org.eclipse.kapua.service.authentication.credential.mfa.MfaOptionService; import org.eclipse.kapua.service.authentication.credential.mfa.shiro.MfaOptionFactoryImpl; -import org.eclipse.kapua.service.authentication.credential.shiro.CredentialQueryImpl; import org.eclipse.kapua.service.authorization.access.AccessInfoCreator; import org.eclipse.kapua.service.authorization.access.AccessInfoFactory; import org.eclipse.kapua.service.authorization.access.AccessInfoService; import org.eclipse.kapua.service.authorization.access.AccessPermission; import org.eclipse.kapua.service.authorization.access.AccessPermissionAttributes; -import org.eclipse.kapua.service.authorization.access.AccessPermissionQuery; import org.eclipse.kapua.service.authorization.access.AccessPermissionService; -import org.eclipse.kapua.service.authorization.access.shiro.AccessPermissionQueryImpl; import org.eclipse.kapua.service.authorization.permission.Permission; import org.eclipse.kapua.service.authorization.permission.PermissionFactory; import org.eclipse.kapua.service.user.User; @@ -75,19 +78,15 @@ import org.eclipse.kapua.service.user.UserStatus; import org.junit.Assert; -import javax.inject.Inject; -import java.math.BigInteger; -import java.text.MessageFormat; -import java.time.LocalDate; -import java.time.ZoneId; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; +import com.google.inject.Singleton; + +import io.cucumber.java.After; +import io.cucumber.java.Before; +import io.cucumber.java.Scenario; +import io.cucumber.java.en.And; +import io.cucumber.java.en.Given; +import io.cucumber.java.en.Then; +import io.cucumber.java.en.When; /** * Implementation of Gherkin steps used in user test scenarios. @@ -242,7 +241,7 @@ public void searchForUsers() throws Exception { KapuaId scpId = DEFAULT_ID; Set iFoundUsers; stepData.remove(USER_LIST); - KapuaQuery query = userFactory.newQuery(scpId); + KapuaQuery query = new UserQuery(scpId); UserListResult queryResult = userService.query(query); iFoundUsers = new HashSet<>(); List users = queryResult.getItems(); @@ -335,7 +334,7 @@ public void searchUserByName() throws Exception { @When("I query for users in scope with id {int}") public void queryForUsers(int scopeId) throws Exception { stepData.remove(USER_LIST); - UserQuery query = userFactory.newQuery(new KapuaEid(BigInteger.valueOf(scopeId))); + UserQuery query = new UserQuery(new KapuaEid(BigInteger.valueOf(scopeId))); UserListResult queryResult = userService.query(query); Set iFoundUsers = new HashSet<>(); for (User userItem : queryResult.getItems()) { @@ -346,7 +345,7 @@ public void queryForUsers(int scopeId) throws Exception { @When("I count users in scope {int}") public void countUsersInScope(int scopeId) throws Exception { - UserQuery query = userFactory.newQuery(new KapuaEid(BigInteger.valueOf(scopeId))); + UserQuery query = new UserQuery(new KapuaEid(BigInteger.valueOf(scopeId))); stepData.updateCount((int) userService.count(query)); } @@ -464,7 +463,7 @@ public void searchForLastCreatedCredentials() throws Exception { ComparableUser comparableUser = (ComparableUser) stepData.get(LAST_USER); primeException(); try { - CredentialQuery credentialQuery = new CredentialQueryImpl(getCurrentScopeId()); + KapuaQuery credentialQuery = new KapuaQuery(getCurrentScopeId()); credentialQuery.setPredicate(credentialQuery.attributePredicate(CredentialAttributes.USER_ID, comparableUser.getUser().getId())); CredentialListResult credentials = credentialService.query(credentialQuery); stepData.put("CredentialsListFound", credentials); @@ -518,7 +517,7 @@ public void queryForLastAddedPermission() throws Exception { Permission permission = (Permission) stepData.get(LAST_PERMISSION_ADDED_TO_USER); primeException(); try { - AccessPermissionQuery query = new AccessPermissionQueryImpl(getCurrentScopeId()); + KapuaQuery query = new KapuaQuery(getCurrentScopeId()); query.setPredicate(query.attributePredicate(AccessPermissionAttributes.PERMISSION, permission)); AccessPermission accessPermission = accessPermissionService.query(query).getFirstItem(); stepData.put(LAST_FOUND_ACCESS_PERMISSION, accessPermission); @@ -717,12 +716,12 @@ public void logout() throws KapuaException { // ******************* /** - * Extract list of users form step parameter table and create those users in - * kapua. - * Operation is performed in privileged mode, without access and authorization checks. + * Extract list of users form step parameter table and create those users in kapua. Operation is performed in privileged mode, without access and authorization checks. * - * @param userList list of users in step - * @param account account in which users are created + * @param userList + * list of users in step + * @param account + * account in which users are created * @return Set of created users as ComparableUser Set * @throws Exception */ @@ -751,11 +750,12 @@ private HashSet createUsersInList(List userList, Accoun } /** - * Create User object with user data filed with quasi random data for user name, - * email, display name. Scope id and user id is set to test wide id. + * Create User object with user data filed with quasi random data for user name, email, display name. Scope id and user id is set to test wide id. * - * @param userId unique user id - * @param scopeId user scope id + * @param userId + * unique user id + * @param scopeId + * user scope id * @return User instance */ private User createUserInstance(int userId, int scopeId) { @@ -794,10 +794,10 @@ private UserCreator userCreatorCreator(String name, String displayName, String e } /** - * Create credentials for specific user, set users password. - * It finds user by name and sets its password. + * Create credentials for specific user, set users password. It finds user by name and sets its password. * - * @param cucCredentials username and open password + * @param cucCredentials + * username and open password * @return created credential */ private Credential createCredentials(CucCredentials cucCredentials) throws Exception { @@ -819,11 +819,16 @@ private Credential createCredentials(CucCredentials cucCredentials) throws Excep /** * Create credential creator for user with password. * - * @param scopeId scopeId in which user is - * @param userId userId for which credetntials are set - * @param password open password as credetntials - * @param status status of credentials enabled or disabled - * @param expirationDate credential expiration date + * @param scopeId + * scopeId in which user is + * @param userId + * userId for which credetntials are set + * @param password + * open password as credetntials + * @param status + * status of credentials enabled or disabled + * @param expirationDate + * credential expiration date * @return credential creator used for creating credentials */ private CredentialCreator credentialCreatorCreator(KapuaId scopeId, KapuaId userId, String password, CredentialStatus status, Date expirationDate) { @@ -835,10 +840,12 @@ private CredentialCreator credentialCreatorCreator(KapuaId scopeId, KapuaId user /** * Creates permissions for user with specified account. Permissions are created in priveledged mode. * - * @param permissionList list of permissions for user, if targetScopeId is not set user scope that is - * specifed as account - * @param user user for whom permissions are set - * @param account account in which user is defined + * @param permissionList + * list of permissions for user, if targetScopeId is not set user scope that is specifed as account + * @param user + * user for whom permissions are set + * @param account + * account in which user is defined * @throws Exception */ private void createPermissions(List permissionList, ComparableUser user, Account account) throws Exception { @@ -855,12 +862,14 @@ private void createPermissions(List permissionList, ComparableUse } /** - * Create accessInfoCreator instance with data about user permissions. - * If target scope is not defined in permission list use account scope. + * Create accessInfoCreator instance with data about user permissions. If target scope is not defined in permission list use account scope. * - * @param permissionList list of all permissions - * @param user user for which permissions are set - * @param account that user belongs to + * @param permissionList + * list of all permissions + * @param user + * user for which permissions are set + * @param account + * that user belongs to * @return AccessInfoCreator instance for creating user permissions */ private AccessInfoCreator accessInfoCreatorCreator(List permissionList, ComparableUser user, Account account) throws KapuaException { @@ -1037,7 +1046,7 @@ public void iSearchForTheUserWithExpirationDateInThePresent() throws KapuaExcept KapuaId scpId = DEFAULT_ID; Set iFoundUsers; stepData.remove(USER_LIST); - KapuaQuery query = userFactory.newQuery(scpId); + KapuaQuery query = new UserQuery(scpId); UserListResult queryResult = userService.query(query); iFoundUsers = new HashSet<>(); List users = queryResult.getItems(); @@ -1076,7 +1085,7 @@ public void iSearchForTheUserWithExpirationDateInThePast() throws KapuaException KapuaId scpId = DEFAULT_ID; Set iFoundUsers; stepData.remove(USER_LIST); - KapuaQuery query = userFactory.newQuery(scpId); + KapuaQuery query = new UserQuery(scpId); UserListResult queryResult = userService.query(query); iFoundUsers = new HashSet<>(); List users = queryResult.getItems(); @@ -1179,7 +1188,7 @@ public void iFindUsersWithPhoneNumber(List userList) { @And("I search users with phone number {string}") public void iSearchUsersWithPhoneNumber(String phoneNum) throws Throwable { - UserQuery userQuery = userFactory.newQuery(DEFAULT_ID); + UserQuery userQuery = new UserQuery(DEFAULT_ID); userQuery.setPredicate(userQuery.attributePredicate(UserAttributes.PHONE_NUMBER, phoneNum, AttributePredicate.Operator.EQUAL)); UserListResult userListResult = userService.query(userQuery); stepData.put(FOUND_USERS, userListResult); @@ -1187,7 +1196,7 @@ public void iSearchUsersWithPhoneNumber(String phoneNum) throws Throwable { @And("I search users with email {string}") public void iSearchForUsersWithEmail(String email) throws Throwable { - UserQuery userQuery = userFactory.newQuery(DEFAULT_ID); + UserQuery userQuery = new UserQuery(DEFAULT_ID); userQuery.setPredicate(userQuery.attributePredicate(UserAttributes.EMAIL, email, AttributePredicate.Operator.EQUAL)); UserListResult userListResult = userService.query(userQuery); stepData.put(FOUND_USERS, userListResult); 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 39e9e78e324..c16e75879a1 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 @@ -28,14 +28,12 @@ import org.eclipse.kapua.commons.metric.CommonsMetric; import org.eclipse.kapua.commons.metric.MetricsService; import org.eclipse.kapua.commons.metric.MetricsServiceImpl; -import org.eclipse.kapua.commons.model.query.QueryFactoryImpl; import org.eclipse.kapua.commons.service.event.store.internal.EventStoreRecordImplJpaRepository; import org.eclipse.kapua.commons.service.internal.cache.CacheManagerProvider; import org.eclipse.kapua.commons.setting.system.SystemSetting; import org.eclipse.kapua.commons.util.xml.XmlUtil; import org.eclipse.kapua.locator.KapuaLocator; import org.eclipse.kapua.model.config.metatype.KapuaMetatypeFactory; -import org.eclipse.kapua.model.query.QueryFactory; import org.eclipse.kapua.qa.common.MockedLocator; import org.eclipse.kapua.qa.common.TestJAXBContextProvider; import org.eclipse.kapua.service.account.AccountService; @@ -101,8 +99,6 @@ protected void configure() { // skip } - bind(QueryFactory.class).toInstance(new QueryFactoryImpl()); - bind(AuthorizationService.class).toInstance(mockedAuthorization); // Inject mocked Permission Factory PermissionFactory mockPermissionFactory = Mockito.mock(PermissionFactory.class); From 18153d2148bd0c2462e60133795cbf902ba3ce32 Mon Sep 17 00:00:00 2001 From: dseurotech Date: Wed, 15 Jan 2025 10:36:54 +0100 Subject: [PATCH 3/4] revert me - changing the version to differentiate artifacts Signed-off-by: dseurotech --- README.md | 104 +++++--- UPGRADE_NOTES.md | 24 +- assembly/api/pom.xml | 2 +- assembly/broker-artemis/pom.xml | 2 +- assembly/console/pom.xml | 2 +- .../entrypoint/run-consumer-lifecycle | 2 +- assembly/consumer/lifecycle/pom.xml | 2 +- assembly/consumer/pom.xml | 2 +- .../entrypoint/run-consumer-telemetry | 2 +- assembly/consumer/telemetry/pom.xml | 2 +- assembly/events-broker/pom.xml | 2 +- assembly/java-base/pom.xml | 2 +- assembly/jetty-base/pom.xml | 2 +- assembly/job-engine/pom.xml | 2 +- assembly/pom.xml | 2 +- .../entrypoint/run-service-authentication | 2 +- assembly/service/authentication/pom.xml | 2 +- assembly/service/pom.xml | 2 +- assembly/sql/pom.xml | 2 +- broker/artemis/plugin/pom.xml | 2 +- broker/artemis/pom.xml | 2 +- broker/pom.xml | 2 +- build-tools/pom.xml | 2 +- client/gateway/api/pom.xml | 2 +- client/gateway/features/karaf/pom.xml | 2 +- client/gateway/features/pom.xml | 2 +- client/gateway/pom.xml | 2 +- client/gateway/profile/kura/pom.xml | 2 +- client/gateway/provider/fuse/pom.xml | 2 +- client/gateway/provider/mqtt/pom.xml | 2 +- client/gateway/provider/paho/pom.xml | 2 +- client/gateway/provider/pom.xml | 2 +- client/gateway/spi/pom.xml | 2 +- client/pom.xml | 2 +- client/security/pom.xml | 2 +- commons-rest/errors/pom.xml | 2 +- commons-rest/filters/pom.xml | 2 +- commons-rest/model/pom.xml | 2 +- commons-rest/pom.xml | 2 +- commons/pom.xml | 2 +- console/core/pom.xml | 2 +- console/module/about/pom.xml | 2 +- console/module/account/pom.xml | 2 +- console/module/api/pom.xml | 2 +- console/module/authentication/pom.xml | 2 +- console/module/authorization/pom.xml | 2 +- console/module/certificate/pom.xml | 2 +- console/module/data/pom.xml | 2 +- console/module/device/pom.xml | 2 +- console/module/endpoint/pom.xml | 2 +- console/module/job/pom.xml | 2 +- console/module/pom.xml | 2 +- console/module/tag/pom.xml | 2 +- console/module/user/pom.xml | 2 +- console/module/welcome/pom.xml | 2 +- console/pom.xml | 2 +- console/web/pom.xml | 2 +- consumer/lifecycle-app/pom.xml | 2 +- consumer/lifecycle/pom.xml | 2 +- consumer/pom.xml | 2 +- consumer/telemetry-app/pom.xml | 2 +- consumer/telemetry/pom.xml | 2 +- deployment/commons/pom.xml | 2 +- deployment/commons/sso/keycloak/build | 2 +- deployment/docker/pom.xml | 2 +- deployment/docker/unix/docker-common.sh | 2 +- deployment/minishift/minishift-importer.sh | 2 +- deployment/minishift/minishift-pull-images.sh | 2 +- deployment/minishift/pom.xml | 2 +- deployment/minishift/sso/keycloak-importer | 2 +- deployment/openshift/openshift-deploy.sh | 2 +- deployment/openshift/pom.xml | 2 +- deployment/pom.xml | 2 +- dev-tools/cucumber-reports/pom.xml | 2 +- dev-tools/pom.xml | 2 +- docs/developer-guide/en/running.md | 136 +++++++---- extras/encryption-migrator/README.md | 31 ++- extras/encryption-migrator/pom.xml | 2 +- extras/es-migrator/pom.xml | 2 +- extras/foreignkeys/pom.xml | 2 +- extras/liquibase-unlocker/README.md | 43 +++- extras/liquibase-unlocker/pom.xml | 2 +- extras/pom.xml | 2 +- job-engine/api/pom.xml | 2 +- job-engine/app/core/pom.xml | 2 +- job-engine/app/pom.xml | 2 +- job-engine/app/resources/pom.xml | 2 +- job-engine/app/web/pom.xml | 2 +- job-engine/client/pom.xml | 2 +- job-engine/commons/pom.xml | 2 +- job-engine/jbatch/pom.xml | 2 +- job-engine/pom.xml | 2 +- locator/guice/pom.xml | 2 +- locator/pom.xml | 2 +- message/api/pom.xml | 2 +- message/internal/pom.xml | 2 +- message/pom.xml | 2 +- plug-ins/pom.xml | 2 +- plug-ins/sso/openid-connect/api/pom.xml | 2 +- plug-ins/sso/openid-connect/pom.xml | 2 +- .../openid-connect/provider-generic/pom.xml | 2 +- .../openid-connect/provider-keycloak/pom.xml | 2 +- plug-ins/sso/openid-connect/provider/pom.xml | 2 +- plug-ins/sso/pom.xml | 2 +- pom.xml | 2 +- qa/common/pom.xml | 6 +- qa/integration-steps/pom.xml | 2 +- .../qa/integration/steps/DockerSteps.java | 228 ++++++++++-------- qa/integration/pom.xml | 2 +- qa/markers/pom.xml | 2 +- qa/pom.xml | 2 +- rest-api/core/pom.xml | 2 +- rest-api/pom.xml | 2 +- rest-api/resources/pom.xml | 2 +- .../src/main/resources/openapi/openapi.yaml | 2 +- rest-api/web/pom.xml | 2 +- service/account/api/pom.xml | 2 +- service/account/internal/pom.xml | 2 +- service/account/pom.xml | 2 +- service/account/test-steps/pom.xml | 2 +- service/account/test/pom.xml | 2 +- service/api/pom.xml | 2 +- service/authentication-app/pom.xml | 2 +- service/authentication/pom.xml | 2 +- service/camel/pom.xml | 2 +- service/client/pom.xml | 2 +- .../commons/elasticsearch/client-api/pom.xml | 2 +- .../commons/elasticsearch/client-rest/pom.xml | 2 +- service/commons/elasticsearch/pom.xml | 2 +- service/commons/pom.xml | 2 +- service/commons/storable/api/pom.xml | 2 +- service/commons/storable/internal/pom.xml | 2 +- service/commons/storable/pom.xml | 2 +- service/commons/utils/api/pom.xml | 2 +- service/commons/utils/internal/pom.xml | 2 +- service/commons/utils/pom.xml | 2 +- service/datastore/api/pom.xml | 2 +- service/datastore/internal/pom.xml | 2 +- service/datastore/pom.xml | 2 +- service/datastore/test-steps/pom.xml | 2 +- service/datastore/test/pom.xml | 2 +- service/device/api/pom.xml | 2 +- service/device/authentication/pom.xml | 2 +- service/device/call/api/pom.xml | 2 +- service/device/call/kura/pom.xml | 2 +- service/device/call/pom.xml | 2 +- service/device/commons/pom.xml | 2 +- service/device/management/all/api/pom.xml | 2 +- .../device/management/all/internal/pom.xml | 2 +- service/device/management/all/job/pom.xml | 2 +- service/device/management/all/pom.xml | 2 +- service/device/management/api/pom.xml | 2 +- .../device/management/asset-store/api/pom.xml | 2 +- .../management/asset-store/dummy/pom.xml | 2 +- service/device/management/asset-store/pom.xml | 2 +- service/device/management/asset/api/pom.xml | 2 +- .../device/management/asset/internal/pom.xml | 2 +- service/device/management/asset/job/pom.xml | 2 +- service/device/management/asset/pom.xml | 2 +- service/device/management/bundle/api/pom.xml | 2 +- .../device/management/bundle/internal/pom.xml | 2 +- service/device/management/bundle/job/pom.xml | 2 +- service/device/management/bundle/pom.xml | 2 +- service/device/management/command/api/pom.xml | 2 +- .../management/command/internal/pom.xml | 2 +- service/device/management/command/job/pom.xml | 2 +- service/device/management/command/pom.xml | 2 +- .../configuration-store/api/pom.xml | 2 +- .../configuration-store/dummy/pom.xml | 2 +- .../management/configuration-store/pom.xml | 2 +- .../management/configuration/api/pom.xml | 2 +- .../management/configuration/internal/pom.xml | 2 +- .../management/configuration/job/pom.xml | 2 +- .../configuration/message-api/pom.xml | 2 +- .../device/management/configuration/pom.xml | 2 +- .../device/management/inventory/api/pom.xml | 2 +- .../management/inventory/internal/pom.xml | 2 +- service/device/management/inventory/pom.xml | 2 +- service/device/management/job/api/pom.xml | 2 +- .../device/management/job/internal/pom.xml | 2 +- service/device/management/job/pom.xml | 2 +- .../device/management/keystore/api/pom.xml | 2 +- .../management/keystore/internal/pom.xml | 2 +- .../device/management/keystore/job/pom.xml | 2 +- service/device/management/keystore/pom.xml | 2 +- .../device/management/packages/api/pom.xml | 2 +- .../management/packages/internal/pom.xml | 2 +- .../device/management/packages/job/pom.xml | 2 +- service/device/management/packages/pom.xml | 2 +- service/device/management/pom.xml | 2 +- .../device/management/registry/api/pom.xml | 2 +- .../management/registry/internal/pom.xml | 2 +- service/device/management/registry/pom.xml | 2 +- service/device/management/request/api/pom.xml | 2 +- .../management/request/internal/pom.xml | 2 +- service/device/management/request/pom.xml | 2 +- service/device/pom.xml | 2 +- service/device/registry/api/pom.xml | 2 +- service/device/registry/internal/pom.xml | 2 +- service/device/registry/pom.xml | 2 +- service/device/registry/test-steps/pom.xml | 2 +- service/device/registry/test/pom.xml | 2 +- service/endpoint/api/pom.xml | 2 +- service/endpoint/internal/pom.xml | 2 +- service/endpoint/pom.xml | 2 +- service/endpoint/test-steps/pom.xml | 2 +- service/job/api/pom.xml | 2 +- service/job/internal/pom.xml | 2 +- service/job/pom.xml | 2 +- service/job/test-steps/pom.xml | 2 +- service/job/test/pom.xml | 2 +- service/pom.xml | 2 +- service/scheduler/api/pom.xml | 2 +- service/scheduler/pom.xml | 2 +- service/scheduler/quartz/pom.xml | 2 +- service/scheduler/test-steps/pom.xml | 2 +- service/scheduler/test/pom.xml | 2 +- service/security/authentication/api/pom.xml | 2 +- service/security/authentication/pom.xml | 2 +- service/security/authorization/api/pom.xml | 2 +- service/security/authorization/pom.xml | 2 +- service/security/certificate/api/pom.xml | 2 +- service/security/certificate/internal/pom.xml | 2 +- service/security/certificate/pom.xml | 2 +- service/security/pom.xml | 2 +- service/security/registration/api/pom.xml | 2 +- service/security/registration/pom.xml | 2 +- service/security/registration/simple/pom.xml | 4 +- service/security/shiro/pom.xml | 2 +- service/security/test-steps/pom.xml | 2 +- service/security/test/pom.xml | 2 +- service/stream/api/pom.xml | 2 +- service/stream/internal/pom.xml | 2 +- service/stream/pom.xml | 2 +- service/system/api/pom.xml | 2 +- service/system/internal/pom.xml | 2 +- service/system/pom.xml | 2 +- service/system/test-steps/pom.xml | 2 +- service/system/test/pom.xml | 2 +- service/tag/api/pom.xml | 2 +- service/tag/internal/pom.xml | 2 +- service/tag/pom.xml | 2 +- service/tag/test-steps/pom.xml | 2 +- service/tag/test/pom.xml | 2 +- service/user/api/pom.xml | 2 +- service/user/internal/pom.xml | 2 +- service/user/pom.xml | 2 +- service/user/test-steps/pom.xml | 2 +- service/user/test/pom.xml | 2 +- simulator-kura/pom.xml | 2 +- translator/api/pom.xml | 2 +- translator/kapua/kura/pom.xml | 2 +- translator/kapua/pom.xml | 2 +- translator/kura/jms/pom.xml | 2 +- translator/kura/mqtt/pom.xml | 2 +- translator/kura/pom.xml | 2 +- translator/pom.xml | 2 +- translator/test-steps/pom.xml | 2 +- translator/test/pom.xml | 2 +- transport/api/pom.xml | 2 +- transport/jms/pom.xml | 2 +- transport/mqtt/pom.xml | 2 +- transport/pom.xml | 2 +- 263 files changed, 619 insertions(+), 467 deletions(-) diff --git a/README.md b/README.md index 124313dcad1..7d6864e6695 100644 --- a/README.md +++ b/README.md @@ -15,8 +15,11 @@ ![GitHub Actions CI](https://img.shields.io/github/actions/workflow/status/eclipse/kapua/kapua-ci.yaml)
    ![Jenkins](https://img.shields.io/jenkins/build?jobUrl=https:%2F%2Fci.eclipse.org%2Fkapua%2Fjob%2Fdevelop-build&label=Jenkins%20Build&logo=jenkins)
    -[Eclipse Kapua™](http://eclipse.org/kapua) is a modular platform providing the services required to manage IoT gateways and smart edge devices. Kapua provides a core integration framework and an -initial set of core IoT services including a device registry, device management services, messaging services, data management, and application enablement. +[Eclipse Kapua™](http://eclipse.org/kapua) is a modular platform providing the +services required to manage IoT gateways and smart edge devices. Kapua provides a core +integration framework and an +initial set of core IoT services including a device registry, device management services, +messaging services, data management, and application enablement. ## Quick Start Guide @@ -34,7 +37,8 @@ Two more backend services are required that implement the data tier: * The SQL database * The NoSQL datastore -Eclipse Kapua™ can be deployed in a variety of modes. A practical way for running a local demo is through Docker containers. +Eclipse Kapua™ can be deployed in a variety of modes. A practical way for running a +local demo is through Docker containers. ### Requirements @@ -45,31 +49,43 @@ Before starting, check that your environment has the following prerequisites: * Java VM Version 11 * Docker Version 1.2+ * Swagger CLI 4+ (Installed via NPM or separately) -* Node 16+ +* Node 16+ * Internet Access (needed to download the artifacts) ### Demo Setup -The team maintains some docker images in a Docker Hub repository at [Kapua Repository](https://hub.docker.com/r/kapua/). Check the repo to view the list of available images, if you haven't found one -fitting your needs you may create your own. Please refer to the paragraph [More deployment info](#more-deployment-info) to find more about creating your own images and/or alternative demo deployment +The team maintains some docker images in a Docker Hub repository +at [Kapua Repository](https://hub.docker.com/r/kapua/). Check the repo to view the list of +available images, if you haven't found one +fitting your needs you may create your own. Please refer to the +paragraph [More deployment info](#more-deployment-info) to find more about creating your +own images and/or alternative demo deployment scenarios. *** -**Note:** the Docker Hub repository mentioned above is not the official project repository from Eclipse Foundation. +**Note:** the Docker Hub repository mentioned above is not the official project repository +from Eclipse Foundation. *** -Suppose the target is the current snapshot 2.1.0-SNAPSHOT. +Suppose the target is the current snapshot 2.1.0-FALSE_EXTENSIONS-SNAPSHOT. * Clone Eclipse Kapua™ into a local directory * Open an OS shell and move to Kapua project root directory * Start Docker runtime -The Kapua repository mentioned above hosts only images of released versions. It is possible to test different versions of Kapua doing a checkout into -the release branches (for example, "release-1.6.x") and to the tagged commits to select the specific version (for example, the commit tagged as "1.6.7"). Doing so, it is assured -that the following step will pull proper images from the Docker Hub. If, on the other hand, your target is a SNAPSHOT version (for example, the 2.1.0-SNAPSHOT), a local build is required -in order to create the docker images and proceed to the next step. Instructions for building can be found in the building.md file under the path docs/developer-guide. -Assuming that your interest is to deploy a release before 2.0.0 and that you want to pull images from the Docker Hub, it is important to set now the -`IMAGE_VERSION` environment variable with a value equal to the target version. For example, in the case of the 1.6.7 +The Kapua repository mentioned above hosts only images of released versions. It is +possible to test different versions of Kapua doing a checkout into +the release branches (for example, "release-1.6.x") and to the tagged commits to select +the specific version (for example, the commit tagged as "1.6.7"). Doing so, it is assured +that the following step will pull proper images from the Docker Hub. If, on the other +hand, your target is a SNAPSHOT version (for example, the +2.1.0-FALSE_EXTENSIONS-SNAPSHOT), a local build is required +in order to create the docker images and proceed to the next step. Instructions for +building can be found in the building.md file under the path docs/developer-guide. +Assuming that your interest is to deploy a release before 2.0.0 and that you want to pull +images from the Docker Hub, it is important to set now the +`IMAGE_VERSION` environment variable with a value equal to the target version. For +example, in the case of the 1.6.7 export IMAGE_VERSION=1.6.7 @@ -113,31 +129,41 @@ On Windows (PowerShell): ### Access -Once the containers are running, the Kapua services can be accessed. Eclipse Kapua™ is a multi tenant -system. The demo installation comes with one default tenant, called _kapua-sys_, which is also the root tenant. +Once the containers are running, the Kapua services can be accessed. Eclipse Kapua™ +is a multi tenant +system. The demo installation comes with one default tenant, called _kapua-sys_, which is +also the root tenant. In Eclipse Kapua™ a _tenant_ is commonly referred to as an _account_. #### The console -The administration console is available at [http://localhost:8080/](http://localhost:8080/). -Copy paste the URL above to a Web browser, as the login screen appears, type the following credentials: +The administration console is available +at [http://localhost:8080/](http://localhost:8080/). +Copy paste the URL above to a Web browser, as the login screen appears, type the following +credentials: * Username: `kapua-sys` * Password: `kapua-password` Press _Login_ button and start working with the console. -**Note**: If you are using Docker on Windows the hostname will most likely not be `localhost` but +**Note**: If you are using Docker on Windows the hostname will most likely not be +`localhost` but the IP address of your docker instance. #### RESTful APIs -The documentation of RESTful API is available at [http://localhost:8081/doc/](http://localhost:8081/doc/) while the mount points are available at [http://localhost:8081/v1/](http://localhost:8081/v1/) +The documentation of RESTful API is available +at [http://localhost:8081/doc/](http://localhost:8081/doc/) while the mount points are +available at [http://localhost:8081/v1/](http://localhost:8081/v1/) . -The documentation is available through Swagger UI which greatly helps testing and exploring the exposed services. +The documentation is available through Swagger UI which greatly helps testing and +exploring the exposed services. -In order to get access a REST resource through an API, an authentication token is needed. Fortunately the token can be easily obtained by executing the authentication API. There are several ways to +In order to get access a REST resource through an API, an authentication token is needed. +Fortunately the token can be easily obtained by executing the authentication API. There +are several ways to invoke the API, an easy one is by using the Swagger UI: * Open the URL http://localhost:8081/doc/ @@ -154,7 +180,8 @@ invoke the API, an easy one is by using the Swagger UI: } ``` -**Note:** as an alternative to the previous, if curl is available on your machine, execute the following from the shell: +**Note:** as an alternative to the previous, if curl is available on your machine, execute +the following from the shell: ```bash curl -X POST 'http://localhost:8081/v1/authentication/user' --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{ @@ -170,17 +197,24 @@ The system will return a JSON object. * Copy the value of the field _tokenId_ * Paste the value in the box labelled _api\_key_ at the top of the web page -Swagger will automatically add the authentication token to each subsequent request done using the Swagger UI. You're ready to try executing the documented APIs. +Swagger will automatically add the authentication token to each subsequent request done +using the Swagger UI. You're ready to try executing the documented APIs. -**Note**: If you are using Docker on Windows the hostname will most likely not be `localhost` but +**Note**: If you are using Docker on Windows the hostname will most likely not be +`localhost` but the IP address of your docker instance. #### The Broker -The broker container exposes an [Mqtt](http://mqtt.org/) end point at tcp://localhost:1883/. -The broker can be accessed through either [Eclipse Kura™](http://www.eclipse.org/kura/) or a plain Mqtt client like, for example, [Eclipse Paho™](http://www.eclipse.org/paho/). +The broker container exposes an [Mqtt](http://mqtt.org/) end point at tcp://localhost: +1883/. +The broker can be accessed through +either [Eclipse Kura™](http://www.eclipse.org/kura/) or a plain Mqtt client like, +for example, [Eclipse Paho™](http://www.eclipse.org/paho/). -In order for a client to establish a Mqtt connection with the broker, a client must provide a valid identity. The _kapua-sys_ account provides the user named _kapua-broker_ which has been pre-seeded +In order for a client to establish a Mqtt connection with the broker, a client must +provide a valid identity. The _kapua-sys_ account provides the user named _kapua-broker_ +which has been pre-seeded and profiled for the purpose. The credentials for the user kapua-broker are the following: @@ -190,17 +224,22 @@ The credentials for the user kapua-broker are the following: **Note:** do not use the user `kapua-sys` to establish Mqtt connections. -**Note**: If you are using Docker on Windows the hostname will most likely not be `localhost` but +**Note**: If you are using Docker on Windows the hostname will most likely not be +`localhost` but the IP address of your docker instance. #### Simulation -Kapua comes with a framework that you can use to simulate Kura gateways. It can be used to test your Kapua deployments easily. See [Simulator documentation](docs/user-manual/en/simulator.md) for more +Kapua comes with a framework that you can use to simulate Kura gateways. It can be used to +test your Kapua deployments easily. +See [Simulator documentation](docs/user-manual/en/simulator.md) for more info. #### More deployment info -Installing and running a demo using Docker is easy, but it's not the only way. There are other scenarios that the users may be interested in. We provide advanced setup scenarios in the following +Installing and running a demo using Docker is easy, but it's not the only way. There are +other scenarios that the users may be interested in. We provide advanced setup scenarios +in the following guides: * [Running with Docker](deployment/docker/README.md) @@ -216,7 +255,8 @@ They will provide more advanced deployment scenarios. ### Contributing -If you're interested to get involved in IoT and Eclipse Kapua™ project, join the community and give your contribution to the project, please +If you're interested to get involved in IoT and Eclipse Kapua™ project, join the +community and give your contribution to the project, please read [how to contribute to Eclipse Kapua™](https://github.com/eclipse/kapua/blob/develop/CONTRIBUTING.md). ### Community diff --git a/UPGRADE_NOTES.md b/UPGRADE_NOTES.md index 8b344132f38..7b3342ab5ae 100644 --- a/UPGRADE_NOTES.md +++ b/UPGRADE_NOTES.md @@ -1,22 +1,32 @@ -# Upgrade Notes v 2.1.0-SNAPSHOT +# Upgrade Notes v 2.1.0-FALSE_EXTENSIONS-SNAPSHOT -Below are described most important changes, features, additions and bugfixes that needs attention while performing the upgrade from the previous version. +Below are described most important changes, features, additions and bugfixes that needs +attention while performing the upgrade from the previous version. -This report is only partial for Eclipse Kapua release 2.1.0-SNAPSHOT, since we started to maintain it mid-release development. +This report is only partial for Eclipse Kapua release 2.1.0-FALSE_EXTENSIONS-SNAPSHOT, +since we started to maintain it mid-release development. ## Changes #### Deprecation of `db.pool.size.min` and `db.pool.size.max` sizing options -With [#4112](https://github.com/eclipse/kapua/pull/4112) we deprecated `commons.db.pool.size.min` and `commons.db.pool.size.max` settings, switching to a new `commons.db.pool.size.fixed` setting which will configure the database connection pool to a fixed size with a default value of `5`. +With [#4112](https://github.com/eclipse/kapua/pull/4112) we deprecated +`commons.db.pool.size.min` and `commons.db.pool.size.max` settings, switching to a new +`commons.db.pool.size.fixed` setting which will configure the database connection pool to +a fixed size with a default value of `5`. -Backward compatibility is granted by `db.pool.size.strategy`. Default value is `fixed`, but it can be changed to `range` to continue use of a variable database connection pool. Be aware that at some point `range` strategy will be removed and only fixed size will be available. +Backward compatibility is granted by `db.pool.size.strategy`. Default value is `fixed`, +but it can be changed to `range` to continue use of a variable database connection pool. +Be aware that at some point `range` strategy will be removed and only fixed size will be +available. ## DB Changes #### New column in MFA Option table -In PR [#4115](https://github.com/eclipse/kapua/pull/4115) a new `has_trust_me` column has been added to the `atht_mfa_option`. +In PR [#4115](https://github.com/eclipse/kapua/pull/4115) a new `has_trust_me` column has +been added to the `atht_mfa_option`. -New column defaults to `null` and doesn't need any migration. The code itself will populate the column accordingly on first update. +New column defaults to `null` and doesn't need any migration. The code itself will +populate the column accordingly on first update. For large `atht_mfa_option` tables it might take sometime to be added. \ No newline at end of file diff --git a/assembly/api/pom.xml b/assembly/api/pom.xml index 9456d579902..6d75e61c94f 100644 --- a/assembly/api/pom.xml +++ b/assembly/api/pom.xml @@ -19,7 +19,7 @@ kapua-assembly org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT pom diff --git a/assembly/broker-artemis/pom.xml b/assembly/broker-artemis/pom.xml index 1b31a7e22b8..b8929e96970 100644 --- a/assembly/broker-artemis/pom.xml +++ b/assembly/broker-artemis/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-assembly - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT pom diff --git a/assembly/console/pom.xml b/assembly/console/pom.xml index dc884af515d..4d3893c373d 100644 --- a/assembly/console/pom.xml +++ b/assembly/console/pom.xml @@ -19,7 +19,7 @@ org.eclipse.kapua kapua-assembly - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT pom diff --git a/assembly/consumer/lifecycle/entrypoint/run-consumer-lifecycle b/assembly/consumer/lifecycle/entrypoint/run-consumer-lifecycle index 1366bf64936..58582f536a1 100644 --- a/assembly/consumer/lifecycle/entrypoint/run-consumer-lifecycle +++ b/assembly/consumer/lifecycle/entrypoint/run-consumer-lifecycle @@ -13,4 +13,4 @@ JAVA_OPTS="${JAVA_OPTS} --add-opens java.base/java.lang=ALL-UNNAMED" -java ${JAVA_OPTS} ${DEBUG_OPTS} ${JMX_OPTS} -jar kapua-consumer-lifecycle-2.1.0-SNAPSHOT-app.jar +java ${JAVA_OPTS} ${DEBUG_OPTS} ${JMX_OPTS} -jar kapua-consumer-lifecycle-2.1.0-FALSE_EXTENSIONS-SNAPSHOT-app.jar diff --git a/assembly/consumer/lifecycle/pom.xml b/assembly/consumer/lifecycle/pom.xml index aa5d0253a28..f6b0a6098b0 100644 --- a/assembly/consumer/lifecycle/pom.xml +++ b/assembly/consumer/lifecycle/pom.xml @@ -17,7 +17,7 @@ kapua-assembly-consumer org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT 4.0.0 diff --git a/assembly/consumer/pom.xml b/assembly/consumer/pom.xml index 962e069b04c..9e1078d194f 100644 --- a/assembly/consumer/pom.xml +++ b/assembly/consumer/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-assembly - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT pom diff --git a/assembly/consumer/telemetry/entrypoint/run-consumer-telemetry b/assembly/consumer/telemetry/entrypoint/run-consumer-telemetry index 513000dd51d..60e607c3233 100644 --- a/assembly/consumer/telemetry/entrypoint/run-consumer-telemetry +++ b/assembly/consumer/telemetry/entrypoint/run-consumer-telemetry @@ -13,4 +13,4 @@ JAVA_OPTS="${JAVA_OPTS} --add-opens java.base/java.lang=ALL-UNNAMED" -java ${JAVA_OPTS} ${DEBUG_OPTS} ${JMX_OPTS} -jar kapua-consumer-telemetry-2.1.0-SNAPSHOT-app.jar +java ${JAVA_OPTS} ${DEBUG_OPTS} ${JMX_OPTS} -jar kapua-consumer-telemetry-2.1.0-FALSE_EXTENSIONS-SNAPSHOT-app.jar diff --git a/assembly/consumer/telemetry/pom.xml b/assembly/consumer/telemetry/pom.xml index 36c7539ee24..6fc8c14e3a9 100644 --- a/assembly/consumer/telemetry/pom.xml +++ b/assembly/consumer/telemetry/pom.xml @@ -18,7 +18,7 @@ kapua-assembly-consumer org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT 4.0.0 diff --git a/assembly/events-broker/pom.xml b/assembly/events-broker/pom.xml index 1427e85fc05..6b9204355c3 100644 --- a/assembly/events-broker/pom.xml +++ b/assembly/events-broker/pom.xml @@ -19,7 +19,7 @@ org.eclipse.kapua kapua-assembly - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT pom diff --git a/assembly/java-base/pom.xml b/assembly/java-base/pom.xml index 52e28b65ae3..74463c56ec1 100644 --- a/assembly/java-base/pom.xml +++ b/assembly/java-base/pom.xml @@ -19,7 +19,7 @@ org.eclipse.kapua kapua-assembly - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT pom diff --git a/assembly/jetty-base/pom.xml b/assembly/jetty-base/pom.xml index 9da71c65329..456b639c0eb 100644 --- a/assembly/jetty-base/pom.xml +++ b/assembly/jetty-base/pom.xml @@ -19,7 +19,7 @@ org.eclipse.kapua kapua-assembly - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT pom diff --git a/assembly/job-engine/pom.xml b/assembly/job-engine/pom.xml index bb22db4c737..30906b9db5e 100644 --- a/assembly/job-engine/pom.xml +++ b/assembly/job-engine/pom.xml @@ -19,7 +19,7 @@ kapua-assembly org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-assembly-job-engine diff --git a/assembly/pom.xml b/assembly/pom.xml index 3fd129198ed..199b402dc02 100644 --- a/assembly/pom.xml +++ b/assembly/pom.xml @@ -19,7 +19,7 @@ org.eclipse.kapua kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-assembly diff --git a/assembly/service/authentication/entrypoint/run-service-authentication b/assembly/service/authentication/entrypoint/run-service-authentication index 2ce1430c6f7..54b5ad695af 100644 --- a/assembly/service/authentication/entrypoint/run-service-authentication +++ b/assembly/service/authentication/entrypoint/run-service-authentication @@ -11,4 +11,4 @@ # Eurotech ################################################################################ -java ${JAVA_OPTS} ${DEBUG_OPTS} ${JMX_OPTS} -jar kapua-service-authentication-2.1.0-SNAPSHOT-app.jar +java ${JAVA_OPTS} ${DEBUG_OPTS} ${JMX_OPTS} -jar kapua-service-authentication-2.1.0-FALSE_EXTENSIONS-SNAPSHOT-app.jar diff --git a/assembly/service/authentication/pom.xml b/assembly/service/authentication/pom.xml index 0c3a490be95..b2b7e914d95 100644 --- a/assembly/service/authentication/pom.xml +++ b/assembly/service/authentication/pom.xml @@ -17,7 +17,7 @@ kapua-assembly-service org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT 4.0.0 diff --git a/assembly/service/pom.xml b/assembly/service/pom.xml index 5b48874dc3e..572b0d4aed2 100644 --- a/assembly/service/pom.xml +++ b/assembly/service/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-assembly - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT pom diff --git a/assembly/sql/pom.xml b/assembly/sql/pom.xml index a6816d92c48..94ee4f6aff0 100644 --- a/assembly/sql/pom.xml +++ b/assembly/sql/pom.xml @@ -19,7 +19,7 @@ org.eclipse.kapua kapua-assembly - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT pom diff --git a/broker/artemis/plugin/pom.xml b/broker/artemis/plugin/pom.xml index 2274a9986d1..fda9f63267b 100644 --- a/broker/artemis/plugin/pom.xml +++ b/broker/artemis/plugin/pom.xml @@ -17,7 +17,7 @@ org.eclipse.kapua kapua-broker-artemis - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-broker-artemis-plugin diff --git a/broker/artemis/pom.xml b/broker/artemis/pom.xml index 271cfcc9e91..a4b946549c0 100644 --- a/broker/artemis/pom.xml +++ b/broker/artemis/pom.xml @@ -19,7 +19,7 @@ kapua-broker org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT pom diff --git a/broker/pom.xml b/broker/pom.xml index b8f203b1427..7fb781c787d 100644 --- a/broker/pom.xml +++ b/broker/pom.xml @@ -19,7 +19,7 @@ kapua org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT pom diff --git a/build-tools/pom.xml b/build-tools/pom.xml index 78e34c5fd02..90c91f2a810 100644 --- a/build-tools/pom.xml +++ b/build-tools/pom.xml @@ -24,7 +24,7 @@ org.eclipse.kapua.build kapua-build-tools - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT UTF-8 diff --git a/client/gateway/api/pom.xml b/client/gateway/api/pom.xml index a38e71c86e8..a20288cc566 100644 --- a/client/gateway/api/pom.xml +++ b/client/gateway/api/pom.xml @@ -19,7 +19,7 @@ org.eclipse.kapua kapua-client-gateway - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT .. diff --git a/client/gateway/features/karaf/pom.xml b/client/gateway/features/karaf/pom.xml index bb463b7e51c..8616672159a 100644 --- a/client/gateway/features/karaf/pom.xml +++ b/client/gateway/features/karaf/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-client-gateway-features - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT .. diff --git a/client/gateway/features/pom.xml b/client/gateway/features/pom.xml index 6d29f6689ba..6df7e0afa6e 100644 --- a/client/gateway/features/pom.xml +++ b/client/gateway/features/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-client-gateway - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT Eclipse Kapua :: Gateway Client :: Features diff --git a/client/gateway/pom.xml b/client/gateway/pom.xml index dcaf727bd4e..f18d61cbefa 100644 --- a/client/gateway/pom.xml +++ b/client/gateway/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-client - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-client-gateway diff --git a/client/gateway/profile/kura/pom.xml b/client/gateway/profile/kura/pom.xml index e5714293224..fa57223a768 100644 --- a/client/gateway/profile/kura/pom.xml +++ b/client/gateway/profile/kura/pom.xml @@ -20,7 +20,7 @@ org.eclipse.kapua kapua-client-gateway - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT ../.. diff --git a/client/gateway/provider/fuse/pom.xml b/client/gateway/provider/fuse/pom.xml index f4d783b5eaf..a6c1c43a898 100644 --- a/client/gateway/provider/fuse/pom.xml +++ b/client/gateway/provider/fuse/pom.xml @@ -19,7 +19,7 @@ org.eclipse.kapua kapua-client-gateway-provider - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT .. diff --git a/client/gateway/provider/mqtt/pom.xml b/client/gateway/provider/mqtt/pom.xml index 31595da4d0b..29b12ee5649 100644 --- a/client/gateway/provider/mqtt/pom.xml +++ b/client/gateway/provider/mqtt/pom.xml @@ -19,7 +19,7 @@ org.eclipse.kapua kapua-client-gateway-provider - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT .. diff --git a/client/gateway/provider/paho/pom.xml b/client/gateway/provider/paho/pom.xml index 93204d7be97..392b0639b68 100644 --- a/client/gateway/provider/paho/pom.xml +++ b/client/gateway/provider/paho/pom.xml @@ -19,7 +19,7 @@ org.eclipse.kapua kapua-client-gateway-provider - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT .. diff --git a/client/gateway/provider/pom.xml b/client/gateway/provider/pom.xml index 6164b5d73e8..f7810ea5a0c 100644 --- a/client/gateway/provider/pom.xml +++ b/client/gateway/provider/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-client-gateway - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT .. diff --git a/client/gateway/spi/pom.xml b/client/gateway/spi/pom.xml index 9ebf960c420..1772a83a2e5 100644 --- a/client/gateway/spi/pom.xml +++ b/client/gateway/spi/pom.xml @@ -19,7 +19,7 @@ org.eclipse.kapua kapua-client-gateway - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT .. diff --git a/client/pom.xml b/client/pom.xml index 560f29ff189..85650b14e00 100644 --- a/client/pom.xml +++ b/client/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-client diff --git a/client/security/pom.xml b/client/security/pom.xml index 2680c5c78dd..bd9f13446dd 100644 --- a/client/security/pom.xml +++ b/client/security/pom.xml @@ -17,7 +17,7 @@ org.eclipse.kapua kapua-client - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-client-security diff --git a/commons-rest/errors/pom.xml b/commons-rest/errors/pom.xml index 910d050272e..7e4a4452964 100644 --- a/commons-rest/errors/pom.xml +++ b/commons-rest/errors/pom.xml @@ -18,7 +18,7 @@ kapua-commons-rest org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-commons-rest-errors diff --git a/commons-rest/filters/pom.xml b/commons-rest/filters/pom.xml index 2b6ecc524bb..ec61b8322cd 100644 --- a/commons-rest/filters/pom.xml +++ b/commons-rest/filters/pom.xml @@ -18,7 +18,7 @@ kapua-commons-rest org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-commons-rest-filters diff --git a/commons-rest/model/pom.xml b/commons-rest/model/pom.xml index 64f4cfbf14a..6405dfb2b50 100644 --- a/commons-rest/model/pom.xml +++ b/commons-rest/model/pom.xml @@ -19,7 +19,7 @@ kapua-commons-rest org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-commons-rest-model diff --git a/commons-rest/pom.xml b/commons-rest/pom.xml index cd3a20cdbf7..32b90b3169f 100644 --- a/commons-rest/pom.xml +++ b/commons-rest/pom.xml @@ -18,7 +18,7 @@ kapua org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-commons-rest diff --git a/commons/pom.xml b/commons/pom.xml index ce7f4dee901..4398e34ddd2 100644 --- a/commons/pom.xml +++ b/commons/pom.xml @@ -19,7 +19,7 @@ org.eclipse.kapua kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-commons diff --git a/console/core/pom.xml b/console/core/pom.xml index 8506e9aa00f..35a64823a7d 100644 --- a/console/core/pom.xml +++ b/console/core/pom.xml @@ -19,7 +19,7 @@ kapua-console org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-console-core diff --git a/console/module/about/pom.xml b/console/module/about/pom.xml index f3db0492ed4..692e612c600 100644 --- a/console/module/about/pom.xml +++ b/console/module/about/pom.xml @@ -18,7 +18,7 @@ kapua-console-module org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-console-module-about diff --git a/console/module/account/pom.xml b/console/module/account/pom.xml index 7363b8896e4..8be93146d82 100644 --- a/console/module/account/pom.xml +++ b/console/module/account/pom.xml @@ -18,7 +18,7 @@ kapua-console-module org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-console-module-account diff --git a/console/module/api/pom.xml b/console/module/api/pom.xml index b752be2d393..0106966e38a 100644 --- a/console/module/api/pom.xml +++ b/console/module/api/pom.xml @@ -19,7 +19,7 @@ kapua-console-module org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-console-module-api diff --git a/console/module/authentication/pom.xml b/console/module/authentication/pom.xml index 7a709713a4c..6b99af60ef8 100644 --- a/console/module/authentication/pom.xml +++ b/console/module/authentication/pom.xml @@ -19,7 +19,7 @@ kapua-console-module org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-console-module-authentication diff --git a/console/module/authorization/pom.xml b/console/module/authorization/pom.xml index 1f36a6a9d74..0cf330f97e7 100644 --- a/console/module/authorization/pom.xml +++ b/console/module/authorization/pom.xml @@ -19,7 +19,7 @@ kapua-console-module org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-console-module-authorization diff --git a/console/module/certificate/pom.xml b/console/module/certificate/pom.xml index 3accafe8a1f..25b936f3dff 100644 --- a/console/module/certificate/pom.xml +++ b/console/module/certificate/pom.xml @@ -18,7 +18,7 @@ kapua-console-module org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-console-module-certificate diff --git a/console/module/data/pom.xml b/console/module/data/pom.xml index 54eb376032a..f79b8d50394 100644 --- a/console/module/data/pom.xml +++ b/console/module/data/pom.xml @@ -19,7 +19,7 @@ kapua-console-module org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-console-module-data diff --git a/console/module/device/pom.xml b/console/module/device/pom.xml index 599cee6930a..d48dabf5692 100644 --- a/console/module/device/pom.xml +++ b/console/module/device/pom.xml @@ -19,7 +19,7 @@ kapua-console-module org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-console-module-device diff --git a/console/module/endpoint/pom.xml b/console/module/endpoint/pom.xml index 8648d5dc7b3..208224109ec 100644 --- a/console/module/endpoint/pom.xml +++ b/console/module/endpoint/pom.xml @@ -19,7 +19,7 @@ kapua-console-module org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-console-module-endpoint diff --git a/console/module/job/pom.xml b/console/module/job/pom.xml index 8344a29a1b8..584329c8ef6 100644 --- a/console/module/job/pom.xml +++ b/console/module/job/pom.xml @@ -19,7 +19,7 @@ kapua-console-module org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-console-module-job diff --git a/console/module/pom.xml b/console/module/pom.xml index c5f9d67905a..490c88568f3 100644 --- a/console/module/pom.xml +++ b/console/module/pom.xml @@ -17,7 +17,7 @@ kapua-console org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-console-module diff --git a/console/module/tag/pom.xml b/console/module/tag/pom.xml index 9ae04b86e5f..c7d2b67d302 100644 --- a/console/module/tag/pom.xml +++ b/console/module/tag/pom.xml @@ -19,7 +19,7 @@ kapua-console-module org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-console-module-tag diff --git a/console/module/user/pom.xml b/console/module/user/pom.xml index 376b13040f7..ce826542da0 100644 --- a/console/module/user/pom.xml +++ b/console/module/user/pom.xml @@ -19,7 +19,7 @@ kapua-console-module org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-console-module-user diff --git a/console/module/welcome/pom.xml b/console/module/welcome/pom.xml index a00362d7cee..2783230fdc3 100644 --- a/console/module/welcome/pom.xml +++ b/console/module/welcome/pom.xml @@ -19,7 +19,7 @@ kapua-console-module org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-console-module-welcome diff --git a/console/pom.xml b/console/pom.xml index 725ef14caa4..0ab244b6a79 100644 --- a/console/pom.xml +++ b/console/pom.xml @@ -19,7 +19,7 @@ org.eclipse.kapua kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-console diff --git a/console/web/pom.xml b/console/web/pom.xml index 20bf64faf85..086c20431d4 100644 --- a/console/web/pom.xml +++ b/console/web/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-console - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-console-web diff --git a/consumer/lifecycle-app/pom.xml b/consumer/lifecycle-app/pom.xml index 017a07fbc0f..2a077a77c3b 100644 --- a/consumer/lifecycle-app/pom.xml +++ b/consumer/lifecycle-app/pom.xml @@ -19,7 +19,7 @@ kapua-consumer org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-consumer-lifecycle-app diff --git a/consumer/lifecycle/pom.xml b/consumer/lifecycle/pom.xml index 2696f202246..c03a5dbe5ec 100644 --- a/consumer/lifecycle/pom.xml +++ b/consumer/lifecycle/pom.xml @@ -17,7 +17,7 @@ org.eclipse.kapua kapua-consumer - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-consumer-lifecycle diff --git a/consumer/pom.xml b/consumer/pom.xml index c5b17142e42..c17ee8c9f98 100644 --- a/consumer/pom.xml +++ b/consumer/pom.xml @@ -19,7 +19,7 @@ org.eclipse.kapua kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT pom diff --git a/consumer/telemetry-app/pom.xml b/consumer/telemetry-app/pom.xml index c2c247e8dce..136d809960d 100644 --- a/consumer/telemetry-app/pom.xml +++ b/consumer/telemetry-app/pom.xml @@ -18,7 +18,7 @@ kapua-consumer org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT 4.0.0 diff --git a/consumer/telemetry/pom.xml b/consumer/telemetry/pom.xml index 657ff990e5f..791831f3d38 100644 --- a/consumer/telemetry/pom.xml +++ b/consumer/telemetry/pom.xml @@ -17,7 +17,7 @@ org.eclipse.kapua kapua-consumer - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-consumer-telemetry diff --git a/deployment/commons/pom.xml b/deployment/commons/pom.xml index 67625aa915c..f92d24ef75c 100644 --- a/deployment/commons/pom.xml +++ b/deployment/commons/pom.xml @@ -19,7 +19,7 @@ kapua-deployment org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-deployment-commons diff --git a/deployment/commons/sso/keycloak/build b/deployment/commons/sso/keycloak/build index f15941a1afa..a446049e80f 100755 --- a/deployment/commons/sso/keycloak/build +++ b/deployment/commons/sso/keycloak/build @@ -14,7 +14,7 @@ echo "Building Kapua Keycloak Docker image..." -docker build -f ./docker/Dockerfile -t kapua/kapua-keycloak:"${IMAGE_VERSION:=2.1.0-SNAPSHOT}" . || +docker build -f ./docker/Dockerfile -t kapua/kapua-keycloak:"${IMAGE_VERSION:=2.1.0-FALSE_EXTENSIONS-SNAPSHOT}" . || { echo "Building Kapua Keycloak docker image... ERROR!" exit 1 diff --git a/deployment/docker/pom.xml b/deployment/docker/pom.xml index 727f45592ec..ef41cb98c01 100644 --- a/deployment/docker/pom.xml +++ b/deployment/docker/pom.xml @@ -19,7 +19,7 @@ kapua-deployment org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-docker diff --git a/deployment/docker/unix/docker-common.sh b/deployment/docker/unix/docker-common.sh index 0b1adbbdc18..9c0309bdf99 100755 --- a/deployment/docker/unix/docker-common.sh +++ b/deployment/docker/unix/docker-common.sh @@ -15,7 +15,7 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -export IMAGE_VERSION=${IMAGE_VERSION:=2.1.0-SNAPSHOT} +export IMAGE_VERSION=${IMAGE_VERSION:=2.1.0-FALSE_EXTENSIONS-SNAPSHOT} export CRYPTO_SECRET_KEY="${CRYPTO_SECRET_KEY:=dockerSecretKey!}" # Certificates diff --git a/deployment/minishift/minishift-importer.sh b/deployment/minishift/minishift-importer.sh index e2c1efce932..caaaab012fb 100755 --- a/deployment/minishift/minishift-importer.sh +++ b/deployment/minishift/minishift-importer.sh @@ -29,7 +29,7 @@ ERROR=0 DOCKER_ACCOUNT=${DOCKER_ACCOUNT:=kapua} -IMAGE_VERSION=${IMAGE_VERSION:=2.1.0-SNAPSHOT} +IMAGE_VERSION=${IMAGE_VERSION:=2.1.0-FALSE_EXTENSIONS-SNAPSHOT} SERVICES=("console" "api" "sql" "broker" "events-broker") TMP_DIR="/tmp/kapua-containers-$(date +%s)" diff --git a/deployment/minishift/minishift-pull-images.sh b/deployment/minishift/minishift-pull-images.sh index 0ec90b04794..dbf8400b1a8 100755 --- a/deployment/minishift/minishift-pull-images.sh +++ b/deployment/minishift/minishift-pull-images.sh @@ -17,7 +17,7 @@ # DOCKER_ACCOUNT=${DOCKER_ACCOUNT:=kapua} -IMAGE_VERSION=${IMAGE_VERSION:=2.1.0-SNAPSHOT} +IMAGE_VERSION=${IMAGE_VERSION:=2.1.0-FALSE_EXTENSIONS-SNAPSHOT} SERVICES=("console" "api" "sql" "broker" "events-broker") echo "Pulling Kapua images..." diff --git a/deployment/minishift/pom.xml b/deployment/minishift/pom.xml index ab0504435ba..2ff960a7d16 100644 --- a/deployment/minishift/pom.xml +++ b/deployment/minishift/pom.xml @@ -19,7 +19,7 @@ kapua-deployment org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-minishift diff --git a/deployment/minishift/sso/keycloak-importer b/deployment/minishift/sso/keycloak-importer index 463ed399591..a1bb1b941ec 100755 --- a/deployment/minishift/sso/keycloak-importer +++ b/deployment/minishift/sso/keycloak-importer @@ -14,7 +14,7 @@ ERROR=0 DOCKER_ACCOUNT=${DOCKER_ACCOUNT:=kapua} -IMAGE_VERSION=${IMAGE_VERSION:=2.1.0-SNAPSHOT} +IMAGE_VERSION=${IMAGE_VERSION:=2.1.0-FALSE_EXTENSIONS-SNAPSHOT} KEYCLOAK="keycloak" TMP_DIR="/tmp/keycloak-container-$(date +%s)" diff --git a/deployment/openshift/openshift-deploy.sh b/deployment/openshift/openshift-deploy.sh index 6ae5f7c2f66..5ab5ad698fe 100755 --- a/deployment/openshift/openshift-deploy.sh +++ b/deployment/openshift/openshift-deploy.sh @@ -19,7 +19,7 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" . ${SCRIPT_DIR}/openshift-common.sh : DOCKER_ACCOUNT=${DOCKER_ACCOUNT:=kapua} -: IMAGE_VERSION=${IMAGE_VERSION:=2.1.0-SNAPSHOT} +: IMAGE_VERSION=${IMAGE_VERSION:=2.1.0-FALSE_EXTENSIONS-SNAPSHOT} : JAVA_OPTS_EXTRA=${JAVA_OPTS_EXTRA:=''} ### Test if the project is already created ... fail otherwise diff --git a/deployment/openshift/pom.xml b/deployment/openshift/pom.xml index 2e9d18339e6..ba03fc61bd9 100644 --- a/deployment/openshift/pom.xml +++ b/deployment/openshift/pom.xml @@ -19,7 +19,7 @@ kapua-deployment org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT pom diff --git a/deployment/pom.xml b/deployment/pom.xml index 9c3a34f127a..dd7ffbb82f7 100644 --- a/deployment/pom.xml +++ b/deployment/pom.xml @@ -19,7 +19,7 @@ kapua org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-deployment diff --git a/dev-tools/cucumber-reports/pom.xml b/dev-tools/cucumber-reports/pom.xml index 02b70853212..87d6cd9627b 100644 --- a/dev-tools/cucumber-reports/pom.xml +++ b/dev-tools/cucumber-reports/pom.xml @@ -19,7 +19,7 @@ kapua-dev-tools org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-cucumber-reports diff --git a/dev-tools/pom.xml b/dev-tools/pom.xml index 2f6dd730dcb..17b5bc4c002 100644 --- a/dev-tools/pom.xml +++ b/dev-tools/pom.xml @@ -20,7 +20,7 @@ org.eclipse.kapua kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-dev-tools diff --git a/docs/developer-guide/en/running.md b/docs/developer-guide/en/running.md index 0af8d2fd0f9..684fddda16b 100644 --- a/docs/developer-guide/en/running.md +++ b/docs/developer-guide/en/running.md @@ -1,9 +1,11 @@ # Running -Kapua can be run in a few different ways. See the following chapters for more information about how to start and run +Kapua can be run in a few different ways. See the following chapters for more information +about how to start and run Kapua. -{% hint style='info' %} Most of the following descriptions focus on a developer centric setup and not on a full blown +{% hint style='info' %} Most of the following descriptions focus on a developer centric +setup and not on a full blown production setup. {% endhint %} ## Docker containers @@ -11,25 +13,35 @@ production setup. {% endhint %} Before running Kapua on Docker, you need to 1. Install `docker` and `docker-compose` -2. Make sure that you have built Kapua docker images locally, following the provided building section of this documentation. Alternatively, you can utilize images hosted under - the [Kapua DockerHub account](https://hub.docker.com/r/kapua/), for this case we recommend you to follow the "Quick Start Guide" section that can be found in the readme.md file under the root +2. Make sure that you have built Kapua docker images locally, following the provided + building section of this documentation. Alternatively, you can utilize images hosted + under + the [Kapua DockerHub account](https://hub.docker.com/r/kapua/), for this case we + recommend you to follow the "Quick Start Guide" section that can be found in the + readme.md file under the root folder. Now, you can start Kapua by using Docker Compose. To do so, run kapua/deployment/docker/docker-deploy.sh -Note in case of a deployment of and old version: Assuming that you have built images for a release previous to 2.0.0, and consequently you have done a checkout to the proper tagged commit, keep in -mind that the building procedure created a set of docker images tagged as "latest". The "docker-deploy" script pulls images tagged in this way. This implies that the newly built images will be +Note in case of a deployment of and old version: Assuming that you have built images for a +release previous to 2.0.0, and consequently you have done a checkout to the proper tagged +commit, keep in +mind that the building procedure created a set of docker images tagged as "latest". The " +docker-deploy" script pulls images tagged in this way. This implies that the newly built +images will be launched. -After Kapua has been started, you can navigate your browser to http://localhost:8080 and log in using the following +After Kapua has been started, you can navigate your browser to http://localhost:8080 and +log in using the following credentials: `kapua-sys` : `kapua-password` You can access the API using: http://localhost:8081 -**Note**: If you are using Docker on Windows the hostname will most likely not be `localhost` but the IP address of your +**Note**: If you are using Docker on Windows the hostname will most likely not be +`localhost` but the IP address of your docker instance. To stop Kapua, run @@ -38,55 +50,69 @@ To stop Kapua, run #### Advanced options -It's possible to deploy kapua with some advanced options that are exposed in this document: +It's possible to deploy kapua with some advanced options that are exposed in this +document: kapua/deployment/docker/README.md -If you are interested in having debugging/logging capabilities we recommend you to consult it. +If you are interested in having debugging/logging capabilities we recommend you to consult +it. ## OpenShift -OpenShift is a PaaS (Platform As A Service) platform based on Kubernetes. Kapua supports deployments -into [OpenShift Origin](https://www.openshift.org), which is an open source community project. Origin sources, can be +OpenShift is a PaaS (Platform As A Service) platform based on Kubernetes. Kapua supports +deployments +into [OpenShift Origin](https://www.openshift.org), which is an open source community +project. Origin sources, can be found [here](https://www.openshift.org/). We support Kapua on OpenShift Origin **1.4.1**. -Currently we support running OpenShift only on Linux OS. If you would like to run Kapua on Mac OS or on Windows for +Currently we support running OpenShift only on Linux OS. If you would like to run Kapua on +Mac OS or on Windows for development purposes, please install Linux -(for example Fedora 25) into a virtual machine (for example VirtualBox) and install OpenShift there. +(for example Fedora 25) into a virtual machine (for example VirtualBox) and install +OpenShift there. ### Starting OpenShift cluster -For running Kapua on an OpenShift you need to have OpenShift cluster installed and started in the first place. You can +For running Kapua on an OpenShift you need to have OpenShift cluster installed and started +in the first place. You can install it by yourself or rely on the script we provide: sudo kapua/deployment/openshift/openshift-start.sh -If you are running your OpenShift cluster for the first time, execute the following initialized script as well: +If you are running your OpenShift cluster for the first time, execute the following +initialized script as well: kapua/deployment/openshift/openshift-initialize.sh -Initialization script is responsible for logging you into a cluster and creating new OpenShift project for Kapua. +Initialization script is responsible for logging you into a cluster and creating new +OpenShift project for Kapua. -If your Openshift cluster is not on the localhost, set the `OPENSHIFT_HOST` environment variable. For example, something +If your Openshift cluster is not on the localhost, set the `OPENSHIFT_HOST` environment +variable. For example, something like export OPENSHIFT_HOST=192.168.64.2:8443 -If for some reasons, you cannot start your cluster, try to execute the startup script with option `DOCKERIZED=FALSE`: +If for some reasons, you cannot start your cluster, try to execute the startup script with +option `DOCKERIZED=FALSE`: sudo DOCKERIZED=FALSE kapua/deployment/openshift/openshift-start.sh -Option `DOCKERIZED=FALSE` tells startup script to use standard binary installation of OpenShift Origin instead of +Option `DOCKERIZED=FALSE` tells startup script to use standard binary installation of +OpenShift Origin instead of Docker-based `oc cluster up` command. ### Deploying Kapua into OpenShift cluster -Now when you have OpenShift cluster up, running and initialized, execute the following script: +Now when you have OpenShift cluster up, running and initialized, execute the following +script: cd kapua/deployment/openshift ./openshift-deploy.sh -Now open the following URL in your web browser - `http://localhost:8080`. And log-in into Kapua UI using default +Now open the following URL in your web browser - `http://localhost:8080`. And log-in into +Kapua UI using default credentials:

    @@ -96,8 +122,10 @@ credentials: ## Using Minishift -Minishift is a tool that helps you run OpenShift locally by running a single-node OpenShift cluster inside a VM. -Follow [this guide](https://docs.openshift.org/latest/minishift/getting-started/index.html) for installing and having +Minishift is a tool that helps you run OpenShift locally by running a single-node +OpenShift cluster inside a VM. +Follow [this guide](https://docs.openshift.org/latest/minishift/getting-started/index.html) +for installing and having Minishift up and running. Steps to run Kapua on Minishift are the following @@ -144,13 +172,17 @@ Steps to run Kapua on Minishift are the following ### External Node port for MQTT -The default setup uses port 31883 to export the MQTT over TCP port of the broker. This means that you can connect from +The default setup uses port 31883 to export the MQTT over TCP port of the broker. This +means that you can connect from outside of the OpenShift cluster to Kapua over port 31883 (instead of port 1883) to Kapua. -However it is only possible for one service to make use of this port. If you are planning to add a second Kapua -installation and still want to use the external node port, then you will need to choose a different, yet unsed, port. +However it is only possible for one service to make use of this port. If you are planning +to add a second Kapua +installation and still want to use the external node port, then you will need to choose a +different, yet unsed, port. -Also see: https://docs.openshift.com/container-platform/latest/dev_guide/getting_traffic_into_cluster.html +Also +see: https://docs.openshift.com/container-platform/latest/dev_guide/getting_traffic_into_cluster.html ### Adding metrics @@ -161,40 +193,53 @@ then you can also install Grafana for Hawkular to visualize your data: ### External access -In order to enable devices to access Kapua we need to allow external access to the broker's MQTT connector. In the +In order to enable devices to access Kapua we need to allow external access to the +broker's MQTT connector. In the default deployment there are two ways to achieve this. -First, the broker exposes MQTT over WebSocket transport. As WebSocket is based on HTTP we can define a router inside the -Openshift to get those device connections to the broker. For example, if your Openshift deployment is running at the -address `192.168.64.2`, you can connect the [Kura Simulator](../user-manual/simulator.md) like this +First, the broker exposes MQTT over WebSocket transport. As WebSocket is based on HTTP we +can define a router inside the +Openshift to get those device connections to the broker. For example, if your Openshift +deployment is running at the +address `192.168.64.2`, you can connect the [Kura Simulator](../user-manual/simulator.md) +like this java -jar target/kapua-simulator-kura-*-SNAPSHOT-app.jar --broker ws://kapua-broker:kapua-password@broker-eclipse-kapua.192.168.64.2.nip.io:80 -Not all MQTT clients have WebSocket support, so we need to enable direct MQTT over TCP access to the broker as well. By -default, Kapua comes with the NodePort service that routes all traffic from port `31883` to the broker. So you can -connect your MQTT clients directly to this service. For the simulator example similar to the above, that would look +Not all MQTT clients have WebSocket support, so we need to enable direct MQTT over TCP +access to the broker as well. By +default, Kapua comes with the NodePort service that routes all traffic from port `31883` +to the broker. So you can +connect your MQTT clients directly to this service. For the simulator example similar to +the above, that would look something like - java -jar target/kapua-simulator-kura-2.1.0-SNAPSHOT-app.jar --broker tcp://kapua-broker:kapua-password@192.168.64.2:31883 + java -jar target/kapua-simulator-kura-2.1.0-FALSE_EXTENSIONS-SNAPSHOT-app.jar --broker tcp://kapua-broker:kapua-password@192.168.64.2:31883 -This is suitable only for the local deployments. In the cloud or production environments, you should deploy a proper +This is suitable only for the local deployments. In the cloud or production environments, +you should deploy a proper LoadBalancer Openshift service to enable external traffic flow to the broker. ### Ensuring enough entropy -It may happen that firing up docker containers and starting up application which use Java's `SecureRandom` (which -happens in the next step a few times) run dry the Linux Kernel's entropy pool. The result is that some application will +It may happen that firing up docker containers and starting up application which use +Java's `SecureRandom` (which +happens in the next step a few times) run dry the Linux Kernel's entropy pool. The result +is that some application will block during startup -(even longer than 30 seconds) which will trigger OpenShift to kill the pods since they are considered unresponsive ( +(even longer than 30 seconds) which will trigger OpenShift to kill the pods since they are +considered unresponsive ( which they actually are). You can check the amount of entropy the kernel has available with the following command: cat /proc/sys/kernel/random/entropy_avail -If this number drops to zero, then the kernel has run out of entropy and application will block. +If this number drops to zero, then the kernel has run out of entropy and application will +block. -One solution (there are a few others) is to install `haveged` a user-space daemon which provides entropy to the kernel. +One solution (there are a few others) is to install `haveged` a user-space daemon which +provides entropy to the kernel. On CentOS 7 it can be installed with the following commands (all as `root`): @@ -202,8 +247,11 @@ On CentOS 7 it can be installed with the following commands (all as `root`): yum install haveged systemctl enable --now haveged -As the package comes from the [EPEL repositories](https://fedoraproject.org/wiki/EPEL "Information about EPEL"). If you -haven't yet enabled those repositories, then you need to do this before trying to install `haveged`: +As the package comes from +the [EPEL repositories](https://fedoraproject.org/wiki/EPEL "Information about EPEL"). If +you +haven't yet enabled those repositories, then you need to do this before trying to install +`haveged`: yum install epel-release diff --git a/extras/encryption-migrator/README.md b/extras/encryption-migrator/README.md index 3813973cc0a..a68344e1291 100644 --- a/extras/encryption-migrator/README.md +++ b/extras/encryption-migrator/README.md @@ -3,20 +3,28 @@ Kapua Encryption Migrator ## Introduction -This module contains a Java Application that leverages the Kapua APIs to update the encryption key used to perform symmetric encryption of entity attributes on DB persistence and any other usage of +This module contains a Java Application that leverages the Kapua APIs to update the +encryption key used to perform symmetric encryption of entity attributes on DB persistence +and any other usage of CryptoUtil class. ## Background -To improve security against unauthorized access to DB some fields that contain sensible data needs to be encrypted. This encryption makes difficult for an attacker to easily read data from the +To improve security against unauthorized access to DB some fields that contain sensible +data needs to be encrypted. This encryption makes difficult for an attacker to easily read +data from the database that may contain sensible data. -Kapua had already in place one-way encryption for Credentials and other resources while fields that required symmetric encryption didn't have a uniform and simple way to manage the encryption of the +Kapua had already in place one-way encryption for Credentials and other resources while +fields that required symmetric encryption didn't have a uniform and simple way to manage +the encryption of the fields. ## Changes in Kapua 2.0 -With Kapua 2.0.0 entity attributes can be symmetric encrypted by simply adding an annotation to the rest of the JPA mappings for an entity attribute which instructs JPA to crypt and decrypt fields +With Kapua 2.0.0 entity attributes can be symmetric encrypted by simply adding an +annotation to the rest of the JPA mappings for an entity attribute which instructs JPA to +crypt and decrypt fields values. Before Kapua 2.0.0 fields that were symmetric-encrypted are: @@ -28,16 +36,21 @@ After Kapua 2.0.0 fields that are symmetric-encrypted are: - MfaOption.mfaSecretKey - JobStepProperty.propertyValue -Every field share the same key and lets the developer abstract from the specific task of encrypting fields which gets delegated to JPA. While this can affect performances (we lose the on-demand +Every field share the same key and lets the developer abstract from the specific task of +encrypting fields which gets delegated to JPA. While this can affect performances (we lose +the on-demand encryption/decryption), we gain the ease of using this security feature. ## The ES indices Migration tool The encryption migration tool has been implemented with two goals: -- Do the first migration: to allow every field listed before to be unified under a single encryption key and mechanism. -- Update the encryption secret key: it might happen that a secret key needs to be replaced (e.g.: the secret key disclosure) - and this tools migrate every attribute from a given old encryption secret key to the newly given. +- Do the first migration: to allow every field listed before to be unified under a single + encryption key and mechanism. +- Update the encryption secret key: it might happen that a secret key needs to be + replaced (e.g.: the secret key disclosure) + and this tools migrate every attribute from a given old encryption secret key to the + newly given. ### Settings @@ -63,5 +76,5 @@ Other useful properties from Kapua #### Example usage ```bash -java -Dcommons.db.connection.host=somehost -Dmigrator.encryption.key.old=changeMePlease\!\! -Dmigrator.encryption.key.new=changedMeThanks\! -jar kapua-encryption-migrator-2.1.0-SNAPSHOT-app.jar +java -Dcommons.db.connection.host=somehost -Dmigrator.encryption.key.old=changeMePlease\!\! -Dmigrator.encryption.key.new=changedMeThanks\! -jar kapua-encryption-migrator-2.1.0-FALSE_EXTENSIONS-SNAPSHOT-app.jar ``` diff --git a/extras/encryption-migrator/pom.xml b/extras/encryption-migrator/pom.xml index b552cc5b6db..392d265cb7e 100644 --- a/extras/encryption-migrator/pom.xml +++ b/extras/encryption-migrator/pom.xml @@ -18,7 +18,7 @@ kapua-extras org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-encryption-migrator diff --git a/extras/es-migrator/pom.xml b/extras/es-migrator/pom.xml index 00487f4704f..4d413f5a51b 100644 --- a/extras/es-migrator/pom.xml +++ b/extras/es-migrator/pom.xml @@ -17,7 +17,7 @@ kapua-extras org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT 4.0.0 kapua-es-migrator diff --git a/extras/foreignkeys/pom.xml b/extras/foreignkeys/pom.xml index 0b98fea8029..79d43c7ae94 100644 --- a/extras/foreignkeys/pom.xml +++ b/extras/foreignkeys/pom.xml @@ -17,7 +17,7 @@ org.eclipse.kapua kapua-extras - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-foreignkeys diff --git a/extras/liquibase-unlocker/README.md b/extras/liquibase-unlocker/README.md index 14dc4f4ef66..000b5bdfc66 100644 --- a/extras/liquibase-unlocker/README.md +++ b/extras/liquibase-unlocker/README.md @@ -3,27 +3,44 @@ Liquibase "changeLogLock" table unlocker tool ## Introduction -This module contains a Java Application that unlocks a stucked deployment caused by a wrong execution of liquibase updates +This module contains a Java Application that unlocks a stucked deployment caused by a +wrong execution of liquibase updates ## Background -The liquibase updates, run on changelog files, are performed concurrently by some Kapua containers. To ensure that a single container is running an update on the DB, aka to ensure the right concurrent -access to this shared resource, liquibase uses a table called DATABASECHANGELOGLOCK to track which entity is performing the update. A row in this table testifies the presence of an entity making an -update, therefore consulting it before performing an update allows you to understand if it is possible to acquire the lock on the resource. -After the update, the container that locked the recourse releases the lock by deleting the row in this table. - -It may happen that, while inside the critical section, the container running the update is stopped for some reason, for example for a crash. After this event, the DATABASECHANGELOGLOCK is left with a -row therefore the lock will never be released. If subsequent containers tries to perform other liquibase updates (for example, the mentioned container that has been restarted) they will be blocked +The liquibase updates, run on changelog files, are performed concurrently by some Kapua +containers. To ensure that a single container is running an update on the DB, aka to +ensure the right concurrent +access to this shared resource, liquibase uses a table called DATABASECHANGELOGLOCK to +track which entity is performing the update. A row in this table testifies the presence of +an entity making an +update, therefore consulting it before performing an update allows you to understand if it +is possible to acquire the lock on the resource. +After the update, the container that locked the recourse releases the lock by deleting the +row in this table. + +It may happen that, while inside the critical section, the container running the update is +stopped for some reason, for example for a crash. After this event, the +DATABASECHANGELOGLOCK is left with a +row therefore the lock will never be released. If subsequent containers tries to perform +other liquibase updates (for example, the mentioned container that has been restarted) +they will be blocked endlessly trying to enter the critical section. -Tu unlock this situation, a manual operation on such table (for example, the deletion of the row or the deletion of the entire table) sometime works. The fact is that the liquibase api provides an -explicit command to troubleshoot this situation, in a more safe way, so it is encouraged to use it. Furthermore, the mentioned manual operation requires access to the DB retrieving credentials and so -on. The proposed script doesn't require this and get the job done with a single invocation. +Tu unlock this situation, a manual operation on such table (for example, the deletion of +the row or the deletion of the entire table) sometime works. The fact is that the +liquibase api provides an +explicit command to troubleshoot this situation, in a more safe way, so it is encouraged +to use it. Furthermore, the mentioned manual operation requires access to the DB +retrieving credentials and so +on. The proposed script doesn't require this and get the job done with a single +invocation. #### Usage ```bash -java -jar kapua-liquibase-unlocker-2.1.0-SNAPSHOT-app.jar +java -jar kapua-liquibase-unlocker-2.1.0-FALSE_EXTENSIONS-SNAPSHOT-app.jar ``` -To be used when the deployment is stucked for the afore mentioned reasons, the lock will be released and the deployment will continue. \ No newline at end of file +To be used when the deployment is stucked for the afore mentioned reasons, the lock will +be released and the deployment will continue. \ No newline at end of file diff --git a/extras/liquibase-unlocker/pom.xml b/extras/liquibase-unlocker/pom.xml index 2372ac19716..a89e7a59c0e 100644 --- a/extras/liquibase-unlocker/pom.xml +++ b/extras/liquibase-unlocker/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-extras - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-liquibase-unlocker diff --git a/extras/pom.xml b/extras/pom.xml index 15051dabf3a..03c13cf1827 100644 --- a/extras/pom.xml +++ b/extras/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-extras diff --git a/job-engine/api/pom.xml b/job-engine/api/pom.xml index f568abf6915..8eea3632b7e 100644 --- a/job-engine/api/pom.xml +++ b/job-engine/api/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-job-engine - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-job-engine-api diff --git a/job-engine/app/core/pom.xml b/job-engine/app/core/pom.xml index 144a6281231..edbab59ce9a 100644 --- a/job-engine/app/core/pom.xml +++ b/job-engine/app/core/pom.xml @@ -19,7 +19,7 @@ kapua-job-engine-app org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-job-engine-app-core diff --git a/job-engine/app/pom.xml b/job-engine/app/pom.xml index d07e6b2083d..084760a91eb 100644 --- a/job-engine/app/pom.xml +++ b/job-engine/app/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-job-engine - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-job-engine-app diff --git a/job-engine/app/resources/pom.xml b/job-engine/app/resources/pom.xml index e53d16012a5..443e14a141d 100644 --- a/job-engine/app/resources/pom.xml +++ b/job-engine/app/resources/pom.xml @@ -18,7 +18,7 @@ kapua-job-engine-app org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-job-engine-app-resources diff --git a/job-engine/app/web/pom.xml b/job-engine/app/web/pom.xml index 927ba567304..96a76e37c34 100644 --- a/job-engine/app/web/pom.xml +++ b/job-engine/app/web/pom.xml @@ -18,7 +18,7 @@ kapua-job-engine-app org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-job-engine-app-web diff --git a/job-engine/client/pom.xml b/job-engine/client/pom.xml index 94eeb99cf6f..f4d7630b8f7 100644 --- a/job-engine/client/pom.xml +++ b/job-engine/client/pom.xml @@ -20,7 +20,7 @@ kapua-job-engine org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-job-engine-client diff --git a/job-engine/commons/pom.xml b/job-engine/commons/pom.xml index c7d193790e4..14d59b966a0 100644 --- a/job-engine/commons/pom.xml +++ b/job-engine/commons/pom.xml @@ -19,7 +19,7 @@ org.eclipse.kapua kapua-job-engine - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-job-engine-commons diff --git a/job-engine/jbatch/pom.xml b/job-engine/jbatch/pom.xml index 66487f05c56..7eff6a04893 100644 --- a/job-engine/jbatch/pom.xml +++ b/job-engine/jbatch/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-job-engine - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-job-engine-jbatch diff --git a/job-engine/pom.xml b/job-engine/pom.xml index 8492a9ff8e0..69f6b85131d 100644 --- a/job-engine/pom.xml +++ b/job-engine/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-job-engine diff --git a/locator/guice/pom.xml b/locator/guice/pom.xml index baab0c418bc..bff3fd4af7f 100644 --- a/locator/guice/pom.xml +++ b/locator/guice/pom.xml @@ -19,7 +19,7 @@ org.eclipse.kapua kapua-locator - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-locator-guice diff --git a/locator/pom.xml b/locator/pom.xml index 7862d0572b9..7743eb1e026 100644 --- a/locator/pom.xml +++ b/locator/pom.xml @@ -19,7 +19,7 @@ org.eclipse.kapua kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-locator diff --git a/message/api/pom.xml b/message/api/pom.xml index 81501ecf2d9..5abe58a65b6 100644 --- a/message/api/pom.xml +++ b/message/api/pom.xml @@ -19,7 +19,7 @@ org.eclipse.kapua kapua-message - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-message-api diff --git a/message/internal/pom.xml b/message/internal/pom.xml index fd46f4e7672..56e64736a67 100644 --- a/message/internal/pom.xml +++ b/message/internal/pom.xml @@ -19,7 +19,7 @@ org.eclipse.kapua kapua-message - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-message-internal diff --git a/message/pom.xml b/message/pom.xml index d205e851a95..6a8da023be7 100644 --- a/message/pom.xml +++ b/message/pom.xml @@ -19,7 +19,7 @@ org.eclipse.kapua kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT pom diff --git a/plug-ins/pom.xml b/plug-ins/pom.xml index c06224fcb5f..e7584889099 100644 --- a/plug-ins/pom.xml +++ b/plug-ins/pom.xml @@ -21,7 +21,7 @@ org.eclipse.kapua kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT pom diff --git a/plug-ins/sso/openid-connect/api/pom.xml b/plug-ins/sso/openid-connect/api/pom.xml index 792bf68b14e..b0fab85f5bc 100644 --- a/plug-ins/sso/openid-connect/api/pom.xml +++ b/plug-ins/sso/openid-connect/api/pom.xml @@ -20,7 +20,7 @@ org.eclipse.kapua kapua-openid-connect - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-openid-api diff --git a/plug-ins/sso/openid-connect/pom.xml b/plug-ins/sso/openid-connect/pom.xml index 44d0dddeb72..80a8a71c3e9 100644 --- a/plug-ins/sso/openid-connect/pom.xml +++ b/plug-ins/sso/openid-connect/pom.xml @@ -21,7 +21,7 @@ org.eclipse.kapua kapua-sso - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT pom diff --git a/plug-ins/sso/openid-connect/provider-generic/pom.xml b/plug-ins/sso/openid-connect/provider-generic/pom.xml index f10b49f8c42..e5ba59fd808 100644 --- a/plug-ins/sso/openid-connect/provider-generic/pom.xml +++ b/plug-ins/sso/openid-connect/provider-generic/pom.xml @@ -21,7 +21,7 @@ org.eclipse.kapua kapua-openid-connect - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-openid-provider-generic diff --git a/plug-ins/sso/openid-connect/provider-keycloak/pom.xml b/plug-ins/sso/openid-connect/provider-keycloak/pom.xml index 6b6c3149857..55e0cad140f 100644 --- a/plug-ins/sso/openid-connect/provider-keycloak/pom.xml +++ b/plug-ins/sso/openid-connect/provider-keycloak/pom.xml @@ -21,7 +21,7 @@ org.eclipse.kapua kapua-openid-connect - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-openid-provider-keycloak diff --git a/plug-ins/sso/openid-connect/provider/pom.xml b/plug-ins/sso/openid-connect/provider/pom.xml index 4bae8fdb2e0..075dc9db901 100644 --- a/plug-ins/sso/openid-connect/provider/pom.xml +++ b/plug-ins/sso/openid-connect/provider/pom.xml @@ -20,7 +20,7 @@ org.eclipse.kapua kapua-openid-connect - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-openid-provider diff --git a/plug-ins/sso/pom.xml b/plug-ins/sso/pom.xml index dc4f6e12d07..f0a709d7278 100644 --- a/plug-ins/sso/pom.xml +++ b/plug-ins/sso/pom.xml @@ -21,7 +21,7 @@ org.eclipse.kapua kapua-plug-ins - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT pom diff --git a/pom.xml b/pom.xml index 34565661301..29453bc72c1 100644 --- a/pom.xml +++ b/pom.xml @@ -17,7 +17,7 @@ org.eclipse.kapua kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua pom diff --git a/qa/common/pom.xml b/qa/common/pom.xml index 931fb57cf78..4cfb028397d 100644 --- a/qa/common/pom.xml +++ b/qa/common/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-qa - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-qa-common @@ -172,8 +172,8 @@ camel-jms-starter - org.apache.geronimo.specs - geronimo-jms_1.1_spec + org.apache.geronimo.specs + geronimo-jms_1.1_spec diff --git a/qa/integration-steps/pom.xml b/qa/integration-steps/pom.xml index af9e8f2e8ae..a96e71ae72a 100644 --- a/qa/integration-steps/pom.xml +++ b/qa/integration-steps/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-qa - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-qa-integration-steps diff --git a/qa/integration-steps/src/main/java/org/eclipse/kapua/qa/integration/steps/DockerSteps.java b/qa/integration-steps/src/main/java/org/eclipse/kapua/qa/integration/steps/DockerSteps.java index ae6079dfebf..9e33aae110b 100644 --- a/qa/integration-steps/src/main/java/org/eclipse/kapua/qa/integration/steps/DockerSteps.java +++ b/qa/integration-steps/src/main/java/org/eclipse/kapua/qa/integration/steps/DockerSteps.java @@ -12,6 +12,31 @@ *******************************************************************************/ package org.eclipse.kapua.qa.integration.steps; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.HttpURLConnection; +import java.net.URL; +import java.nio.charset.StandardCharsets; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.inject.Inject; + +import org.eclipse.kapua.commons.core.ServiceModuleBundle; +import org.eclipse.kapua.locator.KapuaLocator; +import org.eclipse.kapua.qa.common.BasicSteps; +import org.eclipse.kapua.qa.common.DBHelper; +import org.eclipse.kapua.qa.common.StepData; +import org.eclipse.paho.client.mqttv3.MqttException; +import org.junit.Assert; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.collect.Lists; import com.google.inject.Singleton; @@ -32,32 +57,10 @@ import com.spotify.docker.client.messages.NetworkConfig; import com.spotify.docker.client.messages.NetworkCreation; import com.spotify.docker.client.messages.PortBinding; + import io.cucumber.java.en.And; import io.cucumber.java.en.Given; import io.cucumber.java.en.Then; -import org.eclipse.kapua.commons.core.ServiceModuleBundle; -import org.eclipse.kapua.locator.KapuaLocator; -import org.eclipse.kapua.qa.common.BasicSteps; -import org.eclipse.kapua.qa.common.DBHelper; -import org.eclipse.kapua.qa.common.StepData; -import org.eclipse.paho.client.mqttv3.MqttException; -import org.junit.Assert; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.inject.Inject; -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.net.HttpURLConnection; -import java.net.URL; -import java.nio.charset.StandardCharsets; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; @Singleton public class DockerSteps { @@ -65,7 +68,7 @@ public class DockerSteps { private static final Logger logger = LoggerFactory.getLogger(DockerSteps.class); private static final String NETWORK_PREFIX = "kapua-net"; - private static final String KAPUA_VERSION = "2.1.0-SNAPSHOT"; + private static final String KAPUA_VERSION = "2.1.0-FALSE_EXTENSIONS-SNAPSHOT"; private static final String ES_IMAGE = "elasticsearch:7.8.1"; private static final String BROKER_IMAGE = "kapua-broker-artemis"; private static final String LIFECYCLE_CONSUMER_IMAGE = "kapua-consumer-lifecycle"; @@ -126,7 +129,6 @@ public class DockerSteps { private static final String ALL_IP = "0.0.0.0"; - @Inject public DockerSteps(StepData stepData, DBHelper database) { this.stepData = stepData; @@ -237,7 +239,8 @@ public void startFullDockerEnvironment() throws Exception { /** * Starts Docker container requested. * - * @param dockerContainers The Docker containers to start + * @param dockerContainers + * The Docker containers to start * @throws Exception * @since 2.1.0 */ @@ -251,56 +254,63 @@ public void startDockerEnvironmentWithResources(List dockerContainers) t for (String dockerContainer : dockerContainers) { switch (dockerContainer) { - case "db": { - startDBContainer(BasicSteps.DB_CONTAINER_NAME); - synchronized (this) { - this.wait(WAIT_FOR_DB); - } - } break; - case "es": { - startESContainer(BasicSteps.ES_CONTAINER_NAME); - synchronized (this) { - this.wait(WAIT_FOR_ES); - } - } break; - case "events-broker": { - startEventBrokerContainer(BasicSteps.EVENTS_BROKER_CONTAINER_NAME); - synchronized (this) { - this.wait(WAIT_FOR_EVENTS_BROKER); - } - } break; - case "job-engine": { - startJobEngineContainer(BasicSteps.JOB_ENGINE_CONTAINER_NAME); - synchronized (this) { - this.wait(WAIT_FOR_JOB_ENGINE); - } - } break; - case "message-broker": { - startMessageBrokerContainer(BasicSteps.MESSAGE_BROKER_CONTAINER_NAME); - synchronized (this) { - this.wait(WAIT_FOR_BROKER); - } - } break; - case "broker-auth-service": { - startAuthServiceContainer(BasicSteps.AUTH_SERVICE_CONTAINER_NAME); - - long timeout = System.currentTimeMillis(); - while (System.currentTimeMillis() - timeout < 30000) { - isServiceReady(AUTH_SERVICE_CHECK_WEB_APP); - Thread.sleep(500); - } - } break; - case "consumer-lifecycle": { - startLifecycleConsumerContainer(BasicSteps.LIFECYCLE_CONSUMER_CONTAINER_NAME); - - long timeout = System.currentTimeMillis(); - while (System.currentTimeMillis() - timeout < 30000) { - isServiceReady(LIFECYCLE_CHECK_WEB_APP); - Thread.sleep(500); - } - } break; - default: - throw new UnsupportedOperationException("Unknown container resource: " + dockerContainer); + case "db": { + startDBContainer(BasicSteps.DB_CONTAINER_NAME); + synchronized (this) { + this.wait(WAIT_FOR_DB); + } + } + break; + case "es": { + startESContainer(BasicSteps.ES_CONTAINER_NAME); + synchronized (this) { + this.wait(WAIT_FOR_ES); + } + } + break; + case "events-broker": { + startEventBrokerContainer(BasicSteps.EVENTS_BROKER_CONTAINER_NAME); + synchronized (this) { + this.wait(WAIT_FOR_EVENTS_BROKER); + } + } + break; + case "job-engine": { + startJobEngineContainer(BasicSteps.JOB_ENGINE_CONTAINER_NAME); + synchronized (this) { + this.wait(WAIT_FOR_JOB_ENGINE); + } + } + break; + case "message-broker": { + startMessageBrokerContainer(BasicSteps.MESSAGE_BROKER_CONTAINER_NAME); + synchronized (this) { + this.wait(WAIT_FOR_BROKER); + } + } + break; + case "broker-auth-service": { + startAuthServiceContainer(BasicSteps.AUTH_SERVICE_CONTAINER_NAME); + + long timeout = System.currentTimeMillis(); + while (System.currentTimeMillis() - timeout < 30000) { + isServiceReady(AUTH_SERVICE_CHECK_WEB_APP); + Thread.sleep(500); + } + } + break; + case "consumer-lifecycle": { + startLifecycleConsumerContainer(BasicSteps.LIFECYCLE_CONSUMER_CONTAINER_NAME); + + long timeout = System.currentTimeMillis(); + while (System.currentTimeMillis() - timeout < 30000) { + isServiceReady(LIFECYCLE_CHECK_WEB_APP); + Thread.sleep(500); + } + } + break; + default: + throw new UnsupportedOperationException("Unknown container resource: " + dockerContainer); } } } @@ -443,7 +453,7 @@ private boolean isServiceReady(String type) throws IOException { int status = conn.getResponseCode(); if (status == 200) { try (InputStreamReader isr = new InputStreamReader(conn.getInputStream()); - BufferedReader in = new BufferedReader(isr)) { + BufferedReader in = new BufferedReader(isr)) { return isRunning(MAPPER.readValue(in, Map.class)); } } else { @@ -775,7 +785,8 @@ private void printContainerLog(String name) { try { LogStream logStream = DockerUtil.getDockerClient().logs(container.id(), LogsParam.stdout(), LogsParam.stderr()); Logger brokerLogger = LoggerFactory.getLogger(name); - brokerLogger.info("\n===================================================\n START LOG FOR CONTAINER: {} (id: {})\n===================================================", name, container.id()); + brokerLogger.info("\n===================================================\n START LOG FOR CONTAINER: {} (id: {})\n===================================================", name, + container.id()); StringBuilder builder = new StringBuilder(); int i = 0; while (logStream.hasNext()) { @@ -786,7 +797,8 @@ private void printContainerLog(String name) { } } brokerLogger.info(builder.toString()); - brokerLogger.info("\n---------------------------------------------------\n END LOG FOR CONTAINER: {} (id: {})\n---------------------------------------------------", name, container.id()); + brokerLogger.info("\n---------------------------------------------------\n END LOG FOR CONTAINER: {} (id: {})\n---------------------------------------------------", name, + container.id()); } catch (Exception e1) { logger.warn("Cannot print container log for name/id '{}'/'{}'", name, container.id()); } @@ -803,25 +815,33 @@ private void printContainerLog(String name) { * @param brokerAddr * @param brokerIp * @param clusterName - * @param mqttPort mqtt port on docker - * @param mqttHostPort mqtt port on docker host - * @param mqttsPort mqtts port on docker - * @param mqttsHostPort mqtts port on docker host - * @param webPort web port on docker - * @param webHostPort web port on docker host - * @param debugPort debug port on docker - * @param debugHostPort debug port on docker host - * // * @param brokerInternalDebugPort - * @param dockerImage full name of image (e.g. "kapua/kapua-broker:" + version) + * @param mqttPort + * mqtt port on docker + * @param mqttHostPort + * mqtt port on docker host + * @param mqttsPort + * mqtts port on docker + * @param mqttsHostPort + * mqtts port on docker host + * @param webPort + * web port on docker + * @param webHostPort + * web port on docker host + * @param debugPort + * debug port on docker + * @param debugHostPort + * debug port on docker host // * @param brokerInternalDebugPort + * @param dockerImage + * full name of image (e.g. "kapua/kapua-broker:" + version) * @return Container configuration for specific boroker instance */ private ContainerConfig getBrokerContainerConfig(String brokerIp, - int mqttPort, int mqttHostPort, - int mqttInternalPort, int mqttInternalHostPort, - int mqttsPort, int mqttsHostPort, - int webPort, int webHostPort, - int debugPort, int debugHostPort, - String dockerImage) { + int mqttPort, int mqttHostPort, + int mqttInternalPort, int mqttInternalHostPort, + int mqttsPort, int mqttsHostPort, + int webPort, int webHostPort, + int debugPort, int debugHostPort, + String dockerImage) { final Map> portBindings = new HashMap<>(); addHostPort(ALL_IP, portBindings, mqttPort, mqttHostPort); @@ -846,7 +866,7 @@ private ContainerConfig getBrokerContainerConfig(String brokerIp, } if (debug) { -// envVars.add(String.format("ACTIVEMQ_DEBUG_OPTS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=%s", debugPort)); + // envVars.add(String.format("ACTIVEMQ_DEBUG_OPTS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=%s", debugPort)); envVars.add(String.format("DEBUG_ARGS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:%s", debugPort)); } @@ -892,7 +912,7 @@ private ContainerConfig getDbContainerConfig() { "DB_USER=kapua", "DB_PASSWORD=kapua", //uncomment this line to enable the H@ web console (WARNING enable it only for test and then disable it again!) -// "H2_WEB_OPTS=-web -webAllowOthers -webPort 8181", + // "H2_WEB_OPTS=-web -webAllowOthers -webPort 8181", "DB_PORT_3306_TCP_PORT=3306" ) .image("kapua/kapua-sql:" + KAPUA_VERSION) @@ -1054,13 +1074,17 @@ private ContainerConfig getJobEngineContainerConfig() { /** * Add docker port to host port mapping. * - * @param host ip address of host - * @param portBindings list ob bindings that gets updated - * @param port docker port - * @param hostPort port on host + * @param host + * ip address of host + * @param portBindings + * list ob bindings that gets updated + * @param port + * docker port + * @param hostPort + * port on host */ private void addHostPort(String host, Map> portBindings, - int port, int hostPort) { + int port, int hostPort) { List hostPorts = new ArrayList<>(); hostPorts.add(PortBinding.of(host, hostPort)); diff --git a/qa/integration/pom.xml b/qa/integration/pom.xml index ba63d0fbcf5..da152233ab1 100644 --- a/qa/integration/pom.xml +++ b/qa/integration/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-qa - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT ${kapua-client.maven.toolchain.jdk.version} diff --git a/qa/markers/pom.xml b/qa/markers/pom.xml index c75258c28c8..b8ddfe8cc27 100644 --- a/qa/markers/pom.xml +++ b/qa/markers/pom.xml @@ -17,7 +17,7 @@ org.eclipse.kapua kapua-qa - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-qa-markers diff --git a/qa/pom.xml b/qa/pom.xml index d8bf3712b3a..488ab473fed 100644 --- a/qa/pom.xml +++ b/qa/pom.xml @@ -19,7 +19,7 @@ org.eclipse.kapua kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-qa diff --git a/rest-api/core/pom.xml b/rest-api/core/pom.xml index 7d2e9868011..2f798fbafe3 100644 --- a/rest-api/core/pom.xml +++ b/rest-api/core/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-rest-api - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-rest-api-core diff --git a/rest-api/pom.xml b/rest-api/pom.xml index d3c38eccf2a..7daeb636926 100644 --- a/rest-api/pom.xml +++ b/rest-api/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-rest-api diff --git a/rest-api/resources/pom.xml b/rest-api/resources/pom.xml index e054c141599..7fdac14956c 100644 --- a/rest-api/resources/pom.xml +++ b/rest-api/resources/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-rest-api - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-rest-api-resources diff --git a/rest-api/resources/src/main/resources/openapi/openapi.yaml b/rest-api/resources/src/main/resources/openapi/openapi.yaml index d45ca00e92b..148e9fd289b 100644 --- a/rest-api/resources/src/main/resources/openapi/openapi.yaml +++ b/rest-api/resources/src/main/resources/openapi/openapi.yaml @@ -2,7 +2,7 @@ openapi: 3.0.3 info: title: Eclipse Kapua REST API - version: '2.1.0-SNAPSHOT' + version: '2.1.0-FALSE_EXTENSIONS-SNAPSHOT' contact: name: Eclipse Kapua Dev Team url: https://eclipse.org/kapua diff --git a/rest-api/web/pom.xml b/rest-api/web/pom.xml index d7a5ca98888..9760c5859b8 100644 --- a/rest-api/web/pom.xml +++ b/rest-api/web/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-rest-api - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-rest-api-web diff --git a/service/account/api/pom.xml b/service/account/api/pom.xml index 3874824bb9c..facef182fda 100644 --- a/service/account/api/pom.xml +++ b/service/account/api/pom.xml @@ -17,7 +17,7 @@ org.eclipse.kapua kapua-account - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-account-api diff --git a/service/account/internal/pom.xml b/service/account/internal/pom.xml index d774ec36bf1..a80fdba2918 100644 --- a/service/account/internal/pom.xml +++ b/service/account/internal/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-account - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-account-internal diff --git a/service/account/pom.xml b/service/account/pom.xml index 3405811d8c3..3c1a8c3884f 100644 --- a/service/account/pom.xml +++ b/service/account/pom.xml @@ -19,7 +19,7 @@ org.eclipse.kapua kapua-service - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT pom diff --git a/service/account/test-steps/pom.xml b/service/account/test-steps/pom.xml index a9134a3c77c..7a36f0c6cd9 100644 --- a/service/account/test-steps/pom.xml +++ b/service/account/test-steps/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-account - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-account-test-steps diff --git a/service/account/test/pom.xml b/service/account/test/pom.xml index 15ba53d53b1..5a6062c6691 100644 --- a/service/account/test/pom.xml +++ b/service/account/test/pom.xml @@ -20,7 +20,7 @@ org.eclipse.kapua kapua-account - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-account-test diff --git a/service/api/pom.xml b/service/api/pom.xml index a22320ea2fc..445f79d5e8f 100644 --- a/service/api/pom.xml +++ b/service/api/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-service - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-service-api diff --git a/service/authentication-app/pom.xml b/service/authentication-app/pom.xml index 61961c6a479..21b13533861 100644 --- a/service/authentication-app/pom.xml +++ b/service/authentication-app/pom.xml @@ -17,7 +17,7 @@ kapua-service org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT 4.0.0 diff --git a/service/authentication/pom.xml b/service/authentication/pom.xml index ddac23de86c..bb77c61f2cf 100644 --- a/service/authentication/pom.xml +++ b/service/authentication/pom.xml @@ -17,7 +17,7 @@ org.eclipse.kapua kapua-service - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-service-authentication diff --git a/service/camel/pom.xml b/service/camel/pom.xml index 247c9dc88b7..af8be948d06 100644 --- a/service/camel/pom.xml +++ b/service/camel/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-service - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-service-camel diff --git a/service/client/pom.xml b/service/client/pom.xml index 256633f5f45..a361b042fde 100644 --- a/service/client/pom.xml +++ b/service/client/pom.xml @@ -17,7 +17,7 @@ org.eclipse.kapua kapua-service - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-service-client diff --git a/service/commons/elasticsearch/client-api/pom.xml b/service/commons/elasticsearch/client-api/pom.xml index 5d0ff5352a9..73650e7f6b8 100644 --- a/service/commons/elasticsearch/client-api/pom.xml +++ b/service/commons/elasticsearch/client-api/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-service-elasticsearch - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-service-elasticsearch-client-api diff --git a/service/commons/elasticsearch/client-rest/pom.xml b/service/commons/elasticsearch/client-rest/pom.xml index 2fd83072d81..d11bfaaebdd 100644 --- a/service/commons/elasticsearch/client-rest/pom.xml +++ b/service/commons/elasticsearch/client-rest/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-service-elasticsearch - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-service-elasticsearch-client-rest diff --git a/service/commons/elasticsearch/pom.xml b/service/commons/elasticsearch/pom.xml index bb71bbfc719..fa86a235231 100644 --- a/service/commons/elasticsearch/pom.xml +++ b/service/commons/elasticsearch/pom.xml @@ -19,7 +19,7 @@ kapua-service-commons org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-service-elasticsearch diff --git a/service/commons/pom.xml b/service/commons/pom.xml index 01d92ffcdbc..f861384542e 100644 --- a/service/commons/pom.xml +++ b/service/commons/pom.xml @@ -19,7 +19,7 @@ kapua-service org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-service-commons diff --git a/service/commons/storable/api/pom.xml b/service/commons/storable/api/pom.xml index a8c7885fe32..c77a5d9d59a 100644 --- a/service/commons/storable/api/pom.xml +++ b/service/commons/storable/api/pom.xml @@ -19,7 +19,7 @@ kapua-service-storable org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-service-storable-api diff --git a/service/commons/storable/internal/pom.xml b/service/commons/storable/internal/pom.xml index 232dc36ba55..2ca242ab448 100644 --- a/service/commons/storable/internal/pom.xml +++ b/service/commons/storable/internal/pom.xml @@ -19,7 +19,7 @@ kapua-service-storable org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-service-storable-internal diff --git a/service/commons/storable/pom.xml b/service/commons/storable/pom.xml index 14967b34dac..dca9a85d20c 100644 --- a/service/commons/storable/pom.xml +++ b/service/commons/storable/pom.xml @@ -19,7 +19,7 @@ kapua-service-commons org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-service-storable diff --git a/service/commons/utils/api/pom.xml b/service/commons/utils/api/pom.xml index 9d369e90ea6..6ea60f375f0 100644 --- a/service/commons/utils/api/pom.xml +++ b/service/commons/utils/api/pom.xml @@ -19,7 +19,7 @@ kapua-service-commons-utils org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-service-commons-utils-api diff --git a/service/commons/utils/internal/pom.xml b/service/commons/utils/internal/pom.xml index 555c35f87fb..a0921513958 100644 --- a/service/commons/utils/internal/pom.xml +++ b/service/commons/utils/internal/pom.xml @@ -19,7 +19,7 @@ kapua-service-commons-utils org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-service-commons-utils-internal diff --git a/service/commons/utils/pom.xml b/service/commons/utils/pom.xml index 570015d3c10..2295fc8e432 100644 --- a/service/commons/utils/pom.xml +++ b/service/commons/utils/pom.xml @@ -19,7 +19,7 @@ kapua-service-commons org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-service-commons-utils diff --git a/service/datastore/api/pom.xml b/service/datastore/api/pom.xml index 3d527ae63a0..f36618b5d84 100644 --- a/service/datastore/api/pom.xml +++ b/service/datastore/api/pom.xml @@ -19,7 +19,7 @@ org.eclipse.kapua kapua-datastore - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-datastore-api diff --git a/service/datastore/internal/pom.xml b/service/datastore/internal/pom.xml index 3a6b89e60a7..1408b3fdbd2 100644 --- a/service/datastore/internal/pom.xml +++ b/service/datastore/internal/pom.xml @@ -20,7 +20,7 @@ org.eclipse.kapua kapua-datastore - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-datastore-internal diff --git a/service/datastore/pom.xml b/service/datastore/pom.xml index c5778e1498c..5ffe3440301 100644 --- a/service/datastore/pom.xml +++ b/service/datastore/pom.xml @@ -19,7 +19,7 @@ org.eclipse.kapua kapua-service - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-datastore diff --git a/service/datastore/test-steps/pom.xml b/service/datastore/test-steps/pom.xml index 309183a7add..83befb754f8 100644 --- a/service/datastore/test-steps/pom.xml +++ b/service/datastore/test-steps/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-datastore - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-datastore-test-steps diff --git a/service/datastore/test/pom.xml b/service/datastore/test/pom.xml index 7ad503eb482..8ada69deee6 100644 --- a/service/datastore/test/pom.xml +++ b/service/datastore/test/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-datastore - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-datastore-test diff --git a/service/device/api/pom.xml b/service/device/api/pom.xml index c31b1606eca..2c19623ad45 100644 --- a/service/device/api/pom.xml +++ b/service/device/api/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-device - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-device-api diff --git a/service/device/authentication/pom.xml b/service/device/authentication/pom.xml index 994416661b0..4ff7f1a8e14 100644 --- a/service/device/authentication/pom.xml +++ b/service/device/authentication/pom.xml @@ -19,7 +19,7 @@ org.eclipse.kapua kapua-device - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-device-authentication diff --git a/service/device/call/api/pom.xml b/service/device/call/api/pom.xml index 7109dc7c587..4821b04f8ef 100644 --- a/service/device/call/api/pom.xml +++ b/service/device/call/api/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-device-call - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-device-call-api diff --git a/service/device/call/kura/pom.xml b/service/device/call/kura/pom.xml index eb1b91e0117..140db1904c0 100644 --- a/service/device/call/kura/pom.xml +++ b/service/device/call/kura/pom.xml @@ -19,7 +19,7 @@ org.eclipse.kapua kapua-device-call - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-device-call-kura diff --git a/service/device/call/pom.xml b/service/device/call/pom.xml index e30359f57c3..6714377cc85 100644 --- a/service/device/call/pom.xml +++ b/service/device/call/pom.xml @@ -19,7 +19,7 @@ org.eclipse.kapua kapua-device - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT pom diff --git a/service/device/commons/pom.xml b/service/device/commons/pom.xml index 1a921d5b9d9..943995be7a7 100644 --- a/service/device/commons/pom.xml +++ b/service/device/commons/pom.xml @@ -19,7 +19,7 @@ org.eclipse.kapua kapua-device - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-device-commons diff --git a/service/device/management/all/api/pom.xml b/service/device/management/all/api/pom.xml index b2e7ca09e61..907f231e394 100644 --- a/service/device/management/all/api/pom.xml +++ b/service/device/management/all/api/pom.xml @@ -19,7 +19,7 @@ kapua-device-management-all org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-device-management-all-api diff --git a/service/device/management/all/internal/pom.xml b/service/device/management/all/internal/pom.xml index 6a2228bfacb..a512accd4f2 100644 --- a/service/device/management/all/internal/pom.xml +++ b/service/device/management/all/internal/pom.xml @@ -19,7 +19,7 @@ kapua-device-management-all org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-device-management-all-internal diff --git a/service/device/management/all/job/pom.xml b/service/device/management/all/job/pom.xml index 8d93265ac07..eb971d1c982 100644 --- a/service/device/management/all/job/pom.xml +++ b/service/device/management/all/job/pom.xml @@ -19,7 +19,7 @@ kapua-device-management-all org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-device-management-all-job diff --git a/service/device/management/all/pom.xml b/service/device/management/all/pom.xml index e128485df2c..a01d80a32f9 100644 --- a/service/device/management/all/pom.xml +++ b/service/device/management/all/pom.xml @@ -19,7 +19,7 @@ kapua-device-management org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT pom diff --git a/service/device/management/api/pom.xml b/service/device/management/api/pom.xml index fac6e087150..20a4e70607e 100644 --- a/service/device/management/api/pom.xml +++ b/service/device/management/api/pom.xml @@ -19,7 +19,7 @@ kapua-device-management org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-device-management-api diff --git a/service/device/management/asset-store/api/pom.xml b/service/device/management/asset-store/api/pom.xml index c4eb4a6bd71..b0e3f1e3b1e 100644 --- a/service/device/management/asset-store/api/pom.xml +++ b/service/device/management/asset-store/api/pom.xml @@ -19,7 +19,7 @@ org.eclipse.kapua kapua-device-management-asset-store - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-device-management-asset-store-api diff --git a/service/device/management/asset-store/dummy/pom.xml b/service/device/management/asset-store/dummy/pom.xml index e8e6362414d..8abe32502d2 100644 --- a/service/device/management/asset-store/dummy/pom.xml +++ b/service/device/management/asset-store/dummy/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-device-management-asset-store - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-device-management-asset-store-dummy diff --git a/service/device/management/asset-store/pom.xml b/service/device/management/asset-store/pom.xml index d0174ff0d1f..56c3f8caebe 100644 --- a/service/device/management/asset-store/pom.xml +++ b/service/device/management/asset-store/pom.xml @@ -19,7 +19,7 @@ org.eclipse.kapua kapua-device-management - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-device-management-asset-store diff --git a/service/device/management/asset/api/pom.xml b/service/device/management/asset/api/pom.xml index f5e0aa9d9d9..b0700a0800e 100644 --- a/service/device/management/asset/api/pom.xml +++ b/service/device/management/asset/api/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-device-management-asset - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-device-management-asset-api diff --git a/service/device/management/asset/internal/pom.xml b/service/device/management/asset/internal/pom.xml index 51102f7d007..5161bc0d943 100644 --- a/service/device/management/asset/internal/pom.xml +++ b/service/device/management/asset/internal/pom.xml @@ -19,7 +19,7 @@ org.eclipse.kapua kapua-device-management-asset - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-device-management-asset-internal diff --git a/service/device/management/asset/job/pom.xml b/service/device/management/asset/job/pom.xml index a0d42a046f7..5ef58ededbf 100644 --- a/service/device/management/asset/job/pom.xml +++ b/service/device/management/asset/job/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-device-management-asset - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-device-management-asset-job diff --git a/service/device/management/asset/pom.xml b/service/device/management/asset/pom.xml index 74fad02b933..9908e693727 100644 --- a/service/device/management/asset/pom.xml +++ b/service/device/management/asset/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-device-management - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT pom diff --git a/service/device/management/bundle/api/pom.xml b/service/device/management/bundle/api/pom.xml index be5878a2869..8d443cc3331 100644 --- a/service/device/management/bundle/api/pom.xml +++ b/service/device/management/bundle/api/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-device-management-bundle - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-device-management-bundle-api diff --git a/service/device/management/bundle/internal/pom.xml b/service/device/management/bundle/internal/pom.xml index 35dde25a651..dca60e6a0bb 100644 --- a/service/device/management/bundle/internal/pom.xml +++ b/service/device/management/bundle/internal/pom.xml @@ -19,7 +19,7 @@ org.eclipse.kapua kapua-device-management-bundle - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-device-management-bundle-internal diff --git a/service/device/management/bundle/job/pom.xml b/service/device/management/bundle/job/pom.xml index 445f44576a1..2cef4effe85 100644 --- a/service/device/management/bundle/job/pom.xml +++ b/service/device/management/bundle/job/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-device-management-bundle - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-device-management-bundle-job diff --git a/service/device/management/bundle/pom.xml b/service/device/management/bundle/pom.xml index 10374e816fe..7ce446dd342 100644 --- a/service/device/management/bundle/pom.xml +++ b/service/device/management/bundle/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-device-management - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT pom diff --git a/service/device/management/command/api/pom.xml b/service/device/management/command/api/pom.xml index fee3316fee6..89a926bd449 100644 --- a/service/device/management/command/api/pom.xml +++ b/service/device/management/command/api/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-device-management-command - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-device-management-command-api diff --git a/service/device/management/command/internal/pom.xml b/service/device/management/command/internal/pom.xml index ae728bc3705..1008f085033 100644 --- a/service/device/management/command/internal/pom.xml +++ b/service/device/management/command/internal/pom.xml @@ -19,7 +19,7 @@ org.eclipse.kapua kapua-device-management-command - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-device-management-command-internal diff --git a/service/device/management/command/job/pom.xml b/service/device/management/command/job/pom.xml index 9578791fe80..0c6715b31fc 100644 --- a/service/device/management/command/job/pom.xml +++ b/service/device/management/command/job/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-device-management-command - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-device-management-command-job diff --git a/service/device/management/command/pom.xml b/service/device/management/command/pom.xml index 70bd1f0bc2c..c4d20fbfaba 100644 --- a/service/device/management/command/pom.xml +++ b/service/device/management/command/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-device-management - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT pom diff --git a/service/device/management/configuration-store/api/pom.xml b/service/device/management/configuration-store/api/pom.xml index b59bac0a7a2..b7693a989a1 100644 --- a/service/device/management/configuration-store/api/pom.xml +++ b/service/device/management/configuration-store/api/pom.xml @@ -19,7 +19,7 @@ org.eclipse.kapua kapua-device-management-configuration-store - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-device-management-configuration-store-api diff --git a/service/device/management/configuration-store/dummy/pom.xml b/service/device/management/configuration-store/dummy/pom.xml index d9583e5b472..1e3e37a56e4 100644 --- a/service/device/management/configuration-store/dummy/pom.xml +++ b/service/device/management/configuration-store/dummy/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-device-management-configuration-store - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-device-management-configuration-store-dummy diff --git a/service/device/management/configuration-store/pom.xml b/service/device/management/configuration-store/pom.xml index 545dd3dce3e..de109c61e28 100644 --- a/service/device/management/configuration-store/pom.xml +++ b/service/device/management/configuration-store/pom.xml @@ -19,7 +19,7 @@ org.eclipse.kapua kapua-device-management - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-device-management-configuration-store diff --git a/service/device/management/configuration/api/pom.xml b/service/device/management/configuration/api/pom.xml index d721aad23e1..ecff656e9f7 100644 --- a/service/device/management/configuration/api/pom.xml +++ b/service/device/management/configuration/api/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-device-management-configuration - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-device-management-configuration-api diff --git a/service/device/management/configuration/internal/pom.xml b/service/device/management/configuration/internal/pom.xml index 75ead3a0013..cdf4fcc6703 100644 --- a/service/device/management/configuration/internal/pom.xml +++ b/service/device/management/configuration/internal/pom.xml @@ -19,7 +19,7 @@ org.eclipse.kapua kapua-device-management-configuration - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-device-management-configuration-internal diff --git a/service/device/management/configuration/job/pom.xml b/service/device/management/configuration/job/pom.xml index 6cb75339f37..2cbfad1f8ae 100644 --- a/service/device/management/configuration/job/pom.xml +++ b/service/device/management/configuration/job/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-device-management-configuration - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-device-management-configuration-job diff --git a/service/device/management/configuration/message-api/pom.xml b/service/device/management/configuration/message-api/pom.xml index 39c116d05dd..68501c2493f 100644 --- a/service/device/management/configuration/message-api/pom.xml +++ b/service/device/management/configuration/message-api/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-device-management-configuration - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-device-management-configuration-message-api diff --git a/service/device/management/configuration/pom.xml b/service/device/management/configuration/pom.xml index 28eb211e6bb..234dc2d94b7 100644 --- a/service/device/management/configuration/pom.xml +++ b/service/device/management/configuration/pom.xml @@ -19,7 +19,7 @@ org.eclipse.kapua kapua-device-management - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT pom diff --git a/service/device/management/inventory/api/pom.xml b/service/device/management/inventory/api/pom.xml index ae6b6cb2711..cc478499fdb 100644 --- a/service/device/management/inventory/api/pom.xml +++ b/service/device/management/inventory/api/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-device-management-inventory - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-device-management-inventory-api diff --git a/service/device/management/inventory/internal/pom.xml b/service/device/management/inventory/internal/pom.xml index 8fc1252ee77..29bd23ebc4f 100644 --- a/service/device/management/inventory/internal/pom.xml +++ b/service/device/management/inventory/internal/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-device-management-inventory - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-device-management-inventory-internal diff --git a/service/device/management/inventory/pom.xml b/service/device/management/inventory/pom.xml index 2a974021de2..af59942217a 100644 --- a/service/device/management/inventory/pom.xml +++ b/service/device/management/inventory/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-device-management - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-device-management-inventory diff --git a/service/device/management/job/api/pom.xml b/service/device/management/job/api/pom.xml index 87b32430a06..fe5198f18a6 100644 --- a/service/device/management/job/api/pom.xml +++ b/service/device/management/job/api/pom.xml @@ -18,7 +18,7 @@ kapua-device-management-job org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-device-management-job-api diff --git a/service/device/management/job/internal/pom.xml b/service/device/management/job/internal/pom.xml index d85ba14ed1f..6ee3757752f 100644 --- a/service/device/management/job/internal/pom.xml +++ b/service/device/management/job/internal/pom.xml @@ -18,7 +18,7 @@ kapua-device-management-job org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-device-management-job-internal diff --git a/service/device/management/job/pom.xml b/service/device/management/job/pom.xml index fba5b4495ca..806928977da 100644 --- a/service/device/management/job/pom.xml +++ b/service/device/management/job/pom.xml @@ -18,7 +18,7 @@ kapua-device-management org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT pom diff --git a/service/device/management/keystore/api/pom.xml b/service/device/management/keystore/api/pom.xml index f54deb6c97a..25c76c62802 100644 --- a/service/device/management/keystore/api/pom.xml +++ b/service/device/management/keystore/api/pom.xml @@ -17,7 +17,7 @@ org.eclipse.kapua kapua-device-management-keystore - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-device-management-keystore-api diff --git a/service/device/management/keystore/internal/pom.xml b/service/device/management/keystore/internal/pom.xml index 77b17da9db3..ccb4cc50dbc 100644 --- a/service/device/management/keystore/internal/pom.xml +++ b/service/device/management/keystore/internal/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-device-management-keystore - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-device-management-keystore-internal diff --git a/service/device/management/keystore/job/pom.xml b/service/device/management/keystore/job/pom.xml index f74f99da050..9ebabe6218f 100644 --- a/service/device/management/keystore/job/pom.xml +++ b/service/device/management/keystore/job/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-device-management-keystore - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-device-management-keystore-job diff --git a/service/device/management/keystore/pom.xml b/service/device/management/keystore/pom.xml index b89c44ad26d..53c6a41a022 100644 --- a/service/device/management/keystore/pom.xml +++ b/service/device/management/keystore/pom.xml @@ -19,7 +19,7 @@ kapua-device-management org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-device-management-keystore diff --git a/service/device/management/packages/api/pom.xml b/service/device/management/packages/api/pom.xml index dac3b355f01..4584f6561e5 100644 --- a/service/device/management/packages/api/pom.xml +++ b/service/device/management/packages/api/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-device-management-packages - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-device-management-packages-api diff --git a/service/device/management/packages/internal/pom.xml b/service/device/management/packages/internal/pom.xml index 6c6ecdf1f37..4db8733a892 100644 --- a/service/device/management/packages/internal/pom.xml +++ b/service/device/management/packages/internal/pom.xml @@ -19,7 +19,7 @@ org.eclipse.kapua kapua-device-management-packages - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-device-management-packages-internal diff --git a/service/device/management/packages/job/pom.xml b/service/device/management/packages/job/pom.xml index 096810c4c1b..1751ed77474 100644 --- a/service/device/management/packages/job/pom.xml +++ b/service/device/management/packages/job/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-device-management-packages - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-device-management-packages-job diff --git a/service/device/management/packages/pom.xml b/service/device/management/packages/pom.xml index f49ae48699d..3b1dbb8ae5e 100644 --- a/service/device/management/packages/pom.xml +++ b/service/device/management/packages/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-device-management - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT pom diff --git a/service/device/management/pom.xml b/service/device/management/pom.xml index 61e4ac4c1bd..36b942bf72f 100644 --- a/service/device/management/pom.xml +++ b/service/device/management/pom.xml @@ -19,7 +19,7 @@ kapua-device org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-device-management diff --git a/service/device/management/registry/api/pom.xml b/service/device/management/registry/api/pom.xml index 97531a18804..23e7fd0dfce 100644 --- a/service/device/management/registry/api/pom.xml +++ b/service/device/management/registry/api/pom.xml @@ -19,7 +19,7 @@ kapua-device-management-registry org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-device-management-registry-api diff --git a/service/device/management/registry/internal/pom.xml b/service/device/management/registry/internal/pom.xml index 77a1f243a52..aebfeccf15a 100644 --- a/service/device/management/registry/internal/pom.xml +++ b/service/device/management/registry/internal/pom.xml @@ -19,7 +19,7 @@ kapua-device-management-registry org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-device-management-registry-internal diff --git a/service/device/management/registry/pom.xml b/service/device/management/registry/pom.xml index a0e4a1cbdd3..f9eda1a7aba 100644 --- a/service/device/management/registry/pom.xml +++ b/service/device/management/registry/pom.xml @@ -19,7 +19,7 @@ kapua-device-management org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT pom diff --git a/service/device/management/request/api/pom.xml b/service/device/management/request/api/pom.xml index e8a6a98be0b..94412f2fcb3 100644 --- a/service/device/management/request/api/pom.xml +++ b/service/device/management/request/api/pom.xml @@ -18,7 +18,7 @@ kapua-device-management-request org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-device-management-request-api diff --git a/service/device/management/request/internal/pom.xml b/service/device/management/request/internal/pom.xml index 4da3264c8b5..f6aea23cf2c 100644 --- a/service/device/management/request/internal/pom.xml +++ b/service/device/management/request/internal/pom.xml @@ -19,7 +19,7 @@ kapua-device-management-request org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-device-management-request-internal diff --git a/service/device/management/request/pom.xml b/service/device/management/request/pom.xml index 354f6bca1d9..de72c32255a 100644 --- a/service/device/management/request/pom.xml +++ b/service/device/management/request/pom.xml @@ -18,7 +18,7 @@ kapua-device-management org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT pom diff --git a/service/device/pom.xml b/service/device/pom.xml index ed1e9ee0fe5..2aa1cae273e 100644 --- a/service/device/pom.xml +++ b/service/device/pom.xml @@ -17,7 +17,7 @@ org.eclipse.kapua kapua-service - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-device diff --git a/service/device/registry/api/pom.xml b/service/device/registry/api/pom.xml index 129d1e33bec..f10b762ad1c 100644 --- a/service/device/registry/api/pom.xml +++ b/service/device/registry/api/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-device-registry - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-device-registry-api diff --git a/service/device/registry/internal/pom.xml b/service/device/registry/internal/pom.xml index a45c35fb83a..4865a506f91 100644 --- a/service/device/registry/internal/pom.xml +++ b/service/device/registry/internal/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-device-registry - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-device-registry-internal diff --git a/service/device/registry/pom.xml b/service/device/registry/pom.xml index 1bef64494e8..bbcd92acd0a 100644 --- a/service/device/registry/pom.xml +++ b/service/device/registry/pom.xml @@ -19,7 +19,7 @@ org.eclipse.kapua kapua-device - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT pom diff --git a/service/device/registry/test-steps/pom.xml b/service/device/registry/test-steps/pom.xml index 5a03ada40b2..30c53824df9 100644 --- a/service/device/registry/test-steps/pom.xml +++ b/service/device/registry/test-steps/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-device-registry - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-device-registry-test-steps diff --git a/service/device/registry/test/pom.xml b/service/device/registry/test/pom.xml index f387cc6ac3c..21fd22bffd6 100644 --- a/service/device/registry/test/pom.xml +++ b/service/device/registry/test/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-device-registry - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-device-registry-test diff --git a/service/endpoint/api/pom.xml b/service/endpoint/api/pom.xml index eaf41a67eda..3cafd8933fb 100644 --- a/service/endpoint/api/pom.xml +++ b/service/endpoint/api/pom.xml @@ -17,7 +17,7 @@ kapua-endpoint org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT 4.0.0 diff --git a/service/endpoint/internal/pom.xml b/service/endpoint/internal/pom.xml index 4e8ec80cb14..61ee508e6ea 100644 --- a/service/endpoint/internal/pom.xml +++ b/service/endpoint/internal/pom.xml @@ -19,7 +19,7 @@ kapua-endpoint org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-endpoint-internal diff --git a/service/endpoint/pom.xml b/service/endpoint/pom.xml index 7c481c805c5..b823a49e110 100644 --- a/service/endpoint/pom.xml +++ b/service/endpoint/pom.xml @@ -19,7 +19,7 @@ kapua-service org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT pom diff --git a/service/endpoint/test-steps/pom.xml b/service/endpoint/test-steps/pom.xml index eb0158d80cf..d21bd706916 100644 --- a/service/endpoint/test-steps/pom.xml +++ b/service/endpoint/test-steps/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-endpoint - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-endpoint-test-steps diff --git a/service/job/api/pom.xml b/service/job/api/pom.xml index 8dfac9aefe9..4980855413a 100644 --- a/service/job/api/pom.xml +++ b/service/job/api/pom.xml @@ -17,7 +17,7 @@ org.eclipse.kapua kapua-job - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-job-api diff --git a/service/job/internal/pom.xml b/service/job/internal/pom.xml index 0b3a7864e42..a34af0b2941 100755 --- a/service/job/internal/pom.xml +++ b/service/job/internal/pom.xml @@ -17,7 +17,7 @@ org.eclipse.kapua kapua-job - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-job-internal diff --git a/service/job/pom.xml b/service/job/pom.xml index d57f667e03e..1c9c7c891ba 100644 --- a/service/job/pom.xml +++ b/service/job/pom.xml @@ -19,7 +19,7 @@ org.eclipse.kapua kapua-service - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT pom diff --git a/service/job/test-steps/pom.xml b/service/job/test-steps/pom.xml index f78eb382223..f81eaaa3f22 100644 --- a/service/job/test-steps/pom.xml +++ b/service/job/test-steps/pom.xml @@ -20,7 +20,7 @@ org.eclipse.kapua kapua-job - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-job-test-steps diff --git a/service/job/test/pom.xml b/service/job/test/pom.xml index 52325ef6660..05eb601b22b 100644 --- a/service/job/test/pom.xml +++ b/service/job/test/pom.xml @@ -19,7 +19,7 @@ org.eclipse.kapua kapua-job - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-job-test diff --git a/service/pom.xml b/service/pom.xml index add024cb096..002ed19ff8f 100644 --- a/service/pom.xml +++ b/service/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-service diff --git a/service/scheduler/api/pom.xml b/service/scheduler/api/pom.xml index 80fba1fe7ce..397ce99ef3a 100644 --- a/service/scheduler/api/pom.xml +++ b/service/scheduler/api/pom.xml @@ -17,7 +17,7 @@ org.eclipse.kapua kapua-scheduler - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-scheduler-api diff --git a/service/scheduler/pom.xml b/service/scheduler/pom.xml index 7023ffd5497..c0aced5d150 100644 --- a/service/scheduler/pom.xml +++ b/service/scheduler/pom.xml @@ -19,7 +19,7 @@ org.eclipse.kapua kapua-service - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT pom diff --git a/service/scheduler/quartz/pom.xml b/service/scheduler/quartz/pom.xml index ca1128d8d78..759f9e0d5e3 100644 --- a/service/scheduler/quartz/pom.xml +++ b/service/scheduler/quartz/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-scheduler - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-scheduler-quartz diff --git a/service/scheduler/test-steps/pom.xml b/service/scheduler/test-steps/pom.xml index 1042bfc5e8d..4097815ae7f 100644 --- a/service/scheduler/test-steps/pom.xml +++ b/service/scheduler/test-steps/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-scheduler - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-scheduler-test-steps diff --git a/service/scheduler/test/pom.xml b/service/scheduler/test/pom.xml index 79a7a9b7b3e..860d765f45d 100644 --- a/service/scheduler/test/pom.xml +++ b/service/scheduler/test/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-scheduler - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-scheduler-test diff --git a/service/security/authentication/api/pom.xml b/service/security/authentication/api/pom.xml index 99ab2e99607..784de19b3f4 100644 --- a/service/security/authentication/api/pom.xml +++ b/service/security/authentication/api/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-security-authentication - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-security-authentication-api diff --git a/service/security/authentication/pom.xml b/service/security/authentication/pom.xml index ee0f23469ad..fd782adad5f 100644 --- a/service/security/authentication/pom.xml +++ b/service/security/authentication/pom.xml @@ -19,7 +19,7 @@ org.eclipse.kapua kapua-security - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT pom diff --git a/service/security/authorization/api/pom.xml b/service/security/authorization/api/pom.xml index a03de2ea37c..be074666293 100644 --- a/service/security/authorization/api/pom.xml +++ b/service/security/authorization/api/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-security-authorization - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-security-authorization-api diff --git a/service/security/authorization/pom.xml b/service/security/authorization/pom.xml index 7e7437df613..0ff58c9e704 100644 --- a/service/security/authorization/pom.xml +++ b/service/security/authorization/pom.xml @@ -19,7 +19,7 @@ org.eclipse.kapua kapua-security - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT pom diff --git a/service/security/certificate/api/pom.xml b/service/security/certificate/api/pom.xml index 490d4b98b81..f8eb36e157a 100644 --- a/service/security/certificate/api/pom.xml +++ b/service/security/certificate/api/pom.xml @@ -18,7 +18,7 @@ kapua-security-certificate org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT 4.0.0 diff --git a/service/security/certificate/internal/pom.xml b/service/security/certificate/internal/pom.xml index a6845068dc7..b890dfe3060 100644 --- a/service/security/certificate/internal/pom.xml +++ b/service/security/certificate/internal/pom.xml @@ -18,7 +18,7 @@ kapua-security-certificate org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT 4.0.0 diff --git a/service/security/certificate/pom.xml b/service/security/certificate/pom.xml index 94dac4e7302..b7cf0c479e8 100644 --- a/service/security/certificate/pom.xml +++ b/service/security/certificate/pom.xml @@ -18,7 +18,7 @@ kapua-security org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT 4.0.0 diff --git a/service/security/pom.xml b/service/security/pom.xml index 7d36e97e075..f858c5dcb48 100644 --- a/service/security/pom.xml +++ b/service/security/pom.xml @@ -19,7 +19,7 @@ org.eclipse.kapua kapua-service - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT pom diff --git a/service/security/registration/api/pom.xml b/service/security/registration/api/pom.xml index 30a6e408070..7336c93f4c2 100644 --- a/service/security/registration/api/pom.xml +++ b/service/security/registration/api/pom.xml @@ -19,7 +19,7 @@ org.eclipse.kapua kapua-security-registration - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-security-registration-api diff --git a/service/security/registration/pom.xml b/service/security/registration/pom.xml index a57ea61a4a2..ba487981b88 100644 --- a/service/security/registration/pom.xml +++ b/service/security/registration/pom.xml @@ -19,7 +19,7 @@ org.eclipse.kapua kapua-security - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-security-registration diff --git a/service/security/registration/simple/pom.xml b/service/security/registration/simple/pom.xml index 9218ec8dc06..809a3b33cf7 100644 --- a/service/security/registration/simple/pom.xml +++ b/service/security/registration/simple/pom.xml @@ -20,7 +20,7 @@ org.eclipse.kapua kapua-security-registration - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-security-registration-simple @@ -33,7 +33,7 @@ org.eclipse.kapua kapua-account-internal - + org.eclipse.kapua kapua-datastore-api diff --git a/service/security/shiro/pom.xml b/service/security/shiro/pom.xml index e763f31fff0..973d22c899f 100644 --- a/service/security/shiro/pom.xml +++ b/service/security/shiro/pom.xml @@ -19,7 +19,7 @@ org.eclipse.kapua kapua-security - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-security-shiro diff --git a/service/security/test-steps/pom.xml b/service/security/test-steps/pom.xml index 05ce7b0cdeb..d01c41ee436 100644 --- a/service/security/test-steps/pom.xml +++ b/service/security/test-steps/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-security - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-security-test-steps diff --git a/service/security/test/pom.xml b/service/security/test/pom.xml index 2aca64b4dcd..18d4475552b 100644 --- a/service/security/test/pom.xml +++ b/service/security/test/pom.xml @@ -20,7 +20,7 @@ org.eclipse.kapua kapua-security - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-security-test diff --git a/service/stream/api/pom.xml b/service/stream/api/pom.xml index e1f47334393..1f2e4c90273 100644 --- a/service/stream/api/pom.xml +++ b/service/stream/api/pom.xml @@ -18,7 +18,7 @@ kapua-stream org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-stream-api diff --git a/service/stream/internal/pom.xml b/service/stream/internal/pom.xml index fb6e01f4527..c3dd3c32ba8 100644 --- a/service/stream/internal/pom.xml +++ b/service/stream/internal/pom.xml @@ -18,7 +18,7 @@ kapua-stream org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-stream-internal diff --git a/service/stream/pom.xml b/service/stream/pom.xml index 0a316c3fc9b..b439a7c140e 100644 --- a/service/stream/pom.xml +++ b/service/stream/pom.xml @@ -16,7 +16,7 @@ kapua-service org.eclipse.kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT 4.0.0 diff --git a/service/system/api/pom.xml b/service/system/api/pom.xml index 493a801d368..4638249277e 100644 --- a/service/system/api/pom.xml +++ b/service/system/api/pom.xml @@ -17,7 +17,7 @@ org.eclipse.kapua kapua-system - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-system-api diff --git a/service/system/internal/pom.xml b/service/system/internal/pom.xml index e78e48bb76f..22a81ebf0cf 100644 --- a/service/system/internal/pom.xml +++ b/service/system/internal/pom.xml @@ -17,7 +17,7 @@ org.eclipse.kapua kapua-system - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-system-internal diff --git a/service/system/pom.xml b/service/system/pom.xml index fb5df7322d0..ba4fc81bf5c 100644 --- a/service/system/pom.xml +++ b/service/system/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-service - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT pom diff --git a/service/system/test-steps/pom.xml b/service/system/test-steps/pom.xml index 0bec73d65cb..cb45ac417c9 100644 --- a/service/system/test-steps/pom.xml +++ b/service/system/test-steps/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-system - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-system-test-steps diff --git a/service/system/test/pom.xml b/service/system/test/pom.xml index 9fac00589f2..0903d256fb3 100644 --- a/service/system/test/pom.xml +++ b/service/system/test/pom.xml @@ -20,7 +20,7 @@ org.eclipse.kapua kapua-system - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-system-test diff --git a/service/tag/api/pom.xml b/service/tag/api/pom.xml index 9154588db01..f14dedd6f86 100644 --- a/service/tag/api/pom.xml +++ b/service/tag/api/pom.xml @@ -17,7 +17,7 @@ org.eclipse.kapua kapua-tag - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-tag-api diff --git a/service/tag/internal/pom.xml b/service/tag/internal/pom.xml index 3c16a9f0504..bc6d6bad211 100644 --- a/service/tag/internal/pom.xml +++ b/service/tag/internal/pom.xml @@ -17,7 +17,7 @@ org.eclipse.kapua kapua-tag - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-tag-internal diff --git a/service/tag/pom.xml b/service/tag/pom.xml index a47591d2763..993db684972 100644 --- a/service/tag/pom.xml +++ b/service/tag/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-service - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT pom diff --git a/service/tag/test-steps/pom.xml b/service/tag/test-steps/pom.xml index 14f40a33555..a4eb7b8018d 100644 --- a/service/tag/test-steps/pom.xml +++ b/service/tag/test-steps/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-tag - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-tag-test-steps diff --git a/service/tag/test/pom.xml b/service/tag/test/pom.xml index f7322e9ca7c..239fbfa5c60 100644 --- a/service/tag/test/pom.xml +++ b/service/tag/test/pom.xml @@ -20,7 +20,7 @@ org.eclipse.kapua kapua-tag - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-tag-test diff --git a/service/user/api/pom.xml b/service/user/api/pom.xml index f1465c6e034..cb22ad8396a 100644 --- a/service/user/api/pom.xml +++ b/service/user/api/pom.xml @@ -19,7 +19,7 @@ org.eclipse.kapua kapua-user - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-user-api diff --git a/service/user/internal/pom.xml b/service/user/internal/pom.xml index f68f05937fb..ceb2718242f 100644 --- a/service/user/internal/pom.xml +++ b/service/user/internal/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-user - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-user-internal diff --git a/service/user/pom.xml b/service/user/pom.xml index 30aa951bdc4..3af9b91ed7e 100644 --- a/service/user/pom.xml +++ b/service/user/pom.xml @@ -19,7 +19,7 @@ org.eclipse.kapua kapua-service - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT pom diff --git a/service/user/test-steps/pom.xml b/service/user/test-steps/pom.xml index 7043a39cf25..d4f79ac9e26 100644 --- a/service/user/test-steps/pom.xml +++ b/service/user/test-steps/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-user - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-user-test-steps diff --git a/service/user/test/pom.xml b/service/user/test/pom.xml index 5a547010dd8..1638ca77b90 100644 --- a/service/user/test/pom.xml +++ b/service/user/test/pom.xml @@ -20,7 +20,7 @@ org.eclipse.kapua kapua-user - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-user-test diff --git a/simulator-kura/pom.xml b/simulator-kura/pom.xml index 1929cf82af1..d197d5717a7 100644 --- a/simulator-kura/pom.xml +++ b/simulator-kura/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-simulator-kura diff --git a/translator/api/pom.xml b/translator/api/pom.xml index e44ce6cf1d9..fd666a82994 100644 --- a/translator/api/pom.xml +++ b/translator/api/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-translator - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-translator-api diff --git a/translator/kapua/kura/pom.xml b/translator/kapua/kura/pom.xml index 1c7ebc9cc94..8359f1f5483 100644 --- a/translator/kapua/kura/pom.xml +++ b/translator/kapua/kura/pom.xml @@ -19,7 +19,7 @@ org.eclipse.kapua kapua-translator-kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-translator-kapua-kura diff --git a/translator/kapua/pom.xml b/translator/kapua/pom.xml index 2d275de630c..9f61e08cbf2 100644 --- a/translator/kapua/pom.xml +++ b/translator/kapua/pom.xml @@ -19,7 +19,7 @@ org.eclipse.kapua kapua-translator - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-translator-kapua diff --git a/translator/kura/jms/pom.xml b/translator/kura/jms/pom.xml index 196f4f7b73b..0cb9917dd77 100644 --- a/translator/kura/jms/pom.xml +++ b/translator/kura/jms/pom.xml @@ -19,7 +19,7 @@ org.eclipse.kapua kapua-translator-kura - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-translator-kura-jms diff --git a/translator/kura/mqtt/pom.xml b/translator/kura/mqtt/pom.xml index f3d5031a6d5..66e64a02b70 100644 --- a/translator/kura/mqtt/pom.xml +++ b/translator/kura/mqtt/pom.xml @@ -19,7 +19,7 @@ org.eclipse.kapua kapua-translator-kura - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-translator-kura-mqtt diff --git a/translator/kura/pom.xml b/translator/kura/pom.xml index d8a2c605eb3..36b7503052e 100644 --- a/translator/kura/pom.xml +++ b/translator/kura/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-translator - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-translator-kura diff --git a/translator/pom.xml b/translator/pom.xml index 765b845c112..82b9c444747 100644 --- a/translator/pom.xml +++ b/translator/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-translator diff --git a/translator/test-steps/pom.xml b/translator/test-steps/pom.xml index c6717dc0306..4f9ce480dcb 100644 --- a/translator/test-steps/pom.xml +++ b/translator/test-steps/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-translator - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-translator-test-steps diff --git a/translator/test/pom.xml b/translator/test/pom.xml index 866085ee6b5..874813fc01a 100644 --- a/translator/test/pom.xml +++ b/translator/test/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua-translator - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-translator-test diff --git a/transport/api/pom.xml b/transport/api/pom.xml index ac5fe343ceb..aa0d99981ed 100644 --- a/transport/api/pom.xml +++ b/transport/api/pom.xml @@ -19,7 +19,7 @@ org.eclipse.kapua kapua-transport - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-transport-api diff --git a/transport/jms/pom.xml b/transport/jms/pom.xml index 3a302442bd4..149ceecbff1 100644 --- a/transport/jms/pom.xml +++ b/transport/jms/pom.xml @@ -19,7 +19,7 @@ org.eclipse.kapua kapua-transport - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-transport-jms diff --git a/transport/mqtt/pom.xml b/transport/mqtt/pom.xml index 3e07ac625a3..56faef2b443 100644 --- a/transport/mqtt/pom.xml +++ b/transport/mqtt/pom.xml @@ -19,7 +19,7 @@ org.eclipse.kapua kapua-transport - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT kapua-transport-mqtt diff --git a/transport/pom.xml b/transport/pom.xml index d6a32e57b47..aa4d0cef67a 100644 --- a/transport/pom.xml +++ b/transport/pom.xml @@ -18,7 +18,7 @@ org.eclipse.kapua kapua - 2.1.0-SNAPSHOT + 2.1.0-FALSE_EXTENSIONS-SNAPSHOT pom From 9c92f15097fcfeaecfecfe0b0cde618009a6c605 Mon Sep 17 00:00:00 2001 From: dseurotech Date: Fri, 17 Jan 2025 14:25:39 +0100 Subject: [PATCH 4/4] :boom: Creators are now concrete classes, without factories Signed-off-by: dseurotech --- .../rest/filters/CORSResponseFilter.java | 2 +- ...puaConfigurableResourceLimitedService.java | 2 +- .../configuration/ServiceConfigCreator.java | 44 +- .../ServiceConfigCreatorImpl.java | 67 --- .../configuration/ServiceConfigImpl.java | 2 +- .../UsedEntitiesCounterImpl.java | 5 +- .../model/AbstractKapuaEntityCreator.java | 59 --- .../AbstractKapuaNamedEntityCreator.java | 66 --- .../model/AbstractKapuaUpdatableEntity.java | 44 +- .../AbstractKapuaUpdatableEntityCreator.java | 62 --- .../event/store/api/EventStoreFactory.java | 2 +- .../store/api/EventStoreRecordCreator.java | 15 +- .../store/api/EventStoreXmlRegistry.java | 9 - .../store/internal/EventStoreFactoryImpl.java | 6 - .../internal/EventStoreRecordCreatorImpl.java | 39 -- ...est.java => ServiceConfigCreatorTest.java} | 12 +- .../model/AbstractKapuaEntityCreatorTest.java | 20 +- ....java => KapuaNamedEntityCreatorTest.java} | 36 +- ...a => KapuaUpdatableEntityCreatorTest.java} | 14 +- .../internal/EventStoreFactoryImplTest.java | 11 - ....java => EventStoreRecordCreatorTest.java} | 13 +- .../commons/util/PropertiesUtilsTest.java | 26 +- .../account/server/GwtAccountServiceImpl.java | 9 +- .../GwtKapuaAuthenticationModelConverter.java | 15 +- .../server/GwtAccessInfoServiceImpl.java | 4 +- .../server/GwtGroupServiceImpl.java | 2 +- .../server/GwtRoleServiceImpl.java | 2 +- .../GwtKapuaAuthorizationModelConverter.java | 8 +- .../device/server/GwtDeviceServiceImpl.java | 2 +- .../server/GwtEndpointServiceImpl.java | 4 +- .../util/GwtKapuaEndpointModelConverter.java | 17 +- .../module/job/server/GwtJobServiceImpl.java | 2 +- .../job/server/GwtJobTargetServiceImpl.java | 2 +- .../job/server/GwtTriggerServiceImpl.java | 2 +- .../util/GwtKapuaJobModelConverter.java | 8 +- .../module/tag/server/GwtTagServiceImpl.java | 2 +- .../user/server/GwtUserServiceImpl.java | 4 +- .../queue/QueuedJobExecutionCreator.java | 74 +++- .../queue/QueuedJobExecutionFactory.java | 2 +- .../queue/QueuedJobExecutionXmlRegistry.java | 10 - .../jbatch/listener/KapuaJobListener.java | 4 +- .../jbatch/QueuedJobExecutionCreatorImpl.java | 84 ---- .../jbatch/QueuedJobExecutionFactoryImpl.java | 6 - ...plTest.java => AccessInfoCreatorTest.java} | 26 +- .../misc/EventStoreServiceImplTest.java | 8 +- .../misc/RolePermissionFactoryTest.java | 13 - .../MessageStoreServiceSslTest.java | 2 +- .../resources/v1/resources/EndpointInfos.java | 102 +++-- .../api/resources/v1/resources/UserMfa.java | 43 +- .../api/resources/v1/resources/UsersMfa.java | 68 +-- .../kapua/service/account/AccountCreator.java | 186 ++++++-- .../kapua/service/account/AccountFactory.java | 17 +- .../account/xml/AccountXmlRegistry.java | 11 - .../account/internal/AccountCreatorImpl.java | 175 -------- .../account/internal/AccountFactoryImpl.java | 13 - .../account/steps/AccountServiceSteps.java | 8 +- .../org/eclipse/kapua}/PropertiesUtils.java | 23 +- .../kapua/model/KapuaEntityCreator.java | 36 +- .../kapua/model/KapuaEntityFactory.java | 14 +- .../kapua/model/KapuaNamedEntityCreator.java | 55 ++- .../model/KapuaUpdatableEntityCreator.java | 43 +- .../authentication/AuthenticationLogic.java | 2 +- .../datastore/steps/DatastoreSteps.java | 4 +- .../AbstractDeviceManagementServiceImpl.java | 91 ++-- ...iceManagementTransactionalServiceImpl.java | 82 ++-- .../JobDeviceManagementOperationCreator.java | 51 ++- .../JobDeviceManagementOperationFactory.java | 2 +- ...bDeviceManagementOperationXmlRegistry.java | 5 - ...bDeviceManagementOperationCreatorImpl.java | 54 --- ...bDeviceManagementOperationFactoryImpl.java | 6 - .../DevicePackageManagementServiceImpl.java | 35 +- .../AbstractDevicePackageTargetProcessor.java | 6 +- .../DeviceManagementOperationCreator.java | 112 +++-- .../DeviceManagementOperationFactory.java | 2 +- .../DeviceManagementOperationXmlRegistry.java | 5 - ...anagementOperationNotificationCreator.java | 105 +++-- ...anagementOperationNotificationFactory.java | 2 +- ...ementOperationNotificationXmlRegistry.java | 5 - ...eManagementRegistryManagerServiceImpl.java | 8 +- .../DeviceManagementOperationCreatorImpl.java | 126 ------ .../DeviceManagementOperationFactoryImpl.java | 6 - ...ementOperationNotificationCreatorImpl.java | 95 ---- ...ementOperationNotificationFactoryImpl.java | 6 - .../device/registry/DeviceCreator.java | 410 +++++++++++++----- .../device/registry/DeviceFactory.java | 17 +- .../device/registry/DeviceXmlRegistry.java | 10 - .../connection/DeviceConnectionCreator.java | 127 ++++-- .../connection/DeviceConnectionFactory.java | 2 +- .../option/DeviceConnectionOptionCreator.java | 48 +- .../option/DeviceConnectionOptionFactory.java | 2 +- .../registry/event/DeviceEventCreator.java | 117 ++++- .../registry/event/DeviceEventFactory.java | 21 +- .../internal/DeviceConnectionCreatorImpl.java | 161 ------- .../internal/DeviceConnectionFactoryImpl.java | 6 - .../DeviceConnectionOptionCreatorImpl.java | 73 ---- .../DeviceConnectionOptionFactoryImpl.java | 6 - .../internal/DeviceEventCreatorImpl.java | 148 ------- .../internal/DeviceEventFactoryImpl.java | 21 - .../registry/internal/DeviceCreatorImpl.java | 385 ---------------- .../registry/internal/DeviceFactoryImpl.java | 13 - .../internal/DeviceLifeCycleServiceImpl.java | 64 ++- .../device/registry/steps/AclCreator.java | 63 +-- .../registry/steps/DeviceRegistrySteps.java | 36 +- .../service/endpoint/EndpointInfoCreator.java | 115 +++-- .../service/endpoint/EndpointInfoFactory.java | 5 +- .../service/endpoint/EndpointInfoQuery.java | 2 +- .../endpoint/EndpointInfoXmlRegistry.java | 18 - .../internal/EndpointInfoCreatorImpl.java | 106 ----- .../internal/EndpointInfoFactoryImpl.java | 12 - .../internal/EndpointInfoServiceImpl.java | 4 +- .../endpoint/steps/EndpointServiceSteps.java | 89 ++-- .../eclipse/kapua/service/job/JobCreator.java | 57 ++- .../eclipse/kapua/service/job/JobFactory.java | 2 +- .../kapua/service/job/JobXmlRegistry.java | 9 - .../job/execution/JobExecutionCreator.java | 59 ++- .../job/execution/JobExecutionFactory.java | 2 +- .../execution/JobExecutionXmlRegistry.java | 10 - .../service/job/step/JobStepCreator.java | 89 ++-- .../service/job/step/JobStepFactory.java | 2 +- .../service/job/step/JobStepXmlRegistry.java | 9 - .../definition/JobStepDefinitionCreator.java | 79 +++- .../definition/JobStepDefinitionFactory.java | 2 +- .../JobStepDefinitionXmlRegistry.java | 9 - .../service/job/targets/JobTargetCreator.java | 48 +- .../service/job/targets/JobTargetFactory.java | 2 +- .../job/targets/JobTargetXmlRegistry.java | 10 - .../internal/JobExecutionCreatorImpl.java | 69 --- .../internal/JobExecutionFactoryImpl.java | 6 - .../service/job/internal/JobCreatorImpl.java | 63 --- .../service/job/internal/JobFactoryImpl.java | 6 - .../JobStepDefinitionCreatorImpl.java | 98 ----- .../JobStepDefinitionFactoryImpl.java | 6 - .../job/step/internal/JobStepCreatorImpl.java | 86 ---- .../job/step/internal/JobStepFactoryImpl.java | 6 - .../internal/JobTargetCreatorImpl.java | 51 --- .../internal/JobTargetFactoryImpl.java | 6 - .../job/steps/JobExecutionServiceSteps.java | 4 +- .../service/job/steps/JobServiceSteps.java | 18 +- .../steps/JobStepDefinitionServiceSteps.java | 6 +- .../job/steps/JobStepServiceSteps.java | 6 +- .../job/steps/JobTargetServiceSteps.java | 10 +- .../scheduler/trigger/TriggerCreator.java | 116 +++-- .../scheduler/trigger/TriggerFactory.java | 2 +- .../scheduler/trigger/TriggerXmlRegistry.java | 4 - .../definition/TriggerDefinitionCreator.java | 72 ++- .../definition/TriggerDefinitionFactory.java | 2 +- .../TriggerDefinitionXmlRegistry.java | 4 - .../trigger/fired/FiredTriggerCreator.java | 76 +++- .../trigger/fired/FiredTriggerFactory.java | 2 +- .../fired/FiredTriggerXmlRegistry.java | 4 - .../quartz/job/KapuaJobLauncher.java | 64 +-- .../quartz/TriggerDefinitionCreatorImpl.java | 87 ---- .../quartz/TriggerDefinitionFactoryImpl.java | 6 - .../fired/quartz/FiredTriggerCreatorImpl.java | 84 ---- .../fired/quartz/FiredTriggerFactoryImpl.java | 6 - .../trigger/quartz/TriggerCreatorImpl.java | 121 ------ .../trigger/quartz/TriggerFactoryImpl.java | 6 - .../steps/JobScheduleServiceSteps.java | 8 +- .../credential/CredentialCreator.java | 123 +++++- .../credential/CredentialFactory.java | 21 +- .../credential/CredentialXmlRegistry.java | 10 - .../credential/mfa/MfaOptionCreator.java | 53 ++- .../credential/mfa/MfaOptionFactory.java | 16 +- .../credential/mfa/MfaOptionXmlRegistry.java | 10 - .../token/AccessTokenCreator.java | 140 ++++-- .../token/AccessTokenFactory.java | 23 +- .../token/AccessTokenXmlRegistry.java | 8 +- .../access/AccessInfoCreator.java | 110 +++-- .../access/AccessInfoFactory.java | 2 +- .../access/AccessInfoXmlRegistry.java | 10 - .../access/AccessPermissionCreator.java | 55 ++- .../access/AccessPermissionFactory.java | 2 +- .../access/AccessPermissionXmlRegistry.java | 9 - .../access/AccessRoleCreator.java | 60 ++- .../access/AccessRoleFactory.java | 2 +- .../access/AccessRoleXmlRegistry.java | 10 - .../authorization/domain/DomainCreator.java | 97 ++++- .../authorization/domain/DomainFactory.java | 12 +- .../authorization/group/GroupCreator.java | 22 +- .../authorization/group/GroupFactory.java | 15 +- .../authorization/group/GroupXmlRegistry.java | 10 - .../authorization/role/RoleCreator.java | 48 +- .../authorization/role/RoleFactory.java | 2 +- .../role/RolePermissionCreator.java | 55 ++- .../role/RolePermissionFactory.java | 2 +- .../role/RolePermissionXmlRegistry.java | 10 - .../authorization/role/RoleXmlRegistry.java | 9 - .../certificate/CertificateCreator.java | 99 ++++- .../certificate/CertificateFactory.java | 2 +- .../info/CertificateInfoCreator.java | 23 +- .../info/CertificateInfoFactory.java | 2 +- .../info/xml/CertificateInfoXmlRegistry.java | 6 - .../xml/CertificateXmlRegistry.java | 5 - .../internal/CertificateInfoFactoryImpl.java | 6 - .../internal/CertificateFactoryImpl.java | 6 - .../simple/SimpleRegistrationProcessor.java | 62 +-- .../SimpleRegistrationProcessorProvider.java | 14 +- .../mfa/shiro/MfaOptionCreatorImpl.java | 54 --- .../mfa/shiro/MfaOptionFactoryImpl.java | 13 - .../shiro/CredentialCreatorImpl.java | 127 ------ .../shiro/CredentialFactoryImpl.java | 12 - .../shiro/AuthenticationServiceShiroImpl.java | 2 +- .../token/shiro/AccessTokenCreatorImpl.java | 119 ----- .../token/shiro/AccessTokenFactoryImpl.java | 22 - .../access/shiro/AccessInfoCreatorImpl.java | 97 ----- .../access/shiro/AccessInfoFactoryImpl.java | 6 - .../access/shiro/AccessInfoServiceImpl.java | 4 +- .../shiro/AccessPermissionCreatorImpl.java | 58 --- .../shiro/AccessPermissionFactoryImpl.java | 6 - .../access/shiro/AccessRoleCreatorImpl.java | 62 --- .../access/shiro/AccessRoleFactoryImpl.java | 6 - .../domain/shiro/DomainCreatorImpl.java | 89 ---- .../domain/shiro/DomainFactoryImpl.java | 12 - .../group/shiro/GroupCreatorImpl.java | 45 -- .../group/shiro/GroupFactoryImpl.java | 15 - .../role/shiro/RoleCreatorImpl.java | 58 --- .../role/shiro/RoleFactoryImpl.java | 6 - .../role/shiro/RolePermissionCreatorImpl.java | 58 --- .../role/shiro/RolePermissionFactoryImpl.java | 6 - .../role/shiro/RoleServiceImpl.java | 2 +- ...mplTest.java => MfaOptionCreatorTest.java} | 22 +- .../mfa/shiro/MfaOptionFactoryImplTest.java | 13 +- ...plTest.java => CredentialCreatorTest.java} | 17 +- .../shiro/CredentialFactoryImplTest.java | 4 +- .../shiro/AccessTokenCreatorImplTest.java | 58 ++- .../shiro/AccessTokenFactoryImplTest.java | 36 -- .../shiro/AccessInfoFactoryImplTest.java | 15 - ....java => AccessPermissionCreatorTest.java} | 12 +- .../AccessPermissionFactoryImplTest.java | 8 - ...plTest.java => AccessRoleCreatorTest.java} | 9 +- .../shiro/AccessRoleFactoryImplTest.java | 4 +- ...orImplTest.java => DomainCreatorTest.java} | 29 +- .../domain/shiro/DomainFactoryImplTest.java | 31 -- ...torImplTest.java => GroupCreatorTest.java} | 19 +- .../group/shiro/GroupFactoryImplTest.java | 10 +- ...atorImplTest.java => RoleCreatorTest.java} | 15 +- .../role/shiro/RoleFactoryImplTest.java | 13 - ...st.java => RolePermissionCreatorTest.java} | 32 +- .../steps/AuthenticationServiceSteps.java | 29 +- .../steps/AuthorizationServiceSteps.java | 74 ++-- .../stream/internal/StreamServiceImpl.java | 60 +-- .../eclipse/kapua/service/tag/TagCreator.java | 22 +- .../eclipse/kapua/service/tag/TagFactory.java | 14 +- .../kapua/service/tag/TagXmlRegistry.java | 12 - .../service/tag/internal/TagCreatorImpl.java | 51 --- .../service/tag/internal/TagFactoryImpl.java | 15 - .../tag/internal/TagServiceImplTest.java | 14 +- .../service/tag/steps/TagServiceSteps.java | 4 +- .../kapua/service/user/UserCreator.java | 111 ++++- .../kapua/service/user/UserFactory.java | 15 +- .../kapua/service/user/UserXmlRegistry.java | 9 - .../user/internal/UserCreatorImpl.java | 138 ------ .../user/internal/UserFactoryImpl.java | 15 - .../user/steps/UserRoleServiceSteps.java | 51 +-- .../service/user/steps/UserServiceSteps.java | 16 +- 255 files changed, 3361 insertions(+), 5733 deletions(-) delete mode 100644 commons/src/main/java/org/eclipse/kapua/commons/configuration/ServiceConfigCreatorImpl.java delete mode 100644 commons/src/main/java/org/eclipse/kapua/commons/model/AbstractKapuaEntityCreator.java delete mode 100644 commons/src/main/java/org/eclipse/kapua/commons/model/AbstractKapuaNamedEntityCreator.java delete mode 100644 commons/src/main/java/org/eclipse/kapua/commons/model/AbstractKapuaUpdatableEntityCreator.java delete mode 100644 commons/src/main/java/org/eclipse/kapua/commons/service/event/store/internal/EventStoreRecordCreatorImpl.java rename commons/src/test/java/org/eclipse/kapua/commons/configuration/{ServiceConfigurationCreatorImplTest.java => ServiceConfigCreatorTest.java} (92%) rename commons/src/test/java/org/eclipse/kapua/commons/model/{AbstractKapuaNamedEntityCreatorTest.java => KapuaNamedEntityCreatorTest.java} (72%) rename commons/src/test/java/org/eclipse/kapua/commons/model/{AbstractKapuaUpdatableEntityCreatorTest.java => KapuaUpdatableEntityCreatorTest.java} (79%) rename commons/src/test/java/org/eclipse/kapua/commons/service/event/store/internal/{EventStoreRecordCreatorImplTest.java => EventStoreRecordCreatorTest.java} (79%) delete mode 100644 job-engine/jbatch/src/main/java/org/eclipse/kapua/job/engine/queue/jbatch/QueuedJobExecutionCreatorImpl.java rename qa/integration/src/test/java/org/eclipse/kapua/integration/misc/{AccessInfoCreatorImplTest.java => AccessInfoCreatorTest.java} (87%) delete mode 100644 service/account/internal/src/main/java/org/eclipse/kapua/service/account/internal/AccountCreatorImpl.java rename {commons/src/main/java/org/eclipse/kapua/commons/util => service/api/src/main/java/org/eclipse/kapua}/PropertiesUtils.java (76%) delete mode 100644 service/device/management/job/internal/src/main/java/org/eclipse/kapua/service/device/management/job/internal/JobDeviceManagementOperationCreatorImpl.java delete mode 100644 service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/internal/DeviceManagementOperationCreatorImpl.java delete mode 100644 service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/internal/ManagementOperationNotificationCreatorImpl.java delete mode 100644 service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/internal/DeviceConnectionCreatorImpl.java delete mode 100644 service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/internal/DeviceConnectionOptionCreatorImpl.java delete mode 100644 service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/event/internal/DeviceEventCreatorImpl.java delete mode 100644 service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/internal/DeviceCreatorImpl.java delete mode 100644 service/endpoint/internal/src/main/java/org/eclipse/kapua/service/endpoint/internal/EndpointInfoCreatorImpl.java delete mode 100644 service/job/internal/src/main/java/org/eclipse/kapua/service/job/execution/internal/JobExecutionCreatorImpl.java delete mode 100644 service/job/internal/src/main/java/org/eclipse/kapua/service/job/internal/JobCreatorImpl.java delete mode 100644 service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/definition/internal/JobStepDefinitionCreatorImpl.java delete mode 100644 service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/internal/JobStepCreatorImpl.java delete mode 100644 service/job/internal/src/main/java/org/eclipse/kapua/service/job/targets/internal/JobTargetCreatorImpl.java delete mode 100644 service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/definition/quartz/TriggerDefinitionCreatorImpl.java delete mode 100644 service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/fired/quartz/FiredTriggerCreatorImpl.java delete mode 100644 service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/quartz/TriggerCreatorImpl.java delete mode 100644 service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionCreatorImpl.java delete mode 100644 service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialCreatorImpl.java delete mode 100644 service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/token/shiro/AccessTokenCreatorImpl.java delete mode 100644 service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoCreatorImpl.java delete mode 100644 service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionCreatorImpl.java delete mode 100644 service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessRoleCreatorImpl.java delete mode 100644 service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/domain/shiro/DomainCreatorImpl.java delete mode 100644 service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/group/shiro/GroupCreatorImpl.java delete mode 100644 service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RoleCreatorImpl.java delete mode 100644 service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RolePermissionCreatorImpl.java rename service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/{MfaOptionCreatorImplTest.java => MfaOptionCreatorTest.java} (76%) rename service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/shiro/{CredentialCreatorImplTest.java => CredentialCreatorTest.java} (91%) rename service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/{AccessPermissionCreatorImplTest.java => AccessPermissionCreatorTest.java} (81%) rename service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/{AccessRoleCreatorImplTest.java => AccessRoleCreatorTest.java} (88%) rename service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/domain/shiro/{DomainCreatorImplTest.java => DomainCreatorTest.java} (74%) rename service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/group/shiro/{GroupCreatorImplTest.java => GroupCreatorTest.java} (77%) rename service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/role/shiro/{RoleCreatorImplTest.java => RoleCreatorTest.java} (91%) rename service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/role/shiro/{RolePermissionCreatorImplTest.java => RolePermissionCreatorTest.java} (61%) delete mode 100644 service/tag/internal/src/main/java/org/eclipse/kapua/service/tag/internal/TagCreatorImpl.java delete mode 100644 service/user/internal/src/main/java/org/eclipse/kapua/service/user/internal/UserCreatorImpl.java diff --git a/commons-rest/filters/src/main/java/org/eclipse/kapua/commons/rest/filters/CORSResponseFilter.java b/commons-rest/filters/src/main/java/org/eclipse/kapua/commons/rest/filters/CORSResponseFilter.java index b12fc9687e4..903c784dac4 100644 --- a/commons-rest/filters/src/main/java/org/eclipse/kapua/commons/rest/filters/CORSResponseFilter.java +++ b/commons-rest/filters/src/main/java/org/eclipse/kapua/commons/rest/filters/CORSResponseFilter.java @@ -198,7 +198,7 @@ private synchronized void refreshOrigins() { final KapuaQuery accounts = new KapuaQuery((KapuaId) null); AccountListResult accountListResult = KapuaSecurityUtils.doPrivileged(() -> accountService.query(accounts)); accountListResult.getItems().forEach(account -> { - EndpointInfoQuery endpointInfoQuery = endpointInfoFactory.newQuery(account.getId()); + EndpointInfoQuery endpointInfoQuery = new EndpointInfoQuery(account.getId()); try { EndpointInfoListResult endpointInfoListResult = KapuaSecurityUtils.doPrivileged(() -> endpointInfoService.query(endpointInfoQuery, EndpointInfo.ENDPOINT_TYPE_CORS)); endpointInfoListResult.getItems().forEach(endpointInfo -> newAllowedOrigins.put(endpointInfo.toStringURI(), account.getId())); diff --git a/commons/src/main/java/org/eclipse/kapua/commons/configuration/AbstractKapuaConfigurableResourceLimitedService.java b/commons/src/main/java/org/eclipse/kapua/commons/configuration/AbstractKapuaConfigurableResourceLimitedService.java index be11fe15047..62ffb804517 100644 --- a/commons/src/main/java/org/eclipse/kapua/commons/configuration/AbstractKapuaConfigurableResourceLimitedService.java +++ b/commons/src/main/java/org/eclipse/kapua/commons/configuration/AbstractKapuaConfigurableResourceLimitedService.java @@ -64,7 +64,7 @@ public abstract class AbstractKapuaConfigurableResourceLimitedService< E extends KapuaEntity, C extends KapuaEntityCreator, S extends KapuaEntityService, - F extends KapuaEntityFactory + F extends KapuaEntityFactory > extends AbstractKapuaConfigurableService implements KapuaEntityService { diff --git a/commons/src/main/java/org/eclipse/kapua/commons/configuration/ServiceConfigCreator.java b/commons/src/main/java/org/eclipse/kapua/commons/configuration/ServiceConfigCreator.java index 3518333becb..79e79290bfc 100644 --- a/commons/src/main/java/org/eclipse/kapua/commons/configuration/ServiceConfigCreator.java +++ b/commons/src/main/java/org/eclipse/kapua/commons/configuration/ServiceConfigCreator.java @@ -14,43 +14,71 @@ import java.util.Properties; -import org.eclipse.kapua.KapuaException; +import javax.xml.bind.annotation.XmlElement; + +import org.eclipse.kapua.model.KapuaEntityCreator; import org.eclipse.kapua.model.KapuaUpdatableEntityCreator; +import org.eclipse.kapua.model.id.KapuaId; /** * Service configuration creator definition. * * @since 1.0 */ -public interface ServiceConfigCreator extends KapuaUpdatableEntityCreator { +public class ServiceConfigCreator extends KapuaUpdatableEntityCreator { + + private static final long serialVersionUID = 7508550960304732465L; + + @XmlElement(name = "pid") + private String pid; + + @XmlElement(name = "configurations") + private Properties configurations; + + public ServiceConfigCreator() { + } + + public ServiceConfigCreator(KapuaId scopeId) { + super(scopeId); + } + + public ServiceConfigCreator(KapuaEntityCreator entityCreator) { + super(entityCreator); + } /** * Return service pid * * @return */ - public String getPid(); + public String getPid() { + return pid; + } /** * Set service pid * * @param pid */ - public void setPid(String pid); + public void setPid(String pid) { + this.pid = pid; + } /** * Return service configurations * * @return - * @throws KapuaException */ - public Properties getConfigurations() throws KapuaException; + public Properties getConfigurations() { + return this.configurations; + } /** * Set service configurations * * @param configurations - * @throws KapuaException */ - public void setConfigurations(Properties configurations) throws KapuaException; + public void setConfigurations(Properties configurations) { + this.configurations = configurations; + } } diff --git a/commons/src/main/java/org/eclipse/kapua/commons/configuration/ServiceConfigCreatorImpl.java b/commons/src/main/java/org/eclipse/kapua/commons/configuration/ServiceConfigCreatorImpl.java deleted file mode 100644 index 8713525270a..00000000000 --- a/commons/src/main/java/org/eclipse/kapua/commons/configuration/ServiceConfigCreatorImpl.java +++ /dev/null @@ -1,67 +0,0 @@ -/******************************************************************************* - * 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.Properties; - -import javax.xml.bind.annotation.XmlElement; - -import org.eclipse.kapua.commons.model.AbstractKapuaUpdatableEntityCreator; -import org.eclipse.kapua.model.id.KapuaId; - -/** - * Service configuration creator reference implementation. - * - * @since 1.0 - * - */ -public class ServiceConfigCreatorImpl extends AbstractKapuaUpdatableEntityCreator - implements ServiceConfigCreator { - - private static final long serialVersionUID = 7508550960304732465L; - - @XmlElement(name = "pid") - private String pid; - - @XmlElement(name = "configurations") - private Properties configurations; - - /** - * Constructor - * - * @param scopeId - */ - protected ServiceConfigCreatorImpl(KapuaId scopeId) { - super(scopeId); - } - - @Override - public String getPid() { - return pid; - } - - @Override - public void setPid(String pid) { - this.pid = pid; - } - - @Override - public Properties getConfigurations() { - return this.configurations; - } - - @Override - public void setConfigurations(Properties configurations) { - this.configurations = configurations; - } -} diff --git a/commons/src/main/java/org/eclipse/kapua/commons/configuration/ServiceConfigImpl.java b/commons/src/main/java/org/eclipse/kapua/commons/configuration/ServiceConfigImpl.java index 7ad7c0b71c7..42ace129aa8 100644 --- a/commons/src/main/java/org/eclipse/kapua/commons/configuration/ServiceConfigImpl.java +++ b/commons/src/main/java/org/eclipse/kapua/commons/configuration/ServiceConfigImpl.java @@ -27,8 +27,8 @@ import javax.xml.bind.annotation.XmlType; import org.eclipse.kapua.KapuaException; +import org.eclipse.kapua.PropertiesUtils; import org.eclipse.kapua.commons.model.AbstractKapuaUpdatableEntity; -import org.eclipse.kapua.commons.util.PropertiesUtils; import org.eclipse.kapua.model.id.KapuaId; @XmlRootElement diff --git a/commons/src/main/java/org/eclipse/kapua/commons/configuration/UsedEntitiesCounterImpl.java b/commons/src/main/java/org/eclipse/kapua/commons/configuration/UsedEntitiesCounterImpl.java index 53cb5e92b16..2f964e6cc6f 100644 --- a/commons/src/main/java/org/eclipse/kapua/commons/configuration/UsedEntitiesCounterImpl.java +++ b/commons/src/main/java/org/eclipse/kapua/commons/configuration/UsedEntitiesCounterImpl.java @@ -15,7 +15,6 @@ import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.model.KapuaEntity; -import org.eclipse.kapua.model.KapuaEntityCreator; import org.eclipse.kapua.model.KapuaEntityFactory; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.model.query.KapuaListResult; @@ -25,10 +24,8 @@ public class UsedEntitiesCounterImpl< E extends KapuaEntity, - C extends KapuaEntityCreator, L extends KapuaListResult, - Q extends KapuaQuery, - F extends KapuaEntityFactory + F extends KapuaEntityFactory > implements UsedEntitiesCounter { private final F factory; diff --git a/commons/src/main/java/org/eclipse/kapua/commons/model/AbstractKapuaEntityCreator.java b/commons/src/main/java/org/eclipse/kapua/commons/model/AbstractKapuaEntityCreator.java deleted file mode 100644 index 9ce733b593c..00000000000 --- a/commons/src/main/java/org/eclipse/kapua/commons/model/AbstractKapuaEntityCreator.java +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************* - * 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.model; - -import java.io.Serializable; - -import org.eclipse.kapua.model.KapuaEntity; -import org.eclipse.kapua.model.KapuaEntityCreator; -import org.eclipse.kapua.model.id.KapuaId; - -/** - * Kapua entity base creator service (reference abstract implementation). - * - * @param - * entity type - * - * @since 1.0 - * - */ -@SuppressWarnings("serial") -public abstract class AbstractKapuaEntityCreator implements KapuaEntityCreator, Serializable { - - protected KapuaId scopeId; - - /** - * Constructor - * - * @param scopeId - */ - protected AbstractKapuaEntityCreator(KapuaId scopeId) { - super(); - setScopeId(scopeId); - } - - protected AbstractKapuaEntityCreator(AbstractKapuaEntityCreator abstractEntityCreator) { - this(abstractEntityCreator.getScopeId()); - } - - @Override - public KapuaId getScopeId() { - return scopeId; - } - - @Override - public void setScopeId(KapuaId scopeId) { - - this.scopeId = scopeId; - } -} diff --git a/commons/src/main/java/org/eclipse/kapua/commons/model/AbstractKapuaNamedEntityCreator.java b/commons/src/main/java/org/eclipse/kapua/commons/model/AbstractKapuaNamedEntityCreator.java deleted file mode 100644 index 3fe4a69e00c..00000000000 --- a/commons/src/main/java/org/eclipse/kapua/commons/model/AbstractKapuaNamedEntityCreator.java +++ /dev/null @@ -1,66 +0,0 @@ -/******************************************************************************* - * 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.model; - -import org.eclipse.kapua.model.KapuaEntity; -import org.eclipse.kapua.model.KapuaNamedEntityCreator; -import org.eclipse.kapua.model.id.KapuaId; - -/** - * {@link KapuaNamedEntityCreator} {@code abstract} implementation. - * - * @param {@link KapuaEntity} which this {@link AbstractKapuaUpdatableEntityCreator} is for - * @since 1.0.0 - */ -public abstract class AbstractKapuaNamedEntityCreator extends AbstractKapuaUpdatableEntityCreator implements KapuaNamedEntityCreator { - - protected String name; - protected String description; - - /** - * Constructor - * - * @param scopeId the scope {@link KapuaId} - * @param name the name - * @since 1.0.0 - */ - protected AbstractKapuaNamedEntityCreator(KapuaId scopeId, String name) { - super(scopeId); - - setName(name); - } - - public AbstractKapuaNamedEntityCreator(KapuaId scopeId) { - super(scopeId); - } - - @Override - public String getName() { - return name; - } - - @Override - public void setName(String name) { - this.name = name; - } - - @Override - public String getDescription() { - return description; - } - - @Override - public void setDescription(String description) { - this.description = description; - } -} diff --git a/commons/src/main/java/org/eclipse/kapua/commons/model/AbstractKapuaUpdatableEntity.java b/commons/src/main/java/org/eclipse/kapua/commons/model/AbstractKapuaUpdatableEntity.java index b24fc034de4..a00f3236bf4 100644 --- a/commons/src/main/java/org/eclipse/kapua/commons/model/AbstractKapuaUpdatableEntity.java +++ b/commons/src/main/java/org/eclipse/kapua/commons/model/AbstractKapuaUpdatableEntity.java @@ -12,14 +12,9 @@ *******************************************************************************/ package org.eclipse.kapua.commons.model; -import org.eclipse.kapua.commons.model.id.KapuaEid; -import org.eclipse.kapua.commons.security.KapuaSecurityUtils; -import org.eclipse.kapua.commons.util.PropertiesUtils; -import org.eclipse.kapua.entity.EntityPropertiesReadException; -import org.eclipse.kapua.entity.EntityPropertiesWriteException; -import org.eclipse.kapua.model.KapuaEntity; -import org.eclipse.kapua.model.KapuaUpdatableEntity; -import org.eclipse.kapua.model.id.KapuaId; +import java.io.IOException; +import java.util.Date; +import java.util.Properties; import javax.persistence.Access; import javax.persistence.AccessType; @@ -33,9 +28,15 @@ import javax.persistence.Temporal; import javax.persistence.TemporalType; import javax.persistence.Version; -import java.io.IOException; -import java.util.Date; -import java.util.Properties; + +import org.eclipse.kapua.PropertiesUtils; +import org.eclipse.kapua.commons.model.id.KapuaEid; +import org.eclipse.kapua.commons.security.KapuaSecurityUtils; +import org.eclipse.kapua.entity.EntityPropertiesReadException; +import org.eclipse.kapua.entity.EntityPropertiesWriteException; +import org.eclipse.kapua.model.KapuaEntity; +import org.eclipse.kapua.model.KapuaUpdatableEntity; +import org.eclipse.kapua.model.id.KapuaId; /** * {@link KapuaUpdatableEntity} {@code abstract} implementation. @@ -69,8 +70,7 @@ public abstract class AbstractKapuaUpdatableEntity extends AbstractKapuaEntity i protected String properties; /** - * Protected default constructor.
    - * Required by JPA. + * Protected default constructor.
    Required by JPA. * * @since 1.0.0 */ @@ -81,7 +81,8 @@ protected AbstractKapuaUpdatableEntity() { /** * Constructor. * - * @param scopeId The scope {@link KapuaId} to set for this {@link KapuaUpdatableEntity} + * @param scopeId + * The scope {@link KapuaId} to set for this {@link KapuaUpdatableEntity} * @since 1.0.0 */ public AbstractKapuaUpdatableEntity(KapuaId scopeId) { @@ -93,8 +94,10 @@ public AbstractKapuaUpdatableEntity(KapuaId scopeId) { *

    * It can be used to clone the {@link KapuaUpdatableEntity} * - * @throws EntityPropertiesReadException see {@link #getEntityProperties()} and {@link #getEntityAttributes()} - * @throws EntityPropertiesWriteException see {@link #setEntityProperties(Properties)} and {@link #setEntityAttributes(Properties)} + * @throws EntityPropertiesReadException + * see {@link #getEntityProperties()} and {@link #getEntityAttributes()} + * @throws EntityPropertiesWriteException + * see {@link #setEntityProperties(Properties)} and {@link #setEntityAttributes(Properties)} * @since 1.0.0 */ protected AbstractKapuaUpdatableEntity(KapuaUpdatableEntity entity) { @@ -115,7 +118,8 @@ public Date getModifiedOn() { /** * Sets the date of the last update * - * @param modifiedOn The date of the last update + * @param modifiedOn + * The date of the last update * @since 1.0.0 */ public void setModifiedOn(Date modifiedOn) { @@ -130,7 +134,8 @@ public KapuaId getModifiedBy() { /** * Sets the identity {@link KapuaId} who has updated this {@link KapuaEntity} * - * @param modifiedBy The identity {@link KapuaId} who has updated this {@link KapuaEntity} + * @param modifiedBy + * The identity {@link KapuaId} who has updated this {@link KapuaEntity} * @since 1.0.0 */ public void setModifiedBy(KapuaId modifiedBy) { @@ -192,8 +197,7 @@ public void setEntityProperties(Properties properties) { } /** - * Before create action invokes {@link AbstractKapuaEntity#prePersistsAction()} and - * sets {@link KapuaUpdatableEntity} {@link #modifiedBy} and {@link #modifiedOn}. + * Before create action invokes {@link AbstractKapuaEntity#prePersistsAction()} and sets {@link KapuaUpdatableEntity} {@link #modifiedBy} and {@link #modifiedOn}. * * @since 1.0.0 */ diff --git a/commons/src/main/java/org/eclipse/kapua/commons/model/AbstractKapuaUpdatableEntityCreator.java b/commons/src/main/java/org/eclipse/kapua/commons/model/AbstractKapuaUpdatableEntityCreator.java deleted file mode 100644 index a0f596d3032..00000000000 --- a/commons/src/main/java/org/eclipse/kapua/commons/model/AbstractKapuaUpdatableEntityCreator.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017, 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.model; - -import org.eclipse.kapua.commons.util.PropertiesUtils; -import org.eclipse.kapua.entity.EntityPropertiesReadException; -import org.eclipse.kapua.entity.EntityPropertiesWriteException; -import org.eclipse.kapua.model.KapuaEntity; -import org.eclipse.kapua.model.KapuaUpdatableEntityCreator; -import org.eclipse.kapua.model.id.KapuaId; - -import java.io.IOException; -import java.util.Properties; - -/** - * {@link KapuaUpdatableEntityCreator} {@code abstract} implementation. - * - * @param the {@link KapuaEntity} for which this {@link AbstractKapuaEntityCreator} is for. - * @since 1.0.0 - */ -public abstract class AbstractKapuaUpdatableEntityCreator extends AbstractKapuaEntityCreator implements KapuaUpdatableEntityCreator { - - protected String attributes; - - /** - * Constructor. - * - * @param scopeId The scope {@link KapuaId} to set to in the {@link KapuaUpdatableEntityCreator} - * @since 1.0.0 - */ - public AbstractKapuaUpdatableEntityCreator(KapuaId scopeId) { - super(scopeId); - } - - @Override - public Properties getEntityAttributes() { - try { - return PropertiesUtils.readPropertiesFromString(attributes); - } catch (IOException e) { - throw new EntityPropertiesReadException(e, "attributes", attributes); - } - } - - @Override - public void setEntityAttributes(Properties attributes) { - try { - this.attributes = PropertiesUtils.writePropertiesToString(attributes); - } catch (IOException e) { - throw new EntityPropertiesWriteException(e, "attributes", attributes); - } - } -} diff --git a/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/api/EventStoreFactory.java b/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/api/EventStoreFactory.java index b08e336761e..80843bbbd1b 100644 --- a/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/api/EventStoreFactory.java +++ b/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/api/EventStoreFactory.java @@ -20,6 +20,6 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface EventStoreFactory extends KapuaEntityFactory { +public interface EventStoreFactory extends KapuaEntityFactory { } diff --git a/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/api/EventStoreRecordCreator.java b/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/api/EventStoreRecordCreator.java index 196599158c4..04283a24080 100644 --- a/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/api/EventStoreRecordCreator.java +++ b/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/api/EventStoreRecordCreator.java @@ -13,7 +13,20 @@ package org.eclipse.kapua.commons.service.event.store.api; import org.eclipse.kapua.model.KapuaEntityCreator; +import org.eclipse.kapua.model.id.KapuaId; -public interface EventStoreRecordCreator extends KapuaEntityCreator { +public class EventStoreRecordCreator extends KapuaEntityCreator { + private static final long serialVersionUID = 1048699703033893534L; + + public EventStoreRecordCreator() { + } + + public EventStoreRecordCreator(KapuaId scopeId) { + super(scopeId); + } + + public EventStoreRecordCreator(KapuaEntityCreator entityCreator) { + super(entityCreator); + } } diff --git a/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/api/EventStoreXmlRegistry.java b/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/api/EventStoreXmlRegistry.java index 8969833f06e..4a53749ef2a 100644 --- a/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/api/EventStoreXmlRegistry.java +++ b/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/api/EventStoreXmlRegistry.java @@ -29,13 +29,4 @@ public class EventStoreXmlRegistry { public EventStoreRecord newEventStoreRecord() { return kapuaEventFactory.newEntity(null); } - - /** - * Creates a new kapuaEvent creator instance - * - * @return - */ - public EventStoreRecordCreator newEventStoreRecordCreator() { - return kapuaEventFactory.newCreator(null); - } } diff --git a/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/internal/EventStoreFactoryImpl.java b/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/internal/EventStoreFactoryImpl.java index 2c735c60922..53543b4f33d 100644 --- a/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/internal/EventStoreFactoryImpl.java +++ b/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/internal/EventStoreFactoryImpl.java @@ -17,7 +17,6 @@ import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.commons.service.event.store.api.EventStoreFactory; import org.eclipse.kapua.commons.service.event.store.api.EventStoreRecord; -import org.eclipse.kapua.commons.service.event.store.api.EventStoreRecordCreator; import org.eclipse.kapua.model.id.KapuaId; /** @@ -33,11 +32,6 @@ public EventStoreRecord newEntity(KapuaId scopeId) { return new EventStoreRecordImpl(scopeId); } - @Override - public EventStoreRecordCreator newCreator(KapuaId scopeId) { - return new EventStoreRecordCreatorImpl(scopeId); - } - @Override public EventStoreRecord clone(EventStoreRecord eventStoreRecord) { try { diff --git a/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/internal/EventStoreRecordCreatorImpl.java b/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/internal/EventStoreRecordCreatorImpl.java deleted file mode 100644 index 63057c711d6..00000000000 --- a/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/internal/EventStoreRecordCreatorImpl.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * 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.service.event.store.internal; - -import org.eclipse.kapua.commons.model.AbstractKapuaEntityCreator; -import org.eclipse.kapua.commons.service.event.store.api.EventStoreRecord; -import org.eclipse.kapua.commons.service.event.store.api.EventStoreRecordCreator; -import org.eclipse.kapua.model.id.KapuaId; - -/** - * KapuaEvent creator service implementation. - * - * @since 1.0 - * - */ -public class EventStoreRecordCreatorImpl extends AbstractKapuaEntityCreator implements EventStoreRecordCreator { - - private static final long serialVersionUID = 1048699703033893534L; - - /** - * Constructor - * - * @param scopeId - */ - public EventStoreRecordCreatorImpl(KapuaId scopeId) { - super(scopeId); - } - -} diff --git a/commons/src/test/java/org/eclipse/kapua/commons/configuration/ServiceConfigurationCreatorImplTest.java b/commons/src/test/java/org/eclipse/kapua/commons/configuration/ServiceConfigCreatorTest.java similarity index 92% rename from commons/src/test/java/org/eclipse/kapua/commons/configuration/ServiceConfigurationCreatorImplTest.java rename to commons/src/test/java/org/eclipse/kapua/commons/configuration/ServiceConfigCreatorTest.java index 1ccb058a742..1a5b911beae 100644 --- a/commons/src/test/java/org/eclipse/kapua/commons/configuration/ServiceConfigurationCreatorImplTest.java +++ b/commons/src/test/java/org/eclipse/kapua/commons/configuration/ServiceConfigCreatorTest.java @@ -12,6 +12,8 @@ *******************************************************************************/ package org.eclipse.kapua.commons.configuration; +import java.util.Properties; + import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.qa.markers.junit.JUnitTests; import org.junit.Assert; @@ -19,17 +21,15 @@ import org.junit.Test; import org.junit.experimental.categories.Category; -import java.util.Properties; - - @Category(JUnitTests.class) -public class ServiceConfigurationCreatorImplTest { - ServiceConfigCreatorImpl configCreator; +public class ServiceConfigCreatorTest { + + ServiceConfigCreator configCreator; @Before public void createInstanceOfClass() { KapuaId id = KapuaId.ONE; - configCreator = new ServiceConfigCreatorImpl(id); + configCreator = new ServiceConfigCreator(id); } @Test diff --git a/commons/src/test/java/org/eclipse/kapua/commons/model/AbstractKapuaEntityCreatorTest.java b/commons/src/test/java/org/eclipse/kapua/commons/model/AbstractKapuaEntityCreatorTest.java index d224355c2fb..8303f1dd510 100644 --- a/commons/src/test/java/org/eclipse/kapua/commons/model/AbstractKapuaEntityCreatorTest.java +++ b/commons/src/test/java/org/eclipse/kapua/commons/model/AbstractKapuaEntityCreatorTest.java @@ -12,9 +12,14 @@ *******************************************************************************/ package org.eclipse.kapua.commons.model; +import java.math.BigInteger; +import java.util.Arrays; +import java.util.Random; + import org.eclipse.kapua.commons.model.id.KapuaEid; import org.eclipse.kapua.commons.util.RandomUtils; import org.eclipse.kapua.model.KapuaEntity; +import org.eclipse.kapua.model.KapuaEntityCreator; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.qa.markers.junit.JUnitTests; import org.junit.Assert; @@ -24,11 +29,6 @@ import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; -import java.math.BigInteger; -import java.util.Arrays; -import java.util.Random; - - @Category(JUnitTests.class) @RunWith(value = Parameterized.class) public class AbstractKapuaEntityCreatorTest { @@ -39,20 +39,20 @@ public class AbstractKapuaEntityCreatorTest { @Parameters public static Iterable eids() { - return Arrays.asList(new Object[]{new BigInteger(64, RANDOM)}, new Object[]{null}); + return Arrays.asList(new Object[] { new BigInteger(64, RANDOM) }, new Object[] { null }); } public AbstractKapuaEntityCreatorTest(BigInteger eid) { this.eid = eid; } - private class ActualKapuaEntityCreator extends AbstractKapuaEntityCreator { + private class ActualKapuaEntityCreator extends KapuaEntityCreator { public ActualKapuaEntityCreator(KapuaId scopeId) { super(scopeId); } - public ActualKapuaEntityCreator(AbstractKapuaEntityCreator abstractEntityCreator) { + public ActualKapuaEntityCreator(KapuaEntityCreator abstractEntityCreator) { super(abstractEntityCreator); } } @@ -60,8 +60,8 @@ public ActualKapuaEntityCreator(AbstractKapuaEntityCreator abstractEntityCrea @Test public void constructorScopeIdTest() { KapuaId scopeId = new KapuaEid(eid); - AbstractKapuaEntityCreator kapuaEntityCreator = new ActualKapuaEntityCreator(scopeId); - AbstractKapuaEntityCreator kapuaCopyEntityCreator = new ActualKapuaEntityCreator(kapuaEntityCreator); + KapuaEntityCreator kapuaEntityCreator = new ActualKapuaEntityCreator(scopeId); + KapuaEntityCreator kapuaCopyEntityCreator = new ActualKapuaEntityCreator(kapuaEntityCreator); Assert.assertEquals("Those entities should have the same scopeId.", kapuaEntityCreator.getScopeId(), kapuaCopyEntityCreator.getScopeId()); } } diff --git a/commons/src/test/java/org/eclipse/kapua/commons/model/AbstractKapuaNamedEntityCreatorTest.java b/commons/src/test/java/org/eclipse/kapua/commons/model/KapuaNamedEntityCreatorTest.java similarity index 72% rename from commons/src/test/java/org/eclipse/kapua/commons/model/AbstractKapuaNamedEntityCreatorTest.java rename to commons/src/test/java/org/eclipse/kapua/commons/model/KapuaNamedEntityCreatorTest.java index e287297625d..2c173bcf4fd 100644 --- a/commons/src/test/java/org/eclipse/kapua/commons/model/AbstractKapuaNamedEntityCreatorTest.java +++ b/commons/src/test/java/org/eclipse/kapua/commons/model/KapuaNamedEntityCreatorTest.java @@ -12,8 +12,12 @@ *******************************************************************************/ package org.eclipse.kapua.commons.model; +import java.util.Arrays; +import java.util.Collection; + import org.eclipse.kapua.commons.model.id.KapuaEid; import org.eclipse.kapua.model.KapuaEntity; +import org.eclipse.kapua.model.KapuaNamedEntityCreator; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.qa.markers.junit.JUnitTests; import org.junit.Assert; @@ -23,13 +27,9 @@ import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; -import java.util.Arrays; -import java.util.Collection; - - @Category(JUnitTests.class) @RunWith(value = Parameterized.class) -public class AbstractKapuaNamedEntityCreatorTest { +public class KapuaNamedEntityCreatorTest { private final String name; @@ -37,30 +37,26 @@ public class AbstractKapuaNamedEntityCreatorTest { KapuaId scopeId = new KapuaEid(); - AbstractKapuaNamedEntityCreator namedEntityCreator = new ActualKapuaNamedEntityCreator(scopeId); + KapuaNamedEntityCreator namedEntityCreator = new ActualKapuaNamedEntityCreator(scopeId, null); - public AbstractKapuaNamedEntityCreatorTest(String name, String description) { + public KapuaNamedEntityCreatorTest(String name, String description) { this.name = name; this.description = description; } @Parameters public static Collection strings() { - return Arrays.asList(new Object[][]{ - {"", ""}, - {"name", "description"}, - {"NAME", "DESCRIPTION"}, - {"&name%", "#description!"}, - {"1234", "5678"}, - {"make space", "make space"}, + return Arrays.asList(new Object[][] { + { "", "" }, + { "name", "description" }, + { "NAME", "DESCRIPTION" }, + { "&name%", "#description!" }, + { "1234", "5678" }, + { "make space", "make space" }, }); } - private class ActualKapuaNamedEntityCreator extends AbstractKapuaNamedEntityCreator { - - protected ActualKapuaNamedEntityCreator(KapuaId scopeId) { - super(scopeId); - } + private class ActualKapuaNamedEntityCreator extends KapuaNamedEntityCreator { protected ActualKapuaNamedEntityCreator(KapuaId scopeId, String name) { super(scopeId, name); @@ -70,7 +66,7 @@ protected ActualKapuaNamedEntityCreator(KapuaId scopeId, String name) { @Test public void abstractKapuaNamedEntityCreatorNameTest() { namedEntityCreator.setName(name); - AbstractKapuaNamedEntityCreator namedCopyEntityCreator = new ActualKapuaNamedEntityCreator(scopeId, name); + KapuaNamedEntityCreator namedCopyEntityCreator = new ActualKapuaNamedEntityCreator(scopeId, name); Assert.assertEquals("Expected and actual values should be the same!", namedEntityCreator.getName(), namedCopyEntityCreator.getName()); } diff --git a/commons/src/test/java/org/eclipse/kapua/commons/model/AbstractKapuaUpdatableEntityCreatorTest.java b/commons/src/test/java/org/eclipse/kapua/commons/model/KapuaUpdatableEntityCreatorTest.java similarity index 79% rename from commons/src/test/java/org/eclipse/kapua/commons/model/AbstractKapuaUpdatableEntityCreatorTest.java rename to commons/src/test/java/org/eclipse/kapua/commons/model/KapuaUpdatableEntityCreatorTest.java index d4d4b67e0bb..43e0baa8f6f 100644 --- a/commons/src/test/java/org/eclipse/kapua/commons/model/AbstractKapuaUpdatableEntityCreatorTest.java +++ b/commons/src/test/java/org/eclipse/kapua/commons/model/KapuaUpdatableEntityCreatorTest.java @@ -12,21 +12,21 @@ *******************************************************************************/ package org.eclipse.kapua.commons.model; +import java.util.Properties; + import org.eclipse.kapua.commons.model.id.KapuaEid; import org.eclipse.kapua.model.KapuaEntity; +import org.eclipse.kapua.model.KapuaUpdatableEntityCreator; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.qa.markers.junit.JUnitTests; import org.junit.Assert; import org.junit.Test; import org.junit.experimental.categories.Category; -import java.util.Properties; - - @Category(JUnitTests.class) -public class AbstractKapuaUpdatableEntityCreatorTest { +public class KapuaUpdatableEntityCreatorTest { - private class ActualKapuaUpdatableEntityCreator extends AbstractKapuaUpdatableEntityCreator { + private class ActualKapuaUpdatableEntityCreator extends KapuaUpdatableEntityCreator { public ActualKapuaUpdatableEntityCreator(KapuaId scopeId) { super(scopeId); @@ -36,14 +36,14 @@ public ActualKapuaUpdatableEntityCreator(KapuaId scopeId) { @Test public void abstractKapuaUpdatableEntityCreatorScopeId() { KapuaId scopeId = new KapuaEid(); - AbstractKapuaUpdatableEntityCreator kapuaUpdatableEntityCreator = new ActualKapuaUpdatableEntityCreator<>(scopeId); + KapuaUpdatableEntityCreator kapuaUpdatableEntityCreator = new ActualKapuaUpdatableEntityCreator<>(scopeId); Assert.assertEquals("Actual and expected values are not the same!", scopeId, kapuaUpdatableEntityCreator.getScopeId()); } @Test public void getEntityAttributesTest() { KapuaId scopeId = new KapuaEid(); - AbstractKapuaUpdatableEntityCreator kapuaUpdatableEntityCreator = new ActualKapuaUpdatableEntityCreator<>(scopeId); + KapuaUpdatableEntityCreator kapuaUpdatableEntityCreator = new ActualKapuaUpdatableEntityCreator<>(scopeId); Properties properties = new Properties(); kapuaUpdatableEntityCreator.setEntityAttributes(properties); Assert.assertEquals("Actual and expected values are not the same!", properties, kapuaUpdatableEntityCreator.getEntityAttributes()); diff --git a/commons/src/test/java/org/eclipse/kapua/commons/service/event/store/internal/EventStoreFactoryImplTest.java b/commons/src/test/java/org/eclipse/kapua/commons/service/event/store/internal/EventStoreFactoryImplTest.java index 8b70a247bed..1faf50064fd 100644 --- a/commons/src/test/java/org/eclipse/kapua/commons/service/event/store/internal/EventStoreFactoryImplTest.java +++ b/commons/src/test/java/org/eclipse/kapua/commons/service/event/store/internal/EventStoreFactoryImplTest.java @@ -39,17 +39,6 @@ public void newEntityTest() { } } - @Test - public void newCreatorTest() { - EventStoreFactoryImpl eventStoreFactoryImpl = new EventStoreFactoryImpl(); - KapuaId[] scopeIdList = { null, new KapuaEid(BigInteger.ONE) }; - - for (KapuaId scopeId : scopeIdList) { - Assert.assertNotNull("Null not expected.", eventStoreFactoryImpl.newCreator(scopeId)); - Assert.assertThat("EventStoreRecordImpl object expected.", eventStoreFactoryImpl.newCreator(scopeId), IsInstanceOf.instanceOf(EventStoreRecordCreatorImpl.class)); - } - } - @Test public void cloneTest() { EventStoreFactoryImpl eventStoreFactoryImpl = new EventStoreFactoryImpl(); diff --git a/commons/src/test/java/org/eclipse/kapua/commons/service/event/store/internal/EventStoreRecordCreatorImplTest.java b/commons/src/test/java/org/eclipse/kapua/commons/service/event/store/internal/EventStoreRecordCreatorTest.java similarity index 79% rename from commons/src/test/java/org/eclipse/kapua/commons/service/event/store/internal/EventStoreRecordCreatorImplTest.java rename to commons/src/test/java/org/eclipse/kapua/commons/service/event/store/internal/EventStoreRecordCreatorTest.java index a4cfc72bcfc..be05ad60276 100644 --- a/commons/src/test/java/org/eclipse/kapua/commons/service/event/store/internal/EventStoreRecordCreatorImplTest.java +++ b/commons/src/test/java/org/eclipse/kapua/commons/service/event/store/internal/EventStoreRecordCreatorTest.java @@ -12,6 +12,9 @@ *******************************************************************************/ package org.eclipse.kapua.commons.service.event.store.internal; +import java.math.BigInteger; + +import org.eclipse.kapua.commons.service.event.store.api.EventStoreRecordCreator; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.model.id.KapuaIdImpl; import org.eclipse.kapua.qa.markers.junit.JUnitTests; @@ -19,17 +22,15 @@ import org.junit.Test; import org.junit.experimental.categories.Category; -import java.math.BigInteger; - - @Category(JUnitTests.class) -public class EventStoreRecordCreatorImplTest { +public class EventStoreRecordCreatorTest { + @Test public void eventStoreRecordCreatorImplTest() { - KapuaId[] scopeIdList = {null, new KapuaIdImpl(BigInteger.ONE)}; + KapuaId[] scopeIdList = { null, new KapuaIdImpl(BigInteger.ONE) }; for (KapuaId scopeId : scopeIdList) { - EventStoreRecordCreatorImpl eventStoreRecordCreatorImpl = new EventStoreRecordCreatorImpl(scopeId); + EventStoreRecordCreator eventStoreRecordCreatorImpl = new EventStoreRecordCreator(scopeId); Assert.assertEquals("Expected and actual values should be the same.", scopeId, eventStoreRecordCreatorImpl.getScopeId()); } } diff --git a/commons/src/test/java/org/eclipse/kapua/commons/util/PropertiesUtilsTest.java b/commons/src/test/java/org/eclipse/kapua/commons/util/PropertiesUtilsTest.java index dae14bfc114..453a7efa809 100644 --- a/commons/src/test/java/org/eclipse/kapua/commons/util/PropertiesUtilsTest.java +++ b/commons/src/test/java/org/eclipse/kapua/commons/util/PropertiesUtilsTest.java @@ -12,17 +12,17 @@ *******************************************************************************/ package org.eclipse.kapua.commons.util; +import java.lang.reflect.Constructor; +import java.util.Date; +import java.util.Properties; + +import org.eclipse.kapua.PropertiesUtils; import org.eclipse.kapua.qa.markers.junit.JUnitTests; import org.junit.Assert; import org.junit.ComparisonFailure; import org.junit.Test; import org.junit.experimental.categories.Category; -import java.lang.reflect.Constructor; -import java.util.Date; -import java.util.Properties; - - @Category(JUnitTests.class) public class PropertiesUtilsTest { @@ -35,8 +35,9 @@ public void testConstructor() throws Exception { @Test public void readPropertiesFromStringTest() throws Exception { - String[] inputString = new String[]{"StringString", "!string\n !string", " #string\n String=S123", " string! Strin=g ", "strin#g : string", "string str1, \\\nstr2, \\\nstr3", "string\\ String 12 34", "123\\:\\=12%#34:String", "Str\ting String", "Strin\fg=String", "string\n "}; - String[] emptyOrNullString = new String[]{null, ""}; + String[] inputString = new String[] { "StringString", "!string\n !string", " #string\n String=S123", " string! Strin=g ", "strin#g : string", + "string str1, \\\nstr2, \\\nstr3", "string\\ String 12 34", "123\\:\\=12%#34:String", "Str\ting String", "Strin\fg=String", "string\n " }; + String[] emptyOrNullString = new String[] { null, "" }; Properties prop1 = new Properties(); prop1.setProperty("StringString", ""); @@ -87,8 +88,9 @@ public void readPropertiesFromStringTest() throws Exception { Properties emptyProp2 = new Properties(); emptyProp2.setProperty("", ""); - Properties[] validPropArray = new Properties[]{prop1, prop2, prop3, prop4, prop5, prop6, prop7, prop8, prop9, prop10, prop11}; - Properties[] invalidPropArray = new Properties[]{invalidProp1, invalidProp2, invalidProp3, invalidProp4, invalidProp5, invalidProp6, invalidProp7, invalidProp8, invalidProp9, invalidProp10, invalidProp11}; + Properties[] validPropArray = new Properties[] { prop1, prop2, prop3, prop4, prop5, prop6, prop7, prop8, prop9, prop10, prop11 }; + Properties[] invalidPropArray = new Properties[] { invalidProp1, invalidProp2, invalidProp3, invalidProp4, invalidProp5, invalidProp6, invalidProp7, invalidProp8, invalidProp9, invalidProp10, + invalidProp11 }; //Positive tests for (int i = 0; i < inputString.length; i++) { @@ -156,9 +158,9 @@ public void writePropertiesToStringTest() throws Exception { String invalidString4 = "#" + new Date().toString() + lineSeparator + "st ring#a=StriNG aaa';" + lineSeparator; String invalidString5 = "#" + new Date().toString() + "\\ String=ssss12_ ;; " + lineSeparator; - String[] validOutputString = new String[]{str1, str2, str3, str4, str5}; - String[] invalidOutputString = new String[]{invalidString1, invalidString2, invalidString3, invalidString4, invalidString5}; - Properties[] propArray = new Properties[]{prop1, prop2, prop3, prop4, prop5}; + String[] validOutputString = new String[] { str1, str2, str3, str4, str5 }; + String[] invalidOutputString = new String[] { invalidString1, invalidString2, invalidString3, invalidString4, invalidString5 }; + Properties[] propArray = new Properties[] { prop1, prop2, prop3, prop4, prop5 }; //Positive tests for (int i = 0; i < propArray.length; i++) { diff --git a/console/module/account/src/main/java/org/eclipse/kapua/app/console/module/account/server/GwtAccountServiceImpl.java b/console/module/account/src/main/java/org/eclipse/kapua/app/console/module/account/server/GwtAccountServiceImpl.java index 9323f407d0d..4a8d97492cb 100644 --- a/console/module/account/src/main/java/org/eclipse/kapua/app/console/module/account/server/GwtAccountServiceImpl.java +++ b/console/module/account/src/main/java/org/eclipse/kapua/app/console/module/account/server/GwtAccountServiceImpl.java @@ -83,6 +83,7 @@ import org.eclipse.kapua.service.endpoint.EndpointInfo; import org.eclipse.kapua.service.endpoint.EndpointInfoFactory; import org.eclipse.kapua.service.endpoint.EndpointInfoListResult; +import org.eclipse.kapua.service.endpoint.EndpointInfoQuery; import org.eclipse.kapua.service.endpoint.EndpointInfoService; import org.eclipse.kapua.service.user.User; import org.eclipse.kapua.service.user.UserFactory; @@ -134,7 +135,7 @@ public GwtAccount create(GwtXSRFToken xsrfToken, GwtAccountCreator gwtAccountCre GwtAccount gwtAccount = null; KapuaId parentAccountId = KapuaEid.parseCompactId(gwtAccountCreator.getParentAccountId()); try { - AccountCreator accountCreator = ACCOUNT_FACTORY.newCreator(parentAccountId); + AccountCreator accountCreator = new AccountCreator(parentAccountId); accountCreator.setName(gwtAccountCreator.getAccountName()); accountCreator.setOrganizationName(gwtAccountCreator.getOrganizationName()); @@ -159,7 +160,7 @@ public void run() throws Exception { // Admin Permission adminPermission = PERMISSION_FACTORY.newPermission((String) null, null, account.getId(), null, true); - RoleCreator adminRoleCreator = ROLE_FACTORY.newCreator(account.getId()); + RoleCreator adminRoleCreator = new RoleCreator(account.getId()); adminRoleCreator.setName("Admin"); adminRoleCreator.setScopeId(account.getId()); adminRoleCreator.setPermissions(Sets.newHashSet(adminPermission)); @@ -169,7 +170,7 @@ public void run() throws Exception { // Thing Permission thingPermission = PERMISSION_FACTORY.newPermission(Domains.BROKER, Actions.connect, account.getId(), null, false); - RoleCreator thingRoleCreator = ROLE_FACTORY.newCreator(account.getId()); + RoleCreator thingRoleCreator = new RoleCreator(account.getId()); thingRoleCreator.setName("Thing"); thingRoleCreator.setScopeId(account.getId()); thingRoleCreator.setPermissions(Sets.newHashSet(thingPermission)); @@ -252,7 +253,7 @@ public Account call() throws Exception { @Override public EndpointInfoListResult call() throws Exception { - return ENDPOINT_INFO_SERVICE.query(ENDPOINT_INFO_FACTORY.newQuery(account.getId())); + return ENDPOINT_INFO_SERVICE.query(new EndpointInfoQuery(account.getId())); } }); diff --git a/console/module/authentication/src/main/java/org/eclipse/kapua/app/console/module/authentication/shared/util/GwtKapuaAuthenticationModelConverter.java b/console/module/authentication/src/main/java/org/eclipse/kapua/app/console/module/authentication/shared/util/GwtKapuaAuthenticationModelConverter.java index c8c8372c718..39610ac3e14 100644 --- a/console/module/authentication/src/main/java/org/eclipse/kapua/app/console/module/authentication/shared/util/GwtKapuaAuthenticationModelConverter.java +++ b/console/module/authentication/src/main/java/org/eclipse/kapua/app/console/module/authentication/shared/util/GwtKapuaAuthenticationModelConverter.java @@ -104,13 +104,12 @@ public static CredentialCreator convertCredentialCreator(GwtCredentialCreator gw // Convert scopeId KapuaId scopeId = GwtKapuaCommonsModelConverter.convertKapuaId(gwtCredentialCreator.getScopeId()); - CredentialCreator credentialCreator = CREDENTIAL_FACTORY - .newCreator(scopeId, - GwtKapuaCommonsModelConverter.convertKapuaId(gwtCredentialCreator.getUserId()), - gwtCredentialCreator.getCredentialType(), - gwtCredentialCreator.getCredentialPlainKey(), - convertCredentialStatus(gwtCredentialCreator.getCredentialStatus()), - gwtCredentialCreator.getExpirationDate()); + CredentialCreator credentialCreator = new CredentialCreator(scopeId, + GwtKapuaCommonsModelConverter.convertKapuaId(gwtCredentialCreator.getUserId()), + gwtCredentialCreator.getCredentialType(), + gwtCredentialCreator.getCredentialPlainKey(), + convertCredentialStatus(gwtCredentialCreator.getCredentialStatus()), + gwtCredentialCreator.getExpirationDate()); // Return converted return credentialCreator; } @@ -151,7 +150,7 @@ public static CredentialStatus convertCredentialStatus(GwtCredentialStatus gwtCr public static MfaOptionCreator convertMfaCredentialOptionsCreator(GwtMfaCredentialOptionsCreator gwtMfaCredentialOptionsCreator) { KapuaId scopeId = GwtKapuaCommonsModelConverter.convertKapuaId(gwtMfaCredentialOptionsCreator.getScopeId()); KapuaId userId = GwtKapuaCommonsModelConverter.convertKapuaId(gwtMfaCredentialOptionsCreator.getUserId()); - return MFA_OPTION_FACTORY.newCreator(scopeId, userId); + return new MfaOptionCreator(scopeId, userId); } } diff --git a/console/module/authorization/src/main/java/org/eclipse/kapua/app/console/module/authorization/server/GwtAccessInfoServiceImpl.java b/console/module/authorization/src/main/java/org/eclipse/kapua/app/console/module/authorization/server/GwtAccessInfoServiceImpl.java index 2d8286a838c..5f1264e8f99 100644 --- a/console/module/authorization/src/main/java/org/eclipse/kapua/app/console/module/authorization/server/GwtAccessInfoServiceImpl.java +++ b/console/module/authorization/src/main/java/org/eclipse/kapua/app/console/module/authorization/server/GwtAccessInfoServiceImpl.java @@ -26,7 +26,6 @@ import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.authorization.access.AccessInfo; import org.eclipse.kapua.service.authorization.access.AccessInfoCreator; -import org.eclipse.kapua.service.authorization.access.AccessInfoFactory; import org.eclipse.kapua.service.authorization.access.AccessInfoService; import org.eclipse.kapua.service.authorization.access.AccessPermission; import org.eclipse.kapua.service.authorization.access.AccessPermissionListResult; @@ -110,8 +109,7 @@ public GwtAccessInfo findByUserIdOrCreate(String scopeShortId, String userShortI AccessInfoService accessInfoService = locator.getService(AccessInfoService.class); AccessInfo accessInfo = accessInfoService.findByUserId(scopeId, userId); if (accessInfo == null) { - AccessInfoFactory accessInfoFactory = locator.getFactory(AccessInfoFactory.class); - AccessInfoCreator accessInfoCreator = accessInfoFactory.newCreator(scopeId); + AccessInfoCreator accessInfoCreator = new AccessInfoCreator(scopeId); accessInfoCreator.setUserId(userId); accessInfo = accessInfoService.create(accessInfoCreator); } diff --git a/console/module/authorization/src/main/java/org/eclipse/kapua/app/console/module/authorization/server/GwtGroupServiceImpl.java b/console/module/authorization/src/main/java/org/eclipse/kapua/app/console/module/authorization/server/GwtGroupServiceImpl.java index 636179e9782..5b4dadfb667 100644 --- a/console/module/authorization/src/main/java/org/eclipse/kapua/app/console/module/authorization/server/GwtGroupServiceImpl.java +++ b/console/module/authorization/src/main/java/org/eclipse/kapua/app/console/module/authorization/server/GwtGroupServiceImpl.java @@ -72,7 +72,7 @@ public GwtGroup create(GwtGroupCreator gwtGroupCreator) throws GwtKapuaException try { KapuaId scopeId = KapuaEid.parseCompactId(gwtGroupCreator.getScopeId()); - GroupCreator groupCreator = GROUP_FACTORY.newCreator(scopeId, gwtGroupCreator.getName()); + GroupCreator groupCreator = new GroupCreator(scopeId, gwtGroupCreator.getName()); groupCreator.setDescription(gwtGroupCreator.getDescription()); Group group = GROUP_SERVICE.create(groupCreator); diff --git a/console/module/authorization/src/main/java/org/eclipse/kapua/app/console/module/authorization/server/GwtRoleServiceImpl.java b/console/module/authorization/src/main/java/org/eclipse/kapua/app/console/module/authorization/server/GwtRoleServiceImpl.java index 280df1b2100..36595e2a9eb 100644 --- a/console/module/authorization/src/main/java/org/eclipse/kapua/app/console/module/authorization/server/GwtRoleServiceImpl.java +++ b/console/module/authorization/src/main/java/org/eclipse/kapua/app/console/module/authorization/server/GwtRoleServiceImpl.java @@ -341,7 +341,7 @@ public GwtRolePermission addRolePermission(GwtXSRFToken gwtXsrfToken, GwtRolePer try { KapuaId scopeId = GwtKapuaCommonsModelConverter.convertKapuaId(gwtRolePermissionCreator.getScopeId()); - RolePermissionCreator rolePermissionCreator = ROLE_PERMISSION_FACTORY.newCreator(scopeId); + RolePermissionCreator rolePermissionCreator = new RolePermissionCreator(scopeId); rolePermissionCreator.setRoleId(GwtKapuaCommonsModelConverter.convertKapuaId(gwtRolePermissionCreator.getRoleId())); rolePermissionCreator.setScopeId(scopeId); rolePermissionCreator.setPermission(GwtKapuaAuthorizationModelConverter.convertPermission(gwtPermission)); diff --git a/console/module/authorization/src/main/java/org/eclipse/kapua/app/console/module/authorization/shared/util/GwtKapuaAuthorizationModelConverter.java b/console/module/authorization/src/main/java/org/eclipse/kapua/app/console/module/authorization/shared/util/GwtKapuaAuthorizationModelConverter.java index 8cef2834377..d7fa53731e9 100644 --- a/console/module/authorization/src/main/java/org/eclipse/kapua/app/console/module/authorization/shared/util/GwtKapuaAuthorizationModelConverter.java +++ b/console/module/authorization/src/main/java/org/eclipse/kapua/app/console/module/authorization/shared/util/GwtKapuaAuthorizationModelConverter.java @@ -215,7 +215,7 @@ public static RoleCreator convertRoleCreator(GwtRoleCreator gwtRoleCreator) thro // Convert scopeId KapuaId scopeId = GwtKapuaCommonsModelConverter.convertKapuaId(gwtRoleCreator.getScopeId()); - RoleCreator roleCreator = roleFactory.newCreator(scopeId); + RoleCreator roleCreator = new RoleCreator(scopeId); // Convert name roleCreator.setName(gwtRoleCreator.getName()); @@ -250,7 +250,7 @@ public static AccessRoleCreator convertAccessRoleCreator(GwtAccessRoleCreator gw // Convert scopeId KapuaId scopeId = GwtKapuaCommonsModelConverter.convertKapuaId(gwtAccessRoleCreator.getScopeId()); - AccessRoleCreator accessRoleCreator = accessRoleFactory.newCreator(scopeId); + AccessRoleCreator accessRoleCreator = new AccessRoleCreator(scopeId); // Convert accessInfoId accessRoleCreator.setAccessInfoId(GwtKapuaCommonsModelConverter.convertKapuaId(gwtAccessRoleCreator.getAccessInfoId())); @@ -277,7 +277,7 @@ public static AccessPermissionCreator convertAccessPermissionCreator(GwtAccessPe // Convert scopeId KapuaId scopeId = GwtKapuaCommonsModelConverter.convertKapuaId(gwtAccessPermissionCreator.getScopeId()); - AccessPermissionCreator accessPermissionCreator = accessPermissionFactory.newCreator(scopeId); + AccessPermissionCreator accessPermissionCreator = new AccessPermissionCreator(scopeId); // Convert accessInfoId accessPermissionCreator.setAccessInfoId(GwtKapuaCommonsModelConverter.convertKapuaId(gwtAccessPermissionCreator.getAccessInfoId())); @@ -295,7 +295,7 @@ public static AccessInfoCreator convertAccessInfoCreator(GwtAccessInfoCreator gw // Convert scopeId KapuaId scopeId = GwtKapuaCommonsModelConverter.convertKapuaId(gwtAccessInfoCreator.getScopeId()); - AccessInfoCreator accessInfoCreator = accessInfoFactory.newCreator(scopeId); + AccessInfoCreator accessInfoCreator = new AccessInfoCreator(scopeId); // Convert userId accessInfoCreator.setUserId(GwtKapuaCommonsModelConverter.convertKapuaId(gwtAccessInfoCreator.getUserId())); diff --git a/console/module/device/src/main/java/org/eclipse/kapua/app/console/module/device/server/GwtDeviceServiceImpl.java b/console/module/device/src/main/java/org/eclipse/kapua/app/console/module/device/server/GwtDeviceServiceImpl.java index 926bb8eeec1..1e8ea8749ad 100644 --- a/console/module/device/src/main/java/org/eclipse/kapua/app/console/module/device/server/GwtDeviceServiceImpl.java +++ b/console/module/device/src/main/java/org/eclipse/kapua/app/console/module/device/server/GwtDeviceServiceImpl.java @@ -385,7 +385,7 @@ public GwtDevice createDevice(GwtXSRFToken xsrfToken, GwtDeviceCreator gwtDevice try { KapuaId scopeId = KapuaEid.parseCompactId(gwtDeviceCreator.getScopeId()); - DeviceCreator deviceCreator = deviceFactory.newCreator(scopeId, gwtDeviceCreator.getClientId()); + DeviceCreator deviceCreator = new DeviceCreator(scopeId, gwtDeviceCreator.getClientId()); deviceCreator.setDisplayName(gwtDeviceCreator.getDisplayName()); deviceCreator.setGroupId(GwtKapuaCommonsModelConverter.convertKapuaId(gwtDeviceCreator.getGroupId())); deviceCreator.setStatus((DeviceStatus.valueOf(gwtDeviceCreator.getDeviceStatus()))); diff --git a/console/module/endpoint/src/main/java/org/eclipse/kapua/app/console/module/endpoint/server/GwtEndpointServiceImpl.java b/console/module/endpoint/src/main/java/org/eclipse/kapua/app/console/module/endpoint/server/GwtEndpointServiceImpl.java index 6098643c90d..8587bd6feec 100644 --- a/console/module/endpoint/src/main/java/org/eclipse/kapua/app/console/module/endpoint/server/GwtEndpointServiceImpl.java +++ b/console/module/endpoint/src/main/java/org/eclipse/kapua/app/console/module/endpoint/server/GwtEndpointServiceImpl.java @@ -79,7 +79,7 @@ public GwtEndpoint create(GwtXSRFToken xsrfToken, GwtEndpointCreator gwtEndpoint try { KapuaId scopeId = KapuaEid.parseCompactId(gwtEndpointCreator.getScopeId()); - EndpointInfoCreator endpointCreator = ENDPOINT_INFO_FACTORY.newCreator(scopeId); + EndpointInfoCreator endpointCreator = new EndpointInfoCreator(scopeId); endpointCreator.setSchema(gwtEndpointCreator.getSchema()); endpointCreator.setDns(gwtEndpointCreator.getDns()); endpointCreator.setPort(gwtEndpointCreator.getPort().intValue()); @@ -246,7 +246,7 @@ public List findAll(String scopeId) throws GwtKapuaException { List endpointList = new ArrayList(); try { - EndpointInfoQuery query = ENDPOINT_INFO_FACTORY.newQuery(GwtKapuaCommonsModelConverter.convertKapuaId(scopeId)); + EndpointInfoQuery query = new EndpointInfoQuery(GwtKapuaCommonsModelConverter.convertKapuaId(scopeId)); EndpointInfoListResult result = ENDPOINT_INFO_SERVICE.query(query); for (EndpointInfo endpoint : result.getItems()) { diff --git a/console/module/endpoint/src/main/java/org/eclipse/kapua/app/console/module/endpoint/shared/util/GwtKapuaEndpointModelConverter.java b/console/module/endpoint/src/main/java/org/eclipse/kapua/app/console/module/endpoint/shared/util/GwtKapuaEndpointModelConverter.java index 34869622759..7ace5173755 100644 --- a/console/module/endpoint/src/main/java/org/eclipse/kapua/app/console/module/endpoint/shared/util/GwtKapuaEndpointModelConverter.java +++ b/console/module/endpoint/src/main/java/org/eclipse/kapua/app/console/module/endpoint/shared/util/GwtKapuaEndpointModelConverter.java @@ -12,21 +12,22 @@ *******************************************************************************/ package org.eclipse.kapua.app.console.module.endpoint.shared.util; -import com.extjs.gxt.ui.client.Style.SortDir; -import com.extjs.gxt.ui.client.data.PagingLoadConfig; -import com.google.common.base.Strings; import org.apache.commons.lang3.StringUtils; import org.eclipse.kapua.app.console.module.api.shared.util.GwtKapuaCommonsModelConverter; import org.eclipse.kapua.app.console.module.endpoint.shared.model.GwtEndpointQuery; +import org.eclipse.kapua.locator.KapuaLocator; import org.eclipse.kapua.model.query.FieldSortCriteria; import org.eclipse.kapua.model.query.SortOrder; -import org.eclipse.kapua.locator.KapuaLocator; import org.eclipse.kapua.model.query.predicate.AndPredicate; import org.eclipse.kapua.model.query.predicate.AttributePredicate; import org.eclipse.kapua.service.endpoint.EndpointInfoAttributes; import org.eclipse.kapua.service.endpoint.EndpointInfoFactory; import org.eclipse.kapua.service.endpoint.EndpointInfoQuery; +import com.extjs.gxt.ui.client.Style.SortDir; +import com.extjs.gxt.ui.client.data.PagingLoadConfig; +import com.google.common.base.Strings; + public class GwtKapuaEndpointModelConverter { private static final KapuaLocator LOCATOR = KapuaLocator.getInstance(); @@ -38,13 +39,15 @@ private GwtKapuaEndpointModelConverter() { /** * Converts a {@link GwtEndpointQuery} into a {@link EndpointInfoQuery} object for backend usage * - * @param loadConfig the load configuration - * @param gwtEndpointQuery the {@link GwtEndpointQuery} to convertKapuaId + * @param loadConfig + * the load configuration + * @param gwtEndpointQuery + * the {@link GwtEndpointQuery} to convertKapuaId * @return the converted {@link EndpointInfoQuery} */ public static EndpointInfoQuery convertEndpointQuery(PagingLoadConfig loadConfig, GwtEndpointQuery gwtEndpointQuery) { - EndpointInfoQuery query = ENDPOINT_FACTORY.newQuery(GwtKapuaCommonsModelConverter.convertKapuaId(gwtEndpointQuery.getScopeId())); + EndpointInfoQuery query = new EndpointInfoQuery(GwtKapuaCommonsModelConverter.convertKapuaId(gwtEndpointQuery.getScopeId())); // Predicates conversion AndPredicate andPredicate = query.andPredicate(); diff --git a/console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/server/GwtJobServiceImpl.java b/console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/server/GwtJobServiceImpl.java index 94d523386ea..bd1d8c5681e 100644 --- a/console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/server/GwtJobServiceImpl.java +++ b/console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/server/GwtJobServiceImpl.java @@ -116,7 +116,7 @@ public GwtJob create(GwtXSRFToken xsrfToken, GwtJobCreator gwtJobCreator) throws GwtJob gwtJob = null; try { KapuaId scopeId = KapuaEid.parseCompactId(gwtJobCreator.getScopeId()); - JobCreator jobCreator = JOB_FACTORY.newCreator(scopeId); + JobCreator jobCreator = new JobCreator(scopeId); jobCreator.setName(gwtJobCreator.getName()); jobCreator.setDescription(gwtJobCreator.getDescription()); // Create the Job diff --git a/console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/server/GwtJobTargetServiceImpl.java b/console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/server/GwtJobTargetServiceImpl.java index 6d33a9bf00b..0eff0b6b305 100644 --- a/console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/server/GwtJobTargetServiceImpl.java +++ b/console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/server/GwtJobTargetServiceImpl.java @@ -147,7 +147,7 @@ public List create(GwtXSRFToken xsrfToken, String scopeId, String devices.add(device); } KapuaId creatorScopeId = KapuaEid.parseCompactId(gwtJobTargetCreator.getScopeId()); - JobTargetCreator jobTargetCreator = JOB_TARGET_FACTORY.newCreator(creatorScopeId); + JobTargetCreator jobTargetCreator = new JobTargetCreator(creatorScopeId); jobTargetCreator.setJobId(GwtKapuaCommonsModelConverter.convertKapuaId(gwtJobTargetCreator.getJobId())); jobTargetCreator.setJobTargetId(GwtKapuaCommonsModelConverter.convertKapuaId(gwtJobTargetCreator.getJobTargetId())); diff --git a/console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/server/GwtTriggerServiceImpl.java b/console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/server/GwtTriggerServiceImpl.java index dfccf56c7f2..d8350647d1d 100644 --- a/console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/server/GwtTriggerServiceImpl.java +++ b/console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/server/GwtTriggerServiceImpl.java @@ -152,7 +152,7 @@ public GwtTrigger create(GwtXSRFToken xsrfToken, GwtTriggerCreator gwtTriggerCre try { KapuaId scopeId = KapuaEid.parseCompactId(gwtTriggerCreator.getScopeId()); - TriggerCreator triggerCreator = TRIGGER_FACTORY.newCreator(scopeId); + TriggerCreator triggerCreator = new TriggerCreator(scopeId); triggerCreator.setName(gwtTriggerCreator.getTriggerName()); triggerCreator.setStartsOn(gwtTriggerCreator.getStartsOn()); triggerCreator.setEndsOn(gwtTriggerCreator.getEndsOn()); diff --git a/console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/shared/util/GwtKapuaJobModelConverter.java b/console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/shared/util/GwtKapuaJobModelConverter.java index be23d90ed1d..9f2ca178eb2 100644 --- a/console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/shared/util/GwtKapuaJobModelConverter.java +++ b/console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/shared/util/GwtKapuaJobModelConverter.java @@ -46,17 +46,14 @@ import org.eclipse.kapua.service.job.JobFactory; import org.eclipse.kapua.service.job.JobQuery; import org.eclipse.kapua.service.job.execution.JobExecutionAttributes; -import org.eclipse.kapua.service.job.execution.JobExecutionFactory; import org.eclipse.kapua.service.job.execution.JobExecutionQuery; import org.eclipse.kapua.service.job.step.JobStep; import org.eclipse.kapua.service.job.step.JobStepAttributes; import org.eclipse.kapua.service.job.step.JobStepCreator; import org.eclipse.kapua.service.job.step.JobStepFactory; -import org.eclipse.kapua.service.job.step.definition.JobStepDefinitionFactory; import org.eclipse.kapua.service.job.step.definition.JobStepDefinitionQuery; import org.eclipse.kapua.service.job.step.definition.JobStepProperty; import org.eclipse.kapua.service.job.targets.JobTargetAttributes; -import org.eclipse.kapua.service.job.targets.JobTargetFactory; import org.eclipse.kapua.service.scheduler.trigger.TriggerAttributes; import org.eclipse.kapua.service.scheduler.trigger.TriggerFactory; import org.eclipse.kapua.service.scheduler.trigger.definition.TriggerProperty; @@ -68,11 +65,8 @@ public class GwtKapuaJobModelConverter { private static final KapuaLocator LOCATOR = KapuaLocator.getInstance(); - private static final JobExecutionFactory JOB_EXECUTION_FACTORY = LOCATOR.getFactory(JobExecutionFactory.class); private static final JobFactory JOB_FACTORY = LOCATOR.getFactory(JobFactory.class); private static final JobStepFactory JOB_STEP_FACTORY = LOCATOR.getFactory(JobStepFactory.class); - private static final JobStepDefinitionFactory JOB_STEP_DEFINITION_FACTORY = LOCATOR.getFactory(JobStepDefinitionFactory.class); - private static final JobTargetFactory JOB_TARGET_FACTORY = LOCATOR.getFactory(JobTargetFactory.class); private static final JobEngineFactory JOB_ENGINE_FACTORY = LOCATOR.getFactory(JobEngineFactory.class); private static final TriggerFactory TRIGGER_FACTORY = LOCATOR.getFactory(TriggerFactory.class); @@ -239,7 +233,7 @@ public static JobStepCreator convertJobStepCreator(GwtJobStepCreator gwtJobStepC // Convert scopeId KapuaId scopeId = GwtKapuaCommonsModelConverter.convertKapuaId(gwtJobStepCreator.getScopeId()); - JobStepCreator jobStepCreator = JOB_STEP_FACTORY.newCreator(scopeId); + JobStepCreator jobStepCreator = new JobStepCreator(scopeId); jobStepCreator.setName(gwtJobStepCreator.getJobName()); jobStepCreator.setDescription(gwtJobStepCreator.getJobDescription()); diff --git a/console/module/tag/src/main/java/org/eclipse/kapua/app/console/module/tag/server/GwtTagServiceImpl.java b/console/module/tag/src/main/java/org/eclipse/kapua/app/console/module/tag/server/GwtTagServiceImpl.java index 38df2982c45..4b721f6c62e 100644 --- a/console/module/tag/src/main/java/org/eclipse/kapua/app/console/module/tag/server/GwtTagServiceImpl.java +++ b/console/module/tag/src/main/java/org/eclipse/kapua/app/console/module/tag/server/GwtTagServiceImpl.java @@ -76,7 +76,7 @@ public GwtTag create(GwtTagCreator gwtTagCreator) throws GwtKapuaException { GwtTag gwtTag = null; try { KapuaId scopeId = KapuaEid.parseCompactId(gwtTagCreator.getScopeId()); - TagCreator tagCreator = tagFactory.newCreator(scopeId, gwtTagCreator.getName()); + TagCreator tagCreator = new TagCreator(scopeId, gwtTagCreator.getName()); tagCreator.setDescription(gwtTagCreator.getDescription()); Tag tag = tagService.create(tagCreator); diff --git a/console/module/user/src/main/java/org/eclipse/kapua/app/console/module/user/server/GwtUserServiceImpl.java b/console/module/user/src/main/java/org/eclipse/kapua/app/console/module/user/server/GwtUserServiceImpl.java index c08e4686211..e3361a82cae 100644 --- a/console/module/user/src/main/java/org/eclipse/kapua/app/console/module/user/server/GwtUserServiceImpl.java +++ b/console/module/user/src/main/java/org/eclipse/kapua/app/console/module/user/server/GwtUserServiceImpl.java @@ -101,7 +101,7 @@ public GwtUser create(GwtXSRFToken xsrfToken, GwtUserCreator gwtUserCreator) thr try { KapuaId scopeId = KapuaEid.parseCompactId(gwtUserCreator.getScopeId()); - UserCreator userCreator = USER_FACTORY.newCreator(scopeId, gwtUserCreator.getUsername()); + UserCreator userCreator = new UserCreator(scopeId, gwtUserCreator.getUsername()); userCreator.setUserType(GwtKapuaUserModelConverter.convertUserType(gwtUserCreator.getUserType())); userCreator.setDisplayName(gwtUserCreator.getDisplayName()); userCreator.setEmail(gwtUserCreator.getEmail()); @@ -116,7 +116,7 @@ public GwtUser create(GwtXSRFToken xsrfToken, GwtUserCreator gwtUserCreator) thr if (UserType.INTERNAL.equals(user.getUserType()) && gwtUserCreator.getPassword() != null) { - CredentialCreator credentialCreator = CREDENTIAL_FACTORY.newCreator(scopeId, + CredentialCreator credentialCreator = new CredentialCreator(scopeId, user.getId(), "PASSWORD", gwtUserCreator.getPassword(), diff --git a/job-engine/api/src/main/java/org/eclipse/kapua/job/engine/queue/QueuedJobExecutionCreator.java b/job-engine/api/src/main/java/org/eclipse/kapua/job/engine/queue/QueuedJobExecutionCreator.java index e1d21ba99f4..88f8ece9792 100644 --- a/job-engine/api/src/main/java/org/eclipse/kapua/job/engine/queue/QueuedJobExecutionCreator.java +++ b/job-engine/api/src/main/java/org/eclipse/kapua/job/engine/queue/QueuedJobExecutionCreator.java @@ -12,14 +12,15 @@ *******************************************************************************/ package org.eclipse.kapua.job.engine.queue; -import org.eclipse.kapua.model.KapuaUpdatableEntityCreator; -import org.eclipse.kapua.model.id.KapuaId; - import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import org.eclipse.kapua.model.KapuaEntityCreator; +import org.eclipse.kapua.model.KapuaUpdatableEntityCreator; +import org.eclipse.kapua.model.id.KapuaId; + /** * {@link QueuedJobExecutionCreator} definition. * @@ -27,8 +28,26 @@ */ @XmlRootElement(name = "queuedJobExecutionCreator") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = QueuedJobExecutionXmlRegistry.class, factoryMethod = "newQueuedJobExecutionCreator") -public interface QueuedJobExecutionCreator extends KapuaUpdatableEntityCreator { +@XmlType +public class QueuedJobExecutionCreator extends KapuaUpdatableEntityCreator { + + private static final long serialVersionUID = 3119071638220738358L; + + private KapuaId jobId; + private KapuaId jobExecutionId; + private KapuaId waitForJobExecutionId; + private QueuedJobExecutionStatus status; + + public QueuedJobExecutionCreator() { + } + + public QueuedJobExecutionCreator(KapuaId scopeId) { + super(scopeId); + } + + public QueuedJobExecutionCreator(KapuaEntityCreator entityCreator) { + super(entityCreator); + } /** * Gets the {@link org.eclipse.kapua.service.job.Job} {@link KapuaId}. @@ -36,15 +55,20 @@ public interface QueuedJobExecutionCreator extends KapuaUpdatableEntityCreator { +public interface QueuedJobExecutionFactory extends KapuaEntityFactory { } diff --git a/job-engine/api/src/main/java/org/eclipse/kapua/job/engine/queue/QueuedJobExecutionXmlRegistry.java b/job-engine/api/src/main/java/org/eclipse/kapua/job/engine/queue/QueuedJobExecutionXmlRegistry.java index e53d63fcb29..e44130e0391 100644 --- a/job-engine/api/src/main/java/org/eclipse/kapua/job/engine/queue/QueuedJobExecutionXmlRegistry.java +++ b/job-engine/api/src/main/java/org/eclipse/kapua/job/engine/queue/QueuedJobExecutionXmlRegistry.java @@ -34,14 +34,4 @@ public class QueuedJobExecutionXmlRegistry { public QueuedJobExecution newQueuedJobExecution() { return queuedJobExecutionFactory.newEntity(null); } - - /** - * Creates a new job creator instance - * - * @return - */ - public QueuedJobExecutionCreator newQueuedJobExecutionCreator() { - return queuedJobExecutionFactory.newCreator(null); - } - } diff --git a/job-engine/jbatch/src/main/java/org/eclipse/kapua/job/engine/jbatch/listener/KapuaJobListener.java b/job-engine/jbatch/src/main/java/org/eclipse/kapua/job/engine/jbatch/listener/KapuaJobListener.java index 697209eef62..364c1c7c548 100644 --- a/job-engine/jbatch/src/main/java/org/eclipse/kapua/job/engine/jbatch/listener/KapuaJobListener.java +++ b/job-engine/jbatch/src/main/java/org/eclipse/kapua/job/engine/jbatch/listener/KapuaJobListener.java @@ -278,7 +278,7 @@ private JobExecution createJobExecution(KapuaId scopeId, KapuaId jobId, JobTarge Properties jobExecutionProperties = new Properties(); jobExecutionProperties.put(JBATCH_EXECUTION_ID, Long.toString(jBatchExecutionId)); - JobExecutionCreator jobExecutionCreator = jobExecutionFactory.newCreator(scopeId); + JobExecutionCreator jobExecutionCreator = new JobExecutionCreator(scopeId); jobExecutionCreator.setJobId(jobId); jobExecutionCreator.setStartedOn(new Date()); @@ -377,7 +377,7 @@ private JobExecution getAnotherJobExecutionRunning(KapuaId scopeId, KapuaId jobI */ private QueuedJobExecution enqueueJobExecution(KapuaId scopeId, KapuaId jobId, KapuaId jobExecutionId, KapuaId runningJobExecutionId) throws KapuaException { - QueuedJobExecutionCreator queuedJobExecutionCreator = queuedJobExecutionFactory.newCreator(scopeId); + QueuedJobExecutionCreator queuedJobExecutionCreator = new QueuedJobExecutionCreator(scopeId); queuedJobExecutionCreator.setJobId(jobId); queuedJobExecutionCreator.setJobExecutionId(jobExecutionId); queuedJobExecutionCreator.setWaitForJobExecutionId(runningJobExecutionId); diff --git a/job-engine/jbatch/src/main/java/org/eclipse/kapua/job/engine/queue/jbatch/QueuedJobExecutionCreatorImpl.java b/job-engine/jbatch/src/main/java/org/eclipse/kapua/job/engine/queue/jbatch/QueuedJobExecutionCreatorImpl.java deleted file mode 100644 index 4962add3d41..00000000000 --- a/job-engine/jbatch/src/main/java/org/eclipse/kapua/job/engine/queue/jbatch/QueuedJobExecutionCreatorImpl.java +++ /dev/null @@ -1,84 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2019, 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.job.engine.queue.jbatch; - -import org.eclipse.kapua.commons.model.AbstractKapuaUpdatableEntityCreator; -import org.eclipse.kapua.job.engine.queue.QueuedJobExecution; -import org.eclipse.kapua.job.engine.queue.QueuedJobExecutionCreator; -import org.eclipse.kapua.job.engine.queue.QueuedJobExecutionStatus; -import org.eclipse.kapua.model.id.KapuaId; - -/** - * {@link QueuedJobExecutionCreator} implementation - * - * @since 1.0.0 - */ -public class QueuedJobExecutionCreatorImpl extends AbstractKapuaUpdatableEntityCreator implements QueuedJobExecutionCreator { - - private static final long serialVersionUID = 3119071638220738358L; - - private KapuaId jobId; - private KapuaId jobExecutionId; - private KapuaId waitForJobExecutionId; - private QueuedJobExecutionStatus status; - - /** - * Constructor. - * - * @param scopeId The scope {@link KapuaId} to set into the {@link QueuedJobExecutionCreator}. - * @since 1.1.0 - */ - protected QueuedJobExecutionCreatorImpl(KapuaId scopeId) { - super(scopeId); - } - - @Override - public KapuaId getJobId() { - return jobId; - } - - @Override - public void setJobId(KapuaId jobId) { - this.jobId = jobId; - } - - @Override - public KapuaId getJobExecutionId() { - return jobExecutionId; - } - - @Override - public void setJobExecutionId(KapuaId jobExecutionId) { - this.jobExecutionId = jobExecutionId; - } - - @Override - public KapuaId getWaitForJobExecutionId() { - return waitForJobExecutionId; - } - - @Override - public void setWaitForJobExecutionId(KapuaId waitForJobExecutionId) { - this.waitForJobExecutionId = waitForJobExecutionId; - } - - @Override - public QueuedJobExecutionStatus getStatus() { - return status; - } - - @Override - public void setStatus(QueuedJobExecutionStatus status) { - this.status = status; - } -} diff --git a/job-engine/jbatch/src/main/java/org/eclipse/kapua/job/engine/queue/jbatch/QueuedJobExecutionFactoryImpl.java b/job-engine/jbatch/src/main/java/org/eclipse/kapua/job/engine/queue/jbatch/QueuedJobExecutionFactoryImpl.java index 86d3c73800a..9e0db656e1a 100644 --- a/job-engine/jbatch/src/main/java/org/eclipse/kapua/job/engine/queue/jbatch/QueuedJobExecutionFactoryImpl.java +++ b/job-engine/jbatch/src/main/java/org/eclipse/kapua/job/engine/queue/jbatch/QueuedJobExecutionFactoryImpl.java @@ -16,7 +16,6 @@ import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.job.engine.queue.QueuedJobExecution; -import org.eclipse.kapua.job.engine.queue.QueuedJobExecutionCreator; import org.eclipse.kapua.job.engine.queue.QueuedJobExecutionFactory; import org.eclipse.kapua.model.id.KapuaId; @@ -33,11 +32,6 @@ public QueuedJobExecution newEntity(KapuaId scopeId) { return new QueuedJobExecutionImpl(scopeId); } - @Override - public QueuedJobExecutionCreator newCreator(KapuaId scopeId) { - return new QueuedJobExecutionCreatorImpl(scopeId); - } - @Override public QueuedJobExecution clone(QueuedJobExecution queuedJobExecution) { try { diff --git a/qa/integration/src/test/java/org/eclipse/kapua/integration/misc/AccessInfoCreatorImplTest.java b/qa/integration/src/test/java/org/eclipse/kapua/integration/misc/AccessInfoCreatorTest.java similarity index 87% rename from qa/integration/src/test/java/org/eclipse/kapua/integration/misc/AccessInfoCreatorImplTest.java rename to qa/integration/src/test/java/org/eclipse/kapua/integration/misc/AccessInfoCreatorTest.java index d8b56216200..a57eed88147 100644 --- a/qa/integration/src/test/java/org/eclipse/kapua/integration/misc/AccessInfoCreatorImplTest.java +++ b/qa/integration/src/test/java/org/eclipse/kapua/integration/misc/AccessInfoCreatorTest.java @@ -12,12 +12,12 @@ *******************************************************************************/ package org.eclipse.kapua.integration.misc; -import org.eclipse.kapua.locator.KapuaLocator; +import java.util.HashSet; +import java.util.Set; + import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.qa.markers.junit.JUnitTests; import org.eclipse.kapua.service.authorization.access.AccessInfoCreator; -import org.eclipse.kapua.service.authorization.access.AccessInfoFactory; -import org.eclipse.kapua.service.authorization.access.shiro.AccessInfoCreatorImpl; import org.eclipse.kapua.service.authorization.permission.Permission; import org.junit.Assert; import org.junit.Before; @@ -25,23 +25,17 @@ import org.junit.experimental.categories.Category; import org.mockito.Mockito; -import java.util.HashSet; -import java.util.Set; - - @Category(JUnitTests.class) -public class AccessInfoCreatorImplTest { +public class AccessInfoCreatorTest { - AccessInfoFactory accessInfoFactory; AccessInfoCreator accessInfoCreator; Set roleId; Set setPermission; - AccessInfoCreatorImpl accessInfoCreatorImpl1, accessInfoCreatorImpl2; + AccessInfoCreator accessInfoCreatorImpl1, accessInfoCreatorImpl2; @Before public void initialize() { - accessInfoFactory = KapuaLocator.getInstance().getFactory(AccessInfoFactory.class); - accessInfoCreator = accessInfoFactory.newCreator(KapuaId.ONE); + accessInfoCreator = new AccessInfoCreator(KapuaId.ONE); roleId = new HashSet<>(); setPermission = new HashSet<>(); roleId.add(KapuaId.ANY); @@ -51,8 +45,8 @@ public void initialize() { accessInfoCreator.setRoleIds(roleId); accessInfoCreator.setPermissions(setPermission); - accessInfoCreatorImpl1 = new AccessInfoCreatorImpl(accessInfoCreator); - accessInfoCreatorImpl2 = new AccessInfoCreatorImpl(KapuaId.ONE); + accessInfoCreatorImpl1 = new AccessInfoCreator(accessInfoCreator); + accessInfoCreatorImpl2 = new AccessInfoCreator(KapuaId.ONE); } @Test @@ -65,7 +59,7 @@ public void accessInfoCreatorImplAccessInfoCreatorParameterTest() { @Test(expected = NullPointerException.class) public void accessInfoCreatorImplNullAccessInfoCreatorParameterTest() { - accessInfoCreatorImpl1 = new AccessInfoCreatorImpl((AccessInfoCreator) null); + accessInfoCreatorImpl1 = new AccessInfoCreator((AccessInfoCreator) null); } @Test @@ -78,7 +72,7 @@ public void accessInfoCreatorScopeIdParameterTest() { @Test public void accessInfoCreatorNullScopeIdParameterTest() { - accessInfoCreatorImpl2 = new AccessInfoCreatorImpl((KapuaId) null); + accessInfoCreatorImpl2 = new AccessInfoCreator((KapuaId) null); Assert.assertNull("Null expected.", accessInfoCreatorImpl2.getScopeId()); Assert.assertNull("Null expected.", accessInfoCreatorImpl2.getUserId()); diff --git a/qa/integration/src/test/java/org/eclipse/kapua/integration/misc/EventStoreServiceImplTest.java b/qa/integration/src/test/java/org/eclipse/kapua/integration/misc/EventStoreServiceImplTest.java index 9a0e6bcf552..095fa1948a2 100644 --- a/qa/integration/src/test/java/org/eclipse/kapua/integration/misc/EventStoreServiceImplTest.java +++ b/qa/integration/src/test/java/org/eclipse/kapua/integration/misc/EventStoreServiceImplTest.java @@ -12,11 +12,12 @@ *******************************************************************************/ package org.eclipse.kapua.integration.misc; +import java.math.BigInteger; + import org.eclipse.kapua.commons.model.id.KapuaEid; import org.eclipse.kapua.commons.service.event.store.api.EventStoreFactory; import org.eclipse.kapua.commons.service.event.store.api.EventStoreRecordCreator; import org.eclipse.kapua.commons.service.event.store.api.EventStoreRecordRepository; -import org.eclipse.kapua.commons.service.event.store.internal.EventStoreRecordCreatorImpl; import org.eclipse.kapua.commons.service.event.store.internal.EventStoreServiceImpl; import org.eclipse.kapua.qa.markers.junit.JUnitTests; import org.eclipse.kapua.service.authorization.AuthorizationService; @@ -27,9 +28,6 @@ import org.junit.experimental.categories.Category; import org.mockito.Mockito; -import java.math.BigInteger; - - @Category(JUnitTests.class) //TODO: rewrite this public class EventStoreServiceImplTest { @@ -42,7 +40,7 @@ public void createTest() { Mockito.mock(TxManager.class), Mockito.mock(EventStoreFactory.class), Mockito.mock(EventStoreRecordRepository.class)); - EventStoreRecordCreator[] creator = {null, new EventStoreRecordCreatorImpl(new KapuaEid(BigInteger.ONE))}; + EventStoreRecordCreator[] creator = { null, new EventStoreRecordCreator(new KapuaEid(BigInteger.ONE)) }; UnsupportedOperationException unsupportedOperationException = new UnsupportedOperationException(); for (EventStoreRecordCreator eventStoreRecordCreator : creator) { diff --git a/qa/integration/src/test/java/org/eclipse/kapua/integration/misc/RolePermissionFactoryTest.java b/qa/integration/src/test/java/org/eclipse/kapua/integration/misc/RolePermissionFactoryTest.java index e30f56787a6..9d413cf23b7 100644 --- a/qa/integration/src/test/java/org/eclipse/kapua/integration/misc/RolePermissionFactoryTest.java +++ b/qa/integration/src/test/java/org/eclipse/kapua/integration/misc/RolePermissionFactoryTest.java @@ -18,7 +18,6 @@ import org.eclipse.kapua.qa.markers.junit.JUnitTests; import org.eclipse.kapua.service.authorization.permission.shiro.PermissionImpl; import org.eclipse.kapua.service.authorization.role.RolePermission; -import org.eclipse.kapua.service.authorization.role.RolePermissionCreator; import org.eclipse.kapua.service.authorization.role.shiro.RolePermissionFactoryImpl; import org.junit.Assert; import org.junit.Before; @@ -64,18 +63,6 @@ public void newEntityNullTest() { Assert.assertNull("Null expected.", rolePermissionFactoryImpl.newEntity(null).getScopeId()); } - @Test - public void newCreatorTest() { - Assert.assertTrue("True expected.", rolePermissionFactoryImpl.newCreator(scopeId) instanceof RolePermissionCreator); - Assert.assertEquals("Expected and actual values should be the same.", scopeId, rolePermissionFactoryImpl.newCreator(scopeId).getScopeId()); - } - - @Test - public void newCreatorNullTest() { - Assert.assertTrue("True expected.", rolePermissionFactoryImpl.newCreator(null) instanceof RolePermissionCreator); - Assert.assertNull("Null expected.", rolePermissionFactoryImpl.newCreator(null).getScopeId()); - } - @Test public void cloneTest() { RolePermission resultRolePermission = rolePermissionFactoryImpl.clone(rolePermission); diff --git a/qa/integration/src/test/java/org/eclipse/kapua/integration/service/datastoreJunit/MessageStoreServiceSslTest.java b/qa/integration/src/test/java/org/eclipse/kapua/integration/service/datastoreJunit/MessageStoreServiceSslTest.java index f47b426fdf4..75b24bb123f 100644 --- a/qa/integration/src/test/java/org/eclipse/kapua/integration/service/datastoreJunit/MessageStoreServiceSslTest.java +++ b/qa/integration/src/test/java/org/eclipse/kapua/integration/service/datastoreJunit/MessageStoreServiceSslTest.java @@ -192,7 +192,7 @@ private void storeMessage(String semanticTopic) throws InterruptedException, Kap Account account = getTestAccountCreator(adminScopeId); String clientId = String.format("device-%d", new Date().getTime()); - DeviceCreator deviceCreator = deviceFactory.newCreator(account.getId(), clientId); + DeviceCreator deviceCreator = new DeviceCreator(account.getId(), clientId); Device device = deviceRegistryService.create(deviceCreator); // leave the message index by as default (DEVICE_TIMESTAMP) diff --git a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/EndpointInfos.java b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/EndpointInfos.java index 164fb0a7aeb..cf4d82473a9 100644 --- a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/EndpointInfos.java +++ b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/EndpointInfos.java @@ -26,7 +26,6 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import com.google.common.base.Strings; import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.app.api.core.model.CountResult; import org.eclipse.kapua.app.api.core.model.EntityId; @@ -43,6 +42,8 @@ import org.eclipse.kapua.service.endpoint.EndpointInfoQuery; import org.eclipse.kapua.service.endpoint.EndpointInfoService; +import com.google.common.base.Strings; + @Path("{scopeId}/endpointInfos") public class EndpointInfos extends AbstractKapuaResource { @@ -54,17 +55,22 @@ public class EndpointInfos extends AbstractKapuaResource { /** * Gets the {@link EndpointInfo} list in the scope. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param usage The {@link EndpointInfo} usage to filter results - * @param offset The result set offset. - * @param limit The result set limit. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param usage + * The {@link EndpointInfo} usage to filter results + * @param offset + * The result set offset. + * @param limit + * The result set limit. * @return The {@link EndpointInfoListResult} of all the endpointInfos associated to the current selected scope. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @GET - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public EndpointInfoListResult simpleQuery( @PathParam("scopeId") ScopeId scopeId, @QueryParam("usage") String usage, @@ -75,7 +81,7 @@ public EndpointInfoListResult simpleQuery( @QueryParam("sortDir") @DefaultValue("ASCENDING") SortOrder sortDir, @QueryParam("offset") @DefaultValue("0") int offset, @QueryParam("limit") @DefaultValue("50") int limit) throws KapuaException { - EndpointInfoQuery query = endpointInfoFactory.newQuery(scopeId); + EndpointInfoQuery query = new EndpointInfoQuery(scopeId); AndPredicate andPredicate = query.andPredicate(); if (!Strings.isNullOrEmpty(usage)) { @@ -99,17 +105,20 @@ public EndpointInfoListResult simpleQuery( /** * Queries the results with the given {@link EndpointInfoQuery} parameter. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param query The {@link EndpointInfoQuery} to use to filter results. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param query + * The {@link EndpointInfoQuery} to use to filter results. * @return The {@link EndpointInfoListResult} of all the result matching the given {@link EndpointInfoQuery} parameter. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @POST @Path("_query") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public EndpointInfoListResult query( @PathParam("scopeId") ScopeId scopeId, @QueryParam("endpointType") @DefaultValue(EndpointInfo.ENDPOINT_TYPE_RESOURCE) String endpointType, @@ -122,17 +131,20 @@ public EndpointInfoListResult query( /** * Counts the results with the given {@link EndpointInfoQuery} parameter. * - * @param scopeId The {@link ScopeId} in which to search results. - * @param query The {@link EndpointInfoQuery} to use to filter results. + * @param scopeId + * The {@link ScopeId} in which to search results. + * @param query + * The {@link EndpointInfoQuery} to use to filter results. * @return The count of all the result matching the given {@link EndpointInfoQuery} parameter. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @POST @Path("_count") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public CountResult count( @PathParam("scopeId") ScopeId scopeId, @QueryParam("endpointType") @DefaultValue(EndpointInfo.ENDPOINT_TYPE_RESOURCE) String endpointType, @@ -143,19 +155,21 @@ public CountResult count( } /** - * Creates a new EndpointInfo based on the information provided in EndpointInfoCreator - * parameter. + * Creates a new EndpointInfo based on the information provided in EndpointInfoCreator parameter. * - * @param scopeId The {@link ScopeId} in which to create the {@link EndpointInfo} - * @param endpointInfoCreator Provides the information for the new {@link EndpointInfo} to be created. + * @param scopeId + * The {@link ScopeId} in which to create the {@link EndpointInfo} + * @param endpointInfoCreator + * Provides the information for the new {@link EndpointInfo} to be created. * @return The newly created {@link EndpointInfo} object. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @POST - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public Response create( @PathParam("scopeId") ScopeId scopeId, EndpointInfoCreator endpointInfoCreator) throws KapuaException { @@ -167,39 +181,46 @@ public Response create( /** * Returns the EndpointInfo specified by the "endpointInfoId" path parameter. * - * @param scopeId The {@link ScopeId} of the requested {@link EndpointInfo}. - * @param endpointInfoId The id of the requested EndpointInfo. + * @param scopeId + * The {@link ScopeId} of the requested {@link EndpointInfo}. + * @param endpointInfoId + * The id of the requested EndpointInfo. * @return The requested EndpointInfo object. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @GET @Path("{endpointInfoId}") - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public EndpointInfo find( @PathParam("scopeId") ScopeId scopeId, @PathParam("endpointInfoId") EntityId endpointInfoId) throws KapuaException { EndpointInfo endpointInfo = endpointInfoService.find(scopeId, endpointInfoId); - return returnNotNullEntity(endpointInfo,EndpointInfo.TYPE, endpointInfoId); + return returnNotNullEntity(endpointInfo, EndpointInfo.TYPE, endpointInfoId); } /** * Updates the EndpointInfo based on the information provided in the EndpointInfo parameter. * - * @param scopeId The ScopeId of the requested {@link EndpointInfo}. - * @param endpointInfoId The id of the requested {@link EndpointInfo} - * @param endpointInfo The modified EndpointInfo whose attributed need to be updated. + * @param scopeId + * The ScopeId of the requested {@link EndpointInfo}. + * @param endpointInfoId + * The id of the requested {@link EndpointInfo} + * @param endpointInfo + * The modified EndpointInfo whose attributed need to be updated. * @return The updated endpointInfo. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @PUT @Path("{endpointInfoId}") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public EndpointInfo update( @PathParam("scopeId") ScopeId scopeId, @PathParam("endpointInfoId") EntityId endpointInfoId, @@ -213,10 +234,13 @@ public EndpointInfo update( /** * Deletes the EndpointInfo specified by the "endpointInfoId" path parameter. * - * @param scopeId The ScopeId of the requested {@link EndpointInfo}. - * @param endpointInfoId The id of the EndpointInfo to be deleted. + * @param scopeId + * The ScopeId of the requested {@link EndpointInfo}. + * @param endpointInfoId + * The id of the EndpointInfo to be deleted. * @return HTTP 200 if operation has completed successfully. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ diff --git a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/UserMfa.java b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/UserMfa.java index 634d343fe61..e2d8090c5fd 100644 --- a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/UserMfa.java +++ b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/UserMfa.java @@ -12,16 +12,6 @@ *******************************************************************************/ package org.eclipse.kapua.app.api.resources.v1.resources; -import org.eclipse.kapua.KapuaEntityNotFoundException; -import org.eclipse.kapua.KapuaException; -import org.eclipse.kapua.app.api.core.resources.AbstractKapuaResource; -import org.eclipse.kapua.commons.security.KapuaSecurityUtils; -import org.eclipse.kapua.service.KapuaService; -import org.eclipse.kapua.service.authentication.credential.mfa.MfaOption; -import org.eclipse.kapua.service.authentication.credential.mfa.MfaOptionCreator; -import org.eclipse.kapua.service.authentication.credential.mfa.MfaOptionService; -import org.eclipse.kapua.service.authentication.credential.mfa.shiro.MfaOptionCreatorImpl; - import javax.inject.Inject; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; @@ -32,6 +22,15 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; +import org.eclipse.kapua.KapuaEntityNotFoundException; +import org.eclipse.kapua.KapuaException; +import org.eclipse.kapua.app.api.core.resources.AbstractKapuaResource; +import org.eclipse.kapua.commons.security.KapuaSecurityUtils; +import org.eclipse.kapua.service.KapuaService; +import org.eclipse.kapua.service.authentication.credential.mfa.MfaOption; +import org.eclipse.kapua.service.authentication.credential.mfa.MfaOptionCreator; +import org.eclipse.kapua.service.authentication.credential.mfa.MfaOptionService; + @Path("user") public class UserMfa extends AbstractKapuaResource { @@ -42,16 +41,17 @@ public class UserMfa extends AbstractKapuaResource { * Creates a new {@link MfaOption} for the user specified by the "userId" path parameter. * * @return The newly created {@link MfaOption} object. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 2.0.0 */ @POST @Path("mfa") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public Response activateMfa() throws KapuaException { - MfaOptionCreator mfaOptionCreator = new MfaOptionCreatorImpl(KapuaSecurityUtils.getSession().getScopeId()); + MfaOptionCreator mfaOptionCreator = new MfaOptionCreator(KapuaSecurityUtils.getSession().getScopeId()); mfaOptionCreator.setUserId(KapuaSecurityUtils.getSession().getUserId()); return returnCreated(KapuaSecurityUtils.doPrivileged(() -> mfaOptionService.create(mfaOptionCreator))); @@ -61,12 +61,13 @@ public Response activateMfa() throws KapuaException { * Returns the {@link MfaOption} of the user specified by the "userId" path parameter. * * @return The requested {@link MfaOption} object. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.4.0 */ @GET @Path("mfa") - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public MfaOption findMfa() throws KapuaException { MfaOption mfaOption = KapuaSecurityUtils.doPrivileged(() -> mfaOptionService.findByUserId(KapuaSecurityUtils.getSession().getScopeId(), KapuaSecurityUtils.getSession().getUserId())); if (mfaOption == null) { @@ -79,7 +80,8 @@ public MfaOption findMfa() throws KapuaException { * Deletes the {@link MfaOption} of the user specified by the "userId" path parameter. * * @return HTTP 200 if operation has completed successfully. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.4.0 */ @DELETE @@ -94,13 +96,14 @@ public Response deleteMfa() throws KapuaException { * Disable trusted machine for a given {@link MfaOption}. * * @return HTTP 200 if operation has completed successfully. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.4.0 */ @DELETE @Path("mfa/disableTrust") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public Response disableTrust() throws KapuaException { KapuaSecurityUtils.doPrivileged(() -> mfaOptionService.disableTrustByUserId(KapuaSecurityUtils.getSession().getScopeId(), KapuaSecurityUtils.getSession().getUserId())); return returnNoContent(); diff --git a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/UsersMfa.java b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/UsersMfa.java index 2129f3da467..51fe584d0ba 100644 --- a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/UsersMfa.java +++ b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/UsersMfa.java @@ -12,16 +12,6 @@ *******************************************************************************/ package org.eclipse.kapua.app.api.resources.v1.resources; -import org.eclipse.kapua.KapuaEntityNotFoundException; -import org.eclipse.kapua.KapuaException; -import org.eclipse.kapua.app.api.core.model.EntityId; -import org.eclipse.kapua.app.api.core.model.ScopeId; -import org.eclipse.kapua.app.api.core.resources.AbstractKapuaResource; -import org.eclipse.kapua.service.KapuaService; -import org.eclipse.kapua.service.authentication.credential.mfa.MfaOption; -import org.eclipse.kapua.service.authentication.credential.mfa.MfaOptionService; -import org.eclipse.kapua.service.authentication.credential.mfa.shiro.MfaOptionCreatorImpl; - import javax.inject.Inject; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; @@ -33,6 +23,16 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; +import org.eclipse.kapua.KapuaEntityNotFoundException; +import org.eclipse.kapua.KapuaException; +import org.eclipse.kapua.app.api.core.model.EntityId; +import org.eclipse.kapua.app.api.core.model.ScopeId; +import org.eclipse.kapua.app.api.core.resources.AbstractKapuaResource; +import org.eclipse.kapua.service.KapuaService; +import org.eclipse.kapua.service.authentication.credential.mfa.MfaOption; +import org.eclipse.kapua.service.authentication.credential.mfa.MfaOptionCreator; +import org.eclipse.kapua.service.authentication.credential.mfa.MfaOptionService; + @Path("{scopeId}/users") public class UsersMfa extends AbstractKapuaResource { @@ -42,36 +42,42 @@ public class UsersMfa extends AbstractKapuaResource { /** * Creates a new {@link MfaOption} for the user specified by the "userId" path parameter. * - * @param scopeId The {@link ScopeId} in which to create the {@link MfaOption} - * @param userId The {@link EntityId} of the User to which the {@link MfaOption} belongs + * @param scopeId + * The {@link ScopeId} in which to create the {@link MfaOption} + * @param userId + * The {@link EntityId} of the User to which the {@link MfaOption} belongs * @return The newly created {@link MfaOption} object. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.4.0 * @deprecated since 2.0.0 - use POST {scopeId}/user/mfa instead (see {@link UserMfa}) */ @POST @Path("{userId}/mfa") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) @Deprecated public Response createMfa( @PathParam("scopeId") ScopeId scopeId, @PathParam("userId") EntityId userId) throws KapuaException { - return returnCreated(mfaOptionService.create(new MfaOptionCreatorImpl(scopeId, userId))); + return returnCreated(mfaOptionService.create(new MfaOptionCreator(scopeId, userId))); } /** * Returns the {@link MfaOption} of the user specified by the "userId" path parameter. * - * @param scopeId The {@link ScopeId} of the requested {@link MfaOption} - * @param userId The {@link EntityId} of the User to which the {@link MfaOption} belongs + * @param scopeId + * The {@link ScopeId} of the requested {@link MfaOption} + * @param userId + * The {@link EntityId} of the User to which the {@link MfaOption} belongs * @return The requested {@link MfaOption} object. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.4.0 */ @GET @Path("{userId}/mfa") - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public MfaOption findMfa( @PathParam("scopeId") ScopeId scopeId, @PathParam("userId") EntityId userId) throws KapuaException { @@ -86,10 +92,13 @@ public MfaOption findMfa( /** * Deletes the {@link MfaOption} of the user specified by the "userId" path parameter. * - * @param scopeId The {@link ScopeId} of the requested {@link MfaOption} - * @param userId The {@link EntityId} of the User to which the {@link MfaOption} belongs + * @param scopeId + * The {@link ScopeId} of the requested {@link MfaOption} + * @param userId + * The {@link EntityId} of the User to which the {@link MfaOption} belongs * @return HTTP 200 if operation has completed successfully. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.4.0 */ @DELETE @@ -105,16 +114,19 @@ public Response deleteMfa( /** * Disable trusted machine for a given {@link MfaOption}. * - * @param scopeId The ScopeId of the requested {@link MfaOption}. - * @param userId The {@link EntityId} of the User to which the {@link MfaOption} belongs + * @param scopeId + * The ScopeId of the requested {@link MfaOption}. + * @param userId + * The {@link EntityId} of the User to which the {@link MfaOption} belongs * @return HTTP 200 if operation has completed successfully. - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.4.0 */ @DELETE @Path("{userId}/mfa/disableTrust") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public Response disableTrust( @PathParam("scopeId") ScopeId scopeId, @PathParam("userId") EntityId userId) throws KapuaException { diff --git a/service/account/api/src/main/java/org/eclipse/kapua/service/account/AccountCreator.java b/service/account/api/src/main/java/org/eclipse/kapua/service/account/AccountCreator.java index 2d410b5ba83..774837ce057 100644 --- a/service/account/api/src/main/java/org/eclipse/kapua/service/account/AccountCreator.java +++ b/service/account/api/src/main/java/org/eclipse/kapua/service/account/AccountCreator.java @@ -12,10 +12,7 @@ *******************************************************************************/ package org.eclipse.kapua.service.account; -import org.eclipse.kapua.model.KapuaEntityCreator; -import org.eclipse.kapua.model.KapuaNamedEntityCreator; -import org.eclipse.kapua.model.xml.DateXmlAdapter; -import org.eclipse.kapua.service.account.xml.AccountXmlRegistry; +import java.util.Date; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; @@ -23,7 +20,11 @@ import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; -import java.util.Date; + +import org.eclipse.kapua.model.KapuaEntityCreator; +import org.eclipse.kapua.model.KapuaNamedEntityCreator; +import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.model.xml.DateXmlAdapter; /** * {@link Account} {@link KapuaEntityCreator} definition. @@ -46,9 +47,44 @@ "organizationStateProvinceCounty", "organizationCountry", "expirationDate" - }, - factoryClass = AccountXmlRegistry.class, factoryMethod = "newAccountCreator") -public interface AccountCreator extends KapuaNamedEntityCreator { + }) +public class AccountCreator extends KapuaNamedEntityCreator { + + private static final long serialVersionUID = -2460883485294616032L; + + private String organizationName; + private String organizationPersonName; + private String organizationEmail; + private String organizationPhoneNumber; + private String organizationAddressLine1; + private String organizationAddressLine2; + private String organizationAddressLine3; + private String organizationCity; + private String organizationZipPostCode; + private String organizationStateProvinceCounty; + private String organizationCountry; + + private Date expirationDate; + + public AccountCreator() { + } + + public AccountCreator(KapuaId scopeId) { + super(scopeId); + } + + /** + * Constructor. + * + * @param scopeId + * The {@link AccountCreator#getScopeId()}. + * @param name + * The {@link AccountCreator#getName()}. + * @since 1.0.0 + */ + public AccountCreator(KapuaId scopeId, String name) { + super(scopeId, name); + } /** * Gets the {@link Organization#getName()}. @@ -57,15 +93,20 @@ public interface AccountCreator extends KapuaNamedEntityCreator { * @since 1.0.0 */ @XmlElement(name = "organizationName") - String getOrganizationName(); + public String getOrganizationName() { + return organizationName; + } /** * Sets the {@link Organization#getName()}. * - * @param organizationName The {@link Organization#getName()}. + * @param organizationName + * The {@link Organization#getName()}. * @since 1.0.0 */ - void setOrganizationName(String organizationName); + public void setOrganizationName(String organizationName) { + this.organizationName = organizationName; + } /** * Gets the {@link Organization#getPersonName()}. @@ -74,15 +115,20 @@ public interface AccountCreator extends KapuaNamedEntityCreator { * @since 1.0.0 */ @XmlElement(name = "organizationPersonName") - String getOrganizationPersonName(); + public String getOrganizationPersonName() { + return organizationPersonName; + } /** * Sets the {@link Organization#getPersonName()}. * - * @param organizationPersonName The {@link Organization#getPersonName()}. + * @param organizationPersonName + * The {@link Organization#getPersonName()}. * @since 1.0.0 */ - void setOrganizationPersonName(String organizationPersonName); + public void setOrganizationPersonName(String organizationPersonName) { + this.organizationPersonName = organizationPersonName; + } /** * Gets the {@link Organization#getEmail()}. @@ -91,15 +137,20 @@ public interface AccountCreator extends KapuaNamedEntityCreator { * @since 1.0.0 */ @XmlElement(name = "organizationEmail") - String getOrganizationEmail(); + public String getOrganizationEmail() { + return organizationEmail; + } /** * Sets the {@link Organization#getEmail()}. * - * @param organizationEmail The {@link Organization#getEmail()}. + * @param organizationEmail + * The {@link Organization#getEmail()}. * @since 1.0.0 */ - void setOrganizationEmail(String organizationEmail); + public void setOrganizationEmail(String organizationEmail) { + this.organizationEmail = organizationEmail; + } /** * Gets the {@link Organization#getPhoneNumber()}. @@ -108,15 +159,20 @@ public interface AccountCreator extends KapuaNamedEntityCreator { * @since 1.0.0 */ @XmlElement(name = "organizationPhoneNumber") - String getOrganizationPhoneNumber(); + public String getOrganizationPhoneNumber() { + return organizationPhoneNumber; + } /** * Sets the {@link Organization#getPhoneNumber()}. * - * @param organizationPhoneNumber The {@link Organization#getPhoneNumber()}. + * @param organizationPhoneNumber + * The {@link Organization#getPhoneNumber()}. * @since 1.0.0 */ - void setOrganizationPhoneNumber(String organizationPhoneNumber); + public void setOrganizationPhoneNumber(String organizationPhoneNumber) { + this.organizationPhoneNumber = organizationPhoneNumber; + } /** * Gets the {@link Organization#getAddressLine1()}. @@ -125,15 +181,20 @@ public interface AccountCreator extends KapuaNamedEntityCreator { * @since 1.0.0 */ @XmlElement(name = "organizationAddressLine1") - String getOrganizationAddressLine1(); + public String getOrganizationAddressLine1() { + return organizationAddressLine1; + } /** * Sets the {@link Organization#getAddressLine1()}. * - * @param organizationAddressLine1 The {@link Organization#getAddressLine1()}. + * @param organizationAddressLine1 + * The {@link Organization#getAddressLine1()}. * @since 1.0.0 */ - void setOrganizationAddressLine1(String organizationAddressLine1); + public void setOrganizationAddressLine1(String organizationAddressLine1) { + this.organizationAddressLine1 = organizationAddressLine1; + } /** * Gets the {@link Organization#getAddressLine2()}. @@ -142,32 +203,42 @@ public interface AccountCreator extends KapuaNamedEntityCreator { * @since 1.0.0 */ @XmlElement(name = "organizationAddressLine2") - String getOrganizationAddressLine2(); + public String getOrganizationAddressLine2() { + return organizationAddressLine2; + } /** * Sets the {@link Organization#getAddressLine2()}. * - * @param organizationAddressLine2 The {@link Organization#getAddressLine2()}. + * @param organizationAddressLine2 + * The {@link Organization#getAddressLine2()}. * @since 1.0.0 */ - void setOrganizationAddressLine2(String organizationAddressLine2); + public void setOrganizationAddressLine2(String organizationAddressLine2) { + this.organizationAddressLine2 = organizationAddressLine2; + } - /*3 + /** * Gets the {@link Organization#getAddressLine3()}. * * @return The {@link Organization#getAddressLine3()}. * @since 1.0.0 */ @XmlElement(name = "organizationAddressLine3") - String getOrganizationAddressLine3(); + public String getOrganizationAddressLine3() { + return organizationAddressLine3; + } /** * Sets the {@link Organization#getAddressLine3()}. * - * @param organizationAddressLine3 The {@link Organization#getAddressLine3()}. + * @param organizationAddressLine3 + * The {@link Organization#getAddressLine3()}. * @since 1.0.0 */ - void setOrganizationAddressLine3(String organizationAddressLine3); + public void setOrganizationAddressLine3(String organizationAddressLine3) { + this.organizationAddressLine3 = organizationAddressLine3; + } /** * Gets the {@link Organization#getCity()}. @@ -176,15 +247,20 @@ public interface AccountCreator extends KapuaNamedEntityCreator { * @since 1.0.0 */ @XmlElement(name = "organizationCity") - String getOrganizationCity(); + public String getOrganizationCity() { + return organizationCity; + } /** * Sets the {@link Organization#getCity()}. * - * @param organizationCity The {@link Organization#getCity()}. + * @param organizationCity + * The {@link Organization#getCity()}. * @since 1.0.0 */ - void setOrganizationCity(String organizationCity); + public void setOrganizationCity(String organizationCity) { + this.organizationCity = organizationCity; + } /** * Gets the {@link Organization#getZipPostCode()}. @@ -193,15 +269,20 @@ public interface AccountCreator extends KapuaNamedEntityCreator { * @since 1.0.0 */ @XmlElement(name = "organizationZipPostCode") - String getOrganizationZipPostCode(); + public String getOrganizationZipPostCode() { + return organizationZipPostCode; + } /** * Sets the {@link Organization#getZipPostCode()}. * - * @param organizationZipPostCode The {@link Organization#getZipPostCode()}. + * @param organizationZipPostCode + * The {@link Organization#getZipPostCode()}. * @since 1.0.0 */ - void setOrganizationZipPostCode(String organizationZipPostCode); + public void setOrganizationZipPostCode(String organizationZipPostCode) { + this.organizationZipPostCode = organizationZipPostCode; + } /** * Gets the {@link Organization#getStateProvinceCounty()}. @@ -210,15 +291,20 @@ public interface AccountCreator extends KapuaNamedEntityCreator { * @since 1.0.0 */ @XmlElement(name = "organizationStateProvinceCounty") - String getOrganizationStateProvinceCounty(); + public String getOrganizationStateProvinceCounty() { + return this.organizationStateProvinceCounty; + } /** * Sets the {@link Organization#getStateProvinceCounty()}. * - * @param organizationStateProvinceCounty The {@link Organization#getStateProvinceCounty()}. + * @param organizationStateProvinceCounty + * The {@link Organization#getStateProvinceCounty()}. * @since 1.0.0 */ - void setOrganizationStateProvinceCounty(String organizationStateProvinceCounty); + public void setOrganizationStateProvinceCounty(String organizationStateProvinceCounty) { + this.organizationStateProvinceCounty = organizationStateProvinceCounty; + } /** * Gets the {@link Organization#getCountry()}. @@ -227,15 +313,20 @@ public interface AccountCreator extends KapuaNamedEntityCreator { * @since 1.0.0 */ @XmlElement(name = "organizationCountry") - String getOrganizationCountry(); + public String getOrganizationCountry() { + return organizationCountry; + } /** * Sets the {@link Organization#getCountry()}. * - * @param organizationCountry The {@link Organization#getCountry()}. + * @param organizationCountry + * The {@link Organization#getCountry()}. * @since 1.0.0 */ - void setOrganizationCountry(String organizationCountry); + public void setOrganizationCountry(String organizationCountry) { + this.organizationCountry = organizationCountry; + } /** * Gets the expiration date. @@ -245,13 +336,18 @@ public interface AccountCreator extends KapuaNamedEntityCreator { */ @XmlElement(name = "expirationDate") @XmlJavaTypeAdapter(DateXmlAdapter.class) - Date getExpirationDate(); + public Date getExpirationDate() { + return expirationDate; + } /** * Sets the expiration date. * - * @param expirationDate The expiration date. + * @param expirationDate + * The expiration date. * @since 1.0.0 */ - void setExpirationDate(Date expirationDate); + public void setExpirationDate(Date expirationDate) { + this.expirationDate = expirationDate; + } } diff --git a/service/account/api/src/main/java/org/eclipse/kapua/service/account/AccountFactory.java b/service/account/api/src/main/java/org/eclipse/kapua/service/account/AccountFactory.java index 5abbe9cee1c..fed0b991b40 100644 --- a/service/account/api/src/main/java/org/eclipse/kapua/service/account/AccountFactory.java +++ b/service/account/api/src/main/java/org/eclipse/kapua/service/account/AccountFactory.java @@ -13,7 +13,6 @@ package org.eclipse.kapua.service.account; import org.eclipse.kapua.model.KapuaEntityFactory; -import org.eclipse.kapua.model.id.KapuaId; /** * {@link Account} {@link KapuaEntityFactory} definition. @@ -21,21 +20,7 @@ * @see KapuaEntityFactory * @since 1.0.0 */ -public interface AccountFactory extends KapuaEntityFactory { - - /** - * Instantiates a new {@link AccountCreator} with the given name. - * - * @param scopeId - * The scope {@link KapuaId} to set in the {@link AccountCreator} - * @param name - * The name to set in the {@link AccountCreator} - * @return The newly instantiated {@link AccountCreator} - * @since 1.0.0 - * @deprecated Since 1.6.0. Please make use of {@link #newCreator(KapuaId)} and then use {@link AccountCreator#setName(String)}. - */ - @Deprecated - AccountCreator newCreator(KapuaId scopeId, String name); +public interface AccountFactory extends KapuaEntityFactory { /** * Instantiates a new {@link Organization}. diff --git a/service/account/api/src/main/java/org/eclipse/kapua/service/account/xml/AccountXmlRegistry.java b/service/account/api/src/main/java/org/eclipse/kapua/service/account/xml/AccountXmlRegistry.java index 52b5bae1095..1b673ec9133 100644 --- a/service/account/api/src/main/java/org/eclipse/kapua/service/account/xml/AccountXmlRegistry.java +++ b/service/account/api/src/main/java/org/eclipse/kapua/service/account/xml/AccountXmlRegistry.java @@ -16,7 +16,6 @@ import org.eclipse.kapua.locator.KapuaLocator; import org.eclipse.kapua.service.account.Account; -import org.eclipse.kapua.service.account.AccountCreator; import org.eclipse.kapua.service.account.AccountFactory; import org.eclipse.kapua.service.account.Organization; @@ -41,16 +40,6 @@ public Account newAccount() { return factory.newEntity(null); } - /** - * Instantiates a new {@link AccountCreator}. - * - * @return The newly instantiated {@link AccountCreator}. - * @since 1.0.0 - */ - public AccountCreator newAccountCreator() { - return factory.newCreator(null); - } - /** * Instantiates a new {@link Organization}. * diff --git a/service/account/internal/src/main/java/org/eclipse/kapua/service/account/internal/AccountCreatorImpl.java b/service/account/internal/src/main/java/org/eclipse/kapua/service/account/internal/AccountCreatorImpl.java deleted file mode 100644 index a5217b68426..00000000000 --- a/service/account/internal/src/main/java/org/eclipse/kapua/service/account/internal/AccountCreatorImpl.java +++ /dev/null @@ -1,175 +0,0 @@ -/******************************************************************************* - * 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.service.account.internal; - -import org.eclipse.kapua.commons.model.AbstractKapuaNamedEntityCreator; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.service.account.Account; -import org.eclipse.kapua.service.account.AccountCreator; - -import java.util.Date; - -/** - * {@link AccountCreator} implementation. - * - * @since 1.0.0 - */ -public class AccountCreatorImpl extends AbstractKapuaNamedEntityCreator implements AccountCreator { - - private static final long serialVersionUID = -2460883485294616032L; - - private String organizationName; - private String organizationPersonName; - private String organizationEmail; - private String organizationPhoneNumber; - private String organizationAddressLine1; - private String organizationAddressLine2; - private String organizationAddressLine3; - private String organizationCity; - private String organizationZipPostCode; - private String organizationStateProvinceCounty; - private String organizationCountry; - - private Date expirationDate; - - /** - * Constructor. - * - * @param scopeId The {@link AccountCreator#getScopeId()}. - * @param name The {@link AccountCreator#getName()}. - * @since 1.0.0 - */ - public AccountCreatorImpl(KapuaId scopeId, String name) { - super(scopeId, name); - } - - @Override - public String getOrganizationName() { - return organizationName; - } - - @Override - public void setOrganizationName(String organizationName) { - this.organizationName = organizationName; - } - - @Override - public String getOrganizationPersonName() { - return organizationPersonName; - } - - @Override - public void setOrganizationPersonName(String organizationPersonName) { - this.organizationPersonName = organizationPersonName; - } - - @Override - public String getOrganizationEmail() { - return organizationEmail; - } - - @Override - public void setOrganizationEmail(String organizationEmail) { - this.organizationEmail = organizationEmail; - } - - @Override - public String getOrganizationPhoneNumber() { - return organizationPhoneNumber; - } - - @Override - public void setOrganizationPhoneNumber(String organizationPhoneNumber) { - this.organizationPhoneNumber = organizationPhoneNumber; - } - - @Override - public String getOrganizationAddressLine1() { - return organizationAddressLine1; - } - - @Override - public void setOrganizationAddressLine1(String organizationAddressLine1) { - this.organizationAddressLine1 = organizationAddressLine1; - } - - @Override - public String getOrganizationAddressLine2() { - return organizationAddressLine2; - } - - @Override - public void setOrganizationAddressLine2(String organizationAddressLine2) { - this.organizationAddressLine2 = organizationAddressLine2; - } - - @Override - public String getOrganizationAddressLine3() { - return organizationAddressLine3; - } - - @Override - public void setOrganizationAddressLine3(String organizationAddressLine3) { - this.organizationAddressLine3 = organizationAddressLine3; - } - - @Override - public String getOrganizationCity() { - return organizationCity; - } - - @Override - public void setOrganizationCity(String organizationCity) { - this.organizationCity = organizationCity; - } - - @Override - public String getOrganizationZipPostCode() { - return organizationZipPostCode; - } - - @Override - public void setOrganizationZipPostCode(String organizationZipPostCode) { - this.organizationZipPostCode = organizationZipPostCode; - } - - @Override - public String getOrganizationStateProvinceCounty() { - return organizationStateProvinceCounty; - } - - @Override - public void setOrganizationStateProvinceCounty(String organizationStateProvinceCounty) { - this.organizationStateProvinceCounty = organizationStateProvinceCounty; - } - - @Override - public String getOrganizationCountry() { - return organizationCountry; - } - - @Override - public void setOrganizationCountry(String organizationCountry) { - this.organizationCountry = organizationCountry; - } - - @Override - public Date getExpirationDate() { - return expirationDate; - } - - @Override - public void setExpirationDate(Date expirationDate) { - this.expirationDate = expirationDate; - } -} diff --git a/service/account/internal/src/main/java/org/eclipse/kapua/service/account/internal/AccountFactoryImpl.java b/service/account/internal/src/main/java/org/eclipse/kapua/service/account/internal/AccountFactoryImpl.java index 778a9f02c48..f8adaa25a1c 100644 --- a/service/account/internal/src/main/java/org/eclipse/kapua/service/account/internal/AccountFactoryImpl.java +++ b/service/account/internal/src/main/java/org/eclipse/kapua/service/account/internal/AccountFactoryImpl.java @@ -17,7 +17,6 @@ import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.account.Account; -import org.eclipse.kapua.service.account.AccountCreator; import org.eclipse.kapua.service.account.AccountFactory; import org.eclipse.kapua.service.account.Organization; @@ -29,18 +28,6 @@ @Singleton public class AccountFactoryImpl implements AccountFactory { - @Override - public AccountCreator newCreator(KapuaId scopeId) { - return new AccountCreatorImpl(scopeId, null); - } - - @Override - public AccountCreator newCreator(KapuaId scopeId, String name) { - AccountCreator creator = newCreator(scopeId); - creator.setName(name); - return creator; - } - @Override public Account newEntity(KapuaId scopeId) { return new AccountImpl(scopeId); diff --git a/service/account/test-steps/src/main/java/org/eclipse/kapua/service/account/steps/AccountServiceSteps.java b/service/account/test-steps/src/main/java/org/eclipse/kapua/service/account/steps/AccountServiceSteps.java index 46e2d4293b0..d9b73746c0c 100755 --- a/service/account/test-steps/src/main/java/org/eclipse/kapua/service/account/steps/AccountServiceSteps.java +++ b/service/account/test-steps/src/main/java/org/eclipse/kapua/service/account/steps/AccountServiceSteps.java @@ -714,7 +714,7 @@ public void setAccountServiceConfig(List cucConfigs) throws Exception * @return The newly created account creator object. */ private AccountCreator prepareRegularAccountCreator(KapuaId parentId, String name) { - AccountCreator tmpAccCreator = accountFactory.newCreator(parentId); + AccountCreator tmpAccCreator = new AccountCreator(parentId); tmpAccCreator.setName(name); tmpAccCreator.setOrganizationName("org_" + name); @@ -768,7 +768,7 @@ private Account createAccount(CucAccount cucAccount) throws Exception { */ private AccountCreator accountCreatorCreator(String name, BigInteger scopeId, Date expiration) { - AccountCreator accountCreator = accountFactory.newCreator(new KapuaEid(scopeId)); + AccountCreator accountCreator = new AccountCreator(new KapuaEid(scopeId)); accountCreator.setName(name); accountCreator.setOrganizationName("ACME Inc."); accountCreator.setOrganizationEmail("some@one.com"); @@ -803,7 +803,7 @@ public void iTryToEditAccountWithName(String description) throws Exception { @And("I create an account with name {string}, organization name {string} and email address {string}") public void iCreateAAccountWithNameOrganizationNameAndEmailaddress(String accountName, String organizationName, String email) throws Exception { - AccountCreator accountCreator = accountFactory.newCreator(getCurrentScopeId()); + AccountCreator accountCreator = new AccountCreator(getCurrentScopeId()); accountCreator.setName(accountName); accountCreator.setOrganizationName(organizationName); accountCreator.setOrganizationEmail(email); @@ -850,7 +850,7 @@ public void verifySelfAccount() throws Exception { public void iCreateAccountWithNameOrganizationNameAndEmailaddressAndChildAccount(String accountName, String organizationName, String email) throws Exception { Account lastAccount = (Account) stepData.get(LAST_ACCOUNT); - AccountCreator accountCreator = accountFactory.newCreator(lastAccount.getId()); + AccountCreator accountCreator = new AccountCreator(lastAccount.getId()); accountCreator.setName(accountName); accountCreator.setOrganizationName(organizationName); accountCreator.setOrganizationEmail(email); diff --git a/commons/src/main/java/org/eclipse/kapua/commons/util/PropertiesUtils.java b/service/api/src/main/java/org/eclipse/kapua/PropertiesUtils.java similarity index 76% rename from commons/src/main/java/org/eclipse/kapua/commons/util/PropertiesUtils.java rename to service/api/src/main/java/org/eclipse/kapua/PropertiesUtils.java index 7c96c21ff24..ef9d1efcde3 100644 --- a/commons/src/main/java/org/eclipse/kapua/commons/util/PropertiesUtils.java +++ b/service/api/src/main/java/org/eclipse/kapua/PropertiesUtils.java @@ -10,10 +10,7 @@ * Contributors: * Eurotech - initial API and implementation *******************************************************************************/ -package org.eclipse.kapua.commons.util; - -import com.google.common.base.Strings; -import org.checkerframework.checker.nullness.qual.Nullable; +package org.eclipse.kapua; import java.io.IOException; import java.io.Reader; @@ -22,6 +19,8 @@ import java.io.Writer; import java.util.Properties; +import com.google.common.base.Strings; + /** * Utilities around the Java {@link Properties} class. * @@ -35,13 +34,15 @@ private PropertiesUtils() { /** * Reads the given {@link String} and loads it into the returned {@link Properties}. * - * @param stringProperties The source {@link String} + * @param stringProperties + * The source {@link String} * @return The loaded {@link Properties} - * @throws IOException If the {@link String} is not properly formatted. + * @throws IOException + * If the {@link String} is not properly formatted. * @see Properties#load(Reader) * @since 1.1.0 */ - public static Properties readPropertiesFromString(@Nullable String stringProperties) throws IOException { + public static Properties readPropertiesFromString(String stringProperties) throws IOException { Properties props = new Properties(); if (!Strings.isNullOrEmpty(stringProperties)) { try (Reader reader = new StringReader(stringProperties)) { @@ -54,13 +55,15 @@ public static Properties readPropertiesFromString(@Nullable String stringPropert /** * Writes the given {@link Properties} into the returned {@link String} * - * @param properties The source {@link Properties} + * @param properties + * The source {@link Properties} * @return The written {@link Properties}. - * @throws IOException if error occurs while writing properties. + * @throws IOException + * if error occurs while writing properties. * @see Properties#store(Writer, String) * @since 1.1.0 */ - public static String writePropertiesToString(@Nullable Properties properties) throws IOException { + public static String writePropertiesToString(Properties properties) throws IOException { String stringProperties = null; if (properties != null) { try (Writer writer = new StringWriter()) { diff --git a/service/api/src/main/java/org/eclipse/kapua/model/KapuaEntityCreator.java b/service/api/src/main/java/org/eclipse/kapua/model/KapuaEntityCreator.java index 82603baa642..7bd621bbdb9 100644 --- a/service/api/src/main/java/org/eclipse/kapua/model/KapuaEntityCreator.java +++ b/service/api/src/main/java/org/eclipse/kapua/model/KapuaEntityCreator.java @@ -12,21 +12,35 @@ *******************************************************************************/ package org.eclipse.kapua.model; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.model.id.KapuaIdAdapter; - import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; +import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.model.id.KapuaIdAdapter; + /** * {@link KapuaEntityCreator} definition *

    * All the {@link KapuaEntityCreator} will be an extension of this. * - * @param entity type + * @param + * entity type * @since 1.0.0 */ -public interface KapuaEntityCreator { +public abstract class KapuaEntityCreator { + + protected KapuaId scopeId; + + public KapuaEntityCreator() { + } + + public KapuaEntityCreator(KapuaId scopeId) { + this.scopeId = scopeId; + } + + protected KapuaEntityCreator(KapuaEntityCreator entityCreator) { + this(entityCreator.getScopeId()); + } /** * Gets the scope {@link KapuaId} @@ -36,13 +50,19 @@ public interface KapuaEntityCreator { */ @XmlElement(name = "scopeId") @XmlJavaTypeAdapter(KapuaIdAdapter.class) - KapuaId getScopeId(); + public KapuaId getScopeId() { + return scopeId; + } /** * Sets the scope {@link KapuaId} * - * @param scopeId the scope {@link KapuaId} + * @param scopeId + * the scope {@link KapuaId} * @since 1.0.0 */ - void setScopeId(KapuaId scopeId); + public void setScopeId(KapuaId scopeId) { + + this.scopeId = scopeId; + } } diff --git a/service/api/src/main/java/org/eclipse/kapua/model/KapuaEntityFactory.java b/service/api/src/main/java/org/eclipse/kapua/model/KapuaEntityFactory.java index bcd810e1204..fceb7841a8a 100644 --- a/service/api/src/main/java/org/eclipse/kapua/model/KapuaEntityFactory.java +++ b/service/api/src/main/java/org/eclipse/kapua/model/KapuaEntityFactory.java @@ -20,11 +20,9 @@ * * @param * The {@link KapuaEntity} for which this {@link KapuaEntityFactory} is for. - * @param - * The {@link KapuaEntityCreator} for which this {@link KapuaEntityFactory} is for. * @since 1.0.0 */ -public interface KapuaEntityFactory> extends KapuaObjectFactory { +public interface KapuaEntityFactory extends KapuaObjectFactory { /** * Instantiates a new {@link KapuaEntity}. @@ -36,16 +34,6 @@ public interface KapuaEntityFactory @@ -41,11 +43,36 @@ *

    * * - * @param {@link KapuaEntity} which this {@link KapuaEntityCreator} is for + * @param + * {@link KapuaEntity} which this {@link KapuaEntityCreator} is for * @since 1.0.0 */ -@XmlType(propOrder = {"name", "description"}) -public interface KapuaNamedEntityCreator extends KapuaUpdatableEntityCreator { +@XmlType(propOrder = { "name", "description" }) +public abstract class KapuaNamedEntityCreator extends KapuaUpdatableEntityCreator { + + protected String name; + protected String description; + + public KapuaNamedEntityCreator() { + } + + public KapuaNamedEntityCreator(KapuaId scopeId) { + super(scopeId); + } + + /** + * Constructor + * + * @param scopeId + * the scope {@link KapuaId} + * @param name + * the name + * @since 1.0.0 + */ + public KapuaNamedEntityCreator(KapuaId scopeId, String name) { + super(scopeId); + this.name = name; + } /** * Gets the name @@ -54,15 +81,20 @@ public interface KapuaNamedEntityCreator extends KapuaUpd * @since 1.0.0 */ @XmlElement(name = "name") - String getName(); + public String getName() { + return name; + } /** * Sets the name * - * @param name the name + * @param name + * the name * @since 1.0.0 */ - void setName(String name); + public void setName(String name) { + this.name = name; + } /** * Gets the description @@ -70,13 +102,18 @@ public interface KapuaNamedEntityCreator extends KapuaUpd * @return the description * @since 1.0.0 */ - String getDescription(); + public String getDescription() { + return description; + } /** * Sets the description * - * @param description the description + * @param description + * the description * @since 1.0.0 */ - void setDescription(String description); + public void setDescription(String description) { + this.description = description; + } } diff --git a/service/api/src/main/java/org/eclipse/kapua/model/KapuaUpdatableEntityCreator.java b/service/api/src/main/java/org/eclipse/kapua/model/KapuaUpdatableEntityCreator.java index 8d2fa3c5335..70808d0483f 100644 --- a/service/api/src/main/java/org/eclipse/kapua/model/KapuaUpdatableEntityCreator.java +++ b/service/api/src/main/java/org/eclipse/kapua/model/KapuaUpdatableEntityCreator.java @@ -12,21 +12,52 @@ *******************************************************************************/ package org.eclipse.kapua.model; -import org.eclipse.kapua.KapuaException; +import java.io.IOException; +import java.util.Properties; import javax.xml.bind.annotation.XmlTransient; -import java.util.Properties; + +import org.eclipse.kapua.PropertiesUtils; +import org.eclipse.kapua.entity.EntityPropertiesReadException; +import org.eclipse.kapua.entity.EntityPropertiesWriteException; +import org.eclipse.kapua.model.id.KapuaId; /** * {@link KapuaUpdatableEntityCreator} definition. * - * @param entity type + * @param + * entity type * @since 1.0.0 */ -public interface KapuaUpdatableEntityCreator extends KapuaEntityCreator { +public abstract class KapuaUpdatableEntityCreator extends KapuaEntityCreator { + + protected String attributes; + + public KapuaUpdatableEntityCreator() { + } + + public KapuaUpdatableEntityCreator(KapuaId scopeId) { + super(scopeId); + } + + protected KapuaUpdatableEntityCreator(KapuaEntityCreator entityCreator) { + super(entityCreator); + } @XmlTransient - Properties getEntityAttributes() throws KapuaException; + public Properties getEntityAttributes() { + try { + return PropertiesUtils.readPropertiesFromString(attributes); + } catch (IOException e) { + throw new EntityPropertiesReadException(e, "attributes", attributes); + } + } - void setEntityAttributes(Properties entityAttributes) throws KapuaException; + public void setEntityAttributes(Properties attributes) { + try { + this.attributes = PropertiesUtils.writePropertiesToString(attributes); + } catch (IOException e) { + throw new EntityPropertiesWriteException(e, "attributes", attributes); + } + } } diff --git a/service/authentication/src/main/java/org/eclipse/kapua/service/authentication/authentication/AuthenticationLogic.java b/service/authentication/src/main/java/org/eclipse/kapua/service/authentication/authentication/AuthenticationLogic.java index 6733b65d31c..1b58098af18 100644 --- a/service/authentication/src/main/java/org/eclipse/kapua/service/authentication/authentication/AuthenticationLogic.java +++ b/service/authentication/src/main/java/org/eclipse/kapua/service/authentication/authentication/AuthenticationLogic.java @@ -268,7 +268,7 @@ protected ConnectionUserCouplingMode loadConnectionUserCouplingModeFromConfig(Ma */ protected DeviceConnection createDeviceConnection(AuthContext authContext) throws KapuaException { // TODO manage the stealing link event (may be a good idea to use different connect status (connect -stealing)? - DeviceConnectionCreator deviceConnectionCreator = deviceConnectionFactory.newCreator(KapuaEid.parseCompactId(authContext.getScopeId())); + DeviceConnectionCreator deviceConnectionCreator = new DeviceConnectionCreator(KapuaEid.parseCompactId(authContext.getScopeId())); deviceConnectionCreator.setStatus(DeviceConnectionStatus.CONNECTED); deviceConnectionCreator.setClientId(authContext.getClientId()); deviceConnectionCreator.setClientIp(authContext.getClientIp()); diff --git a/service/datastore/test-steps/src/main/java/org/eclipse/kapua/service/datastore/steps/DatastoreSteps.java b/service/datastore/test-steps/src/main/java/org/eclipse/kapua/service/datastore/steps/DatastoreSteps.java index c1e747114b0..18fe71a4d3b 100755 --- a/service/datastore/test-steps/src/main/java/org/eclipse/kapua/service/datastore/steps/DatastoreSteps.java +++ b/service/datastore/test-steps/src/main/java/org/eclipse/kapua/service/datastore/steps/DatastoreSteps.java @@ -567,12 +567,12 @@ public void prepareUnorderedRandomMessagesWithTopics(int number, String lstKey, String clientId1 = "test-device-1"; Date sentOn1 = new Date(new Date().getTime() - 10000); Date capturedOn1 = new Date(new Date().getTime() - 500); - DeviceCreator tmpDevCr1 = deviceFactory.newCreator(tmpAccount.getId(), clientId1); + DeviceCreator tmpDevCr1 = new DeviceCreator(tmpAccount.getId(), clientId1); Device device1 = deviceRegistryService.create(tmpDevCr1); String clientId2 = "test-device-2"; Date sentOn2 = new Date(sentOn1.getTime() + 1000); Date capturedOn2 = new Date(new Date().getTime()); - DeviceCreator tmpDevCr2 = deviceFactory.newCreator(tmpAccount.getId(), clientId2); + DeviceCreator tmpDevCr2 = new DeviceCreator(tmpAccount.getId(), clientId2); Device device2 = deviceRegistryService.create(tmpDevCr2); Device tmpDev; Date sentOn; diff --git a/service/device/commons/src/main/java/org/eclipse/kapua/service/device/management/commons/AbstractDeviceManagementServiceImpl.java b/service/device/commons/src/main/java/org/eclipse/kapua/service/device/management/commons/AbstractDeviceManagementServiceImpl.java index a8d0d4d8fa5..f251658843a 100644 --- a/service/device/commons/src/main/java/org/eclipse/kapua/service/device/management/commons/AbstractDeviceManagementServiceImpl.java +++ b/service/device/commons/src/main/java/org/eclipse/kapua/service/device/management/commons/AbstractDeviceManagementServiceImpl.java @@ -12,6 +12,15 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.management.commons; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.concurrent.Callable; + +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Null; + import org.eclipse.kapua.KapuaEntityNotFoundException; import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.commons.security.KapuaSecurityUtils; @@ -46,14 +55,6 @@ import org.eclipse.kapua.service.device.registry.event.DeviceEventFactory; import org.eclipse.kapua.service.device.registry.event.DeviceEventService; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Null; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Map; -import java.util.concurrent.Callable; - /** * Utility {@code abstract} {@link Class} used to provide utility methods to all implementation of {@link DeviceManagementService}s. * @@ -83,17 +84,22 @@ public abstract class AbstractDeviceManagementServiceImpl { * This operation is performed using {@link KapuaSecurityUtils#doPrivileged(ThrowingRunnable)} since {@link org.eclipse.kapua.commons.model.domains.Domains#DEVICE_EVENT} isn't a required * permission to use any of the Device Management Services. * - * @param scopeId The scopeId in which to create the {@link org.eclipse.kapua.service.device.registry.event.DeviceEvent} - * @param deviceId The {@link org.eclipse.kapua.service.device.registry.Device} id for which the {@link org.eclipse.kapua.service.device.registry.event.DeviceEvent} is created - * @param requestMessage The {@link KapuaRequestMessage} of the DeviceManagementService operation from which to extract data. - * @param responseMessage The {@link KapuaResponseMessage} of the DeviceManagementService operation from which to extract data. - * @throws KapuaException If the creation of the {@link org.eclipse.kapua.service.device.registry.event.DeviceEvent} fails for some reasons + * @param scopeId + * The scopeId in which to create the {@link org.eclipse.kapua.service.device.registry.event.DeviceEvent} + * @param deviceId + * The {@link org.eclipse.kapua.service.device.registry.Device} id for which the {@link org.eclipse.kapua.service.device.registry.event.DeviceEvent} is created + * @param requestMessage + * The {@link KapuaRequestMessage} of the DeviceManagementService operation from which to extract data. + * @param responseMessage + * The {@link KapuaResponseMessage} of the DeviceManagementService operation from which to extract data. + * @throws KapuaException + * If the creation of the {@link org.eclipse.kapua.service.device.registry.event.DeviceEvent} fails for some reasons * @since 1.0.0 */ protected void createDeviceEvent(KapuaId scopeId, KapuaId deviceId, KapuaRequestMessage requestMessage, KapuaResponseMessage responseMessage) throws KapuaException { DeviceEventCreator deviceEventCreator = - deviceEventFactory.newCreator( + new DeviceEventCreator( scopeId, deviceId, responseMessage != null ? responseMessage.getReceivedOn() : requestMessage.getSentOn(), @@ -111,9 +117,12 @@ protected void createDeviceEvent(KapuaId scopeId, KapuaId deviceId, KapuaRequest /** * Checks whether the {@link Device} exists and if it is connected. * - * @param scopeId The {@link Device#getScopeId()}. - * @param deviceId The {@link Device#getId()}. - * @return {@code true} if {@link Device} exists, has a {@link Device#getConnection()} and the {@link DeviceConnection#getStatus()} is {@link DeviceConnectionStatus#CONNECTED}, {@code false} otherwise. + * @param scopeId + * The {@link Device#getScopeId()}. + * @param deviceId + * The {@link Device#getId()}. + * @return {@code true} if {@link Device} exists, has a {@link Device#getConnection()} and the {@link DeviceConnection#getStatus()} is {@link DeviceConnectionStatus#CONNECTED}, {@code false} + * otherwise. * @throws KapuaException */ public boolean isDeviceConnected(KapuaId scopeId, KapuaId deviceId) throws KapuaException { @@ -142,7 +151,7 @@ public boolean isDeviceConnected(KapuaId scopeId, KapuaId deviceId) throws Kapua protected KapuaId createManagementOperation(KapuaId scopeId, KapuaId deviceId, KapuaId operationId, KapuaRequestMessage requestMessage) throws KapuaException { - DeviceManagementOperationCreator deviceManagementOperationCreator = deviceManagementOperationFactory.newCreator(scopeId); + DeviceManagementOperationCreator deviceManagementOperationCreator = new DeviceManagementOperationCreator(scopeId); deviceManagementOperationCreator.setDeviceId(deviceId); deviceManagementOperationCreator.setOperationId(operationId); deviceManagementOperationCreator.setStartedOn(new Date()); @@ -179,7 +188,6 @@ protected void closeManagementOperation(KapuaId scopeId, KapuaId deviceId, Kapua KapuaSecurityUtils.doPrivileged(() -> deviceManagementOperationRegistryService.update(deviceManagementOperation)); } - // // Response handling // @@ -187,8 +195,10 @@ protected void closeManagementOperation(KapuaId scopeId, KapuaId deviceId, Kapua /** * Checks the {@link KapuaResponseMessage#getResponseCode()} if it is {@link KapuaResponseCode#ACCEPTED} or throws the proper {@link DeviceManagementResponseCodeException}. * - * @param responseMessage The {@link KapuaResponseMessage} to check. - * @throws DeviceManagementResponseCodeException if {@link KapuaResponseMessage#getResponseCode()} is not {@link KapuaResponseCode#ACCEPTED}. + * @param responseMessage + * The {@link KapuaResponseMessage} to check. + * @throws DeviceManagementResponseCodeException + * if {@link KapuaResponseMessage#getResponseCode()} is not {@link KapuaResponseCode#ACCEPTED}. * @since 1.5.0 */ protected void checkResponseAcceptedOrThrowError(@NotNull KapuaResponseMessage responseMessage) throws DeviceManagementResponseCodeException { @@ -204,15 +214,21 @@ protected void checkResponseAcceptedOrThrowError(@NotNull KapuaResponseMessage * If {@link Callable} is not provided the returned result will be {@code null}. * - * @param responseMessage The {@link KapuaResponseMessage} to check. - * @param resultGetter The {@link Callable} that gets the result. - * @param The type of the result. + * @param responseMessage + * The {@link KapuaResponseMessage} to check. + * @param resultGetter + * The {@link Callable} that gets the result. + * @param + * The type of the result. * @return The result from the {@link KapuaResponseMessage} if {@link KapuaResponseMessage#getResponseCode()} is {@link KapuaResponseCode#ACCEPTED}. - * @throws DeviceManagementResponseCodeException if {@link KapuaResponseMessage#getResponseCode()} is not {@link KapuaResponseCode#ACCEPTED}. - * @throws DeviceManagementResponseContentException if getting the result causes any {@link Exception}. + * @throws DeviceManagementResponseCodeException + * if {@link KapuaResponseMessage#getResponseCode()} is not {@link KapuaResponseCode#ACCEPTED}. + * @throws DeviceManagementResponseContentException + * if getting the result causes any {@link Exception}. * @since 1.5.0 */ - protected R checkResponseAcceptedOrThrowError(@NotNull KapuaResponseMessage responseMessage, @Null Callable resultGetter) throws DeviceManagementResponseCodeException, DeviceManagementResponseContentException { + protected R checkResponseAcceptedOrThrowError(@NotNull KapuaResponseMessage responseMessage, @Null Callable resultGetter) + throws DeviceManagementResponseCodeException, DeviceManagementResponseContentException { if (responseMessage.getResponseCode().isAccepted()) { if (resultGetter != null) { try { @@ -231,7 +247,8 @@ protected R checkResponseAcceptedOrThrowError(@NotNull KapuaResponseMessage< /** * Builds the {@link DeviceManagementResponseCodeException} from the {@link KapuaResponseMessage}. * - * @param kapuaResponseMessage The {@link KapuaResponseMessage} to build from. + * @param kapuaResponseMessage + * The {@link KapuaResponseMessage} to build from. * @return The proper {@link DeviceManagementResponseCodeException} for the {@link KapuaResponseMessage#getResponseCode()} * @since 1.5.0 */ @@ -240,15 +257,15 @@ protected DeviceManagementResponseCodeException buildExceptionFromDeviceResponse KapuaResponsePayload responsePayload = kapuaResponseMessage.getPayload(); switch (kapuaResponseMessage.getResponseCode()) { - case BAD_REQUEST: - return new DeviceManagementResponseBadRequestException(kapuaResponseMessage.getResponseCode(), responsePayload.getExceptionMessage(), responsePayload.getExceptionMessage()); - case NOT_FOUND: - return new DeviceManagementResponseNotFoundException(kapuaResponseMessage.getResponseCode(), responsePayload.getExceptionMessage(), responsePayload.getExceptionMessage()); - case INTERNAL_ERROR: - return new DeviceManagementResponseInternalErrorException(kapuaResponseMessage.getResponseCode(), responsePayload.getExceptionMessage(), responsePayload.getExceptionMessage()); - case ACCEPTED: - default: - return new DeviceManagementResponseUnknownCodeException(kapuaResponseMessage.getResponseCode(), responsePayload.getExceptionMessage(), responsePayload.getExceptionMessage()); + case BAD_REQUEST: + return new DeviceManagementResponseBadRequestException(kapuaResponseMessage.getResponseCode(), responsePayload.getExceptionMessage(), responsePayload.getExceptionMessage()); + case NOT_FOUND: + return new DeviceManagementResponseNotFoundException(kapuaResponseMessage.getResponseCode(), responsePayload.getExceptionMessage(), responsePayload.getExceptionMessage()); + case INTERNAL_ERROR: + return new DeviceManagementResponseInternalErrorException(kapuaResponseMessage.getResponseCode(), responsePayload.getExceptionMessage(), responsePayload.getExceptionMessage()); + case ACCEPTED: + default: + return new DeviceManagementResponseUnknownCodeException(kapuaResponseMessage.getResponseCode(), responsePayload.getExceptionMessage(), responsePayload.getExceptionMessage()); } } diff --git a/service/device/commons/src/main/java/org/eclipse/kapua/service/device/management/commons/AbstractDeviceManagementTransactionalServiceImpl.java b/service/device/commons/src/main/java/org/eclipse/kapua/service/device/management/commons/AbstractDeviceManagementTransactionalServiceImpl.java index 4924be3c218..d582073ae9d 100644 --- a/service/device/commons/src/main/java/org/eclipse/kapua/service/device/management/commons/AbstractDeviceManagementTransactionalServiceImpl.java +++ b/service/device/commons/src/main/java/org/eclipse/kapua/service/device/management/commons/AbstractDeviceManagementTransactionalServiceImpl.java @@ -12,6 +12,12 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.management.commons; +import java.util.Optional; +import java.util.concurrent.Callable; + +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Null; + import org.eclipse.kapua.KapuaEntityNotFoundException; import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.commons.security.KapuaSecurityUtils; @@ -40,11 +46,6 @@ import org.eclipse.kapua.service.device.registry.event.DeviceEventService; import org.eclipse.kapua.storage.TxManager; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Null; -import java.util.Optional; -import java.util.concurrent.Callable; - /** * Utility {@code abstract} {@link Class} used to provide utility methods to all implementation of {@link DeviceManagementService}s. * @@ -83,17 +84,22 @@ public AbstractDeviceManagementTransactionalServiceImpl( * This operation is performed using {@link KapuaSecurityUtils#doPrivileged(ThrowingRunnable)} since {@link org.eclipse.kapua.commons.model.domains.Domains#DEVICE_EVENT} isn't a required * permission to use any of the Device Management Services. * - * @param scopeId The scopeId in which to create the {@link org.eclipse.kapua.service.device.registry.event.DeviceEvent} - * @param deviceId The {@link org.eclipse.kapua.service.device.registry.Device} id for which the {@link org.eclipse.kapua.service.device.registry.event.DeviceEvent} is created - * @param requestMessage The {@link KapuaRequestMessage} of the DeviceManagementService operation from which to extract data. - * @param responseMessage The {@link KapuaResponseMessage} of the DeviceManagementService operation from which to extract data. - * @throws KapuaException If the creation of the {@link org.eclipse.kapua.service.device.registry.event.DeviceEvent} fails for some reasons + * @param scopeId + * The scopeId in which to create the {@link org.eclipse.kapua.service.device.registry.event.DeviceEvent} + * @param deviceId + * The {@link org.eclipse.kapua.service.device.registry.Device} id for which the {@link org.eclipse.kapua.service.device.registry.event.DeviceEvent} is created + * @param requestMessage + * The {@link KapuaRequestMessage} of the DeviceManagementService operation from which to extract data. + * @param responseMessage + * The {@link KapuaResponseMessage} of the DeviceManagementService operation from which to extract data. + * @throws KapuaException + * If the creation of the {@link org.eclipse.kapua.service.device.registry.event.DeviceEvent} fails for some reasons * @since 1.0.0 */ protected void createDeviceEvent(KapuaId scopeId, KapuaId deviceId, KapuaRequestMessage requestMessage, KapuaResponseMessage responseMessage) throws KapuaException { DeviceEventCreator deviceEventCreator = - deviceEventFactory.newCreator( + new DeviceEventCreator( scopeId, deviceId, responseMessage != null ? responseMessage.getReceivedOn() : requestMessage.getSentOn(), @@ -111,9 +117,12 @@ protected void createDeviceEvent(KapuaId scopeId, KapuaId deviceId, KapuaRequest /** * Checks whether the {@link Device} exists and if it is connected. * - * @param scopeId The {@link Device#getScopeId()}. - * @param deviceId The {@link Device#getId()}. - * @return {@code true} if {@link Device} exists, has a {@link Device#getConnection()} and the {@link DeviceConnection#getStatus()} is {@link DeviceConnectionStatus#CONNECTED}, {@code false} otherwise. + * @param scopeId + * The {@link Device#getScopeId()}. + * @param deviceId + * The {@link Device#getId()}. + * @return {@code true} if {@link Device} exists, has a {@link Device#getConnection()} and the {@link DeviceConnection#getStatus()} is {@link DeviceConnectionStatus#CONNECTED}, {@code false} + * otherwise. * @throws KapuaException */ public boolean isDeviceConnected(KapuaId scopeId, KapuaId deviceId) throws KapuaException { @@ -134,8 +143,10 @@ public boolean isDeviceConnected(KapuaId scopeId, KapuaId deviceId) throws Kapua /** * Checks the {@link KapuaResponseMessage#getResponseCode()} if it is {@link KapuaResponseCode#ACCEPTED} or throws the proper {@link DeviceManagementResponseCodeException}. * - * @param responseMessage The {@link KapuaResponseMessage} to check. - * @throws DeviceManagementResponseCodeException if {@link KapuaResponseMessage#getResponseCode()} is not {@link KapuaResponseCode#ACCEPTED}. + * @param responseMessage + * The {@link KapuaResponseMessage} to check. + * @throws DeviceManagementResponseCodeException + * if {@link KapuaResponseMessage#getResponseCode()} is not {@link KapuaResponseCode#ACCEPTED}. * @since 1.5.0 */ protected void checkResponseAcceptedOrThrowError(@NotNull KapuaResponseMessage responseMessage) throws DeviceManagementResponseCodeException { @@ -151,15 +162,21 @@ protected void checkResponseAcceptedOrThrowError(@NotNull KapuaResponseMessage * If {@link Callable} is not provided the returned result will be {@code null}. * - * @param responseMessage The {@link KapuaResponseMessage} to check. - * @param resultGetter The {@link Callable} that gets the result. - * @param The type of the result. + * @param responseMessage + * The {@link KapuaResponseMessage} to check. + * @param resultGetter + * The {@link Callable} that gets the result. + * @param + * The type of the result. * @return The result from the {@link KapuaResponseMessage} if {@link KapuaResponseMessage#getResponseCode()} is {@link KapuaResponseCode#ACCEPTED}. - * @throws DeviceManagementResponseCodeException if {@link KapuaResponseMessage#getResponseCode()} is not {@link KapuaResponseCode#ACCEPTED}. - * @throws DeviceManagementResponseContentException if getting the result causes any {@link Exception}. + * @throws DeviceManagementResponseCodeException + * if {@link KapuaResponseMessage#getResponseCode()} is not {@link KapuaResponseCode#ACCEPTED}. + * @throws DeviceManagementResponseContentException + * if getting the result causes any {@link Exception}. * @since 1.5.0 */ - protected R checkResponseAcceptedOrThrowError(@NotNull KapuaResponseMessage responseMessage, @Null Callable resultGetter) throws DeviceManagementResponseCodeException, DeviceManagementResponseContentException { + protected R checkResponseAcceptedOrThrowError(@NotNull KapuaResponseMessage responseMessage, @Null Callable resultGetter) + throws DeviceManagementResponseCodeException, DeviceManagementResponseContentException { if (responseMessage.getResponseCode().isAccepted()) { if (resultGetter != null) { try { @@ -178,7 +195,8 @@ protected R checkResponseAcceptedOrThrowError(@NotNull KapuaResponseMessage< /** * Builds the {@link DeviceManagementResponseCodeException} from the {@link KapuaResponseMessage}. * - * @param kapuaResponseMessage The {@link KapuaResponseMessage} to build from. + * @param kapuaResponseMessage + * The {@link KapuaResponseMessage} to build from. * @return The proper {@link DeviceManagementResponseCodeException} for the {@link KapuaResponseMessage#getResponseCode()} * @since 1.5.0 */ @@ -187,15 +205,15 @@ protected DeviceManagementResponseCodeException buildExceptionFromDeviceResponse KapuaResponsePayload responsePayload = kapuaResponseMessage.getPayload(); switch (kapuaResponseMessage.getResponseCode()) { - case BAD_REQUEST: - return new DeviceManagementResponseBadRequestException(kapuaResponseMessage.getResponseCode(), responsePayload.getExceptionMessage(), responsePayload.getExceptionMessage()); - case NOT_FOUND: - return new DeviceManagementResponseNotFoundException(kapuaResponseMessage.getResponseCode(), responsePayload.getExceptionMessage(), responsePayload.getExceptionMessage()); - case INTERNAL_ERROR: - return new DeviceManagementResponseInternalErrorException(kapuaResponseMessage.getResponseCode(), responsePayload.getExceptionMessage(), responsePayload.getExceptionMessage()); - case ACCEPTED: - default: - return new DeviceManagementResponseUnknownCodeException(kapuaResponseMessage.getResponseCode(), responsePayload.getExceptionMessage(), responsePayload.getExceptionMessage()); + case BAD_REQUEST: + return new DeviceManagementResponseBadRequestException(kapuaResponseMessage.getResponseCode(), responsePayload.getExceptionMessage(), responsePayload.getExceptionMessage()); + case NOT_FOUND: + return new DeviceManagementResponseNotFoundException(kapuaResponseMessage.getResponseCode(), responsePayload.getExceptionMessage(), responsePayload.getExceptionMessage()); + case INTERNAL_ERROR: + return new DeviceManagementResponseInternalErrorException(kapuaResponseMessage.getResponseCode(), responsePayload.getExceptionMessage(), responsePayload.getExceptionMessage()); + case ACCEPTED: + default: + return new DeviceManagementResponseUnknownCodeException(kapuaResponseMessage.getResponseCode(), responsePayload.getExceptionMessage(), responsePayload.getExceptionMessage()); } } } diff --git a/service/device/management/job/api/src/main/java/org/eclipse/kapua/service/device/management/job/JobDeviceManagementOperationCreator.java b/service/device/management/job/api/src/main/java/org/eclipse/kapua/service/device/management/job/JobDeviceManagementOperationCreator.java index cb29b88c086..a42fe2d34fc 100644 --- a/service/device/management/job/api/src/main/java/org/eclipse/kapua/service/device/management/job/JobDeviceManagementOperationCreator.java +++ b/service/device/management/job/api/src/main/java/org/eclipse/kapua/service/device/management/job/JobDeviceManagementOperationCreator.java @@ -12,24 +12,39 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.management.job; -import org.eclipse.kapua.model.KapuaEntityCreator; -import org.eclipse.kapua.model.id.KapuaId; - import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import org.eclipse.kapua.commons.model.id.KapuaEid; +import org.eclipse.kapua.model.KapuaEntityCreator; +import org.eclipse.kapua.model.id.KapuaId; + /** - * {@link JobDeviceManagementOperationCreator} encapsulates all the information needed to create a new {@link JobDeviceManagementOperation} in the system.
    - * The data provided will be used to seed the new {@link JobDeviceManagementOperation}. + * {@link JobDeviceManagementOperationCreator} encapsulates all the information needed to create a new {@link JobDeviceManagementOperation} in the system.
    The data provided will be used to seed + * the new {@link JobDeviceManagementOperation}. * * @since 1.1.0 */ @XmlRootElement(name = "jobDeviceManagementOperationCreator") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = JobDeviceManagementOperationXmlRegistry.class, factoryMethod = "newJobDeviceManagementOperationCreator") -public interface JobDeviceManagementOperationCreator extends KapuaEntityCreator { +@XmlType +public class JobDeviceManagementOperationCreator extends KapuaEntityCreator { + + private KapuaId jobId; + private KapuaId deviceManagementOperationId; + + public JobDeviceManagementOperationCreator() { + } + + public JobDeviceManagementOperationCreator(KapuaId scopeId) { + super(scopeId); + } + + public JobDeviceManagementOperationCreator(KapuaEntityCreator entityCreator) { + super(entityCreator); + } /** * Gets the {@link org.eclipse.kapua.service.job.Job} {@link KapuaId}. @@ -37,15 +52,20 @@ public interface JobDeviceManagementOperationCreator extends KapuaEntityCreator< * @return The {@link org.eclipse.kapua.service.job.Job} {@link KapuaId}. * @since 1.1.0 */ - KapuaId getJobId(); + public KapuaId getJobId() { + return jobId; + } /** * Sets the {@link org.eclipse.kapua.service.job.Job} {@link KapuaId}. * - * @param jobId The {@link org.eclipse.kapua.service.job.Job} {@link KapuaId}. + * @param jobId + * The {@link org.eclipse.kapua.service.job.Job} {@link KapuaId}. * @since 1.1.0 */ - void setJobId(KapuaId jobId); + public void setJobId(KapuaId jobId) { + this.jobId = jobId; + } /** * Gets the {@link org.eclipse.kapua.service.device.management.registry.operation.DeviceManagementOperation} {@link KapuaId}. @@ -53,13 +73,18 @@ public interface JobDeviceManagementOperationCreator extends KapuaEntityCreator< * @return The {@link org.eclipse.kapua.service.device.management.registry.operation.DeviceManagementOperation} {@link KapuaId}. * @since 1.1.0 */ - KapuaId getDeviceManagementOperationId(); + public KapuaId getDeviceManagementOperationId() { + return deviceManagementOperationId; + } /** * Sets the {@link org.eclipse.kapua.service.device.management.registry.operation.DeviceManagementOperation} {@link KapuaId}. * - * @param deviceManagementOperationId The {@link org.eclipse.kapua.service.device.management.registry.operation.DeviceManagementOperation} {@link KapuaId}. + * @param deviceManagementOperationId + * The {@link org.eclipse.kapua.service.device.management.registry.operation.DeviceManagementOperation} {@link KapuaId}. * @since 1.1.0 */ - void setDeviceManagementOperationId(KapuaId deviceManagementOperationId); + public void setDeviceManagementOperationId(KapuaId deviceManagementOperationId) { + this.deviceManagementOperationId = KapuaEid.parseKapuaId(deviceManagementOperationId); + } } diff --git a/service/device/management/job/api/src/main/java/org/eclipse/kapua/service/device/management/job/JobDeviceManagementOperationFactory.java b/service/device/management/job/api/src/main/java/org/eclipse/kapua/service/device/management/job/JobDeviceManagementOperationFactory.java index a46ec83b6c0..d3489bd6847 100644 --- a/service/device/management/job/api/src/main/java/org/eclipse/kapua/service/device/management/job/JobDeviceManagementOperationFactory.java +++ b/service/device/management/job/api/src/main/java/org/eclipse/kapua/service/device/management/job/JobDeviceManagementOperationFactory.java @@ -19,6 +19,6 @@ * * @since 1.1.0 */ -public interface JobDeviceManagementOperationFactory extends KapuaEntityFactory { +public interface JobDeviceManagementOperationFactory extends KapuaEntityFactory { } diff --git a/service/device/management/job/api/src/main/java/org/eclipse/kapua/service/device/management/job/JobDeviceManagementOperationXmlRegistry.java b/service/device/management/job/api/src/main/java/org/eclipse/kapua/service/device/management/job/JobDeviceManagementOperationXmlRegistry.java index eb23385a81b..5faf4264281 100644 --- a/service/device/management/job/api/src/main/java/org/eclipse/kapua/service/device/management/job/JobDeviceManagementOperationXmlRegistry.java +++ b/service/device/management/job/api/src/main/java/org/eclipse/kapua/service/device/management/job/JobDeviceManagementOperationXmlRegistry.java @@ -29,9 +29,4 @@ public class JobDeviceManagementOperationXmlRegistry { public JobDeviceManagementOperation newJobDeviceManagementOperation() { return jobDeviceManagementOperationFactory.newEntity(null); } - - public JobDeviceManagementOperationCreator newJobDeviceManagementOperationCreator() { - return jobDeviceManagementOperationFactory.newCreator(null); - } - } diff --git a/service/device/management/job/internal/src/main/java/org/eclipse/kapua/service/device/management/job/internal/JobDeviceManagementOperationCreatorImpl.java b/service/device/management/job/internal/src/main/java/org/eclipse/kapua/service/device/management/job/internal/JobDeviceManagementOperationCreatorImpl.java deleted file mode 100644 index f4b92a1630a..00000000000 --- a/service/device/management/job/internal/src/main/java/org/eclipse/kapua/service/device/management/job/internal/JobDeviceManagementOperationCreatorImpl.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2019, 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.service.device.management.job.internal; - -import org.eclipse.kapua.commons.model.AbstractKapuaEntityCreator; -import org.eclipse.kapua.commons.model.id.KapuaEid; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.service.device.management.job.JobDeviceManagementOperation; -import org.eclipse.kapua.service.device.management.job.JobDeviceManagementOperationCreator; - -/** - * {@link JobDeviceManagementOperationCreator} implementation - * - * @since 1.1.0 - */ -public class JobDeviceManagementOperationCreatorImpl extends AbstractKapuaEntityCreator implements JobDeviceManagementOperationCreator { - - private KapuaId jobId; - private KapuaId deviceManagementOperationId; - - public JobDeviceManagementOperationCreatorImpl(KapuaId scopeId) { - super(scopeId); - } - - @Override - public KapuaId getJobId() { - return jobId; - } - - @Override - public void setJobId(KapuaId jobId) { - this.jobId = jobId; - } - - @Override - public KapuaId getDeviceManagementOperationId() { - return deviceManagementOperationId; - } - - @Override - public void setDeviceManagementOperationId(KapuaId deviceManagementOperationId) { - this.deviceManagementOperationId = KapuaEid.parseKapuaId(deviceManagementOperationId); - } -} diff --git a/service/device/management/job/internal/src/main/java/org/eclipse/kapua/service/device/management/job/internal/JobDeviceManagementOperationFactoryImpl.java b/service/device/management/job/internal/src/main/java/org/eclipse/kapua/service/device/management/job/internal/JobDeviceManagementOperationFactoryImpl.java index 32c2868962a..3cfb76daea5 100644 --- a/service/device/management/job/internal/src/main/java/org/eclipse/kapua/service/device/management/job/internal/JobDeviceManagementOperationFactoryImpl.java +++ b/service/device/management/job/internal/src/main/java/org/eclipse/kapua/service/device/management/job/internal/JobDeviceManagementOperationFactoryImpl.java @@ -17,7 +17,6 @@ import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.device.management.job.JobDeviceManagementOperation; -import org.eclipse.kapua.service.device.management.job.JobDeviceManagementOperationCreator; import org.eclipse.kapua.service.device.management.job.JobDeviceManagementOperationFactory; /** @@ -33,11 +32,6 @@ public JobDeviceManagementOperation newEntity(KapuaId scopeId) { return new JobDeviceManagementOperationImpl(scopeId); } - @Override - public JobDeviceManagementOperationCreator newCreator(KapuaId scopeId) { - return new JobDeviceManagementOperationCreatorImpl(scopeId); - } - @Override public JobDeviceManagementOperation clone(JobDeviceManagementOperation jobDeviceManagementOperation) { try { diff --git a/service/device/management/packages/internal/src/main/java/org/eclipse/kapua/service/device/management/packages/internal/DevicePackageManagementServiceImpl.java b/service/device/management/packages/internal/src/main/java/org/eclipse/kapua/service/device/management/packages/internal/DevicePackageManagementServiceImpl.java index c2916002560..83784300540 100644 --- a/service/device/management/packages/internal/src/main/java/org/eclipse/kapua/service/device/management/packages/internal/DevicePackageManagementServiceImpl.java +++ b/service/device/management/packages/internal/src/main/java/org/eclipse/kapua/service/device/management/packages/internal/DevicePackageManagementServiceImpl.java @@ -12,7 +12,15 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.management.packages.internal; -import com.google.common.base.MoreObjects; +import java.net.MalformedURLException; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Map; + +import javax.inject.Inject; +import javax.inject.Singleton; + import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.KapuaIllegalArgumentException; import org.eclipse.kapua.commons.model.domains.Domains; @@ -67,13 +75,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.inject.Inject; -import javax.inject.Singleton; -import java.net.MalformedURLException; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Map; +import com.google.common.base.MoreObjects; /** * {@link DevicePackageManagementService} implementation. @@ -220,10 +222,14 @@ public KapuaId downloadExec(KapuaId scopeId, KapuaId deviceId, DevicePackageDown AdvancedPackageDownloadOptions advancedOptions = packageDownloadRequest.getAdvancedOptions(); packageRequestPayload.setPackageDownloadRestart(advancedOptions.getRestart()); - packageRequestPayload.setPackageDownloadBlockSize(MoreObjects.firstNonNull(advancedOptions.getBlockSize(), packageManagementServiceSetting.getInt(PackageManagementServiceSettingKeys.PACKAGE_MANAGEMENT_SERVICE_SETTING_DOWDLOAD_DEFAULT_BLOCK_SIZE))); - packageRequestPayload.setPackageDownloadBlockDelay(MoreObjects.firstNonNull(advancedOptions.getBlockDelay(), packageManagementServiceSetting.getInt(PackageManagementServiceSettingKeys.PACKAGE_MANAGEMENT_SERVICE_SETTING_DOWDLOAD_DEFAULT_BLOCK_DELAY))); - packageRequestPayload.setPackageDownloadBlockTimeout(MoreObjects.firstNonNull(advancedOptions.getBlockTimeout(), packageManagementServiceSetting.getInt(PackageManagementServiceSettingKeys.PACKAGE_MANAGEMENT_SERVICE_SETTING_DOWDLOAD_DEFAULT_BLOCK_TIMEOUT))); - packageRequestPayload.setPackageDownloadBlockSize(MoreObjects.firstNonNull(advancedOptions.getNotifyBlockSize(), packageManagementServiceSetting.getInt(PackageManagementServiceSettingKeys.PACKAGE_MANAGEMENT_SERVICE_SETTING_DOWDLOAD_DEFAULT_NOTIFY_BLOCK_SIZE))); + packageRequestPayload.setPackageDownloadBlockSize(MoreObjects.firstNonNull(advancedOptions.getBlockSize(), + packageManagementServiceSetting.getInt(PackageManagementServiceSettingKeys.PACKAGE_MANAGEMENT_SERVICE_SETTING_DOWDLOAD_DEFAULT_BLOCK_SIZE))); + packageRequestPayload.setPackageDownloadBlockDelay(MoreObjects.firstNonNull(advancedOptions.getBlockDelay(), + packageManagementServiceSetting.getInt(PackageManagementServiceSettingKeys.PACKAGE_MANAGEMENT_SERVICE_SETTING_DOWDLOAD_DEFAULT_BLOCK_DELAY))); + packageRequestPayload.setPackageDownloadBlockTimeout(MoreObjects.firstNonNull(advancedOptions.getBlockTimeout(), + packageManagementServiceSetting.getInt(PackageManagementServiceSettingKeys.PACKAGE_MANAGEMENT_SERVICE_SETTING_DOWDLOAD_DEFAULT_BLOCK_TIMEOUT))); + packageRequestPayload.setPackageDownloadBlockSize(MoreObjects.firstNonNull(advancedOptions.getNotifyBlockSize(), + packageManagementServiceSetting.getInt(PackageManagementServiceSettingKeys.PACKAGE_MANAGEMENT_SERVICE_SETTING_DOWDLOAD_DEFAULT_NOTIFY_BLOCK_SIZE))); packageRequestPayload.setPackageDownloadInstallVerifierURI(advancedOptions.getInstallVerifierURI()); // Message @@ -492,7 +498,8 @@ public KapuaId uninstallExec(KapuaId scopeId, KapuaId deviceId, DevicePackageUni } @Override - public KapuaId uninstallExec(KapuaId scopeId, KapuaId deviceId, DevicePackageUninstallRequest packageUninstallRequest, DevicePackageUninstallOptions packageUninstallOptions) throws KapuaException { + public KapuaId uninstallExec(KapuaId scopeId, KapuaId deviceId, DevicePackageUninstallRequest packageUninstallRequest, DevicePackageUninstallOptions packageUninstallOptions) + throws KapuaException { // Argument Validation ArgumentValidator.notNull(scopeId, SCOPE_ID); ArgumentValidator.notNull(deviceId, DEVICE_ID); @@ -629,7 +636,7 @@ private List extractInputProperties(KapuaRequ // Device Management Operations protected KapuaId createManagementOperation(KapuaId scopeId, KapuaId deviceId, KapuaId operationId, KapuaRequestMessage requestMessage) throws KapuaException { - final DeviceManagementOperationCreator deviceManagementOperationCreator = deviceManagementOperationFactory.newCreator(scopeId); + final DeviceManagementOperationCreator deviceManagementOperationCreator = new DeviceManagementOperationCreator(scopeId); deviceManagementOperationCreator.setDeviceId(deviceId); deviceManagementOperationCreator.setOperationId(operationId); deviceManagementOperationCreator.setStartedOn(new Date()); diff --git a/service/device/management/packages/job/src/main/java/org/eclipse/kapua/service/device/management/packages/job/AbstractDevicePackageTargetProcessor.java b/service/device/management/packages/job/src/main/java/org/eclipse/kapua/service/device/management/packages/job/AbstractDevicePackageTargetProcessor.java index 9657e50dacb..dff1bd01868 100644 --- a/service/device/management/packages/job/src/main/java/org/eclipse/kapua/service/device/management/packages/job/AbstractDevicePackageTargetProcessor.java +++ b/service/device/management/packages/job/src/main/java/org/eclipse/kapua/service/device/management/packages/job/AbstractDevicePackageTargetProcessor.java @@ -12,6 +12,8 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.management.packages.job; +import javax.inject.Inject; + import org.eclipse.kapua.KapuaEntityNotFoundException; import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.commons.security.KapuaSecurityUtils; @@ -32,8 +34,6 @@ import org.eclipse.kapua.service.job.targets.JobTarget; import org.eclipse.kapua.service.job.targets.JobTargetStatus; -import javax.inject.Inject; - /** * {@link AbstractDevicePackageTargetProcessor} for {@link DevicePackageManagementService} operations. * @@ -54,7 +54,7 @@ public abstract class AbstractDevicePackageTargetProcessor extends AbstractDevic protected void createJobDeviceManagementOperation(KapuaId scopeId, KapuaId jobId, JobTarget jobTarget, KapuaId operationId) throws KapuaException { // Save the jobId-deviceManagementOperationId pair to track resuming - JobDeviceManagementOperationCreator jobDeviceManagementOperationCreator = jobDeviceManagementOperationFactory.newCreator(scopeId); + JobDeviceManagementOperationCreator jobDeviceManagementOperationCreator = new JobDeviceManagementOperationCreator(scopeId); jobDeviceManagementOperationCreator.setJobId(jobId); jobDeviceManagementOperationCreator.setDeviceManagementOperationId(operationId); diff --git a/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/DeviceManagementOperationCreator.java b/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/DeviceManagementOperationCreator.java index 7ee48462520..351daa9aa7a 100644 --- a/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/DeviceManagementOperationCreator.java +++ b/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/DeviceManagementOperationCreator.java @@ -12,12 +12,9 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.management.registry.operation; -import org.eclipse.kapua.model.KapuaEntityCreator; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.model.id.KapuaIdAdapter; -import org.eclipse.kapua.model.xml.DateXmlAdapter; -import org.eclipse.kapua.service.device.management.message.KapuaMethod; -import org.eclipse.kapua.service.device.management.message.notification.NotifyStatus; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; @@ -26,57 +23,116 @@ import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; -import java.util.Date; -import java.util.List; + +import org.eclipse.kapua.model.KapuaEntityCreator; +import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.model.id.KapuaIdAdapter; +import org.eclipse.kapua.model.xml.DateXmlAdapter; +import org.eclipse.kapua.service.device.management.message.KapuaMethod; +import org.eclipse.kapua.service.device.management.message.notification.NotifyStatus; @XmlRootElement(name = "deviceManagementOperationCreator") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = DeviceManagementOperationXmlRegistry.class, factoryMethod = "newDeviceManagementOperationCreator") -public interface DeviceManagementOperationCreator extends KapuaEntityCreator { +@XmlType +public class DeviceManagementOperationCreator extends KapuaEntityCreator { + + private Date startedOn; + private KapuaId deviceId; + private KapuaId operationId; + private String appId; + private KapuaMethod action; + private String resource; + private NotifyStatus status; + private List inputProperties; + + public DeviceManagementOperationCreator() { + } + + public DeviceManagementOperationCreator(KapuaId scopeId) { + super(scopeId); + } + + public DeviceManagementOperationCreator(KapuaEntityCreator entityCreator) { + super(entityCreator); + } @XmlElement(name = "startedOn") @XmlJavaTypeAdapter(DateXmlAdapter.class) - public Date getStartedOn(); + public Date getStartedOn() { + return startedOn; + } - void setStartedOn(Date startedOn); + public void setStartedOn(Date startedOn) { + this.startedOn = startedOn; + } @XmlElement(name = "deviceId") @XmlJavaTypeAdapter(KapuaIdAdapter.class) - KapuaId getDeviceId(); - - void setDeviceId(KapuaId deviceId); + public KapuaId getDeviceId() { + return deviceId; + } + public void setDeviceId(KapuaId deviceId) { + this.deviceId = deviceId; + } @XmlElement(name = "operationId") @XmlJavaTypeAdapter(KapuaIdAdapter.class) - KapuaId getOperationId(); - - void setOperationId(KapuaId operationId); + public KapuaId getOperationId() { + return operationId; + } + public void setOperationId(KapuaId operationId) { + this.operationId = operationId; + } @XmlElement(name = "appId") - String getAppId(); + public String getAppId() { + return appId; + } - void setAppId(String appId); + public void setAppId(String appId) { + this.appId = appId; + } @XmlElement(name = "action") - KapuaMethod getAction(); + public KapuaMethod getAction() { + return action.normalizeAction(); + } - void setAction(KapuaMethod action); + public void setAction(KapuaMethod action) { + this.action = action.normalizeAction(); + } @XmlElement(name = "resource") - String getResource(); + public String getResource() { + return resource; + } - void setResource(String resource); + public void setResource(String resource) { + this.resource = resource; + } @XmlElement(name = "status") - NotifyStatus getStatus(); + public NotifyStatus getStatus() { + return status; + } - void setStatus(NotifyStatus status); + public void setStatus(NotifyStatus status) { + this.status = status; + } @XmlElementWrapper(name = "operationProperties") @XmlElement(name = "operationProperty") -

    List

    getInputProperties(); + public List getInputProperties() { + if (inputProperties == null) { + inputProperties = new ArrayList<>(); + } + + return inputProperties; + } - void setInputProperties(List inputProperties); + public void setInputProperties(List inputProperties) { + this.inputProperties = inputProperties; + } } diff --git a/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/DeviceManagementOperationFactory.java b/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/DeviceManagementOperationFactory.java index d42678c6005..05f03b72284 100644 --- a/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/DeviceManagementOperationFactory.java +++ b/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/DeviceManagementOperationFactory.java @@ -20,7 +20,7 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface DeviceManagementOperationFactory extends KapuaEntityFactory { +public interface DeviceManagementOperationFactory extends KapuaEntityFactory { /** * Instantiates a new {@link DeviceManagementOperationProperty}. diff --git a/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/DeviceManagementOperationXmlRegistry.java b/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/DeviceManagementOperationXmlRegistry.java index dae33e20998..3f14358fbff 100644 --- a/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/DeviceManagementOperationXmlRegistry.java +++ b/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/DeviceManagementOperationXmlRegistry.java @@ -30,9 +30,4 @@ public class DeviceManagementOperationXmlRegistry { DeviceManagementOperation newDeviceManagementOperation() { return factory.newEntity(null); } - - DeviceManagementOperationCreator newDeviceManagementOperationCreator() { - return factory.newCreator(null); - } - } diff --git a/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/ManagementOperationNotificationCreator.java b/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/ManagementOperationNotificationCreator.java index dd247156e92..f9622d4689d 100644 --- a/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/ManagementOperationNotificationCreator.java +++ b/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/ManagementOperationNotificationCreator.java @@ -12,13 +12,7 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.management.registry.operation.notification; -import org.eclipse.kapua.model.KapuaEntityCreator; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.model.id.KapuaIdAdapter; -import org.eclipse.kapua.model.xml.DateXmlAdapter; -import org.eclipse.kapua.service.device.management.message.notification.NotifyStatus; -import org.eclipse.kapua.service.device.management.registry.operation.DeviceManagementOperation; -import org.eclipse.kapua.service.device.management.registry.operation.DeviceManagementOperationStatus; +import java.util.Date; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; @@ -26,7 +20,14 @@ import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; -import java.util.Date; + +import org.eclipse.kapua.model.KapuaEntityCreator; +import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.model.id.KapuaIdAdapter; +import org.eclipse.kapua.model.xml.DateXmlAdapter; +import org.eclipse.kapua.service.device.management.message.notification.NotifyStatus; +import org.eclipse.kapua.service.device.management.registry.operation.DeviceManagementOperation; +import org.eclipse.kapua.service.device.management.registry.operation.DeviceManagementOperationStatus; /** * {@link ManagementOperationNotificationCreator} definition. @@ -35,8 +36,26 @@ */ @XmlRootElement(name = "deviceManagementOperationNotificationCreator") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = ManagementOperationNotificationXmlRegistry.class, factoryMethod = "newManagementOperationNotificationCreator") -public interface ManagementOperationNotificationCreator extends KapuaEntityCreator { +@XmlType +public class ManagementOperationNotificationCreator extends KapuaEntityCreator { + + private KapuaId operationId; + private Date sentOn; + private DeviceManagementOperationStatus status; + private String resource; + private Integer progress; + private String message; + + public ManagementOperationNotificationCreator() { + } + + public ManagementOperationNotificationCreator(KapuaId scopeId) { + super(scopeId); + } + + public ManagementOperationNotificationCreator(KapuaEntityCreator entityCreator) { + super(entityCreator); + } /** * Gets the {@link DeviceManagementOperation#getId()}. @@ -46,15 +65,20 @@ public interface ManagementOperationNotificationCreator extends KapuaEntityCreat */ @XmlElement(name = "operationId") @XmlJavaTypeAdapter(KapuaIdAdapter.class) - KapuaId getOperationId(); + public KapuaId getOperationId() { + return operationId; + } /** * Sets the {@link DeviceManagementOperation#getId()}. * - * @param operationId The {@link DeviceManagementOperation#getId()}. + * @param operationId + * The {@link DeviceManagementOperation#getId()}. * @since 1.0.0 */ - void setOperationId(KapuaId operationId); + public void setOperationId(KapuaId operationId) { + this.operationId = operationId; + } /** * Gets the {@link Date} of when the notification has been sent to the platform. @@ -64,15 +88,20 @@ public interface ManagementOperationNotificationCreator extends KapuaEntityCreat */ @XmlElement(name = "sentOn") @XmlJavaTypeAdapter(DateXmlAdapter.class) - Date getSentOn(); + public Date getSentOn() { + return sentOn; + } /** * Sets the {@link Date} of when the notification has been sent to the platform. * - * @param sentOn The {@link Date} of when the notification has been sent to the platform. + * @param sentOn + * The {@link Date} of when the notification has been sent to the platform. * @since 1.0.0 */ - void setSentOn(Date sentOn); + public void setSentOn(Date sentOn) { + this.sentOn = sentOn; + } /** * Gets the {@link NotifyStatus} @@ -81,15 +110,20 @@ public interface ManagementOperationNotificationCreator extends KapuaEntityCreat * @since 1.0.0 */ @XmlElement(name = "status") - DeviceManagementOperationStatus getStatus(); + public DeviceManagementOperationStatus getStatus() { + return status; + } /** * Sets the {@link NotifyStatus} * - * @param status The {@link NotifyStatus} + * @param status + * The {@link NotifyStatus} * @since 1.0.0 */ - void setStatus(DeviceManagementOperationStatus status); + public void setStatus(DeviceManagementOperationStatus status) { + this.status = status; + } /** * Gets the {@link DeviceManagementOperation#getResource()} @@ -98,15 +132,20 @@ public interface ManagementOperationNotificationCreator extends KapuaEntityCreat * @since 1.0.0 */ @XmlElement(name = "resource") - String getResource(); + public String getResource() { + return resource; + } /** * Sets the {@link DeviceManagementOperation#getResource()} * - * @param resource The {@link DeviceManagementOperation#getResource()} + * @param resource + * The {@link DeviceManagementOperation#getResource()} * @since 1.0.0 */ - void setResource(String resource); + public void setResource(String resource) { + this.resource = resource; + } /** * Gets the progress percentage of the processing. @@ -115,15 +154,20 @@ public interface ManagementOperationNotificationCreator extends KapuaEntityCreat * @since 1.0.0 */ @XmlElement(name = "progress") - Integer getProgress(); + public Integer getProgress() { + return progress; + } /** * Sets the progress percentage of the processing. * - * @param progress The progress percentage of the processing. + * @param progress + * The progress percentage of the processing. * @since 1.0.0 */ - void setProgress(Integer progress); + public void setProgress(Integer progress) { + this.progress = progress; + } /** * Gets the detailed message related to the {@link NotifyStatus} @@ -131,13 +175,18 @@ public interface ManagementOperationNotificationCreator extends KapuaEntityCreat * @return The detailed message related to the {@link NotifyStatus} * @since 1.2.0 */ - String getMessage(); + public String getMessage() { + return message; + } /** * Sets the detailed message related to the {@link NotifyStatus} * - * @param message The detailed message related to the {@link NotifyStatus} + * @param message + * The detailed message related to the {@link NotifyStatus} * @since 1.2.0 */ - void setMessage(String message); + public void setMessage(String message) { + this.message = message; + } } diff --git a/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/ManagementOperationNotificationFactory.java b/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/ManagementOperationNotificationFactory.java index 46e1515076c..e21a5916055 100644 --- a/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/ManagementOperationNotificationFactory.java +++ b/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/ManagementOperationNotificationFactory.java @@ -20,6 +20,6 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface ManagementOperationNotificationFactory extends KapuaEntityFactory { +public interface ManagementOperationNotificationFactory extends KapuaEntityFactory { } diff --git a/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/ManagementOperationNotificationXmlRegistry.java b/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/ManagementOperationNotificationXmlRegistry.java index 6e4b125a51a..5bbd900268c 100644 --- a/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/ManagementOperationNotificationXmlRegistry.java +++ b/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/ManagementOperationNotificationXmlRegistry.java @@ -29,9 +29,4 @@ public class ManagementOperationNotificationXmlRegistry { ManagementOperationNotification newManagementOperationNotification() { return managementOperationNotificationFactory.newEntity(null); } - - ManagementOperationNotificationCreator newManagementOperationNotificationCreator() { - return managementOperationNotificationFactory.newCreator(null); - } - } diff --git a/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/manager/internal/DeviceManagementRegistryManagerServiceImpl.java b/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/manager/internal/DeviceManagementRegistryManagerServiceImpl.java index d8af6c324ae..a65d7c16721 100644 --- a/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/manager/internal/DeviceManagementRegistryManagerServiceImpl.java +++ b/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/manager/internal/DeviceManagementRegistryManagerServiceImpl.java @@ -31,7 +31,6 @@ import org.eclipse.kapua.service.device.management.registry.operation.notification.ManagementOperationNotification; import org.eclipse.kapua.service.device.management.registry.operation.notification.ManagementOperationNotificationAttributes; import org.eclipse.kapua.service.device.management.registry.operation.notification.ManagementOperationNotificationCreator; -import org.eclipse.kapua.service.device.management.registry.operation.notification.ManagementOperationNotificationFactory; import org.eclipse.kapua.service.device.management.registry.operation.notification.ManagementOperationNotificationListResult; import org.eclipse.kapua.service.device.management.registry.operation.notification.ManagementOperationNotificationQuery; import org.eclipse.kapua.service.device.management.registry.operation.notification.ManagementOperationNotificationService; @@ -47,18 +46,15 @@ public class DeviceManagementRegistryManagerServiceImpl implements DeviceManagem private final DeviceManagementOperationRegistryService deviceManagementOperationRegistryService; private final ManagementOperationNotificationService managementOperationNotificationService; - private final ManagementOperationNotificationFactory managementOperationNotificationFactory; private static final String LOG_MESSAGE_GENERATING = "Generating..."; @Inject public DeviceManagementRegistryManagerServiceImpl( DeviceManagementOperationRegistryService deviceManagementOperationRegistryService, - ManagementOperationNotificationService managementOperationNotificationService, - ManagementOperationNotificationFactory managementOperationNotificationFactory) { + ManagementOperationNotificationService managementOperationNotificationService) { this.deviceManagementOperationRegistryService = deviceManagementOperationRegistryService; this.managementOperationNotificationService = managementOperationNotificationService; - this.managementOperationNotificationFactory = managementOperationNotificationFactory; } @Override @@ -105,7 +101,7 @@ public void processCompletedNotification(KapuaId scopeId, KapuaId operationId, D public void storeManagementNotification(KapuaId scopeId, KapuaId operationId, Date updateOn, NotifyStatus notifyStatus, String resource, Integer progress, String message) throws KapuaException { DeviceManagementOperation deviceManagementOperation = getDeviceManagementOperation(scopeId, operationId); - ManagementOperationNotificationCreator managementOperationNotificationCreator = managementOperationNotificationFactory.newCreator(scopeId); + ManagementOperationNotificationCreator managementOperationNotificationCreator = new ManagementOperationNotificationCreator(scopeId); managementOperationNotificationCreator.setOperationId(deviceManagementOperation.getId()); managementOperationNotificationCreator.setSentOn(updateOn); managementOperationNotificationCreator.setStatus(DeviceManagementOperationStatus.readFrom(notifyStatus)); diff --git a/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/internal/DeviceManagementOperationCreatorImpl.java b/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/internal/DeviceManagementOperationCreatorImpl.java deleted file mode 100644 index 1c47f3cbd93..00000000000 --- a/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/internal/DeviceManagementOperationCreatorImpl.java +++ /dev/null @@ -1,126 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017, 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.service.device.management.registry.operation.internal; - -import org.eclipse.kapua.commons.model.AbstractKapuaEntityCreator; -import org.eclipse.kapua.commons.model.id.KapuaEid; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.service.device.management.message.KapuaMethod; -import org.eclipse.kapua.service.device.management.message.notification.NotifyStatus; -import org.eclipse.kapua.service.device.management.registry.operation.DeviceManagementOperation; -import org.eclipse.kapua.service.device.management.registry.operation.DeviceManagementOperationCreator; -import org.eclipse.kapua.service.device.management.registry.operation.DeviceManagementOperationProperty; - -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -public class DeviceManagementOperationCreatorImpl extends AbstractKapuaEntityCreator implements DeviceManagementOperationCreator { - - private Date startedOn; - private KapuaEid deviceId; - private KapuaEid operationId; - private String appId; - private KapuaMethod action; - private String resource; - private NotifyStatus status; - private List inputProperties; - - public DeviceManagementOperationCreatorImpl(KapuaId scopeId) { - super(scopeId); - } - - @Override - public Date getStartedOn() { - return startedOn; - } - - @Override - public void setStartedOn(Date startedOn) { - this.startedOn = startedOn; - } - - @Override - public KapuaEid getDeviceId() { - return deviceId; - } - - @Override - public void setDeviceId(KapuaId deviceId) { - this.deviceId = KapuaEid.parseKapuaId(deviceId); - } - - @Override - public KapuaEid getOperationId() { - return operationId; - } - - @Override - public void setOperationId(KapuaId operationId) { - this.operationId = KapuaEid.parseKapuaId(operationId); - } - - @Override - public String getAppId() { - return appId; - } - - @Override - public void setAppId(String appId) { - this.appId = appId; - } - - @Override - public KapuaMethod getAction() { - return action.normalizeAction(); - } - - @Override - public void setAction(KapuaMethod action) { - this.action = action.normalizeAction(); - } - - @Override - public String getResource() { - return resource; - } - - @Override - public void setResource(String resource) { - this.resource = resource; - } - - @Override - public NotifyStatus getStatus() { - return status; - } - - @Override - public void setStatus(NotifyStatus status) { - this.status = status; - } - - @Override - public List getInputProperties() { - if (inputProperties == null) { - inputProperties = new ArrayList<>(); - } - - return inputProperties; - } - - @Override - public void setInputProperties(List inputProperties) { - this.inputProperties = inputProperties; - } -} diff --git a/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/internal/DeviceManagementOperationFactoryImpl.java b/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/internal/DeviceManagementOperationFactoryImpl.java index ecd84b9f59a..26f703a8dc1 100644 --- a/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/internal/DeviceManagementOperationFactoryImpl.java +++ b/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/internal/DeviceManagementOperationFactoryImpl.java @@ -17,7 +17,6 @@ import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.device.management.registry.operation.DeviceManagementOperation; -import org.eclipse.kapua.service.device.management.registry.operation.DeviceManagementOperationCreator; import org.eclipse.kapua.service.device.management.registry.operation.DeviceManagementOperationFactory; import org.eclipse.kapua.service.device.management.registry.operation.DeviceManagementOperationProperty; @@ -34,11 +33,6 @@ public DeviceManagementOperation newEntity(KapuaId scopeId) { return new DeviceManagementOperationImpl(scopeId); } - @Override - public DeviceManagementOperationCreator newCreator(KapuaId scopeId) { - return new DeviceManagementOperationCreatorImpl(scopeId); - } - @Override public DeviceManagementOperationProperty newStepProperty(String name, String propertyType, String propertyValue) { return new DeviceManagementOperationPropertyImpl(name, propertyType, propertyValue); diff --git a/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/internal/ManagementOperationNotificationCreatorImpl.java b/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/internal/ManagementOperationNotificationCreatorImpl.java deleted file mode 100644 index 390b1285293..00000000000 --- a/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/internal/ManagementOperationNotificationCreatorImpl.java +++ /dev/null @@ -1,95 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017, 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.service.device.management.registry.operation.notification.internal; - -import org.eclipse.kapua.commons.model.AbstractKapuaEntityCreator; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.service.device.management.registry.operation.DeviceManagementOperationStatus; -import org.eclipse.kapua.service.device.management.registry.operation.notification.ManagementOperationNotification; -import org.eclipse.kapua.service.device.management.registry.operation.notification.ManagementOperationNotificationCreator; - -import java.util.Date; - -public class ManagementOperationNotificationCreatorImpl extends AbstractKapuaEntityCreator implements ManagementOperationNotificationCreator { - - private KapuaId operationId; - private Date sentOn; - private DeviceManagementOperationStatus status; - private String resource; - private Integer progress; - private String message; - - public ManagementOperationNotificationCreatorImpl(KapuaId scopeId) { - super(scopeId); - } - - @Override - public KapuaId getOperationId() { - return operationId; - } - - @Override - public void setOperationId(KapuaId operationId) { - this.operationId = operationId; - } - - @Override - public Date getSentOn() { - return sentOn; - } - - @Override - public void setSentOn(Date sentOn) { - this.sentOn = sentOn; - } - - @Override - public DeviceManagementOperationStatus getStatus() { - return status; - } - - @Override - public void setStatus(DeviceManagementOperationStatus status) { - this.status = status; - } - - @Override - public String getResource() { - return resource; - } - - @Override - public void setResource(String resource) { - this.resource = resource; - } - - @Override - public Integer getProgress() { - return progress; - } - - @Override - public void setProgress(Integer progress) { - this.progress = progress; - } - - @Override - public String getMessage() { - return message; - } - - @Override - public void setMessage(String message) { - this.message = message; - } -} diff --git a/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/internal/ManagementOperationNotificationFactoryImpl.java b/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/internal/ManagementOperationNotificationFactoryImpl.java index 180b8ee32cc..d7ec4a6efc4 100644 --- a/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/internal/ManagementOperationNotificationFactoryImpl.java +++ b/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/internal/ManagementOperationNotificationFactoryImpl.java @@ -16,7 +16,6 @@ import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.device.management.registry.operation.notification.ManagementOperationNotification; -import org.eclipse.kapua.service.device.management.registry.operation.notification.ManagementOperationNotificationCreator; import org.eclipse.kapua.service.device.management.registry.operation.notification.ManagementOperationNotificationFactory; /** @@ -32,11 +31,6 @@ public ManagementOperationNotification newEntity(KapuaId scopeId) { return new ManagementOperationNotificationImpl(scopeId); } - @Override - public ManagementOperationNotificationCreator newCreator(KapuaId scopeId) { - return new ManagementOperationNotificationCreatorImpl(scopeId); - } - @Override public ManagementOperationNotification clone(ManagementOperationNotification managementOperationNotification) { return new ManagementOperationNotificationImpl(managementOperationNotification); diff --git a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/DeviceCreator.java b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/DeviceCreator.java index 7ce14db5eb7..07b5302e15b 100644 --- a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/DeviceCreator.java +++ b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/DeviceCreator.java @@ -12,8 +12,12 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.registry; +import java.util.ArrayList; +import java.util.HashSet; import java.util.List; import java.util.Set; + +import javax.validation.constraints.NotNull; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; @@ -21,6 +25,7 @@ import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; +import org.eclipse.kapua.model.KapuaEntityCreator; import org.eclipse.kapua.model.KapuaUpdatableEntityCreator; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.model.id.KapuaIdAdapter; @@ -29,12 +34,10 @@ import org.eclipse.kapua.service.device.registry.event.DeviceEvent; /** - * {@link DeviceCreator} encapsulates all the information needed to create a new {@link Device} in the system.
    - * The data provided will be used to seed the new {@link Device} and its related information.
    - * The fields of the {@link DeviceCreator} presents the attributes that are searchable for a given device.
    - * The DeviceCreator Properties field can be used to provide additional properties associated to the Device; - * those properties will not be searchable through Device queries.
    - * The clientId field of the Device is used to store the MAC address of the primary network interface of the device. + * {@link DeviceCreator} encapsulates all the information needed to create a new {@link Device} in the system.
    The data provided will be used to seed the new {@link Device} and its related + * information.
    The fields of the {@link DeviceCreator} presents the attributes that are searchable for a given device.
    The DeviceCreator Properties field can be used to provide additional + * properties associated to the Device; those properties will not be searchable through Device queries.
    The clientId field of the Device is used to store the MAC address of the primary network + * interface of the device. * * @since 1.0.0 */ @@ -71,8 +74,56 @@ "extendedProperties", "tagIds", "tamperStatus" -}, factoryClass = DeviceXmlRegistry.class, factoryMethod = "newDeviceCreator") -public interface DeviceCreator extends KapuaUpdatableEntityCreator { +}) +public class DeviceCreator extends KapuaUpdatableEntityCreator { + + private static final long serialVersionUID = 8497299443773395462L; + private KapuaId groupId; + private String clientId; + private DeviceStatus status = DeviceStatus.ENABLED; + private KapuaId connectionId; + private KapuaId lastEventId; + private String displayName; + private String serialNumber; + private String modelId; + private String modelName; + private String imei; + private String imsi; + private String iccid; + private String biosVersion; + private String firmwareVersion; + private String osVersion; + private String jvmVersion; + private String osgiFrameworkVersion; + private String applicationFrameworkVersion; + private String connectionInterface; + private String connectionIp; + private String applicationIdentifiers; + private String acceptEncoding; + private String customAttribute1; + private String customAttribute2; + private String customAttribute3; + private String customAttribute4; + private String customAttribute5; + private List extendedProperties; + private String tamperStatus; + private Set tagIds; + + public DeviceCreator() { + } + + public DeviceCreator(KapuaId scopeId) { + super(scopeId); + } + + public DeviceCreator(KapuaEntityCreator entityCreator) { + super(entityCreator); + } + + public DeviceCreator(KapuaId scopeId, String clientId) { + super(scopeId); + this.clientId = clientId; + } /** * Gets the {@link Group#getId()}. @@ -82,15 +133,20 @@ public interface DeviceCreator extends KapuaUpdatableEntityCreator { */ @XmlElement(name = "groupId") @XmlJavaTypeAdapter(KapuaIdAdapter.class) - KapuaId getGroupId(); + public KapuaId getGroupId() { + return groupId; + } /** * Sets the {@link Group#getId()}. * - * @param groupId The {@link Group#getId()}. + * @param groupId + * The {@link Group#getId()}. * @since 1.0.0 */ - void setGroupId(KapuaId groupId); + public void setGroupId(KapuaId groupId) { + this.groupId = groupId; + } /** * Gets the client identifier. @@ -99,15 +155,20 @@ public interface DeviceCreator extends KapuaUpdatableEntityCreator { * @since 1.0.0 */ @XmlElement(name = "clientId") - String getClientId(); + public String getClientId() { + return clientId; + } /** * Sets the client identifier. * - * @param clientId The client identifier. + * @param clientId + * The client identifier. * @since 1.0.0 */ - void setClientId(String clientId); + public void setClientId(String clientId) { + this.clientId = clientId; + } /** * Gets the {@link DeviceConnection#getId()}. @@ -117,15 +178,20 @@ public interface DeviceCreator extends KapuaUpdatableEntityCreator { */ @XmlElement(name = "connectionId") @XmlJavaTypeAdapter(KapuaIdAdapter.class) - KapuaId getConnectionId(); + public KapuaId getConnectionId() { + return connectionId; + } /** * Sets the {@link DeviceConnection#getId()}. * - * @param connectionId The {@link DeviceConnection#getId()}. + * @param connectionId + * The {@link DeviceConnection#getId()}. * @since 1.0.0 */ - void setConnectionId(KapuaId connectionId); + public void setConnectionId(KapuaId connectionId) { + this.connectionId = connectionId; + } /** * Gets the {@link DeviceStatus}. @@ -134,15 +200,20 @@ public interface DeviceCreator extends KapuaUpdatableEntityCreator { * @since 1.0.0 */ @XmlElement(name = "status") - DeviceStatus getStatus(); + public DeviceStatus getStatus() { + return status; + } /** * Sets the {@link DeviceStatus}. * - * @param status The {@link DeviceStatus}. + * @param status + * The {@link DeviceStatus}. * @since 1.0.0 */ - void setStatus(DeviceStatus status); + public void setStatus(DeviceStatus status) { + this.status = status; + } /** * Gets the display name. @@ -151,15 +222,20 @@ public interface DeviceCreator extends KapuaUpdatableEntityCreator { * @since 1.0.0 */ @XmlElement(name = "displayName") - String getDisplayName(); + public String getDisplayName() { + return displayName; + } /** * Sets the display name. * - * @param diplayName The display name. + * @param displayName + * The display name. * @since 1.0.0 */ - void setDisplayName(String diplayName); + public void setDisplayName(String displayName) { + this.displayName = displayName; + } /** * Gets the last {@link DeviceEvent#getId()}. @@ -169,15 +245,20 @@ public interface DeviceCreator extends KapuaUpdatableEntityCreator { */ @XmlElement(name = "lastEventId") @XmlJavaTypeAdapter(KapuaIdAdapter.class) - KapuaId getLastEventId(); + public KapuaId getLastEventId() { + return lastEventId; + } /** * Sets the last {@link DeviceEvent#getId()}. * - * @param lastEventId The last {@link DeviceEvent#getId()}. + * @param lastEventId + * The last {@link DeviceEvent#getId()}. * @since 1.0.0 */ - void setLastEventId(KapuaId lastEventId); + public void setLastEventId(KapuaId lastEventId) { + this.lastEventId = lastEventId; + } /** * Gets the serial number. @@ -186,15 +267,20 @@ public interface DeviceCreator extends KapuaUpdatableEntityCreator { * @since 1.0.0 */ @XmlElement(name = "serialNumber") - String getSerialNumber(); + public String getSerialNumber() { + return serialNumber; + } /** * Sets the serial number. * - * @param serialNumber The serial number. + * @param serialNumber + * The serial number. * @since 1.0.0 */ - void setSerialNumber(String serialNumber); + public void setSerialNumber(String serialNumber) { + this.serialNumber = serialNumber; + } /** * Gets the model identifier. @@ -203,15 +289,20 @@ public interface DeviceCreator extends KapuaUpdatableEntityCreator { * @since 1.0.0 */ @XmlElement(name = "modelId") - String getModelId(); + public String getModelId() { + return modelId; + } /** * Sets the model identifier. * - * @param modelId The model identifier. + * @param modelId + * The model identifier. * @since 1.0.0 */ - void setModelId(String modelId); + public void setModelId(String modelId) { + this.modelId = modelId; + } /** * Gets the model name. @@ -220,15 +311,20 @@ public interface DeviceCreator extends KapuaUpdatableEntityCreator { * @since 1.0.0 */ @XmlElement(name = "modelName") - String getModelName(); + public String getModelName() { + return modelName; + } /** * Sets the model name. * - * @param modelName The model name. + * @param modelName + * The model name. * @since 1.0.0 */ - void setModelName(String modelName); + public void setModelName(String modelName) { + this.modelName = modelName; + } /** * Gets the modem imei. @@ -237,15 +333,20 @@ public interface DeviceCreator extends KapuaUpdatableEntityCreator { * @since 1.0.0 */ @XmlElement(name = "imei") - String getImei(); + public String getImei() { + return imei; + } /** * Sets the modem imei. * - * @param imei The modem imei. + * @param imei + * The modem imei. * @since 1.0.0 */ - void setImei(String imei); + public void setImei(String imei) { + this.imei = imei; + } /** * Gets the modem imsi. @@ -254,15 +355,20 @@ public interface DeviceCreator extends KapuaUpdatableEntityCreator { * @since 1.0.0 */ @XmlElement(name = "imsi") - String getImsi(); + public String getImsi() { + return this.imsi; + } /** * Sets the modem imsi. * - * @param imsi The modem imsi. + * @param imsi + * The modem imsi. * @since 1.0.0 */ - void setImsi(String imsi); + public void setImsi(String imsi) { + this.imsi = imsi; + } /** * Gets the modem iccid. @@ -271,15 +377,20 @@ public interface DeviceCreator extends KapuaUpdatableEntityCreator { * @since 1.0.0 */ @XmlElement(name = "iccid") - String getIccid(); + public String getIccid() { + return iccid; + } /** * Sets the modem iccid. * - * @param iccid The modem iccid. + * @param iccid + * The modem iccid. * @since 1.0.0 */ - void setIccid(String iccid); + public void setIccid(String iccid) { + this.iccid = iccid; + } /** * Gets the bios version. @@ -288,15 +399,20 @@ public interface DeviceCreator extends KapuaUpdatableEntityCreator { * @since 1.0.0 */ @XmlElement(name = "biosVersion") - String getBiosVersion(); + public String getBiosVersion() { + return biosVersion; + } /** * Sets the bios version. * - * @param biosVersion The bios version. + * @param biosVersion + * The bios version. * @since 1.0.0 */ - void setBiosVersion(String biosVersion); + public void setBiosVersion(String biosVersion) { + this.biosVersion = biosVersion; + } /** * Gets the firmware version. @@ -305,15 +421,20 @@ public interface DeviceCreator extends KapuaUpdatableEntityCreator { * @since 1.0.0 */ @XmlElement(name = "firmwareVersion") - String getFirmwareVersion(); + public String getFirmwareVersion() { + return firmwareVersion; + } /** * Sets the firmware version. * - * @param firmwareVersion The firmware version. + * @param firmwareVersion + * The firmware version. * @since 1.0.0 */ - void setFirmwareVersion(String firmwareVersion); + public void setFirmwareVersion(String firmwareVersion) { + this.firmwareVersion = firmwareVersion; + } /** * Gets the OS version. @@ -322,15 +443,20 @@ public interface DeviceCreator extends KapuaUpdatableEntityCreator { * @since 1.0.0 */ @XmlElement(name = "osVersion") - String getOsVersion(); + public String getOsVersion() { + return osVersion; + } /** * Sets the OS version. * - * @param osVersion The OS version. + * @param osVersion + * The OS version. * @since 1.0.0 */ - void setOsVersion(String osVersion); + public void setOsVersion(String osVersion) { + this.osVersion = osVersion; + } /** * Gets the JVM version. @@ -339,15 +465,20 @@ public interface DeviceCreator extends KapuaUpdatableEntityCreator { * @since 1.0.0 */ @XmlElement(name = "jvmVersion") - String getJvmVersion(); + public String getJvmVersion() { + return jvmVersion; + } /** * Sets the JVM version. * - * @param jvmVersion The JVM version. + * @param jvmVersion + * The JVM version. * @since 1.0.0 */ - void setJvmVersion(String jvmVersion); + public void setJvmVersion(String jvmVersion) { + this.jvmVersion = jvmVersion; + } /** * Gets the OSGi framework version. @@ -356,15 +487,20 @@ public interface DeviceCreator extends KapuaUpdatableEntityCreator { * @since 1.0.0 */ @XmlElement(name = "osgiFrameworkVersion") - String getOsgiFrameworkVersion(); + public String getOsgiFrameworkVersion() { + return osgiFrameworkVersion; + } /** * Sets the OSGi framework version. * - * @param osgiFrameworkVersion The OSGi framework version. + * @param osgiFrameworkVersion + * The OSGi framework version. * @since 1.0.0 */ - void setOsgiFrameworkVersion(String osgiFrameworkVersion); + public void setOsgiFrameworkVersion(String osgiFrameworkVersion) { + this.osgiFrameworkVersion = osgiFrameworkVersion; + } /** * Gets the application framework version. @@ -373,15 +509,20 @@ public interface DeviceCreator extends KapuaUpdatableEntityCreator { * @since 1.0.0 */ @XmlElement(name = "applicationFrameworkVersion") - String getApplicationFrameworkVersion(); + public String getApplicationFrameworkVersion() { + return applicationFrameworkVersion; + } /** * Sets the application framework version. * - * @param appFrameworkVersion The application framework version. + * @param appFrameworkVersion + * The application framework version. * @since 1.0.0 */ - void setApplicationFrameworkVersion(String appFrameworkVersion); + public void setApplicationFrameworkVersion(String appFrameworkVersion) { + this.applicationFrameworkVersion = appFrameworkVersion; + } /** * Gets the device network interfaces name. @@ -390,15 +531,20 @@ public interface DeviceCreator extends KapuaUpdatableEntityCreator { * @since 1.0.0 */ @XmlElement(name = "connectionInterface") - String getConnectionInterface(); + public String getConnectionInterface() { + return connectionInterface; + } /** * Sets the device network interfaces name. * - * @param connectionInterface The device network interfaces name. + * @param connectionInterface + * The device network interfaces name. * @since 1.0.0 */ - void setConnectionInterface(String connectionInterface); + public void setConnectionInterface(String connectionInterface) { + this.connectionInterface = connectionInterface; + } /** * Gets the device network interfaces IP. @@ -407,15 +553,20 @@ public interface DeviceCreator extends KapuaUpdatableEntityCreator { * @since 1.0.0 */ @XmlElement(name = "connectionIp") - String getConnectionIp(); + public String getConnectionIp() { + return connectionIp; + } /** * Sets the device network interfaces IP. * - * @param connectionIp The device network interfaces IP. + * @param connectionIp + * The device network interfaces IP. * @since 1.0.0 */ - void setConnectionIp(String connectionIp); + public void setConnectionIp(String connectionIp) { + this.connectionIp = connectionIp; + } /** * Gets the application identifiers supported. @@ -424,15 +575,20 @@ public interface DeviceCreator extends KapuaUpdatableEntityCreator { * @since 1.0.0 */ @XmlElement(name = "applicationIdentifiers") - String getApplicationIdentifiers(); + public String getApplicationIdentifiers() { + return applicationIdentifiers; + } /** * Sets the application identifiers supported. * - * @param applicationIdentifiers The application identifiers supported. + * @param applicationIdentifiers + * The application identifiers supported. * @since 1.0.0 */ - void setApplicationIdentifiers(String applicationIdentifiers); + public void setApplicationIdentifiers(String applicationIdentifiers) { + this.applicationIdentifiers = applicationIdentifiers; + } /** * Gets the accept encodings. @@ -441,15 +597,20 @@ public interface DeviceCreator extends KapuaUpdatableEntityCreator { * @since 1.0.0 */ @XmlElement(name = "acceptEncoding") - String getAcceptEncoding(); + public String getAcceptEncoding() { + return acceptEncoding; + } /** * Sets the accept encodings. * - * @param acceptEncoding The accept encodings. + * @param acceptEncoding + * The accept encodings. * @since 1.0.0 */ - void setAcceptEncoding(String acceptEncoding); + public void setAcceptEncoding(String acceptEncoding) { + this.acceptEncoding = acceptEncoding; + } /** * Gets the custom attribute 1. @@ -458,15 +619,20 @@ public interface DeviceCreator extends KapuaUpdatableEntityCreator { * @since 1.0.0 */ @XmlElement(name = "customAttribute1") - String getCustomAttribute1(); + public String getCustomAttribute1() { + return customAttribute1; + } /** * Sets the custom attribute 1. * - * @param customAttribute1 The custom attribute 1. + * @param customAttribute1 + * The custom attribute 1. * @since 1.0.0 */ - void setCustomAttribute1(String customAttribute1); + public void setCustomAttribute1(String customAttribute1) { + this.customAttribute1 = customAttribute1; + } /** * Gets the custom attribute 2. @@ -475,15 +641,20 @@ public interface DeviceCreator extends KapuaUpdatableEntityCreator { * @since 1.0.0 */ @XmlElement(name = "customAttribute2") - String getCustomAttribute2(); + public String getCustomAttribute2() { + return customAttribute2; + } /** * Sets the custom attribute 2. * - * @param customAttribute2 The custom attribute 2. + * @param customAttribute2 + * The custom attribute 2. * @since 1.0.0 */ - void setCustomAttribute2(String customAttribute2); + public void setCustomAttribute2(String customAttribute2) { + this.customAttribute2 = customAttribute2; + } /** * Gets the custom attribute 3. @@ -492,15 +663,20 @@ public interface DeviceCreator extends KapuaUpdatableEntityCreator { * @since 1.0.0 */ @XmlElement(name = "customAttribute3") - String getCustomAttribute3(); + public String getCustomAttribute3() { + return customAttribute3; + } /** * Sets the custom attribute 3. * - * @param customAttribute3 The custom attribute 3. + * @param customAttribute3 + * The custom attribute 3. * @since 1.0.0 */ - void setCustomAttribute3(String customAttribute3); + public void setCustomAttribute3(String customAttribute3) { + this.customAttribute3 = customAttribute3; + } /** * Gets the custom attribute 4. @@ -509,15 +685,20 @@ public interface DeviceCreator extends KapuaUpdatableEntityCreator { * @since 1.0.0 */ @XmlElement(name = "customAttribute4") - String getCustomAttribute4(); + public String getCustomAttribute4() { + return customAttribute4; + } /** * Sets the custom attribute 4. * - * @param customAttribute4 The custom attribute 4. + * @param customAttribute4 + * The custom attribute 4. * @since 1.0.0 */ - void setCustomAttribute4(String customAttribute4); + public void setCustomAttribute4(String customAttribute4) { + this.customAttribute4 = customAttribute4; + } /** * Gets the custom attribute 5. @@ -526,15 +707,20 @@ public interface DeviceCreator extends KapuaUpdatableEntityCreator { * @since 1.0.0 */ @XmlElement(name = "customAttribute5") - String getCustomAttribute5(); + public String getCustomAttribute5() { + return customAttribute5; + } /** * Sets the custom attribute 5. * - * @param customAttribute5 The custom attribute 5. + * @param customAttribute5 + * The custom attribute 5. * @since 1.0.0 */ - void setCustomAttribute5(String customAttribute5); + public void setCustomAttribute5(String customAttribute5) { + this.customAttribute5 = customAttribute5; + } /** * Gets the {@link DeviceExtendedProperty} {@link List}. @@ -543,23 +729,35 @@ public interface DeviceCreator extends KapuaUpdatableEntityCreator { * @since 1.5.0 */ @XmlElement(name = "extendedProperties") - List getExtendedProperties(); + public List getExtendedProperties() { + if (extendedProperties == null) { + extendedProperties = new ArrayList<>(); + } + + return extendedProperties; + } /** * Add a {@link DeviceExtendedProperty} to the {@link List}. * - * @param extendedProperty The {@link DeviceExtendedProperty} to add. + * @param extendedProperty + * The {@link DeviceExtendedProperty} to add. * @since 1.5.0 */ - void addExtendedProperty(DeviceExtendedProperty extendedProperty); + public void addExtendedProperty(@NotNull DeviceExtendedProperty extendedProperty) { + getExtendedProperties().add(extendedProperty); + } /** * Sets the {@link DeviceExtendedProperty} {@link List}. * - * @param extendedProperties The {@link DeviceExtendedProperty} {@link List}. + * @param extendedProperties + * The {@link DeviceExtendedProperty} {@link List}. * @since 1.5.0 */ - void setExtendedProperties(List extendedProperties); + public void setExtendedProperties(List extendedProperties) { + this.extendedProperties = extendedProperties; + } /** * Gets the tamper status. @@ -568,16 +766,20 @@ public interface DeviceCreator extends KapuaUpdatableEntityCreator { * @since 2.0.0 */ @XmlElement(name = "tamperStatus") - String getTamperStatus(); + public String getTamperStatus() { + return tamperStatus; + } /** * Sets the tamper status. * - * @param tamperStatus The tamper status. + * @param tamperStatus + * The tamper status. * @since 2.0.0 */ - void setTamperStatus(String tamperStatus); - + public void setTamperStatus(String tamperStatus) { + this.tamperStatus = tamperStatus; + } /** * Gets the list of tags associated with the device. @@ -587,13 +789,19 @@ public interface DeviceCreator extends KapuaUpdatableEntityCreator { */ @XmlElement(name = "tagIds") @XmlJavaTypeAdapter(KapuaIdAdapter.class) - Set getTagIds(); + public Set getTagIds() { + return tagIds == null ? new HashSet<>() : tagIds; + } /** * Sets the list of tags associated with the device. * - * @param tags The list of tags. + * @param tagIds + * The list of tags. * @since 2.0.0 */ - void setTagIds(Set tags); + public void setTagIds(Set tagIds) { + this.tagIds = tagIds; + } + } diff --git a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/DeviceFactory.java b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/DeviceFactory.java index a26482a45a9..1c199ecc111 100644 --- a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/DeviceFactory.java +++ b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/DeviceFactory.java @@ -13,7 +13,6 @@ package org.eclipse.kapua.service.device.registry; import org.eclipse.kapua.model.KapuaEntityFactory; -import org.eclipse.kapua.model.id.KapuaId; /** * {@link Device} {@link KapuaEntityFactory} definition. @@ -21,21 +20,7 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface DeviceFactory extends KapuaEntityFactory { - - /** - * Instantiates a new {@link DeviceCreator} - * - * @param scopeId - * The scope {@link KapuaId} to set into the {@link DeviceCreator} - * @param clientId - * The client id to set into the {@link DeviceCreator} - * @return The newly instantiated {@link DeviceCreator}. - * @since 1.0.0 - * @deprecated Since 1.5.0. Please use {@link #newCreator(KapuaId)}. - */ - @Deprecated - DeviceCreator newCreator(KapuaId scopeId, String clientId); +public interface DeviceFactory extends KapuaEntityFactory { /** * Instantiates a new {@link DeviceExtendedProperty}. diff --git a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/DeviceXmlRegistry.java b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/DeviceXmlRegistry.java index e5b43d14d30..758374e1fa3 100644 --- a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/DeviceXmlRegistry.java +++ b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/DeviceXmlRegistry.java @@ -36,16 +36,6 @@ public Device newDevice() { return deviceFactory.newEntity(null); } - /** - * Creates a new device creator - * - * @return - * @since 1.0.0 - */ - public DeviceCreator newDeviceCreator() { - return deviceFactory.newCreator(null, null); - } - /** * Instantiates a new {@link DeviceExtendedProperty}. * diff --git a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/DeviceConnectionCreator.java b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/DeviceConnectionCreator.java index 6ad48d24659..2826fb42f58 100644 --- a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/DeviceConnectionCreator.java +++ b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/DeviceConnectionCreator.java @@ -12,18 +12,44 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.registry.connection; +import javax.xml.bind.annotation.XmlElement; + +import org.eclipse.kapua.model.KapuaEntityCreator; import org.eclipse.kapua.model.KapuaUpdatableEntityCreator; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.device.registry.ConnectionUserCouplingMode; -import javax.xml.bind.annotation.XmlElement; - /** * Device connection creator service definition. * * @since 1.0 */ -public interface DeviceConnectionCreator extends KapuaUpdatableEntityCreator { +public class DeviceConnectionCreator extends KapuaUpdatableEntityCreator { + + private static final long serialVersionUID = 2740394157765904615L; + + private DeviceConnectionStatus status; + private String clientId; + private KapuaId userId; + private ConnectionUserCouplingMode userCouplingMode; + private KapuaId reservedUserId; + private boolean allowUserChange; + private String authenticationType; + private String lastAuthenticationType; + private String protocol; + private String clientIp; + private String serverIp; + + public DeviceConnectionCreator() { + } + + public DeviceConnectionCreator(KapuaId scopeId) { + super(scopeId); + } + + public DeviceConnectionCreator(KapuaEntityCreator entityCreator) { + super(entityCreator); + } /** * Get the device connection status @@ -31,70 +57,90 @@ public interface DeviceConnectionCreator extends KapuaUpdatableEntityCreatortrue if device can changhe user to connect, false if not. */ @XmlElement(name = "allowUserChange") - boolean getAllowUserChange(); + public boolean getAllowUserChange() { + return allowUserChange; + } /** * Sets whether or not the {@link DeviceConnection} can change user on the next login. * * @param allowUserChange */ - void setAllowUserChange(boolean allowUserChange); + public void setAllowUserChange(boolean allowUserChange) { + this.allowUserChange = allowUserChange; + } /** * Gets the allowed authentication type. @@ -117,15 +167,20 @@ public interface DeviceConnectionCreator extends KapuaUpdatableEntityCreator { +public interface DeviceConnectionFactory extends KapuaEntityFactory { } diff --git a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/DeviceConnectionOptionCreator.java b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/DeviceConnectionOptionCreator.java index 12d721b6130..e280b921677 100644 --- a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/DeviceConnectionOptionCreator.java +++ b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/DeviceConnectionOptionCreator.java @@ -12,6 +12,7 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.registry.connection.option; +import org.eclipse.kapua.model.KapuaEntityCreator; import org.eclipse.kapua.model.KapuaUpdatableEntityCreator; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.device.registry.ConnectionUserCouplingMode; @@ -21,35 +22,61 @@ * * @since 1.0 */ -public interface DeviceConnectionOptionCreator extends KapuaUpdatableEntityCreator { +public class DeviceConnectionOptionCreator extends KapuaUpdatableEntityCreator { + + private static final long serialVersionUID = 2740394157765904615L; + + private ConnectionUserCouplingMode userCouplingMode; + private KapuaId reservedUserId; + + private String authenticationType; + + public DeviceConnectionOptionCreator() { + } + + public DeviceConnectionOptionCreator(KapuaId scopeId) { + super(scopeId); + } + + public DeviceConnectionOptionCreator(KapuaEntityCreator entityCreator) { + super(entityCreator); + } /** * Get the device connection user coupling mode. * * @return */ - ConnectionUserCouplingMode getUserCouplingMode(); + public ConnectionUserCouplingMode getUserCouplingMode() { + return userCouplingMode; + } /** * Set the device connection user coupling mode. * * @param userCouplingMode */ - void setUserCouplingMode(ConnectionUserCouplingMode userCouplingMode); + public void setUserCouplingMode(ConnectionUserCouplingMode userCouplingMode) { + this.userCouplingMode = userCouplingMode; + } /** * Get the reserved user identifier * * @return */ - KapuaId getReservedUserId(); + public KapuaId getReservedUserId() { + return reservedUserId; + } /** * Set the reserved user identifier * * @param reservedUserId */ - void setReservedUserId(KapuaId reservedUserId); + public void setReservedUserId(KapuaId reservedUserId) { + this.reservedUserId = reservedUserId; + } /** * Gets the allowed authentication type. @@ -57,13 +84,18 @@ public interface DeviceConnectionOptionCreator extends KapuaUpdatableEntityCreat * @return The allowed authentication type. * @since 2.0.0 */ - String getAuthenticationType(); + public String getAuthenticationType() { + return authenticationType; + } /** * Sets the allowed authentication type. * - * @param authenticationType The allowed authentication type. + * @param authenticationType + * The allowed authentication type. * @since 2.0.0 */ - void setAuthenticationType(String authenticationType); + public void setAuthenticationType(String authenticationType) { + this.authenticationType = authenticationType; + } } diff --git a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/DeviceConnectionOptionFactory.java b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/DeviceConnectionOptionFactory.java index 1235da32793..6f115996981 100644 --- a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/DeviceConnectionOptionFactory.java +++ b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/DeviceConnectionOptionFactory.java @@ -20,6 +20,6 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface DeviceConnectionOptionFactory extends KapuaEntityFactory { +public interface DeviceConnectionOptionFactory extends KapuaEntityFactory { } diff --git a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/event/DeviceEventCreator.java b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/event/DeviceEventCreator.java index db201dd6ea5..5d3941d4139 100644 --- a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/event/DeviceEventCreator.java +++ b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/event/DeviceEventCreator.java @@ -12,130 +12,209 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.registry.event; +import java.util.Date; + +import javax.xml.bind.annotation.XmlElement; + import org.eclipse.kapua.message.KapuaPosition; import org.eclipse.kapua.model.KapuaEntityCreator; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.device.management.message.KapuaMethod; import org.eclipse.kapua.service.device.management.message.response.KapuaResponseCode; -import java.util.Date; - /** * Device event creator service definition. * * @since 1.0 */ -public interface DeviceEventCreator extends KapuaEntityCreator { +public class DeviceEventCreator extends KapuaEntityCreator { + + private static final long serialVersionUID = -3982569213440658172L; + @XmlElement(name = "deviceId") + private KapuaId deviceId; + + @XmlElement(name = "receivedOn") + private Date receivedOn; + + @XmlElement(name = "sentOn") + private Date sentOn; + + @XmlElement(name = "position") + private KapuaPosition position; + + @XmlElement(name = "resource") + private String resource; + + @XmlElement(name = "action") + private KapuaMethod action; + + @XmlElement(name = "responseCode") + private KapuaResponseCode responseCode; + + @XmlElement(name = "eventMessage") + private String eventMessage; + + public DeviceEventCreator() { + } + + public DeviceEventCreator(KapuaId scopeId) { + super(scopeId); + } + + public DeviceEventCreator(KapuaEntityCreator entityCreator) { + super(entityCreator); + } + + public DeviceEventCreator(KapuaId scopeId, KapuaId deviceId, Date receivedOn, String resource) { + super(scopeId); + this.action = KapuaMethod.CREATE; + this.deviceId = deviceId; + this.receivedOn = new Date(receivedOn.getTime()); + this.resource = resource; + } /** * Get the device identifier * * @return */ - KapuaId getDeviceId(); + public KapuaId getDeviceId() { + return deviceId; + } /** * Set the device identifier * * @param deviceId */ - void setDeviceId(KapuaId deviceId); + public void setDeviceId(KapuaId deviceId) { + this.deviceId = deviceId; + } /** * Get the sent on date * * @return */ - Date getSentOn(); + public Date getSentOn() { + return sentOn != null ? new Date(sentOn.getTime()) : null; + } /** * Set the sent on date * * @param sentOn */ - void setSentOn(Date sentOn); + public void setSentOn(Date sentOn) { + this.sentOn = sentOn; + } /** * Get the received on date * * @return */ - Date getReceivedOn(); + public Date getReceivedOn() { + return receivedOn != null ? new Date(receivedOn.getTime()) : null; + } /** * Set the received on date * * @param receivedOn */ - void setReceivedOn(Date receivedOn); + public void setReceivedOn(Date receivedOn) { + this.receivedOn = receivedOn; + } /** * Get device position * * @return */ - KapuaPosition getPosition(); + public KapuaPosition getPosition() { + return position; + } /** * Set device position * * @param position */ - void setPosition(KapuaPosition position); + public void setPosition(KapuaPosition position) { + this.position = position; + } /** * Get resource * * @return */ - String getResource(); + public String getResource() { + return resource; + } /** * Set resource * * @param resource */ - void setResource(String resource); + public void setResource(String resource) { + this.resource = resource; + } /** * GHet action * * @return */ - KapuaMethod getAction(); + public KapuaMethod getAction() { + return action.normalizeAction(); + } /** * Set action * * @param action */ - void setAction(KapuaMethod action); + public void setAction(KapuaMethod action) { + this.action = action.normalizeAction(); + } /** * Get response code * * @return */ - KapuaResponseCode getResponseCode(); + public KapuaResponseCode getResponseCode() { + return responseCode; + } /** * Set response code * * @param responseCode */ - void setResponseCode(KapuaResponseCode responseCode); + public void setResponseCode(KapuaResponseCode responseCode) { + this.responseCode = responseCode; + } /** * Get event message * * @return */ - String getEventMessage(); + public String getEventMessage() { + return eventMessage; + } /** * Set event message * * @param eventMessage */ - void setEventMessage(String eventMessage); + public void setEventMessage(String eventMessage) { + this.eventMessage = eventMessage; + } + } diff --git a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/event/DeviceEventFactory.java b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/event/DeviceEventFactory.java index 77e03ff7784..038dadb7b8d 100644 --- a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/event/DeviceEventFactory.java +++ b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/event/DeviceEventFactory.java @@ -12,10 +12,7 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.registry.event; -import java.util.Date; - import org.eclipse.kapua.model.KapuaEntityFactory; -import org.eclipse.kapua.model.id.KapuaId; /** * {@link DeviceEventFactory} definition. @@ -23,22 +20,6 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface DeviceEventFactory extends KapuaEntityFactory { - - /** - * Instantiates a new {@link DeviceEventCreator} - * - * @param scopeId - * The scope {@link KapuaId} to be set in the {@link DeviceEventCreator} - * @param deviceId - * The {@link org.eclipse.kapua.service.device.registry.Device} {@link KapuaId} to be set in the {@link DeviceEventCreator} - * @param receivedOn - * The received on {@link KapuaId} to be set in the {@link DeviceEventCreator} - * @param resource - * The resource {@link KapuaId} to be set in the {@link DeviceEventCreator} - * @return The newly instantiated {@link DeviceEventCreator} - * @since 1.0.0 - */ - DeviceEventCreator newCreator(KapuaId scopeId, KapuaId deviceId, Date receivedOn, String resource); +public interface DeviceEventFactory extends KapuaEntityFactory { } diff --git a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/internal/DeviceConnectionCreatorImpl.java b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/internal/DeviceConnectionCreatorImpl.java deleted file mode 100644 index 81d0e9406b6..00000000000 --- a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/internal/DeviceConnectionCreatorImpl.java +++ /dev/null @@ -1,161 +0,0 @@ -/******************************************************************************* - * 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.service.device.registry.connection.internal; - -import org.eclipse.kapua.commons.model.AbstractKapuaUpdatableEntityCreator; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.service.device.registry.ConnectionUserCouplingMode; -import org.eclipse.kapua.service.device.registry.connection.DeviceConnection; -import org.eclipse.kapua.service.device.registry.connection.DeviceConnectionCreator; -import org.eclipse.kapua.service.device.registry.connection.DeviceConnectionStatus; - -/** - * {@link DeviceConnectionCreator} implementation. - * - * @since 1.0.0 - */ -public class DeviceConnectionCreatorImpl extends AbstractKapuaUpdatableEntityCreator implements DeviceConnectionCreator { - - private static final long serialVersionUID = 2740394157765904615L; - - private DeviceConnectionStatus status; - private String clientId; - private KapuaId userId; - private ConnectionUserCouplingMode userCouplingMode; - private KapuaId reservedUserId; - private boolean allowUserChange; - private String authenticationType; - private String lastAuthenticationType; - private String protocol; - private String clientIp; - private String serverIp; - - /** - * Constructor - * - * @param scopeId - */ - public DeviceConnectionCreatorImpl(KapuaId scopeId) { - super(scopeId); - } - - @Override - public DeviceConnectionStatus getStatus() { - return status; - } - - @Override - public void setStatus(DeviceConnectionStatus status) { - this.status = status; - } - - @Override - public String getClientId() { - return clientId; - } - - @Override - public void setClientId(String clientId) { - this.clientId = clientId; - } - - @Override - public KapuaId getUserId() { - return userId; - } - - @Override - public void setUserId(KapuaId userId) { - this.userId = userId; - } - - @Override - public ConnectionUserCouplingMode getUserCouplingMode() { - return userCouplingMode; - } - - @Override - public void setUserCouplingMode(ConnectionUserCouplingMode userCouplingMode) { - this.userCouplingMode = userCouplingMode; - } - - @Override - public KapuaId getReservedUserId() { - return reservedUserId; - } - - @Override - public void setReservedUserId(KapuaId reservedUserId) { - this.reservedUserId = reservedUserId; - } - - @Override - public boolean getAllowUserChange() { - return allowUserChange; - } - - @Override - public void setAllowUserChange(boolean allowUserChange) { - this.allowUserChange = allowUserChange; - } - - @Override - public String getAuthenticationType() { - return authenticationType; - } - - @Override - public void setAuthenticationType(String authenticationType) { - this.authenticationType = authenticationType; - } - - @Override - public String getLastAuthenticationType() { - return lastAuthenticationType; - } - - @Override - public void setLastAuthenticationType(String lastAuthenticationType) { - this.lastAuthenticationType = lastAuthenticationType; - } - - @Override - public String getProtocol() { - return protocol; - } - - @Override - public void setProtocol(String protocol) { - this.protocol = protocol; - } - - @Override - public String getClientIp() { - return clientIp; - } - - @Override - public void setClientIp(String clientIp) { - this.clientIp = clientIp; - } - - @Override - public String getServerIp() { - return serverIp; - } - - @Override - public void setServerIp(String serverIp) { - this.serverIp = serverIp; - } -} diff --git a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/internal/DeviceConnectionFactoryImpl.java b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/internal/DeviceConnectionFactoryImpl.java index 734022e1f10..8b6c9c85138 100644 --- a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/internal/DeviceConnectionFactoryImpl.java +++ b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/internal/DeviceConnectionFactoryImpl.java @@ -17,7 +17,6 @@ import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.device.registry.connection.DeviceConnection; -import org.eclipse.kapua.service.device.registry.connection.DeviceConnectionCreator; import org.eclipse.kapua.service.device.registry.connection.DeviceConnectionFactory; /** @@ -28,11 +27,6 @@ @Singleton public class DeviceConnectionFactoryImpl implements DeviceConnectionFactory { - @Override - public DeviceConnectionCreator newCreator(KapuaId scopeId) { - return new DeviceConnectionCreatorImpl(scopeId); - } - @Override public DeviceConnection newEntity(KapuaId scopeId) { return new DeviceConnectionImpl(scopeId); diff --git a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/internal/DeviceConnectionOptionCreatorImpl.java b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/internal/DeviceConnectionOptionCreatorImpl.java deleted file mode 100644 index 91fb23d48df..00000000000 --- a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/internal/DeviceConnectionOptionCreatorImpl.java +++ /dev/null @@ -1,73 +0,0 @@ -/******************************************************************************* - * 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.service.device.registry.connection.option.internal; - -import org.eclipse.kapua.commons.model.AbstractKapuaUpdatableEntityCreator; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.service.device.registry.ConnectionUserCouplingMode; -import org.eclipse.kapua.service.device.registry.connection.option.DeviceConnectionOption; -import org.eclipse.kapua.service.device.registry.connection.option.DeviceConnectionOptionCreator; - -/** - * Device connection creator service implementation. - * - * @since 1.0 - */ -public class DeviceConnectionOptionCreatorImpl extends AbstractKapuaUpdatableEntityCreator implements DeviceConnectionOptionCreator { - - private static final long serialVersionUID = 2740394157765904615L; - - private ConnectionUserCouplingMode userCouplingMode; - private KapuaId reservedUserId; - - private String authenticationType; - - /** - * Constructor - * - * @param scopeId - */ - public DeviceConnectionOptionCreatorImpl(KapuaId scopeId) { - super(scopeId); - } - - @Override - public ConnectionUserCouplingMode getUserCouplingMode() { - return userCouplingMode; - } - - @Override - public void setUserCouplingMode(ConnectionUserCouplingMode userCouplingMode) { - this.userCouplingMode = userCouplingMode; - } - - @Override - public KapuaId getReservedUserId() { - return reservedUserId; - } - - @Override - public void setReservedUserId(KapuaId reservedUserId) { - this.reservedUserId = reservedUserId; - } - - @Override - public String getAuthenticationType() { - return authenticationType; - } - - @Override - public void setAuthenticationType(String authenticationType) { - this.authenticationType = authenticationType; - } -} diff --git a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/internal/DeviceConnectionOptionFactoryImpl.java b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/internal/DeviceConnectionOptionFactoryImpl.java index fb02d6595dd..1228ea1d555 100644 --- a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/internal/DeviceConnectionOptionFactoryImpl.java +++ b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/internal/DeviceConnectionOptionFactoryImpl.java @@ -17,7 +17,6 @@ import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.device.registry.connection.option.DeviceConnectionOption; -import org.eclipse.kapua.service.device.registry.connection.option.DeviceConnectionOptionCreator; import org.eclipse.kapua.service.device.registry.connection.option.DeviceConnectionOptionFactory; /** @@ -28,11 +27,6 @@ @Singleton public class DeviceConnectionOptionFactoryImpl implements DeviceConnectionOptionFactory { - @Override - public DeviceConnectionOptionCreator newCreator(KapuaId scopeId) { - return new DeviceConnectionOptionCreatorImpl(scopeId); - } - @Override public DeviceConnectionOption newEntity(KapuaId scopeId) { return new DeviceConnectionOptionImpl(scopeId); diff --git a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/event/internal/DeviceEventCreatorImpl.java b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/event/internal/DeviceEventCreatorImpl.java deleted file mode 100644 index 4cafa287f29..00000000000 --- a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/event/internal/DeviceEventCreatorImpl.java +++ /dev/null @@ -1,148 +0,0 @@ -/******************************************************************************* - * 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.service.device.registry.event.internal; - -import org.eclipse.kapua.commons.model.AbstractKapuaEntityCreator; -import org.eclipse.kapua.message.KapuaPosition; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.service.device.management.message.KapuaMethod; -import org.eclipse.kapua.service.device.management.message.response.KapuaResponseCode; -import org.eclipse.kapua.service.device.registry.event.DeviceEvent; -import org.eclipse.kapua.service.device.registry.event.DeviceEventCreator; - -import javax.xml.bind.annotation.XmlElement; -import java.util.Date; - -/** - * Device event creator service implementation. - * - * @since 1.0 - */ -public class DeviceEventCreatorImpl extends AbstractKapuaEntityCreator implements DeviceEventCreator { - - private static final long serialVersionUID = -3982569213440658172L; - - @XmlElement(name = "deviceId") - private KapuaId deviceId; - - @XmlElement(name = "receivedOn") - private Date receivedOn; - - @XmlElement(name = "sentOn") - private Date sentOn; - - @XmlElement(name = "position") - private KapuaPosition position; - - @XmlElement(name = "resource") - private String resource; - - @XmlElement(name = "action") - private KapuaMethod action; - - @XmlElement(name = "responseCode") - private KapuaResponseCode responseCode; - - @XmlElement(name = "eventMessage") - private String eventMessage; - - /** - * Constructor - * - * @param scopeId - */ - protected DeviceEventCreatorImpl(KapuaId scopeId) { - super(scopeId); - } - - @Override - public KapuaId getDeviceId() { - return deviceId; - } - - @Override - public void setDeviceId(KapuaId deviceId) { - this.deviceId = deviceId; - } - - @Override - public Date getSentOn() { - return sentOn != null ? new Date(sentOn.getTime()) : null; - } - - @Override - public void setSentOn(Date sentOn) { - this.sentOn = sentOn; - } - - @Override - public Date getReceivedOn() { - return receivedOn != null ? new Date(receivedOn.getTime()) : null; - } - - @Override - public void setReceivedOn(Date receivedOn) { - this.receivedOn = receivedOn; - } - - @Override - public KapuaPosition getPosition() { - return position; - } - - @Override - public void setPosition(KapuaPosition position) { - this.position = position; - } - - @Override - public String getResource() { - return resource; - } - - @Override - public void setResource(String resource) { - this.resource = resource; - } - - @Override - public KapuaMethod getAction() { - return action.normalizeAction(); - } - - @Override - public void setAction(KapuaMethod action) { - this.action = action.normalizeAction(); - } - - @Override - public KapuaResponseCode getResponseCode() { - return responseCode; - } - - @Override - public void setResponseCode(KapuaResponseCode responseCode) { - this.responseCode = responseCode; - } - - @Override - public String getEventMessage() { - return eventMessage; - } - - @Override - public void setEventMessage(String eventMessage) { - this.eventMessage = eventMessage; - } - -} diff --git a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/event/internal/DeviceEventFactoryImpl.java b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/event/internal/DeviceEventFactoryImpl.java index 0d7df1645b7..217276be88b 100644 --- a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/event/internal/DeviceEventFactoryImpl.java +++ b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/event/internal/DeviceEventFactoryImpl.java @@ -12,14 +12,10 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.registry.event.internal; -import java.util.Date; - import javax.inject.Singleton; import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.service.device.management.message.KapuaMethod; import org.eclipse.kapua.service.device.registry.event.DeviceEvent; -import org.eclipse.kapua.service.device.registry.event.DeviceEventCreator; import org.eclipse.kapua.service.device.registry.event.DeviceEventFactory; /** @@ -30,28 +26,11 @@ @Singleton public class DeviceEventFactoryImpl implements DeviceEventFactory { - @Override - public DeviceEventCreator newCreator(KapuaId scopeId, KapuaId deviceId, Date receivedOn, String resource) { - DeviceEventCreator creator = newCreator(scopeId); - - creator.setDeviceId(deviceId); - creator.setAction(KapuaMethod.CREATE); - creator.setReceivedOn(new Date(receivedOn.getTime())); - creator.setResource(resource); - - return creator; - } - @Override public DeviceEvent newEntity(KapuaId scopeId) { return new DeviceEventImpl(scopeId); } - @Override - public DeviceEventCreator newCreator(KapuaId scopeId) { - return new DeviceEventCreatorImpl(scopeId); - } - @Override public DeviceEvent clone(DeviceEvent deviceEvent) { return new DeviceEventImpl(deviceEvent); diff --git a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/internal/DeviceCreatorImpl.java b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/internal/DeviceCreatorImpl.java deleted file mode 100644 index 746f7e2f0df..00000000000 --- a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/internal/DeviceCreatorImpl.java +++ /dev/null @@ -1,385 +0,0 @@ -/******************************************************************************* - * 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.service.device.registry.internal; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import javax.validation.constraints.NotNull; - -import org.eclipse.kapua.commons.model.AbstractKapuaUpdatableEntityCreator; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.service.device.registry.Device; -import org.eclipse.kapua.service.device.registry.DeviceCreator; -import org.eclipse.kapua.service.device.registry.DeviceExtendedProperty; -import org.eclipse.kapua.service.device.registry.DeviceStatus; - -/** - * {@link DeviceCreator} implementation. - * - * @since 1.0.0 - */ -public class DeviceCreatorImpl extends AbstractKapuaUpdatableEntityCreator implements DeviceCreator { - - private static final long serialVersionUID = 8497299443773395462L; - private KapuaId groupId; - private String clientId; - private DeviceStatus status = DeviceStatus.ENABLED; - private KapuaId connectionId; - private KapuaId lastEventId; - private String displayName; - private String serialNumber; - private String modelId; - private String modelName; - private String imei; - private String imsi; - private String iccid; - private String biosVersion; - private String firmwareVersion; - private String osVersion; - private String jvmVersion; - private String osgiFrameworkVersion; - private String applicationFrameworkVersion; - private String connectionInterface; - private String connectionIp; - private String applicationIdentifiers; - private String acceptEncoding; - private String customAttribute1; - private String customAttribute2; - private String customAttribute3; - private String customAttribute4; - private String customAttribute5; - private List extendedProperties; - private String tamperStatus; - private Set tagIds; - - /** - * Constructor. - * - * @param scopeId The scope {@link KapuaId}. - * @since 1.0.0 - */ - protected DeviceCreatorImpl(KapuaId scopeId) { - super(scopeId); - } - - @Override - public KapuaId getGroupId() { - return groupId; - } - - @Override - public void setGroupId(KapuaId groupId) { - this.groupId = groupId; - } - - @Override - public String getClientId() { - return clientId; - } - - @Override - public void setClientId(String clientId) { - this.clientId = clientId; - } - - @Override - public DeviceStatus getStatus() { - return status; - } - - @Override - public void setStatus(DeviceStatus status) { - this.status = status; - } - - @Override - public KapuaId getConnectionId() { - return connectionId; - } - - @Override - public void setConnectionId(KapuaId connectionId) { - this.connectionId = connectionId; - } - - @Override - public KapuaId getLastEventId() { - return lastEventId; - } - - @Override - public void setLastEventId(KapuaId lastEventId) { - this.lastEventId = lastEventId; - } - - @Override - public String getDisplayName() { - return displayName; - } - - @Override - public void setDisplayName(String displayName) { - this.displayName = displayName; - } - - @Override - public String getSerialNumber() { - return serialNumber; - } - - @Override - public void setSerialNumber(String serialNumber) { - this.serialNumber = serialNumber; - } - - @Override - public String getModelId() { - return modelId; - } - - @Override - public void setModelId(String modelId) { - this.modelId = modelId; - } - - @Override - public String getModelName() { - return modelName; - } - - @Override - public void setModelName(String modelName) { - this.modelName = modelName; - } - - @Override - public String getImei() { - return imei; - } - - @Override - public void setImei(String imei) { - this.imei = imei; - } - - @Override - public String getImsi() { - return imsi; - } - - @Override - public void setImsi(String imsi) { - this.imsi = imsi; - } - - @Override - public String getIccid() { - return iccid; - } - - @Override - public void setIccid(String iccid) { - this.iccid = iccid; - } - - @Override - public String getBiosVersion() { - return biosVersion; - } - - @Override - public void setBiosVersion(String biosVersion) { - this.biosVersion = biosVersion; - } - - @Override - public String getFirmwareVersion() { - return firmwareVersion; - } - - @Override - public void setFirmwareVersion(String firmwareVersion) { - this.firmwareVersion = firmwareVersion; - } - - @Override - public String getOsVersion() { - return osVersion; - } - - @Override - public void setOsVersion(String osVersion) { - this.osVersion = osVersion; - } - - @Override - public String getJvmVersion() { - return jvmVersion; - } - - @Override - public void setJvmVersion(String jvmVersion) { - this.jvmVersion = jvmVersion; - } - - @Override - public String getOsgiFrameworkVersion() { - return osgiFrameworkVersion; - } - - @Override - public void setOsgiFrameworkVersion(String osgiFrameworkVersion) { - this.osgiFrameworkVersion = osgiFrameworkVersion; - } - - @Override - public String getApplicationFrameworkVersion() { - return applicationFrameworkVersion; - } - - @Override - public void setApplicationFrameworkVersion(String applicationFrameworkVersion) { - this.applicationFrameworkVersion = applicationFrameworkVersion; - } - - @Override - public String getConnectionInterface() { - return connectionInterface; - } - - @Override - public void setConnectionInterface(String connectionInterface) { - this.connectionInterface = connectionInterface; - } - - @Override - public String getConnectionIp() { - return connectionIp; - } - - @Override - public void setConnectionIp(String connectionIp) { - this.connectionIp = connectionIp; - } - - @Override - public String getApplicationIdentifiers() { - return applicationIdentifiers; - } - - @Override - public void setApplicationIdentifiers(String applicationIdentifiers) { - this.applicationIdentifiers = applicationIdentifiers; - } - - @Override - public String getAcceptEncoding() { - return acceptEncoding; - } - - @Override - public void setAcceptEncoding(String acceptEncoding) { - this.acceptEncoding = acceptEncoding; - } - - @Override - public String getCustomAttribute1() { - return customAttribute1; - } - - @Override - public void setCustomAttribute1(String customAttribute1) { - this.customAttribute1 = customAttribute1; - } - - @Override - public String getCustomAttribute2() { - return customAttribute2; - } - - @Override - public void setCustomAttribute2(String customAttribute2) { - this.customAttribute2 = customAttribute2; - } - - @Override - public String getCustomAttribute3() { - return customAttribute3; - } - - @Override - public void setCustomAttribute3(String customAttribute3) { - this.customAttribute3 = customAttribute3; - } - - @Override - public String getCustomAttribute4() { - return customAttribute4; - } - - @Override - public void setCustomAttribute4(String customAttribute4) { - this.customAttribute4 = customAttribute4; - } - - @Override - public String getCustomAttribute5() { - return customAttribute5; - } - - @Override - public void setCustomAttribute5(String customAttribute5) { - this.customAttribute5 = customAttribute5; - } - - @Override - public List getExtendedProperties() { - if (extendedProperties == null) { - extendedProperties = new ArrayList<>(); - } - - return extendedProperties; - } - - @Override - public void addExtendedProperty(@NotNull DeviceExtendedProperty extendedProperty) { - getExtendedProperties().add(extendedProperty); - } - - @Override - public void setExtendedProperties(List extendedProperties) { - this.extendedProperties = extendedProperties; - } - - @Override - public String getTamperStatus() { - return tamperStatus; - } - - @Override - public void setTamperStatus(String tamperStatus) { - this.tamperStatus = tamperStatus; - } - - @Override - public Set getTagIds() { - return tagIds == null ? new HashSet<>() : tagIds; - } - - @Override - public void setTagIds(Set tagIds) { - this.tagIds = tagIds; - } -} diff --git a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/internal/DeviceFactoryImpl.java b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/internal/DeviceFactoryImpl.java index 31eabc7398c..a24127554c4 100644 --- a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/internal/DeviceFactoryImpl.java +++ b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/internal/DeviceFactoryImpl.java @@ -17,7 +17,6 @@ import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.device.registry.Device; -import org.eclipse.kapua.service.device.registry.DeviceCreator; import org.eclipse.kapua.service.device.registry.DeviceExtendedProperty; import org.eclipse.kapua.service.device.registry.DeviceFactory; @@ -29,23 +28,11 @@ @Singleton public class DeviceFactoryImpl implements DeviceFactory { - @Override - public DeviceCreator newCreator(KapuaId scopeId, String clientId) { - DeviceCreator deviceCreator = newCreator(scopeId); - deviceCreator.setClientId(clientId); - return deviceCreator; - } - @Override public Device newEntity(KapuaId scopeId) { return new DeviceImpl(scopeId); } - @Override - public DeviceCreator newCreator(KapuaId scopeId) { - return new DeviceCreatorImpl(scopeId); - } - @Override public DeviceExtendedProperty newExtendedProperty(String groupName, String name, String value) { return new DeviceExtendedPropertyImpl(groupName, name, value); diff --git a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/lifecycle/internal/DeviceLifeCycleServiceImpl.java b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/lifecycle/internal/DeviceLifeCycleServiceImpl.java index f9ce2fdc30e..9cac8c21cf5 100644 --- a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/lifecycle/internal/DeviceLifeCycleServiceImpl.java +++ b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/lifecycle/internal/DeviceLifeCycleServiceImpl.java @@ -17,13 +17,11 @@ import java.util.Date; import java.util.List; import java.util.Map; + import javax.inject.Inject; import javax.inject.Singleton; import javax.validation.constraints.NotNull; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.common.base.Strings; import org.checkerframework.checker.nullness.qual.Nullable; import org.eclipse.kapua.KapuaEntityNotFoundException; import org.eclipse.kapua.KapuaException; @@ -58,6 +56,10 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.common.base.Strings; + /** * {@link DeviceLifeCycleService} implementation. * @@ -103,7 +105,7 @@ public void birth(KapuaId connectionId, KapuaBirthMessage birthMessage) throws K // Device update Device device; if (deviceId == null) { - DeviceCreator deviceCreator = deviceFactory.newCreator(scopeId); + DeviceCreator deviceCreator = new DeviceCreator(scopeId); deviceCreator.setClientId(birthChannel.getClientId()); deviceCreator.setDisplayName(birthPayload.getDisplayName()); @@ -168,12 +170,17 @@ public void death(KapuaId connectionId, KapuaDisconnectMessage message) throws K *

    * Tries to update the {@link Device} a number of times to allow close device updates to be stored properly. * - * @param scopeId The {@link Device#getScopeId()} to update. - * @param deviceId The {@link Device#getId()} to update. - * @param birthPayload The {@link KapuaBirthPayload} from which extract data. - * @param connectionId The {@link DeviceConnection#getId()} + * @param scopeId + * The {@link Device#getScopeId()} to update. + * @param deviceId + * The {@link Device#getId()} to update. + * @param birthPayload + * The {@link KapuaBirthPayload} from which extract data. + * @param connectionId + * The {@link DeviceConnection#getId()} * @return The updated {@link Device}. - * @throws KapuaException If {@link Device} does not exists or {@link DeviceRegistryService#update(KapuaUpdatableEntity)} causes an error. + * @throws KapuaException + * If {@link Device} does not exists or {@link DeviceRegistryService#update(KapuaUpdatableEntity)} causes an error. * @since 1.2.0 */ private Device updateDeviceInfoFromMessage(KapuaId scopeId, KapuaId deviceId, KapuaBirthPayload birthPayload, KapuaId connectionId) throws KapuaException { @@ -241,18 +248,21 @@ private Device updateDeviceInfoFromMessage(KapuaId scopeId, KapuaId deviceId, Ka return device; } - /** * Creates a {@link DeviceEvent} from the {@link KapuaLifecycleMessage}. *

    - * Internally invokes {@link DeviceRegistryService#find(KapuaId, KapuaId)} with the given parameters and - * then uses {@link #createLifecycleEvent(Device, String, KapuaLifecycleMessage)} + * Internally invokes {@link DeviceRegistryService#find(KapuaId, KapuaId)} with the given parameters and then uses {@link #createLifecycleEvent(Device, String, KapuaLifecycleMessage)} * - * @param scopeId The {@link Device#getScopeId()} of the {@link Device} that generated the {@link KapuaLifecycleMessage}. - * @param deviceId The {@link Device#getId()} of the {@link Device} that generated the {@link KapuaLifecycleMessage}. - * @param resource The resource used to publish the {@link KapuaLifecycleMessage} - * @param message The {@link KapuaLifecycleMessage} from which to extract data. - * @throws KapuaException if storing the {@link DeviceEvent} throws a {@link KapuaException} + * @param scopeId + * The {@link Device#getScopeId()} of the {@link Device} that generated the {@link KapuaLifecycleMessage}. + * @param deviceId + * The {@link Device#getId()} of the {@link Device} that generated the {@link KapuaLifecycleMessage}. + * @param resource + * The resource used to publish the {@link KapuaLifecycleMessage} + * @param message + * The {@link KapuaLifecycleMessage} from which to extract data. + * @throws KapuaException + * if storing the {@link DeviceEvent} throws a {@link KapuaException} * @since 1.2.0 */ private DeviceEvent createLifecycleEvent(@NotNull KapuaId scopeId, KapuaId deviceId, @NotNull String resource, @NotNull KapuaLifecycleMessage message) throws KapuaException { @@ -265,15 +275,19 @@ private DeviceEvent createLifecycleEvent(@NotNull KapuaId scopeId, KapuaId devic /** * Creates a {@link DeviceEvent} from the {@link KapuaLifecycleMessage}. * - * @param device The {@link Device} that generated the {@link KapuaLifecycleMessage}. - * @param resource The resource used to publish the {@link KapuaLifecycleMessage} - * @param message The {@link KapuaLifecycleMessage} from which to extract data. - * @throws KapuaException if storing the {@link DeviceEvent} throws a {@link KapuaException} + * @param device + * The {@link Device} that generated the {@link KapuaLifecycleMessage}. + * @param resource + * The resource used to publish the {@link KapuaLifecycleMessage} + * @param message + * The {@link KapuaLifecycleMessage} from which to extract data. + * @throws KapuaException + * if storing the {@link DeviceEvent} throws a {@link KapuaException} * @since 1.2.0 */ private DeviceEvent createLifecycleEvent(@NotNull Device device, @NotNull String resource, @NotNull KapuaLifecycleMessage message) throws KapuaException { - DeviceEventCreator deviceEventCreator = deviceEventFactory.newCreator(device.getScopeId(), device.getId(), message.getReceivedOn(), resource); + DeviceEventCreator deviceEventCreator = new DeviceEventCreator(device.getScopeId(), device.getId(), message.getReceivedOn(), resource); deviceEventCreator.setResponseCode(KapuaResponseCode.ACCEPTED); deviceEventCreator.setSentOn(message.getSentOn()); deviceEventCreator.setReceivedOn(Date.from(KapuaDateUtils.getKapuaSysDate())); @@ -293,9 +307,11 @@ private DeviceEvent createLifecycleEvent(@NotNull Device device, @NotNull String /** * Builds the {@link List} of {@link DeviceExtendedProperty}es from the {@link KapuaBirthPayload#getExtendedProperties()} property. * - * @param extendedPropertiesString The {@link KapuaBirthPayload#getExtendedProperties()} to parse. + * @param extendedPropertiesString + * The {@link KapuaBirthPayload#getExtendedProperties()} to parse. * @return The {@link List} of {@link DeviceExtendedProperty}es parsed. - * @throws KapuaException If there are exception while parsing the JSON-formatted metric. + * @throws KapuaException + * If there are exception while parsing the JSON-formatted metric. * @since 1.5.0 */ private List buildDeviceExtendedPropertyFromBirth(@Nullable String extendedPropertiesString) throws KapuaException { diff --git a/service/device/registry/test-steps/src/main/java/org/eclipse/kapua/service/device/registry/steps/AclCreator.java b/service/device/registry/test-steps/src/main/java/org/eclipse/kapua/service/device/registry/steps/AclCreator.java index 8eb6e5313ce..7f1e460c6e1 100644 --- a/service/device/registry/test-steps/src/main/java/org/eclipse/kapua/service/device/registry/steps/AclCreator.java +++ b/service/device/registry/test-steps/src/main/java/org/eclipse/kapua/service/device/registry/steps/AclCreator.java @@ -13,6 +13,14 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.registry.steps; +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.commons.model.domains.Domains; import org.eclipse.kapua.commons.model.id.KapuaEid; @@ -40,14 +48,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.math.BigInteger; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - /** * Creator of Accounts, Users, Permissions that are used in ACL tests */ @@ -88,7 +88,6 @@ public class AclCreator { */ private AccountFactory accountFactory; - /** * Constructor with all support services. */ @@ -112,8 +111,10 @@ public AclCreator() { /** * Configure user service with reasonable default values. * - * @param accId account id - * @param scopeId scope id + * @param accId + * account id + * @param scopeId + * scope id */ private void configureUserService(KapuaId accId, KapuaId scopeId) { @@ -135,8 +136,10 @@ private void configureUserService(KapuaId accId, KapuaId scopeId) { /** * Configure account service with reasonable default values. * - * @param accId account id - * @param scopeId scope id + * @param accId + * account id + * @param scopeId + * scope id */ private void configureAccountService(KapuaId accId, KapuaId scopeId) { @@ -154,10 +157,12 @@ private void configureAccountService(KapuaId accId, KapuaId scopeId) { /** * Creates permissions for user with specified account. Permissions are created in privileged mode. * - * @param permissionList list of permissions for user, if targetScopeId is not set user scope that is - * specified as account - * @param user user for whom permissions are set - * @param account account in which user is defined + * @param permissionList + * list of permissions for user, if targetScopeId is not set user scope that is specified as account + * @param user + * user for whom permissions are set + * @param account + * account in which user is defined * @throws Exception */ private void createPermissions(List permissionList, User user, Account account) @@ -175,18 +180,20 @@ private void createPermissions(List permissionList, User user, Ac } /** - * Create accessInfoCreator instance with data about user permissions. - * If target scope is not defined in permission list use account scope. + * Create accessInfoCreator instance with data about user permissions. If target scope is not defined in permission list use account scope. * - * @param permissionList list of all permissions - * @param user user for which permissions are set - * @param account that user belongs to + * @param permissionList + * list of all permissions + * @param user + * user for which permissions are set + * @param account + * that user belongs to * @return AccessInfoCreator instance for creating user permissions */ private AccessInfoCreator accessInfoCreatorCreator(List permissionList, - User user, Account account) { + User user, Account account) { - AccessInfoCreator accessInfoCreator = accessInfoFactory.newCreator(account.getId()); + AccessInfoCreator accessInfoCreator = new AccessInfoCreator(account.getId()); accessInfoCreator.setUserId(user.getId()); accessInfoCreator.setScopeId(user.getScopeId()); Set permissions = new HashSet<>(); @@ -208,7 +215,7 @@ private AccessInfoCreator accessInfoCreatorCreator(List permissio public void attachUserCredentials(Account account, User user) throws KapuaException { KapuaSecurityUtils.doPrivileged(() -> { CredentialCreator credentialCreator; - credentialCreator = credentialFactory.newCreator(account.getId(), user.getId(), "PASSWORD", "KeepCalm123.", CredentialStatus.ENABLED, null); + credentialCreator = new CredentialCreator(account.getId(), user.getId(), "PASSWORD", "KeepCalm123.", CredentialStatus.ENABLED, null); try { credentialService.create(credentialCreator); } catch (KapuaException ke) { @@ -222,7 +229,7 @@ public void attachUserCredentials(Account account, User user) throws KapuaExcept public void attachUserCredentials(Account account, User user, String password) throws KapuaException { KapuaSecurityUtils.doPrivileged(() -> { CredentialCreator credentialCreator; - credentialCreator = credentialFactory.newCreator(account.getId(), user.getId(), "PASSWORD", password, CredentialStatus.ENABLED, null); + credentialCreator = new CredentialCreator(account.getId(), user.getId(), "PASSWORD", password, CredentialStatus.ENABLED, null); try { credentialService.create(credentialCreator); } catch (KapuaException ke) { @@ -235,14 +242,14 @@ public void attachUserCredentials(Account account, User user, String password) t public User createUser(Account account, String name) throws KapuaException { configureUserService(account.getId(), SYS_ID); - UserCreator userCreator = userFactory.newCreator(account.getId(), name); + UserCreator userCreator = new UserCreator(account.getId(), name); return userService.create(userCreator); } Account createAccount(String name, String orgName, String orgEmail) throws KapuaException { configureAccountService(ROOT_SCOPE_ID, SYS_ID); - AccountCreator accountCreator = accountFactory.newCreator(ROOT_SCOPE_ID); + AccountCreator accountCreator = new AccountCreator(ROOT_SCOPE_ID); accountCreator.setName(name); accountCreator.setOrganizationName(orgName); accountCreator.setOrganizationEmail(orgEmail); diff --git a/service/device/registry/test-steps/src/main/java/org/eclipse/kapua/service/device/registry/steps/DeviceRegistrySteps.java b/service/device/registry/test-steps/src/main/java/org/eclipse/kapua/service/device/registry/steps/DeviceRegistrySteps.java index ed59d9a3b03..cbe60ba8b35 100644 --- a/service/device/registry/test-steps/src/main/java/org/eclipse/kapua/service/device/registry/steps/DeviceRegistrySteps.java +++ b/service/device/registry/test-steps/src/main/java/org/eclipse/kapua/service/device/registry/steps/DeviceRegistrySteps.java @@ -419,7 +419,7 @@ private void createDevicesAsSpecifiedInternal(List cucDevices, Device public void createDeviceWithName(String clientId) throws KapuaException { Account lastAccount = (Account) stepData.get(LAST_ACCOUNT); - DeviceCreator deviceCreator = deviceFactory.newCreator(lastAccount.getId()); + DeviceCreator deviceCreator = new DeviceCreator(lastAccount.getId()); deviceCreator.setClientId(clientId); Device device = deviceRegistryService.create(deviceCreator); @@ -438,7 +438,7 @@ public void createDeviceWithInvalidSymbolsInName() throws Exception { for (int i = 0; i < invalidSymbols.length(); i++) { String clientId = DEVICE + invalidSymbols.charAt(i); try { - DeviceCreator tmpDevCr = deviceFactory.newCreator(tmpAcc.getId(), clientId); + DeviceCreator tmpDevCr = new DeviceCreator(tmpAcc.getId(), clientId); Device tmpDev = deviceRegistryService.create(tmpDevCr); } catch (KapuaException e) { verifyException(e); @@ -521,7 +521,7 @@ public void generateABunchOfTestDevices(int number, String version) throws Excep primeException(); try { for (int i = 0; i < number; i++) { - tmpDevCr = deviceFactory.newCreator(getCurrentScopeId(), "test_" + String.valueOf(random.nextInt())); + tmpDevCr = new DeviceCreator(getCurrentScopeId(), "test_" + String.valueOf(random.nextInt())); tmpDevCr.setBiosVersion(version); deviceRegistryService.create(tmpDevCr); } @@ -540,7 +540,7 @@ public void generateABunchOfTestDevicesInScope(int number, int scope) throws Exc for (int i = 0; i < number; i++) { tmpId = new KapuaEid(BigInteger.valueOf(scope)); tmpClient = "test_" + String.valueOf(random.nextInt()); - tmpDevCr = deviceFactory.newCreator(tmpId, tmpClient); + tmpDevCr = new DeviceCreator(tmpId, tmpClient); deviceRegistryService.create(tmpDevCr); } } catch (KapuaException ex) { @@ -1001,7 +1001,7 @@ public void exerciseAllDeviceFactoryFunctions() { DeviceQuery tmpQuery; DeviceListResult tmpListRes; tmpDevice = deviceFactory.newEntity(SYS_SCOPE_ID); - tmpCreator = deviceFactory.newCreator(SYS_SCOPE_ID); + tmpCreator = new DeviceCreator(SYS_SCOPE_ID); tmpQuery = new DeviceQuery(SYS_SCOPE_ID); tmpListRes = new DeviceListResult(); Assert.assertNotNull(tmpDevice); @@ -1073,7 +1073,7 @@ public void createConnections(List cucConnections) throws Excepti DeviceConnectionListResult deviceConnections = new DeviceConnectionListResult(); for (CucConnection cucConnection : cucConnections) { - connectionCreator = deviceConnectionFactory.newCreator(scopeId); + connectionCreator = new DeviceConnectionCreator(scopeId); connectionCreator.setStatus(DeviceConnectionStatus.CONNECTED); connectionCreator.setUserId(userId); connectionCreator.setUserCouplingMode(ConnectionUserCouplingMode.LOOSE); @@ -1340,7 +1340,7 @@ public void checkThatConnectionIsNull() { public void exerciseAllConnectionFactoryFunctions() { DeviceConnectionCreator tmpCreator = null; DeviceConnectionQuery tmpQuery = null; - tmpCreator = deviceConnectionFactory.newCreator(SYS_SCOPE_ID); + tmpCreator = new DeviceConnectionCreator(SYS_SCOPE_ID); tmpQuery = new DeviceConnectionQuery(SYS_SCOPE_ID); Assert.assertNotNull(tmpCreator); Assert.assertNotNull(tmpQuery); @@ -1635,7 +1635,7 @@ public void exerciseAllEventFactoryFunctions() { DeviceEventQuery tmpQuery = null; DeviceEventListResult tmpList = null; tmpEvent = eventFactory.newEntity(SYS_SCOPE_ID); - tmpCreator = eventFactory.newCreator(SYS_SCOPE_ID, getKapuaId(), new Date(), ""); + tmpCreator = new DeviceEventCreator(SYS_SCOPE_ID, getKapuaId(), new Date(), ""); tmpQuery = new DeviceEventQuery(SYS_SCOPE_ID); tmpList = new DeviceEventListResult(); Assert.assertNotNull(tmpEvent); @@ -1686,7 +1686,7 @@ public void iTagDeviceWithTag(String deviceTagName) throws Exception { Device device = (Device) stepData.get(DEVICE); primeException(); try { - TagCreator tagCreator = tagFactory.newCreator(account.getId()); + TagCreator tagCreator = new TagCreator(account.getId()); tagCreator.setName(deviceTagName); Tag tag = tagService.create(tagCreator); Set tags = new HashSet<>(); @@ -1927,7 +1927,7 @@ public void setDeviceConnectionCouplingMode(String name, String mode) throws Kap public void createConnectionForDevice(List connections) throws KapuaException { KapuaSecurityUtils.doPrivileged(() -> { for (CucConnection tmpConn : connections) { - DeviceConnectionCreator tmpCreator = deviceConnectionFactory.newCreator(tmpConn.getScopeId()); + DeviceConnectionCreator tmpCreator = new DeviceConnectionCreator(tmpConn.getScopeId()); tmpCreator.setStatus(DeviceConnectionStatus.CONNECTED); tmpCreator.setClientId(tmpConn.getClientId()); tmpCreator.setUserId(tmpConn.getUserId()); @@ -2126,7 +2126,7 @@ public void checkUserForExistingConnection(String device, String scope, String n // Create a device creator object. The creator is pre-filled with default data. private DeviceCreator prepareRegularDeviceCreator(KapuaId scopeId, String clientId) { - DeviceCreator deviceCreator = deviceFactory.newCreator(scopeId); + DeviceCreator deviceCreator = new DeviceCreator(scopeId); deviceCreator.setClientId(clientId); deviceCreator.setStatus(DeviceStatus.ENABLED); @@ -2185,7 +2185,7 @@ private Device prepareRegularDevice(KapuaId accountId, KapuaId deviceId) { // Create a connection creator object. The creator is pre-filled with default data. private DeviceConnectionCreator prepareRegularConnectionCreator(KapuaId scopeId, KapuaId userId) { - DeviceConnectionCreator creator = deviceConnectionFactory.newCreator(scopeId); + DeviceConnectionCreator creator = new DeviceConnectionCreator(scopeId); creator.setUserId(userId); creator.setUserCouplingMode(ConnectionUserCouplingMode.LOOSE); creator.setReservedUserId(userId); @@ -2201,7 +2201,7 @@ private DeviceConnectionCreator prepareRegularConnectionCreator(KapuaId scopeId, // Create a event creator object. The creator is pre-filled with default data. private DeviceEventCreator prepareRegularDeviceEventCreator(KapuaId accountId, KapuaId deviceId) { - DeviceEventCreator tmpCreator = eventFactory.newCreator(accountId); + DeviceEventCreator tmpCreator = new DeviceEventCreator(accountId); KapuaPosition tmpPosition = messageFactory.newPosition(); Date timeReceived = new Date(); Date timeSent = new Date(System.currentTimeMillis() - 5 * 60 * 1000); @@ -2490,7 +2490,7 @@ boolean parseBooleanFromString(String value) { @Then("I create a device with name {string}") public void iCreateADeviceWithName(String clientId) throws Exception { - DeviceCreator deviceCreator = deviceFactory.newCreator(getCurrentScopeId()); + DeviceCreator deviceCreator = new DeviceCreator(getCurrentScopeId()); deviceCreator.setClientId(clientId); stepData.put(DEVICE_CREATOR, deviceCreator); try { @@ -2506,13 +2506,13 @@ public void iCreateADeviceWithName(String clientId) throws Exception { @Then("I create a device with name {string} and tags") public void iCreateADeviceWithName(String clientId, List tags) throws Exception { final HashSet tagIds = new HashSet<>(); - final TagCreator tagCreator = tagFactory.newCreator(getCurrentScopeId()); + final TagCreator tagCreator = new TagCreator(getCurrentScopeId()); for (String tagName : tags) { tagCreator.setName(tagName); final Tag tag = tagService.create(tagCreator); tagIds.add(tag.getId()); } - final DeviceCreator deviceCreator = deviceFactory.newCreator(getCurrentScopeId()); + final DeviceCreator deviceCreator = new DeviceCreator(getCurrentScopeId()); deviceCreator.setClientId(clientId); deviceCreator.setTagIds(tagIds); stepData.put(DEVICE_CREATOR, deviceCreator); @@ -3330,7 +3330,7 @@ public void iSearchForADeviceWithName(String clientID) throws Throwable { @Given("I create a device with null clientID") public void iCreateADeviceWithNullClientID() throws Throwable { - DeviceCreator deviceCreator = deviceFactory.newCreator(getCurrentScopeId()); + DeviceCreator deviceCreator = new DeviceCreator(getCurrentScopeId()); deviceCreator.setClientId(null); stepData.put("DeviceCreator", deviceCreator); try { @@ -3345,7 +3345,7 @@ public void iCreateADeviceWithNullClientID() throws Throwable { @Given("I try to create devices with invalid symbols {string} in name") public void iTryToCreateDevicesWithInvalidSymbolsInName(String invalidCharacters) throws Exception { - DeviceCreator deviceCreator = deviceFactory.newCreator(getCurrentScopeId()); + DeviceCreator deviceCreator = new DeviceCreator(getCurrentScopeId()); for (int i = 0; i < invalidCharacters.length(); i++) { String deviceName = "deviceName" + invalidCharacters.charAt(i); deviceCreator.setClientId(deviceName); diff --git a/service/endpoint/api/src/main/java/org/eclipse/kapua/service/endpoint/EndpointInfoCreator.java b/service/endpoint/api/src/main/java/org/eclipse/kapua/service/endpoint/EndpointInfoCreator.java index 127db99299b..499f05589c6 100644 --- a/service/endpoint/api/src/main/java/org/eclipse/kapua/service/endpoint/EndpointInfoCreator.java +++ b/service/endpoint/api/src/main/java/org/eclipse/kapua/service/endpoint/EndpointInfoCreator.java @@ -12,47 +12,100 @@ *******************************************************************************/ package org.eclipse.kapua.service.endpoint; -import org.eclipse.kapua.model.KapuaEntityCreator; +import java.util.HashSet; +import java.util.Set; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; -import java.util.Set; + +import org.eclipse.kapua.model.KapuaEntityCreator; +import org.eclipse.kapua.model.id.KapuaId; /** - * {@link EndpointInfo} creator definition.
    - * It is used to create a new {@link EndpointInfo}. + * {@link EndpointInfo} creator definition.
    It is used to create a new {@link EndpointInfo}. * * @since 1.0.0 */ @XmlRootElement(name = "endpointInfoCreator") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = EndpointInfoXmlRegistry.class, factoryMethod = "newCreator") -public interface EndpointInfoCreator extends KapuaEntityCreator { - - String getSchema(); - - void setSchema(String schema); - - String getDns(); - - void setDns(String dns); - - int getPort(); - - void setPort(int port); - - boolean getSecure(); - - void setSecure(boolean secure); - - Set getUsages(); - - void setUsages(Set usages); - - String getEndpointType(); - - void setEndpointType(String endpointType); - +@XmlType +public class EndpointInfoCreator extends KapuaEntityCreator { + + private String schema; + private String dns; + private int port; + private boolean secure; + private Set usages; + private String endpointType; + + public EndpointInfoCreator() { + } + + public EndpointInfoCreator(KapuaId scopeId) { + super(scopeId); + } + + public EndpointInfoCreator(KapuaEntityCreator entityCreator) { + super(entityCreator); + } + + public String getSchema() { + return schema; + } + + public EndpointInfoCreator setSchema(String schema) { + this.schema = schema; + return this; + } + + public String getDns() { + return dns; + } + + public EndpointInfoCreator setDns(String dns) { + this.dns = dns; + return this; + } + + public int getPort() { + return port; + } + + public EndpointInfoCreator setPort(int port) { + this.port = port; + return this; + } + + public boolean getSecure() { + return secure; + } + + public EndpointInfoCreator setSecure(boolean secure) { + this.secure = secure; + return this; + } + + public Set getUsages() { + if (usages == null) { + usages = new HashSet<>(); + } + + return usages; + } + + public EndpointInfoCreator setUsages(Set usages) { + this.usages = usages; + return this; + } + + public String getEndpointType() { + return endpointType; + } + + public EndpointInfoCreator setEndpointType(String endpointType) { + this.endpointType = endpointType; + return this; + } } diff --git a/service/endpoint/api/src/main/java/org/eclipse/kapua/service/endpoint/EndpointInfoFactory.java b/service/endpoint/api/src/main/java/org/eclipse/kapua/service/endpoint/EndpointInfoFactory.java index 60e9b2515f0..b649458801c 100644 --- a/service/endpoint/api/src/main/java/org/eclipse/kapua/service/endpoint/EndpointInfoFactory.java +++ b/service/endpoint/api/src/main/java/org/eclipse/kapua/service/endpoint/EndpointInfoFactory.java @@ -13,14 +13,13 @@ package org.eclipse.kapua.service.endpoint; import org.eclipse.kapua.model.KapuaEntityFactory; -import org.eclipse.kapua.model.id.KapuaId; /** * {@link EndpointInfoFactory} definition. * * @since 1.0.0 */ -public interface EndpointInfoFactory extends KapuaEntityFactory { +public interface EndpointInfoFactory extends KapuaEntityFactory { /** * Instantiates a new {@link EndpointUsage}. @@ -32,6 +31,4 @@ public interface EndpointInfoFactory extends KapuaEntityFactory implements EndpointInfoCreator { - - private String schema; - private String dns; - private int port; - private boolean secure; - private Set usages; - private String endpointType; - - protected EndpointInfoCreatorImpl(KapuaId scopeId) { - super(scopeId); - } - - @Override - public String getSchema() { - return schema; - } - - @Override - public void setSchema(String schema) { - this.schema = schema; - } - - @Override - public String getDns() { - return dns; - } - - @Override - public void setDns(String dns) { - this.dns = dns; - } - - @Override - public int getPort() { - return port; - } - - @Override - public void setPort(int port) { - this.port = port; - } - - @Override - public boolean getSecure() { - return secure; - } - - @Override - public void setSecure(boolean secure) { - this.secure = secure; - } - - @Override - public Set getUsages() { - if (usages == null) { - usages = new HashSet<>(); - } - - return usages; - } - - @Override - public void setUsages(Set usages) { - this.usages = usages; - } - - @Override - public String getEndpointType() { - return endpointType; - } - - @Override - public void setEndpointType(String endpointType) { - this.endpointType = endpointType; - } - -} diff --git a/service/endpoint/internal/src/main/java/org/eclipse/kapua/service/endpoint/internal/EndpointInfoFactoryImpl.java b/service/endpoint/internal/src/main/java/org/eclipse/kapua/service/endpoint/internal/EndpointInfoFactoryImpl.java index 619afaa71fe..a3c32097005 100644 --- a/service/endpoint/internal/src/main/java/org/eclipse/kapua/service/endpoint/internal/EndpointInfoFactoryImpl.java +++ b/service/endpoint/internal/src/main/java/org/eclipse/kapua/service/endpoint/internal/EndpointInfoFactoryImpl.java @@ -17,9 +17,7 @@ import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.endpoint.EndpointInfo; -import org.eclipse.kapua.service.endpoint.EndpointInfoCreator; import org.eclipse.kapua.service.endpoint.EndpointInfoFactory; -import org.eclipse.kapua.service.endpoint.EndpointInfoQuery; import org.eclipse.kapua.service.endpoint.EndpointUsage; /** @@ -35,16 +33,6 @@ public EndpointInfo newEntity(KapuaId scopeId) { return new EndpointInfoImpl(scopeId); } - @Override - public EndpointInfoQuery newQuery(KapuaId scopeId) { - return new EndpointInfoQuery(scopeId); - } - - @Override - public EndpointInfoCreator newCreator(KapuaId scopeId) { - return new EndpointInfoCreatorImpl(scopeId); - } - @Override public EndpointUsage newEndpointUsage(String name) { return new EndpointUsageImpl(name); diff --git a/service/endpoint/internal/src/main/java/org/eclipse/kapua/service/endpoint/internal/EndpointInfoServiceImpl.java b/service/endpoint/internal/src/main/java/org/eclipse/kapua/service/endpoint/internal/EndpointInfoServiceImpl.java index ab6cd8f5b5c..2756df06959 100644 --- a/service/endpoint/internal/src/main/java/org/eclipse/kapua/service/endpoint/internal/EndpointInfoServiceImpl.java +++ b/service/endpoint/internal/src/main/java/org/eclipse/kapua/service/endpoint/internal/EndpointInfoServiceImpl.java @@ -206,7 +206,7 @@ public EndpointInfo find(KapuaId scopeId, KapuaId endpointInfoId) //found but in another scope...is defined in the scope of the first Account that has defined endpoints? (proceeding upwards) String type = endpointInfoToFind.getEndpointType(); //now find the endpoints of the search type that I can use (aka, the nearest proceeding upwards in Accounts hierarchy) - EndpointInfoQuery query = endpointInfoFactory.newQuery(scopeId); + EndpointInfoQuery query = new EndpointInfoQuery(scopeId); EndpointInfoListResult nearestUsableEndpoints = doQuery(tx, query, type); if (nearestUsableEndpoints.isEmpty() || !nearestUsableEndpoints.getFirstItem().getScopeId() @@ -388,7 +388,7 @@ private void checkDuplicateEndpointInfo(KapuaId scopeId, KapuaId entityId, Strin } private boolean countAllEndpointsInScope(TxContext txContext, KapuaId scopeId, String section) throws KapuaException { - EndpointInfoQuery totalQuery = endpointInfoFactory.newQuery(scopeId); + EndpointInfoQuery totalQuery = new EndpointInfoQuery(scopeId); addSectionToPredicate(totalQuery, section); long totalCount = repository.count(txContext, totalQuery); return totalCount != 0; diff --git a/service/endpoint/test-steps/src/main/java/org/eclipse/kapua/service/endpoint/steps/EndpointServiceSteps.java b/service/endpoint/test-steps/src/main/java/org/eclipse/kapua/service/endpoint/steps/EndpointServiceSteps.java index 447ae1695e1..35bc1474d2b 100644 --- a/service/endpoint/test-steps/src/main/java/org/eclipse/kapua/service/endpoint/steps/EndpointServiceSteps.java +++ b/service/endpoint/test-steps/src/main/java/org/eclipse/kapua/service/endpoint/steps/EndpointServiceSteps.java @@ -12,15 +12,11 @@ *******************************************************************************/ package org.eclipse.kapua.service.endpoint.steps; +import java.util.List; +import java.util.concurrent.Callable; + +import javax.inject.Inject; -import com.google.inject.Singleton; -import io.cucumber.datatable.DataTable; -import io.cucumber.java.After; -import io.cucumber.java.Before; -import io.cucumber.java.Scenario; -import io.cucumber.java.en.And; -import io.cucumber.java.en.Then; -import io.cucumber.java.en.When; import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.KapuaIllegalNullArgumentException; import org.eclipse.kapua.commons.security.KapuaSecurityUtils; @@ -38,9 +34,15 @@ import org.eclipse.kapua.service.endpoint.EndpointInfoService; import org.junit.Assert; -import javax.inject.Inject; -import java.util.List; -import java.util.concurrent.Callable; +import com.google.inject.Singleton; + +import io.cucumber.datatable.DataTable; +import io.cucumber.java.After; +import io.cucumber.java.Before; +import io.cucumber.java.Scenario; +import io.cucumber.java.en.And; +import io.cucumber.java.en.Then; +import io.cucumber.java.en.When; @Singleton public class EndpointServiceSteps extends TestBase { @@ -48,13 +50,13 @@ public class EndpointServiceSteps extends TestBase { private EndpointInfoService endpointInfoService; private EndpointInfoFactory endpointInfoFactory; -// **************************************************************************************** -// * Implementation of Gherkin steps used in JobService.feature scenarios. * -// * * -// * MockedLocator is used for Location Service. Mockito is used to mock other * -// * services that the Account services dependent on. Dependent services are: * -// * - Authorization Service * -// **************************************************************************************** + // **************************************************************************************** + // * Implementation of Gherkin steps used in JobService.feature scenarios. * + // * * + // * MockedLocator is used for Location Service. Mockito is used to mock other * + // * services that the Account services dependent on. Dependent services are: * + // * - Authorization Service * + // **************************************************************************************** private static final String ENDPOINT_INFO = "EndpointInfo"; @@ -64,7 +66,7 @@ public EndpointServiceSteps(StepData stepData) { super(stepData); } - @After(value="@setup") + @After(value = "@setup") public void setServices() { KapuaLocator locator = KapuaLocator.getInstance(); endpointInfoService = locator.getService(EndpointInfoService.class); @@ -81,7 +83,7 @@ public void setServices() { // * Setup and tear-down steps * // ************************************************************************************ - @Before(value="@env_docker or @env_docker_base or @env_none", order=10) + @Before(value = "@env_docker or @env_docker_base or @env_none", order = 10) public void beforeScenarioNone(Scenario scenario) { updateScenario(scenario); } @@ -92,7 +94,7 @@ public void beforeScenarioNone(Scenario scenario) { @And("I create endpoint with schema {string}, domain {string} and port {int}") public void iCreateEndpointWithSchemaDnsAndPort(String schema, String dns, int port) throws Exception { - EndpointInfoCreator endpointInfoCreator = endpointInfoFactory.newCreator(getCurrentScopeId()); + EndpointInfoCreator endpointInfoCreator = new EndpointInfoCreator(getCurrentScopeId()); endpointInfoCreator.setSchema(schema); endpointInfoCreator.setDns(dns); endpointInfoCreator.setPort(port); @@ -115,7 +117,7 @@ public void iTryToCreateInvalidEndpoint() throws Exception { "æÒ\uF8FFÔÓÌÏÎÍÅ«" + "◊ш¯Èˇ¿"; for (int i = 0; i < invalidSymbols.length(); i++) { - EndpointInfoCreator endpointInfoCreator = endpointInfoFactory.newCreator(getCurrentScopeId()); + EndpointInfoCreator endpointInfoCreator = new EndpointInfoCreator(getCurrentScopeId()); String schema = invalidSymbols + invalidSymbols.charAt(i); endpointInfoCreator.setSchema(schema); endpointInfoCreator.setDns("dns.com"); @@ -133,7 +135,7 @@ public void iTryToCreateInvalidEndpoint() throws Exception { @And("I create endpoint with domain name {string} and port {int} without schema") public void iCreateEndpointWithDnsAndPort(String dns, int port) throws Exception { - EndpointInfoCreator endpointInfoCreator = endpointInfoFactory.newCreator(getCurrentScopeId()); + EndpointInfoCreator endpointInfoCreator = new EndpointInfoCreator(getCurrentScopeId()); endpointInfoCreator.setDns(dns); endpointInfoCreator.setPort(port); endpointInfoCreator.setEndpointType(EndpointInfo.ENDPOINT_TYPE_RESOURCE); @@ -147,7 +149,7 @@ public void iCreateEndpointWithDnsAndPort(String dns, int port) throws Exception @And("I create endpoint with schema {string} without domain name and port") public void iCreateEndpointWithSchemaOnly(String schema) throws Exception { - EndpointInfoCreator endpointInfoCreator = endpointInfoFactory.newCreator(getCurrentScopeId()); + EndpointInfoCreator endpointInfoCreator = new EndpointInfoCreator(getCurrentScopeId()); endpointInfoCreator.setSchema(schema); endpointInfoCreator.setEndpointType(EndpointInfo.ENDPOINT_TYPE_RESOURCE); try { @@ -160,7 +162,7 @@ public void iCreateEndpointWithSchemaOnly(String schema) throws Exception { @And("I create endpoint with NULL parameters") public void iCreateEndpointWithNullParameters() throws Exception { - EndpointInfoCreator endpointInfoCreator = endpointInfoFactory.newCreator(getCurrentScopeId()); + EndpointInfoCreator endpointInfoCreator = new EndpointInfoCreator(getCurrentScopeId()); endpointInfoCreator.setSchema(null); endpointInfoCreator.setDns(null); endpointInfoCreator.setPort(0); @@ -177,7 +179,7 @@ public void iCreateEndpointWithNullParameters() throws Exception { public void iDeleteEndpointWithSchema(String schema, String domain, int port) throws Throwable { primeException(); try { - EndpointInfoQuery endpointInfoQuery = endpointInfoFactory.newQuery(getCurrentScopeId()); + EndpointInfoQuery endpointInfoQuery = new EndpointInfoQuery(getCurrentScopeId()); endpointInfoQuery.setPredicate(endpointInfoQuery.attributePredicate(EndpointInfoAttributes.SCHEMA, schema, AttributePredicate.Operator.EQUAL)); EndpointInfo endpointInfo = endpointInfoService.query(endpointInfoQuery).getFirstItem(); Assert.assertEquals(schema, endpointInfo.getSchema()); @@ -203,7 +205,7 @@ public void foundEndpointBySchema(String schema) throws Exception { public void foundEndpointBySchemaDomainPortSection(String schema, String domain, int port, String section) throws Exception { primeException(); try { - EndpointInfoQuery endpointInfoQuery = endpointInfoFactory.newQuery(getCurrentScopeId()); + EndpointInfoQuery endpointInfoQuery = new EndpointInfoQuery(getCurrentScopeId()); AndPredicate andPredicate = endpointInfoQuery.andPredicate(); if (section.equals("cors")) { @@ -263,7 +265,7 @@ public void editEndpointSchema(String schema) throws Exception { public void iDeleteEndpointWithSchema(String schema) throws Exception { primeException(); try { - EndpointInfoQuery endpointInfoQuery = endpointInfoFactory.newQuery(getCurrentScopeId()); + EndpointInfoQuery endpointInfoQuery = new EndpointInfoQuery(getCurrentScopeId()); endpointInfoQuery.setPredicate(endpointInfoQuery.attributePredicate(EndpointInfoAttributes.SCHEMA, schema, AttributePredicate.Operator.EQUAL)); EndpointInfo endpointInfo = endpointInfoService.query(endpointInfoQuery).getFirstItem(); endpointInfoService.delete(SYS_SCOPE_ID, endpointInfo.getId()); @@ -286,7 +288,7 @@ public void iDeleteTheLastCreatedEndpoint() throws Exception { public void iDeleteEndpointWithSchemaDomainAndPort(String schema, String domainName, int port) throws Exception { primeException(); try { - EndpointInfoQuery endpointInfoQuery = endpointInfoFactory.newQuery(getCurrentScopeId()); + EndpointInfoQuery endpointInfoQuery = new EndpointInfoQuery(getCurrentScopeId()); endpointInfoQuery.setPredicate(endpointInfoQuery.attributePredicate(EndpointInfoAttributes.SCHEMA, schema, AttributePredicate.Operator.EQUAL)); endpointInfoQuery.setPredicate(endpointInfoQuery.attributePredicate(EndpointInfoAttributes.DNS, domainName, AttributePredicate.Operator.EQUAL)); endpointInfoQuery.setPredicate(endpointInfoQuery.attributePredicate(EndpointInfoAttributes.PORT, port, AttributePredicate.Operator.EQUAL)); @@ -302,7 +304,7 @@ public void iDeleteEndpointWithSchemaDomainAndPort(String schema, String domainN public void iSearchForAllEndpoints() throws Exception { primeException(); try { - EndpointInfoQuery endpointInfoQuery = endpointInfoFactory.newQuery(getCurrentScopeId()); + EndpointInfoQuery endpointInfoQuery = new EndpointInfoQuery(getCurrentScopeId()); EndpointInfoListResult endpointInfo = endpointInfoService.query(endpointInfoQuery); stepData.put("NumberOfEndpoints", endpointInfo.getSize()); } catch (Exception ex) { @@ -340,7 +342,7 @@ public void notFoundEndpointWithSchema(String endpointSchema) { public void iDeleteEndpointsWithSchema(String schema) throws Throwable { primeException(); try { - EndpointInfoQuery endpointInfoQuery = endpointInfoFactory.newQuery(getCurrentScopeId()); + EndpointInfoQuery endpointInfoQuery = new EndpointInfoQuery(getCurrentScopeId()); endpointInfoQuery.setPredicate(endpointInfoQuery.attributePredicate(EndpointInfoAttributes.SCHEMA, schema, AttributePredicate.Operator.EQUAL)); EndpointInfoListResult endpointsToDelete = endpointInfoService.query(endpointInfoQuery); for (int i = 0; i < endpointsToDelete.getSize(); i++) { @@ -393,7 +395,7 @@ public void iEditLastCreatedEndpointPort(int port) throws Throwable { @Then("I edit port number to {int} in endpoint with schema {string}, domain {string} and port {int}") public void iEditLastCreatedEndpointPortInEndpoint(int newPort, String schema, String domainName, int port) throws Throwable { try { - EndpointInfoQuery endpointInfoQuery = endpointInfoFactory.newQuery(getCurrentScopeId()); + EndpointInfoQuery endpointInfoQuery = new EndpointInfoQuery(getCurrentScopeId()); endpointInfoQuery.setPredicate(endpointInfoQuery.attributePredicate(EndpointInfoAttributes.SCHEMA, schema, AttributePredicate.Operator.EQUAL)); endpointInfoQuery.setPredicate(endpointInfoQuery.attributePredicate(EndpointInfoAttributes.DNS, domainName, AttributePredicate.Operator.EQUAL)); endpointInfoQuery.setPredicate(endpointInfoQuery.attributePredicate(EndpointInfoAttributes.PORT, port, AttributePredicate.Operator.EQUAL)); @@ -406,8 +408,8 @@ public void iEditLastCreatedEndpointPortInEndpoint(int newPort, String schema, S } @And("I create endpoint with schema {string} and port {int} without domain name") - public void iCreateEndpointWithSchemaAndPortWithoutDomain(String schema, int port ) throws Throwable { - EndpointInfoCreator endpointInfoCreator = endpointInfoFactory.newCreator(getCurrentScopeId()); + public void iCreateEndpointWithSchemaAndPortWithoutDomain(String schema, int port) throws Throwable { + EndpointInfoCreator endpointInfoCreator = new EndpointInfoCreator(getCurrentScopeId()); endpointInfoCreator.setSchema(schema); endpointInfoCreator.setPort(port); endpointInfoCreator.setDns(null); @@ -421,8 +423,8 @@ public void iCreateEndpointWithSchemaAndPortWithoutDomain(String schema, int por } @And("I create endpoint with domain name {string} without schema and port") - public void iCreateEndpointWithDomainWithoutSchemaAndPort(String domainName) throws Throwable{ - EndpointInfoCreator endpointInfoCreator = endpointInfoFactory.newCreator(getCurrentScopeId()); + public void iCreateEndpointWithDomainWithoutSchemaAndPort(String domainName) throws Throwable { + EndpointInfoCreator endpointInfoCreator = new EndpointInfoCreator(getCurrentScopeId()); endpointInfoCreator.setDns(domainName); endpointInfoCreator.setEndpointType(EndpointInfo.ENDPOINT_TYPE_RESOURCE); try { @@ -435,7 +437,7 @@ public void iCreateEndpointWithDomainWithoutSchemaAndPort(String domainName) thr @And("I create endpoint with schema {string} and domain {string} without port") public void iCreateEndpointWithSchemaAndDomainWithoutPort(String schema, String domainName) throws Throwable { - EndpointInfoCreator endpointInfoCreator = endpointInfoFactory.newCreator(getCurrentScopeId()); + EndpointInfoCreator endpointInfoCreator = new EndpointInfoCreator(getCurrentScopeId()); endpointInfoCreator.setDns(domainName); endpointInfoCreator.setSchema(schema); endpointInfoCreator.setEndpointType(EndpointInfo.ENDPOINT_TYPE_RESOURCE); @@ -448,8 +450,8 @@ public void iCreateEndpointWithSchemaAndDomainWithoutPort(String schema, String } @And("I create endpoint with port {int} without schema and domain name") - public void iCreateEndpointWithPortWithoutSchemaAndDomain(int port) throws Throwable{ - EndpointInfoCreator endpointInfoCreator = endpointInfoFactory.newCreator(getCurrentScopeId()); + public void iCreateEndpointWithPortWithoutSchemaAndDomain(int port) throws Throwable { + EndpointInfoCreator endpointInfoCreator = new EndpointInfoCreator(getCurrentScopeId()); endpointInfoCreator.setPort(port); endpointInfoCreator.setEndpointType(EndpointInfo.ENDPOINT_TYPE_RESOURCE); try { @@ -462,7 +464,7 @@ public void iCreateEndpointWithPortWithoutSchemaAndDomain(int port) throws Throw @And("I create endpoint with schema {string}, domain {string}, port {int} and {string} secure field") public void iCreateEndpointWithSchemaDomainPortAndSecureField(String schema, String domainName, int port, String secureField) throws Throwable { - EndpointInfoCreator endpointInfoCreator = endpointInfoFactory.newCreator(getCurrentScopeId()); + EndpointInfoCreator endpointInfoCreator = new EndpointInfoCreator(getCurrentScopeId()); endpointInfoCreator.setSchema(schema); endpointInfoCreator.setDns(domainName); endpointInfoCreator.setPort(port); @@ -497,7 +499,7 @@ public void iEditLastCreatedEndpointSecureField(String secureField) throws Throw @When("^I create a CORS filter with schema \"([^\"]*)\", domain \"([^\"]*)\" and port (\\d+)$") public void iCreateCORSFilter(String schema, String domain, int port) throws Exception { - EndpointInfoCreator endpointInfoCreator = endpointInfoFactory.newCreator(getCurrentScopeId()); + EndpointInfoCreator endpointInfoCreator = new EndpointInfoCreator(getCurrentScopeId()); endpointInfoCreator.setSchema(schema); endpointInfoCreator.setDns(domain); endpointInfoCreator.setPort(port); @@ -520,9 +522,10 @@ public void iCreateMultipleCORSFilter(DataTable corsFilters) throws Throwable { @Then("I have (\\d+) CORS filters?$") public void iHaveCORSFilter(int expectedNum) throws KapuaException { int corsFilter = KapuaSecurityUtils.doPrivileged(new Callable() { + @Override public Integer call() throws Exception { - EndpointInfoQuery endpointInfoQuery = endpointInfoFactory.newQuery(getCurrentScopeId()); + EndpointInfoQuery endpointInfoQuery = new EndpointInfoQuery(getCurrentScopeId()); EndpointInfoListResult corsFilters = endpointInfoService.query(endpointInfoQuery, EndpointInfo.ENDPOINT_TYPE_CORS); return corsFilters.getSize(); } @@ -535,7 +538,7 @@ public void iDeleteAllCORSFilters() throws Exception { primeException(); try { - EndpointInfoQuery endpointInfoQuery = endpointInfoFactory.newQuery(getCurrentScopeId()); + EndpointInfoQuery endpointInfoQuery = new EndpointInfoQuery(getCurrentScopeId()); EndpointInfoListResult endpointsToDelete = endpointInfoService.query(endpointInfoQuery, EndpointInfo.ENDPOINT_TYPE_CORS); for (int i = 0; i < endpointsToDelete.getSize(); i++) { diff --git a/service/job/api/src/main/java/org/eclipse/kapua/service/job/JobCreator.java b/service/job/api/src/main/java/org/eclipse/kapua/service/job/JobCreator.java index 543cb6b7b10..364adf32845 100644 --- a/service/job/api/src/main/java/org/eclipse/kapua/service/job/JobCreator.java +++ b/service/job/api/src/main/java/org/eclipse/kapua/service/job/JobCreator.java @@ -12,16 +12,19 @@ *******************************************************************************/ package org.eclipse.kapua.service.job; -import org.eclipse.kapua.model.KapuaEntityCreator; -import org.eclipse.kapua.model.KapuaNamedEntityCreator; -import org.eclipse.kapua.service.job.step.JobStep; +import java.util.ArrayList; +import java.util.List; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlTransient; import javax.xml.bind.annotation.XmlType; -import java.util.List; + +import org.eclipse.kapua.model.KapuaEntityCreator; +import org.eclipse.kapua.model.KapuaNamedEntityCreator; +import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.service.job.step.JobStep; /** * {@link Job} {@link KapuaEntityCreator} definition. @@ -30,8 +33,24 @@ */ @XmlRootElement(name = "jobCreator") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = JobXmlRegistry.class, factoryMethod = "newJobCreator") -public interface JobCreator extends KapuaNamedEntityCreator { +@XmlType +public class JobCreator extends KapuaNamedEntityCreator { + + private static final long serialVersionUID = 3119071638220738358L; + + private List jobSteps; + private String jobXmlDefinition; + + public JobCreator() { + } + + public JobCreator(KapuaId scopeId) { + super(scopeId); + } + + public JobCreator(KapuaId scopeId, String name) { + super(scopeId, name); + } /** * Gets the {@link List} of {@link JobStep}. @@ -42,17 +61,26 @@ public interface JobCreator extends KapuaNamedEntityCreator { */ @Deprecated @XmlTransient - List getJobSteps(); + public List getJobSteps() { + if (jobSteps == null) { + jobSteps = new ArrayList<>(); + } + + return jobSteps; + } /** * Sets the {@link List} of {@link JobStep}. * - * @param jobSteps The {@link List} of {@link JobStep}. + * @param jobSteps + * The {@link List} of {@link JobStep}. * @since 1.0.0 * @deprecated Since 1.1.0. The {@link JobStep} are no longer bound to the {@link Job}. */ @Deprecated - void setJobSteps(List jobSteps); + public void setJobSteps(List jobSteps) { + this.jobSteps = jobSteps; + } /** * Gets the jBatch Job xml definition. @@ -62,16 +90,21 @@ public interface JobCreator extends KapuaNamedEntityCreator { * @deprecated Since 1.1.0. The definition is no longer generated. */ @Deprecated - String getJobXmlDefinition(); + public String getJobXmlDefinition() { + return jobXmlDefinition; + } /** * Sets the jBatch Job xml definition. * - * @param jobXmlDefinition The jBatch Job xml definition. + * @param jobXmlDefinition + * The jBatch Job xml definition. * @since 1.0.0 * @deprecated Since 1.1.0. The definition is no longer generated. */ @Deprecated - void setJobXmlDefinition(String jobXmlDefinition); + public void setJobXmlDefinition(String jobXmlDefinition) { + this.jobXmlDefinition = jobXmlDefinition; + } } diff --git a/service/job/api/src/main/java/org/eclipse/kapua/service/job/JobFactory.java b/service/job/api/src/main/java/org/eclipse/kapua/service/job/JobFactory.java index cf2f8e13a25..4f8980d21b1 100644 --- a/service/job/api/src/main/java/org/eclipse/kapua/service/job/JobFactory.java +++ b/service/job/api/src/main/java/org/eclipse/kapua/service/job/JobFactory.java @@ -20,6 +20,6 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface JobFactory extends KapuaEntityFactory { +public interface JobFactory extends KapuaEntityFactory { } diff --git a/service/job/api/src/main/java/org/eclipse/kapua/service/job/JobXmlRegistry.java b/service/job/api/src/main/java/org/eclipse/kapua/service/job/JobXmlRegistry.java index 3b09636e7e0..8606074b9f7 100644 --- a/service/job/api/src/main/java/org/eclipse/kapua/service/job/JobXmlRegistry.java +++ b/service/job/api/src/main/java/org/eclipse/kapua/service/job/JobXmlRegistry.java @@ -35,15 +35,6 @@ public Job newJob() { return jobFactory.newEntity(null); } - /** - * Creates a new job creator instance - * - * @return - */ - public JobCreator newJobCreator() { - return jobFactory.newCreator(null); - } - public JobQuery newQuery() { return new JobQuery(null); } diff --git a/service/job/api/src/main/java/org/eclipse/kapua/service/job/execution/JobExecutionCreator.java b/service/job/api/src/main/java/org/eclipse/kapua/service/job/execution/JobExecutionCreator.java index bcb3a25e34a..1645d981686 100644 --- a/service/job/api/src/main/java/org/eclipse/kapua/service/job/execution/JobExecutionCreator.java +++ b/service/job/api/src/main/java/org/eclipse/kapua/service/job/execution/JobExecutionCreator.java @@ -12,9 +12,8 @@ *******************************************************************************/ package org.eclipse.kapua.service.job.execution; -import org.eclipse.kapua.model.KapuaUpdatableEntityCreator; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.model.id.KapuaIdAdapter; +import java.util.Date; +import java.util.Set; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; @@ -22,8 +21,11 @@ import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; -import java.util.Date; -import java.util.Set; + +import org.eclipse.kapua.model.KapuaEntityCreator; +import org.eclipse.kapua.model.KapuaUpdatableEntityCreator; +import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.model.id.KapuaIdAdapter; /** * {@link JobExecutionCreator} defintion. @@ -32,32 +34,57 @@ */ @XmlRootElement(name = "jobExecutionCreator") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = JobExecutionXmlRegistry.class, factoryMethod = "newJobExecutionCreator") -public interface JobExecutionCreator extends KapuaUpdatableEntityCreator { +@XmlType +public class JobExecutionCreator extends KapuaUpdatableEntityCreator { + + private static final long serialVersionUID = 3119071638220738358L; + + private KapuaId jobId; + private Date startedOn; + private Set targetIds; + + public JobExecutionCreator() { + } + + public JobExecutionCreator(KapuaId scopeId) { + super(scopeId); + } + + public JobExecutionCreator(KapuaEntityCreator entityCreator) { + super(entityCreator); + } /** * @return * @since 1.0.0 */ - KapuaId getJobId(); + public KapuaId getJobId() { + return jobId; + } /** * @param jobId * @since 1.0.0 */ - void setJobId(KapuaId jobId); + public void setJobId(KapuaId jobId) { + this.jobId = jobId; + } /** * @return * @since 1.0.0 */ - Date getStartedOn(); + public Date getStartedOn() { + return startedOn; + } /** * @param startedOn * @since 1.0.0 */ - void setStartedOn(Date startedOn); + public void setStartedOn(Date startedOn) { + this.startedOn = startedOn; + } /** * @return @@ -65,11 +92,15 @@ public interface JobExecutionCreator extends KapuaUpdatableEntityCreator Set getTargetIds(); + public Set getTargetIds() { + return targetIds; + } /** - * @param tagTargetIds + * @param targetIds * @since 1.1.0 */ - void setTargetIds(Set tagTargetIds); + public void setTargetIds(Set targetIds) { + this.targetIds = targetIds; + } } diff --git a/service/job/api/src/main/java/org/eclipse/kapua/service/job/execution/JobExecutionFactory.java b/service/job/api/src/main/java/org/eclipse/kapua/service/job/execution/JobExecutionFactory.java index 5b89204448f..290775a71de 100644 --- a/service/job/api/src/main/java/org/eclipse/kapua/service/job/execution/JobExecutionFactory.java +++ b/service/job/api/src/main/java/org/eclipse/kapua/service/job/execution/JobExecutionFactory.java @@ -20,6 +20,6 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface JobExecutionFactory extends KapuaEntityFactory { +public interface JobExecutionFactory extends KapuaEntityFactory { } diff --git a/service/job/api/src/main/java/org/eclipse/kapua/service/job/execution/JobExecutionXmlRegistry.java b/service/job/api/src/main/java/org/eclipse/kapua/service/job/execution/JobExecutionXmlRegistry.java index 650dd4c8219..4c4cfb818e9 100644 --- a/service/job/api/src/main/java/org/eclipse/kapua/service/job/execution/JobExecutionXmlRegistry.java +++ b/service/job/api/src/main/java/org/eclipse/kapua/service/job/execution/JobExecutionXmlRegistry.java @@ -34,14 +34,4 @@ public class JobExecutionXmlRegistry { public JobExecution newJobExecution() { return jobExecutionFactory.newEntity(null); } - - /** - * Creates a new job creator instance - * - * @return - */ - public JobExecutionCreator newJobExecutionCreator() { - return jobExecutionFactory.newCreator(null); - } - } diff --git a/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/JobStepCreator.java b/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/JobStepCreator.java index 86c62efde68..7ad4903264f 100644 --- a/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/JobStepCreator.java +++ b/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/JobStepCreator.java @@ -12,10 +12,8 @@ *******************************************************************************/ package org.eclipse.kapua.service.job.step; -import org.eclipse.kapua.model.KapuaNamedEntityCreator; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.model.id.KapuaIdAdapter; -import org.eclipse.kapua.service.job.step.definition.JobStepProperty; +import java.util.ArrayList; +import java.util.List; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; @@ -24,7 +22,11 @@ import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; -import java.util.List; + +import org.eclipse.kapua.model.KapuaNamedEntityCreator; +import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.model.id.KapuaIdAdapter; +import org.eclipse.kapua.service.job.step.definition.JobStepProperty; /** * {@link JobStepCreator} {@link org.eclipse.kapua.model.KapuaEntityCreator} definition @@ -33,56 +35,93 @@ */ @XmlRootElement(name = "jobStepCreator") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = JobStepXmlRegistry.class, factoryMethod = "newJobStepCreator") -public interface JobStepCreator extends KapuaNamedEntityCreator { +@XmlType +public class JobStepCreator extends KapuaNamedEntityCreator { + + private static final long serialVersionUID = 3119071638220738358L; + + private KapuaId jobId; + private Integer stepIndex; + private KapuaId jobStepDefinitionId; + private List jobStepProperty; + + public JobStepCreator() { + } + + public JobStepCreator(KapuaId scopeId) { + super(scopeId); + } + + public JobStepCreator(KapuaId scopeId, String name) { + super(scopeId, name); + } @XmlJavaTypeAdapter(KapuaIdAdapter.class) - KapuaId getJobId(); + public KapuaId getJobId() { + return jobId; + } - void setJobId(KapuaId jobId); + public void setJobId(KapuaId jobId) { + this.jobId = jobId; + } - Integer getStepIndex(); + public Integer getStepIndex() { + return stepIndex; + } - void setStepIndex(Integer stepIndex); + public void setStepIndex(Integer stepIndex) { + this.stepIndex = stepIndex; + } @XmlJavaTypeAdapter(KapuaIdAdapter.class) - KapuaId getJobStepDefinitionId(); + public KapuaId getJobStepDefinitionId() { + return jobStepDefinitionId; + } - void setJobStepDefinitionId(KapuaId jobStepDefinitionId); + public void setJobStepDefinitionId(KapuaId jobStepDefinitionId) { + this.jobStepDefinitionId = jobStepDefinitionId; + } @XmlElementWrapper(name = "stepProperties") @XmlElement(name = "stepProperty") -

    List

    getStepProperties(); + public List getStepProperties() { + if (jobStepProperty == null) { + jobStepProperty = new ArrayList<>(); + } - void setStepProperties(List jobStepProperties); + return jobStepProperty; + } + + public void setStepProperties(List jobStepProperty) { + this.jobStepProperty = jobStepProperty; + } /** - * @deprecated since 2.0.0. Please make use of {@link #getStepProperties()}. This method is deprecated - * because of issue #3580 (i.e. the step properties' field is called different depending on what request are you using). + * @deprecated since 2.0.0. Please make use of {@link #getStepProperties()}. This method is deprecated because of issue #3580 (i.e. the step properties' field is called different depending on what + * request are you using). */ @Deprecated @XmlElementWrapper(name = "jobStepProperties") @XmlElement(name = "jobStepProperty") - default

    List

    getJobStepPropertiesDeprecated() { + public List getJobStepPropertiesDeprecated() { return getStepProperties(); } /** - * @deprecated since 2.0.0. Please make use of {@link #setStepProperties(List)}. This method is deprecated - * because of issue #3580 (i.e. the step properties' field is called different depending on what request are you using). + * @deprecated since 2.0.0. Please make use of {@link #setStepProperties(List)}. This method is deprecated because of issue #3580 (i.e. the step properties' field is called different depending on + * what request are you using). */ @Deprecated - default void setJobStepProperties(List jobStepProperties) { + public void setJobStepProperties(List jobStepProperties) { setStepProperties(jobStepProperties); } - /** - * @deprecated since 2.0.0. Please make use of {@link #setStepProperties(List)}. This method is deprecated - * because of issue #3580 (i.e. the step properties' field is called different depending on what request are you using). + * @deprecated since 2.0.0. Please make use of {@link #setStepProperties(List)}. This method is deprecated because of issue #3580 (i.e. the step properties' field is called different depending on + * what request are you using). */ @Deprecated - default void setJobStepPropertiesDeprecated(List jobStepProperties) { + public void setJobStepPropertiesDeprecated(List jobStepProperties) { setStepProperties(jobStepProperties); } } diff --git a/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/JobStepFactory.java b/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/JobStepFactory.java index 8f0f680d81b..47e7f8fc121 100644 --- a/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/JobStepFactory.java +++ b/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/JobStepFactory.java @@ -21,7 +21,7 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface JobStepFactory extends KapuaEntityFactory { +public interface JobStepFactory extends KapuaEntityFactory { /** * Instantiates a new {@link JobStepProperty}. diff --git a/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/JobStepXmlRegistry.java b/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/JobStepXmlRegistry.java index f1e28f172a2..4dffe58963e 100644 --- a/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/JobStepXmlRegistry.java +++ b/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/JobStepXmlRegistry.java @@ -36,15 +36,6 @@ public JobStep newJobStep() { return jobStepFactory.newEntity(null); } - /** - * Creates a new job creator instance - * - * @return - */ - public JobStepCreator newJobStepCreator() { - return jobStepFactory.newCreator(null); - } - public JobStepProperty newJobStepProperty() { return jobStepFactory.newStepProperty(null, null, null); } diff --git a/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/definition/JobStepDefinitionCreator.java b/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/definition/JobStepDefinitionCreator.java index 204e364d684..8c4a3ec9db5 100644 --- a/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/definition/JobStepDefinitionCreator.java +++ b/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/definition/JobStepDefinitionCreator.java @@ -12,13 +12,16 @@ *******************************************************************************/ package org.eclipse.kapua.service.job.step.definition; -import org.eclipse.kapua.model.KapuaNamedEntityCreator; +import java.util.ArrayList; +import java.util.List; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; -import java.util.List; + +import org.eclipse.kapua.model.KapuaNamedEntityCreator; +import org.eclipse.kapua.model.id.KapuaId; /** * {@link JobStepDefinitionCreator} {@link org.eclipse.kapua.model.KapuaEntityCreator} definition @@ -27,26 +30,74 @@ */ @XmlRootElement(name = "jobStepDefinitionCreator") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = JobStepDefinitionXmlRegistry.class, factoryMethod = "newJobStepDefinitionCreator") -public interface JobStepDefinitionCreator extends KapuaNamedEntityCreator { +@XmlType +public class JobStepDefinitionCreator extends KapuaNamedEntityCreator { + + private static final long serialVersionUID = 4602067255120049746L; + + private JobStepType jobStepType; + private String readerName; + private String processorName; + private String writerName; + private List jobStepProperties; + + public JobStepDefinitionCreator() { + } + + public JobStepDefinitionCreator(KapuaId scopeId) { + super(scopeId); + } + + public JobStepDefinitionCreator(KapuaId scopeId, String name) { + super(scopeId, name); + } + + public JobStepType getStepType() { + return jobStepType; + } - JobStepType getStepType(); + public JobStepDefinitionCreator setStepType(JobStepType jobStepType) { + this.jobStepType = jobStepType; + return this; + } - void setStepType(JobStepType jobStepType); + public String getReaderName() { + return readerName; + } - String getReaderName(); + public JobStepDefinitionCreator setReaderName(String readerName) { + this.readerName = readerName; + return this; + } - void setReaderName(String readerName); + public String getProcessorName() { + return processorName; + } - String getProcessorName(); + public JobStepDefinitionCreator setProcessorName(String processorName) { + this.processorName = processorName; + return this; + } - void setProcessorName(String processorName); + public String getWriterName() { + return writerName; + } - String getWriterName(); + public JobStepDefinitionCreator setWriterName(String writerName) { + this.writerName = writerName; + return this; + } - void setWriterName(String writesName); + public List getStepProperties() { + if (jobStepProperties == null) { + jobStepProperties = new ArrayList<>(); + } - List getStepProperties(); + return jobStepProperties; + } - void setStepProperties(List jobStepProperties); + public JobStepDefinitionCreator setStepProperties(List jobStepProperties) { + this.jobStepProperties = jobStepProperties; + return this; + } } diff --git a/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/definition/JobStepDefinitionFactory.java b/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/definition/JobStepDefinitionFactory.java index ff576bdb12d..051a3f8e22c 100644 --- a/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/definition/JobStepDefinitionFactory.java +++ b/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/definition/JobStepDefinitionFactory.java @@ -20,7 +20,7 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface JobStepDefinitionFactory extends KapuaEntityFactory { +public interface JobStepDefinitionFactory extends KapuaEntityFactory { /** * Instantiates a new {@link JobStepProperty}. diff --git a/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/definition/JobStepDefinitionXmlRegistry.java b/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/definition/JobStepDefinitionXmlRegistry.java index ab20432afc9..cf58315f53d 100644 --- a/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/definition/JobStepDefinitionXmlRegistry.java +++ b/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/definition/JobStepDefinitionXmlRegistry.java @@ -34,13 +34,4 @@ public class JobStepDefinitionXmlRegistry { public JobStepDefinition newJobStepDefinition() { return jobStepDefinitionFactory.newEntity(null); } - - /** - * Creates a new job creator instance - * - * @return - */ - public JobStepDefinitionCreator newJobStepDefinitionCreator() { - return jobStepDefinitionFactory.newCreator(null); - } } diff --git a/service/job/api/src/main/java/org/eclipse/kapua/service/job/targets/JobTargetCreator.java b/service/job/api/src/main/java/org/eclipse/kapua/service/job/targets/JobTargetCreator.java index a5d615868c8..3f19d2ca647 100644 --- a/service/job/api/src/main/java/org/eclipse/kapua/service/job/targets/JobTargetCreator.java +++ b/service/job/api/src/main/java/org/eclipse/kapua/service/job/targets/JobTargetCreator.java @@ -12,34 +12,58 @@ *******************************************************************************/ package org.eclipse.kapua.service.job.targets; -import org.eclipse.kapua.model.KapuaUpdatableEntityCreator; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.model.id.KapuaIdAdapter; - import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; +import org.eclipse.kapua.model.KapuaEntityCreator; +import org.eclipse.kapua.model.KapuaUpdatableEntityCreator; +import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.model.id.KapuaIdAdapter; + /** - * {@link JobTargetCreator} encapsulates all the information needed to create a new JobTarget in the system.
    - * The data provided will be used to seed the new JobTarget. + * {@link JobTargetCreator} encapsulates all the information needed to create a new JobTarget in the system.
    The data provided will be used to seed the new JobTarget. * * @since 1.0.0 */ @XmlRootElement(name = "jobTargetCreator") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = JobTargetXmlRegistry.class, factoryMethod = "newJobTargetCreator") -public interface JobTargetCreator extends KapuaUpdatableEntityCreator { +@XmlType +public class JobTargetCreator extends KapuaUpdatableEntityCreator { + + private static final long serialVersionUID = 3119071638220738358L; + + private KapuaId jobId; + private KapuaId jobTargetId; + + public JobTargetCreator() { + } + + public JobTargetCreator(KapuaId scopeId) { + super(scopeId); + } + + public JobTargetCreator(KapuaEntityCreator entityCreator) { + super(entityCreator); + } @XmlJavaTypeAdapter(KapuaIdAdapter.class) - KapuaId getJobId(); + public KapuaId getJobId() { + return jobId; + } - void setJobId(KapuaId jobId); + public void setJobId(KapuaId jobId) { + this.jobId = jobId; + } @XmlJavaTypeAdapter(KapuaIdAdapter.class) - KapuaId getJobTargetId(); + public KapuaId getJobTargetId() { + return jobTargetId; + } - void setJobTargetId(KapuaId jobTargetId); + public void setJobTargetId(KapuaId jobTargetId) { + this.jobTargetId = jobTargetId; + } } diff --git a/service/job/api/src/main/java/org/eclipse/kapua/service/job/targets/JobTargetFactory.java b/service/job/api/src/main/java/org/eclipse/kapua/service/job/targets/JobTargetFactory.java index 953e0690de9..83c754cc9ed 100644 --- a/service/job/api/src/main/java/org/eclipse/kapua/service/job/targets/JobTargetFactory.java +++ b/service/job/api/src/main/java/org/eclipse/kapua/service/job/targets/JobTargetFactory.java @@ -20,6 +20,6 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface JobTargetFactory extends KapuaEntityFactory { +public interface JobTargetFactory extends KapuaEntityFactory { } diff --git a/service/job/api/src/main/java/org/eclipse/kapua/service/job/targets/JobTargetXmlRegistry.java b/service/job/api/src/main/java/org/eclipse/kapua/service/job/targets/JobTargetXmlRegistry.java index 75b92f3f05f..af21453f536 100644 --- a/service/job/api/src/main/java/org/eclipse/kapua/service/job/targets/JobTargetXmlRegistry.java +++ b/service/job/api/src/main/java/org/eclipse/kapua/service/job/targets/JobTargetXmlRegistry.java @@ -34,14 +34,4 @@ public class JobTargetXmlRegistry { public JobTarget newJobTarget() { return jobTargetFactory.newEntity(null); } - - /** - * Creates a new job creator instance - * - * @return - */ - public JobTargetCreator newJobTargetCreator() { - return jobTargetFactory.newCreator(null); - } - } diff --git a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/execution/internal/JobExecutionCreatorImpl.java b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/execution/internal/JobExecutionCreatorImpl.java deleted file mode 100644 index 10cc8af3b89..00000000000 --- a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/execution/internal/JobExecutionCreatorImpl.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017, 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.service.job.execution.internal; - -import org.eclipse.kapua.commons.model.AbstractKapuaUpdatableEntityCreator; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.service.job.execution.JobExecution; -import org.eclipse.kapua.service.job.execution.JobExecutionCreator; - -import java.util.Date; -import java.util.Set; - -/** - * {@link JobExecutionCreator} implementation - * - * @since 1.0.0 - */ -public class JobExecutionCreatorImpl extends AbstractKapuaUpdatableEntityCreator implements JobExecutionCreator { - - private static final long serialVersionUID = 3119071638220738358L; - - private KapuaId jobId; - private Date startedOn; - private Set targetIds; - - protected JobExecutionCreatorImpl(KapuaId scopeId) { - super(scopeId); - } - - @Override - public KapuaId getJobId() { - return jobId; - } - - @Override - public void setJobId(KapuaId jobId) { - this.jobId = jobId; - } - - @Override - public Date getStartedOn() { - return startedOn; - } - - @Override - public void setStartedOn(Date startedOn) { - this.startedOn = startedOn; - } - - @Override - public Set getTargetIds() { - return targetIds; - } - - @Override - public void setTargetIds(Set targetIds) { - this.targetIds = targetIds; - } -} diff --git a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/execution/internal/JobExecutionFactoryImpl.java b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/execution/internal/JobExecutionFactoryImpl.java index 1ce1c2e8162..3eae6ec50f9 100644 --- a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/execution/internal/JobExecutionFactoryImpl.java +++ b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/execution/internal/JobExecutionFactoryImpl.java @@ -17,7 +17,6 @@ import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.job.execution.JobExecution; -import org.eclipse.kapua.service.job.execution.JobExecutionCreator; import org.eclipse.kapua.service.job.execution.JobExecutionFactory; /** @@ -33,11 +32,6 @@ public JobExecution newEntity(KapuaId scopeId) { return new JobExecutionImpl(scopeId); } - @Override - public JobExecutionCreator newCreator(KapuaId scopeId) { - return new JobExecutionCreatorImpl(scopeId); - } - @Override public JobExecution clone(JobExecution jobExecution) { try { diff --git a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/internal/JobCreatorImpl.java b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/internal/JobCreatorImpl.java deleted file mode 100644 index e424806204c..00000000000 --- a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/internal/JobCreatorImpl.java +++ /dev/null @@ -1,63 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017, 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.service.job.internal; - -import org.eclipse.kapua.commons.model.AbstractKapuaNamedEntityCreator; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.service.job.Job; -import org.eclipse.kapua.service.job.JobCreator; -import org.eclipse.kapua.service.job.step.JobStep; - -import java.util.ArrayList; -import java.util.List; - -/** - * {@link JobCreator} implementation - * - * @since 1.0.0 - */ -public class JobCreatorImpl extends AbstractKapuaNamedEntityCreator implements JobCreator { - - private static final long serialVersionUID = 3119071638220738358L; - - private List jobSteps; - private String jobXmlDefinition; - - public JobCreatorImpl(KapuaId scopeId) { - super(scopeId); - } - - @Override - public List getJobSteps() { - if (jobSteps == null) { - jobSteps = new ArrayList<>(); - } - - return jobSteps; - } - - @Override - public void setJobSteps(List jobSteps) { - this.jobSteps = jobSteps; - } - - @Override - public String getJobXmlDefinition() { - return jobXmlDefinition; - } - - @Override - public void setJobXmlDefinition(String jobXmlDefinition) { - this.jobXmlDefinition = jobXmlDefinition; - } -} diff --git a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/internal/JobFactoryImpl.java b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/internal/JobFactoryImpl.java index 3f361429a31..d21d9da76e4 100644 --- a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/internal/JobFactoryImpl.java +++ b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/internal/JobFactoryImpl.java @@ -17,7 +17,6 @@ import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.job.Job; -import org.eclipse.kapua.service.job.JobCreator; import org.eclipse.kapua.service.job.JobFactory; /** @@ -33,11 +32,6 @@ public Job newEntity(KapuaId scopeId) { return new JobImpl(scopeId); } - @Override - public JobCreator newCreator(KapuaId scopeId) { - return new JobCreatorImpl(scopeId); - } - @Override public Job clone(Job job) { try { diff --git a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/definition/internal/JobStepDefinitionCreatorImpl.java b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/definition/internal/JobStepDefinitionCreatorImpl.java deleted file mode 100644 index 61823f3ef72..00000000000 --- a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/definition/internal/JobStepDefinitionCreatorImpl.java +++ /dev/null @@ -1,98 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017, 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.service.job.step.definition.internal; - -import org.eclipse.kapua.commons.model.AbstractKapuaNamedEntityCreator; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.service.job.step.definition.JobStepDefinition; -import org.eclipse.kapua.service.job.step.definition.JobStepDefinitionCreator; -import org.eclipse.kapua.service.job.step.definition.JobStepProperty; -import org.eclipse.kapua.service.job.step.definition.JobStepType; - -import java.util.ArrayList; -import java.util.List; - -/** - * {@link JobStepDefinitionCreator} implementation - * - * @since 1.0.0 - */ -public class JobStepDefinitionCreatorImpl extends AbstractKapuaNamedEntityCreator implements JobStepDefinitionCreator { - - private static final long serialVersionUID = 4602067255120049746L; - - private JobStepType jobStepType; - private String readerName; - private String processorName; - private String writerName; - private List jobStepProperties; - - public JobStepDefinitionCreatorImpl(KapuaId scopeId) { - super(scopeId); - } - - @Override - public JobStepType getStepType() { - return jobStepType; - } - - @Override - public void setStepType(JobStepType jobStepType) { - this.jobStepType = jobStepType; - } - - @Override - public String getReaderName() { - return readerName; - } - - @Override - public void setReaderName(String readerName) { - this.readerName = readerName; - } - - @Override - public String getProcessorName() { - return processorName; - } - - @Override - public void setProcessorName(String processorName) { - this.processorName = processorName; - } - - @Override - public String getWriterName() { - return writerName; - } - - @Override - public void setWriterName(String writerName) { - this.writerName = writerName; - } - - @Override - public List getStepProperties() { - if (jobStepProperties == null) { - jobStepProperties = new ArrayList<>(); - } - - return jobStepProperties; - } - - @Override - public void setStepProperties(List jobStepProperties) { - this.jobStepProperties = jobStepProperties; - } - -} diff --git a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/definition/internal/JobStepDefinitionFactoryImpl.java b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/definition/internal/JobStepDefinitionFactoryImpl.java index 3774d45e89a..e43dfb3e77e 100644 --- a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/definition/internal/JobStepDefinitionFactoryImpl.java +++ b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/definition/internal/JobStepDefinitionFactoryImpl.java @@ -17,7 +17,6 @@ import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.job.step.definition.JobStepDefinition; -import org.eclipse.kapua.service.job.step.definition.JobStepDefinitionCreator; import org.eclipse.kapua.service.job.step.definition.JobStepDefinitionFactory; import org.eclipse.kapua.service.job.step.definition.JobStepProperty; @@ -34,11 +33,6 @@ public JobStepDefinition newEntity(KapuaId scopeId) { return new JobStepDefinitionImpl(scopeId); } - @Override - public JobStepDefinitionCreator newCreator(KapuaId scopeId) { - return new JobStepDefinitionCreatorImpl(scopeId); - } - @Override public JobStepProperty newStepProperty(String name, String type, String value) { return new JobStepPropertyImpl(name, type, value, null); diff --git a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/internal/JobStepCreatorImpl.java b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/internal/JobStepCreatorImpl.java deleted file mode 100644 index b7ac041c9bf..00000000000 --- a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/internal/JobStepCreatorImpl.java +++ /dev/null @@ -1,86 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017, 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.service.job.step.internal; - -import org.eclipse.kapua.commons.model.AbstractKapuaNamedEntityCreator; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.service.job.step.JobStep; -import org.eclipse.kapua.service.job.step.JobStepCreator; -import org.eclipse.kapua.service.job.step.definition.JobStepProperty; - -import java.util.ArrayList; -import java.util.List; - -/** - * {@link JobStepCreator} implementation - * - * @since 1.0.0 - */ -public class JobStepCreatorImpl extends AbstractKapuaNamedEntityCreator implements JobStepCreator { - - private static final long serialVersionUID = 3119071638220738358L; - - private KapuaId jobId; - private Integer stepIndex; - private KapuaId jobStepDefinitionId; - private List jobStepProperty; - - public JobStepCreatorImpl(KapuaId scopeId) { - super(scopeId); - } - - @Override - public KapuaId getJobId() { - return jobId; - } - - @Override - public void setJobId(KapuaId jobId) { - this.jobId = jobId; - } - - @Override - public Integer getStepIndex() { - return stepIndex; - } - - @Override - public void setStepIndex(Integer stepIndex) { - this.stepIndex = stepIndex; - } - - @Override - public KapuaId getJobStepDefinitionId() { - return jobStepDefinitionId; - } - - @Override - public void setJobStepDefinitionId(KapuaId jobStepDefinitionId) { - this.jobStepDefinitionId = jobStepDefinitionId; - } - - @Override - public List getStepProperties() { - if (jobStepProperty == null) { - jobStepProperty = new ArrayList<>(); - } - - return jobStepProperty; - } - - @Override - public void setStepProperties(List jobStepProperty) { - this.jobStepProperty = jobStepProperty; - } - -} diff --git a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/internal/JobStepFactoryImpl.java b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/internal/JobStepFactoryImpl.java index 36c9062a8b2..40c77226ced 100644 --- a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/internal/JobStepFactoryImpl.java +++ b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/internal/JobStepFactoryImpl.java @@ -16,7 +16,6 @@ import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.service.job.step.JobStepCreator; import org.eclipse.kapua.service.job.step.JobStepFactory; import org.eclipse.kapua.service.job.step.definition.JobStepProperty; import org.eclipse.kapua.service.job.step.definition.internal.JobStepPropertyImpl; @@ -34,11 +33,6 @@ public org.eclipse.kapua.service.job.step.JobStep newEntity(KapuaId scopeId) { return new JobStepImpl(scopeId); } - @Override - public JobStepCreator newCreator(KapuaId scopeId) { - return new JobStepCreatorImpl(scopeId); - } - @Override public JobStepProperty newStepProperty(String name, String propertyType, String propertyValue) { return new JobStepPropertyImpl(name, propertyType, propertyValue, null); diff --git a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/targets/internal/JobTargetCreatorImpl.java b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/targets/internal/JobTargetCreatorImpl.java deleted file mode 100644 index 88bfe3d09bd..00000000000 --- a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/targets/internal/JobTargetCreatorImpl.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017, 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.service.job.targets.internal; - -import org.eclipse.kapua.commons.model.AbstractKapuaUpdatableEntityCreator; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.service.job.targets.JobTarget; -import org.eclipse.kapua.service.job.targets.JobTargetCreator; - -public class JobTargetCreatorImpl extends AbstractKapuaUpdatableEntityCreator implements JobTargetCreator { - - private static final long serialVersionUID = 3119071638220738358L; - - private KapuaId jobId; - private KapuaId jobTargetId; - - public JobTargetCreatorImpl(KapuaId scopeId) { - super(scopeId); - } - - @Override - public KapuaId getJobId() { - return jobId; - } - - @Override - public void setJobId(KapuaId jobId) { - this.jobId = jobId; - } - - @Override - public KapuaId getJobTargetId() { - return jobTargetId; - } - - @Override - public void setJobTargetId(KapuaId jobTargetId) { - this.jobTargetId = jobTargetId; - } - -} diff --git a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/targets/internal/JobTargetFactoryImpl.java b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/targets/internal/JobTargetFactoryImpl.java index 44b929c4548..e06831ff942 100644 --- a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/targets/internal/JobTargetFactoryImpl.java +++ b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/targets/internal/JobTargetFactoryImpl.java @@ -17,7 +17,6 @@ import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.job.targets.JobTarget; -import org.eclipse.kapua.service.job.targets.JobTargetCreator; import org.eclipse.kapua.service.job.targets.JobTargetFactory; /** @@ -33,11 +32,6 @@ public JobTarget newEntity(KapuaId scopeId) { return new JobTargetImpl(scopeId); } - @Override - public JobTargetCreator newCreator(KapuaId scopeId) { - return new JobTargetCreatorImpl(scopeId); - } - @Override public JobTarget clone(JobTarget jobTarget) { try { diff --git a/service/job/test-steps/src/main/java/org/eclipse/kapua/service/job/steps/JobExecutionServiceSteps.java b/service/job/test-steps/src/main/java/org/eclipse/kapua/service/job/steps/JobExecutionServiceSteps.java index 6eba218e487..12c0b4c2ee3 100644 --- a/service/job/test-steps/src/main/java/org/eclipse/kapua/service/job/steps/JobExecutionServiceSteps.java +++ b/service/job/test-steps/src/main/java/org/eclipse/kapua/service/job/steps/JobExecutionServiceSteps.java @@ -448,14 +448,14 @@ public void checkThatNoExecutionWasFound() { @When("I test the sanity of the job execution factory") public void testTheJobExecutionFactory() { - Assert.assertNotNull(jobExecutionFactory.newCreator(SYS_SCOPE_ID)); + Assert.assertNotNull(new JobExecutionCreator(SYS_SCOPE_ID)); Assert.assertNotNull(jobExecutionFactory.newEntity(SYS_SCOPE_ID)); } // Private methods private JobExecutionCreator prepareDefaultJobExecutionCreator() { KapuaId currentJobId = (KapuaId) stepData.get(CURRENT_JOB_ID); - JobExecutionCreator tmpCr = jobExecutionFactory.newCreator(getCurrentScopeId()); + JobExecutionCreator tmpCr = new JobExecutionCreator(getCurrentScopeId()); tmpCr.setJobId(currentJobId); tmpCr.setStartedOn(DateTime.now().toDate()); return tmpCr; diff --git a/service/job/test-steps/src/main/java/org/eclipse/kapua/service/job/steps/JobServiceSteps.java b/service/job/test-steps/src/main/java/org/eclipse/kapua/service/job/steps/JobServiceSteps.java index f650eea81c3..01b12b58083 100644 --- a/service/job/test-steps/src/main/java/org/eclipse/kapua/service/job/steps/JobServiceSteps.java +++ b/service/job/test-steps/src/main/java/org/eclipse/kapua/service/job/steps/JobServiceSteps.java @@ -95,7 +95,7 @@ public void setJobServiceConfigurationValue(List cucConfigs) throws E @Given("A regular job creator with the name {string}") public void prepareARegularJobCreator(String name) { - JobCreator jobCreator = jobFactory.newCreator(getCurrentScopeId()); + JobCreator jobCreator = new JobCreator(getCurrentScopeId()); jobCreator.setName(name); jobCreator.setDescription(TEST_JOB); stepData.put(JOB_CREATOR, jobCreator); @@ -103,7 +103,7 @@ public void prepareARegularJobCreator(String name) { @Given("A job creator with a null name") public void prepareAJobCreatorWithNullName() { - JobCreator jobCreator = jobFactory.newCreator(getCurrentScopeId()); + JobCreator jobCreator = new JobCreator(getCurrentScopeId()); jobCreator.setName(null); jobCreator.setDescription(TEST_JOB); stepData.put(JOB_CREATOR, jobCreator); @@ -111,7 +111,7 @@ public void prepareAJobCreatorWithNullName() { @Given("A job creator with an empty name") public void prepareAJobCreatorWithAnEmptyName() { - JobCreator jobCreator = jobFactory.newCreator(getCurrentScopeId()); + JobCreator jobCreator = new JobCreator(getCurrentScopeId()); jobCreator.setName(""); jobCreator.setDescription(TEST_JOB); stepData.put(JOB_CREATOR, jobCreator); @@ -138,7 +138,7 @@ public void createANumberOfJobs(int num) throws Exception { primeException(); try { for (int i = 0; i < num; i++) { - JobCreator tmpCreator = jobFactory.newCreator(getCurrentScopeId()); + JobCreator tmpCreator = new JobCreator(getCurrentScopeId()); tmpCreator.setName(String.format("TestJobNum%d", i)); tmpCreator.setDescription("TestJobDescription"); jobService.create(tmpCreator); @@ -150,7 +150,7 @@ public void createANumberOfJobs(int num) throws Exception { @Given("I create {int} job items with the name {string}") public void createANumberOfJobsWithName(int num, String name) throws Exception { - JobCreator tmpCreator = jobFactory.newCreator(getCurrentScopeId()); + JobCreator tmpCreator = new JobCreator(getCurrentScopeId()); tmpCreator.setDescription("TestJobDescription"); primeException(); try { @@ -339,7 +339,7 @@ public void checkJobItemXMLDefinition(String definition) { @When("I test the sanity of the job factory") public void testJobFactorySanity() { primeException(); - Assert.assertNotNull("The job factory returned a null creator!", jobFactory.newCreator(SYS_SCOPE_ID)); + Assert.assertNotNull("The job factory returned a null creator!", new JobCreator(SYS_SCOPE_ID)); Assert.assertNotNull("The job factory returned a null job object!", jobFactory.newEntity(SYS_SCOPE_ID)); Assert.assertNotNull("The job factory returned a null job query!", new JobQuery(SYS_SCOPE_ID)); } @@ -402,7 +402,7 @@ public void iQueryForTheJobMatchTerm(String matchTerm) throws Exception { @Given("I prepare a job with name {string} and description {string}") public void iPrepareAJobWithNameAndDescription(String name, String description) { - JobCreator jobCreator = jobFactory.newCreator(SYS_SCOPE_ID); + JobCreator jobCreator = new JobCreator(SYS_SCOPE_ID); jobCreator.setName(name); jobCreator.setDescription(description); stepData.put(JOB_CREATOR, jobCreator); @@ -472,7 +472,7 @@ public void iChangeTheJobDescriptionFromTo(String oldDescription, String newDesc // Private methods private void tryToCreateJob(String characters) throws Exception { - JobCreator jobCreator = jobFactory.newCreator(getCurrentScopeId()); + JobCreator jobCreator = new JobCreator(getCurrentScopeId()); for (int i = 0; i < characters.length(); i++) { String jobName = JOB_NAME + characters.charAt(i); jobCreator.setName(jobName); @@ -488,7 +488,7 @@ private void tryToCreateJob(String characters) throws Exception { } private void tryToUpdateJobName(String characters) throws Exception { - JobCreator jobCreator = jobFactory.newCreator(getCurrentScopeId()); + JobCreator jobCreator = new JobCreator(getCurrentScopeId()); //are we sure works as expected with invalid characters? for (int i = 0; i < characters.length(); i++) { String jobName = JOB_NAME + characters.charAt(i); diff --git a/service/job/test-steps/src/main/java/org/eclipse/kapua/service/job/steps/JobStepDefinitionServiceSteps.java b/service/job/test-steps/src/main/java/org/eclipse/kapua/service/job/steps/JobStepDefinitionServiceSteps.java index 9ce506eb522..2dcbf642376 100644 --- a/service/job/test-steps/src/main/java/org/eclipse/kapua/service/job/steps/JobStepDefinitionServiceSteps.java +++ b/service/job/test-steps/src/main/java/org/eclipse/kapua/service/job/steps/JobStepDefinitionServiceSteps.java @@ -158,7 +158,7 @@ public void createANumberOfStepDefinitions(Integer num) throws Exception { primeException(); try { for (int i = 0; i < num; i++) { - tmpCreator = jobStepDefinitionFactory.newCreator(getCurrentScopeId()); + tmpCreator = new JobStepDefinitionCreator(getCurrentScopeId()); tmpCreator.setName(String.format("TestStepDefinitionNum%d", random.nextLong())); tmpCreator.setProcessorName("TestStepProcessor"); tmpCreator.setStepType(JobStepType.TARGET); @@ -326,7 +326,7 @@ public void checkStepDefinitionProcessorName(String name) { @When("I test the sanity of the step definition factory") public void testTheStepDefinitionFactory() { - Assert.assertNotNull(jobStepDefinitionFactory.newCreator(SYS_SCOPE_ID)); + Assert.assertNotNull(new JobStepDefinitionCreator(SYS_SCOPE_ID)); Assert.assertNotNull(jobStepDefinitionFactory.newEntity(SYS_SCOPE_ID)); Assert.assertNotNull(jobStepDefinitionFactory.newStepProperty("TestName", "TestType", "TestValue", "TestExampleValue")); } @@ -340,7 +340,7 @@ private JobStepType getTypeFromString(String type) { } private JobStepDefinitionCreator prepareDefaultJobStepDefinitionCreator() { - JobStepDefinitionCreator tmpCr = jobStepDefinitionFactory.newCreator(getCurrentScopeId()); + JobStepDefinitionCreator tmpCr = new JobStepDefinitionCreator(getCurrentScopeId()); tmpCr.setName(String.format("DefinitionName_%d", random.nextInt())); tmpCr.setDescription("DefinitionDescription"); tmpCr.setReaderName(null); diff --git a/service/job/test-steps/src/main/java/org/eclipse/kapua/service/job/steps/JobStepServiceSteps.java b/service/job/test-steps/src/main/java/org/eclipse/kapua/service/job/steps/JobStepServiceSteps.java index ea17fc5d7ce..4ab97d4dc54 100644 --- a/service/job/test-steps/src/main/java/org/eclipse/kapua/service/job/steps/JobStepServiceSteps.java +++ b/service/job/test-steps/src/main/java/org/eclipse/kapua/service/job/steps/JobStepServiceSteps.java @@ -121,7 +121,7 @@ public void iAddJobStepToJobWithSelectedJobStepDefinitionAndFollowingJobStepProp Job job = (Job) stepData.get(JOB); JobStepDefinition jobStepDefinition = (JobStepDefinition) stepData.get(JOB_STEP_DEFINITION); - JobStepCreator jobStepCreator = jobStepFactory.newCreator(job.getScopeId()); + JobStepCreator jobStepCreator = new JobStepCreator(job.getScopeId()); jobStepCreator.setJobId(job.getId()); jobStepCreator.setName(jobStepName); jobStepCreator.setJobStepDefinitionId(jobStepDefinition.getId()); @@ -378,7 +378,7 @@ public void checkJobStepNotFound() { @When("I test the JobStepFactory") public void testTheStepFactory() { - Assert.assertNotNull(jobStepFactory.newCreator(SYS_SCOPE_ID)); + Assert.assertNotNull(new JobStepCreator(SYS_SCOPE_ID)); Assert.assertNotNull(jobStepFactory.newEntity(SYS_SCOPE_ID)); Assert.assertNotNull(new KapuaQuery(SYS_SCOPE_ID)); Assert.assertNotNull(jobStepFactory.newStepProperty("TestName", "TestType", "TestValue")); @@ -386,7 +386,7 @@ public void testTheStepFactory() { // Private methods private JobStepCreator prepareDefaultJobStepCreator() { - JobStepCreator tmpCr = jobStepFactory.newCreator(getCurrentScopeId()); + JobStepCreator tmpCr = new JobStepCreator(getCurrentScopeId()); tmpCr.setName(String.format("StepName_%d", random.nextInt())); tmpCr.setDescription("StepDescription"); return tmpCr; diff --git a/service/job/test-steps/src/main/java/org/eclipse/kapua/service/job/steps/JobTargetServiceSteps.java b/service/job/test-steps/src/main/java/org/eclipse/kapua/service/job/steps/JobTargetServiceSteps.java index 82ed30dd114..c40a729a49e 100644 --- a/service/job/test-steps/src/main/java/org/eclipse/kapua/service/job/steps/JobTargetServiceSteps.java +++ b/service/job/test-steps/src/main/java/org/eclipse/kapua/service/job/steps/JobTargetServiceSteps.java @@ -166,7 +166,7 @@ public void addDeviceTargetsToJob(List clientIds) throws Exception { Job job = (Job) stepData.get("Job"); - JobTargetCreator jobTargetCreator = jobTargetFactory.newCreator(getCurrentScopeId()); + JobTargetCreator jobTargetCreator = new JobTargetCreator(getCurrentScopeId()); jobTargetCreator.setJobId(job.getId()); List jobTargets = new ArrayList<>(); @@ -180,7 +180,7 @@ public void addDeviceTargetsToJob(List clientIds) throws Exception { @And("I add target(s) to job") public void addTargetsToJob() throws Exception { - JobTargetCreator jobTargetCreator = jobTargetFactory.newCreator(getCurrentScopeId()); + JobTargetCreator jobTargetCreator = new JobTargetCreator(getCurrentScopeId()); Job job = (Job) stepData.get("Job"); ArrayList devices = (ArrayList) stepData.get("DeviceList"); ArrayList jobTargetList = new ArrayList<>(); @@ -371,7 +371,7 @@ public void checkThatNoTargetWasFound() { @When("I test the sanity of the job target factory") public void testTheJobTargetFactory() { - Assert.assertNotNull(jobTargetFactory.newCreator(SYS_SCOPE_ID)); + Assert.assertNotNull(new JobTargetCreator(SYS_SCOPE_ID)); Assert.assertNotNull(jobTargetFactory.newEntity(SYS_SCOPE_ID)); } @@ -460,7 +460,7 @@ private void checkJobTargetForJobHas(JobTarget jobTarget, int expectedStepIndex, private JobTargetCreator prepareJobTargetCreator() { KapuaId currentJobId = (KapuaId) stepData.get(CURRENT_JOB_ID); Device device = (Device) stepData.get(DEVICE); - JobTargetCreator tmpCr = jobTargetFactory.newCreator(getCurrentScopeId()); + JobTargetCreator tmpCr = new JobTargetCreator(getCurrentScopeId()); tmpCr.setJobId(currentJobId); tmpCr.setJobTargetId(device.getId()); return tmpCr; @@ -468,7 +468,7 @@ private JobTargetCreator prepareJobTargetCreator() { private JobTargetCreator prepareDefaultJobTargetCreator() { KapuaId currentJobId = (KapuaId) stepData.get(CURRENT_JOB_ID); - JobTargetCreator tmpCr = jobTargetFactory.newCreator(getCurrentScopeId()); + JobTargetCreator tmpCr = new JobTargetCreator(getCurrentScopeId()); tmpCr.setJobId(currentJobId); tmpCr.setJobTargetId(getKapuaId()); return tmpCr; diff --git a/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/TriggerCreator.java b/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/TriggerCreator.java index 51c08681b52..4e81f6ae4e3 100644 --- a/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/TriggerCreator.java +++ b/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/TriggerCreator.java @@ -12,18 +12,20 @@ *******************************************************************************/ package org.eclipse.kapua.service.scheduler.trigger; -import org.eclipse.kapua.model.KapuaNamedEntityCreator; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.model.id.KapuaIdAdapter; -import org.eclipse.kapua.service.scheduler.trigger.definition.TriggerProperty; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; -import java.util.Date; -import java.util.List; + +import org.eclipse.kapua.model.KapuaNamedEntityCreator; +import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.model.id.KapuaIdAdapter; +import org.eclipse.kapua.service.scheduler.trigger.definition.TriggerProperty; /** * {@link Trigger} {@link KapuaNamedEntityCreator} definition. @@ -33,8 +35,28 @@ */ @XmlRootElement(name = "triggerCreator") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = TriggerXmlRegistry.class, factoryMethod = "newCreator") -public interface TriggerCreator extends KapuaNamedEntityCreator { +@XmlType +public class TriggerCreator extends KapuaNamedEntityCreator { + + private static final long serialVersionUID = -2460883485294616032L; + + private Date startsOn; + private Date endsOn; + private String cronScheduling; + private Long retryInterval; + private KapuaId triggerDefinitionId; + private List triggerProperties; + + public TriggerCreator() { + } + + public TriggerCreator(KapuaId scopeId) { + super(scopeId); + } + + public TriggerCreator(KapuaId scopeId, String name) { + super(scopeId, name); + } /** * Gets the start {@link Date} from which this {@link Trigger} will be valid. @@ -42,15 +64,20 @@ public interface TriggerCreator extends KapuaNamedEntityCreator { * @return The start {@link Date} from which this {@link Trigger} will be valid. * @since 1.0.0 */ - Date getStartsOn(); + public Date getStartsOn() { + return startsOn; + } /** * Sets the start {@link Date} from which this {@link Trigger} will be valid. * - * @param starstOn The start {@link Date} from which this {@link Trigger} will be valid. + * @param startsOn + * The start {@link Date} from which this {@link Trigger} will be valid. * @since 1.0.0 */ - void setStartsOn(Date starstOn); + public void setStartsOn(Date startsOn) { + this.startsOn = startsOn; + } /** * Gets the end {@link Date} until which this {@link Trigger} will be valid. @@ -60,17 +87,22 @@ public interface TriggerCreator extends KapuaNamedEntityCreator { * @return The start {@link Date} from which this {@link Trigger} will be valid. * @since 1.0.0 */ - Date getEndsOn(); + public Date getEndsOn() { + return endsOn; + } /** * Gets the end {@link Date} until which this {@link Trigger} will be valid. *

    * {@code null} means that never expires. * - * @param endsOn The end {@link Date} until which this {@link Trigger} will be valid. + * @param endsOn + * The end {@link Date} until which this {@link Trigger} will be valid. * @since 1.0.0 */ - void setEndsOn(Date endsOn); + public void setEndsOn(Date endsOn) { + this.endsOn = endsOn; + } /** * Gets the CRON scheduling. @@ -82,19 +114,24 @@ public interface TriggerCreator extends KapuaNamedEntityCreator { * @deprecated since 1.1.0 */ @Deprecated - String getCronScheduling(); + public String getCronScheduling() { + return cronScheduling; + } /** * Sets the CRON scheduling. *

    * This field is {@code deprecated}. Please make use of {@link org.eclipse.kapua.service.scheduler.trigger.definition.TriggerDefinition} and {@link TriggerProperty}es. * - * @param cronScheduling The CRON scheduling. + * @param cronScheduling + * The CRON scheduling. * @since 1.0.0 * @deprecated since 1.1.0 */ @Deprecated - void setCronScheduling(String cronScheduling); + public void setCronScheduling(String cronScheduling) { + this.cronScheduling = cronScheduling; + } /** * Gets the retry interval. @@ -106,19 +143,24 @@ public interface TriggerCreator extends KapuaNamedEntityCreator { * @deprecated since 1.1.0 */ @Deprecated - Long getRetryInterval(); + public Long getRetryInterval() { + return retryInterval; + } /** * Sets the retry interval. *

    * This field is {@code deprecated}. Please make use of {@link org.eclipse.kapua.service.scheduler.trigger.definition.TriggerDefinition} and {@link TriggerProperty}es. * - * @param retryInterval The retry interval. + * @param retryInterval + * The retry interval. * @since 1.0.0 * @deprecated since 1.1.0 */ @Deprecated - void setRetryInterval(Long retryInterval); + public void setRetryInterval(Long retryInterval) { + this.retryInterval = retryInterval; + } /** * Gets the {@link org.eclipse.kapua.service.scheduler.trigger.definition.TriggerDefinition} {@link KapuaId} which this {@link TriggerCreator} refers to. @@ -127,15 +169,20 @@ public interface TriggerCreator extends KapuaNamedEntityCreator { * @since 1.1.0 */ @XmlJavaTypeAdapter(KapuaIdAdapter.class) - KapuaId getTriggerDefinitionId(); + public KapuaId getTriggerDefinitionId() { + return triggerDefinitionId; + } /** * Sets the {@link org.eclipse.kapua.service.scheduler.trigger.definition.TriggerDefinition} {@link KapuaId} which this {@link TriggerCreator} refers to. * - * @param triggerDefinitionId The {@link org.eclipse.kapua.service.scheduler.trigger.definition.TriggerDefinition} {@link KapuaId} which this {@link TriggerCreator} refers to. + * @param triggerDefinitionId + * The {@link org.eclipse.kapua.service.scheduler.trigger.definition.TriggerDefinition} {@link KapuaId} which this {@link TriggerCreator} refers to. * @since 1.1.0 */ - void setTriggerDefinitionId(KapuaId triggerDefinitionId); + public void setTriggerDefinitionId(KapuaId triggerDefinitionId) { + this.triggerDefinitionId = triggerDefinitionId; + } /** * Gets the {@link List} of {@link TriggerProperty}es associated with this {@link TriggerCreator} @@ -143,22 +190,35 @@ public interface TriggerCreator extends KapuaNamedEntityCreator { * @return The {@link List} of {@link TriggerProperty}es associated with this {@link TriggerCreator} * @since 1.0.0 */ - List getTriggerProperties(); + public List getTriggerProperties() { + if (triggerProperties == null) { + triggerProperties = new ArrayList<>(); + } + + return triggerProperties; + } /** * Gets the {@link TriggerProperty} by the name. * - * @param name The {@link TriggerProperty#getName()} to look for. + * @param name + * The {@link TriggerProperty#getName()} to look for. * @return The found {@link TriggerProperty} or {@code null}. * @since 1.5.0 */ - TriggerProperty getTriggerProperty(String name); + public TriggerProperty getTriggerProperty(String name) { + return getTriggerProperties().stream().filter(tp -> tp.getName().equals(name)).findAny().orElse(null); + } /** * Sets the {@link List} of {@link TriggerProperty}es associated with this {@link TriggerCreator} * - * @param triggerProperties The {@link List} of {@link TriggerProperty}es associated with this {@link TriggerCreator} + * @param triggerProperties + * The {@link List} of {@link TriggerProperty}es associated with this {@link TriggerCreator} * @since 1.0.0 */ - void setTriggerProperties(List triggerProperties); + public void setTriggerProperties(List triggerProperties) { + this.triggerProperties = triggerProperties; + } + } diff --git a/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/TriggerFactory.java b/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/TriggerFactory.java index f02c3784664..ff843fa3eaf 100644 --- a/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/TriggerFactory.java +++ b/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/TriggerFactory.java @@ -21,7 +21,7 @@ * @see KapuaEntityFactory * @since 1.0.0 */ -public interface TriggerFactory extends KapuaEntityFactory { +public interface TriggerFactory extends KapuaEntityFactory { /** * Instantiates a new {@link TriggerProperty} diff --git a/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/TriggerXmlRegistry.java b/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/TriggerXmlRegistry.java index 7bd5dadb886..fac935b3976 100644 --- a/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/TriggerXmlRegistry.java +++ b/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/TriggerXmlRegistry.java @@ -31,10 +31,6 @@ public Trigger newEntity() { return triggerFactory.newEntity(null); } - public TriggerCreator newCreator() { - return triggerFactory.newCreator(null); - } - public TriggerProperty newTriggerProperty() { return triggerFactory.newTriggerProperty(null, null, null); } diff --git a/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/definition/TriggerDefinitionCreator.java b/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/definition/TriggerDefinitionCreator.java index 0302d732674..488721ba076 100644 --- a/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/definition/TriggerDefinitionCreator.java +++ b/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/definition/TriggerDefinitionCreator.java @@ -12,13 +12,16 @@ *******************************************************************************/ package org.eclipse.kapua.service.scheduler.trigger.definition; -import org.eclipse.kapua.model.KapuaNamedEntityCreator; +import java.util.ArrayList; +import java.util.List; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; -import java.util.List; + +import org.eclipse.kapua.model.KapuaNamedEntityCreator; +import org.eclipse.kapua.model.id.KapuaId; /** * {@link TriggerDefinition} {@link org.eclipse.kapua.model.KapuaEntityCreator} definition. @@ -27,8 +30,25 @@ */ @XmlRootElement(name = "triggerDefinitionCreator") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = TriggerDefinitionXmlRegistry.class, factoryMethod = "newCreator") -public interface TriggerDefinitionCreator extends KapuaNamedEntityCreator { +@XmlType +public class TriggerDefinitionCreator extends KapuaNamedEntityCreator { + + private static final long serialVersionUID = 4602067255120049746L; + + private TriggerType triggerType; + private String processorName; + private List triggerProperties; + + public TriggerDefinitionCreator() { + } + + public TriggerDefinitionCreator(KapuaId scopeId) { + super(scopeId); + } + + public TriggerDefinitionCreator(KapuaId scopeId, String name) { + super(scopeId, name); + } /** * Gets the {@link TriggerType}. @@ -36,15 +56,20 @@ public interface TriggerDefinitionCreator extends KapuaNamedEntityCreator getTriggerProperties(); + public List getTriggerProperties() { + if (triggerProperties == null) { + triggerProperties = new ArrayList<>(); + } + + return triggerProperties; + } /** * Gets the {@link TriggerProperty} by the name. * - * @param name The {@link TriggerProperty#getName()} to look for. + * @param name + * The {@link TriggerProperty#getName()} to look for. * @return The found {@link TriggerProperty} or {@code null}. * @since 1.5.0 */ - TriggerProperty getTriggerProperty(String name); + public TriggerProperty getTriggerProperty(String name) { + return getTriggerProperties().stream().filter(tp -> tp.getName().equals(name)).findAny().orElse(null); + } /** * Sets the {@link TriggerProperty}s. * - * @param triggerProperties The {@link TriggerProperty}s. + * @param triggerProperties + * The {@link TriggerProperty}s. * @since 1.1.0 */ - void setTriggerProperties(List triggerProperties); + public void setTriggerProperties(List triggerProperties) { + this.triggerProperties = triggerProperties; + } } diff --git a/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/definition/TriggerDefinitionFactory.java b/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/definition/TriggerDefinitionFactory.java index 0cb033c3389..008d7b4d29b 100644 --- a/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/definition/TriggerDefinitionFactory.java +++ b/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/definition/TriggerDefinitionFactory.java @@ -20,7 +20,7 @@ * @see KapuaEntityFactory * @since 1.1.0 */ -public interface TriggerDefinitionFactory extends KapuaEntityFactory { +public interface TriggerDefinitionFactory extends KapuaEntityFactory { /** * Instantiates a new {@link TriggerProperty}. diff --git a/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/definition/TriggerDefinitionXmlRegistry.java b/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/definition/TriggerDefinitionXmlRegistry.java index d231589c09c..c363543b701 100644 --- a/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/definition/TriggerDefinitionXmlRegistry.java +++ b/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/definition/TriggerDefinitionXmlRegistry.java @@ -30,8 +30,4 @@ public TriggerDefinition newEntity() { return triggerDefinitionFactory.newEntity(null); } - public TriggerDefinitionCreator newCreator() { - return triggerDefinitionFactory.newCreator(null); - } - } diff --git a/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/fired/FiredTriggerCreator.java b/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/fired/FiredTriggerCreator.java index 56a707972fe..1a1d902d165 100644 --- a/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/fired/FiredTriggerCreator.java +++ b/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/fired/FiredTriggerCreator.java @@ -12,10 +12,7 @@ *******************************************************************************/ package org.eclipse.kapua.service.scheduler.trigger.fired; -import org.eclipse.kapua.model.KapuaEntityCreator; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.model.id.KapuaIdAdapter; -import org.eclipse.kapua.service.scheduler.trigger.Trigger; +import java.util.Date; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; @@ -23,7 +20,11 @@ import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; -import java.util.Date; + +import org.eclipse.kapua.model.KapuaEntityCreator; +import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.model.id.KapuaIdAdapter; +import org.eclipse.kapua.service.scheduler.trigger.Trigger; /** * {@link FiredTrigger} {@link org.eclipse.kapua.model.KapuaEntityCreator} definition. @@ -32,8 +33,24 @@ */ @XmlRootElement(name = "firedTriggerCreator") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = FiredTriggerXmlRegistry.class, factoryMethod = "newCreator") -public interface FiredTriggerCreator extends KapuaEntityCreator { +@XmlType +public class FiredTriggerCreator extends KapuaEntityCreator { + + private KapuaId triggerId; + private Date firedOn; + private FiredTriggerStatus status; + private String message; + + public FiredTriggerCreator() { + } + + public FiredTriggerCreator(KapuaId scopeId) { + super(scopeId); + } + + public FiredTriggerCreator(KapuaEntityCreator entityCreator) { + super(entityCreator); + } /** * Gets the {@link Trigger#getId()} @@ -43,15 +60,20 @@ public interface FiredTriggerCreator extends KapuaEntityCreator { */ @XmlElement(name = "triggerId") @XmlJavaTypeAdapter(KapuaIdAdapter.class) - KapuaId getTriggerId(); + public KapuaId getTriggerId() { + return triggerId; + } /** * Sets the {@link Trigger#getId()}. * - * @param triggerId The {@link Trigger#getId()}. + * @param triggerId + * The {@link Trigger#getId()}. * @since 1.5.0 */ - void setTriggerId(KapuaId triggerId); + public void setTriggerId(KapuaId triggerId) { + this.triggerId = triggerId; + } /** * Gets the actual fire {@link Date}. @@ -60,15 +82,20 @@ public interface FiredTriggerCreator extends KapuaEntityCreator { * @since 1.5.0 */ @XmlElement(name = "firedOn") - Date getFiredOn(); + public Date getFiredOn() { + return firedOn; + } /** * Sets the actual fire {@link Date}. * - * @param firedOn The actual fire {@link Date}. + * @param firedOn + * The actual fire {@link Date}. * @since 1.5.0 */ - void setFiredOn(Date firedOn); + public void setFiredOn(Date firedOn) { + this.firedOn = firedOn; + } /** * Gets the {@link FiredTriggerStatus} of the processing. @@ -77,15 +104,20 @@ public interface FiredTriggerCreator extends KapuaEntityCreator { * @since 1.5.0 */ @XmlElement(name = "status") - FiredTriggerStatus getStatus(); + public FiredTriggerStatus getStatus() { + return status; + } /** * Sets the {@link FiredTriggerStatus} of the processing. * - * @param status The {@link FiredTriggerStatus} of the processing. + * @param status + * The {@link FiredTriggerStatus} of the processing. * @since 1.5.0 */ - void setStatus(FiredTriggerStatus status); + public void setStatus(FiredTriggerStatus status) { + this.status = status; + } /** * Gets the {@link Exception#getMessage()} if there are errors in the processing. @@ -94,13 +126,19 @@ public interface FiredTriggerCreator extends KapuaEntityCreator { * @since 1.5.0 */ @XmlElement(name = "message") - String getMessage(); + public String getMessage() { + return message; + } /** * Sets the {@link Exception#getMessage()} if there are errors in the processing. * - * @param message The {@link Exception#getMessage()} if there are errors in the processing. + * @param message + * The {@link Exception#getMessage()} if there are errors in the processing. * @since 1.5.0 */ - void setMessage(String message); + public void setMessage(String message) { + this.message = message; + } + } diff --git a/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/fired/FiredTriggerFactory.java b/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/fired/FiredTriggerFactory.java index 3bf723e5376..526d3c5f344 100644 --- a/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/fired/FiredTriggerFactory.java +++ b/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/fired/FiredTriggerFactory.java @@ -20,6 +20,6 @@ * @see KapuaEntityFactory * @since 1.5.0 */ -public interface FiredTriggerFactory extends KapuaEntityFactory { +public interface FiredTriggerFactory extends KapuaEntityFactory { } diff --git a/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/fired/FiredTriggerXmlRegistry.java b/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/fired/FiredTriggerXmlRegistry.java index f6ca0a0dc99..97b1750cf34 100644 --- a/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/fired/FiredTriggerXmlRegistry.java +++ b/service/scheduler/api/src/main/java/org/eclipse/kapua/service/scheduler/trigger/fired/FiredTriggerXmlRegistry.java @@ -30,8 +30,4 @@ public FiredTrigger newEntity() { return firedTriggerFactory.newEntity(null); } - public FiredTriggerCreator newCreator() { - return firedTriggerFactory.newCreator(null); - } - } diff --git a/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/quartz/job/KapuaJobLauncher.java b/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/quartz/job/KapuaJobLauncher.java index ff2ae6d1f96..67ccad48332 100644 --- a/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/quartz/job/KapuaJobLauncher.java +++ b/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/quartz/job/KapuaJobLauncher.java @@ -12,6 +12,11 @@ *******************************************************************************/ package org.eclipse.kapua.service.scheduler.quartz.job; +import java.util.Date; + +import javax.validation.constraints.NotNull; + +import org.checkerframework.checker.nullness.qual.Nullable; import org.eclipse.kapua.KapuaEntityNotFoundException; import org.eclipse.kapua.commons.security.KapuaSecurityUtils; import org.eclipse.kapua.job.engine.JobEngineService; @@ -26,25 +31,19 @@ import org.eclipse.kapua.service.scheduler.trigger.fired.FiredTriggerFactory; import org.eclipse.kapua.service.scheduler.trigger.fired.FiredTriggerService; import org.eclipse.kapua.service.scheduler.trigger.fired.FiredTriggerStatus; - -import org.checkerframework.checker.nullness.qual.Nullable; import org.quartz.Job; import org.quartz.JobExecutionContext; import org.quartz.JobExecutionException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.validation.constraints.NotNull; -import java.util.Date; - /** * Ths is the {@link Job} that triggers the {@link JobEngineService#startJob(KapuaId, KapuaId)}. *

    - * In case of successful start it creates a {@link FiredTrigger} to track that {@link JobEngineService#startJob(KapuaId, KapuaId)} - * was successful + * In case of successful start it creates a {@link FiredTrigger} to track that {@link JobEngineService#startJob(KapuaId, KapuaId)} was successful *

    - * In case of {@link Exception} from {@link JobEngineService#startJob(KapuaId, KapuaId)} it saves the {@link Exception#getMessage()} - * into the {@link FiredTrigger#getMessage()} to let the user be able to solve the issue. + * In case of {@link Exception} from {@link JobEngineService#startJob(KapuaId, KapuaId)} it saves the {@link Exception#getMessage()} into the {@link FiredTrigger#getMessage()} to let the user be able + * to solve the issue. * * @since 1.0.0 */ @@ -123,7 +122,8 @@ public KapuaId getScopeId() { /** * Sets the {@link org.eclipse.kapua.service.job.Job#getScopeId()}. * - * @param scopeId The {@link org.eclipse.kapua.service.job.Job#getScopeId()}. + * @param scopeId + * The {@link org.eclipse.kapua.service.job.Job#getScopeId()}. * @since 1.0.0 */ public void setScopeId(KapuaId scopeId) { @@ -143,7 +143,8 @@ public KapuaId getJobId() { /** * Sets the {@link org.eclipse.kapua.service.job.Job#getId()}. * - * @param jobId The {@link org.eclipse.kapua.service.job.Job#getId()}. + * @param jobId + * The {@link org.eclipse.kapua.service.job.Job#getId()}. * @since 1.0.0 */ public void setJobId(KapuaId jobId) { @@ -163,7 +164,8 @@ public JobStartOptions getJobStartOptions() { /** * Sets the {@link org.eclipse.kapua.service.job.Job}'s {@link JobStartOptions}. * - * @param jobStartOptions The {@link org.eclipse.kapua.service.job.Job}'s {@link JobStartOptions}. + * @param jobStartOptions + * The {@link org.eclipse.kapua.service.job.Job}'s {@link JobStartOptions}. * @since 1.0.0 */ public void setJobStartOptions(JobStartOptions jobStartOptions) { @@ -173,9 +175,12 @@ public void setJobStartOptions(JobStartOptions jobStartOptions) { /** * Creates a {@link FiredTrigger} with {@link FiredTriggerStatus#FIRED}. * - * @param scopeId The {@link Trigger#getScopeId()}. - * @param triggerId The {@link Trigger#getId()}. - * @param fireTime The actual {@link Trigger} fire time. Sourced from {@link JobExecutionContext#getFireTime()}. + * @param scopeId + * The {@link Trigger#getScopeId()}. + * @param triggerId + * The {@link Trigger#getId()}. + * @param fireTime + * The actual {@link Trigger} fire time. Sourced from {@link JobExecutionContext#getFireTime()}. * @since 1.5.0 */ public void createSuccessfulFiredTrigger(@NotNull KapuaId scopeId, @NotNull KapuaId triggerId, @NotNull Date fireTime) { @@ -185,10 +190,14 @@ public void createSuccessfulFiredTrigger(@NotNull KapuaId scopeId, @NotNull Kapu /** * Creates a {@link FiredTrigger} with {@link FiredTriggerStatus#FAILED}. * - * @param scopeId The {@link Trigger#getScopeId()}. - * @param triggerId The {@link Trigger#getId()}. - * @param fireTime The actual {@link Trigger} fire time. Sourced from {@link JobExecutionContext#getFireTime()}. - * @param exception The {@link Exception} occurred while processing. + * @param scopeId + * The {@link Trigger#getScopeId()}. + * @param triggerId + * The {@link Trigger#getId()}. + * @param fireTime + * The actual {@link Trigger} fire time. Sourced from {@link JobExecutionContext#getFireTime()}. + * @param exception + * The {@link Exception} occurred while processing. * @since 1.5.0 */ public void createdUnsuccessfulFiredTrigger(@NotNull KapuaId scopeId, @NotNull KapuaId triggerId, @NotNull Date fireTime, @NotNull Exception exception) { @@ -198,16 +207,21 @@ public void createdUnsuccessfulFiredTrigger(@NotNull KapuaId scopeId, @NotNull K /** * Creates a {@link FiredTrigger} with the given parameters. * - * @param scopeId The {@link Trigger#getScopeId()}. - * @param triggerId The {@link Trigger#getId()}. - * @param fireTime The actual {@link Trigger} fire time. Sourced from {@link JobExecutionContext#getFireTime()}. - * @param status The {@link FiredTriggerStatus} of the processing. - * @param exception The {@link Exception} occurred while processing, if any. + * @param scopeId + * The {@link Trigger#getScopeId()}. + * @param triggerId + * The {@link Trigger#getId()}. + * @param fireTime + * The actual {@link Trigger} fire time. Sourced from {@link JobExecutionContext#getFireTime()}. + * @param status + * The {@link FiredTriggerStatus} of the processing. + * @param exception + * The {@link Exception} occurred while processing, if any. * @since 1.5.0 */ public void createFiredTrigger(@NotNull KapuaId scopeId, @NotNull KapuaId triggerId, @NotNull Date fireTime, @NotNull FiredTriggerStatus status, @Nullable Exception exception) { try { - FiredTriggerCreator firedTriggerCreator = firedTriggerFactory.newCreator(scopeId); + FiredTriggerCreator firedTriggerCreator = new FiredTriggerCreator(scopeId); firedTriggerCreator.setTriggerId(triggerId); firedTriggerCreator.setFiredOn(fireTime); firedTriggerCreator.setStatus(status); diff --git a/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/definition/quartz/TriggerDefinitionCreatorImpl.java b/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/definition/quartz/TriggerDefinitionCreatorImpl.java deleted file mode 100644 index 65a9fa2bc2f..00000000000 --- a/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/definition/quartz/TriggerDefinitionCreatorImpl.java +++ /dev/null @@ -1,87 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2019, 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.service.scheduler.trigger.definition.quartz; - -import org.eclipse.kapua.commons.model.AbstractKapuaNamedEntityCreator; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.service.scheduler.trigger.definition.TriggerDefinition; -import org.eclipse.kapua.service.scheduler.trigger.definition.TriggerDefinitionCreator; -import org.eclipse.kapua.service.scheduler.trigger.definition.TriggerProperty; -import org.eclipse.kapua.service.scheduler.trigger.definition.TriggerType; - -import java.util.ArrayList; -import java.util.List; - -/** - * {@link TriggerDefinitionCreator} implementation. - * - * @since 1.1.0 - */ -public class TriggerDefinitionCreatorImpl extends AbstractKapuaNamedEntityCreator implements TriggerDefinitionCreator { - - private static final long serialVersionUID = 4602067255120049746L; - - private TriggerType triggerType; - private String processorName; - private List triggerProperties; - - /** - * Constructor. - * - * @param scopeId The scope {@link KapuaId} for the Trigger. - * @since 1.1.0 - */ - public TriggerDefinitionCreatorImpl(KapuaId scopeId) { - super(scopeId); - } - - @Override - public TriggerType getTriggerType() { - return triggerType; - } - - @Override - public void setTriggerType(TriggerType triggerType) { - this.triggerType = triggerType; - } - - @Override - public String getProcessorName() { - return processorName; - } - - @Override - public void setProcessorName(String processorName) { - this.processorName = processorName; - } - - @Override - public List getTriggerProperties() { - if (triggerProperties == null) { - triggerProperties = new ArrayList<>(); - } - - return triggerProperties; - } - - @Override - public TriggerProperty getTriggerProperty(String name) { - return getTriggerProperties().stream().filter(tp -> tp.getName().equals(name)).findAny().orElse(null); - } - - @Override - public void setTriggerProperties(List triggerProperties) { - this.triggerProperties = triggerProperties; - } - -} diff --git a/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/definition/quartz/TriggerDefinitionFactoryImpl.java b/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/definition/quartz/TriggerDefinitionFactoryImpl.java index 85a3c027b4d..5559e0d8380 100644 --- a/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/definition/quartz/TriggerDefinitionFactoryImpl.java +++ b/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/definition/quartz/TriggerDefinitionFactoryImpl.java @@ -17,7 +17,6 @@ import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.scheduler.trigger.definition.TriggerDefinition; -import org.eclipse.kapua.service.scheduler.trigger.definition.TriggerDefinitionCreator; import org.eclipse.kapua.service.scheduler.trigger.definition.TriggerDefinitionFactory; import org.eclipse.kapua.service.scheduler.trigger.definition.TriggerProperty; @@ -34,11 +33,6 @@ public TriggerDefinition newEntity(KapuaId scopeId) { return new TriggerDefinitionImpl(scopeId); } - @Override - public TriggerDefinitionCreator newCreator(KapuaId scopeId) { - return new TriggerDefinitionCreatorImpl(scopeId); - } - @Override public TriggerProperty newTriggerProperty(String name, String type, String value) { return new TriggerPropertyImpl(name, type, value); diff --git a/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/fired/quartz/FiredTriggerCreatorImpl.java b/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/fired/quartz/FiredTriggerCreatorImpl.java deleted file mode 100644 index 7a2970bd570..00000000000 --- a/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/fired/quartz/FiredTriggerCreatorImpl.java +++ /dev/null @@ -1,84 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2021, 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.service.scheduler.trigger.fired.quartz; - -import org.eclipse.kapua.commons.model.AbstractKapuaEntityCreator; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.service.scheduler.trigger.fired.FiredTrigger; -import org.eclipse.kapua.service.scheduler.trigger.fired.FiredTriggerCreator; -import org.eclipse.kapua.service.scheduler.trigger.fired.FiredTriggerStatus; - -import java.util.Date; - -/** - * {@link FiredTriggerCreator} implementation. - * - * @since 1.5.0 - */ -public class FiredTriggerCreatorImpl extends AbstractKapuaEntityCreator implements FiredTriggerCreator { - - private KapuaId triggerId; - private Date firedOn; - private FiredTriggerStatus status; - private String message; - - /** - * Constructor. - * - * @param scopeId The scope {@link KapuaId}. - * @since 1.5.0 - */ - public FiredTriggerCreatorImpl(KapuaId scopeId) { - super(scopeId); - } - - @Override - public KapuaId getTriggerId() { - return triggerId; - } - - @Override - public void setTriggerId(KapuaId triggerId) { - this.triggerId = triggerId; - } - - @Override - public Date getFiredOn() { - return firedOn; - } - - @Override - public void setFiredOn(Date firedOn) { - this.firedOn = firedOn; - } - - @Override - public FiredTriggerStatus getStatus() { - return status; - } - - @Override - public void setStatus(FiredTriggerStatus status) { - this.status = status; - } - - @Override - public String getMessage() { - return message; - } - - @Override - public void setMessage(String message) { - this.message = message; - } -} diff --git a/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/fired/quartz/FiredTriggerFactoryImpl.java b/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/fired/quartz/FiredTriggerFactoryImpl.java index bba556f7007..d373879920b 100644 --- a/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/fired/quartz/FiredTriggerFactoryImpl.java +++ b/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/fired/quartz/FiredTriggerFactoryImpl.java @@ -17,7 +17,6 @@ import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.scheduler.trigger.fired.FiredTrigger; -import org.eclipse.kapua.service.scheduler.trigger.fired.FiredTriggerCreator; import org.eclipse.kapua.service.scheduler.trigger.fired.FiredTriggerFactory; /** @@ -33,11 +32,6 @@ public FiredTrigger newEntity(KapuaId scopeId) { return new FiredTriggerImpl(scopeId); } - @Override - public FiredTriggerCreator newCreator(KapuaId scopeId) { - return new FiredTriggerCreatorImpl(scopeId); - } - @Override public FiredTrigger clone(FiredTrigger firedTrigger) { try { diff --git a/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/quartz/TriggerCreatorImpl.java b/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/quartz/TriggerCreatorImpl.java deleted file mode 100644 index 3b04c026011..00000000000 --- a/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/quartz/TriggerCreatorImpl.java +++ /dev/null @@ -1,121 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017, 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.service.scheduler.trigger.quartz; - -import org.eclipse.kapua.commons.model.AbstractKapuaNamedEntityCreator; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.service.scheduler.trigger.Trigger; -import org.eclipse.kapua.service.scheduler.trigger.TriggerCreator; -import org.eclipse.kapua.service.scheduler.trigger.definition.TriggerProperty; - -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -/** - * {@link TriggerCreator} implementation. - * - * @since 1.0.0 - */ -public class TriggerCreatorImpl extends AbstractKapuaNamedEntityCreator implements TriggerCreator { - - private static final long serialVersionUID = -2460883485294616032L; - - private Date startsOn; - private Date endsOn; - private String cronScheduling; - private Long retryInterval; - private KapuaId triggerDefinitionId; - private List triggerProperties; - - /** - * Constructor. - * - * @param scopeId The scope {@link KapuaId}. - * @param name The name. - * @since 1.0.0 - */ - public TriggerCreatorImpl(KapuaId scopeId, String name) { - super(scopeId, name); - } - - @Override - public Date getStartsOn() { - return startsOn; - } - - @Override - public void setStartsOn(Date startsOn) { - this.startsOn = startsOn; - } - - @Override - public Date getEndsOn() { - return endsOn; - } - - @Override - public void setEndsOn(Date endsOn) { - this.endsOn = endsOn; - } - - @Override - public String getCronScheduling() { - return cronScheduling; - } - - @Override - public void setCronScheduling(String cronScheduling) { - this.cronScheduling = cronScheduling; - } - - @Override - public Long getRetryInterval() { - return retryInterval; - } - - @Override - public void setRetryInterval(Long retryInterval) { - this.retryInterval = retryInterval; - } - - @Override - public KapuaId getTriggerDefinitionId() { - return triggerDefinitionId; - } - - @Override - public void setTriggerDefinitionId(KapuaId triggerDefinitionId) { - this.triggerDefinitionId = triggerDefinitionId; - } - - @Override - public List getTriggerProperties() { - if (triggerProperties == null) { - triggerProperties = new ArrayList<>(); - } - - return triggerProperties; - } - - @Override - public TriggerProperty getTriggerProperty(String name) { - return getTriggerProperties().stream().filter(tp -> tp.getName().equals(name)).findAny().orElse(null); - } - - @Override - public void setTriggerProperties(List triggerProperties) { - this.triggerProperties = triggerProperties; - } - -} diff --git a/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/quartz/TriggerFactoryImpl.java b/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/quartz/TriggerFactoryImpl.java index 83b9bb4f03e..b095607a903 100644 --- a/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/quartz/TriggerFactoryImpl.java +++ b/service/scheduler/quartz/src/main/java/org/eclipse/kapua/service/scheduler/trigger/quartz/TriggerFactoryImpl.java @@ -17,7 +17,6 @@ import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.scheduler.trigger.Trigger; -import org.eclipse.kapua.service.scheduler.trigger.TriggerCreator; import org.eclipse.kapua.service.scheduler.trigger.TriggerFactory; import org.eclipse.kapua.service.scheduler.trigger.definition.TriggerProperty; import org.eclipse.kapua.service.scheduler.trigger.definition.quartz.TriggerPropertyImpl; @@ -30,11 +29,6 @@ @Singleton public class TriggerFactoryImpl implements TriggerFactory { - @Override - public TriggerCreator newCreator(KapuaId scopeId) { - return new TriggerCreatorImpl(scopeId, null); - } - @Override public Trigger newEntity(KapuaId scopeId) { return new TriggerImpl(scopeId); diff --git a/service/scheduler/test-steps/src/main/java/org/eclipse/kapua/service/scheduler/steps/JobScheduleServiceSteps.java b/service/scheduler/test-steps/src/main/java/org/eclipse/kapua/service/scheduler/steps/JobScheduleServiceSteps.java index 542d6d7e833..91984822dff 100644 --- a/service/scheduler/test-steps/src/main/java/org/eclipse/kapua/service/scheduler/steps/JobScheduleServiceSteps.java +++ b/service/scheduler/test-steps/src/main/java/org/eclipse/kapua/service/scheduler/steps/JobScheduleServiceSteps.java @@ -113,7 +113,7 @@ public void beforeScenarioDockerFull(Scenario scenario) { @And("I try to create scheduler with name {string}") public void iTryToCreateSchedulerWithName(String schedulerName) throws Exception { - TriggerCreator triggerCreator = triggerFactory.newCreator(getCurrentScopeId()); + TriggerCreator triggerCreator = new TriggerCreator(getCurrentScopeId()); KapuaId triggerDefinitionId = (KapuaId) stepData.get(TRIGGER_DEFINITION_ID); triggerCreator.setName(schedulerName); triggerCreator.setDescription("A trigger description"); @@ -146,7 +146,7 @@ public void iFindTriggerPropertiesWithName(String triggerDefinitionName) throws @And("A regular trigger creator with the name {string} is created") public void aRegularTriggerCreatorWithTheName(String triggerName) { - TriggerCreator triggerCreator = triggerFactory.newCreator(getCurrentScopeId()); + TriggerCreator triggerCreator = new TriggerCreator(getCurrentScopeId()); KapuaId currentTriggerDefId = (KapuaId) stepData.get(TRIGGER_DEFINITION_ID); KapuaId jobId = (KapuaId) stepData.get("CurrentJobId"); triggerCreator.setName(triggerName); @@ -160,7 +160,7 @@ public void aRegularTriggerCreatorWithTheName(String triggerName) { @And("A trigger creator without a name") public void aTriggerCreatorWithoutAName() { - TriggerCreator triggerCreator = triggerFactory.newCreator(getCurrentScopeId()); + TriggerCreator triggerCreator = new TriggerCreator(getCurrentScopeId()); KapuaId currentTriggerDefId = (KapuaId) stepData.get(TRIGGER_DEFINITION_ID); triggerCreator.setTriggerDefinitionId(currentTriggerDefId); triggerCreator.setName(null); @@ -169,7 +169,7 @@ public void aTriggerCreatorWithoutAName() { @And("A regular trigger creator with the name {string} and following properties") public void aRegularTriggerCreatorWithTheNameAndFollowingProperties(String triggerName, List list) { - TriggerCreator triggerCreator = triggerFactory.newCreator(getCurrentScopeId()); + TriggerCreator triggerCreator = new TriggerCreator(getCurrentScopeId()); KapuaId currentTriggerDefId = (KapuaId) stepData.get(TRIGGER_DEFINITION_ID); triggerCreator.setName(triggerName); triggerCreator.setDescription("A trigger description"); diff --git a/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/credential/CredentialCreator.java b/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/credential/CredentialCreator.java index 9221fade50b..2a5b190c58c 100644 --- a/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/credential/CredentialCreator.java +++ b/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/credential/CredentialCreator.java @@ -12,11 +12,7 @@ *******************************************************************************/ package org.eclipse.kapua.service.authentication.credential; -import org.eclipse.kapua.model.KapuaEntityCreator; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.model.id.KapuaIdAdapter; -import org.eclipse.kapua.model.xml.DateXmlAdapter; -import org.eclipse.kapua.service.user.User; +import java.util.Date; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; @@ -24,7 +20,12 @@ import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; -import java.util.Date; + +import org.eclipse.kapua.model.KapuaEntityCreator; +import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.model.id.KapuaIdAdapter; +import org.eclipse.kapua.model.xml.DateXmlAdapter; +import org.eclipse.kapua.service.user.User; /** * {@link Credential} {@link KapuaEntityCreator} @@ -33,8 +34,59 @@ */ @XmlRootElement(name = "credentialCreator") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = CredentialXmlRegistry.class, factoryMethod = "newCredentialCreator") -public interface CredentialCreator extends KapuaEntityCreator { +@XmlType +public class CredentialCreator extends KapuaEntityCreator { + + private static final long serialVersionUID = -5020680413729882095L; + + private KapuaId userId; + private String credentialType; + private String credentialKey; + private Date expirationDate; + private CredentialStatus credentialStatus; + + public CredentialCreator() { + } + + public CredentialCreator(KapuaId scopeId) { + super(scopeId); + } + + public CredentialCreator(KapuaEntityCreator entityCreator) { + super(entityCreator); + } + + /** + * Constructor. + * + * @param scopeId + * The {@link CredentialCreator#getScopeId()} + * @param userId + * The {@link CredentialCreator#getUserId()} + * @param credentialType + * The {@link CredentialCreator#getCredentialType()} + * @param credentialKey + * The plain {@link CredentialCreator#getCredentialPlainKey()} + * @param credentialStatus + * The {@link CredentialCreator#getCredentialStatus()} + * @param expirationDate + * The {@link CredentialCreator#getExpirationDate()} + * @since 1.0.0 + */ + public CredentialCreator(KapuaId scopeId, + KapuaId userId, + String credentialType, + String credentialKey, + CredentialStatus credentialStatus, + Date expirationDate) { + super(scopeId); + + this.userId = userId; + this.credentialType = credentialType; + this.credentialKey = credentialKey; + this.credentialStatus = credentialStatus; + this.expirationDate = expirationDate; + } /** * Gets the {@link User#getId()} owner of the {@link Credential} @@ -44,15 +96,20 @@ public interface CredentialCreator extends KapuaEntityCreator { */ @XmlElement(name = "userId") @XmlJavaTypeAdapter(KapuaIdAdapter.class) - KapuaId getUserId(); + public KapuaId getUserId() { + return userId; + } /** * Sets the {@link User#getId()} owner of the {@link Credential} * - * @param userId The {@link User#getId()} + * @param userId + * The {@link User#getId()} * @since 1.0.0 */ - void setUserId(KapuaId userId); + public void setUserId(KapuaId userId) { + this.userId = userId; + } /** * Gets the type. @@ -61,15 +118,20 @@ public interface CredentialCreator extends KapuaEntityCreator { * @since 1.0.0 */ @XmlElement(name = "credentialType") - String getCredentialType(); + public String getCredentialType() { + return credentialType; + } /** * Sets the type. * - * @param credentialType The type. + * @param credentialType + * The type. * @since 1.0.0 */ - void setCredentialType(String credentialType); + public void setCredentialType(String credentialType) { + this.credentialType = credentialType; + } /** * Gets the plain secret key @@ -78,15 +140,20 @@ public interface CredentialCreator extends KapuaEntityCreator { * @since 1.0.0 */ @XmlElement(name = "credentialKey") - String getCredentialPlainKey(); + public String getCredentialPlainKey() { + return credentialKey; + } /** * Set the plain secret key * - * @param plainKey The plain secret key + * @param plainKey + * The plain secret key * @since 1.0.0 */ - void setCredentialPlainKey(String plainKey); + public void setCredentialPlainKey(String plainKey) { + this.credentialKey = plainKey; + } /** * Gets the expiration date @@ -96,15 +163,20 @@ public interface CredentialCreator extends KapuaEntityCreator { */ @XmlElement(name = "expirationDate") @XmlJavaTypeAdapter(DateXmlAdapter.class) - Date getExpirationDate(); + public Date getExpirationDate() { + return expirationDate; + } /** * Sets the expiration date * - * @param expirationDate The expiration date + * @param expirationDate + * The expiration date * @since 1.0.0 */ - void setExpirationDate(Date expirationDate); + public void setExpirationDate(Date expirationDate) { + this.expirationDate = expirationDate; + } /** * Gets the {@link CredentialStatus} @@ -113,13 +185,18 @@ public interface CredentialCreator extends KapuaEntityCreator { * @since 1.0.0 */ @XmlElement(name = "credentialStatus") - CredentialStatus getCredentialStatus(); + public CredentialStatus getCredentialStatus() { + return credentialStatus; + } /** * Sets the {@link CredentialStatus} * - * @param credentialStatus The {@link CredentialStatus} + * @param credentialStatus + * The {@link CredentialStatus} * @since 1.0.0 */ - void setCredentialStatus(CredentialStatus credentialStatus); + public void setCredentialStatus(CredentialStatus credentialStatus) { + this.credentialStatus = credentialStatus; + } } diff --git a/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/credential/CredentialFactory.java b/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/credential/CredentialFactory.java index f533c052327..5cfa2a99c73 100644 --- a/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/credential/CredentialFactory.java +++ b/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/credential/CredentialFactory.java @@ -22,7 +22,7 @@ * * @since 1.0.0 */ -public interface CredentialFactory extends KapuaEntityFactory { +public interface CredentialFactory extends KapuaEntityFactory { /** * Instantiates a new {@link Credential}. @@ -44,23 +44,4 @@ public interface CredentialFactory extends KapuaEntityFactory { +@XmlType +public class MfaOptionCreator extends KapuaEntityCreator { + + private static final long serialVersionUID = -4619585500941519330L; + + private KapuaId userId; + + public MfaOptionCreator() { + } + + public MfaOptionCreator(KapuaId scopeId) { + super(scopeId); + } + + public MfaOptionCreator(KapuaEntityCreator entityCreator) { + super(entityCreator); + } + + /** + * Constructor + * + * @param scopeId + * scope identifier + * @param userId + * user identifier + */ + public MfaOptionCreator(KapuaId scopeId, KapuaId userId) { + super(scopeId); + this.userId = userId; + } /** * Gets the {@link User#getId()} @@ -42,13 +70,18 @@ public interface MfaOptionCreator extends KapuaEntityCreator { */ @XmlElement(name = "userId") @XmlJavaTypeAdapter(KapuaIdAdapter.class) - KapuaId getUserId(); + public KapuaId getUserId() { + return userId; + } /** * Sets the {@link User#getId()} * - * @param userId The {@link User#getId()} + * @param userId + * The {@link User#getId()} * @since 1.3.0 */ - void setUserId(KapuaId userId); + public void setUserId(KapuaId userId) { + this.userId = userId; + } } diff --git a/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/MfaOptionFactory.java b/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/MfaOptionFactory.java index db1f4151794..7f8f103d27f 100644 --- a/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/MfaOptionFactory.java +++ b/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/MfaOptionFactory.java @@ -13,8 +13,6 @@ package org.eclipse.kapua.service.authentication.credential.mfa; import org.eclipse.kapua.model.KapuaEntityFactory; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.service.authentication.token.AccessToken; /** * {@link MfaOption} {@link KapuaEntityFactory} definition. @@ -22,18 +20,6 @@ * @see KapuaEntityFactory * @since 1.3.0 */ -public interface MfaOptionFactory extends KapuaEntityFactory { - - /** - * Instantiates a new {@link MfaOptionCreator}. - * - * @param scopeId - * The scope {@link KapuaId} to set into the {@link MfaOptionCreator}. - * @param userId - * The {@link org.eclipse.kapua.service.user.User} {@link KapuaId} to set into the{@link AccessToken}. - * @return The newly instantiated {@link MfaOptionCreator} - * @since 1.3.0 - */ - MfaOptionCreator newCreator(KapuaId scopeId, KapuaId userId); +public interface MfaOptionFactory extends KapuaEntityFactory { } diff --git a/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/MfaOptionXmlRegistry.java b/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/MfaOptionXmlRegistry.java index 9ad503a6534..7988d0991a4 100644 --- a/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/MfaOptionXmlRegistry.java +++ b/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/MfaOptionXmlRegistry.java @@ -21,16 +21,6 @@ public class MfaOptionXmlRegistry { private final MfaOptionFactory mfaOptionFactory = KapuaLocator.getInstance().getFactory(MfaOptionFactory.class); - /** - * Instantiates a new {@link MfaOptionCreator} instance - * - * @return The newly instantiated {@link MfaOptionCreator} - * @since 1.3.0 - */ - public MfaOptionCreator newMfaOptionCreator() { - return mfaOptionFactory.newCreator(null, null); - } - /** * Instantiates a new {@link MfaOption} instance * diff --git a/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/token/AccessTokenCreator.java b/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/token/AccessTokenCreator.java index 91d1703c670..52cb41df8ba 100644 --- a/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/token/AccessTokenCreator.java +++ b/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/token/AccessTokenCreator.java @@ -12,15 +12,16 @@ *******************************************************************************/ package org.eclipse.kapua.service.authentication.token; -import org.eclipse.kapua.model.KapuaEntityCreator; -import org.eclipse.kapua.model.id.KapuaId; +import java.util.Date; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; -import java.util.Date; + +import org.eclipse.kapua.model.KapuaEntityCreator; +import org.eclipse.kapua.model.id.KapuaId; /** * Access token creator service definition @@ -28,35 +29,89 @@ * @since 1.0 */ @XmlRootElement -@XmlAccessorType(XmlAccessType.FIELD) +@XmlAccessorType(XmlAccessType.PROPERTY) @XmlType(propOrder = { "tokenId", "userId", "expiresOn", "refreshToken", "refreshExpiresOn", "tokenIdentifier" -}, // - factoryClass = AccessTokenXmlRegistry.class, // - factoryMethod = "newAccessTokenCreator") -public interface AccessTokenCreator extends KapuaEntityCreator { +}) +public class AccessTokenCreator extends KapuaEntityCreator { + + private static final long serialVersionUID = -27718046815190710L; + + private String tokenId; + private KapuaId userId; + private Date expiresOn; + private String refreshToken; + private Date refreshExpiresOn; + private String tokenIdentifier; + + public AccessTokenCreator() { + } + + public AccessTokenCreator(KapuaId scopeId) { + super(scopeId); + } + + public AccessTokenCreator(KapuaEntityCreator entityCreator) { + super(entityCreator); + } + + /** + * Instantiates a new {@link AccessTokenCreator}. + * + * @param scopeId + * The scope {@link KapuaId} to set into the{@link AccessToken}. + * @param userId + * The {@link org.eclipse.kapua.service.user.User} {@link KapuaId} to set into the{@link AccessToken}. + * @param tokenId + * The token id to set into the{@link AccessToken}. + * @param expiresOn + * The expiration date to set into the{@link AccessToken}. + * @param refreshToken + * The refresh token to set into the{@link AccessToken}. + * @since 1.0.0 + */ + public AccessTokenCreator( + KapuaId scopeId, + KapuaId userId, + String tokenId, + Date expiresOn, + String refreshToken, + Date refreshExpiresOn, + String tokenIdentifier) { + super(scopeId); + this.userId = userId; + this.tokenId = tokenId; + this.expiresOn = expiresOn; + this.refreshToken = refreshToken; + this.refreshExpiresOn = refreshExpiresOn; + this.tokenIdentifier = tokenIdentifier; + } /** - * Gets the token id - * This represents the content of the JWT token + * Gets the token id This represents the content of the JWT token * * @return The token id * @since 1.0 */ @XmlElement(name = "tokenId") - String getTokenId(); + public String getTokenId() { + return tokenId; + } /** * Sets the token id * - * @param tokenId the token id to set + * @param tokenId + * the token id to set * @since 1.0 */ - void setTokenId(String tokenId); + public void setTokenId(String tokenId) { + this.tokenId = tokenId; + } /** * Gets the user id owner of this token @@ -65,15 +120,20 @@ public interface AccessTokenCreator extends KapuaEntityCreator { * @since 1.0 */ @XmlElement(name = "userId") - KapuaId getUserId(); + public KapuaId getUserId() { + return userId; + } /** * Sets the user id owner of this token. * - * @param userId The user id owner of this token. + * @param userId + * The user id owner of this token. * @since 1.0 */ - void setUserId(KapuaId userId); + public void setUserId(KapuaId userId) { + this.userId = userId; + } /** * Gets the expire date of this token. @@ -82,15 +142,20 @@ public interface AccessTokenCreator extends KapuaEntityCreator { * @since 1.0 */ @XmlElement(name = "expiresOn") - Date getExpiresOn(); + public Date getExpiresOn() { + return expiresOn; + } /** * Sets the expire date of this token. * - * @param expiresOn The expire date of this token. + * @param expiresOn + * The expire date of this token. * @since 1.0 */ - void setExpiresOn(Date expiresOn); + public void setExpiresOn(Date expiresOn) { + this.expiresOn = expiresOn; + } /** * Gets the refresh token to obtain a new {@link AccessToken} after expiration. @@ -98,15 +163,20 @@ public interface AccessTokenCreator extends KapuaEntityCreator { * @since 1.0 */ @XmlElement(name = "refreshToken") - String getRefreshToken(); + public String getRefreshToken() { + return refreshToken; + } /** * Sets the refresh token to obtain a new {@link AccessToken} after expiration. * - * @param refreshToken The refresh token + * @param refreshToken + * The refresh token * @since 1.0 */ - void setRefreshToken(String refreshToken); + public void setRefreshToken(String refreshToken) { + this.refreshToken = refreshToken; + } /** * Gets the expiration date of the refresh token. @@ -114,33 +184,41 @@ public interface AccessTokenCreator extends KapuaEntityCreator { * @since 1.0 */ @XmlElement(name = "refreshExpiresOn") - Date getRefreshExpiresOn(); + public Date getRefreshExpiresOn() { + return refreshExpiresOn; + } /** * Sets the expire date of this token. * - * @param refreshExpiresOn The expiration date of the refresh token. + * @param refreshExpiresOn + * The expiration date of the refresh token. * @since 1.0 */ - void setRefreshExpiresOn(Date refreshExpiresOn); + public void setRefreshExpiresOn(Date refreshExpiresOn) { + this.refreshExpiresOn = refreshExpiresOn; + } /** - * Gets the token identifier - * This represents an id for the JWT token and is meant to be inserted inside its payload + * Gets the token identifier This represents an id for the JWT token and is meant to be inserted inside its payload * * @return The token id * @since 2.0 */ @XmlElement(name = "tokenIdentifier") - String getTokenIdentifier(); + public String getTokenIdentifier() { + return tokenIdentifier; + } /** * Sets the token identifier * - * @param tokenId the token id to set + * @param tokenId + * the token id to set * @since 2.0 */ - void setTokenIdentifier(String tokenId); - + public void setTokenIdentifier(String tokenId) { + this.tokenIdentifier = tokenId; + } } diff --git a/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/token/AccessTokenFactory.java b/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/token/AccessTokenFactory.java index cb277276e4b..2882c292fd0 100644 --- a/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/token/AccessTokenFactory.java +++ b/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/token/AccessTokenFactory.java @@ -12,10 +12,7 @@ *******************************************************************************/ package org.eclipse.kapua.service.authentication.token; -import java.util.Date; - import org.eclipse.kapua.model.KapuaEntityFactory; -import org.eclipse.kapua.model.id.KapuaId; /** * {@link AccessTokenFactory} definition. @@ -23,25 +20,7 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface AccessTokenFactory extends KapuaEntityFactory { - - /** - * Instantiates a new {@link AccessTokenCreator}. - * - * @param scopeId - * The scope {@link KapuaId} to set into the{@link AccessToken}. - * @param userId - * The {@link org.eclipse.kapua.service.user.User} {@link KapuaId} to set into the{@link AccessToken}. - * @param tokenId - * The token id to set into the{@link AccessToken}. - * @param expiresOn - * The expiration date to set into the{@link AccessToken}. - * @param refreshToken - * The refresh token to set into the{@link AccessToken}. - * @return The newly instantiated {@link AccessTokenCreator}. - * @since 1.0.0 - */ - AccessTokenCreator newCreator(KapuaId scopeId, KapuaId userId, String tokenId, Date expiresOn, String refreshToken, Date refreshExpiresOn, String tokenIdentifier); +public interface AccessTokenFactory extends KapuaEntityFactory { /** * Instantiates a new {@link LoginInfo} diff --git a/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/token/AccessTokenXmlRegistry.java b/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/token/AccessTokenXmlRegistry.java index 8c313ac1d35..c228c2c92b1 100644 --- a/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/token/AccessTokenXmlRegistry.java +++ b/service/security/authentication/api/src/main/java/org/eclipse/kapua/service/authentication/token/AccessTokenXmlRegistry.java @@ -12,10 +12,10 @@ *******************************************************************************/ package org.eclipse.kapua.service.authentication.token; -import org.eclipse.kapua.locator.KapuaLocator; - import javax.xml.bind.annotation.XmlRegistry; +import org.eclipse.kapua.locator.KapuaLocator; + @XmlRegistry public class AccessTokenXmlRegistry { @@ -24,8 +24,4 @@ public class AccessTokenXmlRegistry { public AccessToken newAccessToken() { return accessTokenFactory.newEntity(null); } - - public AccessTokenCreator newAccessTokenCreator() { - return accessTokenFactory.newCreator(null, null, null, null, null, null, null); - } } diff --git a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessInfoCreator.java b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessInfoCreator.java index 4d6a82081cb..87cf7ec64de 100644 --- a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessInfoCreator.java +++ b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessInfoCreator.java @@ -12,12 +12,9 @@ *******************************************************************************/ package org.eclipse.kapua.service.authorization.access; -import org.eclipse.kapua.model.KapuaEntityCreator; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.model.id.KapuaIdAdapter; -import org.eclipse.kapua.service.authorization.domain.Domain; -import org.eclipse.kapua.service.authorization.permission.Permission; -import org.eclipse.kapua.service.user.User; +import java.security.Permissions; +import java.util.HashSet; +import java.util.Set; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; @@ -26,31 +23,63 @@ import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; -import java.security.Permissions; -import java.util.Set; + +import org.eclipse.kapua.model.KapuaEntityCreator; +import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.model.id.KapuaIdAdapter; +import org.eclipse.kapua.service.authorization.domain.Domain; +import org.eclipse.kapua.service.authorization.permission.Permission; +import org.eclipse.kapua.service.user.User; /** - * {@link AccessInfo} creator definition.
    - * It is used to assign a set of {@link Domain}s and {@link Permission}s to the referenced {@link User}.
    + * {@link AccessInfo} creator definition.
    It is used to assign a set of {@link Domain}s and {@link Permission}s to the referenced {@link User}.
    * * @since 1.0.0 */ @XmlRootElement -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(propOrder = {"userId", +@XmlAccessorType(XmlAccessType.PROPERTY) +@XmlType(propOrder = { "userId", "roleIds", - "permissions"}, - factoryClass = AccessInfoXmlRegistry.class, - factoryMethod = "newAccessInfoCreator") -public interface AccessInfoCreator extends KapuaEntityCreator { + "permissions" }) +public class AccessInfoCreator extends KapuaEntityCreator { + + private static final long serialVersionUID = 972154225756734130L; + + private KapuaId userId; + private Set roleIds; + private Set permissions; + + public AccessInfoCreator() { + } + + /** + * Constructor + * + * @param accessInfo + */ + @SuppressWarnings({ "rawtypes", "unchecked" }) + public AccessInfoCreator(AccessInfoCreator accessInfo) { + super((KapuaEntityCreator) accessInfo); + + setUserId(accessInfo.getUserId()); + setRoleIds(accessInfo.getRoleIds()); + setPermissions(accessInfo.getPermissions()); + } + + public AccessInfoCreator(KapuaId scopeId) { + super(scopeId); + } /** * Sets the user identifier. * - * @param userId The user id to set. + * @param userId + * The user id to set. * @since 1.0.0 */ - void setUserId(KapuaId userId); + public void setUserId(KapuaId userId) { + this.userId = userId; + } /** * Gets the user id. @@ -60,20 +89,23 @@ public interface AccessInfoCreator extends KapuaEntityCreator { */ @XmlElement(name = "userId") @XmlJavaTypeAdapter(KapuaIdAdapter.class) - KapuaId getUserId(); + public KapuaId getUserId() { + return userId; + } /** - * Sets the set of {@link Domain} ids to assign to the {@link AccessInfo} created entity. - * It up to the implementation class to make a clone of the set or use the given set. + * Sets the set of {@link Domain} ids to assign to the {@link AccessInfo} created entity. It up to the implementation class to make a clone of the set or use the given set. * - * @param roleIds The set of {@link Domain} ids. + * @param roleIds + * The set of {@link Domain} ids. * @since 1.0.0 */ - void setRoleIds(Set roleIds); + public void setRoleIds(Set roleIds) { + this.roleIds = roleIds; + } /** - * Gets the set of {@link Domain} ids added to this {@link AccessInfoCreator}. - * The implementation must return the reference of the set and not make a clone. + * Gets the set of {@link Domain} ids added to this {@link AccessInfoCreator}. The implementation must return the reference of the set and not make a clone. * * @return The set of {@link Domain} ids. * @since 1.0.0 @@ -81,26 +113,36 @@ public interface AccessInfoCreator extends KapuaEntityCreator { @XmlElementWrapper(name = "roleIds") @XmlElement(name = "roleId") @XmlJavaTypeAdapter(KapuaIdAdapter.class) - Set getRoleIds(); + public Set getRoleIds() { + if (roleIds == null) { + roleIds = new HashSet<>(); + } + return roleIds; + } /** - * Sets the set of {@link Permissions} to assign to the {@link AccessInfo} created entity. - * It up to the implementation class to make a clone of the set or use the given set. + * Sets the set of {@link Permissions} to assign to the {@link AccessInfo} created entity. It up to the implementation class to make a clone of the set or use the given set. * - * @param permissions The set of {@link Permissions}. + * @param permissions + * The set of {@link Permissions}. * @since 1.0.0 */ - void setPermissions(Set permissions); + public void setPermissions(Set permissions) { + this.permissions = permissions; + } /** - * Gets the set of {@link Permission} added to this {@link AccessInfoCreator}. - * The implementation must return the reference of the set and not make a clone. + * Gets the set of {@link Permission} added to this {@link AccessInfoCreator}. The implementation must return the reference of the set and not make a clone. * * @return The set of {@link Permission}. * @since 1.0.0 */ @XmlElementWrapper(name = "permissions") @XmlElement(name = "permission") -

    Set

    getPermissions(); - + public Set getPermissions() { + if (permissions == null) { + permissions = new HashSet<>(); + } + return permissions; + } } diff --git a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessInfoFactory.java b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessInfoFactory.java index 784adb9493f..4ad03d82bd6 100644 --- a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessInfoFactory.java +++ b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessInfoFactory.java @@ -20,6 +20,6 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface AccessInfoFactory extends KapuaEntityFactory { +public interface AccessInfoFactory extends KapuaEntityFactory { } diff --git a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessInfoXmlRegistry.java b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessInfoXmlRegistry.java index f95778c0540..6c111290e82 100644 --- a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessInfoXmlRegistry.java +++ b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessInfoXmlRegistry.java @@ -29,14 +29,4 @@ public class AccessInfoXmlRegistry { public AccessInfo newAccessInfo() { return accessInfoFactory.newEntity(null); } - - /** - * Creates a new access info creator instance - * - * @return - */ - public AccessInfoCreator newAccessInfoCreator() { - return accessInfoFactory.newCreator(null); - } - } diff --git a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessPermissionCreator.java b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessPermissionCreator.java index 96cfcf0356e..cb22145b526 100644 --- a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessPermissionCreator.java +++ b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessPermissionCreator.java @@ -12,11 +12,6 @@ *******************************************************************************/ package org.eclipse.kapua.service.authorization.access; -import org.eclipse.kapua.model.KapuaEntityCreator; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.model.id.KapuaIdAdapter; -import org.eclipse.kapua.service.authorization.permission.Permission; - import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; @@ -24,25 +19,43 @@ import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; +import org.eclipse.kapua.model.KapuaEntityCreator; +import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.model.id.KapuaIdAdapter; +import org.eclipse.kapua.service.authorization.permission.Permission; + /** - * {@link AccessPermission} creator definition.
    - * It is used to create a new {@link AccessPermission}. + * {@link AccessPermission} creator definition.
    It is used to create a new {@link AccessPermission}. * * @since 1.0.0 */ @XmlRootElement(name = "accessPermissionCreator") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(propOrder = {"accessInfoId", "permission"},// - factoryClass = AccessPermissionXmlRegistry.class, factoryMethod = "newCreator") -public interface AccessPermissionCreator extends KapuaEntityCreator { +@XmlType(propOrder = { "accessInfoId", "permission" }) +public class AccessPermissionCreator extends KapuaEntityCreator { + + private static final long serialVersionUID = 972154225756734130L; + + private KapuaId accessInfo; + private Permission permission; + + public AccessPermissionCreator() { + } + + public AccessPermissionCreator(KapuaId scopeId) { + super(scopeId); + } /** * Sets the {@link AccessInfo} id for this {@link AccessPermission}. * - * @param accessInfoId The {@link AccessInfo} id for this {@link AccessPermission}. + * @param accessInfoId + * The {@link AccessInfo} id for this {@link AccessPermission}. * @since 1.0.0 */ - void setAccessInfoId(KapuaId accessInfoId); + public void setAccessInfoId(KapuaId accessInfoId) { + this.accessInfo = accessInfoId; + } /** * Gets the {@link AccessInfo} id of this {@link AccessPermission}. @@ -52,16 +65,20 @@ public interface AccessPermissionCreator extends KapuaEntityCreator P getPermission(); + public Permission getPermission() { + return permission; + } } diff --git a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessPermissionFactory.java b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessPermissionFactory.java index 7841bb0e710..77c6297bd1a 100644 --- a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessPermissionFactory.java +++ b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessPermissionFactory.java @@ -20,6 +20,6 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface AccessPermissionFactory extends KapuaEntityFactory { +public interface AccessPermissionFactory extends KapuaEntityFactory { } diff --git a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessPermissionXmlRegistry.java b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessPermissionXmlRegistry.java index 5a9095d179c..e49f3495d82 100644 --- a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessPermissionXmlRegistry.java +++ b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessPermissionXmlRegistry.java @@ -29,13 +29,4 @@ public class AccessPermissionXmlRegistry { public AccessPermission newAccessPermission() { return accessPermissionFactory.newEntity(null); } - - /** - * Creates a new {@link AccessPermission} instance - * - * @return - */ - public AccessPermissionCreator newCreator() { - return accessPermissionFactory.newCreator(null); - } } diff --git a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessRoleCreator.java b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessRoleCreator.java index 750950863c7..c825668ea7e 100644 --- a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessRoleCreator.java +++ b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessRoleCreator.java @@ -12,11 +12,6 @@ *******************************************************************************/ package org.eclipse.kapua.service.authorization.access; -import org.eclipse.kapua.model.KapuaEntityCreator; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.model.id.KapuaIdAdapter; -import org.eclipse.kapua.service.authorization.role.Role; - import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; @@ -24,25 +19,48 @@ import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; +import org.eclipse.kapua.model.KapuaEntityCreator; +import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.model.id.KapuaIdAdapter; +import org.eclipse.kapua.service.authorization.role.Role; + /** - * {@link AccessRole} creator definition.
    - * It is used to create a new {@link AccessRole}. + * {@link AccessRole} creator definition.
    It is used to create a new {@link AccessRole}. * * @since 1.0.0 */ @XmlRootElement(name = "accessRoleCreator") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(propOrder = { "accessInfoId", "roleId" },// - factoryClass = AccessRoleXmlRegistry.class, factoryMethod = "newCreator") -public interface AccessRoleCreator extends KapuaEntityCreator { +@XmlType(propOrder = { "accessInfoId", "roleId" }) +public class AccessRoleCreator extends KapuaEntityCreator { + + private static final long serialVersionUID = 972154225756734130L; + + private KapuaId accessInfo; + private KapuaId roleId; + + public AccessRoleCreator() { + } + + /** + * Constructor + * + * @param scopeId + */ + public AccessRoleCreator(KapuaId scopeId) { + super(scopeId); + } /** * Sets the {@link AccessInfo} id for this {@link AccessRole}. * - * @param accessInfoId The {@link AccessInfo} id for this {@link AccessRole}. + * @param accessInfoId + * The {@link AccessInfo} id for this {@link AccessRole}. * @since 1.0.0 */ - void setAccessInfoId(KapuaId accessInfoId); + public void setAccessInfoId(KapuaId accessInfoId) { + this.accessInfo = accessInfoId; + } /** * Gets the {@link AccessInfo} id of this {@link AccessRole}. @@ -52,16 +70,20 @@ public interface AccessRoleCreator extends KapuaEntityCreator { */ @XmlElement(name = "accessInfoId") @XmlJavaTypeAdapter(KapuaIdAdapter.class) - KapuaId getAccessInfoId(); + public KapuaId getAccessInfoId() { + return accessInfo; + } /** - * Sets the {@link Role} id to assign to the {@link AccessRole} created entity. - * It up to the implementation class to make a clone of the object or use the given object. + * Sets the {@link Role} id to assign to the {@link AccessRole} created entity. It up to the implementation class to make a clone of the object or use the given object. * - * @param roleId The {@link Role} id + * @param roleId + * The {@link Role} id * @since 1.0.0 */ - void setRoleId(KapuaId roleId); + public void setRoleId(KapuaId roleId) { + this.roleId = roleId; + } /** * Gets the {@link Role} id added to this {@link AccessRole}. @@ -71,5 +93,7 @@ public interface AccessRoleCreator extends KapuaEntityCreator { */ @XmlElement(name = "roleId") @XmlJavaTypeAdapter(KapuaIdAdapter.class) - KapuaId getRoleId(); + public KapuaId getRoleId() { + return roleId; + } } diff --git a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessRoleFactory.java b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessRoleFactory.java index 6fe12ad0704..2d53af95d47 100644 --- a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessRoleFactory.java +++ b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessRoleFactory.java @@ -20,6 +20,6 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface AccessRoleFactory extends KapuaEntityFactory { +public interface AccessRoleFactory extends KapuaEntityFactory { } diff --git a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessRoleXmlRegistry.java b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessRoleXmlRegistry.java index eba9eed0899..3b21acbab7d 100644 --- a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessRoleXmlRegistry.java +++ b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/access/AccessRoleXmlRegistry.java @@ -29,14 +29,4 @@ public class AccessRoleXmlRegistry { public AccessRole newAccessRole() { return accessRoleFactory.newEntity(null); } - - /** - * Creates a new {@link AccessRole} instance - * - * @return - */ - public AccessRoleCreator newCreator() { - return accessRoleFactory.newCreator(null); - } - } diff --git a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/domain/DomainCreator.java b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/domain/DomainCreator.java index 7f4a26fa0f5..8e68968b1bd 100644 --- a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/domain/DomainCreator.java +++ b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/domain/DomainCreator.java @@ -12,14 +12,16 @@ *******************************************************************************/ package org.eclipse.kapua.service.authorization.domain; -import org.eclipse.kapua.model.KapuaEntityCreator; -import org.eclipse.kapua.model.domain.Actions; -import org.eclipse.kapua.service.authorization.permission.Permission; +import java.util.Set; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; -import java.util.Set; + +import org.eclipse.kapua.model.KapuaEntityCreator; +import org.eclipse.kapua.model.domain.Actions; +import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.service.authorization.permission.Permission; /** * {@link DomainCreator} definition.
    @@ -30,49 +32,100 @@ */ @XmlRootElement(name = "domainCreator") @XmlAccessorType(XmlAccessType.PROPERTY) -public interface DomainCreator extends KapuaEntityCreator { // org.eclipse.kapua.model.domain.Domain { +public class DomainCreator extends KapuaEntityCreator { // org.eclipse.kapua.model.domain.Domain { + + private static final long serialVersionUID = -4676187845961673421L; - String getName(); + private String name; - String getServiceName(); + private String serviceName; + private Set actions; + private boolean groupable; - Set getActions(); + public DomainCreator() { + } - boolean getGroupable(); + public DomainCreator(KapuaId scopeId, String name) { + super(scopeId); + this.name = name; + } + + public DomainCreator(KapuaId scopeId) { + super(scopeId); + } + + /** + * Constructor + * + * @param name + * The name to set for this {@link DomainCreator}. + * @since 1.0.0 + */ + public DomainCreator(String name) { + this.name = name; + } + + public String getServiceName() { + return serviceName; + } + + public Set getActions() { + return actions; + } + + public boolean getGroupable() { + return groupable; + } /** * Sets the {@link Domain} name. * - * @param name The {@link Domain} name. + * @param name + * The {@link Domain} name. * @since 1.0.0 */ - void setName(String name); + public void setName(String name) { + this.name = name; + } + + public String getName() { + return name; + } /** * Sets the {@link Domain} service name. * - * @param serviceName The {@link Domain} name. + * @param serviceName + * The {@link Domain} name. * @since 1.0.0 */ - void setServiceName(String serviceName); + public void setServiceName(String serviceName) { + this.serviceName = serviceName; + } /** - * Sets the set of {@link Actions} available in the {@link Domain}.
    - * It up to the implementation class to make a clone of the set or use the given set. + * Sets the set of {@link Actions} available in the {@link Domain}.
    It up to the implementation class to make a clone of the set or use the given set. * - * @param actions The set of {@link Actions}. + * @param actions + * The set of {@link Actions}. * @since 1.0.0 */ - void setActions(Set actions); + public void setActions(Set actions) { + this.actions = actions; + } /** - * Sets whether or not this {@link Domain} is group-able or not. - * This determines if the {@link org.eclipse.kapua.service.authorization.permission.Permission} in this {@link Domain} can have a {@link org.eclipse.kapua.service.authorization.group.Group} or not. - * This is related to the {@link org.eclipse.kapua.service.authorization.group.Groupable} property of a {@link KapuaEntityCreator}. + * Sets whether or not this {@link Domain} is group-able or not. This determines if the {@link org.eclipse.kapua.service.authorization.permission.Permission} in this {@link Domain} can have a + * {@link org.eclipse.kapua.service.authorization.group.Group} or not. This is related to the {@link org.eclipse.kapua.service.authorization.group.Groupable} property of a + * {@link KapuaEntityCreator}. * - * @param groupable {@code true} if the {@link org.eclipse.kapua.service.authorization.permission.Permission} on this {@link Domain} can have the {@link Permission#getGroupId()} property set, {@code false} otherwise. + * @param groupable + * {@code true} if the {@link org.eclipse.kapua.service.authorization.permission.Permission} on this {@link Domain} can have the {@link Permission#getGroupId()} property set, {@code false} + * otherwise. * @since 0.3.1 */ - void setGroupable(boolean groupable); + public void setGroupable(boolean groupable) { + this.groupable = groupable; + } } diff --git a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/domain/DomainFactory.java b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/domain/DomainFactory.java index 4a8154eb2f6..7dfbc936a28 100644 --- a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/domain/DomainFactory.java +++ b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/domain/DomainFactory.java @@ -20,16 +20,6 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface DomainFactory extends KapuaEntityFactory { - - /** - * Instantiates a new {@link DomainCreator} - * - * @param name - * The name to set into the {@link Domain}. - * @return The newly instantiated {@link Domain}. - * @since 1.0.0 - */ - DomainCreator newCreator(String name); +public interface DomainFactory extends KapuaEntityFactory { } diff --git a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/group/GroupCreator.java b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/group/GroupCreator.java index a0e0cdca9e3..1173c21bd55 100644 --- a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/group/GroupCreator.java +++ b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/group/GroupCreator.java @@ -12,13 +12,14 @@ *******************************************************************************/ package org.eclipse.kapua.service.authorization.group; -import org.eclipse.kapua.model.KapuaNamedEntityCreator; - import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import org.eclipse.kapua.model.KapuaNamedEntityCreator; +import org.eclipse.kapua.model.id.KapuaId; + /** * {@link GroupCreator} definition. *

    @@ -28,6 +29,19 @@ */ @XmlRootElement(name = "groupCreator") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = GroupXmlRegistry.class, factoryMethod = "newGroupCreator") -public interface GroupCreator extends KapuaNamedEntityCreator { +@XmlType +public class GroupCreator extends KapuaNamedEntityCreator { + + private static final long serialVersionUID = -4676187845961673421L; + + public GroupCreator() { + } + + public GroupCreator(KapuaId scopeId) { + super(scopeId); + } + + public GroupCreator(KapuaId scopeId, String name) { + super(scopeId, name); + } } diff --git a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/group/GroupFactory.java b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/group/GroupFactory.java index 670acfe713b..560e3c39a79 100644 --- a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/group/GroupFactory.java +++ b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/group/GroupFactory.java @@ -13,7 +13,6 @@ package org.eclipse.kapua.service.authorization.group; import org.eclipse.kapua.model.KapuaEntityFactory; -import org.eclipse.kapua.model.id.KapuaId; /** * {@link GroupFactory} definition. @@ -21,18 +20,6 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface GroupFactory extends KapuaEntityFactory { - - /** - * Instantiates a new {@link GroupCreator}. - * - * @param scopeId - * The scope {@link KapuaId} to set into the {@link GroupCreator} - * @param name - * The name to set into the {@link GroupCreator} - * @return The newly instantatied {@link GroupCreator} - * @since 1.0.0 - */ - GroupCreator newCreator(KapuaId scopeId, String name); +public interface GroupFactory extends KapuaEntityFactory { } diff --git a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/group/GroupXmlRegistry.java b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/group/GroupXmlRegistry.java index 58d75b19f3f..dc14bd45e82 100644 --- a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/group/GroupXmlRegistry.java +++ b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/group/GroupXmlRegistry.java @@ -30,14 +30,4 @@ public class GroupXmlRegistry { public Group newGroup() { return groupFactory.newEntity(null); } - - /** - * Creates a new {@link GroupCreator} instance. - * - * @return The newly created {@link GroupCreator} instance. - * @since 1.0.0 - */ - public GroupCreator newGroupCreator() { - return groupFactory.newCreator(null, null); - } } diff --git a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RoleCreator.java b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RoleCreator.java index 0752ae89ad8..c66834bcf0b 100644 --- a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RoleCreator.java +++ b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RoleCreator.java @@ -12,8 +12,9 @@ *******************************************************************************/ package org.eclipse.kapua.service.authorization.role; -import org.eclipse.kapua.model.KapuaNamedEntityCreator; -import org.eclipse.kapua.service.authorization.permission.Permission; +import java.security.Permissions; +import java.util.HashSet; +import java.util.Set; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; @@ -21,8 +22,10 @@ import javax.xml.bind.annotation.XmlElementWrapper; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; -import java.security.Permissions; -import java.util.Set; + +import org.eclipse.kapua.model.KapuaNamedEntityCreator; +import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.service.authorization.permission.Permission; /** * {@link RoleCreator} definition. @@ -33,27 +36,44 @@ */ @XmlRootElement(name = "roleCreator") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = RoleXmlRegistry.class, factoryMethod = "newRoleCreator") -public interface RoleCreator extends KapuaNamedEntityCreator { +@XmlType +public class RoleCreator extends KapuaNamedEntityCreator { + + private static final long serialVersionUID = 972154225756734130L; + + private Set permissions; + + public RoleCreator() { + + } + + public RoleCreator(KapuaId scopeId) { + super(scopeId); + } /** - * Sets the set of {@link Permissions} to assign to the {@link Role} created entity. - * It up to the implementation class to make a clone of the set or use the given set. + * Sets the set of {@link Permissions} to assign to the {@link Role} created entity. It up to the implementation class to make a clone of the set or use the given set. * - * @param permissions The set of {@link Permissions}. + * @param permissions + * The set of {@link Permissions}. * @since 1.0.0 */ - void setPermissions(Set permissions); + public void setPermissions(Set permissions) { + this.permissions = permissions; + } /** - * Gets the set of {@link Permission} added to this {@link Role}. - * The implementation must return the reference of the set and not make a clone. + * Gets the set of {@link Permission} added to this {@link Role}. The implementation must return the reference of the set and not make a clone. * - * @param

    The {@link Permission} class implementation. * @return The set of {@link Permission}. * @since 1.0.0 */ @XmlElementWrapper(name = "permissions") @XmlElement(name = "permission") -

    Set

    getPermissions(); + public Set getPermissions() { + if (permissions == null) { + permissions = new HashSet<>(); + } + return permissions; + } } diff --git a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RoleFactory.java b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RoleFactory.java index 44b89b7e46e..cec18c32d22 100644 --- a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RoleFactory.java +++ b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RoleFactory.java @@ -20,7 +20,7 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface RoleFactory extends KapuaEntityFactory { +public interface RoleFactory extends KapuaEntityFactory { /** * Instantiates a new {@link RolePermission}. diff --git a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RolePermissionCreator.java b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RolePermissionCreator.java index d503e0f231d..a91b0aa541b 100644 --- a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RolePermissionCreator.java +++ b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RolePermissionCreator.java @@ -12,11 +12,6 @@ *******************************************************************************/ package org.eclipse.kapua.service.authorization.role; -import org.eclipse.kapua.model.KapuaEntityCreator; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.model.id.KapuaIdAdapter; -import org.eclipse.kapua.service.authorization.permission.Permission; - import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; @@ -24,25 +19,43 @@ import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; +import org.eclipse.kapua.model.KapuaEntityCreator; +import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.model.id.KapuaIdAdapter; +import org.eclipse.kapua.service.authorization.permission.Permission; + /** - * {@link RolePermission} creator definition.
    - * It is used to create a new {@link RolePermission}. + * {@link RolePermission} creator definition.
    It is used to create a new {@link RolePermission}. * * @since 1.0.0 */ @XmlRootElement(name = "rolePermissionCreator") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(propOrder = {"roleId", "permission"},// - factoryClass = RolePermissionXmlRegistry.class, factoryMethod = "newCreator") -public interface RolePermissionCreator extends KapuaEntityCreator { +@XmlType(propOrder = { "roleId", "permission" }) +public class RolePermissionCreator extends KapuaEntityCreator { + + private static final long serialVersionUID = 972154225756734130L; + + private KapuaId roleId; + private Permission permission; + + public RolePermissionCreator() { + } + + public RolePermissionCreator(KapuaId scopeId) { + super(scopeId); + } /** * Sets the {@link Role} id for this {@link RolePermission}. * - * @param roleId The {@link Role} id for this {@link RolePermission}. + * @param roleId + * The {@link Role} id for this {@link RolePermission}. * @since 1.0.0 */ - void setRoleId(KapuaId roleId); + public void setRoleId(KapuaId roleId) { + this.roleId = roleId; + } /** * Gets the {@link Role} id of this {@link RolePermission}. @@ -52,16 +65,20 @@ public interface RolePermissionCreator extends KapuaEntityCreator P getPermission(); + public Permission getPermission() { + return permission; + } } diff --git a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RolePermissionFactory.java b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RolePermissionFactory.java index 3f22b6ff052..3a694eb1a56 100644 --- a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RolePermissionFactory.java +++ b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RolePermissionFactory.java @@ -20,6 +20,6 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface RolePermissionFactory extends KapuaEntityFactory { +public interface RolePermissionFactory extends KapuaEntityFactory { } diff --git a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RolePermissionXmlRegistry.java b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RolePermissionXmlRegistry.java index e03cd41004a..ff476e71c44 100644 --- a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RolePermissionXmlRegistry.java +++ b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RolePermissionXmlRegistry.java @@ -29,14 +29,4 @@ public class RolePermissionXmlRegistry { public RolePermission newRolePermission() { return rolePermissionFactory.newEntity(null); } - - /** - * Creates a new {@link RolePermission} instance - * - * @return - */ - public RolePermissionCreator newCreator() { - return rolePermissionFactory.newCreator(null); - } - } diff --git a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RoleXmlRegistry.java b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RoleXmlRegistry.java index 982975a8dca..ee52f98433e 100644 --- a/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RoleXmlRegistry.java +++ b/service/security/authorization/api/src/main/java/org/eclipse/kapua/service/authorization/role/RoleXmlRegistry.java @@ -31,13 +31,4 @@ public Role newRole() { return roleFactory.newEntity(null); } - /** - * Creates a new {@link RoleCreator} instance. - * - * @return The newly created {@link RoleCreator} instance. - * @since 1.0.0 - */ - public RoleCreator newRoleCreator() { - return roleFactory.newCreator(null); - } } diff --git a/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/CertificateCreator.java b/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/CertificateCreator.java index ee17959ac1f..f74cb066a0c 100644 --- a/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/CertificateCreator.java +++ b/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/CertificateCreator.java @@ -12,10 +12,8 @@ *******************************************************************************/ package org.eclipse.kapua.service.certificate; -import org.eclipse.kapua.model.KapuaNamedEntityCreator; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.model.id.KapuaIdAdapter; -import org.eclipse.kapua.service.certificate.xml.CertificateXmlRegistry; +import java.util.HashSet; +import java.util.Set; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; @@ -24,7 +22,10 @@ import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; -import java.util.Set; + +import org.eclipse.kapua.model.KapuaNamedEntityCreator; +import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.model.id.KapuaIdAdapter; /** * {@link Certificate} {@link org.eclipse.kapua.model.KapuaEntityCreator}encapsulates all the information needed to create a new {@link Certificate} in the system. @@ -33,43 +34,97 @@ */ @XmlRootElement(name = "certificateCreator") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = CertificateXmlRegistry.class, factoryMethod = "newCreator") -public interface CertificateCreator extends KapuaNamedEntityCreator { +@XmlType +public class CertificateCreator extends KapuaNamedEntityCreator { + + private String certificate; + private CertificateStatus status; + private String privateKey; + private KapuaId caId; + private String password; + private Set certificateUsages; + private Boolean forwardable; + + public CertificateCreator() { + } + + public CertificateCreator(KapuaId scopeId) { + super(scopeId); + } + + public CertificateCreator(KapuaId scopeId, String name) { + super(scopeId, name); + } @XmlElement(name = "certificate") - String getCertificate(); + public String getCertificate() { + return certificate; + } - void setCertificate(String certificate); + public void setCertificate(String certificate) { + this.certificate = certificate; + } @XmlElement(name = "status") - CertificateStatus getStatus(); + public CertificateStatus getStatus() { + //Kind hackish, but the database does not allow nulls here. + //default value was previously set in the constructor, but that only works if the field is not present in the "dto" (request payload for rest apis), and not when the field is passed as null, and changing the field to be required would break back-compatibility. + return status == null ? CertificateStatus.VALID : status; + } - void setStatus(CertificateStatus status); + public void setStatus(CertificateStatus status) { + this.status = status; + } @XmlElement(name = "privateKey") - String getPrivateKey(); + public String getPrivateKey() { + return privateKey; + } - void setPrivateKey(String privateKey); + public void setPrivateKey(String privateKey) { + this.privateKey = privateKey; + } @XmlElement(name = "caId") @XmlJavaTypeAdapter(KapuaIdAdapter.class) - KapuaId getCaId(); + public KapuaId getCaId() { + return caId; + } - void setCaId(KapuaId caId); + public void setCaId(KapuaId caId) { + this.caId = caId; + } @XmlElement(name = "password") - String getPassword(); + public String getPassword() { + return password; + } - void setPassword(String password); + public void setPassword(String password) { + this.password = password; + } @XmlElementWrapper(name = "certificateUsages") @XmlElement(name = "certificateUsage") - Set getCertificateUsages(); - - void setCertificateUsages(Set certificateUsages); + public Set getCertificateUsages() { + return certificateUsages; + } + + public void setCertificateUsages(Set set) { + Set newSet = new HashSet<>(); + for (CertificateUsage certificateUsage : set) { + newSet.add(certificateUsage); + } + certificateUsages = newSet; + } @XmlElement(name = "forwardable") - Boolean getForwardable(); + public Boolean getForwardable() { + return forwardable; + } + + public void setForwardable(Boolean forwardable) { + this.forwardable = forwardable; + } - void setForwardable(Boolean forwardable); } diff --git a/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/CertificateFactory.java b/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/CertificateFactory.java index ad5d0549dc5..b73aded9ad9 100644 --- a/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/CertificateFactory.java +++ b/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/CertificateFactory.java @@ -20,7 +20,7 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface CertificateFactory extends KapuaEntityFactory { +public interface CertificateFactory extends KapuaEntityFactory { /** * Instantiates a new {@link CertificateUsage}. diff --git a/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/info/CertificateInfoCreator.java b/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/info/CertificateInfoCreator.java index 862056e315d..7037a39f31f 100644 --- a/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/info/CertificateInfoCreator.java +++ b/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/info/CertificateInfoCreator.java @@ -12,19 +12,32 @@ *******************************************************************************/ package org.eclipse.kapua.service.certificate.info; -import org.eclipse.kapua.model.KapuaNamedEntityCreator; -import org.eclipse.kapua.service.certificate.info.xml.CertificateInfoXmlRegistry; - import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import org.eclipse.kapua.model.KapuaNamedEntityCreator; +import org.eclipse.kapua.model.id.KapuaId; + /** * @since 1.1.0 */ @XmlRootElement(name = "certificateInfoCreator") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = CertificateInfoXmlRegistry.class, factoryMethod = "newCreator") -public interface CertificateInfoCreator extends KapuaNamedEntityCreator { +@XmlType +//This class exists only because the Service needed a placeholder.Sigh. +public class CertificateInfoCreator extends KapuaNamedEntityCreator { + + public CertificateInfoCreator() { + throw new UnsupportedOperationException(); + } + + public CertificateInfoCreator(KapuaId scopeId) { + throw new UnsupportedOperationException(); + } + + public CertificateInfoCreator(KapuaId scopeId, String name) { + throw new UnsupportedOperationException(); + } } diff --git a/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/info/CertificateInfoFactory.java b/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/info/CertificateInfoFactory.java index b8a70ce6e29..c1ba0bdc295 100644 --- a/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/info/CertificateInfoFactory.java +++ b/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/info/CertificateInfoFactory.java @@ -17,6 +17,6 @@ /** * @since 1.1.0 */ -public interface CertificateInfoFactory extends KapuaEntityFactory { +public interface CertificateInfoFactory extends KapuaEntityFactory { } diff --git a/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/info/xml/CertificateInfoXmlRegistry.java b/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/info/xml/CertificateInfoXmlRegistry.java index cd4d810065c..ce65eeeac87 100644 --- a/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/info/xml/CertificateInfoXmlRegistry.java +++ b/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/info/xml/CertificateInfoXmlRegistry.java @@ -16,7 +16,6 @@ import org.eclipse.kapua.locator.KapuaLocator; import org.eclipse.kapua.service.certificate.info.CertificateInfo; -import org.eclipse.kapua.service.certificate.info.CertificateInfoCreator; import org.eclipse.kapua.service.certificate.info.CertificateInfoFactory; @XmlRegistry @@ -27,9 +26,4 @@ public class CertificateInfoXmlRegistry { public CertificateInfo newCertificateInfo() { return certificateInfoFactory.newEntity(null); } - - public CertificateInfoCreator newCreator() { - return certificateInfoFactory.newCreator(null); - } - } diff --git a/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/xml/CertificateXmlRegistry.java b/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/xml/CertificateXmlRegistry.java index 7e3ab86d667..bde79ee1232 100644 --- a/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/xml/CertificateXmlRegistry.java +++ b/service/security/certificate/api/src/main/java/org/eclipse/kapua/service/certificate/xml/CertificateXmlRegistry.java @@ -16,7 +16,6 @@ import org.eclipse.kapua.locator.KapuaLocator; import org.eclipse.kapua.service.certificate.Certificate; -import org.eclipse.kapua.service.certificate.CertificateCreator; import org.eclipse.kapua.service.certificate.CertificateFactory; import org.eclipse.kapua.service.certificate.CertificateGenerator; import org.eclipse.kapua.service.certificate.CertificateUsage; @@ -30,10 +29,6 @@ public Certificate newCertificate() { return certificateFactory.newEntity(null); } - public CertificateCreator newCreator() { - return certificateFactory.newCreator(null); - } - public CertificateGenerator newCertificateGenerator() { return certificateFactory.newCertificateGenerator(); } diff --git a/service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/info/internal/CertificateInfoFactoryImpl.java b/service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/info/internal/CertificateInfoFactoryImpl.java index e5a2cd7c0e3..80e518ab3d4 100644 --- a/service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/info/internal/CertificateInfoFactoryImpl.java +++ b/service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/info/internal/CertificateInfoFactoryImpl.java @@ -17,7 +17,6 @@ import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.certificate.info.CertificateInfo; -import org.eclipse.kapua.service.certificate.info.CertificateInfoCreator; import org.eclipse.kapua.service.certificate.info.CertificateInfoFactory; @Singleton @@ -28,11 +27,6 @@ public CertificateInfo newEntity(KapuaId scopeId) { return new CertificateInfoImpl(scopeId); } - @Override - public CertificateInfoCreator newCreator(KapuaId scopeId) { - throw new UnsupportedOperationException(); - } - @Override public CertificateInfo clone(CertificateInfo certificateInfo) throws KapuaEntityCloneException { try { diff --git a/service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/internal/CertificateFactoryImpl.java b/service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/internal/CertificateFactoryImpl.java index 5dad8bd6097..51c66fbbe4d 100644 --- a/service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/internal/CertificateFactoryImpl.java +++ b/service/security/certificate/internal/src/main/java/org/eclipse/kapua/service/certificate/internal/CertificateFactoryImpl.java @@ -17,7 +17,6 @@ import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.certificate.Certificate; -import org.eclipse.kapua.service.certificate.CertificateCreator; import org.eclipse.kapua.service.certificate.CertificateFactory; import org.eclipse.kapua.service.certificate.CertificateGenerator; import org.eclipse.kapua.service.certificate.CertificateUsage; @@ -37,11 +36,6 @@ public Certificate newEntity(KapuaId scopeId) { return new CertificateImpl(scopeId); } - @Override - public CertificateCreator newCreator(KapuaId scopeId) { - throw new UnsupportedOperationException(); - } - @Override public CertificateUsage newCertificateUsage(String name) { return new CertificateUsageImpl(name); diff --git a/service/security/registration/simple/src/main/java/org/eclipse/kapua/security/registration/simple/SimpleRegistrationProcessor.java b/service/security/registration/simple/src/main/java/org/eclipse/kapua/security/registration/simple/SimpleRegistrationProcessor.java index ceedb5e7d85..74ac751b478 100644 --- a/service/security/registration/simple/src/main/java/org/eclipse/kapua/security/registration/simple/SimpleRegistrationProcessor.java +++ b/service/security/registration/simple/src/main/java/org/eclipse/kapua/security/registration/simple/SimpleRegistrationProcessor.java @@ -12,6 +12,16 @@ *******************************************************************************/ package org.eclipse.kapua.security.registration.simple; +import java.time.Instant; +import java.time.temporal.ChronoUnit; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; + import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.commons.model.domains.Domains; import org.eclipse.kapua.commons.security.KapuaSecurityUtils; @@ -27,43 +37,28 @@ import org.eclipse.kapua.service.account.AccountFactory; import org.eclipse.kapua.service.account.AccountService; import org.eclipse.kapua.service.authentication.credential.CredentialCreator; -import org.eclipse.kapua.service.authentication.credential.CredentialFactory; import org.eclipse.kapua.service.authentication.credential.CredentialService; import org.eclipse.kapua.service.authentication.credential.CredentialStatus; import org.eclipse.kapua.service.authorization.access.AccessInfoCreator; -import org.eclipse.kapua.service.authorization.access.AccessInfoFactory; import org.eclipse.kapua.service.authorization.access.AccessInfoService; import org.eclipse.kapua.service.authorization.permission.Permission; import org.eclipse.kapua.service.authorization.permission.PermissionFactory; import org.eclipse.kapua.service.device.registry.DeviceRegistryService; import org.eclipse.kapua.service.user.User; import org.eclipse.kapua.service.user.UserCreator; -import org.eclipse.kapua.service.user.UserFactory; import org.eclipse.kapua.service.user.UserService; import org.eclipse.kapua.service.user.UserType; import org.jose4j.jwt.consumer.JwtContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.time.Instant; -import java.time.temporal.ChronoUnit; -import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; -import java.util.Set; - /** * A processor which creates a simple account and user setup *

    - * This processor creates a new account based on the OpenID SSO claim and creates a single - * user for this account. + * This processor creates a new account based on the OpenID SSO claim and creates a single user for this account. *

    *

    - * It is possible to define the root account which all accounts will be part of using - * the {@link Settings} class. + * It is possible to define the root account which all accounts will be part of using the {@link Settings} class. *

    */ public class SimpleRegistrationProcessor implements RegistrationProcessor { @@ -92,7 +87,8 @@ public KapuaId getRootAccount() { * If this value is negative then there will be no limit on the number of child users. *

    * - * @param maximumNumberOfChildUsers The number of child users to allow + * @param maximumNumberOfChildUsers + * The number of child users to allow */ public void setMaximumNumberOfUsers(int maximumNumberOfChildUsers) { this.maximumNumberOfUsers = maximumNumberOfChildUsers; @@ -144,15 +140,12 @@ private static SimpleRegistrationProcessor.Settings applySimpleSettings(KapuaId private final AccountFactory accountFactory; private final CredentialService credentialService; - private final CredentialFactory credentialFactory; private final DeviceRegistryService deviceRegistryService; private final UserService userService; - private final UserFactory userFactory; private final AccessInfoService accessInfoService; - private final AccessInfoFactory accessInfoFactory; private final PermissionFactory permissionFactory; private final SimpleSetting simpleSetting; @@ -166,27 +159,23 @@ private static SimpleRegistrationProcessor.Settings applySimpleSettings(KapuaId * @param accountService * @param accountFactory * @param credentialService - * @param credentialFactory * @param deviceRegistryService * @param userService - * @param userFactory * @param accessInfoService - * @param accessInfoFactory * @param permissionFactory * @param simpleSetting - * @param claimName the claim to use as account name - * @param settings the settings for the processor + * @param claimName + * the claim to use as account name + * @param settings + * the settings for the processor */ public SimpleRegistrationProcessor( AccountService accountService, AccountFactory accountFactory, CredentialService credentialService, - CredentialFactory credentialFactory, DeviceRegistryService deviceRegistryService, UserService userService, - UserFactory userFactory, AccessInfoService accessInfoService, - AccessInfoFactory accessInfoFactory, PermissionFactory permissionFactory, SimpleSetting simpleSetting, String claimName, @@ -194,12 +183,9 @@ public SimpleRegistrationProcessor( this.accountService = accountService; this.accountFactory = accountFactory; this.credentialService = credentialService; - this.credentialFactory = credentialFactory; this.deviceRegistryService = deviceRegistryService; this.userService = userService; - this.userFactory = userFactory; this.accessInfoService = accessInfoService; - this.accessInfoFactory = accessInfoFactory; this.permissionFactory = permissionFactory; this.simpleSetting = simpleSetting; this.claimName = claimName; @@ -241,7 +227,7 @@ private Optional internalCreateUser(JwtContext context) throws Exception { // define account - AccountCreator accountCreator = accountFactory.newCreator(settings.getRootAccount()); + AccountCreator accountCreator = new AccountCreator(settings.getRootAccount()); accountCreator.setName(name); accountCreator.setOrganizationEmail(email); accountCreator.setOrganizationName(name); @@ -280,7 +266,7 @@ private User createUser(String name, String email, String displayName, String su // define - UserCreator userCreator = userFactory.newCreator(account.getId(), name); + UserCreator userCreator = new UserCreator(account.getId(), name); userCreator.setUserType(UserType.EXTERNAL); userCreator.setExternalId(subject); userCreator.setEmail(email); @@ -292,7 +278,7 @@ private User createUser(String name, String email, String displayName, String su // assign login permissions - AccessInfoCreator accessInfoCreator = accessInfoFactory.newCreator(user.getScopeId()); + AccessInfoCreator accessInfoCreator = new AccessInfoCreator(user.getScopeId()); accessInfoCreator.setUserId(user.getId()); Set permissions = new HashSet<>(); @@ -322,7 +308,7 @@ private User createBrokerUser(String baseName, Account account) throws KapuaExce // define - UserCreator userCreator = userFactory.newCreator(account.getId(), baseName + "-broker"); + UserCreator userCreator = new UserCreator(account.getId(), baseName + "-broker"); userCreator.setUserType(UserType.INTERNAL); // FIXME: need to find out why this isn't DEVICE but INTERNAL userCreator.setDisplayName("Gateway User"); @@ -332,7 +318,7 @@ private User createBrokerUser(String baseName, Account account) throws KapuaExce // assign permissions - AccessInfoCreator accessInfoCreator = accessInfoFactory.newCreator(user.getScopeId()); + AccessInfoCreator accessInfoCreator = new AccessInfoCreator(user.getScopeId()); accessInfoCreator.setUserId(user.getId()); Set permissions = new HashSet<>(); @@ -344,7 +330,7 @@ private User createBrokerUser(String baseName, Account account) throws KapuaExce // Create default password - CredentialCreator credential = credentialFactory.newCreator(account.getId(), user.getId(), "PASSWORD", baseName + "-Password1!", CredentialStatus.ENABLED, null); + CredentialCreator credential = new CredentialCreator(account.getId(), user.getId(), "PASSWORD", baseName + "-Password1!", CredentialStatus.ENABLED, null); credentialService.create(credential); return user; diff --git a/service/security/registration/simple/src/main/java/org/eclipse/kapua/security/registration/simple/SimpleRegistrationProcessorProvider.java b/service/security/registration/simple/src/main/java/org/eclipse/kapua/security/registration/simple/SimpleRegistrationProcessorProvider.java index 26ea71350e6..e1a225d1398 100644 --- a/service/security/registration/simple/src/main/java/org/eclipse/kapua/security/registration/simple/SimpleRegistrationProcessorProvider.java +++ b/service/security/registration/simple/src/main/java/org/eclipse/kapua/security/registration/simple/SimpleRegistrationProcessorProvider.java @@ -12,6 +12,12 @@ *******************************************************************************/ package org.eclipse.kapua.security.registration.simple; +import java.util.Collections; +import java.util.Optional; +import java.util.Set; + +import javax.inject.Inject; + import org.eclipse.kapua.security.registration.RegistrationProcessor; import org.eclipse.kapua.security.registration.RegistrationProcessorProvider; import org.eclipse.kapua.security.registration.simple.SimpleRegistrationProcessor.Settings; @@ -27,11 +33,6 @@ import org.eclipse.kapua.service.user.UserFactory; import org.eclipse.kapua.service.user.UserService; -import javax.inject.Inject; -import java.util.Collections; -import java.util.Optional; -import java.util.Set; - public class SimpleRegistrationProcessorProvider implements RegistrationProcessorProvider { private final SimpleSetting simpleSetting; @@ -80,12 +81,9 @@ public Set createAll() { accountService, accountFactory, credentialService, - credentialFactory, deviceRegistryService, userService, - userFactory, accessInfoService, - accessInfoFactory, permissionFactory, simpleSetting, "preferred_username", diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionCreatorImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionCreatorImpl.java deleted file mode 100644 index a3a0fd9c6ab..00000000000 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionCreatorImpl.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2020, 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.service.authentication.credential.mfa.shiro; - -import org.eclipse.kapua.commons.model.AbstractKapuaEntityCreator; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.service.authentication.credential.mfa.MfaOption; -import org.eclipse.kapua.service.authentication.credential.mfa.MfaOptionCreator; - -/** - * {@link MfaOption} creator implementation. - */ -public class MfaOptionCreatorImpl extends AbstractKapuaEntityCreator implements MfaOptionCreator { - - private static final long serialVersionUID = -4619585500941519330L; - - private KapuaId userId; - - /** - * Constructor - * - * @param scopeId scope identifier - * @param userId user identifier - */ - public MfaOptionCreatorImpl(KapuaId scopeId, KapuaId userId) { - super(scopeId); - this.userId = userId; - } - - public MfaOptionCreatorImpl(KapuaId scopeId) { - super(scopeId); - } - - @Override - public KapuaId getUserId() { - return userId; - } - - @Override - public void setUserId(KapuaId userId) { - this.userId = userId; - } - -} diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionFactoryImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionFactoryImpl.java index 1deced40bf4..2bbbedadbc3 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionFactoryImpl.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionFactoryImpl.java @@ -17,7 +17,6 @@ import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.authentication.credential.mfa.MfaOption; -import org.eclipse.kapua.service.authentication.credential.mfa.MfaOptionCreator; import org.eclipse.kapua.service.authentication.credential.mfa.MfaOptionFactory; /** @@ -31,11 +30,6 @@ public MfaOption newEntity(KapuaId scopeId) { return new MfaOptionImpl(scopeId); } - @Override - public MfaOptionCreator newCreator(KapuaId scopeId) { - return new MfaOptionCreatorImpl(scopeId); - } - @Override public MfaOption clone(MfaOption mfaOption) { try { @@ -44,11 +38,4 @@ public MfaOption clone(MfaOption mfaOption) { throw new KapuaEntityCloneException(e, MfaOption.TYPE, mfaOption); } } - - @Override - public MfaOptionCreator newCreator(KapuaId scopeId, KapuaId userId) { - final MfaOptionCreatorImpl res = new MfaOptionCreatorImpl(scopeId); - res.setUserId(userId); - return res; - } } diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialCreatorImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialCreatorImpl.java deleted file mode 100644 index a821cc05d8f..00000000000 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialCreatorImpl.java +++ /dev/null @@ -1,127 +0,0 @@ -/******************************************************************************* - * 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.service.authentication.credential.shiro; - -import org.eclipse.kapua.commons.model.AbstractKapuaEntityCreator; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.service.authentication.credential.Credential; -import org.eclipse.kapua.service.authentication.credential.CredentialCreator; -import org.eclipse.kapua.service.authentication.credential.CredentialStatus; - -import java.util.Date; - -/** - * {@link CredentialCreator} implementation. - * - * @since 1.0.0 - */ -public class CredentialCreatorImpl extends AbstractKapuaEntityCreator implements CredentialCreator { - - private static final long serialVersionUID = -5020680413729882095L; - - private KapuaId userId; - private String credentialType; - private String credentialKey; - private Date expirationDate; - private CredentialStatus credentialStatus; - - /** - * Constructor. - * - * @param scopeId - * The {@link CredentialCreator#getScopeId()} - * @param userId - * The {@link CredentialCreator#getUserId()} - * @param credentialType - * The {@link CredentialCreator#getCredentialType()} - * @param credentialKey - * The plain {@link CredentialCreator#getCredentialPlainKey()} - * @param credentialStatus - * The {@link CredentialCreator#getCredentialStatus()} - * @param expirationDate - * The {@link CredentialCreator#getExpirationDate()} - * @since 1.0.0 - */ - public CredentialCreatorImpl(KapuaId scopeId, - KapuaId userId, - String credentialType, - String credentialKey, - CredentialStatus credentialStatus, - Date expirationDate) { - super(scopeId); - - this.userId = userId; - this.credentialType = credentialType; - this.credentialKey = credentialKey; - this.credentialStatus = credentialStatus; - this.expirationDate = expirationDate; - } - - /** - * Constructor. - * - * @param scopeId The {@link CredentialCreator#getScopeId()} - * @since 1.0.0 - */ - public CredentialCreatorImpl(KapuaId scopeId) { - super(scopeId); - } - - @Override - public KapuaId getUserId() { - return userId; - } - - public void setUserId(KapuaId userId) { - this.userId = userId; - } - - @Override - public String getCredentialType() { - return credentialType; - } - - public void setCredentialType(String credentialType) { - this.credentialType = credentialType; - } - - @Override - public String getCredentialPlainKey() { - return credentialKey; - } - - @Override - public void setCredentialPlainKey(String credentialKey) { - this.credentialKey = credentialKey; - } - - @Override - public Date getExpirationDate() { - return expirationDate; - } - - @Override - public void setExpirationDate(Date expirationDate) { - this.expirationDate = expirationDate; - } - - @Override - public CredentialStatus getCredentialStatus() { - return credentialStatus; - } - - @Override - public void setCredentialStatus(CredentialStatus credentialStatus) { - this.credentialStatus = credentialStatus; - } -} diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialFactoryImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialFactoryImpl.java index 1f309b75fc1..e5bc0c40154 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialFactoryImpl.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialFactoryImpl.java @@ -19,7 +19,6 @@ import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.authentication.credential.Credential; -import org.eclipse.kapua.service.authentication.credential.CredentialCreator; import org.eclipse.kapua.service.authentication.credential.CredentialFactory; import org.eclipse.kapua.service.authentication.credential.CredentialStatus; @@ -31,26 +30,15 @@ @Singleton public class CredentialFactoryImpl implements CredentialFactory { - @Override - public CredentialCreatorImpl newCreator(KapuaId scopeId, KapuaId userId, String credentialType, String credentialKey, CredentialStatus credentialStatus, Date expirationDate) { - return new CredentialCreatorImpl(scopeId, userId, credentialType, credentialKey, credentialStatus, expirationDate); - } - @Override public Credential newEntity(KapuaId scopeId) { return new CredentialImpl(scopeId); } - @Override public Credential newCredential(KapuaId scopeId, KapuaId userId, String credentialType, String credentialKey, CredentialStatus credentialStatus, Date expirationDate) { return new CredentialImpl(scopeId, userId, credentialType, credentialKey, credentialStatus, expirationDate); } - @Override - public CredentialCreator newCreator(KapuaId scopeId) { - return new CredentialCreatorImpl(scopeId); - } - @Override public Credential clone(Credential credential) { try { diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/shiro/AuthenticationServiceShiroImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/shiro/AuthenticationServiceShiroImpl.java index ad8534dd38d..78cfc1a1020 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/shiro/AuthenticationServiceShiroImpl.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/shiro/AuthenticationServiceShiroImpl.java @@ -568,7 +568,7 @@ private AccessToken createAccessToken(KapuaEid scopeId, KapuaEid userId) throws String jwt = generateJwt(scopeId, userId, now, tokenTtl, tokenId); // Persist token - AccessTokenCreator accessTokenCreator = accessTokenFactory.newCreator(scopeId, + AccessTokenCreator accessTokenCreator = new AccessTokenCreator(scopeId, userId, jwt, new Date(now.getTime() + tokenTtl), diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/token/shiro/AccessTokenCreatorImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/token/shiro/AccessTokenCreatorImpl.java deleted file mode 100644 index 3bee25a8045..00000000000 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/token/shiro/AccessTokenCreatorImpl.java +++ /dev/null @@ -1,119 +0,0 @@ -/******************************************************************************* - * 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.service.authentication.token.shiro; - -import java.util.Date; - -import org.eclipse.kapua.commons.model.AbstractKapuaEntityCreator; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.service.authentication.token.AccessToken; -import org.eclipse.kapua.service.authentication.token.AccessTokenCreator; - -/** - * Access token implementation - * - * @since 1.0 - * - */ -public class AccessTokenCreatorImpl extends AbstractKapuaEntityCreator implements AccessTokenCreator { - - private static final long serialVersionUID = -27718046815190710L; - - private String tokenId; - private KapuaId userId; - private Date expiresOn; - private String refreshToken; - private Date refreshExpiresOn; - private String tokenIdentifier; - - /** - * Constructor - * - * @param scopeId - */ - protected AccessTokenCreatorImpl(KapuaId scopeId) { - super(scopeId); - } - - @Override - public String getTokenId() { - return tokenId; - } - - @Override - public void setTokenId(String tokenId) { - this.tokenId = tokenId; - - } - - @Override - public KapuaId getUserId() { - return userId; - } - - @Override - public void setUserId(KapuaId userId) { - this.userId = userId; - } - - @Override - public Date getExpiresOn() { - return expiresOn; - } - - @Override - public void setExpiresOn(Date expiresOn) { - this.expiresOn = expiresOn; - } - - @Override - public String getRefreshToken() { - return refreshToken; - } - - @Override - public void setRefreshToken(String refreshToken) { - this.refreshToken = refreshToken; - - } - - @Override - public Date getRefreshExpiresOn() { - return refreshExpiresOn; - } - - @Override - public void setRefreshExpiresOn(Date refreshExpiresOn) { - this.refreshExpiresOn = refreshExpiresOn; - } - - /** - * Get the token identifier - * - * @since 2.0 - */ - public String getTokenIdentifier() { - return tokenIdentifier; - } - - /** - * Sets the token identifier - * - * @param tokenId the token id to set - * @since 2.0 - */ - public void setTokenIdentifier(String tokenId) { - this.tokenIdentifier=tokenId; - } - -} diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/token/shiro/AccessTokenFactoryImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/token/shiro/AccessTokenFactoryImpl.java index d23c792391f..38877992084 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/token/shiro/AccessTokenFactoryImpl.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authentication/token/shiro/AccessTokenFactoryImpl.java @@ -12,14 +12,11 @@ *******************************************************************************/ package org.eclipse.kapua.service.authentication.token.shiro; -import java.util.Date; - import javax.inject.Singleton; import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.authentication.token.AccessToken; -import org.eclipse.kapua.service.authentication.token.AccessTokenCreator; import org.eclipse.kapua.service.authentication.token.AccessTokenFactory; import org.eclipse.kapua.service.authentication.token.LoginInfo; @@ -31,30 +28,11 @@ @Singleton public class AccessTokenFactoryImpl implements AccessTokenFactory { - @Override - public AccessTokenCreatorImpl newCreator(KapuaId scopeId, KapuaId userId, String tokenId, Date expiresOn, String refreshToken, Date refreshExpiresOn, String tokenIdentifier) { - AccessTokenCreatorImpl accessTokenCreator = new AccessTokenCreatorImpl(scopeId); - - accessTokenCreator.setUserId(userId); - accessTokenCreator.setTokenId(tokenId); - accessTokenCreator.setExpiresOn(expiresOn); - accessTokenCreator.setRefreshToken(refreshToken); - accessTokenCreator.setRefreshExpiresOn(refreshExpiresOn); - accessTokenCreator.setTokenIdentifier(tokenIdentifier); - - return accessTokenCreator; - } - @Override public AccessToken newEntity(KapuaId scopeId) { return new AccessTokenImpl(scopeId); } - @Override - public AccessTokenCreator newCreator(KapuaId scopeId) { - return new AccessTokenCreatorImpl(scopeId); - } - @Override public AccessToken clone(AccessToken accessToken) { try { diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoCreatorImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoCreatorImpl.java deleted file mode 100644 index 6a941e9faf0..00000000000 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoCreatorImpl.java +++ /dev/null @@ -1,97 +0,0 @@ -/******************************************************************************* - * 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.service.authorization.access.shiro; - -import org.eclipse.kapua.commons.model.AbstractKapuaEntityCreator; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.service.authorization.access.AccessInfo; -import org.eclipse.kapua.service.authorization.access.AccessInfoCreator; -import org.eclipse.kapua.service.authorization.permission.Permission; - -import java.util.HashSet; -import java.util.Set; - -/** - * Access info creator service implementation. - * - * @since 1.0 - */ -public class AccessInfoCreatorImpl extends AbstractKapuaEntityCreator implements AccessInfoCreator { - - private static final long serialVersionUID = 972154225756734130L; - - private KapuaId userId; - private Set roleIds; - private Set permissions; - - /** - * Constructor - * - * @param accessInfo - */ - @SuppressWarnings({"rawtypes", "unchecked"}) - public AccessInfoCreatorImpl(AccessInfoCreator accessInfo) { - super((AbstractKapuaEntityCreator) accessInfo); - - setUserId(accessInfo.getUserId()); - setRoleIds(accessInfo.getRoleIds()); - setPermissions(accessInfo.getPermissions()); - } - - /** - * Constructor - * - * @param scopeId - */ - public AccessInfoCreatorImpl(KapuaId scopeId) { - super(scopeId); - } - - @Override - public void setUserId(KapuaId userId) { - this.userId = userId; - } - - @Override - public KapuaId getUserId() { - return userId; - } - - @Override - public void setRoleIds(Set roleIds) { - this.roleIds = roleIds; - } - - @Override - public Set getRoleIds() { - if (roleIds == null) { - roleIds = new HashSet<>(); - } - return roleIds; - } - - @Override - public void setPermissions(Set permissions) { - this.permissions = permissions; - - } - - @Override - public Set getPermissions() { - if (permissions == null) { - permissions = new HashSet<>(); - } - return permissions; - } - -} diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoFactoryImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoFactoryImpl.java index d14100952d7..09043c27cd8 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoFactoryImpl.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoFactoryImpl.java @@ -17,7 +17,6 @@ import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.authorization.access.AccessInfo; -import org.eclipse.kapua.service.authorization.access.AccessInfoCreator; import org.eclipse.kapua.service.authorization.access.AccessInfoFactory; /** @@ -33,11 +32,6 @@ public AccessInfo newEntity(KapuaId scopeId) { return new AccessInfoImpl(); } - @Override - public AccessInfoCreator newCreator(KapuaId scopeId) { - return new AccessInfoCreatorImpl(scopeId); - } - @Override public AccessInfo clone(AccessInfo accessInfo) { try { diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoServiceImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoServiceImpl.java index 02ae11ab102..2909f023952 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoServiceImpl.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoServiceImpl.java @@ -124,7 +124,7 @@ public AccessInfo create(AccessInfoCreator accessInfoCreator) if (!accessInfoCreator.getPermissions().isEmpty()) { for (Permission p : accessInfoCreator.getPermissions()) { - AccessPermissionCreator accessPermissionCreator = accessPermissionFactory.newCreator(accessInfoCreator.getScopeId()); + AccessPermissionCreator accessPermissionCreator = new AccessPermissionCreator(accessInfoCreator.getScopeId()); accessPermissionCreator.setAccessInfoId(accessInfo.getId()); accessPermissionCreator.setPermission(p); @@ -139,7 +139,7 @@ public AccessInfo create(AccessInfoCreator accessInfoCreator) if (!accessInfoCreator.getRoleIds().isEmpty()) { for (KapuaId roleId : accessInfoCreator.getRoleIds()) { - AccessRoleCreator accessRoleCreator = accessRoleFactory.newCreator(accessInfoCreator.getScopeId()); + AccessRoleCreator accessRoleCreator = new AccessRoleCreator(accessInfoCreator.getScopeId()); accessRoleCreator.setAccessInfoId(accessInfo.getId()); accessRoleCreator.setRoleId(roleId); diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionCreatorImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionCreatorImpl.java deleted file mode 100644 index 758b71ffdd3..00000000000 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionCreatorImpl.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * 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.service.authorization.access.shiro; - -import org.eclipse.kapua.commons.model.AbstractKapuaEntityCreator; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.service.authorization.access.AccessPermission; -import org.eclipse.kapua.service.authorization.access.AccessPermissionCreator; -import org.eclipse.kapua.service.authorization.permission.Permission; - -/** - * {@link AccessPermission} creator implementation. - * - * @since 1.0.0 - */ -public class AccessPermissionCreatorImpl extends AbstractKapuaEntityCreator implements AccessPermissionCreator { - - private static final long serialVersionUID = 972154225756734130L; - - private KapuaId accessInfo; - private Permission permission; - - /** - * Constructor - * - * @param scopeId - */ - public AccessPermissionCreatorImpl(KapuaId scopeId) { - super(scopeId); - } - - public KapuaId getAccessInfoId() { - return accessInfo; - } - - public void setAccessInfoId(KapuaId accessInfo) { - this.accessInfo = accessInfo; - } - - @SuppressWarnings("unchecked") - public Permission getPermission() { - return permission; - } - - public void setPermission(Permission permission) { - this.permission = permission; - } -} diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionFactoryImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionFactoryImpl.java index 28fe911811f..9d85d6a7fc3 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionFactoryImpl.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionFactoryImpl.java @@ -16,7 +16,6 @@ import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.authorization.access.AccessPermission; -import org.eclipse.kapua.service.authorization.access.AccessPermissionCreator; import org.eclipse.kapua.service.authorization.access.AccessPermissionFactory; /** @@ -32,11 +31,6 @@ public AccessPermission newEntity(KapuaId scopeId) { return new AccessPermissionImpl(scopeId); } - @Override - public AccessPermissionCreator newCreator(KapuaId scopeId) { - return new AccessPermissionCreatorImpl(scopeId); - } - @Override public AccessPermission clone(AccessPermission accessPermission) { return new AccessPermissionImpl(accessPermission); diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessRoleCreatorImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessRoleCreatorImpl.java deleted file mode 100644 index abfb6941875..00000000000 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessRoleCreatorImpl.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * 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.service.authorization.access.shiro; - -import org.eclipse.kapua.commons.model.AbstractKapuaEntityCreator; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.service.authorization.access.AccessRole; -import org.eclipse.kapua.service.authorization.access.AccessRoleCreator; - -/** - * {@link AccessRole} creator implementation. - * - * @since 1.0.0 - * - */ -public class AccessRoleCreatorImpl extends AbstractKapuaEntityCreator implements AccessRoleCreator { - - private static final long serialVersionUID = 972154225756734130L; - - private KapuaId accessInfo; - private KapuaId roleId; - - /** - * Constructor - * - * @param scopeId - */ - public AccessRoleCreatorImpl(KapuaId scopeId) { - super(scopeId); - } - - @Override - public KapuaId getAccessInfoId() { - return accessInfo; - } - - @Override - public void setAccessInfoId(KapuaId accessInfo) { - this.accessInfo = accessInfo; - } - - @Override - public KapuaId getRoleId() { - return roleId; - } - - @Override - public void setRoleId(KapuaId roleId) { - this.roleId = roleId; - } - -} diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessRoleFactoryImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessRoleFactoryImpl.java index d104f53185f..86a41a20f51 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessRoleFactoryImpl.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/access/shiro/AccessRoleFactoryImpl.java @@ -17,7 +17,6 @@ import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.authorization.access.AccessRole; -import org.eclipse.kapua.service.authorization.access.AccessRoleCreator; import org.eclipse.kapua.service.authorization.access.AccessRoleFactory; /** @@ -33,11 +32,6 @@ public AccessRole newEntity(KapuaId scopeId) { return new AccessRoleImpl(scopeId); } - @Override - public AccessRoleCreator newCreator(KapuaId scopeId) { - return new AccessRoleCreatorImpl(scopeId); - } - @Override public AccessRole clone(AccessRole accessRole) { try { diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/domain/shiro/DomainCreatorImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/domain/shiro/DomainCreatorImpl.java deleted file mode 100644 index 864f7c13005..00000000000 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/domain/shiro/DomainCreatorImpl.java +++ /dev/null @@ -1,89 +0,0 @@ -/******************************************************************************* - * 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.service.authorization.domain.shiro; - -import org.eclipse.kapua.commons.model.AbstractKapuaEntityCreator; -import org.eclipse.kapua.model.domain.Actions; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.service.authorization.domain.Domain; -import org.eclipse.kapua.service.authorization.domain.DomainCreator; - -import java.util.Set; - -/** - * {@link DomainCreator} implementation - * - * @since 1.0.0 - */ -public class DomainCreatorImpl extends AbstractKapuaEntityCreator implements DomainCreator { - - private static final long serialVersionUID = -4676187845961673421L; - - private String name; - - private String serviceName; - private Set actions; - private boolean groupable; - - /** - * Constructor - * - * @param name The name to set for this {@link DomainCreator}. - * @since 1.0.0 - */ - public DomainCreatorImpl(String name) { - super((KapuaId) null); - - setName(name); - } - - @Override - public void setName(String name) { - this.name = name; - } - - public void setServiceName(String serviceName) { - this.serviceName = serviceName; - } - - @Override - public String getName() { - return name; - } - - @Override - public String getServiceName() { - return serviceName; - } - - @Override - public Set getActions() { - return actions; - } - - @Override - public void setActions(Set actions) { - this.actions = actions; - } - - @Override - public boolean getGroupable() { - return groupable; - } - - @Override - public void setGroupable(boolean groupable) { - this.groupable = groupable; - } - -} diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/domain/shiro/DomainFactoryImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/domain/shiro/DomainFactoryImpl.java index 81cdedd3a3b..746d0c9d0f0 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/domain/shiro/DomainFactoryImpl.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/domain/shiro/DomainFactoryImpl.java @@ -14,10 +14,8 @@ import javax.inject.Singleton; -import org.apache.commons.lang.NotImplementedException; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.authorization.domain.Domain; -import org.eclipse.kapua.service.authorization.domain.DomainCreator; import org.eclipse.kapua.service.authorization.domain.DomainFactory; /** @@ -28,21 +26,11 @@ @Singleton public class DomainFactoryImpl implements DomainFactory { - @Override - public DomainCreator newCreator(String name) { - return new DomainCreatorImpl(name); - } - @Override public Domain newEntity(KapuaId scopeId) { return new DomainImpl(scopeId); } - @Override - public DomainCreator newCreator(KapuaId scopeId) { - throw new NotImplementedException(); - } - @Override public Domain clone(Domain domain) { return new DomainImpl(domain); diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/group/shiro/GroupCreatorImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/group/shiro/GroupCreatorImpl.java deleted file mode 100644 index bd09d40240e..00000000000 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/group/shiro/GroupCreatorImpl.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * 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.service.authorization.group.shiro; - -import org.eclipse.kapua.commons.model.AbstractKapuaNamedEntityCreator; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.service.authorization.domain.DomainCreator; -import org.eclipse.kapua.service.authorization.group.Group; -import org.eclipse.kapua.service.authorization.group.GroupCreator; - -/** - * {@link GroupCreator} implementation. - * - * @since 1.0.0 - */ -public class GroupCreatorImpl extends AbstractKapuaNamedEntityCreator implements GroupCreator { - - private static final long serialVersionUID = -4676187845961673421L; - - /** - * Constructor - * - * @param scopeId The scope id to set. - * @param name The name to set for this {@link DomainCreator}. - * @since 1.0.0 - */ - public GroupCreatorImpl(KapuaId scopeId, String name) { - super(scopeId); - setName(name); - } - - public GroupCreatorImpl(KapuaId scopeId) { - super(scopeId); - } -} diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/group/shiro/GroupFactoryImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/group/shiro/GroupFactoryImpl.java index 63e7d3ca80b..713da386c91 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/group/shiro/GroupFactoryImpl.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/group/shiro/GroupFactoryImpl.java @@ -17,7 +17,6 @@ import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.authorization.group.Group; -import org.eclipse.kapua.service.authorization.group.GroupCreator; import org.eclipse.kapua.service.authorization.group.GroupFactory; /** @@ -28,25 +27,11 @@ @Singleton public class GroupFactoryImpl implements GroupFactory { - @Override - public GroupCreator newCreator(KapuaId scopeId, String name) { - GroupCreator creator = newCreator(scopeId); - - creator.setName(name); - - return creator; - } - @Override public Group newEntity(KapuaId scopeId) { return new GroupImpl(scopeId); } - @Override - public GroupCreator newCreator(KapuaId scopeId) { - return new GroupCreatorImpl(scopeId); - } - @Override public Group clone(Group group) { try { diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RoleCreatorImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RoleCreatorImpl.java deleted file mode 100644 index 1a60cde28c9..00000000000 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RoleCreatorImpl.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * 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.service.authorization.role.shiro; - -import org.eclipse.kapua.commons.model.AbstractKapuaNamedEntityCreator; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.service.authorization.permission.Permission; -import org.eclipse.kapua.service.authorization.role.Role; -import org.eclipse.kapua.service.authorization.role.RoleCreator; - -import java.util.HashSet; -import java.util.Set; - -/** - * {@link RoleCreator} implementation. - * - * @since 1.0.0 - */ -public class RoleCreatorImpl extends AbstractKapuaNamedEntityCreator implements RoleCreator { - - private static final long serialVersionUID = 972154225756734130L; - - private Set permissions; - - /** - * Constructor - * - * @param scopeId The scope {@link KapuaId} - * @since 1.0.0 - */ - public RoleCreatorImpl(KapuaId scopeId) { - super(scopeId); - } - - @Override - public void setPermissions(Set permissions) { - this.permissions = permissions; - } - - @Override - public Set getPermissions() { - if (permissions == null) { - permissions = new HashSet<>(); - } - return permissions; - } - -} diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RoleFactoryImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RoleFactoryImpl.java index 0b0715573d5..fc6e5168e7e 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RoleFactoryImpl.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RoleFactoryImpl.java @@ -17,7 +17,6 @@ import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.authorization.role.Role; -import org.eclipse.kapua.service.authorization.role.RoleCreator; import org.eclipse.kapua.service.authorization.role.RoleFactory; import org.eclipse.kapua.service.authorization.role.RolePermission; @@ -34,11 +33,6 @@ public Role newEntity(KapuaId scopeId) { return new RoleImpl(scopeId); } - @Override - public RoleCreator newCreator(KapuaId scopeId) { - return new RoleCreatorImpl(scopeId); - } - @Override public RolePermission newRolePermission() { return new RolePermissionImpl(); diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RolePermissionCreatorImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RolePermissionCreatorImpl.java deleted file mode 100644 index 698bd0c1385..00000000000 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RolePermissionCreatorImpl.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * 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.service.authorization.role.shiro; - -import org.eclipse.kapua.commons.model.AbstractKapuaEntityCreator; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.service.authorization.permission.Permission; -import org.eclipse.kapua.service.authorization.role.RolePermission; -import org.eclipse.kapua.service.authorization.role.RolePermissionCreator; - -/** - * Role creator service implementation. - * - * @since 1.0 - */ -public class RolePermissionCreatorImpl extends AbstractKapuaEntityCreator implements RolePermissionCreator { - - private static final long serialVersionUID = 972154225756734130L; - - private KapuaId roleId; - private Permission permission; - - /** - * Costructor - * - * @param scopeId - */ - public RolePermissionCreatorImpl(KapuaId scopeId) { - super(scopeId); - } - - public KapuaId getRoleId() { - return roleId; - } - - public void setRoleId(KapuaId roleId) { - this.roleId = roleId; - } - - @SuppressWarnings("unchecked") - public Permission getPermission() { - return permission; - } - - public void setPermission(Permission permission) { - this.permission = permission; - } -} diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RolePermissionFactoryImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RolePermissionFactoryImpl.java index 28c63e38a7c..f7604cef62e 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RolePermissionFactoryImpl.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RolePermissionFactoryImpl.java @@ -16,7 +16,6 @@ import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.authorization.role.RolePermission; -import org.eclipse.kapua.service.authorization.role.RolePermissionCreator; import org.eclipse.kapua.service.authorization.role.RolePermissionFactory; /** @@ -32,11 +31,6 @@ public RolePermission newEntity(KapuaId scopeId) { return new RolePermissionImpl(scopeId); } - @Override - public RolePermissionCreator newCreator(KapuaId scopeId) { - return new RolePermissionCreatorImpl(scopeId); - } - @Override public RolePermission clone(RolePermission rolePermission) { return new RolePermissionImpl(rolePermission); diff --git a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RoleServiceImpl.java b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RoleServiceImpl.java index 51b1db3e6fd..e4120a15a4d 100644 --- a/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RoleServiceImpl.java +++ b/service/security/shiro/src/main/java/org/eclipse/kapua/service/authorization/role/shiro/RoleServiceImpl.java @@ -161,7 +161,7 @@ public Role create(RoleCreator roleCreator) throws KapuaException { if (!roleCreator.getPermissions().isEmpty()) { for (Permission p : roleCreator.getPermissions()) { - RolePermissionCreator rolePermissionCreator = rolePermissionFactory.newCreator(roleCreator.getScopeId()); + RolePermissionCreator rolePermissionCreator = new RolePermissionCreator(roleCreator.getScopeId()); rolePermissionCreator.setRoleId(createdRole.getId()); rolePermissionCreator.setPermission(p); diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionCreatorImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionCreatorTest.java similarity index 76% rename from service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionCreatorImplTest.java rename to service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionCreatorTest.java index 2f69e86301d..998f04018d8 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionCreatorImplTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionCreatorTest.java @@ -14,35 +14,35 @@ import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.qa.markers.junit.JUnitTests; +import org.eclipse.kapua.service.authentication.credential.mfa.MfaOptionCreator; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(JUnitTests.class) -public class MfaOptionCreatorImplTest { +public class MfaOptionCreatorTest { KapuaId[] scopeIds; KapuaId[] userIds; KapuaId[] newUserIds; - MfaOptionCreatorImpl mfaOptionCreatorImpl1; - MfaOptionCreatorImpl mfaOptionCreatorImpl2; + MfaOptionCreator mfaOptionCreatorImpl1; + MfaOptionCreator mfaOptionCreatorImpl2; @Before public void initialize() { - scopeIds = new KapuaId[]{null, KapuaId.ONE}; - userIds = new KapuaId[]{null, KapuaId.ONE}; - newUserIds = new KapuaId[]{null, KapuaId.ANY}; - mfaOptionCreatorImpl1 = new MfaOptionCreatorImpl(KapuaId.ONE, KapuaId.ONE); - mfaOptionCreatorImpl2 = new MfaOptionCreatorImpl(KapuaId.ONE); + scopeIds = new KapuaId[] { null, KapuaId.ONE }; + userIds = new KapuaId[] { null, KapuaId.ONE }; + newUserIds = new KapuaId[] { null, KapuaId.ANY }; + mfaOptionCreatorImpl1 = new MfaOptionCreator(KapuaId.ONE, KapuaId.ONE); + mfaOptionCreatorImpl2 = new MfaOptionCreator(KapuaId.ONE); } @Test public void mfaOptionCreatorImplScopeIdUserIdSecretKeyParametersTest() { for (KapuaId scopeId : scopeIds) { for (KapuaId userId : userIds) { - MfaOptionCreatorImpl mfaOptionCreatorImpl = new MfaOptionCreatorImpl(scopeId, userId); + MfaOptionCreator mfaOptionCreatorImpl = new MfaOptionCreator(scopeId, userId); Assert.assertEquals("Expected and actual values should be the same.", scopeId, mfaOptionCreatorImpl.getScopeId()); Assert.assertEquals("Expected and actual values should be the same.", userId, mfaOptionCreatorImpl.getUserId()); } @@ -52,7 +52,7 @@ public void mfaOptionCreatorImplScopeIdUserIdSecretKeyParametersTest() { @Test public void mfaOptionCreatorImplScopeIdParameterTest() { for (KapuaId scopeId : scopeIds) { - MfaOptionCreatorImpl mfaOptionCreatorImpl = new MfaOptionCreatorImpl(scopeId); + MfaOptionCreator mfaOptionCreatorImpl = new MfaOptionCreator(scopeId); Assert.assertEquals("Expected and actual values should be the same.", scopeId, mfaOptionCreatorImpl.getScopeId()); Assert.assertNull("Null expected.", mfaOptionCreatorImpl.getUserId()); } diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionFactoryImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionFactoryImplTest.java index 87767faaf19..4de136da130 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionFactoryImplTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionFactoryImplTest.java @@ -46,17 +46,6 @@ public void initialize() { modifiedOn = new Date(); } - @Test - public void newCreatorScopeIdUserIdMfaSecretKeyParametersTest() { - for (KapuaId scopeId : scopeIds) { - for (KapuaEid userId : userIds) { - MfaOptionCreator mfaOptionCreatorImpl = mfaOptionFactoryImpl.newCreator(scopeId, userId); - Assert.assertEquals("Expected and actual values should be the same.", scopeId, mfaOptionCreatorImpl.getScopeId()); - Assert.assertEquals("Expected and actual values should be the same.", userId, mfaOptionCreatorImpl.getUserId()); - } - } - } - @Test public void newEntityTest() { for (KapuaId scopeId : scopeIds) { @@ -68,7 +57,7 @@ public void newEntityTest() { @Test public void newCreatorScopeIdParameterTest() { for (KapuaId scopeId : scopeIds) { - MfaOptionCreator mfaOptionCreator = mfaOptionFactoryImpl.newCreator(scopeId); + MfaOptionCreator mfaOptionCreator = new MfaOptionCreator(scopeId); Assert.assertEquals("Expected and actual values should be the same.", scopeId, mfaOptionCreator.getScopeId()); } } diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialCreatorImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialCreatorTest.java similarity index 91% rename from service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialCreatorImplTest.java rename to service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialCreatorTest.java index d47070f30d8..65f711c8e9b 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialCreatorImplTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialCreatorTest.java @@ -12,26 +12,27 @@ *******************************************************************************/ package org.eclipse.kapua.service.authentication.credential.shiro; +import java.util.Date; + import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.qa.markers.junit.JUnitTests; +import org.eclipse.kapua.service.authentication.credential.CredentialCreator; import org.eclipse.kapua.service.authentication.credential.CredentialStatus; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.junit.experimental.categories.Category; -import java.util.Date; - @Category(JUnitTests.class) -public class CredentialCreatorImplTest { +public class CredentialCreatorTest { - CredentialCreatorImpl credentialCreatorImpl1, credentialCreatorImpl2; + CredentialCreator credentialCreatorImpl1, credentialCreatorImpl2; @Before public void initialize() { - credentialCreatorImpl1 = new CredentialCreatorImpl(KapuaId.ONE, KapuaId.ONE, "API_KEY", "credential key", CredentialStatus.ENABLED, new Date()); - credentialCreatorImpl2 = new CredentialCreatorImpl(KapuaId.ONE); + credentialCreatorImpl1 = new CredentialCreator(KapuaId.ONE, KapuaId.ONE, "API_KEY", "credential key", CredentialStatus.ENABLED, new Date()); + credentialCreatorImpl2 = new CredentialCreator(KapuaId.ONE); } @Test @@ -49,7 +50,7 @@ public void credentialCreatorImplMultipleParametersTest() { for (String credentialKey : credentialKeys) { for (CredentialStatus credentialStatus : credentialStatuses) { for (Date date : dates) { - CredentialCreatorImpl credentialCreatorImpl = new CredentialCreatorImpl(scopeId, userId, credentialType, credentialKey, credentialStatus, date); + CredentialCreator credentialCreatorImpl = new CredentialCreator(scopeId, userId, credentialType, credentialKey, credentialStatus, date); Assert.assertEquals("Expected and actual values should be the same.", scopeId, credentialCreatorImpl.getScopeId()); Assert.assertEquals("Expected and actual values should be the same.", userId, credentialCreatorImpl.getUserId()); Assert.assertEquals("Expected and actual values should be the same.", credentialType, credentialCreatorImpl.getCredentialType()); @@ -68,7 +69,7 @@ public void credentialCreatorImplMultipleParametersTest() { public void credentialCreatorImplScopeIdParameterTest() { KapuaId[] scopeIds = {null, KapuaId.ONE}; for (KapuaId scopeId : scopeIds) { - CredentialCreatorImpl credentialCreatorImpl = new CredentialCreatorImpl(scopeId); + CredentialCreator credentialCreatorImpl = new CredentialCreator(scopeId); Assert.assertEquals("Expected and actual values should be the same.", scopeId, credentialCreatorImpl.getScopeId()); Assert.assertNull("Null expected.", credentialCreatorImpl.getUserId()); Assert.assertNull("Null expected.", credentialCreatorImpl.getCredentialType()); diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialFactoryImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialFactoryImplTest.java index b34595873e2..acee9d63cd1 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialFactoryImplTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialFactoryImplTest.java @@ -63,7 +63,7 @@ public void newCreatorScopeIdUserIdMfaSecretKeyParametersTest() { for (String credentialKey : credentialKeys) { for (CredentialStatus credentialStatus : credentialStatuses) { for (Date date : dates) { - CredentialCreatorImpl credentialCreatorImpl = credentialFactoryImpl.newCreator(scopeId, userId, credentialType, credentialKey, credentialStatus, date); + CredentialCreator credentialCreatorImpl = new CredentialCreator(scopeId, userId, credentialType, credentialKey, credentialStatus, date); Assert.assertEquals("Expected and actual values should be the same.", scopeId, credentialCreatorImpl.getScopeId()); Assert.assertEquals("Expected and actual values should be the same.", userId, credentialCreatorImpl.getUserId()); Assert.assertEquals("Expected and actual values should be the same.", credentialType, credentialCreatorImpl.getCredentialType()); @@ -121,7 +121,7 @@ public void newQueryTest() { @Test public void newCreatorScopeIdParameterTest() { for (KapuaId scopeId : scopeIds) { - CredentialCreator credentialCreator = credentialFactoryImpl.newCreator(scopeId); + CredentialCreator credentialCreator = new CredentialCreator(scopeId); Assert.assertEquals("Expected and actual values should be the same.", scopeId, credentialCreator.getScopeId()); } } diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/token/shiro/AccessTokenCreatorImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/token/shiro/AccessTokenCreatorImplTest.java index 0d73bf4acce..89bf430b696 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/token/shiro/AccessTokenCreatorImplTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/token/shiro/AccessTokenCreatorImplTest.java @@ -12,87 +12,81 @@ *******************************************************************************/ package org.eclipse.kapua.service.authentication.token.shiro; +import java.util.Date; + import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.qa.markers.junit.JUnitTests; +import org.eclipse.kapua.service.authentication.token.AccessTokenCreator; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.junit.experimental.categories.Category; -import java.util.Date; - - @Category(JUnitTests.class) public class AccessTokenCreatorImplTest { - AccessTokenCreatorImpl accessTokenCreatorImpl; + AccessTokenCreator accessTokenCreator; @Before public void initialize() { - accessTokenCreatorImpl = new AccessTokenCreatorImpl(KapuaId.ONE); + accessTokenCreator = new AccessTokenCreator(KapuaId.ONE); } @Test public void accessTokenCreatorImplTest() { - Assert.assertEquals("Expected and actual values should be the same.", KapuaId.ONE, accessTokenCreatorImpl.getScopeId()); - } - - @Test - public void accessTokenCreatorImplNullTest() { - AccessTokenCreatorImpl accessTokenCreatorImpl = new AccessTokenCreatorImpl(null); - Assert.assertNull("Null expected.", accessTokenCreatorImpl.getScopeId()); + Assert.assertEquals("Expected and actual values should be the same.", KapuaId.ONE, accessTokenCreator.getScopeId()); } @Test public void setAndGetTokenIdTest() { - String[] tokenIds = {null, "", "!!tokenID-1", "#1(TOKEN.,/token id)9--99", "!$$ 1-2 ID//", "id_tokeN(....)<00>"}; + String[] tokenIds = { null, "", "!!tokenID-1", "#1(TOKEN.,/token id)9--99", "!$$ 1-2 ID//", "id_tokeN(....)<00>" }; - Assert.assertNull("Null expected.", accessTokenCreatorImpl.getTokenId()); + Assert.assertNull("Null expected.", accessTokenCreator.getTokenId()); for (String tokenId : tokenIds) { - accessTokenCreatorImpl.setTokenId(tokenId); - Assert.assertEquals("Expected and actual values should be the same.", tokenId, accessTokenCreatorImpl.getTokenId()); + accessTokenCreator.setTokenId(tokenId); + Assert.assertEquals("Expected and actual values should be the same.", tokenId, accessTokenCreator.getTokenId()); } } @Test public void setAndGetUserIdTest() { - KapuaId[] userIds = {null, KapuaId.ONE}; + KapuaId[] userIds = { null, KapuaId.ONE }; - Assert.assertNull("Null expected.", accessTokenCreatorImpl.getUserId()); + Assert.assertNull("Null expected.", accessTokenCreator.getUserId()); for (KapuaId userId : userIds) { - accessTokenCreatorImpl.setUserId(userId); - Assert.assertEquals("Expected and actual values should be the same.", userId, accessTokenCreatorImpl.getUserId()); + accessTokenCreator.setUserId(userId); + Assert.assertEquals("Expected and actual values should be the same.", userId, accessTokenCreator.getUserId()); } } @Test public void setAndGetExpiresOnTest() { - Date[] expiresOnDates = {null, new Date(), new Date(1L), new Date(9999999999999L)}; - Assert.assertNull("Null expected.", accessTokenCreatorImpl.getExpiresOn()); + Date[] expiresOnDates = { null, new Date(), new Date(1L), new Date(9999999999999L) }; + Assert.assertNull("Null expected.", accessTokenCreator.getExpiresOn()); for (Date expiresOnDate : expiresOnDates) { - accessTokenCreatorImpl.setExpiresOn(expiresOnDate); - Assert.assertEquals("Expected and actual values should be the same.", expiresOnDate, accessTokenCreatorImpl.getExpiresOn()); + accessTokenCreator.setExpiresOn(expiresOnDate); + Assert.assertEquals("Expected and actual values should be the same.", expiresOnDate, accessTokenCreator.getExpiresOn()); } } @Test public void setAndGetRefreshTokenTest() { - String[] refreshTokens = {null, "", "!!refreshToken-1", "#1(TOKEN.,/refresh token id)9--99", "!$$ 1-2 REFREsh//", "refresh_tokeN(....)<00>"}; + String[] refreshTokens = { null, "", "!!refreshToken-1", "#1(TOKEN.,/refresh token id)9--99", "!$$ 1-2 REFREsh//", "refresh_tokeN(....)<00>" }; - Assert.assertNull("Null expected.", accessTokenCreatorImpl.getRefreshToken()); + Assert.assertNull("Null expected.", accessTokenCreator.getRefreshToken()); for (String refreshToken : refreshTokens) { - accessTokenCreatorImpl.setRefreshToken(refreshToken); - Assert.assertEquals("Expected and actual values should be the same.", refreshToken, accessTokenCreatorImpl.getRefreshToken()); + accessTokenCreator.setRefreshToken(refreshToken); + Assert.assertEquals("Expected and actual values should be the same.", refreshToken, accessTokenCreator.getRefreshToken()); } } @Test public void setAndGetRefreshExpiresOnTest() { - Date[] refreshExpiresOnDates = {null, new Date(), new Date(1L), new Date(9999999999999L)}; - Assert.assertNull("Null expected.", accessTokenCreatorImpl.getRefreshExpiresOn()); + Date[] refreshExpiresOnDates = { null, new Date(), new Date(1L), new Date(9999999999999L) }; + Assert.assertNull("Null expected.", accessTokenCreator.getRefreshExpiresOn()); for (Date refreshExpiresOnDate : refreshExpiresOnDates) { - accessTokenCreatorImpl.setRefreshExpiresOn(refreshExpiresOnDate); - Assert.assertEquals("Expected and actual values should be the same.", refreshExpiresOnDate, accessTokenCreatorImpl.getRefreshExpiresOn()); + accessTokenCreator.setRefreshExpiresOn(refreshExpiresOnDate); + Assert.assertEquals("Expected and actual values should be the same.", refreshExpiresOnDate, accessTokenCreator.getRefreshExpiresOn()); } } } \ No newline at end of file diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/token/shiro/AccessTokenFactoryImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/token/shiro/AccessTokenFactoryImplTest.java index 1c95d23db85..12f7822f9ea 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/token/shiro/AccessTokenFactoryImplTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/token/shiro/AccessTokenFactoryImplTest.java @@ -19,7 +19,6 @@ import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.qa.markers.junit.JUnitTests; import org.eclipse.kapua.service.authentication.token.AccessToken; -import org.eclipse.kapua.service.authentication.token.AccessTokenCreator; import org.eclipse.kapua.service.authentication.token.LoginInfo; import org.junit.Assert; import org.junit.Before; @@ -54,33 +53,6 @@ public void initialize() { tokenIdentifiers = new String[] { "a2fe104f-5d03-4a09-a28d-817ebbc85901", "8e075aeb-be2a-49a7-8dec-346760375d19", "e71b2f52-e02e-4e24-9147-96674e3bf599" }; } - @Test - public void newCreatorMultipleParametersTest() { - for (KapuaId scopeId : scopeIds) { - for (KapuaEid userId : userIds) { - for (String tokenId : tokenIds) { - for (Date expiresOnDate : expiresOnDates) { - for (String refreshToken : refreshTokens) { - for (Date refreshExpiresOnDate : refreshExpiresOnDates) { - for (String tokenIdenfier : tokenIdentifiers) { - AccessTokenCreatorImpl accessTokenCreatorImpl = accessTokenFactoryImpl.newCreator(scopeId, userId, tokenId, expiresOnDate, refreshToken, refreshExpiresOnDate, - tokenIdenfier); - Assert.assertEquals("Expected and actual values should be the same.", scopeId, accessTokenCreatorImpl.getScopeId()); - Assert.assertEquals("Expected and actual values should be the same.", userId, accessTokenCreatorImpl.getUserId()); - Assert.assertEquals("Expected and actual values should be the same.", tokenId, accessTokenCreatorImpl.getTokenId()); - Assert.assertEquals("Expected and actual values should be the same.", expiresOnDate, accessTokenCreatorImpl.getExpiresOn()); - Assert.assertEquals("Expected and actual values should be the same.", refreshToken, accessTokenCreatorImpl.getRefreshToken()); - Assert.assertEquals("Expected and actual values should be the same.", refreshExpiresOnDate, accessTokenCreatorImpl.getRefreshExpiresOn()); - Assert.assertEquals("Expected and actual values should be the same.", tokenIdenfier, accessTokenCreatorImpl.getTokenIdentifier()); - } - } - } - } - } - } - } - } - @Test public void newEntityTest() { for (KapuaId scopeId : scopeIds) { @@ -89,14 +61,6 @@ public void newEntityTest() { } } - @Test - public void newCreatorScopeIdParameterTest() { - for (KapuaId scopeId : scopeIds) { - AccessTokenCreator accessTokenCreator = accessTokenFactoryImpl.newCreator(scopeId); - Assert.assertEquals("Expected and actual values should be the same.", scopeId, accessTokenCreator.getScopeId()); - } - } - @Test public void cloneTest() { Mockito.when(accessToken.getId()).thenReturn(KapuaId.ONE); diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoFactoryImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoFactoryImplTest.java index 6310df8bbba..6190dfb73d4 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoFactoryImplTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoFactoryImplTest.java @@ -19,7 +19,6 @@ import org.eclipse.kapua.model.query.KapuaQuery; import org.eclipse.kapua.qa.markers.junit.JUnitTests; import org.eclipse.kapua.service.authorization.access.AccessInfo; -import org.eclipse.kapua.service.authorization.access.AccessInfoCreator; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -66,20 +65,6 @@ public void newEntityNullTest() { Assert.assertNull("Null expected.", accessInfo.getScopeId()); } - @Test - public void newCreatorTest() { - AccessInfoCreator accessInfoCreator = accessInfoFactoryImpl.newCreator(scopeId); - - Assert.assertEquals("Expected and actual values should be the same.", scopeId, accessInfoCreator.getScopeId()); - } - - @Test - public void newCreatorNullTest() { - AccessInfoCreator accessInfoCreator = accessInfoFactoryImpl.newCreator(null); - - Assert.assertNull("Null expected.", accessInfoCreator.getScopeId()); - } - @Test public void newQueryTest() { KapuaQuery accessInfoQuery = new KapuaQuery(scopeId); diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionCreatorImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionCreatorTest.java similarity index 81% rename from service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionCreatorImplTest.java rename to service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionCreatorTest.java index 725ffc74ff2..f82926f7b65 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionCreatorImplTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionCreatorTest.java @@ -14,31 +14,31 @@ import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.qa.markers.junit.JUnitTests; +import org.eclipse.kapua.service.authorization.access.AccessPermissionCreator; import org.eclipse.kapua.service.authorization.permission.Permission; import org.junit.Assert; import org.junit.Test; import org.junit.experimental.categories.Category; import org.mockito.Mockito; - @Category(JUnitTests.class) -public class AccessPermissionCreatorImplTest { +public class AccessPermissionCreatorTest { @Test public void accessPermissionCreatorImplTest() { - AccessPermissionCreatorImpl accessPermissionCreatorImpl = new AccessPermissionCreatorImpl(KapuaId.ONE); + AccessPermissionCreator accessPermissionCreatorImpl = new AccessPermissionCreator(KapuaId.ONE); Assert.assertEquals("Expected and actual values should be the same.", KapuaId.ONE, accessPermissionCreatorImpl.getScopeId()); } @Test public void accessPermissionCreatorImplNullTest() { - AccessPermissionCreatorImpl accessPermissionCreatorImpl = new AccessPermissionCreatorImpl(null); + AccessPermissionCreator accessPermissionCreatorImpl = new AccessPermissionCreator(null); Assert.assertNull("Null expected.", accessPermissionCreatorImpl.getScopeId()); } @Test public void setAndGetAccessInfoIdTest() { - AccessPermissionCreatorImpl accessPermissionCreatorImpl = new AccessPermissionCreatorImpl(KapuaId.ONE); + AccessPermissionCreator accessPermissionCreatorImpl = new AccessPermissionCreator(KapuaId.ONE); Assert.assertNull("Null expected.", accessPermissionCreatorImpl.getAccessInfoId()); accessPermissionCreatorImpl.setAccessInfoId(KapuaId.ONE); @@ -49,7 +49,7 @@ public void setAndGetAccessInfoIdTest() { @Test public void setAndGetPermissionTest() { - AccessPermissionCreatorImpl accessPermissionCreatorImpl = new AccessPermissionCreatorImpl(KapuaId.ONE); + AccessPermissionCreator accessPermissionCreatorImpl = new AccessPermissionCreator(KapuaId.ONE); Permission permission = Mockito.mock(Permission.class); Assert.assertNull("Null expected.", accessPermissionCreatorImpl.getPermission()); diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionFactoryImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionFactoryImplTest.java index cca38d81e72..4682d028eb9 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionFactoryImplTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionFactoryImplTest.java @@ -15,7 +15,6 @@ import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.qa.markers.junit.JUnitTests; import org.eclipse.kapua.service.authorization.access.AccessPermission; -import org.eclipse.kapua.service.authorization.access.AccessPermissionCreator; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -41,13 +40,6 @@ public void newEntityTest() { } } - @Test - public void newCreatorTest() { - for (KapuaId scopeId : scopeIds) { - Assert.assertTrue("True expected.", accessPermissionFactoryImpl.newCreator(scopeId) instanceof AccessPermissionCreator); - } - } - @Test public void cloneTest() { AccessPermission accessPermission = Mockito.mock(AccessPermission.class); diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessRoleCreatorImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessRoleCreatorTest.java similarity index 88% rename from service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessRoleCreatorImplTest.java rename to service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessRoleCreatorTest.java index 99538c02f5c..bd33c02a18a 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessRoleCreatorImplTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessRoleCreatorTest.java @@ -14,6 +14,7 @@ import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.qa.markers.junit.JUnitTests; +import org.eclipse.kapua.service.authorization.access.AccessRoleCreator; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -21,13 +22,13 @@ @Category(JUnitTests.class) -public class AccessRoleCreatorImplTest { +public class AccessRoleCreatorTest { - AccessRoleCreatorImpl accessRoleCreatorImpl; + AccessRoleCreator accessRoleCreatorImpl; @Before public void initialize() { - accessRoleCreatorImpl = new AccessRoleCreatorImpl(KapuaId.ONE); + accessRoleCreatorImpl = new AccessRoleCreator(KapuaId.ONE); } @Test @@ -39,7 +40,7 @@ public void accessRoleCreatorImplTest() { @Test public void accessRoleCreatorImplNullTest() { - AccessRoleCreatorImpl accessRoleCreatorImplNullId = new AccessRoleCreatorImpl(null); + AccessRoleCreator accessRoleCreatorImplNullId = new AccessRoleCreator(null); Assert.assertNull("Null expected.", accessRoleCreatorImplNullId.getScopeId()); Assert.assertNull("Null expected.", accessRoleCreatorImplNullId.getAccessInfoId()); Assert.assertNull("Null expected.", accessRoleCreatorImplNullId.getRoleId()); diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessRoleFactoryImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessRoleFactoryImplTest.java index 07aa0e22aef..46dbf1f62a7 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessRoleFactoryImplTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessRoleFactoryImplTest.java @@ -60,13 +60,13 @@ public void newEntityNullTest() { @Test public void newCreatorTest() { - AccessRoleCreator accessRoleCreator = accessRoleFactoryImpl.newCreator(KapuaId.ONE); + AccessRoleCreator accessRoleCreator = new AccessRoleCreator(KapuaId.ONE); Assert.assertEquals("Expected and actual values should be the same.", KapuaId.ONE, accessRoleCreator.getScopeId()); } @Test public void newCreatorNullTest() { - AccessRoleCreator accessRoleCreator = accessRoleFactoryImpl.newCreator(null); + AccessRoleCreator accessRoleCreator = new AccessRoleCreator(null); Assert.assertNull("Null expected.", accessRoleCreator.getScopeId()); } diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/domain/shiro/DomainCreatorImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/domain/shiro/DomainCreatorTest.java similarity index 74% rename from service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/domain/shiro/DomainCreatorImplTest.java rename to service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/domain/shiro/DomainCreatorTest.java index 742a29aaf85..66274b69092 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/domain/shiro/DomainCreatorImplTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/domain/shiro/DomainCreatorTest.java @@ -12,25 +12,27 @@ *******************************************************************************/ package org.eclipse.kapua.service.authorization.domain.shiro; +import java.util.HashSet; +import java.util.Set; + import org.eclipse.kapua.model.domain.Actions; +import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.qa.markers.junit.JUnitTests; +import org.eclipse.kapua.service.authorization.domain.DomainCreator; import org.junit.Assert; import org.junit.Test; import org.junit.experimental.categories.Category; -import java.util.HashSet; -import java.util.Set; - - @Category(JUnitTests.class) -public class DomainCreatorImplTest { +public class DomainCreatorTest { @Test public void domainCreatorImplTest() { - String[] names = {"", " na123)(&*^&NAME <>", "Na-,,..,,Me name ---", "-&^454536 na___,,12 NAME name ", "! 2#@ na meNEMA 2323", "12&^%4 ,,,. '|<>*(", " ,,123name;;'", "12#name--765 ,.aaa!!#$%^<> "}; + String[] names = { "", " na123)(&*^&NAME <>", "Na-,,..,,Me name ---", "-&^454536 na___,,12 NAME name ", "! 2#@ na meNEMA 2323", "12&^%4 ,,,. '|<>*(", " ,,123name;;'", + "12#name--765 ,.aaa!!#$%^<> " }; for (String name : names) { - DomainCreatorImpl domainCreatorImpl = new DomainCreatorImpl(name); + DomainCreator domainCreatorImpl = new DomainCreator(name); Assert.assertNull("Null expected.", domainCreatorImpl.getScopeId()); Assert.assertEquals("Expected and actual values should be the same.", name, domainCreatorImpl.getName()); Assert.assertNull("Null expected.", domainCreatorImpl.getActions()); @@ -40,7 +42,7 @@ public void domainCreatorImplTest() { @Test public void domainCreatorImplNullTest() { - DomainCreatorImpl domainCreatorImpl = new DomainCreatorImpl(null); + DomainCreator domainCreatorImpl = new DomainCreator((KapuaId) null); Assert.assertNull("Null expected.", domainCreatorImpl.getScopeId()); Assert.assertNull("Null expected.", domainCreatorImpl.getName()); Assert.assertNull("Null expected.", domainCreatorImpl.getActions()); @@ -49,9 +51,10 @@ public void domainCreatorImplNullTest() { @Test public void setAndGetNameTest() { - String[] newNames = {"", " na123)(&*^&NAME NEWname <>", "newNa-,,..,,Me name NEW NEW---", "-&^454536 na___,,12 NAME New name ", "! 2#@ na meNewNAME 23NeW23", "12&^%4 ,,,. '|*(", " ,,123name;;'", "12#name-new-name765 ,.aaa!!#$%^<> "}; + String[] newNames = { "", " na123)(&*^&NAME NEWname <>", "newNa-,,..,,Me name NEW NEW---", "-&^454536 na___,,12 NAME New name ", "! 2#@ na meNewNAME 23NeW23", + "12&^%4 ,,,. '|*(", " ,,123name;;'", "12#name-new-name765 ,.aaa!!#$%^<> " }; - DomainCreatorImpl domainCreatorImpl = new DomainCreatorImpl("name"); + DomainCreator domainCreatorImpl = new DomainCreator("name"); for (String newName : newNames) { domainCreatorImpl.setName(newName); Assert.assertEquals("Expected and actual values should be the same.", newName, domainCreatorImpl.getName()); @@ -63,7 +66,7 @@ public void setAndGetNameTest() { @Test public void setAndGetActionsTest() { Set actions = new HashSet<>(); - DomainCreatorImpl domainCreatorImpl = new DomainCreatorImpl("name"); + DomainCreator domainCreatorImpl = new DomainCreator("name"); domainCreatorImpl.setActions(actions); Assert.assertTrue("True expected", domainCreatorImpl.getActions().isEmpty()); @@ -82,8 +85,8 @@ public void setAndGetActionsTest() { @Test public void setAndGetGroupableTest() { - boolean[] groupables = {true, false}; - DomainCreatorImpl domainCreatorImpl = new DomainCreatorImpl("name"); + boolean[] groupables = { true, false }; + DomainCreator domainCreatorImpl = new DomainCreator("name"); for (boolean groupable : groupables) { domainCreatorImpl.setGroupable(groupable); diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/domain/shiro/DomainFactoryImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/domain/shiro/DomainFactoryImplTest.java index 6dffdc20b93..12b6afce9ab 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/domain/shiro/DomainFactoryImplTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/domain/shiro/DomainFactoryImplTest.java @@ -16,12 +16,10 @@ import java.util.HashSet; import java.util.Set; -import org.apache.commons.lang.NotImplementedException; import org.eclipse.kapua.model.domain.Actions; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.qa.markers.junit.JUnitTests; import org.eclipse.kapua.service.authorization.domain.Domain; -import org.eclipse.kapua.service.authorization.domain.DomainCreator; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -38,25 +36,6 @@ public void initialize() { domainFactoryImpl = new DomainFactoryImpl(); } - @Test - public void newCreatorNameParameterTest() { - String[] names = { "", " na123)(&*^&NAME <>", "Na-,,..,,Me name ---", "-&^454536 na___,,12 NAME name ", "! 2#@ na meNEMA 2323", "12&^%4 ,,,. '|<>*(", " ,,123name;;'", - "12#name--765 ,.aaa!!#$%^<> " }; - - for (String name : names) { - DomainCreator domainCreator = domainFactoryImpl.newCreator(name); - Assert.assertEquals("Expected and actual values should be the same.", name, domainCreator.getName()); - Assert.assertNull("Null expected.", domainCreator.getScopeId()); - } - } - - @Test - public void newCreatorNullNameParameterTest() { - DomainCreator domainCreator = domainFactoryImpl.newCreator((String) null); - Assert.assertNull("Null expected.", domainCreator.getName()); - Assert.assertNull("Null expected.", domainCreator.getScopeId()); - } - @Test public void newEntityTest() { Domain domain = domainFactoryImpl.newEntity(KapuaId.ONE); @@ -69,16 +48,6 @@ public void newEntityNullTest() { Assert.assertNull("Null expected.", domain.getScopeId()); } - @Test(expected = NotImplementedException.class) - public void newCreatorScopeIdParameterTest() { - domainFactoryImpl.newCreator(KapuaId.ONE); - } - - @Test(expected = NotImplementedException.class) - public void newCreatorNullScopeIdParameterTest() { - domainFactoryImpl.newCreator((KapuaId) null); - } - @Test public void cloneTest() { Domain domain = Mockito.mock(Domain.class); diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/group/shiro/GroupCreatorImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/group/shiro/GroupCreatorTest.java similarity index 77% rename from service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/group/shiro/GroupCreatorImplTest.java rename to service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/group/shiro/GroupCreatorTest.java index 56d52b01540..993f8f7e541 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/group/shiro/GroupCreatorImplTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/group/shiro/GroupCreatorTest.java @@ -14,28 +14,29 @@ import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.qa.markers.junit.JUnitTests; +import org.eclipse.kapua.service.authorization.group.GroupCreator; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(JUnitTests.class) -public class GroupCreatorImplTest { +public class GroupCreatorTest { String[] names; KapuaId scopeId; @Before public void initialize() { - names = new String[]{"", " na123)(&*^&NAME <>", "Na-,,..,,Me name ---", "-&^454536 na___,,12 NAME name ", "! 2#@ na meNEMA 2323", "12&^%4 ,,,. '|<>*(", " ,,123name;;'", "12#name--765 ,.aaa!!#$%^<> "}; + names = new String[] { "", " na123)(&*^&NAME <>", "Na-,,..,,Me name ---", "-&^454536 na___,,12 NAME name ", "! 2#@ na meNEMA 2323", "12&^%4 ,,,. '|<>*(", " ,,123name;;'", + "12#name--765 ,.aaa!!#$%^<> " }; scopeId = KapuaId.ONE; } @Test public void groupCreatorImplScopeIdNameParametersTest() { for (String name : names) { - GroupCreatorImpl groupCreatorImpl = new GroupCreatorImpl(scopeId, name); + GroupCreator groupCreatorImpl = new GroupCreator(scopeId, name); Assert.assertEquals("Expected and actual values should be the same.", scopeId, groupCreatorImpl.getScopeId()); Assert.assertEquals("Expected and actual values should be the same.", name, groupCreatorImpl.getName()); } @@ -44,7 +45,7 @@ public void groupCreatorImplScopeIdNameParametersTest() { @Test public void groupCreatorImplNullScopeIdNameParametersTest() { for (String name : names) { - GroupCreatorImpl groupCreatorImpl = new GroupCreatorImpl(null, name); + GroupCreator groupCreatorImpl = new GroupCreator(null, name); Assert.assertNull("Null expected.", groupCreatorImpl.getScopeId()); Assert.assertEquals("Expected and actual values should be the same.", name, groupCreatorImpl.getName()); } @@ -52,28 +53,28 @@ public void groupCreatorImplNullScopeIdNameParametersTest() { @Test public void groupCreatorImplScopeIdNullNameParametersTest() { - GroupCreatorImpl groupCreatorImpl = new GroupCreatorImpl(scopeId, null); + GroupCreator groupCreatorImpl = new GroupCreator(scopeId, null); Assert.assertEquals("Expected and actual values should be the same.", scopeId, groupCreatorImpl.getScopeId()); Assert.assertNull("Null expected.", groupCreatorImpl.getName()); } @Test public void groupCreatorImplNullScopeIdNullNameParametersTest() { - GroupCreatorImpl groupCreatorImpl = new GroupCreatorImpl(null, null); + GroupCreator groupCreatorImpl = new GroupCreator(null, null); Assert.assertNull("Null expected.", groupCreatorImpl.getScopeId()); Assert.assertNull("Null expected.", groupCreatorImpl.getName()); } @Test public void groupCreatorImplScopeIdParameterTest() { - GroupCreatorImpl groupCreatorImpl = new GroupCreatorImpl(scopeId); + GroupCreator groupCreatorImpl = new GroupCreator(scopeId); Assert.assertEquals("Expected and actual values should be the same.", scopeId, groupCreatorImpl.getScopeId()); Assert.assertNull("Null expected.", groupCreatorImpl.getName()); } @Test public void groupCreatorImplNullScopeIdParameterTest() { - GroupCreatorImpl groupCreatorImpl = new GroupCreatorImpl(null); + GroupCreator groupCreatorImpl = new GroupCreator(null); Assert.assertNull("Null expected.", groupCreatorImpl.getScopeId()); Assert.assertNull("Null expected.", groupCreatorImpl.getName()); } diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/group/shiro/GroupFactoryImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/group/shiro/GroupFactoryImplTest.java index 1749b5c0181..aae6877d863 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/group/shiro/GroupFactoryImplTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/group/shiro/GroupFactoryImplTest.java @@ -58,7 +58,7 @@ public void initialize() { @Test public void newCreatorScopeIdNameParametersTest() { for (String name : names) { - GroupCreator groupCreator = groupFactoryImpl.newCreator(scopeId, name); + GroupCreator groupCreator = new GroupCreator(scopeId, name); Assert.assertEquals("Expected and actual values should be the same.", name, groupCreator.getName()); Assert.assertEquals("Expected and actual values should be the same.", scopeId, groupCreator.getScopeId()); } @@ -67,7 +67,7 @@ public void newCreatorScopeIdNameParametersTest() { @Test public void newCreatorNullScopeIdNameParametersTest() { for (String name : names) { - GroupCreator groupCreator = groupFactoryImpl.newCreator(null, name); + GroupCreator groupCreator = new GroupCreator(null, name); Assert.assertEquals("Expected and actual values should be the same.", name, groupCreator.getName()); Assert.assertNull("Null expected.", groupCreator.getScopeId()); } @@ -75,7 +75,7 @@ public void newCreatorNullScopeIdNameParametersTest() { @Test public void newCreatorScopeIdNullNameParametersTest() { - GroupCreator groupCreator = groupFactoryImpl.newCreator(scopeId, null); + GroupCreator groupCreator = new GroupCreator(scopeId, null); Assert.assertNull("Null expected.", groupCreator.getName()); Assert.assertEquals("Expected and actual values should be the same.", scopeId, groupCreator.getScopeId()); } @@ -94,13 +94,13 @@ public void newEntityNullTest() { @Test public void newCreatorTest() { - GroupCreator groupCreator = groupFactoryImpl.newCreator(scopeId); + GroupCreator groupCreator = new GroupCreator(scopeId); Assert.assertEquals("Expected and actual values should be the same.", scopeId, groupCreator.getScopeId()); } @Test public void newCreatorNullTest() { - GroupCreator groupCreator = groupFactoryImpl.newCreator(null); + GroupCreator groupCreator = new GroupCreator(null); Assert.assertNull("Null expected.", groupCreator.getScopeId()); } diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/role/shiro/RoleCreatorImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/role/shiro/RoleCreatorTest.java similarity index 91% rename from service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/role/shiro/RoleCreatorImplTest.java rename to service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/role/shiro/RoleCreatorTest.java index d6c96fb0afd..beaed5e7233 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/role/shiro/RoleCreatorImplTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/role/shiro/RoleCreatorTest.java @@ -12,29 +12,30 @@ *******************************************************************************/ package org.eclipse.kapua.service.authorization.role.shiro; +import java.util.HashSet; +import java.util.Set; + import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.qa.markers.junit.JUnitTests; import org.eclipse.kapua.service.authorization.permission.Permission; +import org.eclipse.kapua.service.authorization.role.RoleCreator; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.junit.experimental.categories.Category; import org.mockito.Mockito; -import java.util.HashSet; -import java.util.Set; - @Category(JUnitTests.class) -public class RoleCreatorImplTest { +public class RoleCreatorTest { - RoleCreatorImpl roleCreatorImpl; + RoleCreator roleCreatorImpl; Set permissions; Permission permission1, permission2; @Before public void initialize() { - roleCreatorImpl = new RoleCreatorImpl(KapuaId.ONE); + roleCreatorImpl = new RoleCreator(KapuaId.ONE); permissions = new HashSet<>(); permission1 = Mockito.mock(Permission.class); permission2 = Mockito.mock(Permission.class); @@ -44,7 +45,7 @@ public void initialize() { public void roleCreatorImplTest() { KapuaId[] scopeIds = {KapuaId.ONE, null}; for (KapuaId scopeId : scopeIds) { - RoleCreatorImpl roleCreatorImpl = new RoleCreatorImpl(scopeId); + RoleCreator roleCreatorImpl = new RoleCreator(scopeId); Assert.assertEquals("Expected and actual values should be the same.", scopeId, roleCreatorImpl.getScopeId()); Assert.assertTrue("True expected.", roleCreatorImpl.getPermissions().isEmpty()); } diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/role/shiro/RoleFactoryImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/role/shiro/RoleFactoryImplTest.java index 38f079e9a71..4a46dc9d462 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/role/shiro/RoleFactoryImplTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/role/shiro/RoleFactoryImplTest.java @@ -17,7 +17,6 @@ import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.qa.markers.junit.JUnitTests; import org.eclipse.kapua.service.authorization.role.Role; -import org.eclipse.kapua.service.authorization.role.RoleCreator; import org.eclipse.kapua.service.authorization.role.RolePermission; import org.junit.Assert; import org.junit.Before; @@ -64,18 +63,6 @@ public void newEntityNullTest() { Assert.assertNull("Null expected.", roleFactoryImpl.newEntity(null).getScopeId()); } - @Test - public void newCreatorTest() { - Assert.assertTrue("True expected.", roleFactoryImpl.newCreator(scopeId) instanceof RoleCreator); - Assert.assertEquals("Expected and actual values should be the same.", scopeId, roleFactoryImpl.newCreator(scopeId).getScopeId()); - } - - @Test - public void newCreatorNullTest() { - Assert.assertTrue("True expected.", roleFactoryImpl.newCreator(null) instanceof RoleCreator); - Assert.assertNull("Null expected.", roleFactoryImpl.newCreator(null).getScopeId()); - } - @Test public void newRolePermissionTest() { Assert.assertTrue("True expected.", roleFactoryImpl.newRolePermission() instanceof RolePermission); diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/role/shiro/RolePermissionCreatorImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/role/shiro/RolePermissionCreatorTest.java similarity index 61% rename from service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/role/shiro/RolePermissionCreatorImplTest.java rename to service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/role/shiro/RolePermissionCreatorTest.java index c005528bd66..0f9433c3433 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/role/shiro/RolePermissionCreatorImplTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/role/shiro/RolePermissionCreatorTest.java @@ -15,45 +15,45 @@ import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.qa.markers.junit.JUnitTests; import org.eclipse.kapua.service.authorization.permission.Permission; +import org.eclipse.kapua.service.authorization.role.RolePermissionCreator; import org.junit.Assert; import org.junit.Test; import org.junit.experimental.categories.Category; import org.mockito.Mockito; - @Category(JUnitTests.class) -public class RolePermissionCreatorImplTest { +public class RolePermissionCreatorTest { @Test - public void rolePermissionCreatorImplTest() { - KapuaId[] scopeIds = {null, KapuaId.ANY}; + public void rolePermissionCreatorTest() { + KapuaId[] scopeIds = { null, KapuaId.ANY }; for (KapuaId scopeId : scopeIds) { - RolePermissionCreatorImpl rolePermissionCreatorImpl = new RolePermissionCreatorImpl(scopeId); - Assert.assertEquals("Expected and actual values should be the same.", scopeId, rolePermissionCreatorImpl.getScopeId()); - Assert.assertNull("Null expected.", rolePermissionCreatorImpl.getRoleId()); - Assert.assertNull("Null expected.", rolePermissionCreatorImpl.getPermission()); + RolePermissionCreator rolePermissionCreator = new RolePermissionCreator(scopeId); + Assert.assertEquals("Expected and actual values should be the same.", scopeId, rolePermissionCreator.getScopeId()); + Assert.assertNull("Null expected.", rolePermissionCreator.getRoleId()); + Assert.assertNull("Null expected.", rolePermissionCreator.getPermission()); } } @Test public void setAndGetRoleIdTest() { - KapuaId[] roleIds = {null, KapuaId.ONE}; - RolePermissionCreatorImpl rolePermissionCreatorImpl = new RolePermissionCreatorImpl(KapuaId.ONE); + KapuaId[] roleIds = { null, KapuaId.ONE }; + RolePermissionCreator rolePermissionCreator = new RolePermissionCreator(KapuaId.ONE); for (KapuaId roleId : roleIds) { - rolePermissionCreatorImpl.setRoleId(roleId); - Assert.assertEquals("Expected and actual values should be the same.", roleId, rolePermissionCreatorImpl.getRoleId()); + rolePermissionCreator.setRoleId(roleId); + Assert.assertEquals("Expected and actual values should be the same.", roleId, rolePermissionCreator.getRoleId()); } } @Test public void setAndGetPermissionTest() { - Permission[] permissions = {null, Mockito.mock(Permission.class)}; - RolePermissionCreatorImpl rolePermissionCreatorImpl = new RolePermissionCreatorImpl(KapuaId.ONE); + Permission[] permissions = { null, Mockito.mock(Permission.class) }; + RolePermissionCreator rolePermissionCreator = new RolePermissionCreator(KapuaId.ONE); for (Permission permission : permissions) { - rolePermissionCreatorImpl.setPermission(permission); - Assert.assertEquals("Expected and actual values should be the same.", permission, rolePermissionCreatorImpl.getPermission()); + rolePermissionCreator.setPermission(permission); + Assert.assertEquals("Expected and actual values should be the same.", permission, rolePermissionCreator.getPermission()); } } } \ No newline at end of file diff --git a/service/security/test-steps/src/main/java/org/eclipse/kapua/service/authentication/steps/AuthenticationServiceSteps.java b/service/security/test-steps/src/main/java/org/eclipse/kapua/service/authentication/steps/AuthenticationServiceSteps.java index 0a28f067097..0d246c3b46f 100644 --- a/service/security/test-steps/src/main/java/org/eclipse/kapua/service/authentication/steps/AuthenticationServiceSteps.java +++ b/service/security/test-steps/src/main/java/org/eclipse/kapua/service/authentication/steps/AuthenticationServiceSteps.java @@ -12,12 +12,12 @@ *******************************************************************************/ package org.eclipse.kapua.service.authentication.steps; -import com.google.inject.Singleton; -import io.cucumber.java.After; -import io.cucumber.java.Before; -import io.cucumber.java.Scenario; -import io.cucumber.java.en.Given; -import io.cucumber.java.en.When; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.inject.Inject; + import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.commons.security.KapuaSecurityUtils; import org.eclipse.kapua.locator.KapuaLocator; @@ -45,10 +45,13 @@ import org.eclipse.kapua.service.user.UserService; import org.junit.Assert; -import javax.inject.Inject; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import com.google.inject.Singleton; + +import io.cucumber.java.After; +import io.cucumber.java.Before; +import io.cucumber.java.Scenario; +import io.cucumber.java.en.Given; +import io.cucumber.java.en.When; // Implementation of Gherkin steps used to test miscellaneous Shiro // authorization functionality. @@ -99,7 +102,7 @@ public void setServices() { @When("I create default test-user") public void createDefaultUser() throws KapuaException { - UserCreator userCreator = userFactory.newCreator(KapuaId.ONE, "test-user"); + UserCreator userCreator = new UserCreator(KapuaId.ONE, "test-user"); User user = userService.create(userCreator); stepData.put("User", user); } @@ -192,7 +195,7 @@ public void createPasswordCredential(String password) throws Exception { primeException(); User user = (User) stepData.get("User"); - CredentialCreator credentialCreator = credentialFactory.newCreator(user.getScopeId(), user.getId(), "PASSWORD", password, CredentialStatus.ENABLED, null); + CredentialCreator credentialCreator = new CredentialCreator(user.getScopeId(), user.getId(), "PASSWORD", password, CredentialStatus.ENABLED, null); try { Credential credential = credentialService.create(credentialCreator); stepData.put(BasicSteps.LAST_CREDENTIAL_ID, credential.getId()); @@ -201,7 +204,6 @@ public void createPasswordCredential(String password) throws Exception { } } - @When("I change the user credential password with old password {string} and new password {string}") public void changeUserPasswordCredential(String oldPassword, String newPassword) throws Exception { primeException(); @@ -217,7 +219,6 @@ public void changeUserPasswordCredential(String oldPassword, String newPassword) } } - @When("I reset the last created credential password, with the new password {string}") public void resetUserPasswordCredentialPassword(String newPassword) throws Exception { primeException(); diff --git a/service/security/test-steps/src/main/java/org/eclipse/kapua/service/authorization/steps/AuthorizationServiceSteps.java b/service/security/test-steps/src/main/java/org/eclipse/kapua/service/authorization/steps/AuthorizationServiceSteps.java index 20e4e347ecb..2043bb199c1 100644 --- a/service/security/test-steps/src/main/java/org/eclipse/kapua/service/authorization/steps/AuthorizationServiceSteps.java +++ b/service/security/test-steps/src/main/java/org/eclipse/kapua/service/authorization/steps/AuthorizationServiceSteps.java @@ -247,7 +247,7 @@ public void createAListOfRoles(List roles) throws Exception { permissions.add(permissionFactory.newPermission(domain.getDomain().getName(), tmpAct, tmpRole.getScopeId())); } } - roleCreator = roleFactory.newCreator(tmpRole.getScopeId()); + roleCreator = new RoleCreator(tmpRole.getScopeId()); roleCreator.setName(tmpRole.getName()); roleCreator.setPermissions(permissions); try { @@ -274,7 +274,7 @@ public void createAListOfRolePermissions(List perms) throws E Assert.assertNotNull(tmpCPerm.getScopeId()); Assert.assertNotNull(tmpCPerm.getAction()); domain.setScopeId(tmpCPerm.getScopeId()); - RolePermissionCreator rolePermissionCreator = rolePermissionFactory.newCreator(tmpCPerm.getScopeId()); + RolePermissionCreator rolePermissionCreator = new RolePermissionCreator(tmpCPerm.getScopeId()); rolePermissionCreator.setRoleId(role.getId()); rolePermissionCreator.setPermission(permissionFactory.newPermission(domain.getDomain().getName(), tmpCPerm.getAction(), tmpCPerm.getTargetScopeId())); try { @@ -521,14 +521,14 @@ public void checkRoleForUpdates() { @Then("The role factory returns sane results") public void performRoleFactorySanityChecks() { Assert.assertNotNull(roleFactory.newEntity(SYS_SCOPE_ID)); - Assert.assertNotNull(roleFactory.newCreator(SYS_SCOPE_ID)); + Assert.assertNotNull(new RoleCreator(SYS_SCOPE_ID)); Assert.assertNotNull(roleFactory.newRolePermission()); } @Then("The role permission factory returns sane results") public void performRolePermissionFactorySanityChecks() { Assert.assertNotNull(rolePermissionFactory.newEntity(SYS_SCOPE_ID)); - Assert.assertNotNull(rolePermissionFactory.newCreator(SYS_SCOPE_ID)); + Assert.assertNotNull(new RolePermissionCreator(SYS_SCOPE_ID)); } @Then("The role comparator does its job") @@ -602,7 +602,7 @@ public void createAListOfDomains(List domains) throws Exception { primeException(); for (CucDomain tmpDom : domains) { tmpDom.doParse(); - domainCreator = domainFactory.newCreator(tmpDom.getName()); + domainCreator = new DomainCreator(tmpDom.getName()); if (tmpDom.getActionSet() != null) { domainCreator.setActions(tmpDom.getActionSet()); } @@ -716,7 +716,7 @@ public void checkDomainIsNull() { @Then("I can compare domain objects") public void checkDomainComparison() throws KapuaException { KapuaSecurityUtils.doPrivileged(() -> { - DomainCreator tmpCreator = domainFactory.newCreator("name_1"); + DomainCreator tmpCreator = new DomainCreator("name_1"); tmpCreator.setServiceName("test"); HashSet tmpAct = new HashSet<>(); tmpAct.add(Actions.read); @@ -829,7 +829,7 @@ public void createAListOfGroups(List groups) throws Exception { primeException(); for (CucGroup tmpGrp : groups) { tmpGrp.doParse(); - groupCreator = groupFactory.newCreator(tmpGrp.getScopeId(), tmpGrp.getName()); + groupCreator = new GroupCreator(tmpGrp.getScopeId(), tmpGrp.getName()); try { group = groupService.create(groupCreator); stepData.put(GROUP_CREATOR, groupCreator); @@ -1047,7 +1047,7 @@ public void createPermissionsForDomain(String permList) { public void provideRoleForDomain(String name) throws Exception { KapuaId currId = (KapuaId) stepData.get(LAST_ACCOUNT_ID); Set permissions = (Set) stepData.get(PERMISSIONS); - RoleCreator roleCreator = roleFactory.newCreator(currId); + RoleCreator roleCreator = new RoleCreator(currId); roleCreator.setName(name); roleCreator.setPermissions(permissions); try { @@ -1077,7 +1077,7 @@ public void createAccessRole() throws Exception { KapuaId currScope = (KapuaId) stepData.get(LAST_ACCOUNT_ID); AccessInfo accessInfo = (AccessInfo) stepData.get(ACCESS_INFO); Role role = (Role) stepData.get("Role"); - AccessRoleCreator tmpCreator = accessRoleFactory.newCreator(currScope); + AccessRoleCreator tmpCreator = new AccessRoleCreator(currScope); tmpCreator.setAccessInfoId(accessInfo.getId()); tmpCreator.setRoleId(role.getId()); try { @@ -1094,7 +1094,7 @@ public void createAccessRole() throws Exception { public void createCleanAccessInfoEntity() throws Exception { KapuaId currScope = (KapuaId) stepData.get(LAST_ACCOUNT_ID); User tmpUser = (User) stepData.get("User"); - AccessInfoCreator accessInfoCreator = accessInfoFactory.newCreator(currScope); + AccessInfoCreator accessInfoCreator = new AccessInfoCreator(currScope); accessInfoCreator.setUserId(tmpUser.getId()); stepData.remove(PERMISSIONS); stepData.remove(ROLE_IDS); @@ -1113,7 +1113,7 @@ public void createCleanAccessInfoEntity() throws Exception { public void createAccessInfoEntity() throws Exception { KapuaId currScope = (KapuaId) stepData.get(LAST_ACCOUNT_ID); User tmpUser = (User) stepData.get("User"); - AccessInfoCreator accessInfoCreator = accessInfoFactory.newCreator(currScope); + AccessInfoCreator accessInfoCreator = new AccessInfoCreator(currScope); accessInfoCreator.setUserId(tmpUser.getId()); Set permissions = (Set) stepData.get(PERMISSIONS); Set roleIds = (Set) stepData.get(ROLE_IDS); @@ -1262,7 +1262,7 @@ public void createPermissionEntries() throws Exception { KapuaId currScope = (KapuaId) stepData.get(LAST_ACCOUNT_ID); AccessInfo accessInfo = (AccessInfo) stepData.get(ACCESS_INFO); Set permissions = (Set) stepData.get(PERMISSIONS); - AccessPermissionCreator accessPermissionCreator = accessPermissionFactory.newCreator(currScope); + AccessPermissionCreator accessPermissionCreator = new AccessPermissionCreator(currScope); accessPermissionCreator.setAccessInfoId(accessInfo.getId()); try { primeException(); @@ -1316,9 +1316,9 @@ public void countPermissionsForScope(Integer scope) throws Exception { public void accessInfoServiceSanityCheck() throws Exception { try { primeException(); - Assert.assertNotNull(accessInfoFactory.newCreator(getKapuaId())); + Assert.assertNotNull(new AccessInfoCreator(getKapuaId())); Assert.assertNotNull(accessInfoFactory.newEntity(null)); - AccessInfoCreator tmpCreator = accessInfoFactory.newCreator(getKapuaId()); + AccessInfoCreator tmpCreator = new AccessInfoCreator(getKapuaId()); Assert.assertNotNull(tmpCreator); AccessInfo tmpAccInfo = accessInfoFactory.newEntity(getKapuaId()); Assert.assertNotNull(tmpAccInfo); @@ -1331,11 +1331,11 @@ public void accessInfoServiceSanityCheck() throws Exception { @When("I check the sanity of the access permission factory") public void accessPermissionFactorySanityCheck() { - Assert.assertNotNull(accessPermissionFactory.newCreator(getKapuaId())); + Assert.assertNotNull(new AccessPermissionCreator(getKapuaId())); Assert.assertNotNull(accessPermissionFactory.newEntity(null)); Assert.assertNotNull(accessPermissionFactory.newEntity(getKapuaId())); KapuaId tmpId = getKapuaId(); - AccessPermissionCreator tmpCreator = accessPermissionFactory.newCreator(tmpId); + AccessPermissionCreator tmpCreator = new AccessPermissionCreator(tmpId); Assert.assertNotNull(tmpCreator); Assert.assertNotNull(tmpCreator.getScopeId()); Assert.assertEquals(tmpId, tmpCreator.getScopeId()); @@ -1357,10 +1357,10 @@ public void accessPermissionFactorySanityCheck() { public void accessRoleFactorySanityCheck() throws Exception { try { primeException(); - Assert.assertNotNull(accessRoleFactory.newCreator(getKapuaId())); + Assert.assertNotNull(new AccessRoleCreator(getKapuaId())); Assert.assertNotNull(accessRoleFactory.newEntity(getKapuaId())); KapuaId tmpId = getKapuaId(); - AccessRoleCreator tmpCreator = accessRoleFactory.newCreator(tmpId); + AccessRoleCreator tmpCreator = new AccessRoleCreator(tmpId); Assert.assertNotNull(tmpCreator); Assert.assertNotNull(tmpCreator.getScopeId()); Assert.assertEquals(tmpId, tmpCreator.getScopeId()); @@ -1622,7 +1622,7 @@ public void accessRoleWithNameIsFinded(String roleName) throws Exception { @And("I create the roles") public void iCreateTheRoles(List roleNames) throws Exception { - RoleCreator roleCreator = roleFactory.newCreator(getCurrentScopeId()); + RoleCreator roleCreator = new RoleCreator(getCurrentScopeId()); ArrayList roleArrayList = new ArrayList(); stepData.remove(ROLE_LIST); Role role = null; @@ -1646,7 +1646,7 @@ public void iAddPermissionsToTheRole() throws Exception { Role role = (Role) stepData.get("Role"); Set permissions = (Set) stepData.get(PERMISSIONS); Set rolePermissionList = new HashSet<>(); - RolePermissionCreator rolePermissionCreator = rolePermissionFactory.newCreator(getCurrentScopeId()); + RolePermissionCreator rolePermissionCreator = new RolePermissionCreator(getCurrentScopeId()); for (Permission permission : permissions) { rolePermissionCreator.setPermission(permission); rolePermissionCreator.setRoleId(role.getId()); @@ -1669,7 +1669,7 @@ public void iAddAccessRolesToUser(String userName) throws Exception { List roleList = (List) stepData.get(ROLE_LIST); User user = (User) stepData.get("User"); Assert.assertEquals(userName, user.getName()); - AccessRoleCreator accessRoleCreator = accessRoleFactory.newCreator(getCurrentScopeId()); + AccessRoleCreator accessRoleCreator = new AccessRoleCreator(getCurrentScopeId()); for (Role role : roleList) { accessRoleCreator.setAccessInfoId(accessInfo.getId()); accessRoleCreator.setRoleId(role.getId()); @@ -1727,7 +1727,7 @@ public void iFindRoleWithName(String roleName) throws Exception { @And("I create a group with name {string}") public void iCreateAGroupWithName(String groupName) throws Exception { - GroupCreator groupCreator = groupFactory.newCreator(getCurrentScopeId()); + GroupCreator groupCreator = new GroupCreator(getCurrentScopeId()); groupCreator.setName(groupName); try { primeException(); @@ -1741,7 +1741,7 @@ public void iCreateAGroupWithName(String groupName) throws Exception { @And("I try to create groups with invalid characters in name") public void iTryToCreateInvalidGroups() throws Exception { - GroupCreator groupCreator = groupFactory.newCreator(getCurrentScopeId()); + GroupCreator groupCreator = new GroupCreator(getCurrentScopeId()); String invalidCharacters = "!\"#$%&'()=»Ç>:;<-.,⁄@‹›€*ı–°·‚_±Œ„‰?“‘”’ÉØ∏{}|ÆæÒÔÓÌÏÎÍÅ«"; for (int i = 0; i < invalidCharacters.length(); i++) { String groupName = GROUP + invalidCharacters.charAt(i); @@ -1880,7 +1880,7 @@ public void iCreateRoleInSubaccount(String roleName, String accountName) throws Account account = (Account) stepData.get(LAST_ACCOUNT); Assert.assertEquals(accountName, account.getName()); RoleCreator roleCreator = null; - roleCreator = roleFactory.newCreator(account.getId()); + roleCreator = new RoleCreator(account.getId()); roleCreator.setName(roleName); try { Role role = roleService.create(roleCreator); @@ -1906,7 +1906,7 @@ public void iCreateTheFollowingRolePermissionInSubaccount(String accountName, Li Assert.assertNotNull(tmpCPerm.getScopeId()); Assert.assertNotNull(tmpCPerm.getAction()); domain.setScopeId(tmpCPerm.getScopeId()); - RolePermissionCreator rolePermissionCreator = rolePermissionFactory.newCreator(account.getId()); + RolePermissionCreator rolePermissionCreator = new RolePermissionCreator(account.getId()); rolePermissionCreator.setRoleId(role.getId()); rolePermissionCreator.setPermission(permissionFactory.newPermission(domain.getDomain().getName(), tmpCPerm.getAction(), tmpCPerm.getTargetScopeId())); try { @@ -1957,7 +1957,7 @@ public void iAddAccessRoleToUserInChildAccount(String roleName, String childUser Account account = (Account) stepData.get(LAST_ACCOUNT); User childUser = (User) stepData.get("ChildAccountUser"); Role role = (Role) stepData.get("Role"); - AccessRoleCreator accessRoleCreator = accessRoleFactory.newCreator(account.getId()); + AccessRoleCreator accessRoleCreator = new AccessRoleCreator(account.getId()); accessRoleCreator.setAccessInfoId(accessInfo.getId()); accessRoleCreator.setRoleId(role.getId()); stepData.put("ChildAccountAccessRoleCreator", accessRoleCreator); @@ -1979,7 +1979,7 @@ public void iAddAccessRoleToUserInChildAccount(String roleName, String childUser public void iCreateTheAccessInfoEntityInChildAccount(String accountName) throws Exception { Account account = (Account) stepData.get(LAST_ACCOUNT); User tmpUser = (User) stepData.get("ChildAccountUser"); - AccessInfoCreator accessInfoCreator = accessInfoFactory.newCreator(account.getId()); + AccessInfoCreator accessInfoCreator = new AccessInfoCreator(account.getId()); accessInfoCreator.setUserId(tmpUser.getId()); Assert.assertEquals(accountName, account.getName()); Set permissions = (Set) stepData.get(PERMISSIONS); @@ -2064,7 +2064,7 @@ public void iUpdateTheRoleName(String newRoleName) throws Exception { public void iCreateTheAccessInfoEntities() throws Exception { KapuaId currScope = (KapuaId) stepData.get(LAST_ACCOUNT_ID); ArrayList userArray = (ArrayList) stepData.get("UserList"); - AccessInfoCreator accessInfoCreator = accessInfoFactory.newCreator(currScope); + AccessInfoCreator accessInfoCreator = new AccessInfoCreator(currScope); ArrayList accessInfoList = new ArrayList<>(); Set permissions = (Set) stepData.get(PERMISSIONS); Set roleIds = (Set) stepData.get(ROLE_IDS); @@ -2096,7 +2096,7 @@ public void iCreateTheAccessInfoEntities() throws Exception { @Given("I prepare a role creator with name {string} and description {string}") public void iPrepareARoleCreatorWithNameAndDescription(String name, String description) { - RoleCreator roleCreator = roleFactory.newCreator(SYS_SCOPE_ID); + RoleCreator roleCreator = new RoleCreator(SYS_SCOPE_ID); roleCreator.setName(name); roleCreator.setDescription(description); stepData.put(ROLE_CREATOR, roleCreator); @@ -2122,7 +2122,7 @@ public void iCreateRoles(int num) throws Exception { primeException(); try { for (int i = 0; i < num; i++) { - RoleCreator tmpCreator = roleFactory.newCreator(getCurrentScopeId()); + RoleCreator tmpCreator = new RoleCreator(getCurrentScopeId()); tmpCreator.setName(String.format("TestRoleNum%d", i)); roleService.create(tmpCreator); } @@ -2182,7 +2182,7 @@ public void iFindARoleWithDescription(String roleDesc) throws Throwable { @Given("I try to create roles with invalid characters {string} in name") public void iTryToCreateRolesWithInvalidCharactersInName(String invalidCharacters) throws Exception { - RoleCreator roleCreator = roleFactory.newCreator(SYS_SCOPE_ID); + RoleCreator roleCreator = new RoleCreator(SYS_SCOPE_ID); for (int i = 0; i < invalidCharacters.length(); i++) { String roleName = ROLE_NAME + invalidCharacters.charAt(i); roleCreator.setName(roleName); @@ -2199,7 +2199,7 @@ public void iTryToCreateRolesWithInvalidCharactersInName(String invalidCharacter @Given("I try to create roles with invalid characters {string} in description") public void iTryToCreateRolesWithInvalidCharactersInDescription(String invalidCharacters) throws Exception { - RoleCreator roleCreator = roleFactory.newCreator(SYS_SCOPE_ID); + RoleCreator roleCreator = new RoleCreator(SYS_SCOPE_ID); for (int i = 0; i < invalidCharacters.length(); i++) { String roleDescription = "roleDescription" + invalidCharacters.charAt(i); roleCreator.setDescription(roleDescription); @@ -2217,7 +2217,7 @@ public void iTryToCreateRolesWithInvalidCharactersInDescription(String invalidCh @Then("I update the role name with special characters {string}") public void iUpdateTheRoleNameWithSpecialCharacters(String invalidSymbols) throws Exception { - RoleCreator roleCreator = roleFactory.newCreator(SYS_SCOPE_ID); + RoleCreator roleCreator = new RoleCreator(SYS_SCOPE_ID); for (int i = 0; i < invalidSymbols.length(); i++) { String roleName = ROLE_NAME + invalidSymbols.charAt(i); roleCreator.setName(ROLE_NAME + i); @@ -2292,7 +2292,7 @@ public void iChangeDevicesGroup() throws Exception { @Given("I create the group with name {string} and description {string}") public void iCreateTheGroupWithName(String groupName, String groupDescription) throws Exception { - GroupCreator groupCreator = groupFactory.newCreator(getCurrentScopeId()); + GroupCreator groupCreator = new GroupCreator(getCurrentScopeId()); groupCreator.setName(groupName); groupCreator.setDescription(groupDescription); try { @@ -2358,7 +2358,7 @@ public void iUpdateTheGroupDescriptionFromTo(String description1, String descrip @And("I try to create the group with invalid characters {string} in name and description {string}") public void iTryToCreateTheGroupWithInvalidCharactersInNameAndDescription(String invalidSymbols, String description) throws Exception { - GroupCreator groupCreator = groupFactory.newCreator(getCurrentScopeId()); + GroupCreator groupCreator = new GroupCreator(getCurrentScopeId()); for (int i = 0; i < invalidSymbols.length(); i++) { String groupName = GROUP_NAME + invalidSymbols.charAt(i); groupCreator.setName(groupName); @@ -2394,7 +2394,7 @@ public void iUpdateTheGroupNameFromToNameWithSpecialCharacters(String name, Stri @Given("I try to create the group with special characters {string} in description") public void iTryToCreateTheGroupWithSpecialCharactersInDescription(String invalidSymbols) throws Exception { - GroupCreator groupCreator = groupFactory.newCreator(SYS_SCOPE_ID); + GroupCreator groupCreator = new GroupCreator(SYS_SCOPE_ID); for (int i = 0; i < invalidSymbols.length(); i++) { String groupDescription = "description" + invalidSymbols.charAt(i); groupCreator.setDescription(groupDescription); @@ -2412,7 +2412,7 @@ public void iTryToCreateTheGroupWithSpecialCharactersInDescription(String invali @When("I update the group description to description with special characters {string}") public void iUpdateTheGroupDescriptionFromToDescriptionWithSpecialCharacters(String invalidSymbols) throws Exception { - GroupCreator groupCreator = groupFactory.newCreator(SYS_SCOPE_ID); + GroupCreator groupCreator = new GroupCreator(SYS_SCOPE_ID); for (int i = 0; i < invalidSymbols.length(); i++) { String groupDescription = "description" + invalidSymbols.charAt(i); groupCreator.setDescription(groupDescription); diff --git a/service/stream/internal/src/main/java/org/eclipse/kapua/service/stream/internal/StreamServiceImpl.java b/service/stream/internal/src/main/java/org/eclipse/kapua/service/stream/internal/StreamServiceImpl.java index 5d526827e8f..ee8ee6eed59 100644 --- a/service/stream/internal/src/main/java/org/eclipse/kapua/service/stream/internal/StreamServiceImpl.java +++ b/service/stream/internal/src/main/java/org/eclipse/kapua/service/stream/internal/StreamServiceImpl.java @@ -13,7 +13,13 @@ *******************************************************************************/ package org.eclipse.kapua.service.stream.internal; -import com.google.common.base.Strings; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +import javax.inject.Inject; +import javax.inject.Singleton; + import org.eclipse.kapua.KapuaEntityNotFoundException; import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.KapuaIllegalArgumentException; @@ -33,7 +39,6 @@ import org.eclipse.kapua.service.device.registry.DeviceRegistryService; import org.eclipse.kapua.service.endpoint.EndpointInfo; import org.eclipse.kapua.service.endpoint.EndpointInfoAttributes; -import org.eclipse.kapua.service.endpoint.EndpointInfoFactory; import org.eclipse.kapua.service.endpoint.EndpointInfoQuery; import org.eclipse.kapua.service.endpoint.EndpointInfoService; import org.eclipse.kapua.service.stream.StreamService; @@ -45,11 +50,7 @@ import org.eclipse.kapua.transport.exception.TransportClientGetException; import org.eclipse.kapua.transport.message.TransportMessage; -import javax.inject.Inject; -import javax.inject.Singleton; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; +import com.google.common.base.Strings; /** * {@link StreamService} implementation. @@ -63,7 +64,6 @@ public class StreamServiceImpl implements StreamService { private final PermissionFactory permissionFactory; private final DeviceRegistryService deviceRegistryService; private final EndpointInfoService endpointInfoService; - private final EndpointInfoFactory endpointInfoFactory; private final TransportClientFactory transportClientFactory; private final TranslatorHub translatorHub; @@ -73,14 +73,12 @@ public StreamServiceImpl( PermissionFactory permissionFactory, DeviceRegistryService deviceRegistryService, EndpointInfoService endpointInfoService, - EndpointInfoFactory endpointInfoFactory, TransportClientFactory transportClientFactory, TranslatorHub translatorHub) { this.authorizationService = authorizationService; this.permissionFactory = permissionFactory; this.deviceRegistryService = deviceRegistryService; this.endpointInfoService = endpointInfoService; - this.endpointInfoFactory = endpointInfoFactory; this.transportClientFactory = transportClientFactory; this.translatorHub = translatorHub; } @@ -119,9 +117,11 @@ public StreamServiceImpl( /** * Picks a {@link TransportFacade} to send the {@link KuraResponseMessage}. * - * @param kapuaDataMessage The K + * @param kapuaDataMessage + * The K * @return The {@link TransportFacade} to use to send the {@link KuraDataMessage}. - * @throws KuraDeviceCallException If getting the {@link TransportFacade} causes any {@link Exception}. + * @throws KuraDeviceCallException + * If getting the {@link TransportFacade} causes any {@link Exception}. * @since 1.0.0 */ protected TransportFacade borrowClient(KapuaDataMessage kapuaDataMessage) throws KuraDeviceCallException { @@ -159,11 +159,15 @@ public StreamServiceImpl( *
  • Both specified: The {@link Device#getClientId()} and the {@link KapuaDataMessage#getClientId()} must match
  • * * - * @param dataMessage The {@link KapuaDataMessage} to publish + * @param dataMessage + * The {@link KapuaDataMessage} to publish * @return The {@link Device} matching the {@link KapuaDataMessage#getDeviceId()} or {@link KapuaDataMessage#getClientId()} - * @throws KapuaEntityNotFoundException if {@link KapuaDataMessage#getDeviceId()} does not match any existing {@link Device} - * @throws KapuaIllegalArgumentException if {@link KapuaDataMessage#getClientId()} does not match the {@link Device#getClientId()} - * @throws KapuaException If any other error occurs. + * @throws KapuaEntityNotFoundException + * if {@link KapuaDataMessage#getDeviceId()} does not match any existing {@link Device} + * @throws KapuaIllegalArgumentException + * if {@link KapuaDataMessage#getClientId()} does not match the {@link Device#getClientId()} + * @throws KapuaException + * If any other error occurs. * @since 1.2.0 */ private Device checkDeviceInfo(KapuaDataMessage dataMessage) throws KapuaException { @@ -187,14 +191,16 @@ private Device checkDeviceInfo(KapuaDataMessage dataMessage) throws KapuaExcepti /** * Looks for the available {@link EndpointInfo} with {@link EndpointInfo#getSchema()} = "mqtt" * - * @param dataMessage The {@link KapuaDataMessage} to publish + * @param dataMessage + * The {@link KapuaDataMessage} to publish * @return The {@link String} {@link java.net.URI} to connect to. - * @throws KapuaException If no {@link EndpointInfo} is available + * @throws KapuaException + * If no {@link EndpointInfo} is available * @since 1.2.0 */ private String getEndpointInfoDNS(KapuaDataMessage dataMessage) throws KapuaException { String serverURI; - EndpointInfoQuery query = endpointInfoFactory.newQuery(dataMessage.getScopeId()); + EndpointInfoQuery query = new EndpointInfoQuery(dataMessage.getScopeId()); query.setPredicate( query.andPredicate( query.attributePredicate(EndpointInfoAttributes.SCHEMA, "mqtt"), @@ -210,16 +216,20 @@ private String getEndpointInfoDNS(KapuaDataMessage dataMessage) throws KapuaExce return serverURI; } - /** * Gets the translator for the given {@link Message} types. * - * @param from The {@link Message} type from which to translate. - * @param to The {@link Message} type to which to translate. - * @param The {@link Message} {@code class}from which to translate. - * @param The {@link Message} {@code class} to which to translate. + * @param from + * The {@link Message} type from which to translate. + * @param to + * The {@link Message} type to which to translate. + * @param + * The {@link Message} {@code class}from which to translate. + * @param + * The {@link Message} {@code class} to which to translate. * @return The {@link Translator} found. - * @throws KuraDeviceCallException If error occurs while loojing for the {@link Translator}. + * @throws KuraDeviceCallException + * If error occurs while loojing for the {@link Translator}. * @since 1.0.0 */ protected , T extends Message> Translator getTranslator(Class from, Class to) throws KuraDeviceCallException { diff --git a/service/tag/api/src/main/java/org/eclipse/kapua/service/tag/TagCreator.java b/service/tag/api/src/main/java/org/eclipse/kapua/service/tag/TagCreator.java index 410e85b2e54..0029f2a5ea7 100644 --- a/service/tag/api/src/main/java/org/eclipse/kapua/service/tag/TagCreator.java +++ b/service/tag/api/src/main/java/org/eclipse/kapua/service/tag/TagCreator.java @@ -12,13 +12,14 @@ *******************************************************************************/ package org.eclipse.kapua.service.tag; -import org.eclipse.kapua.model.KapuaNamedEntityCreator; - import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import org.eclipse.kapua.model.KapuaNamedEntityCreator; +import org.eclipse.kapua.model.id.KapuaId; + /** * {@link TagCreator} definition *

    @@ -28,6 +29,19 @@ */ @XmlRootElement(name = "tagCreator") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = TagXmlRegistry.class, factoryMethod = "newTagCreator") -public interface TagCreator extends KapuaNamedEntityCreator { +@XmlType +public class TagCreator extends KapuaNamedEntityCreator { + + private static final long serialVersionUID = -4676187845961673421L; + + public TagCreator() { + } + + public TagCreator(KapuaId scopeId) { + super(scopeId); + } + + public TagCreator(KapuaId scopeId, String name) { + super(scopeId, name); + } } diff --git a/service/tag/api/src/main/java/org/eclipse/kapua/service/tag/TagFactory.java b/service/tag/api/src/main/java/org/eclipse/kapua/service/tag/TagFactory.java index 5e5ef6d9ed5..32e170dbec2 100644 --- a/service/tag/api/src/main/java/org/eclipse/kapua/service/tag/TagFactory.java +++ b/service/tag/api/src/main/java/org/eclipse/kapua/service/tag/TagFactory.java @@ -13,7 +13,6 @@ package org.eclipse.kapua.service.tag; import org.eclipse.kapua.model.KapuaEntityFactory; -import org.eclipse.kapua.model.id.KapuaId; /** * {@link TagFactory} definition. @@ -21,17 +20,6 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface TagFactory extends KapuaEntityFactory { +public interface TagFactory extends KapuaEntityFactory { - /** - * Instantiates a new {@link TagCreator}. - * - * @param scopeId - * The scope {@link KapuaId} to set into the {@link TagCreator} - * @param name - * The name to set into the {@link TagCreator}. - * @return The newly instantiated {@link TagCreator} - * @since 1.0.0 - */ - TagCreator newCreator(KapuaId scopeId, String name); } diff --git a/service/tag/api/src/main/java/org/eclipse/kapua/service/tag/TagXmlRegistry.java b/service/tag/api/src/main/java/org/eclipse/kapua/service/tag/TagXmlRegistry.java index 3b5f285ab93..eca58fdc102 100644 --- a/service/tag/api/src/main/java/org/eclipse/kapua/service/tag/TagXmlRegistry.java +++ b/service/tag/api/src/main/java/org/eclipse/kapua/service/tag/TagXmlRegistry.java @@ -30,16 +30,4 @@ public Tag newTag() { return tagFactory.newEntity(null); } - /** - * Creates a new tag creator instance - * - * @return - */ - public TagCreator newTagCreator() { - return tagFactory.newCreator(null, null); - } - - public TagQuery newQuery() { - return new TagQuery(null); - } } diff --git a/service/tag/internal/src/main/java/org/eclipse/kapua/service/tag/internal/TagCreatorImpl.java b/service/tag/internal/src/main/java/org/eclipse/kapua/service/tag/internal/TagCreatorImpl.java deleted file mode 100644 index 25921ac8762..00000000000 --- a/service/tag/internal/src/main/java/org/eclipse/kapua/service/tag/internal/TagCreatorImpl.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017, 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.service.tag.internal; - -import org.eclipse.kapua.commons.model.AbstractKapuaNamedEntityCreator; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.service.authorization.domain.DomainCreator; -import org.eclipse.kapua.service.tag.Tag; -import org.eclipse.kapua.service.tag.TagCreator; - -/** - * {@link TagCreator} implementation. - * - * @since 1.0.0 - */ -public class TagCreatorImpl extends AbstractKapuaNamedEntityCreator implements TagCreator { - - private static final long serialVersionUID = -4676187845961673421L; - - /** - * Constructor. - * - * @param scopeId The scope id to set. - * @param name The name to set for this {@link DomainCreator}. - * @since 1.0.0 - */ - public TagCreatorImpl(KapuaId scopeId, String name) { - super(scopeId); - - setName(name); - } - - /** - * Constructor - * - * @param scopeId The scopeId {@link KapuaId} - */ - public TagCreatorImpl(KapuaId scopeId) { - super(scopeId); - } -} diff --git a/service/tag/internal/src/main/java/org/eclipse/kapua/service/tag/internal/TagFactoryImpl.java b/service/tag/internal/src/main/java/org/eclipse/kapua/service/tag/internal/TagFactoryImpl.java index bbec50b8bff..a13177b817b 100644 --- a/service/tag/internal/src/main/java/org/eclipse/kapua/service/tag/internal/TagFactoryImpl.java +++ b/service/tag/internal/src/main/java/org/eclipse/kapua/service/tag/internal/TagFactoryImpl.java @@ -17,7 +17,6 @@ import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.tag.Tag; -import org.eclipse.kapua.service.tag.TagCreator; import org.eclipse.kapua.service.tag.TagFactory; /** @@ -28,25 +27,11 @@ @Singleton public class TagFactoryImpl implements TagFactory { - @Override - public TagCreator newCreator(KapuaId scopeId, String name) { - TagCreator creator = newCreator(scopeId); - - creator.setName(name); - - return creator; - } - @Override public Tag newEntity(KapuaId scopeId) { return new TagImpl(scopeId); } - @Override - public TagCreator newCreator(KapuaId scopeId) { - return new TagCreatorImpl(scopeId); - } - @Override public Tag clone(Tag tag) { try { diff --git a/service/tag/internal/src/test/java/org/eclipse/kapua/service/tag/internal/TagServiceImplTest.java b/service/tag/internal/src/test/java/org/eclipse/kapua/service/tag/internal/TagServiceImplTest.java index 9e8df12ee9b..fc4020a3190 100644 --- a/service/tag/internal/src/test/java/org/eclipse/kapua/service/tag/internal/TagServiceImplTest.java +++ b/service/tag/internal/src/test/java/org/eclipse/kapua/service/tag/internal/TagServiceImplTest.java @@ -12,6 +12,9 @@ *******************************************************************************/ package org.eclipse.kapua.service.tag.internal; +import java.math.BigInteger; +import java.util.function.BiConsumer; + import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.KapuaIllegalNullArgumentException; import org.eclipse.kapua.commons.configuration.ServiceConfigurationManager; @@ -22,6 +25,7 @@ import org.eclipse.kapua.service.authorization.permission.Permission; import org.eclipse.kapua.service.authorization.permission.PermissionFactory; import org.eclipse.kapua.service.tag.Tag; +import org.eclipse.kapua.service.tag.TagCreator; import org.eclipse.kapua.service.tag.TagFactory; import org.eclipse.kapua.service.tag.TagRepository; import org.eclipse.kapua.storage.TxContext; @@ -32,9 +36,6 @@ import org.mockito.MockSettings; import org.mockito.Mockito; -import java.math.BigInteger; -import java.util.function.BiConsumer; - @org.junit.jupiter.api.Tag("org.eclipse.kapua.qa.markers.junit.JUnitTests") public class TagServiceImplTest { @@ -62,6 +63,7 @@ public void setUp() throws KapuaException { .thenAnswer(invocation -> invocation.getArgumentAt(0, Tag.class)); tagFactory = Mockito.mock(TagFactory.class); final TxManager txManager = new TxManager() { + @Override public R execute(TxConsumer transactionConsumer, BiConsumer... afterCommitConsumers) throws KapuaException { return null; @@ -72,8 +74,6 @@ public TxContext getTxContext() { return null; } }; - Mockito.when(tagFactory.newCreator(Mockito.any(), Mockito.any())) - .thenAnswer(invocation -> new TagCreatorImpl(invocation.getArgumentAt(0, KapuaId.class), invocation.getArgumentAt(1, String.class))); Mockito.when(tagFactory.newEntity(Mockito.any())) .thenAnswer(invocation -> new TagImpl(invocation.getArgumentAt(0, KapuaId.class))); @@ -93,10 +93,10 @@ public void createTagPerformsInputValidation() { () -> instance.create(null), "Does not accept null tagCreator"); Assertions.assertThrows(KapuaIllegalNullArgumentException.class, - () -> instance.create(new TagCreatorImpl(null, "testTag")), + () -> instance.create(new TagCreator(null, "testTag")), "Does not accept tagCreator with null scope id"); Assertions.assertThrows(KapuaIllegalNullArgumentException.class, - () -> instance.create(new TagCreatorImpl(new KapuaIdImpl(BigInteger.ONE), null)), + () -> instance.create(new TagCreator(new KapuaIdImpl(BigInteger.ONE), null)), "Does not accept tagCreator with null name"); } } \ No newline at end of file diff --git a/service/tag/test-steps/src/main/java/org/eclipse/kapua/service/tag/steps/TagServiceSteps.java b/service/tag/test-steps/src/main/java/org/eclipse/kapua/service/tag/steps/TagServiceSteps.java index 09b73a6a831..c1eef9e12df 100644 --- a/service/tag/test-steps/src/main/java/org/eclipse/kapua/service/tag/steps/TagServiceSteps.java +++ b/service/tag/test-steps/src/main/java/org/eclipse/kapua/service/tag/steps/TagServiceSteps.java @@ -240,13 +240,13 @@ public void tagWithNameIsDeleted(String tagName) throws Throwable { * @return tag creator for tag with specified name */ private TagCreator tagCreatorCreatorWithoutDescription(String tagName) { - TagCreator tagCreator = tagFactory.newCreator(getCurrentScopeId()); + TagCreator tagCreator = new TagCreator(getCurrentScopeId()); tagCreator.setName(tagName); return tagCreator; } public TagCreator tagCreatorCreatorWithDescription(String tagName, String tagDescription) { - TagCreator tagCreator = tagFactory.newCreator(SYS_SCOPE_ID); + TagCreator tagCreator = new TagCreator(SYS_SCOPE_ID); tagCreator.setName(tagName); tagCreator.setDescription(tagDescription); return tagCreator; diff --git a/service/user/api/src/main/java/org/eclipse/kapua/service/user/UserCreator.java b/service/user/api/src/main/java/org/eclipse/kapua/service/user/UserCreator.java index c22db31cff5..4c28393dead 100644 --- a/service/user/api/src/main/java/org/eclipse/kapua/service/user/UserCreator.java +++ b/service/user/api/src/main/java/org/eclipse/kapua/service/user/UserCreator.java @@ -12,8 +12,7 @@ *******************************************************************************/ package org.eclipse.kapua.service.user; -import org.eclipse.kapua.model.KapuaNamedEntityCreator; -import org.eclipse.kapua.model.xml.DateXmlAdapter; +import java.util.Date; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; @@ -21,7 +20,10 @@ import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; -import java.util.Date; + +import org.eclipse.kapua.model.KapuaNamedEntityCreator; +import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.model.xml.DateXmlAdapter; /** * {@link UserCreator} {@link org.eclipse.kapua.model.KapuaEntityCreator} definition @@ -30,8 +32,39 @@ */ @XmlRootElement(name = "userCreator") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = UserXmlRegistry.class, factoryMethod = "newUserCreator") -public interface UserCreator extends KapuaNamedEntityCreator { +@XmlType +public class UserCreator extends KapuaNamedEntityCreator { + + private static final long serialVersionUID = 4664940282892151008L; + + private UserStatus status; + private String displayName; + private String email; + private String phoneNumber; + private UserType userType = UserType.INTERNAL; + private String externalId; + private String externalUsername; + private Date expirationDate; + + public UserCreator() { + this(null, null); + } + + public UserCreator(KapuaId scopeId) { + this(scopeId, null); + } + + /** + * Constructor + * + * @param accountId + * @param name + */ + public UserCreator(KapuaId accountId, String name) { + super(accountId, name); + setStatus(UserStatus.ENABLED); + setUserType(UserType.INTERNAL); + } /** * Return the display name (may be a friendly username to show in the UI) @@ -39,14 +72,18 @@ public interface UserCreator extends KapuaNamedEntityCreator { * @return */ @XmlElement(name = "displayName") - String getDisplayName(); + public String getDisplayName() { + return displayName; + } /** * Set the display name * * @param displayName */ - void setDisplayName(String displayName); + public void setDisplayName(String displayName) { + this.displayName = displayName; + } /** * Get the email @@ -54,14 +91,18 @@ public interface UserCreator extends KapuaNamedEntityCreator { * @return */ @XmlElement(name = "email") - String getEmail(); + public String getEmail() { + return email; + } /** * Set the email * * @param email */ - void setEmail(String email); + public void setEmail(String email) { + this.email = email; + } /** * Get the phone number @@ -69,14 +110,18 @@ public interface UserCreator extends KapuaNamedEntityCreator { * @return */ @XmlElement(name = "phoneNumber") - String getPhoneNumber(); + public String getPhoneNumber() { + return phoneNumber; + } /** * Set the phone number * * @param phoneNumber */ - void setPhoneNumber(String phoneNumber); + public void setPhoneNumber(String phoneNumber) { + this.phoneNumber = phoneNumber; + } /** * Get the user type @@ -84,14 +129,18 @@ public interface UserCreator extends KapuaNamedEntityCreator { * @return */ @XmlElement(name = "userType") - UserType getUserType(); + public UserType getUserType() { + return userType; + } /** * Set the user type * * @param userType */ - void setUserType(UserType userType); + public void setUserType(UserType userType) { + this.userType = userType; + } /** * Get the external ID @@ -99,14 +148,18 @@ public interface UserCreator extends KapuaNamedEntityCreator { * @return */ @XmlElement(name = "externalId") - String getExternalId(); + public String getExternalId() { + return externalId; + } /** * Set the external ID * * @param externalId */ - void setExternalId(String externalId); + public void setExternalId(String externalId) { + this.externalId = externalId; + } /** * Gets the external username. @@ -115,25 +168,37 @@ public interface UserCreator extends KapuaNamedEntityCreator { * @since 2.0.0 */ @XmlElement(name = "externalUsername") - String getExternalUsername(); + public String getExternalUsername() { + return externalUsername; + } /** * Sets the external username. * - * @param externalUsername The external username. + * @param externalUsername + * The external username. * @since 2.0.0 */ - void setExternalUsername(String externalUsername); - + public void setExternalUsername(String externalUsername) { + this.externalUsername = externalUsername; + } @XmlElement(name = "expirationDate") @XmlJavaTypeAdapter(DateXmlAdapter.class) - Date getExpirationDate(); + public Date getExpirationDate() { + return expirationDate; + } - void setExpirationDate(Date expirationDate); + public void setExpirationDate(Date expirationDate) { + this.expirationDate = expirationDate; + } @XmlElement(name = "status") - UserStatus getStatus(); + public UserStatus getStatus() { + return status; + } - void setStatus(UserStatus status); + public void setStatus(UserStatus status) { + this.status = status; + } } diff --git a/service/user/api/src/main/java/org/eclipse/kapua/service/user/UserFactory.java b/service/user/api/src/main/java/org/eclipse/kapua/service/user/UserFactory.java index eb22907b255..559a9b2f816 100644 --- a/service/user/api/src/main/java/org/eclipse/kapua/service/user/UserFactory.java +++ b/service/user/api/src/main/java/org/eclipse/kapua/service/user/UserFactory.java @@ -13,7 +13,6 @@ package org.eclipse.kapua.service.user; import org.eclipse.kapua.model.KapuaEntityFactory; -import org.eclipse.kapua.model.id.KapuaId; /** * {@link UserFactory} definition. @@ -21,18 +20,6 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface UserFactory extends KapuaEntityFactory { - - /** - * Instantiates a new {@link UserCreator} - * - * @param scopedId - * The scope {@link KapuaId} to set into the {@link UserCreator}. - * @param name - * The name to set into the {@link UserCreator}. - * @return The newly instantiated {@link UserCreator} - * @since 1.0.0 - */ - UserCreator newCreator(KapuaId scopedId, String name); +public interface UserFactory extends KapuaEntityFactory { } diff --git a/service/user/api/src/main/java/org/eclipse/kapua/service/user/UserXmlRegistry.java b/service/user/api/src/main/java/org/eclipse/kapua/service/user/UserXmlRegistry.java index c3ae1a184a6..db1f2101d8a 100644 --- a/service/user/api/src/main/java/org/eclipse/kapua/service/user/UserXmlRegistry.java +++ b/service/user/api/src/main/java/org/eclipse/kapua/service/user/UserXmlRegistry.java @@ -35,15 +35,6 @@ public User newUser() { return userFactory.newEntity(null); } - /** - * Creates a new user creator instance - * - * @return - */ - public UserCreator newUserCreator() { - return userFactory.newCreator(null, null); - } - public UserQuery newQuery() { return new UserQuery(null); } diff --git a/service/user/internal/src/main/java/org/eclipse/kapua/service/user/internal/UserCreatorImpl.java b/service/user/internal/src/main/java/org/eclipse/kapua/service/user/internal/UserCreatorImpl.java deleted file mode 100644 index 7a1a6cbfa94..00000000000 --- a/service/user/internal/src/main/java/org/eclipse/kapua/service/user/internal/UserCreatorImpl.java +++ /dev/null @@ -1,138 +0,0 @@ -/******************************************************************************* - * 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.service.user.internal; - -import org.eclipse.kapua.commons.model.AbstractKapuaNamedEntityCreator; -import org.eclipse.kapua.model.id.KapuaId; -import org.eclipse.kapua.service.user.User; -import org.eclipse.kapua.service.user.UserCreator; -import org.eclipse.kapua.service.user.UserStatus; -import org.eclipse.kapua.service.user.UserType; - -import java.util.Date; - -/** - * {@link UserCreator} implementation. - * - * @since 1.0.0 - */ -public class UserCreatorImpl extends AbstractKapuaNamedEntityCreator implements UserCreator { - - private static final long serialVersionUID = 4664940282892151008L; - - private UserStatus status; - private String displayName; - private String email; - private String phoneNumber; - private UserType userType = UserType.INTERNAL; - private String externalId; - private String externalUsername; - private Date expirationDate; - - /** - * Constructor - * - * @param accountId - * @param name - */ - public UserCreatorImpl(KapuaId accountId, String name) { - super(accountId, name); - - setStatus(UserStatus.ENABLED); - setUserType(UserType.INTERNAL); - } - - public UserCreatorImpl(KapuaId scopeId) { - this(scopeId, null); - } - - @Override - public UserStatus getStatus() { - return status; - } - - @Override - public void setStatus(UserStatus status) { - this.status = status; - } - - @Override - public String getDisplayName() { - return displayName; - } - - @Override - public void setDisplayName(String displayName) { - this.displayName = displayName; - } - - @Override - public String getEmail() { - return email; - } - - @Override - public void setEmail(String email) { - this.email = email; - } - - @Override - public String getPhoneNumber() { - return phoneNumber; - } - - @Override - public void setPhoneNumber(String phoneNumber) { - this.phoneNumber = phoneNumber; - } - - @Override - public UserType getUserType() { - return userType; - } - - @Override - public void setUserType(UserType userType) { - this.userType = userType; - } - - @Override - public String getExternalId() { - return externalId; - } - - @Override - public void setExternalId(String externalId) { - this.externalId = externalId; - } - - @Override - public String getExternalUsername() { - return externalUsername; - } - - @Override - public void setExternalUsername(String externalUsername) { - this.externalUsername = externalUsername; - } - - @Override - public Date getExpirationDate() { - return expirationDate; - } - - @Override - public void setExpirationDate(Date expirationDate) { - this.expirationDate = expirationDate; - } -} diff --git a/service/user/internal/src/main/java/org/eclipse/kapua/service/user/internal/UserFactoryImpl.java b/service/user/internal/src/main/java/org/eclipse/kapua/service/user/internal/UserFactoryImpl.java index 6f4d9d609da..4c117eebef6 100644 --- a/service/user/internal/src/main/java/org/eclipse/kapua/service/user/internal/UserFactoryImpl.java +++ b/service/user/internal/src/main/java/org/eclipse/kapua/service/user/internal/UserFactoryImpl.java @@ -17,7 +17,6 @@ import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.user.User; -import org.eclipse.kapua.service.user.UserCreator; import org.eclipse.kapua.service.user.UserFactory; /** @@ -28,25 +27,11 @@ @Singleton public class UserFactoryImpl implements UserFactory { - @Override - public UserCreator newCreator(KapuaId scopeId, String name) { - UserCreator creator = newCreator(scopeId); - - creator.setName(name); - - return creator; - } - @Override public User newEntity(KapuaId scopeId) { return new UserImpl(scopeId); } - @Override - public UserCreator newCreator(KapuaId scopeId) { - return new UserCreatorImpl(scopeId); - } - @Override public User clone(User user) { try { diff --git a/service/user/test-steps/src/main/java/org/eclipse/kapua/service/user/steps/UserRoleServiceSteps.java b/service/user/test-steps/src/main/java/org/eclipse/kapua/service/user/steps/UserRoleServiceSteps.java index aa3bef3a178..de8d193cb45 100644 --- a/service/user/test-steps/src/main/java/org/eclipse/kapua/service/user/steps/UserRoleServiceSteps.java +++ b/service/user/test-steps/src/main/java/org/eclipse/kapua/service/user/steps/UserRoleServiceSteps.java @@ -12,15 +12,19 @@ *******************************************************************************/ package org.eclipse.kapua.service.user.steps; +import java.util.ArrayList; + +import javax.inject.Inject; + import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.locator.KapuaLocator; -import org.eclipse.kapua.qa.common.TestBase; import org.eclipse.kapua.qa.common.StepData; -import org.eclipse.kapua.service.authorization.access.AccessRoleService; -import org.eclipse.kapua.service.authorization.access.AccessRoleFactory; +import org.eclipse.kapua.qa.common.TestBase; import org.eclipse.kapua.service.authorization.access.AccessInfo; -import org.eclipse.kapua.service.authorization.access.AccessRoleCreator; import org.eclipse.kapua.service.authorization.access.AccessRole; +import org.eclipse.kapua.service.authorization.access.AccessRoleCreator; +import org.eclipse.kapua.service.authorization.access.AccessRoleFactory; +import org.eclipse.kapua.service.authorization.access.AccessRoleService; import org.eclipse.kapua.service.authorization.role.Role; import org.eclipse.kapua.service.user.User; import org.junit.Assert; @@ -33,9 +37,6 @@ import io.cucumber.java.en.And; import io.cucumber.java.en.Then; -import javax.inject.Inject; -import java.util.ArrayList; - @Singleton public class UserRoleServiceSteps extends TestBase { @@ -49,7 +50,7 @@ public UserRoleServiceSteps(StepData stepData) { super(stepData); } - @After(value="@setup") + @After(value = "@setup") public void setServices() { KapuaLocator locator = KapuaLocator.getInstance(); accessRoleService = locator.getService(AccessRoleService.class); @@ -66,25 +67,25 @@ public void addRoleToUser(String roleName, String userName) throws Exception { AccessInfo accessInfo = (AccessInfo) stepData.get("AccessInfo"); Role role = (Role) stepData.get("Role"); User user = (User) stepData.get("User"); - AccessRoleCreator accessRoleCreator = accessRoleFactory.newCreator(getCurrentScopeId()); - accessRoleCreator.setAccessInfoId(accessInfo.getId()); - accessRoleCreator.setRoleId(role.getId()); - stepData.put("AccessRoleCreator", accessRoleCreator); - Assert.assertEquals(roleName, role.getName()); - Assert.assertEquals(userName, user.getName()); - try { - primeException(); - stepData.remove(ACCESS_ROLE); - AccessRole accessRole = accessRoleService.create(accessRoleCreator); - stepData.put(ACCESS_ROLE, accessRole); - stepData.put("AccessRoleId", accessRole.getId()); - } catch (KapuaException ex) { - verifyException(ex); - } + AccessRoleCreator accessRoleCreator = new AccessRoleCreator(getCurrentScopeId()); + accessRoleCreator.setAccessInfoId(accessInfo.getId()); + accessRoleCreator.setRoleId(role.getId()); + stepData.put("AccessRoleCreator", accessRoleCreator); + Assert.assertEquals(roleName, role.getName()); + Assert.assertEquals(userName, user.getName()); + try { + primeException(); + stepData.remove(ACCESS_ROLE); + AccessRole accessRole = accessRoleService.create(accessRoleCreator); + stepData.put(ACCESS_ROLE, accessRole); + stepData.put("AccessRoleId", accessRole.getId()); + } catch (KapuaException ex) { + verifyException(ex); + } } @Then("Access role is not found") - public void accessRoleIsNotFound() throws Exception{ + public void accessRoleIsNotFound() throws Exception { AccessRole accessRole = (AccessRole) stepData.get(ACCESS_ROLE); try { Assert.assertEquals(null, accessRoleService.find(getCurrentScopeId(), accessRole.getId())); @@ -98,7 +99,7 @@ public void iAddAccessRoleToUsers(String roleName) throws Exception { ArrayList accessInfoList = (ArrayList) stepData.get("AccessInfoList"); ArrayList accessRoleList = new ArrayList<>(); Role role = (Role) stepData.get("Role"); - AccessRoleCreator accessRoleCreator = accessRoleFactory.newCreator(getCurrentScopeId()); + AccessRoleCreator accessRoleCreator = new AccessRoleCreator(getCurrentScopeId()); accessRoleCreator.setRoleId(role.getId()); stepData.put("AccessRoleCreator", accessRoleCreator); Assert.assertEquals(roleName, role.getName()); diff --git a/service/user/test-steps/src/main/java/org/eclipse/kapua/service/user/steps/UserServiceSteps.java b/service/user/test-steps/src/main/java/org/eclipse/kapua/service/user/steps/UserServiceSteps.java index 3745138c31d..8642d2869e8 100644 --- a/service/user/test-steps/src/main/java/org/eclipse/kapua/service/user/steps/UserServiceSteps.java +++ b/service/user/test-steps/src/main/java/org/eclipse/kapua/service/user/steps/UserServiceSteps.java @@ -163,7 +163,7 @@ public void crateUserWithName(String userName, int scopeId) { String userEmail = MessageFormat.format("testuser_{0,number,#}@organization.com", now); String displayName = MessageFormat.format("User Display Name {0}", now); KapuaEid scpId = new KapuaEid(BigInteger.valueOf(scopeId)); - UserCreator uc = userFactory.newCreator(scpId, userName); + UserCreator uc = new UserCreator(scpId, userName); uc.setDisplayName(displayName); uc.setEmail(userEmail); uc.setPhoneNumber("+1 555 123 4567"); @@ -779,7 +779,7 @@ private User createUserInstance(int userId, int scopeId) { * @return UserCreator instance for creating user */ private UserCreator userCreatorCreator(String name, String displayName, String email, String phone, KapuaId scopeId) { - UserCreator userCreator = userFactory.newCreator(scopeId, name); + UserCreator userCreator = new UserCreator(scopeId, name); userCreator.setName(name); userCreator.setDisplayName(displayName); userCreator.setEmail(email); @@ -833,7 +833,7 @@ private Credential createCredentials(CucCredentials cucCredentials) throws Excep */ private CredentialCreator credentialCreatorCreator(KapuaId scopeId, KapuaId userId, String password, CredentialStatus status, Date expirationDate) { CredentialCreator credentialCreator; - credentialCreator = credentialFactory.newCreator(scopeId, userId, "PASSWORD", password, status, expirationDate); + credentialCreator = new CredentialCreator(scopeId, userId, "PASSWORD", password, status, expirationDate); return credentialCreator; } @@ -873,7 +873,7 @@ private void createPermissions(List permissionList, ComparableUse * @return AccessInfoCreator instance for creating user permissions */ private AccessInfoCreator accessInfoCreatorCreator(List permissionList, ComparableUser user, Account account) throws KapuaException { - AccessInfoCreator accessInfoCreator = accessInfoFactory.newCreator(account.getId()); + AccessInfoCreator accessInfoCreator = new AccessInfoCreator(account.getId()); accessInfoCreator.setUserId(user.getUser().getId()); accessInfoCreator.setScopeId(user.getUser().getScopeId()); Set permissions = new HashSet<>(); @@ -926,7 +926,7 @@ private boolean matchUserData(User user, CucUser cucUser) { @And("I create user with name {string}") public void iCreateUserWithName(String userName) throws Exception { stepData.remove(USER_CREATOR); - UserCreator userCreator = userFactory.newCreator(getCurrentScopeId()); + UserCreator userCreator = new UserCreator(getCurrentScopeId()); userCreator.setName(userName); stepData.put(USER_CREATOR, userCreator); try { @@ -957,7 +957,7 @@ public void iTryToEditUserWithName(String newUserName) throws Exception { public void iCreateUserWithNameInSubaccount(String name, String accountName) throws Exception { Account account = (Account) stepData.get(LAST_ACCOUNT); Assert.assertEquals(accountName, account.getName()); - UserCreator userCreator = userFactory.newCreator(account.getId()); + UserCreator userCreator = new UserCreator(account.getId()); userCreator.setName(name); primeException(); try { @@ -972,7 +972,7 @@ public void iCreateUserWithNameInSubaccount(String name, String accountName) thr @And("I create users with following names") public void iCreateUsersWithFollowingNames(List tmpUsers) throws Exception { - UserCreator userCreator = userFactory.newCreator(getCurrentScopeId()); + UserCreator userCreator = new UserCreator(getCurrentScopeId()); ArrayList userList = new ArrayList<>(); for (CucUser tmpUser : tmpUsers) { userCreator.setName(tmpUser.getName()); @@ -1217,7 +1217,7 @@ public void iEnableMfa() { KapuaId scopeId = KapuaSecurityUtils.getSession().getScopeId(); MfaOptionFactory mfaFactory = KapuaLocator.getInstance().getFactory(MfaOptionFactoryImpl.class); - MfaOptionCreator mfaCreator = mfaFactory.newCreator(scopeId, userId); + MfaOptionCreator mfaCreator = new MfaOptionCreator(scopeId, userId); MfaOptionService mfaOptionService = KapuaLocator.getInstance().getService(MfaOptionService.class); try { mfaOptionService.create(mfaCreator);