From 7d7c2cbf15585a66a719fa80dc7983d7eb0dc756 Mon Sep 17 00:00:00 2001 From: dseurotech Date: Fri, 17 Jan 2025 14:25:39 +0100 Subject: [PATCH] :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 | 8 +- ...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, 3365 insertions(+), 5706 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..32928e9338f 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 @@ -44,7 +44,7 @@ public void newCreatorNameParameterTest() { "12#name--765 ,.aaa!!#$%^<> " }; for (String name : names) { - DomainCreator domainCreator = domainFactoryImpl.newCreator(name); + DomainCreator domainCreator = new DomainCreator(name); Assert.assertEquals("Expected and actual values should be the same.", name, domainCreator.getName()); Assert.assertNull("Null expected.", domainCreator.getScopeId()); } @@ -52,7 +52,7 @@ public void newCreatorNameParameterTest() { @Test public void newCreatorNullNameParameterTest() { - DomainCreator domainCreator = domainFactoryImpl.newCreator((String) null); + DomainCreator domainCreator = new DomainCreator((String) null); Assert.assertNull("Null expected.", domainCreator.getName()); Assert.assertNull("Null expected.", domainCreator.getScopeId()); } @@ -71,12 +71,12 @@ public void newEntityNullTest() { @Test(expected = NotImplementedException.class) public void newCreatorScopeIdParameterTest() { - domainFactoryImpl.newCreator(KapuaId.ONE); + new DomainCreator(KapuaId.ONE); } @Test(expected = NotImplementedException.class) public void newCreatorNullScopeIdParameterTest() { - domainFactoryImpl.newCreator((KapuaId) null); + new DomainCreator((KapuaId) null); } @Test 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);