diff --git a/commons/src/main/java/org/eclipse/kapua/commons/configuration/AbstractKapuaConfigurableResourceLimitedService.java b/commons/src/main/java/org/eclipse/kapua/commons/configuration/AbstractKapuaConfigurableResourceLimitedService.java index 719a0a0addf..616290f3751 100644 --- a/commons/src/main/java/org/eclipse/kapua/commons/configuration/AbstractKapuaConfigurableResourceLimitedService.java +++ b/commons/src/main/java/org/eclipse/kapua/commons/configuration/AbstractKapuaConfigurableResourceLimitedService.java @@ -12,6 +12,9 @@ *******************************************************************************/ package org.eclipse.kapua.commons.configuration; +import java.util.Map; +import java.util.Optional; + import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.KapuaMaxNumberOfItemsReachedException; import org.eclipse.kapua.commons.configuration.exception.ServiceConfigurationLimitExceededException; @@ -36,9 +39,6 @@ import org.eclipse.kapua.service.authorization.permission.PermissionFactory; import org.eclipse.kapua.service.config.KapuaConfigurableService; -import java.util.Map; -import java.util.Optional; - /** * Base {@code abstract} {@link KapuaConfigurableService} implementation for services that have a max number of entities allowed. *
@@ -48,12 +48,18 @@ *
The {@link KapuaQuery} type. - * @paramThe {@link KapuaEntityFactory} type. + * @param + * The {@link KapuaEntity} type. + * @param + * The {@link KapuaEntityCreator} type. + * @param + * The {@link KapuaEntityService} type. + * @param+ * The {@link KapuaListResult} type. + * @param + * The {@link KapuaQuery} type. + * @param+ * The {@link KapuaEntityFactory} type. * @since 1.0.0 * @deprecated since 2.0.0, in favour of separate configuration component - see {@link ServiceConfigurationManager} and implementations for more details */ @@ -62,14 +68,12 @@ public abstract class AbstractKapuaConfigurableResourceLimitedService< E extends KapuaEntity, C extends KapuaEntityCreator , S extends KapuaEntityService , - L extends KapuaListResult , Q extends KapuaQuery, - F extends KapuaEntityFactory + F extends KapuaEntityFactory > extends AbstractKapuaConfigurableService implements KapuaEntityService { - //TODO: make final as soon as deprecated constructors are removed private AccountRelativeFinder accountRelativeFinder; private F factory; @@ -79,11 +83,16 @@ public abstract class AbstractKapuaConfigurableResourceLimitedService< /** * Constructor. * - * @param pid The {@link KapuaConfigurableService} id. - * @param domain The {@link Domain} on which check access. - * @param entityManagerFactory The {@link EntityManagerFactory} that handles persistence unit - * @param serviceClass The {@link KapuaService} type. - * @param factoryClass The {@link KapuaEntityFactory} type. + * @param pid + * The {@link KapuaConfigurableService} id. + * @param domain + * The {@link Domain} on which check access. + * @param entityManagerFactory + * The {@link EntityManagerFactory} that handles persistence unit + * @param serviceClass + * The {@link KapuaService} type. + * @param factoryClass + * The {@link KapuaEntityFactory} type. * @deprecated Since 1.2.0. This constructor will be removed in a next release (may be) */ @Deprecated @@ -104,12 +113,18 @@ protected AbstractKapuaConfigurableResourceLimitedService( /** * Constructor. * - * @param pid The {@link KapuaConfigurableService} id. - * @param domain The {@link Domain} on which check access. - * @param entityManagerFactory The {@link EntityManagerFactory} that handles persistence unit - * @param abstractCacheFactory The {@link CacheFactory} that handles caching of the entities + * @param pid + * The {@link KapuaConfigurableService} id. + * @param domain + * The {@link Domain} on which check access. + * @param entityManagerFactory + * The {@link EntityManagerFactory} that handles persistence unit + * @param abstractCacheFactory + * The {@link CacheFactory} that handles caching of the entities * @since 1.2.0 - * @deprecated Since 2.0.0. Please use {@link #AbstractKapuaConfigurableResourceLimitedService(String, Domain, EntityManagerFactory, EntityCacheFactory, KapuaEntityFactory, PermissionFactory, AuthorizationService, AccountRelativeFinder, RootUserTester)} This constructor may be removed in a next release + * @deprecated Since 2.0.0. Please use + * {@link #AbstractKapuaConfigurableResourceLimitedService(String, Domain, EntityManagerFactory, EntityCacheFactory, KapuaEntityFactory, PermissionFactory, AuthorizationService, + * AccountRelativeFinder, RootUserTester)} This constructor may be removed in a next release */ @Deprecated protected AbstractKapuaConfigurableResourceLimitedService( @@ -133,24 +148,32 @@ protected AbstractKapuaConfigurableResourceLimitedService( /** * Constructor. * - * @param pid The {@link KapuaConfigurableService} id. - * @param domain The {@link Domain} on which check access. - * @param entityManagerFactory The {@link EntityManagerFactory} that handles persistence unit - * @param abstractCacheFactory The {@link CacheFactory} that handles caching of the entities - * @param factory The {@link KapuaEntityFactory} instance. - * @param permissionFactory The {@link PermissionFactory} instance. - * @param authorizationService The {@link AuthorizationService} instance. - * @param rootUserTester The {@link RootUserTester} instance. + * @param pid + * The {@link KapuaConfigurableService} id. + * @param domain + * The {@link Domain} on which check access. + * @param entityManagerFactory + * The {@link EntityManagerFactory} that handles persistence unit + * @param abstractCacheFactory + * The {@link CacheFactory} that handles caching of the entities + * @param factory + * The {@link KapuaEntityFactory} instance. + * @param permissionFactory + * The {@link PermissionFactory} instance. + * @param authorizationService + * The {@link AuthorizationService} instance. + * @param rootUserTester + * The {@link RootUserTester} instance. */ protected AbstractKapuaConfigurableResourceLimitedService(String pid, - Domain domain, - EntityManagerFactory entityManagerFactory, - EntityCacheFactory abstractCacheFactory, - F factory, - PermissionFactory permissionFactory, - AuthorizationService authorizationService, - AccountRelativeFinder accountRelativeFinder, - RootUserTester rootUserTester) { + Domain domain, + EntityManagerFactory entityManagerFactory, + EntityCacheFactory abstractCacheFactory, + F factory, + PermissionFactory permissionFactory, + AuthorizationService authorizationService, + AccountRelativeFinder accountRelativeFinder, + RootUserTester rootUserTester) { super(pid, domain, entityManagerFactory, abstractCacheFactory, permissionFactory, authorizationService, rootUserTester); this.factory = factory; this.factoryClass = null; //TODO: not needed for this construction path, remove as soon as the deprecated constructor is removed @@ -180,8 +203,10 @@ protected boolean validateNewConfigValuesCoherence(KapuaTocd ocd, Map * The exclusion of the scope is required when updating a limit for a target account. * - * @param scopeId The scope {@link KapuaId}. - * @param targetScopeId The excluded scope {@link KapuaId}. + * @param scopeId + * The scope {@link KapuaId}. + * @param targetScopeId + * The excluded scope {@link KapuaId}. * @return The number of entities remaining for the given scope * @throws KapuaException * @since 1.0.0 @@ -220,14 +248,16 @@ private long allowedChildEntities(KapuaId scopeId, KapuaId targetScopeId) throws } /** - * Gets the number of remaining allowed entity for the given scope, according to the given {@link KapuaConfigurableService} - * excluding a specific scope when checking resources available. + * Gets the number of remaining allowed entity for the given scope, according to the given {@link KapuaConfigurableService} excluding a specific scope when checking resources available. * * The exclusion of the scope is required when updating a limit for a target account. * - * @param scopeId The scope {@link KapuaId}. - * @param targetScopeId The excluded scope {@link KapuaId}. - * @param configuration The configuration to be checked. If not provided will be read from the current service configuration + * @param scopeId + * The scope {@link KapuaId}. + * @param targetScopeId + * The excluded scope {@link KapuaId}. + * @param configuration + * The configuration to be checked. If not provided will be read from the current service configuration * @return The number of entities remaining for the given scope * @throws KapuaException * @since 1.0.0 @@ -263,10 +293,9 @@ private long allowedChildEntities(KapuaId scopeId, KapuaId targetScopeId, Map
getConfigValues(KapuaId scopeId, boolean excludeDi ); ServiceConfigListResult result = entityManagerSession.doAction(EntityManagerContainer. create() - .onResultHandler(em -> ServiceDAO.query(em, ServiceConfig.class, ServiceConfigImpl.class, new ServiceConfigListResultImpl(), query)) + .onResultHandler(em -> ServiceDAO.query(em, ServiceConfig.class, ServiceConfigImpl.class, new ServiceConfigListResult(), query)) .onBeforeHandler(() -> (ServiceConfigListResult) PRIVATE_ENTITY_CACHE.getList(scopeId, pid)) .onAfterHandler(entity -> PRIVATE_ENTITY_CACHE.putList(scopeId, pid, entity))); @@ -592,7 +592,7 @@ public void setConfigValues(KapuaId scopeId, KapuaId parentId, Map create(). - onResultHandler(em -> ServiceDAO.query(em, ServiceConfig.class, ServiceConfigImpl.class, new ServiceConfigListResultImpl(), query)) + onResultHandler(em -> ServiceDAO.query(em, ServiceConfig.class, ServiceConfigImpl.class, new ServiceConfigListResult(), query)) ); Properties props = toProperties(values); diff --git a/commons/src/main/java/org/eclipse/kapua/commons/configuration/ServiceConfigImplJpaRepository.java b/commons/src/main/java/org/eclipse/kapua/commons/configuration/ServiceConfigImplJpaRepository.java index 31b63e33cab..438de108ee4 100644 --- a/commons/src/main/java/org/eclipse/kapua/commons/configuration/ServiceConfigImplJpaRepository.java +++ b/commons/src/main/java/org/eclipse/kapua/commons/configuration/ServiceConfigImplJpaRepository.java @@ -22,7 +22,7 @@ public class ServiceConfigImplJpaRepository extends KapuaUpdatableEntityJpaRepository implements ServiceConfigRepository { public ServiceConfigImplJpaRepository(KapuaJpaRepositoryConfiguration jpaRepoConfig) { - super(ServiceConfigImpl.class, ServiceConfig.TYPE, () -> new ServiceConfigListResultImpl(), jpaRepoConfig); + super(ServiceConfigImpl.class, ServiceConfig.TYPE, () -> new ServiceConfigListResult(), jpaRepoConfig); } @Override diff --git a/commons/src/main/java/org/eclipse/kapua/commons/configuration/ServiceConfigListResult.java b/commons/src/main/java/org/eclipse/kapua/commons/configuration/ServiceConfigListResult.java index 5701270b445..22229c46b19 100644 --- a/commons/src/main/java/org/eclipse/kapua/commons/configuration/ServiceConfigListResult.java +++ b/commons/src/main/java/org/eclipse/kapua/commons/configuration/ServiceConfigListResult.java @@ -18,7 +18,9 @@ * Service configuration result list definition. * * @since 1.0 - * */ -public interface ServiceConfigListResult extends KapuaListResult { +public class ServiceConfigListResult extends KapuaListResult { + + private static final long serialVersionUID = -2550359084026132096L; + } diff --git a/commons/src/main/java/org/eclipse/kapua/commons/configuration/ServiceConfigListResultImpl.java b/commons/src/main/java/org/eclipse/kapua/commons/configuration/ServiceConfigListResultImpl.java deleted file mode 100644 index 79136d21865..00000000000 --- a/commons/src/main/java/org/eclipse/kapua/commons/configuration/ServiceConfigListResultImpl.java +++ /dev/null @@ -1,26 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016, 2022 Eurotech and/or its affiliates and others - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Eurotech - initial API and implementation - *******************************************************************************/ -package org.eclipse.kapua.commons.configuration; - -import org.eclipse.kapua.commons.model.query.KapuaListResultImpl; - -/** - * Service configuration result list reference implementation. - * - * @since 1.0 - * - */ -public class ServiceConfigListResultImpl extends KapuaListResultImpl implements ServiceConfigListResult { - - private static final long serialVersionUID = -2550359084026132096L; -} diff --git a/commons/src/main/java/org/eclipse/kapua/commons/configuration/UsedEntitiesCounterImpl.java b/commons/src/main/java/org/eclipse/kapua/commons/configuration/UsedEntitiesCounterImpl.java index 227dccac161..4b0e24d0251 100644 --- a/commons/src/main/java/org/eclipse/kapua/commons/configuration/UsedEntitiesCounterImpl.java +++ b/commons/src/main/java/org/eclipse/kapua/commons/configuration/UsedEntitiesCounterImpl.java @@ -28,14 +28,14 @@ public class UsedEntitiesCounterImpl< C extends KapuaEntityCreator , L extends KapuaListResult , Q extends KapuaQuery, - F extends KapuaEntityFactory + F extends KapuaEntityFactory > implements UsedEntitiesCounter { private final F factory; private final KapuaEntityRepository entityRepository; public UsedEntitiesCounterImpl(F factory, - KapuaEntityRepository entityRepository) { + KapuaEntityRepository entityRepository) { this.factory = factory; this.entityRepository = entityRepository; } diff --git a/commons/src/main/java/org/eclipse/kapua/commons/model/query/KapuaListResultImpl.java b/commons/src/main/java/org/eclipse/kapua/commons/model/query/KapuaListResultImpl.java deleted file mode 100644 index 3ff330435d3..00000000000 --- a/commons/src/main/java/org/eclipse/kapua/commons/model/query/KapuaListResultImpl.java +++ /dev/null @@ -1,134 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016, 2022 Eurotech and/or its affiliates and others - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Eurotech - initial API and implementation - *******************************************************************************/ -package org.eclipse.kapua.commons.model.query; - -import org.eclipse.kapua.model.KapuaEntity; -import org.eclipse.kapua.model.query.KapuaListResult; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Comparator; -import java.util.List; -import java.util.Map; -import java.util.function.Function; -import java.util.function.Predicate; -import java.util.stream.Collectors; - -/** - * {@link KapuaListResult} implementation. - * - * @param {@link KapuaEntity} type. - * @since 1.0.0 - */ -public class KapuaListResultImpl implements KapuaListResult { - - private static final long serialVersionUID = 8939666089540269261L; - - private ArrayList items; - private boolean limitExceeded; - private Long totalCount; - - /** - * Constructor. - * - * @since 1.0.0 - */ - public KapuaListResultImpl() { - limitExceeded = false; - } - - @Override - public boolean isLimitExceeded() { - return limitExceeded; - } - - @Override - public void setLimitExceeded(boolean limitExceeded) { - this.limitExceeded = limitExceeded; - } - - @Override - public List getItems() { - if (items == null) { - items = new ArrayList<>(); - } - - return items; - } - - @Override - public List getItems(Predicate filter) { - return getItems().stream().filter(filter).collect(Collectors.toList()); - } - - @Override - public Map getItemsAsMap(Function keyMapper) { - return getItems().stream().collect(Collectors.toMap(keyMapper, e -> e)); - } - - @Override - public Map getItemsAsMap(Function keyMapper, Function valueMapper) { - return getItems().stream().collect(Collectors.toMap(keyMapper, valueMapper)); - } - - @Override - public E getItem(int index) { - return getItems().get(index); - } - - @Override - public E getFirstItem() { - return this.isEmpty() ? null : getItem(0); - } - - @Override - public int getSize() { - return getItems().size(); - } - - @Override - public boolean isEmpty() { - return getItems().isEmpty(); - } - - @Override - public void addItems(Collection extends E> items) { - getItems().addAll(items); - } - - @Override - public void addItem(E item) { - getItems().add(item); - } - - @Override - public void clearItems() { - getItems().clear(); - } - - @Override - public void sort(Comparator comparator) { - getItems().sort(comparator); - } - - @Override - public Long getTotalCount() { - return totalCount; - } - - @Override - public void setTotalCount(Long totalCount) { - this.totalCount = totalCount; - } - -} diff --git a/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/api/EventStoreFactory.java b/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/api/EventStoreFactory.java index d26edcfbaca..944d14d51db 100644 --- a/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/api/EventStoreFactory.java +++ b/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/api/EventStoreFactory.java @@ -20,6 +20,6 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface EventStoreFactory extends KapuaEntityFactory { +public interface EventStoreFactory extends KapuaEntityFactory { } diff --git a/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/api/EventStoreRecordListResult.java b/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/api/EventStoreRecordListResult.java index 1ca0de04f84..604c3b771ea 100644 --- a/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/api/EventStoreRecordListResult.java +++ b/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/api/EventStoreRecordListResult.java @@ -23,11 +23,12 @@ * KapuaEvent result list definition. * * @since 1.0 - * */ @XmlRootElement(name = "eventStoreRecords") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = EventStoreXmlRegistry.class,factoryMethod = "newEventStoreRecordListResult") -public interface EventStoreRecordListResult extends KapuaListResult { +@XmlType +public class EventStoreRecordListResult extends KapuaListResult { + + private static final long serialVersionUID = -5118004898345748297L; } diff --git a/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/api/EventStoreXmlRegistry.java b/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/api/EventStoreXmlRegistry.java index 39fd356fa6b..0ea0521588e 100644 --- a/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/api/EventStoreXmlRegistry.java +++ b/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/api/EventStoreXmlRegistry.java @@ -12,10 +12,10 @@ *******************************************************************************/ package org.eclipse.kapua.commons.service.event.store.api; -import org.eclipse.kapua.commons.service.event.store.internal.EventStoreFactoryImpl; - import javax.xml.bind.annotation.XmlRegistry; +import org.eclipse.kapua.commons.service.event.store.internal.EventStoreFactoryImpl; + @XmlRegistry public class EventStoreXmlRegistry { @@ -39,15 +39,6 @@ public EventStoreRecordCreator newEventStoreRecordCreator() { return kapuaEventFactory.newCreator(null); } - /** - * Creates a new kapuaEvent list result instance - * - * @return - */ - public EventStoreRecordListResult newEventStoreRecordListResult() { - return kapuaEventFactory.newListResult(); - } - public EventStoreRecordQuery newQuery() { return kapuaEventFactory.newQuery(null); } diff --git a/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/internal/EventStoreFactoryImpl.java b/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/internal/EventStoreFactoryImpl.java index e5622dfc59c..c6b25def06f 100644 --- a/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/internal/EventStoreFactoryImpl.java +++ b/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/internal/EventStoreFactoryImpl.java @@ -12,16 +12,15 @@ *******************************************************************************/ package org.eclipse.kapua.commons.service.event.store.internal; +import javax.inject.Singleton; + import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.commons.service.event.store.api.EventStoreFactory; import org.eclipse.kapua.commons.service.event.store.api.EventStoreRecord; import org.eclipse.kapua.commons.service.event.store.api.EventStoreRecordCreator; -import org.eclipse.kapua.commons.service.event.store.api.EventStoreRecordListResult; import org.eclipse.kapua.commons.service.event.store.api.EventStoreRecordQuery; import org.eclipse.kapua.model.id.KapuaId; -import javax.inject.Singleton; - /** * {@link EventStoreFactory} implementation * @@ -45,11 +44,6 @@ public EventStoreRecordQuery newQuery(KapuaId scopeId) { return new EventStoreQueryImpl(scopeId); } - @Override - public EventStoreRecordListResult newListResult() { - return new EventStoreRecordListResultImpl(); - } - @Override public EventStoreRecord clone(EventStoreRecord eventStoreRecord) { try { diff --git a/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/internal/EventStoreRecordImplJpaRepository.java b/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/internal/EventStoreRecordImplJpaRepository.java index 10363ed304a..67b965941f6 100644 --- a/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/internal/EventStoreRecordImplJpaRepository.java +++ b/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/internal/EventStoreRecordImplJpaRepository.java @@ -21,9 +21,9 @@ public class EventStoreRecordImplJpaRepository extends KapuaUpdatableEntityJpaRepository implements EventStoreRecordRepository { + public EventStoreRecordImplJpaRepository(KapuaJpaRepositoryConfiguration jpaRepoConfig) { - super(EventStoreRecordImpl.class, EventStoreRecord.TYPE, () -> new EventStoreRecordListResultImpl(), jpaRepoConfig); + super(EventStoreRecordImpl.class, EventStoreRecord.TYPE, () -> new EventStoreRecordListResult(), jpaRepoConfig); } - } diff --git a/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/internal/EventStoreRecordListResultImpl.java b/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/internal/EventStoreRecordListResultImpl.java deleted file mode 100644 index 38ed77fbcc8..00000000000 --- a/commons/src/main/java/org/eclipse/kapua/commons/service/event/store/internal/EventStoreRecordListResultImpl.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016, 2022 Eurotech and/or its affiliates and others - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Eurotech - initial API and implementation - *******************************************************************************/ -package org.eclipse.kapua.commons.service.event.store.internal; - -import org.eclipse.kapua.commons.model.query.KapuaListResultImpl; -import org.eclipse.kapua.commons.service.event.store.api.EventStoreRecord; -import org.eclipse.kapua.commons.service.event.store.api.EventStoreRecordListResult; - -/** - * KapuaEvent list result implementation. - * - * @since 1.0 - */ -public class EventStoreRecordListResultImpl extends KapuaListResultImpl implements EventStoreRecordListResult { - - private static final long serialVersionUID = -5118004898345748297L; -} diff --git a/commons/src/main/java/org/eclipse/kapua/commons/service/internal/cache/EntityCache.java b/commons/src/main/java/org/eclipse/kapua/commons/service/internal/cache/EntityCache.java index f17db8d4930..481a90e69d7 100644 --- a/commons/src/main/java/org/eclipse/kapua/commons/service/internal/cache/EntityCache.java +++ b/commons/src/main/java/org/eclipse/kapua/commons/service/internal/cache/EntityCache.java @@ -12,6 +12,10 @@ *******************************************************************************/ package org.eclipse.kapua.commons.service.internal.cache; +import java.io.Serializable; + +import javax.cache.Cache; + import org.eclipse.kapua.commons.metric.CommonsMetric; import org.eclipse.kapua.model.KapuaEntity; import org.eclipse.kapua.model.id.KapuaId; @@ -19,12 +23,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.cache.Cache; -import java.io.Serializable; - /** - * The basic cache class, it contains two {@link Cache} objects. - * The {@code idCache} cache contains {@link KapuaEntity} objects, while the {@code listsCache} contains {@link KapuaListResult} objects. + * The basic cache class, it contains two {@link Cache} objects. The {@code idCache} cache contains {@link KapuaEntity} objects, while the {@code listsCache} contains {@link KapuaListResult} objects. */ public class EntityCache { @@ -134,11 +134,13 @@ public KapuaListResult removeList(KapuaId scopeId, Serializable id) { } /** - * Checks that the scopeId of the entity matches the provided one. - * This mimics the checks that are performed in the 'find' method of the {@link org.eclipse.kapua.commons.jpa.KapuaEntityJpaRepository} class. + * Checks that the scopeId of the entity matches the provided one. This mimics the checks that are performed in the 'find' method of the + * {@link org.eclipse.kapua.commons.jpa.KapuaEntityJpaRepository} class. * - * @param scopeId a {@link KapuaId} representing the scopeId - * @param entity the {@link KapuaEntity} to be checked + * @param scopeId + * a {@link KapuaId} representing the scopeId + * @param entity + * the {@link KapuaEntity} to be checked * @return the provided entity if it has the required scopeId, null otherwise */ protected KapuaEntity checkResult(KapuaId scopeId, KapuaEntity entity) { @@ -158,14 +160,16 @@ protected KapuaEntity checkResult(KapuaId scopeId, KapuaEntity entity) { } /** - * Checks that the scopeId of the entity matches the provided one. - * This mimics the checks that are performed in the 'find' method of the {@link org.eclipse.kapua.commons.jpa.KapuaEntityJpaRepository} class. + * Checks that the scopeId of the entity matches the provided one. This mimics the checks that are performed in the 'find' method of the + * {@link org.eclipse.kapua.commons.jpa.KapuaEntityJpaRepository} class. * - * @param scopeId a {@link KapuaId} representing the scopeId - * @param entity the {@link KapuaListResult} entity to be checked + * @param scopeId + * a {@link KapuaId} representing the scopeId + * @param entity + * the {@link KapuaListResult} entity to be checked * @return the provided entity if it has the required scopeId, null otherwise */ - protected KapuaListResult checkResult(KapuaId scopeId, KapuaListResult entity) { + protected KapuaListResult checkResult(KapuaId scopeId, KapuaListResult entity) { if (entity != null) { if (entity.getSize() == 0) { return entity; // If the list is empty, I want to return the empty list @@ -186,10 +190,14 @@ protected KapuaListResult checkResult(KapuaId scopeId, KapuaListResult entity) { /** * Handles logging for cache exceptions. * - * @param operation the name of the method/operation - * @param cacheName the name of the cache in which the operation is performed - * @param keyId the Id of the entry's key in the cache - * @param t the exception + * @param operation + * the name of the method/operation + * @param cacheName + * the name of the cache in which the operation is performed + * @param keyId + * the Id of the entry's key in the cache + * @param t + * the exception */ protected void cacheErrorLogger(String operation, String cacheName, Serializable keyId, Throwable t) { commonsMetric.getCacheError().inc(); diff --git a/commons/src/test/java/org/eclipse/kapua/commons/model/misc/CollisionEntityJpaRepository.java b/commons/src/test/java/org/eclipse/kapua/commons/model/misc/CollisionEntityJpaRepository.java index dacf2bbb7e1..e8d5726b35d 100644 --- a/commons/src/test/java/org/eclipse/kapua/commons/model/misc/CollisionEntityJpaRepository.java +++ b/commons/src/test/java/org/eclipse/kapua/commons/model/misc/CollisionEntityJpaRepository.java @@ -14,14 +14,12 @@ import org.eclipse.kapua.commons.jpa.KapuaEntityJpaRepository; import org.eclipse.kapua.commons.jpa.KapuaJpaRepositoryConfiguration; -import org.eclipse.kapua.commons.model.query.KapuaListResultImpl; import org.eclipse.kapua.model.query.KapuaListResult; - public class CollisionEntityJpaRepository extends KapuaEntityJpaRepository > { public CollisionEntityJpaRepository(KapuaJpaRepositoryConfiguration configuration) { - super(CollisionEntity.class, CollisionEntity.TYPE, () -> new KapuaListResultImpl<>(), configuration); + super(CollisionEntity.class, CollisionEntity.TYPE, () -> new KapuaListResult<>(), configuration); } } diff --git a/commons/src/test/java/org/eclipse/kapua/commons/model/query/KapuaListResultImplTest.java b/commons/src/test/java/org/eclipse/kapua/commons/model/query/KapuaListResultTest.java similarity index 85% rename from commons/src/test/java/org/eclipse/kapua/commons/model/query/KapuaListResultImplTest.java rename to commons/src/test/java/org/eclipse/kapua/commons/model/query/KapuaListResultTest.java index db57913c750..add84b7c7cc 100644 --- a/commons/src/test/java/org/eclipse/kapua/commons/model/query/KapuaListResultImplTest.java +++ b/commons/src/test/java/org/eclipse/kapua/commons/model/query/KapuaListResultTest.java @@ -12,31 +12,32 @@ *******************************************************************************/ package org.eclipse.kapua.commons.model.query; +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; +import java.util.Map; +import java.util.Random; + import org.eclipse.kapua.commons.model.AbstractKapuaEntity; import org.eclipse.kapua.commons.model.id.KapuaEid; import org.eclipse.kapua.commons.util.RandomUtils; import org.eclipse.kapua.model.id.KapuaId; +import org.eclipse.kapua.model.query.KapuaListResult; import org.eclipse.kapua.qa.markers.junit.JUnitTests; import org.junit.Assert; import org.junit.Test; import org.junit.experimental.categories.Category; import org.mockito.Mockito; -import java.math.BigInteger; -import java.util.ArrayList; -import java.util.Comparator; -import java.util.List; -import java.util.Map; -import java.util.Random; - @Category(JUnitTests.class) -public class KapuaListResultImplTest { +public class KapuaListResultTest { private final static Random RANDOM = RandomUtils.getInstance(); @Test public void kapuaListResultImplTest() { - KapuaListResultImpl kapuaListResult = new KapuaListResultImpl<>(); + KapuaListResult kapuaListResult = new KapuaListResult<>(); Assert.assertNotNull(kapuaListResult.getItems()); Assert.assertTrue(kapuaListResult.getItems().isEmpty()); @@ -53,7 +54,7 @@ public void addItemsTest() { items.add(kapuaEntity1); items.add(kapuaEntity2); - KapuaListResultImpl kapuaListResult = new KapuaListResultImpl<>(); + KapuaListResult kapuaListResult = new KapuaListResult<>(); kapuaListResult.addItems(items); Assert.assertEquals(2, kapuaListResult.getItems().size()); @@ -67,7 +68,7 @@ public void addItemTest() { AbstractKapuaEntity kapuaEntity1 = Mockito.mock(AbstractKapuaEntity.class); AbstractKapuaEntity kapuaEntity2 = Mockito.mock(AbstractKapuaEntity.class); - KapuaListResultImpl kapuaListResult = new KapuaListResultImpl<>(); + KapuaListResult kapuaListResult = new KapuaListResult<>(); kapuaListResult.addItem(kapuaEntity1); kapuaListResult.addItem(kapuaEntity2); @@ -79,7 +80,7 @@ public void addItemTest() { @Test public void clearItemsTest() { int testSize = 10; - KapuaListResultImpl kapuaListResult = new KapuaListResultImpl<>(); + KapuaListResult kapuaListResult = new KapuaListResult<>(); for (int i = 0; i < testSize; i++) { kapuaListResult.addItem(Mockito.mock(AbstractKapuaEntity.class)); @@ -94,7 +95,7 @@ public void clearItemsTest() { @Test public void getFirstItemTest() { - KapuaListResultImpl kapuaListResult = new KapuaListResultImpl<>(); + KapuaListResult kapuaListResult = new KapuaListResult<>(); AbstractKapuaEntity kapuaEntity1 = Mockito.mock(AbstractKapuaEntity.class); kapuaListResult.addItem(kapuaEntity1); @@ -108,7 +109,7 @@ public void getFirstItemTest() { @Test public void getItemsTest() { - KapuaListResultImpl kapuaListResult = new KapuaListResultImpl<>(); + KapuaListResult kapuaListResult = new KapuaListResult<>(); AbstractKapuaEntity kapuaEntity1 = Mockito.mock(AbstractKapuaEntity.class); kapuaListResult.addItem(kapuaEntity1); @@ -124,7 +125,7 @@ public void getItemsTest() { @Test public void getItemsPredicateTest() { int testSize = 10; - KapuaListResultImpl kapuaListResult = new KapuaListResultImpl<>(); + KapuaListResult kapuaListResult = new KapuaListResult<>(); for (int i = 0; i < testSize; i++) { AbstractKapuaEntity kapuaEntity = Mockito.mock(AbstractKapuaEntity.class); @@ -144,7 +145,7 @@ public void getItemsPredicateTest() { @Test public void getItemsAsMapKeyTest() { int testSize = 10; - KapuaListResultImpl kapuaListResult = new KapuaListResultImpl<>(); + KapuaListResult kapuaListResult = new KapuaListResult<>(); for (int i = 0; i < testSize; i++) { AbstractKapuaEntity kapuaEntity = Mockito.mock(AbstractKapuaEntity.class); @@ -164,7 +165,7 @@ public void getItemsAsMapKeyTest() { @Test public void getItemsAsMapKeyValueTest() { int testSize = 10; - KapuaListResultImpl kapuaListResult = new KapuaListResultImpl<>(); + KapuaListResult kapuaListResult = new KapuaListResult<>(); for (int i = 0; i < testSize; i++) { AbstractKapuaEntity kapuaEntity = Mockito.mock(AbstractKapuaEntity.class); @@ -184,7 +185,7 @@ public void getItemsAsMapKeyValueTest() { @Test public void getItemTest() { - KapuaListResultImpl kapuaListResult = new KapuaListResultImpl<>(); + KapuaListResult kapuaListResult = new KapuaListResult<>(); AbstractKapuaEntity kapuaEntity1 = Mockito.mock(AbstractKapuaEntity.class); kapuaListResult.addItem(kapuaEntity1); @@ -199,7 +200,7 @@ public void getItemTest() { @Test public void getSizeTest() { int testSize = 10; - KapuaListResultImpl kapuaListResult = new KapuaListResultImpl<>(); + KapuaListResult kapuaListResult = new KapuaListResult<>(); for (int i = 0; i < testSize; i++) { kapuaListResult.addItem(Mockito.mock(AbstractKapuaEntity.class)); @@ -210,7 +211,7 @@ public void getSizeTest() { @Test public void isEmptyTest() { - KapuaListResultImpl kapuaListResult = new KapuaListResultImpl<>(); + KapuaListResult kapuaListResult = new KapuaListResult<>(); Assert.assertTrue(kapuaListResult.isEmpty()); kapuaListResult.addItem(Mockito.mock(AbstractKapuaEntity.class)); @@ -219,7 +220,7 @@ public void isEmptyTest() { @Test public void setGetLimitExceededTrueTest() { - KapuaListResultImpl kapuaListResult = new KapuaListResultImpl<>(); + KapuaListResult kapuaListResult = new KapuaListResult<>(); kapuaListResult.setLimitExceeded(true); Assert.assertTrue(kapuaListResult.isLimitExceeded()); @@ -227,7 +228,7 @@ public void setGetLimitExceededTrueTest() { @Test public void setGetLimitExceededFalseTest() { - KapuaListResultImpl kapuaListResult = new KapuaListResultImpl<>(); + KapuaListResult kapuaListResult = new KapuaListResult<>(); kapuaListResult.setLimitExceeded(false); Assert.assertFalse(kapuaListResult.isLimitExceeded()); @@ -235,14 +236,14 @@ public void setGetLimitExceededFalseTest() { @Test public void setGetTotalCountDefaultTest() { - KapuaListResultImpl kapuaListResult = new KapuaListResultImpl<>(); + KapuaListResult kapuaListResult = new KapuaListResult<>(); Assert.assertNull(kapuaListResult.getTotalCount()); } @Test public void setGetTotalCountValueTest() { - KapuaListResultImpl kapuaListResult = new KapuaListResultImpl<>(); + KapuaListResult kapuaListResult = new KapuaListResult<>(); kapuaListResult.setTotalCount(10L); Assert.assertEquals(new Long(10L), kapuaListResult.getTotalCount()); @@ -251,7 +252,7 @@ public void setGetTotalCountValueTest() { @Test public void sortComparatorTest() { int testSize = 10; - KapuaListResultImpl kapuaListResult = new KapuaListResultImpl<>(); + KapuaListResult kapuaListResult = new KapuaListResult<>(); // Add the max value AbstractKapuaEntity kapuaEntityMax = Mockito.mock(AbstractKapuaEntity.class); diff --git a/commons/src/test/java/org/eclipse/kapua/commons/service/event/store/internal/EventStoreFactoryImplTest.java b/commons/src/test/java/org/eclipse/kapua/commons/service/event/store/internal/EventStoreFactoryImplTest.java index 23379802a93..e112a27e521 100644 --- a/commons/src/test/java/org/eclipse/kapua/commons/service/event/store/internal/EventStoreFactoryImplTest.java +++ b/commons/src/test/java/org/eclipse/kapua/commons/service/event/store/internal/EventStoreFactoryImplTest.java @@ -12,11 +12,12 @@ *******************************************************************************/ package org.eclipse.kapua.commons.service.event.store.internal; +import java.math.BigInteger; + import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.commons.model.id.KapuaEid; import org.eclipse.kapua.commons.service.event.store.api.EventStoreRecord; import org.eclipse.kapua.model.id.KapuaId; - import org.eclipse.kapua.qa.markers.junit.JUnitTests; import org.hamcrest.core.IsInstanceOf; import org.junit.Assert; @@ -24,53 +25,42 @@ import org.junit.experimental.categories.Category; import org.mockito.Mockito; -import java.math.BigInteger; - - @Category(JUnitTests.class) public class EventStoreFactoryImplTest { @Test public void newEntityTest() { EventStoreFactoryImpl eventStoreFactoryImpl = new EventStoreFactoryImpl(); - KapuaId[] scopeIdList = {null, new KapuaEid(BigInteger.ONE)}; + KapuaId[] scopeIdList = { null, new KapuaEid(BigInteger.ONE) }; for (KapuaId scopeId : scopeIdList) { Assert.assertNotNull("Null not expected.", eventStoreFactoryImpl.newEntity(scopeId)); - Assert.assertThat("EventStoreRecordImpl object expected.", eventStoreFactoryImpl.newEntity(scopeId), IsInstanceOf.instanceOf(EventStoreRecordImpl.class)); + Assert.assertThat("EventStoreRecordImpl object expected.", eventStoreFactoryImpl.newEntity(scopeId), IsInstanceOf.instanceOf(EventStoreRecordImpl.class)); } } @Test public void newCreatorTest() { EventStoreFactoryImpl eventStoreFactoryImpl = new EventStoreFactoryImpl(); - KapuaId[] scopeIdList = {null, new KapuaEid(BigInteger.ONE)}; + KapuaId[] scopeIdList = { null, new KapuaEid(BigInteger.ONE) }; for (KapuaId scopeId : scopeIdList) { Assert.assertNotNull("Null not expected.", eventStoreFactoryImpl.newCreator(scopeId)); - Assert.assertThat("EventStoreRecordImpl object expected.", eventStoreFactoryImpl.newCreator(scopeId), IsInstanceOf.instanceOf(EventStoreRecordCreatorImpl.class)); + Assert.assertThat("EventStoreRecordImpl object expected.", eventStoreFactoryImpl.newCreator(scopeId), IsInstanceOf.instanceOf(EventStoreRecordCreatorImpl.class)); } } @Test public void newQueryTest() { EventStoreFactoryImpl eventStoreFactoryImpl = new EventStoreFactoryImpl(); - KapuaId[] scopeIdList = {null, new KapuaEid(BigInteger.ONE)}; + KapuaId[] scopeIdList = { null, new KapuaEid(BigInteger.ONE) }; for (KapuaId scopeId : scopeIdList) { Assert.assertNotNull("Null not expected.", eventStoreFactoryImpl.newQuery(scopeId)); - Assert.assertThat("EventStoreQueryImpl object expected.", eventStoreFactoryImpl.newQuery(scopeId), IsInstanceOf.instanceOf(EventStoreQueryImpl.class)); + Assert.assertThat("EventStoreQueryImpl object expected.", eventStoreFactoryImpl.newQuery(scopeId), IsInstanceOf.instanceOf(EventStoreQueryImpl.class)); } } - @Test - public void newListResultTest() { - EventStoreFactoryImpl eventStoreFactoryImpl = new EventStoreFactoryImpl(); - - Assert.assertNotNull("Null not expected.", eventStoreFactoryImpl.newListResult()); - Assert.assertThat("EventStoreRecordListResultImpl object expected.", eventStoreFactoryImpl.newListResult(), IsInstanceOf.instanceOf(EventStoreRecordListResultImpl.class)); - } - @Test public void cloneTest() { EventStoreFactoryImpl eventStoreFactoryImpl = new EventStoreFactoryImpl(); diff --git a/console/module/device/src/main/java/org/eclipse/kapua/app/console/module/device/shared/util/GwtKapuaDeviceModelConverter.java b/console/module/device/src/main/java/org/eclipse/kapua/app/console/module/device/shared/util/GwtKapuaDeviceModelConverter.java index 4a70ef4d824..b9c310f807d 100644 --- a/console/module/device/src/main/java/org/eclipse/kapua/app/console/module/device/shared/util/GwtKapuaDeviceModelConverter.java +++ b/console/module/device/src/main/java/org/eclipse/kapua/app/console/module/device/shared/util/GwtKapuaDeviceModelConverter.java @@ -12,8 +12,9 @@ *******************************************************************************/ package org.eclipse.kapua.app.console.module.device.shared.util; -import com.extjs.gxt.ui.client.Style.SortDir; -import com.extjs.gxt.ui.client.data.PagingLoadConfig; +import java.util.ArrayList; +import java.util.List; + import org.apache.commons.lang3.StringUtils; import org.eclipse.kapua.app.console.module.api.shared.util.GwtKapuaCommonsModelConverter; import org.eclipse.kapua.app.console.module.device.shared.model.GwtDeviceQuery; @@ -51,8 +52,8 @@ import org.eclipse.kapua.service.device.registry.connection.DeviceConnectionQuery; import org.eclipse.kapua.service.device.registry.connection.DeviceConnectionStatus; -import java.util.ArrayList; -import java.util.List; +import com.extjs.gxt.ui.client.Style.SortDir; +import com.extjs.gxt.ui.client.data.PagingLoadConfig; public class GwtKapuaDeviceModelConverter { @@ -64,7 +65,6 @@ public class GwtKapuaDeviceModelConverter { private static final DeviceAssetFactory ASSET_FACTORY = LOCATOR.getFactory(DeviceAssetFactory.class); - private GwtKapuaDeviceModelConverter() { } @@ -89,11 +89,11 @@ public static DeviceConnectionQuery convertConnectionQuery(PagingLoadConfig load } if (gwtDeviceConnectionQuery.getGwtDeviceConnectionReservedUser() != null) { switch (gwtDeviceConnectionQuery.getGwtDeviceConnectionReservedUser()) { - case NONE: - predicate = predicate.and(query.attributePredicate(DeviceConnectionAttributes.RESERVED_USER_ID, null, Operator.IS_NULL)); - break; - default: - predicate = predicate.and(query.attributePredicate(DeviceConnectionAttributes.RESERVED_USER_ID, KapuaEid.parseCompactId(gwtDeviceConnectionQuery.getReservedUserId()))); + case NONE: + predicate = predicate.and(query.attributePredicate(DeviceConnectionAttributes.RESERVED_USER_ID, null, Operator.IS_NULL)); + break; + default: + predicate = predicate.and(query.attributePredicate(DeviceConnectionAttributes.RESERVED_USER_ID, KapuaEid.parseCompactId(gwtDeviceConnectionQuery.getReservedUserId()))); } } @@ -122,7 +122,7 @@ public static DeviceConnectionStatus convertConnectionStatus(String connectionSt } public static DeviceAssets convertDeviceAssets(GwtDeviceAssets deviceAssets) { - DeviceAssets assets = ASSET_FACTORY.newAssetListResult(); + DeviceAssets assets = new DeviceAssets(); List assetList = new ArrayList (); for (GwtDeviceAsset gwtDeviceAsset : deviceAssets.getAssets()) { assetList.add(convertDeviceAsset(gwtDeviceAsset)); @@ -199,22 +199,22 @@ public static DeviceQuery convertDeviceQuery(PagingLoadConfig loadConfig, GwtDev } if (predicates.getDeviceConnectionStatus() != null) { switch (predicates.getDeviceConnectionStatusEnum()) { - case UNKNOWN: - andPred = andPred.and(query.attributePredicate(DeviceAttributes.CONNECTION_ID, DeviceConnectionStatus.NULL, Operator.IS_NULL)); - break; - default: - andPred = andPred.and(query.attributePredicate(DeviceAttributes.CONNECTION_STATUS, DeviceConnectionStatus.valueOf(predicates.getDeviceConnectionStatus()))); + case UNKNOWN: + andPred = andPred.and(query.attributePredicate(DeviceAttributes.CONNECTION_ID, DeviceConnectionStatus.NULL, Operator.IS_NULL)); + break; + default: + andPred = andPred.and(query.attributePredicate(DeviceAttributes.CONNECTION_STATUS, DeviceConnectionStatus.valueOf(predicates.getDeviceConnectionStatus()))); } } if (predicates.getGroupDevice() != null) { switch (predicates.getGroupDeviceEnum()) { - case NO_GROUP: - andPred = andPred.and(query.attributePredicate(DeviceAttributes.GROUP_ID, null, Operator.IS_NULL)); - break; - default: - if (predicates.getGroupId() != null) { - andPred = andPred.and(query.attributePredicate(DeviceAttributes.GROUP_ID, KapuaEid.parseCompactId(predicates.getGroupId()))); - } + case NO_GROUP: + andPred = andPred.and(query.attributePredicate(DeviceAttributes.GROUP_ID, null, Operator.IS_NULL)); + break; + default: + if (predicates.getGroupId() != null) { + andPred = andPred.and(query.attributePredicate(DeviceAttributes.GROUP_ID, KapuaEid.parseCompactId(predicates.getGroupId()))); + } } } if (predicates.getTagIds() != null) { @@ -241,7 +241,6 @@ public static DeviceQuery convertDeviceQuery(PagingLoadConfig loadConfig, GwtDev return query; } - public static DeviceManagementOperationQuery convertDeviceManagementOperationQuery(PagingLoadConfig loadConfig, GwtDeviceManagementOperationQuery gwtQuery) { DeviceManagementOperationQuery query = DEVICE_MANAGEMENT_OPERATION_FACTORY.newQuery(KapuaEid.parseCompactId(gwtQuery.getScopeId())); diff --git a/console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/servlet/JobTargetExporterServlet.java b/console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/servlet/JobTargetExporterServlet.java index 3826c67c117..763c0070c58 100644 --- a/console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/servlet/JobTargetExporterServlet.java +++ b/console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/servlet/JobTargetExporterServlet.java @@ -12,6 +12,13 @@ *******************************************************************************/ package org.eclipse.kapua.app.console.module.job.servlet; +import java.io.IOException; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + import org.eclipse.kapua.KapuaEntityNotFoundException; import org.eclipse.kapua.KapuaIllegalAccessException; import org.eclipse.kapua.KapuaUnauthenticatedException; @@ -21,17 +28,12 @@ import org.eclipse.kapua.service.job.targets.JobTarget; import org.eclipse.kapua.service.job.targets.JobTargetAttributes; import org.eclipse.kapua.service.job.targets.JobTargetFactory; +import org.eclipse.kapua.service.job.targets.JobTargetListResult; import org.eclipse.kapua.service.job.targets.JobTargetQuery; import org.eclipse.kapua.service.job.targets.JobTargetService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; - public class JobTargetExporterServlet extends HttpServlet { private static final long serialVersionUID = -2533869595709953567L; @@ -87,7 +89,7 @@ private void internalDoGet(HttpServletRequest request, HttpServletResponse respo // paginate through the matching message jobTargetQuery.setLimit(250); - KapuaListResult totalJobTargets = jobTargetFactory.newListResult(); + KapuaListResult totalJobTargets = new JobTargetListResult(); KapuaListResult results; do { jobTargetQuery.setOffset(offset); diff --git a/extras/encryption-migrator/src/main/java/org/eclipse/kapua/extras/migrator/encryption/authentication/MfaOptionMigratorJpaRepository.java b/extras/encryption-migrator/src/main/java/org/eclipse/kapua/extras/migrator/encryption/authentication/MfaOptionMigratorJpaRepository.java index aebb923387d..d97364cfe39 100644 --- a/extras/encryption-migrator/src/main/java/org/eclipse/kapua/extras/migrator/encryption/authentication/MfaOptionMigratorJpaRepository.java +++ b/extras/encryption-migrator/src/main/java/org/eclipse/kapua/extras/migrator/encryption/authentication/MfaOptionMigratorJpaRepository.java @@ -12,6 +12,8 @@ *******************************************************************************/ package org.eclipse.kapua.extras.migrator.encryption.authentication; +import java.util.Optional; + import org.eclipse.kapua.commons.jpa.KapuaJpaRepositoryConfiguration; import org.eclipse.kapua.commons.jpa.KapuaUpdatableEntityJpaRepository; import org.eclipse.kapua.model.id.KapuaId; @@ -20,13 +22,12 @@ import org.eclipse.kapua.service.authentication.credential.mfa.MfaOptionRepository; import org.eclipse.kapua.storage.TxContext; -import java.util.Optional; - public class MfaOptionMigratorJpaRepository extends KapuaUpdatableEntityJpaRepository implements MfaOptionRepository { + public MfaOptionMigratorJpaRepository(KapuaJpaRepositoryConfiguration jpaRepoConfig) { - super(MfaOptionMigrator.class, MfaOption.TYPE, () -> new MfaOptionMigratorListResultImpl(), jpaRepoConfig); + super(MfaOptionMigrator.class, MfaOption.TYPE, () -> new MfaOptionListResult(), jpaRepoConfig); } @Override diff --git a/extras/encryption-migrator/src/main/java/org/eclipse/kapua/extras/migrator/encryption/authentication/MfaOptionMigratorListResultImpl.java b/extras/encryption-migrator/src/main/java/org/eclipse/kapua/extras/migrator/encryption/authentication/MfaOptionMigratorListResultImpl.java deleted file mode 100644 index fcade9feb5e..00000000000 --- a/extras/encryption-migrator/src/main/java/org/eclipse/kapua/extras/migrator/encryption/authentication/MfaOptionMigratorListResultImpl.java +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2022 Eurotech and/or its affiliates and others - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Eurotech - initial API and implementation - *******************************************************************************/ -package org.eclipse.kapua.extras.migrator.encryption.authentication; - -import org.eclipse.kapua.commons.model.query.KapuaListResultImpl; -import org.eclipse.kapua.service.authentication.credential.mfa.MfaOption; -import org.eclipse.kapua.service.authentication.credential.mfa.MfaOptionListResult; - -/** - * {@link MfaOptionListResult} implementation. - * - * @since 1.0.0 - */ -public class MfaOptionMigratorListResultImpl extends KapuaListResultImpl implements MfaOptionListResult { -} diff --git a/extras/encryption-migrator/src/main/java/org/eclipse/kapua/extras/migrator/encryption/job/JobStepMigratorJpaRepository.java b/extras/encryption-migrator/src/main/java/org/eclipse/kapua/extras/migrator/encryption/job/JobStepMigratorJpaRepository.java index 252b5bcf617..62e73c3956f 100644 --- a/extras/encryption-migrator/src/main/java/org/eclipse/kapua/extras/migrator/encryption/job/JobStepMigratorJpaRepository.java +++ b/extras/encryption-migrator/src/main/java/org/eclipse/kapua/extras/migrator/encryption/job/JobStepMigratorJpaRepository.java @@ -12,6 +12,8 @@ *******************************************************************************/ package org.eclipse.kapua.extras.migrator.encryption.job; +import java.util.Optional; + import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.commons.jpa.KapuaJpaRepositoryConfiguration; import org.eclipse.kapua.commons.jpa.KapuaNamedEntityJpaRepository; @@ -22,14 +24,12 @@ import org.eclipse.kapua.service.job.step.definition.JobStepProperty; import org.eclipse.kapua.storage.TxContext; -import java.util.Optional; - public class JobStepMigratorJpaRepository extends KapuaNamedEntityJpaRepository implements JobStepRepository { public JobStepMigratorJpaRepository(KapuaJpaRepositoryConfiguration jpaRepoConfig) { - super(JobStepMigrator.class, JobStep.TYPE, () -> new JobStepMigratorListResultImpl(), jpaRepoConfig); + super(JobStepMigrator.class, JobStep.TYPE, () -> new JobStepListResult(), jpaRepoConfig); } @Override diff --git a/extras/encryption-migrator/src/main/java/org/eclipse/kapua/extras/migrator/encryption/job/JobStepMigratorListResultImpl.java b/extras/encryption-migrator/src/main/java/org/eclipse/kapua/extras/migrator/encryption/job/JobStepMigratorListResultImpl.java deleted file mode 100644 index 7662b098c99..00000000000 --- a/extras/encryption-migrator/src/main/java/org/eclipse/kapua/extras/migrator/encryption/job/JobStepMigratorListResultImpl.java +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2022 Eurotech and/or its affiliates and others - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Eurotech - initial API and implementation - *******************************************************************************/ -package org.eclipse.kapua.extras.migrator.encryption.job; - -import org.eclipse.kapua.commons.model.query.KapuaListResultImpl; -import org.eclipse.kapua.service.job.step.JobStep; -import org.eclipse.kapua.service.job.step.JobStepListResult; - -/** - * {@link JobStepListResult} implementation. - * - * @since 1.0.0 - */ -public class JobStepMigratorListResultImpl extends KapuaListResultImpl implements JobStepListResult { -} diff --git a/job-engine/api/src/main/java/org/eclipse/kapua/job/engine/queue/QueuedJobExecutionFactory.java b/job-engine/api/src/main/java/org/eclipse/kapua/job/engine/queue/QueuedJobExecutionFactory.java index 788da3a3d2f..88305e0d0a6 100644 --- a/job-engine/api/src/main/java/org/eclipse/kapua/job/engine/queue/QueuedJobExecutionFactory.java +++ b/job-engine/api/src/main/java/org/eclipse/kapua/job/engine/queue/QueuedJobExecutionFactory.java @@ -19,6 +19,6 @@ * * @since 1.1.0 */ -public interface QueuedJobExecutionFactory extends KapuaEntityFactory { +public interface QueuedJobExecutionFactory extends KapuaEntityFactory { } diff --git a/job-engine/api/src/main/java/org/eclipse/kapua/job/engine/queue/QueuedJobExecutionListResult.java b/job-engine/api/src/main/java/org/eclipse/kapua/job/engine/queue/QueuedJobExecutionListResult.java index d3c35da8534..906559a3a38 100644 --- a/job-engine/api/src/main/java/org/eclipse/kapua/job/engine/queue/QueuedJobExecutionListResult.java +++ b/job-engine/api/src/main/java/org/eclipse/kapua/job/engine/queue/QueuedJobExecutionListResult.java @@ -26,7 +26,7 @@ */ @XmlRootElement(name = "queuedJobListResult") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = QueuedJobExecutionXmlRegistry.class, factoryMethod = "newQueuedJobExecutionListResult") -public interface QueuedJobExecutionListResult extends KapuaListResult { +@XmlType +public class QueuedJobExecutionListResult extends KapuaListResult { } diff --git a/job-engine/api/src/main/java/org/eclipse/kapua/job/engine/queue/QueuedJobExecutionXmlRegistry.java b/job-engine/api/src/main/java/org/eclipse/kapua/job/engine/queue/QueuedJobExecutionXmlRegistry.java index 3f5554b0966..e8a33d71999 100644 --- a/job-engine/api/src/main/java/org/eclipse/kapua/job/engine/queue/QueuedJobExecutionXmlRegistry.java +++ b/job-engine/api/src/main/java/org/eclipse/kapua/job/engine/queue/QueuedJobExecutionXmlRegistry.java @@ -12,10 +12,10 @@ *******************************************************************************/ package org.eclipse.kapua.job.engine.queue; -import org.eclipse.kapua.locator.KapuaLocator; - import javax.xml.bind.annotation.XmlRegistry; +import org.eclipse.kapua.locator.KapuaLocator; + /** * {@link QueuedJobExecution} xml factory class * @@ -44,15 +44,6 @@ public QueuedJobExecutionCreator newQueuedJobExecutionCreator() { return queuedJobExecutionFactory.newCreator(null); } - /** - * Creates a new job list result instance - * - * @return - */ - public QueuedJobExecutionListResult newQueuedJobExecutionListResult() { - return queuedJobExecutionFactory.newListResult(); - } - public QueuedJobExecutionQuery newQuery() { return queuedJobExecutionFactory.newQuery(null); } diff --git a/job-engine/jbatch/src/main/java/org/eclipse/kapua/job/engine/queue/jbatch/QueuedJobExecutionFactoryImpl.java b/job-engine/jbatch/src/main/java/org/eclipse/kapua/job/engine/queue/jbatch/QueuedJobExecutionFactoryImpl.java index fd5c6642390..6a9029ac52b 100644 --- a/job-engine/jbatch/src/main/java/org/eclipse/kapua/job/engine/queue/jbatch/QueuedJobExecutionFactoryImpl.java +++ b/job-engine/jbatch/src/main/java/org/eclipse/kapua/job/engine/queue/jbatch/QueuedJobExecutionFactoryImpl.java @@ -12,16 +12,15 @@ *******************************************************************************/ package org.eclipse.kapua.job.engine.queue.jbatch; +import javax.inject.Singleton; + import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.job.engine.queue.QueuedJobExecution; import org.eclipse.kapua.job.engine.queue.QueuedJobExecutionCreator; import org.eclipse.kapua.job.engine.queue.QueuedJobExecutionFactory; -import org.eclipse.kapua.job.engine.queue.QueuedJobExecutionListResult; import org.eclipse.kapua.job.engine.queue.QueuedJobExecutionQuery; import org.eclipse.kapua.model.id.KapuaId; -import javax.inject.Singleton; - /** * {@link QueuedJobExecutionFactory} implementation. * @@ -45,11 +44,6 @@ public QueuedJobExecutionQuery newQuery(KapuaId scopeId) { return new QueuedJobExecutionQueryImpl(scopeId); } - @Override - public QueuedJobExecutionListResult newListResult() { - return new QueuedJobExecutionListResultImpl(); - } - @Override public QueuedJobExecution clone(QueuedJobExecution queuedJobExecution) { try { diff --git a/job-engine/jbatch/src/main/java/org/eclipse/kapua/job/engine/queue/jbatch/QueuedJobExecutionImplJpaRepository.java b/job-engine/jbatch/src/main/java/org/eclipse/kapua/job/engine/queue/jbatch/QueuedJobExecutionImplJpaRepository.java index a5956470dbf..d4b98e6d520 100644 --- a/job-engine/jbatch/src/main/java/org/eclipse/kapua/job/engine/queue/jbatch/QueuedJobExecutionImplJpaRepository.java +++ b/job-engine/jbatch/src/main/java/org/eclipse/kapua/job/engine/queue/jbatch/QueuedJobExecutionImplJpaRepository.java @@ -22,7 +22,8 @@ public class QueuedJobExecutionImplJpaRepository extends KapuaUpdatableEntityJpaRepository implements QueuedJobExecutionRepository { + public QueuedJobExecutionImplJpaRepository(KapuaJpaRepositoryConfiguration jpaRepoConfig) { - super(QueuedJobExecutionImpl.class, JobExecution.TYPE, () -> new QueuedJobExecutionListResultImpl(), jpaRepoConfig); + super(QueuedJobExecutionImpl.class, JobExecution.TYPE, () -> new QueuedJobExecutionListResult(), jpaRepoConfig); } } diff --git a/job-engine/jbatch/src/main/java/org/eclipse/kapua/job/engine/queue/jbatch/QueuedJobExecutionListResultImpl.java b/job-engine/jbatch/src/main/java/org/eclipse/kapua/job/engine/queue/jbatch/QueuedJobExecutionListResultImpl.java deleted file mode 100644 index d7a642d35d0..00000000000 --- a/job-engine/jbatch/src/main/java/org/eclipse/kapua/job/engine/queue/jbatch/QueuedJobExecutionListResultImpl.java +++ /dev/null @@ -1,26 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2019, 2022 Eurotech and/or its affiliates and others - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Eurotech - initial API and implementation - *******************************************************************************/ -package org.eclipse.kapua.job.engine.queue.jbatch; - -import org.eclipse.kapua.commons.model.query.KapuaListResultImpl; -import org.eclipse.kapua.job.engine.queue.QueuedJobExecution; -import org.eclipse.kapua.job.engine.queue.QueuedJobExecutionListResult; - -/** - * {@link QueuedJobExecutionListResult} implementation. - * - * @since 1.1.0 - */ -public class QueuedJobExecutionListResultImpl extends KapuaListResultImpl implements QueuedJobExecutionListResult { - -} diff --git a/qa/integration/src/test/java/org/eclipse/kapua/integration/misc/RolePermissionFactoryTest.java b/qa/integration/src/test/java/org/eclipse/kapua/integration/misc/RolePermissionFactoryTest.java index 0c5d9152e5c..6de74c1e466 100644 --- a/qa/integration/src/test/java/org/eclipse/kapua/integration/misc/RolePermissionFactoryTest.java +++ b/qa/integration/src/test/java/org/eclipse/kapua/integration/misc/RolePermissionFactoryTest.java @@ -12,12 +12,13 @@ *******************************************************************************/ package org.eclipse.kapua.integration.misc; +import java.util.Date; + import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.qa.markers.junit.JUnitTests; import org.eclipse.kapua.service.authorization.permission.shiro.PermissionImpl; import org.eclipse.kapua.service.authorization.role.RolePermission; import org.eclipse.kapua.service.authorization.role.RolePermissionCreator; -import org.eclipse.kapua.service.authorization.role.RolePermissionListResult; import org.eclipse.kapua.service.authorization.role.RolePermissionQuery; import org.eclipse.kapua.service.authorization.role.shiro.RolePermissionFactoryImpl; import org.junit.Assert; @@ -26,9 +27,6 @@ import org.junit.experimental.categories.Category; import org.mockito.Mockito; -import java.util.Date; - - @Category(JUnitTests.class) public class RolePermissionFactoryTest { @@ -91,12 +89,6 @@ public void newQueryNullTest() { Assert.assertNull("Null expected.", rolePermissionFactoryImpl.newQuery(null).getScopeId()); } - @Test - public void newListResultTest() { - Assert.assertTrue("True expected.", rolePermissionFactoryImpl.newListResult() instanceof RolePermissionListResult); - Assert.assertTrue("True expected.", rolePermissionFactoryImpl.newListResult().isEmpty()); - } - @Test public void cloneTest() { RolePermission resultRolePermission = rolePermissionFactoryImpl.clone(rolePermission); diff --git a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/DeviceManagementAssets.java b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/DeviceManagementAssets.java index a3e12cc6f7d..ea256b9ced7 100644 --- a/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/DeviceManagementAssets.java +++ b/rest-api/resources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/DeviceManagementAssets.java @@ -12,6 +12,18 @@ *******************************************************************************/ package org.eclipse.kapua.app.api.resources.v1.resources; +import javax.inject.Inject; +import javax.ws.rs.DefaultValue; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.app.api.core.model.EntityId; import org.eclipse.kapua.app.api.core.model.ScopeId; @@ -25,18 +37,6 @@ import org.eclipse.kapua.service.device.management.asset.store.settings.DeviceAssetStoreSettings; import org.eclipse.kapua.service.device.registry.Device; -import javax.inject.Inject; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - @Path("{scopeId}/devices/{deviceId}/assets") public class DeviceManagementAssets extends AbstractKapuaResource { @@ -50,34 +50,42 @@ public class DeviceManagementAssets extends AbstractKapuaResource { /** * Returns the list of all the Assets configured on the device. * - * @param scopeId The {@link ScopeId} of the {@link Device}. - * @param deviceId The id of the device - * @param timeout The timeout of the operation in milliseconds + * @param scopeId + * The {@link ScopeId} of the {@link Device}. + * @param deviceId + * The id of the device + * @param timeout + * The timeout of the operation in milliseconds * @return The list of Assets - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @GET - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public DeviceAssets get( @PathParam("scopeId") ScopeId scopeId, @PathParam("deviceId") EntityId deviceId, @QueryParam("timeout") @DefaultValue("30000") Long timeout) throws KapuaException { - return get(scopeId, deviceId, timeout, deviceAssetFilter.newAssetListResult()); + return get(scopeId, deviceId, timeout, new DeviceAssets()); } /** * Returns the list of all the Assets configured on the device filtered by the {@link DeviceAssets} parameter. * - * @param scopeId The {@link ScopeId} of the {@link Device}. - * @param deviceId The id of the device - * @param timeout The timeout of the operation in milliseconds + * @param scopeId + * The {@link ScopeId} of the {@link Device}. + * @param deviceId + * The id of the device + * @param timeout + * The timeout of the operation in milliseconds * @return The list of Assets - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @POST - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public DeviceAssets get( @PathParam("scopeId") ScopeId scopeId, @PathParam("deviceId") EntityId deviceId, @@ -89,16 +97,20 @@ public DeviceAssets get( /** * Reads {@link DeviceAssetChannel}s values available on the device filtered by the {@link DeviceAssets} parameter. * - * @param scopeId The {@link ScopeId} of the {@link Device}. - * @param deviceId The id of the device - * @param timeout The timeout of the operation in milliseconds + * @param scopeId + * The {@link ScopeId} of the {@link Device}. + * @param deviceId + * The id of the device + * @param timeout + * The timeout of the operation in milliseconds * @return The list of Assets - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @POST @Path("_read") - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public DeviceAssets read( @PathParam("scopeId") ScopeId scopeId, @PathParam("deviceId") EntityId deviceId, @@ -110,16 +122,20 @@ public DeviceAssets read( /** * Writes {@link DeviceAssetChannel}s configured on the device filtered by the {@link DeviceAssets} parameter. * - * @param scopeId The {@link ScopeId} of the {@link Device}. - * @param deviceId The id of the device - * @param timeout The timeout of the operation in milliseconds + * @param scopeId + * The {@link ScopeId} of the {@link Device}. + * @param deviceId + * The id of the device + * @param timeout + * The timeout of the operation in milliseconds * @return The list of Assets - * @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. + * @throws KapuaException + * Whenever something bad happens. See specific {@link KapuaService} exceptions. * @since 1.0.0 */ @POST @Path("_write") - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public DeviceAssets write( @PathParam("scopeId") ScopeId scopeId, @PathParam("deviceId") EntityId deviceId, @@ -130,7 +146,7 @@ public DeviceAssets write( @GET @Path("_settings") - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public DeviceAssetStoreSettings getSettings( @PathParam("scopeId") ScopeId scopeId, @PathParam("deviceId") EntityId deviceId) @@ -140,7 +156,7 @@ public DeviceAssetStoreSettings getSettings( @PUT @Path("_settings") - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public Response postSettings( @PathParam("scopeId") ScopeId scopeId, @PathParam("deviceId") EntityId deviceId, diff --git a/service/account/api/src/main/java/org/eclipse/kapua/service/account/AccountFactory.java b/service/account/api/src/main/java/org/eclipse/kapua/service/account/AccountFactory.java index 81ee1ba3ba5..9e2a0d806ad 100644 --- a/service/account/api/src/main/java/org/eclipse/kapua/service/account/AccountFactory.java +++ b/service/account/api/src/main/java/org/eclipse/kapua/service/account/AccountFactory.java @@ -21,13 +21,15 @@ * @see KapuaEntityFactory * @since 1.0.0 */ -public interface AccountFactory extends KapuaEntityFactory { +public interface AccountFactory extends KapuaEntityFactory { /** * Instantiates a new {@link AccountCreator} with the given name. * - * @param scopeId The scope {@link KapuaId} to set in the {@link AccountCreator} - * @param name The name to set in the {@link AccountCreator} + * @param scopeId + * The scope {@link KapuaId} to set in the {@link AccountCreator} + * @param name + * The name to set in the {@link AccountCreator} * @return The newly instantiated {@link AccountCreator} * @since 1.0.0 * @deprecated Since 1.6.0. Please make use of {@link #newCreator(KapuaId)} and then use {@link AccountCreator#setName(String)}. diff --git a/service/account/api/src/main/java/org/eclipse/kapua/service/account/AccountListResult.java b/service/account/api/src/main/java/org/eclipse/kapua/service/account/AccountListResult.java index 2a722a816d7..e6802552b7c 100644 --- a/service/account/api/src/main/java/org/eclipse/kapua/service/account/AccountListResult.java +++ b/service/account/api/src/main/java/org/eclipse/kapua/service/account/AccountListResult.java @@ -12,14 +12,13 @@ *******************************************************************************/ package org.eclipse.kapua.service.account; -import org.eclipse.kapua.model.query.KapuaListResult; -import org.eclipse.kapua.service.account.xml.AccountXmlRegistry; - import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import org.eclipse.kapua.model.query.KapuaListResult; + /** * {@link Account} {@link KapuaListResult} definition. * @@ -28,7 +27,9 @@ */ @XmlRootElement(name = "accountListResult") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = AccountXmlRegistry.class, factoryMethod = "newAccountListResult") -public interface AccountListResult extends KapuaListResult { +@XmlType +public class AccountListResult extends KapuaListResult { + + private static final long serialVersionUID = -5118004898345748297L; } diff --git a/service/account/api/src/main/java/org/eclipse/kapua/service/account/xml/AccountXmlRegistry.java b/service/account/api/src/main/java/org/eclipse/kapua/service/account/xml/AccountXmlRegistry.java index c18879dfbeb..08ea6672fee 100644 --- a/service/account/api/src/main/java/org/eclipse/kapua/service/account/xml/AccountXmlRegistry.java +++ b/service/account/api/src/main/java/org/eclipse/kapua/service/account/xml/AccountXmlRegistry.java @@ -12,16 +12,15 @@ *******************************************************************************/ package org.eclipse.kapua.service.account.xml; +import javax.xml.bind.annotation.XmlRegistry; + import org.eclipse.kapua.locator.KapuaLocator; import org.eclipse.kapua.service.account.Account; import org.eclipse.kapua.service.account.AccountCreator; import org.eclipse.kapua.service.account.AccountFactory; -import org.eclipse.kapua.service.account.AccountListResult; import org.eclipse.kapua.service.account.AccountQuery; import org.eclipse.kapua.service.account.Organization; -import javax.xml.bind.annotation.XmlRegistry; - /** * {@link Account} xml factory class * @@ -53,16 +52,6 @@ public AccountCreator newAccountCreator() { return factory.newCreator(null); } - /** - * Instantiates a new {@link AccountListResult}. - * - * @return The newly instantiated {@link AccountListResult}. - * @since 1.0.0 - */ - public AccountListResult newAccountListResult() { - return factory.newListResult(); - } - /** * Instantiates a new {@link AccountQuery}. * diff --git a/service/account/internal/src/main/java/org/eclipse/kapua/service/account/internal/AccountFactoryImpl.java b/service/account/internal/src/main/java/org/eclipse/kapua/service/account/internal/AccountFactoryImpl.java index 947da2ca339..39a2399496f 100644 --- a/service/account/internal/src/main/java/org/eclipse/kapua/service/account/internal/AccountFactoryImpl.java +++ b/service/account/internal/src/main/java/org/eclipse/kapua/service/account/internal/AccountFactoryImpl.java @@ -12,17 +12,16 @@ *******************************************************************************/ package org.eclipse.kapua.service.account.internal; +import javax.inject.Singleton; + import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.account.Account; import org.eclipse.kapua.service.account.AccountCreator; import org.eclipse.kapua.service.account.AccountFactory; -import org.eclipse.kapua.service.account.AccountListResult; import org.eclipse.kapua.service.account.AccountQuery; import org.eclipse.kapua.service.account.Organization; -import javax.inject.Singleton; - /** * {@link AccountFactory} implementation. * @@ -58,11 +57,6 @@ public AccountQuery newQuery(KapuaId scopeId) { return new AccountQueryImpl(scopeId); } - @Override - public AccountListResult newListResult() { - return new AccountListResultImpl(); - } - @Override public Account clone(Account account) { try { diff --git a/service/account/internal/src/main/java/org/eclipse/kapua/service/account/internal/AccountImplJpaRepository.java b/service/account/internal/src/main/java/org/eclipse/kapua/service/account/internal/AccountImplJpaRepository.java index 123d2691720..40eaad6d959 100644 --- a/service/account/internal/src/main/java/org/eclipse/kapua/service/account/internal/AccountImplJpaRepository.java +++ b/service/account/internal/src/main/java/org/eclipse/kapua/service/account/internal/AccountImplJpaRepository.java @@ -12,6 +12,9 @@ *******************************************************************************/ package org.eclipse.kapua.service.account.internal; +import javax.persistence.EntityManager; +import javax.persistence.TypedQuery; + import org.eclipse.kapua.commons.jpa.JpaAwareTxContext; import org.eclipse.kapua.commons.jpa.KapuaJpaRepositoryConfiguration; import org.eclipse.kapua.commons.jpa.KapuaNamedEntityJpaRepository; @@ -20,15 +23,12 @@ import org.eclipse.kapua.service.account.AccountRepository; import org.eclipse.kapua.storage.TxContext; -import javax.persistence.EntityManager; -import javax.persistence.TypedQuery; - public class AccountImplJpaRepository extends KapuaNamedEntityJpaRepository implements AccountRepository { public AccountImplJpaRepository(KapuaJpaRepositoryConfiguration jpaRepoConfig) { - super(AccountImpl.class, Account.TYPE, () -> new AccountListResultImpl(), jpaRepoConfig); + super(AccountImpl.class, Account.TYPE, () -> new AccountListResult(), jpaRepoConfig); } @Override diff --git a/service/account/internal/src/main/java/org/eclipse/kapua/service/account/internal/AccountListResultImpl.java b/service/account/internal/src/main/java/org/eclipse/kapua/service/account/internal/AccountListResultImpl.java deleted file mode 100644 index 34d05856e03..00000000000 --- a/service/account/internal/src/main/java/org/eclipse/kapua/service/account/internal/AccountListResultImpl.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016, 2022 Eurotech and/or its affiliates and others - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Eurotech - initial API and implementation - *******************************************************************************/ -package org.eclipse.kapua.service.account.internal; - -import org.eclipse.kapua.commons.model.query.KapuaListResultImpl; -import org.eclipse.kapua.service.account.Account; -import org.eclipse.kapua.service.account.AccountListResult; - -/** - * {@link AccountListResult} implementation. - * - * @since 1.0.0 - */ -public class AccountListResultImpl extends KapuaListResultImpl implements AccountListResult { - - private static final long serialVersionUID = -5118004898345748297L; -} diff --git a/service/api/src/main/java/org/eclipse/kapua/model/KapuaEntityFactory.java b/service/api/src/main/java/org/eclipse/kapua/model/KapuaEntityFactory.java index 9ff2033129b..3bbc106a6f6 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,18 +20,23 @@ /** * {@link KapuaEntityFactory} definition. * - * @param The {@link KapuaEntity} for which this {@link KapuaEntityFactory} is for. - * @param The {@link KapuaEntityCreator} for which this {@link KapuaEntityFactory} is for. - * @param The {@link KapuaQuery} for which this {@link KapuaEntityFactory} is for. - * @paramThe {@link KapuaListResult} for which this {@link KapuaEntityFactory} is for. + * @param + * The {@link KapuaEntity} for which this {@link KapuaEntityFactory} is for. + * @param + * The {@link KapuaEntityCreator} for which this {@link KapuaEntityFactory} is for. + * @param + * The {@link KapuaQuery} for which this {@link KapuaEntityFactory} is for. + * @param+ * The {@link KapuaListResult} for which this {@link KapuaEntityFactory} is for. * @since 1.0.0 */ -public interface KapuaEntityFactory , Q extends KapuaQuery, L extends KapuaListResult > extends KapuaObjectFactory { +public interface KapuaEntityFactory , Q extends KapuaQuery> extends KapuaObjectFactory { /** * Instantiates a new {@link KapuaEntity}. * - * @param scopeId The scope {@link KapuaId} to be set in the {@link KapuaEntity} + * @param scopeId + * The scope {@link KapuaId} to be set in the {@link KapuaEntity} * @return The newly instantiated {@link KapuaEntity} * @since 1.0.0 */ @@ -40,7 +45,8 @@ public interface KapuaEntityFactory {@link KapuaEntity} type. + * @param + * {@link KapuaEntity} type. * @since 1.0.0 */ @XmlRootElement(name = "result") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(propOrder = {"limitExceeded", "size", "items", "totalCount"}) -public interface KapuaListResult extends KapuaSerializable { +@XmlType(propOrder = { "limitExceeded", "size", "items", "totalCount" }) +public class KapuaListResult implements KapuaSerializable { + + private static final long serialVersionUID = 8939666089540269261L; + + private ArrayList items; + private boolean limitExceeded; + private Long totalCount; + + /** + * Constructor. + * + * @since 1.0.0 + */ + public KapuaListResult() { + limitExceeded = false; + } /** * Gets the limit exceeded flag. * - * This flag is {@code true} if there are more results that exceded the {@link KapuaQuery#getLimit()}. - * Increasing the {@link KapuaQuery#getLimit()} or moving the {@link KapuaQuery#getOffset()} will return more results + * This flag is {@code true} if there are more results that exceded the {@link KapuaQuery#getLimit()}. Increasing the {@link KapuaQuery#getLimit()} or moving the {@link KapuaQuery#getOffset()} + * will return more results * * @return The limit exceeded flag * @since 1.0.0 */ @XmlElement(name = "limitExceeded") - boolean isLimitExceeded(); + public boolean isLimitExceeded() { + return limitExceeded; + } /** * Sets the limit exceeded flag. *
* To be set to {@code true} if the {@link KapuaQuery} matching elements are more than {@link KapuaQuery#getLimit()}. * - * @param limitExceeded The limit exceeded flag. + * @param limitExceeded + * The limit exceeded flag. * @since 1.0.0 */ - void setLimitExceeded(boolean limitExceeded); + public void setLimitExceeded(boolean limitExceeded) { + this.limitExceeded = limitExceeded; + } /** * Gets the {@link KapuaEntity}s that matched the {@link KapuaQuery#getPredicate()}. @@ -72,55 +95,77 @@ public interface KapuaListResult
extends KapuaSerializabl */ @XmlElementWrapper(name = "items") @XmlElement(name = "item") - List getItems(); + public List getItems() { + if (items == null) { + items = new ArrayList<>(); + } + + return items; + } /** * Gets the {@link KapuaEntity}s that matched the {@link KapuaQuery#getPredicate()} and applies even more filtering. * * This is meant to be used to filter result when is not possible to do so with {@link KapuaQuery#getPredicate()}s. * - * @param filter The filter to apply to select results. + * @param filter + * The filter to apply to select results. * @return The filtered {@link KapuaEntity}s that matched the {@link KapuaQuery#getPredicate()}. * @since 2.0.0 */ - List
getItems(@NotNull Predicate filter); + public List getItems(Predicate filter) { + return getItems().stream().filter(filter).collect(Collectors.toList()); + } /** - * Gets a {@link Map} whose {@link Map#keySet()} are generated from the given {@link Map.Entry#getKey()} mapper {@link Function}. - * The {@link Map#values()} are the {@link KapuaEntity}s themself. + * Gets a {@link Map} whose {@link Map#keySet()} are generated from the given {@link Map.Entry#getKey()} mapper {@link Function}. The {@link Map#values()} are the {@link KapuaEntity}s themself. * * This is like invoking {@link #getItemsAsMap(Function, Function)} whose value mapper returns the {@link KapuaEntity} itself. * - * @param keyMapper The {@link Function} which defines the {@link Map.Entry#getKey()} for each {@link Map.Entry} - * @param
The type of the {@link Map.Entry#getKey()} + * @param keyMapper + * The {@link Function} which defines the {@link Map.Entry#getKey()} for each {@link Map.Entry} + * @param + * The type of the {@link Map.Entry#getKey()} * @return The {@link Map} generated according to the mapping {@link Map.Entry#getKey()} {@link Function}. * @since 2.0.0 */ - Map getItemsAsMap(@NotNull Function keyMapper); + public Map getItemsAsMap(Function keyMapper) { + return getItems().stream().collect(Collectors.toMap(keyMapper, e -> e)); + } /** - * Gets a {@link Map} whose {@link Map#keySet()} are generated from the given {@link Map.Entry#getKey()} mapper {@link Function}. - * The {@link Map#values()} are generated from the given {@link Map.Entry#getValue()} mapper {@link Function}. + * Gets a {@link Map} whose {@link Map#keySet()} are generated from the given {@link Map.Entry#getKey()} mapper {@link Function}. The {@link Map#values()} are generated from the given + * {@link Map.Entry#getValue()} mapper {@link Function}. * - * @param keyMapper The {@link Function} which defines the {@link Map.Entry#getKey()} for each {@link Map.Entry} - * @param valueMapper The {@link Function} which defines the {@link Map.Entry#getValue()} for each {@link Map.Entry} - * @param The type of the {@link Map.Entry#getKey()} - * @param The type of the {@link Map.Entry#getValue()} + * @param keyMapper + * The {@link Function} which defines the {@link Map.Entry#getKey()} for each {@link Map.Entry} + * @param valueMapper + * The {@link Function} which defines the {@link Map.Entry#getValue()} for each {@link Map.Entry} + * @param + * The type of the {@link Map.Entry#getKey()} + * @param + * The type of the {@link Map.Entry#getValue()} * @return The {@link Map} generated according to the mapping {@link Function}s. * @since 2.0.0 */ - Map getItemsAsMap(@NotNull Function keyMapper, @NotNull Function valueMapper); + public Map getItemsAsMap(Function keyMapper, Function valueMapper) { + return getItems().stream().collect(Collectors.toMap(keyMapper, valueMapper)); + } /** * Gets the {@link KapuaEntity} at the given position in the {@link KapuaListResult}. * - * @param i The position in the {@link KapuaListResult} + * @param index + * The position in the {@link KapuaListResult} * @return The {@link KapuaEntity} at the position - * @throws IndexOutOfBoundsException If position is not available. + * @throws IndexOutOfBoundsException + * If position is not available. * @see List#get(int) * @since 1.0.0 */ - E getItem(int i); + public E getItem(int index) { + return getItems().get(index); + } /** * Gets the first {@link KapuaEntity} in the {@link KapuaListResult}. @@ -130,7 +175,9 @@ public interface KapuaListResult extends KapuaSerializabl * @return The first element in the {@link KapuaListResult} or {@code null} if not present. * @since 1.0.0 */ - E getFirstItem(); + public E getFirstItem() { + return this.isEmpty() ? null : getItem(0); + } /** * Gets the result {@link KapuaListResult} size @@ -140,7 +187,9 @@ public interface KapuaListResult extends KapuaSerializabl * @since 1.0.0 */ @XmlElement(name = "size") - int getSize(); + public int getSize() { + return getItems().size(); + } /** * Checks if the result {@link KapuaListResult} is empty @@ -149,23 +198,31 @@ public interface KapuaListResult extends KapuaSerializabl * @see List#isEmpty() * @since 1.0.0 */ - boolean isEmpty(); + public boolean isEmpty() { + return getItems().isEmpty(); + } /** * Adds {@link KapuaEntity}s to the result {@link KapuaListResult} * - * @param items The {@link KapuaEntity}s to add. + * @param items + * The {@link KapuaEntity}s to add. * @see List#addAll(Collection) * @since 1.0.0 */ - void addItems(@NotNull Collection extends E> items); + public void addItems(Collection extends E> items) { + getItems().addAll(items); + } /** * Adds a {@link KapuaEntity} to the {@link KapuaListResult}. * - * @param item The {@link KapuaEntity} to add. + * @param item + * The {@link KapuaEntity} to add. */ - void addItem(@NotNull E item); + public void addItem(E item) { + getItems().add(item); + } /** * Clears {@link KapuaEntity} result {@link KapuaListResult} @@ -173,17 +230,22 @@ public interface KapuaListResult extends KapuaSerializabl * @see List#clear() * @since 1.0.0 */ - void clearItems(); + public void clearItems() { + getItems().clear(); + } /** * Sorts the result {@link List} according to the given {@link Comparator}. * - * @param comparator The {@link Comparator} used to compare items. + * @param comparator + * The {@link Comparator} used to compare items. * @see List#sort(Comparator) * @see Comparator * @since 1.0.0 */ - void sort(@NotNull Comparator comparator); + public void sort(Comparator comparator) { + getItems().sort(comparator); + } /** * Gets the total count of entries that match the {@link KapuaQuery#getPredicate()}s regardless of {@link KapuaQuery#getLimit()} and {@link KapuaQuery#getOffset()} @@ -191,12 +253,16 @@ public interface KapuaListResult extends KapuaSerializabl * @return The total count * @since 1.2.0 */ - Long getTotalCount(); + public Long getTotalCount() { + return totalCount; + } /** * Sets the total count of entries that match the {@link KapuaQuery#getPredicate()}s regardless of {@link KapuaQuery#getLimit()} and {@link KapuaQuery#getOffset()}. * * @since 1.2.0 */ - void setTotalCount(Long totalCount); + public void setTotalCount(Long totalCount) { + this.totalCount = totalCount; + } } diff --git a/service/datastore/internal/src/main/java/org/eclipse/kapua/service/datastore/internal/model/ChannelInfoListResultImpl.java b/service/datastore/internal/src/main/java/org/eclipse/kapua/service/datastore/internal/model/ChannelInfoListResultImpl.java index 30ed498d629..94786a11658 100644 --- a/service/datastore/internal/src/main/java/org/eclipse/kapua/service/datastore/internal/model/ChannelInfoListResultImpl.java +++ b/service/datastore/internal/src/main/java/org/eclipse/kapua/service/datastore/internal/model/ChannelInfoListResultImpl.java @@ -14,7 +14,6 @@ import org.eclipse.kapua.service.datastore.model.ChannelInfo; import org.eclipse.kapua.service.datastore.model.ChannelInfoListResult; -import org.eclipse.kapua.service.elasticsearch.client.model.ResultList; import org.eclipse.kapua.service.storable.model.AbstractStorableListResult; /** @@ -24,25 +23,4 @@ */ public class ChannelInfoListResultImpl extends AbstractStorableListResult implements ChannelInfoListResult { - private static final long serialVersionUID = 1L; - - /** - * Constructor. - * - * @since 1.0.0 - */ - public ChannelInfoListResultImpl() { - super(); - } - - /** - * Constructor. - * - * @param resultList The {@link ResultList} to add. - * @since 1.0.0 - */ - public ChannelInfoListResultImpl(ResultList resultList) { - super(resultList.getResult(), resultList.getTotalCount()); - } - } diff --git a/service/device/management/asset/api/src/main/java/org/eclipse/kapua/service/device/management/asset/DeviceAssetFactory.java b/service/device/management/asset/api/src/main/java/org/eclipse/kapua/service/device/management/asset/DeviceAssetFactory.java index 2898dc9e806..ccef9ce5087 100644 --- a/service/device/management/asset/api/src/main/java/org/eclipse/kapua/service/device/management/asset/DeviceAssetFactory.java +++ b/service/device/management/asset/api/src/main/java/org/eclipse/kapua/service/device/management/asset/DeviceAssetFactory.java @@ -22,14 +22,6 @@ */ public interface DeviceAssetFactory extends KapuaObjectFactory { - /** - * Instantiates a new {@link DeviceAssets} instance. - * - * @return The newly instantiated {@link DeviceAssets}. - * @since 1.0.0 - */ - DeviceAssets newAssetListResult(); - /** * Instantiates a new {@link DeviceAsset} instance. * diff --git a/service/device/management/asset/api/src/main/java/org/eclipse/kapua/service/device/management/asset/DeviceAssetXmlRegistry.java b/service/device/management/asset/api/src/main/java/org/eclipse/kapua/service/device/management/asset/DeviceAssetXmlRegistry.java index 3756d7c6ae8..73d5e2b2d2c 100644 --- a/service/device/management/asset/api/src/main/java/org/eclipse/kapua/service/device/management/asset/DeviceAssetXmlRegistry.java +++ b/service/device/management/asset/api/src/main/java/org/eclipse/kapua/service/device/management/asset/DeviceAssetXmlRegistry.java @@ -12,10 +12,10 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.management.asset; -import org.eclipse.kapua.locator.KapuaLocator; - import javax.xml.bind.annotation.XmlRegistry; +import org.eclipse.kapua.locator.KapuaLocator; + /** * {@link DeviceAsset} XML factory class * @@ -26,16 +26,6 @@ public class DeviceAssetXmlRegistry { private final DeviceAssetFactory deviceAssetFactory = KapuaLocator.getInstance().getFactory(DeviceAssetFactory.class); - /** - * Instantiate a new {@link DeviceAssets}. - * - * @return The newly instantiate {@link DeviceAssets}. - * @since 1.0.0 - */ - public DeviceAssets newAssetListResult() { - return deviceAssetFactory.newAssetListResult(); - } - /** * Instantiate a new {@link DeviceAsset}. * diff --git a/service/device/management/asset/api/src/main/java/org/eclipse/kapua/service/device/management/asset/DeviceAssets.java b/service/device/management/asset/api/src/main/java/org/eclipse/kapua/service/device/management/asset/DeviceAssets.java index c5519a59607..5cd77306707 100644 --- a/service/device/management/asset/api/src/main/java/org/eclipse/kapua/service/device/management/asset/DeviceAssets.java +++ b/service/device/management/asset/api/src/main/java/org/eclipse/kapua/service/device/management/asset/DeviceAssets.java @@ -12,14 +12,16 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.management.asset; -import org.eclipse.kapua.KapuaSerializable; +import java.util.ArrayList; +import java.util.List; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; -import java.util.List; + +import org.eclipse.kapua.KapuaSerializable; /** * {@link DeviceAssets} definition. @@ -28,8 +30,12 @@ */ @XmlRootElement(name = "deviceAssets") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = DeviceAssetXmlRegistry.class, factoryMethod = "newAssetListResult") -public interface DeviceAssets extends KapuaSerializable { +@XmlType +public class DeviceAssets implements KapuaSerializable { + + private static final long serialVersionUID = -6657213220333406876L; + + private List assets; /** * Get the {@link DeviceAsset} {@link List} @@ -38,13 +44,22 @@ public interface DeviceAssets extends KapuaSerializable { * @since 1.0.0 */ @XmlElement(name = "deviceAsset") - List getAssets(); + public List getAssets() { + if (assets == null) { + assets = new ArrayList<>(); + } + + return assets; + } /** * Sets the {@link DeviceAsset} {@link List}. * - * @param assets The {@link DeviceAsset} {@link List}. + * @param assets + * The {@link DeviceAsset} {@link List}. * @since 1.0.0 */ - void setAssets(List assets); + public void setAssets(List assets) { + this.assets = assets; + } } diff --git a/service/device/management/asset/internal/src/main/java/org/eclipse/kapua/service/device/management/asset/internal/DeviceAssetFactoryImpl.java b/service/device/management/asset/internal/src/main/java/org/eclipse/kapua/service/device/management/asset/internal/DeviceAssetFactoryImpl.java index 50dc4e9a9b7..5dc8cff6e00 100644 --- a/service/device/management/asset/internal/src/main/java/org/eclipse/kapua/service/device/management/asset/internal/DeviceAssetFactoryImpl.java +++ b/service/device/management/asset/internal/src/main/java/org/eclipse/kapua/service/device/management/asset/internal/DeviceAssetFactoryImpl.java @@ -12,12 +12,11 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.management.asset.internal; +import javax.inject.Singleton; + import org.eclipse.kapua.service.device.management.asset.DeviceAsset; import org.eclipse.kapua.service.device.management.asset.DeviceAssetChannel; import org.eclipse.kapua.service.device.management.asset.DeviceAssetFactory; -import org.eclipse.kapua.service.device.management.asset.DeviceAssets; - -import javax.inject.Singleton; /** * {@link DeviceAssetFactory} implementation. @@ -27,11 +26,6 @@ @Singleton public class DeviceAssetFactoryImpl implements DeviceAssetFactory { - @Override - public DeviceAssets newAssetListResult() { - return new DeviceAssetsImpl(); - } - @Override public DeviceAsset newDeviceAsset() { return new DeviceAssetImpl(); diff --git a/service/device/management/asset/internal/src/main/java/org/eclipse/kapua/service/device/management/asset/internal/DeviceAssetManagementServiceImpl.java b/service/device/management/asset/internal/src/main/java/org/eclipse/kapua/service/device/management/asset/internal/DeviceAssetManagementServiceImpl.java index a0ef5363703..2b50eed84e8 100644 --- a/service/device/management/asset/internal/src/main/java/org/eclipse/kapua/service/device/management/asset/internal/DeviceAssetManagementServiceImpl.java +++ b/service/device/management/asset/internal/src/main/java/org/eclipse/kapua/service/device/management/asset/internal/DeviceAssetManagementServiceImpl.java @@ -12,6 +12,10 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.management.asset.internal; +import java.util.Date; + +import javax.inject.Singleton; + import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.commons.model.domains.Domains; import org.eclipse.kapua.commons.util.ArgumentValidator; @@ -39,9 +43,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.inject.Singleton; -import java.util.Date; - /** * {@link DeviceAssetManagementService} implementation. * @@ -126,7 +127,7 @@ public DeviceAssets get(KapuaId scopeId, KapuaId deviceId, DeviceAssets deviceAs // Create event createDeviceEvent(scopeId, deviceId, assetRequestMessage, responseMessage); // Check response - DeviceAssets onlineDeviceAssets = checkResponseAcceptedOrThrowError(responseMessage, () -> responseMessage.getPayload().getDeviceAssets().orElse(deviceAssetFactory.newAssetListResult())); + DeviceAssets onlineDeviceAssets = checkResponseAcceptedOrThrowError(responseMessage, () -> responseMessage.getPayload().getDeviceAssets().orElse(new DeviceAssets())); // Store value and return if (deviceAssetStoreService.isServiceEnabled(scopeId) && deviceAssetStoreService.isApplicationEnabled(scopeId, deviceId)) { @@ -192,7 +193,7 @@ public DeviceAssets read(KapuaId scopeId, KapuaId deviceId, DeviceAssets deviceA // Create event createDeviceEvent(scopeId, deviceId, assetRequestMessage, responseMessage); // Check response - DeviceAssets onlineDeviceAssets = checkResponseAcceptedOrThrowError(responseMessage, () -> responseMessage.getPayload().getDeviceAssets().orElse(deviceAssetFactory.newAssetListResult())); + DeviceAssets onlineDeviceAssets = checkResponseAcceptedOrThrowError(responseMessage, () -> responseMessage.getPayload().getDeviceAssets().orElse(new DeviceAssets())); // Store value and return if (deviceAssetStoreService.isServiceEnabled(scopeId) && deviceAssetStoreService.isApplicationEnabled(scopeId, deviceId)) { @@ -258,6 +259,6 @@ public DeviceAssets write(KapuaId scopeId, KapuaId deviceId, DeviceAssets device // Create event createDeviceEvent(scopeId, deviceId, assetRequestMessage, responseMessage); // Check response - return checkResponseAcceptedOrThrowError(responseMessage, () -> responseMessage.getPayload().getDeviceAssets().orElse(deviceAssetFactory.newAssetListResult())); + return checkResponseAcceptedOrThrowError(responseMessage, () -> responseMessage.getPayload().getDeviceAssets().orElse(new DeviceAssets())); } } diff --git a/service/device/management/asset/internal/src/main/java/org/eclipse/kapua/service/device/management/asset/internal/DeviceAssetsImpl.java b/service/device/management/asset/internal/src/main/java/org/eclipse/kapua/service/device/management/asset/internal/DeviceAssetsImpl.java deleted file mode 100644 index 997e09c0bf5..00000000000 --- a/service/device/management/asset/internal/src/main/java/org/eclipse/kapua/service/device/management/asset/internal/DeviceAssetsImpl.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016, 2022 Eurotech and/or its affiliates and others - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Eurotech - initial API and implementation - *******************************************************************************/ -package org.eclipse.kapua.service.device.management.asset.internal; - -import org.eclipse.kapua.service.device.management.asset.DeviceAsset; -import org.eclipse.kapua.service.device.management.asset.DeviceAssets; - -import java.util.ArrayList; -import java.util.List; - -/** - * {@link DeviceAssets} implementation. - * - * @since 1.0.0 - */ -public class DeviceAssetsImpl implements DeviceAssets { - - private static final long serialVersionUID = -6657213220333406876L; - - private List assets; - - @Override - public List getAssets() { - if (assets == null) { - assets = new ArrayList<>(); - } - - return assets; - } - - @Override - public void setAssets(List assets) { - this.assets = assets; - } -} diff --git a/service/device/management/job/api/src/main/java/org/eclipse/kapua/service/device/management/job/JobDeviceManagementOperationFactory.java b/service/device/management/job/api/src/main/java/org/eclipse/kapua/service/device/management/job/JobDeviceManagementOperationFactory.java index e44a31feee6..c125842e2ed 100644 --- a/service/device/management/job/api/src/main/java/org/eclipse/kapua/service/device/management/job/JobDeviceManagementOperationFactory.java +++ b/service/device/management/job/api/src/main/java/org/eclipse/kapua/service/device/management/job/JobDeviceManagementOperationFactory.java @@ -19,6 +19,6 @@ * * @since 1.1.0 */ -public interface JobDeviceManagementOperationFactory extends KapuaEntityFactory { +public interface JobDeviceManagementOperationFactory extends KapuaEntityFactory { } diff --git a/service/device/management/job/api/src/main/java/org/eclipse/kapua/service/device/management/job/JobDeviceManagementOperationListResult.java b/service/device/management/job/api/src/main/java/org/eclipse/kapua/service/device/management/job/JobDeviceManagementOperationListResult.java index c7c8afb6642..5a8855a82d8 100644 --- a/service/device/management/job/api/src/main/java/org/eclipse/kapua/service/device/management/job/JobDeviceManagementOperationListResult.java +++ b/service/device/management/job/api/src/main/java/org/eclipse/kapua/service/device/management/job/JobDeviceManagementOperationListResult.java @@ -12,13 +12,13 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.management.job; -import org.eclipse.kapua.model.query.KapuaListResult; - import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import org.eclipse.kapua.model.query.KapuaListResult; + /** * {@link JobDeviceManagementOperationListResult} definition. * @@ -26,7 +26,7 @@ */ @XmlRootElement(name = "jobDeviceManagementOperationListResult") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = JobDeviceManagementOperationXmlRegistry.class, factoryMethod = "newJobDeviceManagementOperationListResult") -public interface JobDeviceManagementOperationListResult extends KapuaListResult { +@XmlType +public class JobDeviceManagementOperationListResult extends KapuaListResult { } diff --git a/service/device/management/job/api/src/main/java/org/eclipse/kapua/service/device/management/job/JobDeviceManagementOperationXmlRegistry.java b/service/device/management/job/api/src/main/java/org/eclipse/kapua/service/device/management/job/JobDeviceManagementOperationXmlRegistry.java index 604a0f8d1d0..f9b2513eb14 100644 --- a/service/device/management/job/api/src/main/java/org/eclipse/kapua/service/device/management/job/JobDeviceManagementOperationXmlRegistry.java +++ b/service/device/management/job/api/src/main/java/org/eclipse/kapua/service/device/management/job/JobDeviceManagementOperationXmlRegistry.java @@ -12,10 +12,10 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.management.job; -import org.eclipse.kapua.locator.KapuaLocator; - import javax.xml.bind.annotation.XmlRegistry; +import org.eclipse.kapua.locator.KapuaLocator; + /** * {@link JobDeviceManagementOperation} xml factory class * @@ -34,10 +34,6 @@ public JobDeviceManagementOperationCreator newJobDeviceManagementOperationCreato return jobDeviceManagementOperationFactory.newCreator(null); } - public JobDeviceManagementOperationListResult newJobDeviceManagementOperationListResult() { - return jobDeviceManagementOperationFactory.newListResult(); - } - public JobDeviceManagementOperationQuery newQuery() { return jobDeviceManagementOperationFactory.newQuery(null); } diff --git a/service/device/management/job/internal/src/main/java/org/eclipse/kapua/service/device/management/job/internal/JobDeviceManagementOperationFactoryImpl.java b/service/device/management/job/internal/src/main/java/org/eclipse/kapua/service/device/management/job/internal/JobDeviceManagementOperationFactoryImpl.java index cbd204575e2..3db27bf80c4 100644 --- a/service/device/management/job/internal/src/main/java/org/eclipse/kapua/service/device/management/job/internal/JobDeviceManagementOperationFactoryImpl.java +++ b/service/device/management/job/internal/src/main/java/org/eclipse/kapua/service/device/management/job/internal/JobDeviceManagementOperationFactoryImpl.java @@ -12,16 +12,15 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.management.job.internal; +import javax.inject.Singleton; + import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.device.management.job.JobDeviceManagementOperation; import org.eclipse.kapua.service.device.management.job.JobDeviceManagementOperationCreator; import org.eclipse.kapua.service.device.management.job.JobDeviceManagementOperationFactory; -import org.eclipse.kapua.service.device.management.job.JobDeviceManagementOperationListResult; import org.eclipse.kapua.service.device.management.job.JobDeviceManagementOperationQuery; -import javax.inject.Singleton; - /** * {@link JobDeviceManagementOperationFactory} implementation. * @@ -45,11 +44,6 @@ public JobDeviceManagementOperationQuery newQuery(KapuaId scopeId) { return new JobDeviceManagementOperationQueryImpl(scopeId); } - @Override - public JobDeviceManagementOperationListResult newListResult() { - return new JobDeviceManagementOperationListResultImpl(); - } - @Override public JobDeviceManagementOperation clone(JobDeviceManagementOperation jobDeviceManagementOperation) { try { diff --git a/service/device/management/job/internal/src/main/java/org/eclipse/kapua/service/device/management/job/internal/JobDeviceManagementOperationImplJpaRepository.java b/service/device/management/job/internal/src/main/java/org/eclipse/kapua/service/device/management/job/internal/JobDeviceManagementOperationImplJpaRepository.java index dbd24d8cefb..68198b09322 100644 --- a/service/device/management/job/internal/src/main/java/org/eclipse/kapua/service/device/management/job/internal/JobDeviceManagementOperationImplJpaRepository.java +++ b/service/device/management/job/internal/src/main/java/org/eclipse/kapua/service/device/management/job/internal/JobDeviceManagementOperationImplJpaRepository.java @@ -21,7 +21,8 @@ public class JobDeviceManagementOperationImplJpaRepository extends KapuaUpdatableEntityJpaRepository implements JobDeviceManagementOperationRepository { + public JobDeviceManagementOperationImplJpaRepository(KapuaJpaRepositoryConfiguration jpaRepoConfig) { - super(JobDeviceManagementOperationImpl.class, JobDeviceManagementOperation.TYPE, () -> new JobDeviceManagementOperationListResultImpl(), jpaRepoConfig); + super(JobDeviceManagementOperationImpl.class, JobDeviceManagementOperation.TYPE, () -> new JobDeviceManagementOperationListResult(), jpaRepoConfig); } } diff --git a/service/device/management/job/internal/src/main/java/org/eclipse/kapua/service/device/management/job/internal/JobDeviceManagementOperationListResultImpl.java b/service/device/management/job/internal/src/main/java/org/eclipse/kapua/service/device/management/job/internal/JobDeviceManagementOperationListResultImpl.java deleted file mode 100644 index cfd1a91eaf7..00000000000 --- a/service/device/management/job/internal/src/main/java/org/eclipse/kapua/service/device/management/job/internal/JobDeviceManagementOperationListResultImpl.java +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2019, 2022 Eurotech and/or its affiliates and others - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Eurotech - initial API and implementation - *******************************************************************************/ -package org.eclipse.kapua.service.device.management.job.internal; - -import org.eclipse.kapua.commons.model.query.KapuaListResultImpl; -import org.eclipse.kapua.service.device.management.job.JobDeviceManagementOperation; -import org.eclipse.kapua.service.device.management.job.JobDeviceManagementOperationListResult; - -/** - * {@link JobDeviceManagementOperationListResult} implementation. - * - * @since 1.1.0 - */ -public class JobDeviceManagementOperationListResultImpl extends KapuaListResultImpl implements JobDeviceManagementOperationListResult { -} diff --git a/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/DeviceManagementOperationFactory.java b/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/DeviceManagementOperationFactory.java index 157f43cab15..bb1a7c27f9f 100644 --- a/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/DeviceManagementOperationFactory.java +++ b/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/DeviceManagementOperationFactory.java @@ -20,14 +20,17 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface DeviceManagementOperationFactory extends KapuaEntityFactory { +public interface DeviceManagementOperationFactory extends KapuaEntityFactory { /** * Instantiates a new {@link DeviceManagementOperationProperty}. * - * @param name The name to set in the {@link DeviceManagementOperationProperty} - * @param propertyType The property type to set in the {@link DeviceManagementOperationProperty} - * @param propertyValue The property value to set in the {@link DeviceManagementOperationProperty} + * @param name + * The name to set in the {@link DeviceManagementOperationProperty} + * @param propertyType + * The property type to set in the {@link DeviceManagementOperationProperty} + * @param propertyValue + * The property value to set in the {@link DeviceManagementOperationProperty} * @return The newly instantiated {@link DeviceManagementOperationProperty} * @since 1.0.0 */ diff --git a/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/DeviceManagementOperationListResult.java b/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/DeviceManagementOperationListResult.java index 303304154d3..377b61fb8a6 100644 --- a/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/DeviceManagementOperationListResult.java +++ b/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/DeviceManagementOperationListResult.java @@ -12,13 +12,13 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.management.registry.operation; -import org.eclipse.kapua.model.query.KapuaListResult; - import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import org.eclipse.kapua.model.query.KapuaListResult; + /** * {@link DeviceManagementOperationListResult} definition. * @@ -26,7 +26,7 @@ */ @XmlRootElement(name = "deviceManagementOperationListResult") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = DeviceManagementOperationXmlRegistry.class, factoryMethod = "newDeviceManagementOperationListResult") -public interface DeviceManagementOperationListResult extends KapuaListResult { +@XmlType +public class DeviceManagementOperationListResult extends KapuaListResult { } diff --git a/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/DeviceManagementOperationXmlRegistry.java b/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/DeviceManagementOperationXmlRegistry.java index 42f4859e536..827c836a9ac 100644 --- a/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/DeviceManagementOperationXmlRegistry.java +++ b/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/DeviceManagementOperationXmlRegistry.java @@ -12,10 +12,10 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.management.registry.operation; -import org.eclipse.kapua.locator.KapuaLocator; - import javax.xml.bind.annotation.XmlRegistry; +import org.eclipse.kapua.locator.KapuaLocator; + /** * {@link DeviceManagementOperation} xml factory class * @@ -35,10 +35,6 @@ DeviceManagementOperationCreator newDeviceManagementOperationCreator() { return factory.newCreator(null); } - DeviceManagementOperationListResult newDeviceManagementOperationListResult() { - return factory.newListResult(); - } - DeviceManagementOperationQuery newQuery() { return factory.newQuery(null); } diff --git a/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/ManagementOperationNotificationFactory.java b/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/ManagementOperationNotificationFactory.java index b1c814e7366..8e8a3761efb 100644 --- a/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/ManagementOperationNotificationFactory.java +++ b/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/ManagementOperationNotificationFactory.java @@ -20,6 +20,6 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface ManagementOperationNotificationFactory extends KapuaEntityFactory { +public interface ManagementOperationNotificationFactory extends KapuaEntityFactory { } diff --git a/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/ManagementOperationNotificationListResult.java b/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/ManagementOperationNotificationListResult.java index bc28b4ce399..6060a034194 100644 --- a/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/ManagementOperationNotificationListResult.java +++ b/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/ManagementOperationNotificationListResult.java @@ -12,13 +12,13 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.management.registry.operation.notification; -import org.eclipse.kapua.model.query.KapuaListResult; - import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import org.eclipse.kapua.model.query.KapuaListResult; + /** * {@link ManagementOperationNotificationListResult} definition. * @@ -26,7 +26,7 @@ */ @XmlRootElement(name = "managementOperationNotificationListResult") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = ManagementOperationNotificationXmlRegistry.class, factoryMethod = "newManagementOperationNotificationListResult") -public interface ManagementOperationNotificationListResult extends KapuaListResult { +@XmlType +public class ManagementOperationNotificationListResult extends KapuaListResult { } diff --git a/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/ManagementOperationNotificationXmlRegistry.java b/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/ManagementOperationNotificationXmlRegistry.java index 8e9ad286ab4..f98b3685674 100644 --- a/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/ManagementOperationNotificationXmlRegistry.java +++ b/service/device/management/registry/api/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/ManagementOperationNotificationXmlRegistry.java @@ -12,10 +12,10 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.management.registry.operation.notification; -import org.eclipse.kapua.locator.KapuaLocator; - import javax.xml.bind.annotation.XmlRegistry; +import org.eclipse.kapua.locator.KapuaLocator; + /** * {@link ManagementOperationNotification} xml MANAGEMENT_OPERATION_NOTIFICATION_REGISTRY_FACTORY class * @@ -34,11 +34,6 @@ ManagementOperationNotificationCreator newManagementOperationNotificationCreator return managementOperationNotificationFactory.newCreator(null); } - - ManagementOperationNotificationListResult newManagementOperationNotificationListResult() { - return managementOperationNotificationFactory.newListResult(); - } - ManagementOperationNotificationQuery newQuery() { return managementOperationNotificationFactory.newQuery(null); } diff --git a/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/internal/DeviceManagementOperationFactoryImpl.java b/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/internal/DeviceManagementOperationFactoryImpl.java index 3f1802d340d..d9a977b8528 100644 --- a/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/internal/DeviceManagementOperationFactoryImpl.java +++ b/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/internal/DeviceManagementOperationFactoryImpl.java @@ -12,17 +12,16 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.management.registry.operation.internal; +import javax.inject.Singleton; + import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.device.management.registry.operation.DeviceManagementOperation; import org.eclipse.kapua.service.device.management.registry.operation.DeviceManagementOperationCreator; import org.eclipse.kapua.service.device.management.registry.operation.DeviceManagementOperationFactory; -import org.eclipse.kapua.service.device.management.registry.operation.DeviceManagementOperationListResult; import org.eclipse.kapua.service.device.management.registry.operation.DeviceManagementOperationProperty; import org.eclipse.kapua.service.device.management.registry.operation.DeviceManagementOperationQuery; -import javax.inject.Singleton; - /** * {@link DeviceManagementOperationFactory} implementation * @@ -46,11 +45,6 @@ public DeviceManagementOperationQuery newQuery(KapuaId scopeId) { return new DeviceManagementOperationQueryImpl(scopeId); } - @Override - public DeviceManagementOperationListResult newListResult() { - return new DeviceManagementOperationListResultImpl(); - } - @Override public DeviceManagementOperationProperty newStepProperty(String name, String propertyType, String propertyValue) { return new DeviceManagementOperationPropertyImpl(name, propertyType, propertyValue); diff --git a/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/internal/DeviceManagementOperationListResultImpl.java b/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/internal/DeviceManagementOperationListResultImpl.java deleted file mode 100644 index 70231c167da..00000000000 --- a/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/internal/DeviceManagementOperationListResultImpl.java +++ /dev/null @@ -1,26 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017, 2022 Eurotech and/or its affiliates and others - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Eurotech - initial API and implementation - *******************************************************************************/ -package org.eclipse.kapua.service.device.management.registry.operation.internal; - -import org.eclipse.kapua.commons.model.query.KapuaListResultImpl; -import org.eclipse.kapua.service.device.management.registry.operation.DeviceManagementOperation; -import org.eclipse.kapua.service.device.management.registry.operation.DeviceManagementOperationListResult; - -/** - * {@link DeviceManagementOperationListResultImpl} definition. - * - * @since 1.0.0 - */ -public class DeviceManagementOperationListResultImpl extends KapuaListResultImpl implements DeviceManagementOperationListResult { - -} diff --git a/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/internal/DeviceManagementOperationRepositoryImplJpaRepository.java b/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/internal/DeviceManagementOperationRepositoryImplJpaRepository.java index 0912d291a5a..32914d8fbfd 100644 --- a/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/internal/DeviceManagementOperationRepositoryImplJpaRepository.java +++ b/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/internal/DeviceManagementOperationRepositoryImplJpaRepository.java @@ -12,6 +12,8 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.management.registry.operation.internal; +import java.util.Optional; + import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.commons.jpa.KapuaJpaRepositoryConfiguration; import org.eclipse.kapua.commons.jpa.KapuaUpdatableEntityJpaRepository; @@ -21,13 +23,12 @@ import org.eclipse.kapua.service.device.management.registry.operation.DeviceManagementOperationRepository; import org.eclipse.kapua.storage.TxContext; -import java.util.Optional; - public class DeviceManagementOperationRepositoryImplJpaRepository extends KapuaUpdatableEntityJpaRepository implements DeviceManagementOperationRepository { + public DeviceManagementOperationRepositoryImplJpaRepository(KapuaJpaRepositoryConfiguration jpaRepoConfig) { - super(DeviceManagementOperationImpl.class, DeviceManagementOperation.TYPE, () -> new DeviceManagementOperationListResultImpl(), jpaRepoConfig); + super(DeviceManagementOperationImpl.class, DeviceManagementOperation.TYPE, () -> new DeviceManagementOperationListResult(), jpaRepoConfig); } @Override diff --git a/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/internal/ManagementOperationNotificationFactoryImpl.java b/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/internal/ManagementOperationNotificationFactoryImpl.java index a6303dc87c9..5140ad1768b 100644 --- a/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/internal/ManagementOperationNotificationFactoryImpl.java +++ b/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/internal/ManagementOperationNotificationFactoryImpl.java @@ -12,15 +12,14 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.management.registry.operation.notification.internal; +import javax.inject.Singleton; + import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.device.management.registry.operation.notification.ManagementOperationNotification; import org.eclipse.kapua.service.device.management.registry.operation.notification.ManagementOperationNotificationCreator; import org.eclipse.kapua.service.device.management.registry.operation.notification.ManagementOperationNotificationFactory; -import org.eclipse.kapua.service.device.management.registry.operation.notification.ManagementOperationNotificationListResult; import org.eclipse.kapua.service.device.management.registry.operation.notification.ManagementOperationNotificationQuery; -import javax.inject.Singleton; - /** * {@link ManagementOperationNotificationFactory} implementation. * @@ -44,11 +43,6 @@ public ManagementOperationNotificationQuery newQuery(KapuaId scopeId) { return new ManagementOperationNotificationQueryImpl(scopeId); } - @Override - public ManagementOperationNotificationListResult newListResult() { - return new ManagementOperationNotificationListResultImpl(); - } - @Override public ManagementOperationNotification clone(ManagementOperationNotification managementOperationNotification) { return new ManagementOperationNotificationImpl(managementOperationNotification); diff --git a/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/internal/ManagementOperationNotificationImplJpaRepository.java b/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/internal/ManagementOperationNotificationImplJpaRepository.java index 0851913ef21..48e3e245194 100644 --- a/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/internal/ManagementOperationNotificationImplJpaRepository.java +++ b/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/internal/ManagementOperationNotificationImplJpaRepository.java @@ -21,7 +21,8 @@ public class ManagementOperationNotificationImplJpaRepository extends KapuaEntityJpaRepository implements ManagementOperationNotificationRepository { + public ManagementOperationNotificationImplJpaRepository(KapuaJpaRepositoryConfiguration configuration) { - super(ManagementOperationNotificationImpl.class, ManagementOperationNotification.TYPE, () -> new ManagementOperationNotificationListResultImpl(), configuration); + super(ManagementOperationNotificationImpl.class, ManagementOperationNotification.TYPE, () -> new ManagementOperationNotificationListResult(), configuration); } } diff --git a/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/internal/ManagementOperationNotificationListResultImpl.java b/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/internal/ManagementOperationNotificationListResultImpl.java deleted file mode 100644 index 55063328ae2..00000000000 --- a/service/device/management/registry/internal/src/main/java/org/eclipse/kapua/service/device/management/registry/operation/notification/internal/ManagementOperationNotificationListResultImpl.java +++ /dev/null @@ -1,26 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017, 2022 Eurotech and/or its affiliates and others - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Eurotech - initial API and implementation - *******************************************************************************/ -package org.eclipse.kapua.service.device.management.registry.operation.notification.internal; - -import org.eclipse.kapua.commons.model.query.KapuaListResultImpl; -import org.eclipse.kapua.service.device.management.registry.operation.notification.ManagementOperationNotification; -import org.eclipse.kapua.service.device.management.registry.operation.notification.ManagementOperationNotificationListResult; - -/** - * {@link ManagementOperationNotificationListResultImpl} definition. - * - * @since 1.0.0 - */ -public class ManagementOperationNotificationListResultImpl extends KapuaListResultImpl implements ManagementOperationNotificationListResult { - -} diff --git a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/DeviceFactory.java b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/DeviceFactory.java index 6a526e6d7b5..6960844892b 100644 --- a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/DeviceFactory.java +++ b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/DeviceFactory.java @@ -21,13 +21,15 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface DeviceFactory extends KapuaEntityFactory { +public interface DeviceFactory extends KapuaEntityFactory { /** * Instantiates a new {@link DeviceCreator} * - * @param scopeId The scope {@link KapuaId} to set into the {@link DeviceCreator} - * @param clientId The client id to set into the {@link DeviceCreator} + * @param scopeId + * The scope {@link KapuaId} to set into the {@link DeviceCreator} + * @param clientId + * The client id to set into the {@link DeviceCreator} * @return The newly instantiated {@link DeviceCreator}. * @since 1.0.0 * @deprecated Since 1.5.0. Please use {@link #newCreator(KapuaId)}. @@ -38,9 +40,12 @@ public interface DeviceFactory extends KapuaEntityFactory { +@XmlType +public class DeviceListResult extends KapuaListResult { + + private static final long serialVersionUID = -3870951363076544938L; } diff --git a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/DeviceXmlRegistry.java b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/DeviceXmlRegistry.java index 573905a636b..36f44928f1d 100644 --- a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/DeviceXmlRegistry.java +++ b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/DeviceXmlRegistry.java @@ -12,10 +12,10 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.registry; -import org.eclipse.kapua.locator.KapuaLocator; - import javax.xml.bind.annotation.XmlRegistry; +import org.eclipse.kapua.locator.KapuaLocator; + /** * {@link Device} xml factory class * @@ -46,16 +46,6 @@ public DeviceCreator newDeviceCreator() { return deviceFactory.newCreator(null, null); } - /** - * Creates a new device list result - * - * @return - * @since 1.0.0 - */ - public DeviceListResult newDeviceListResult() { - return deviceFactory.newListResult(); - } - public DeviceQuery newQuery() { return deviceFactory.newQuery(null); } diff --git a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/DeviceConnectionFactory.java b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/DeviceConnectionFactory.java index f2340123de1..a19a31be804 100644 --- a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/DeviceConnectionFactory.java +++ b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/DeviceConnectionFactory.java @@ -20,6 +20,6 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface DeviceConnectionFactory extends KapuaEntityFactory { +public interface DeviceConnectionFactory extends KapuaEntityFactory { } diff --git a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/DeviceConnectionListResult.java b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/DeviceConnectionListResult.java index e37886dcaa6..5203c40b686 100644 --- a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/DeviceConnectionListResult.java +++ b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/DeviceConnectionListResult.java @@ -23,6 +23,8 @@ * @since 1.0 */ @XmlRootElement(name = "deviceConnections") -@XmlType(factoryClass = DeviceConnectionXmlRegistry.class, factoryMethod = "newDeviceConnectionListResult") -public interface DeviceConnectionListResult extends KapuaListResult { +@XmlType +public class DeviceConnectionListResult extends KapuaListResult { + + private static final long serialVersionUID = -4450707993798807403L; } diff --git a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/DeviceConnectionXmlRegistry.java b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/DeviceConnectionXmlRegistry.java index b4812c01608..d9b01446c9f 100644 --- a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/DeviceConnectionXmlRegistry.java +++ b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/DeviceConnectionXmlRegistry.java @@ -12,10 +12,10 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.registry.connection; -import org.eclipse.kapua.locator.KapuaLocator; - import javax.xml.bind.annotation.XmlRegistry; +import org.eclipse.kapua.locator.KapuaLocator; + /** * {@link DeviceConnection} xml factory class * @@ -35,15 +35,6 @@ public DeviceConnection newDeviceConnection() { return deviceConnectionFactory.newEntity(null); } - /** - * Creates a new device list result - * - * @return - */ - public DeviceConnectionListResult newDeviceConnectionListResult() { - return deviceConnectionFactory.newListResult(); - } - public DeviceConnectionQuery newQuery() { return deviceConnectionFactory.newQuery(null); } diff --git a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/DeviceConnectionOptionFactory.java b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/DeviceConnectionOptionFactory.java index 231671e4ec2..2c5ee017b0a 100644 --- a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/DeviceConnectionOptionFactory.java +++ b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/DeviceConnectionOptionFactory.java @@ -20,6 +20,6 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface DeviceConnectionOptionFactory extends KapuaEntityFactory { +public interface DeviceConnectionOptionFactory extends KapuaEntityFactory { } diff --git a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/DeviceConnectionOptionListResult.java b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/DeviceConnectionOptionListResult.java index 35281032b68..cefbaaf77ac 100644 --- a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/DeviceConnectionOptionListResult.java +++ b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/DeviceConnectionOptionListResult.java @@ -23,6 +23,8 @@ * @since 1.0.0 */ @XmlRootElement(name = "deviceConnectionOptions") -@XmlType(factoryClass = DeviceConnectionOptionXmlRegistry.class, factoryMethod = "newDeviceConnectionOptionListResult") -public interface DeviceConnectionOptionListResult extends KapuaListResult { +@XmlType +public class DeviceConnectionOptionListResult extends KapuaListResult { + + private static final long serialVersionUID = -4450707993798807403L; } diff --git a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/DeviceConnectionOptionXmlRegistry.java b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/DeviceConnectionOptionXmlRegistry.java index c2da267c5a2..39c5b6fbf7d 100644 --- a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/DeviceConnectionOptionXmlRegistry.java +++ b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/DeviceConnectionOptionXmlRegistry.java @@ -12,10 +12,10 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.registry.connection.option; -import org.eclipse.kapua.locator.KapuaLocator; - import javax.xml.bind.annotation.XmlRegistry; +import org.eclipse.kapua.locator.KapuaLocator; + /** * {@link DeviceConnectionOptionService} XML factory class * @@ -35,15 +35,6 @@ public DeviceConnectionOption newDeviceConnectionOption() { return deviceConnectionOptionFactory.newEntity(null); } - /** - * Creates a new device connection options list result - * - * @return - */ - public DeviceConnectionOptionListResult newDeviceConnectionOptionListResult() { - return deviceConnectionOptionFactory.newListResult(); - } - public DeviceConnectionOptionQuery newQuery() { return deviceConnectionOptionFactory.newQuery(null); } diff --git a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/event/DeviceEventFactory.java b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/event/DeviceEventFactory.java index f6bd2fe9d1e..8ec7d44c5a8 100644 --- a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/event/DeviceEventFactory.java +++ b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/event/DeviceEventFactory.java @@ -12,26 +12,30 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.registry.event; +import java.util.Date; + import org.eclipse.kapua.model.KapuaEntityFactory; import org.eclipse.kapua.model.id.KapuaId; -import java.util.Date; - /** * {@link DeviceEventFactory} definition. * * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface DeviceEventFactory extends KapuaEntityFactory { +public interface DeviceEventFactory extends KapuaEntityFactory { /** * Instantiates a new {@link DeviceEventCreator} * - * @param scopeId The scope {@link KapuaId} to be set in the {@link DeviceEventCreator} - * @param deviceId The {@link org.eclipse.kapua.service.device.registry.Device} {@link KapuaId} to be set in the {@link DeviceEventCreator} - * @param receivedOn The received on {@link KapuaId} to be set in the {@link DeviceEventCreator} - * @param resource The resource {@link KapuaId} to be set in the {@link DeviceEventCreator} + * @param scopeId + * The scope {@link KapuaId} to be set in the {@link DeviceEventCreator} + * @param deviceId + * The {@link org.eclipse.kapua.service.device.registry.Device} {@link KapuaId} to be set in the {@link DeviceEventCreator} + * @param receivedOn + * The received on {@link KapuaId} to be set in the {@link DeviceEventCreator} + * @param resource + * The resource {@link KapuaId} to be set in the {@link DeviceEventCreator} * @return The newly instantiated {@link DeviceEventCreator} * @since 1.0.0 */ diff --git a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/event/DeviceEventListResult.java b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/event/DeviceEventListResult.java index a15cf87c0c4..6e834d0ccb3 100644 --- a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/event/DeviceEventListResult.java +++ b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/event/DeviceEventListResult.java @@ -23,11 +23,12 @@ * Device event list definition. * * @since 1.0 - * */ @XmlRootElement(name = "deviceEventListResult") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = DeviceEventXmlRegistry.class, factoryMethod = "newDeviceEventListResult") -public interface DeviceEventListResult extends KapuaListResult { +@XmlType +public class DeviceEventListResult extends KapuaListResult { + + private static final long serialVersionUID = 6537888946643944463L; } diff --git a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/event/DeviceEventXmlRegistry.java b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/event/DeviceEventXmlRegistry.java index ca95c3f14eb..aff51f6f7ef 100644 --- a/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/event/DeviceEventXmlRegistry.java +++ b/service/device/registry/api/src/main/java/org/eclipse/kapua/service/device/registry/event/DeviceEventXmlRegistry.java @@ -12,10 +12,10 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.registry.event; -import org.eclipse.kapua.locator.KapuaLocator; - import javax.xml.bind.annotation.XmlRegistry; +import org.eclipse.kapua.locator.KapuaLocator; + /** * {@link DeviceEvent} xml factory class. * @@ -35,15 +35,6 @@ public DeviceEvent newDeviceEvent() { return deviceEventFactory.newEntity(null); } - /** - * Creates a new device event list result - * - * @return - */ - public DeviceEventListResult newDeviceEventListResult() { - return deviceEventFactory.newListResult(); - } - public DeviceEventQuery newQuery() { return deviceEventFactory.newQuery(null); } diff --git a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/internal/DeviceConnectionFactoryImpl.java b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/internal/DeviceConnectionFactoryImpl.java index 2cfb367a158..d1c1f083156 100644 --- a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/internal/DeviceConnectionFactoryImpl.java +++ b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/internal/DeviceConnectionFactoryImpl.java @@ -12,16 +12,15 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.registry.connection.internal; +import javax.inject.Singleton; + import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.device.registry.connection.DeviceConnection; import org.eclipse.kapua.service.device.registry.connection.DeviceConnectionCreator; import org.eclipse.kapua.service.device.registry.connection.DeviceConnectionFactory; -import org.eclipse.kapua.service.device.registry.connection.DeviceConnectionListResult; import org.eclipse.kapua.service.device.registry.connection.DeviceConnectionQuery; -import javax.inject.Singleton; - /** * {@link DeviceConnectionFactory} implementation. * @@ -45,11 +44,6 @@ public DeviceConnection newEntity(KapuaId scopeId) { return new DeviceConnectionImpl(scopeId); } - @Override - public DeviceConnectionListResult newListResult() { - return new DeviceConnectionListResultImpl(); - } - @Override public DeviceConnection clone(DeviceConnection deviceConnection) { try { diff --git a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/internal/DeviceConnectionImplJpaRepository.java b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/internal/DeviceConnectionImplJpaRepository.java index 43a5329bcff..2dd44dedb61 100644 --- a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/internal/DeviceConnectionImplJpaRepository.java +++ b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/internal/DeviceConnectionImplJpaRepository.java @@ -28,7 +28,7 @@ public class DeviceConnectionImplJpaRepository implements DeviceConnectionRepository { public DeviceConnectionImplJpaRepository(KapuaJpaRepositoryConfiguration jpaRepoConfig) { - super(DeviceConnectionImpl.class, DeviceConnection.TYPE, () -> new DeviceConnectionListResultImpl(), jpaRepoConfig); + super(DeviceConnectionImpl.class, DeviceConnection.TYPE, () -> new DeviceConnectionListResult(), jpaRepoConfig); } @Override diff --git a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/internal/DeviceConnectionListResultImpl.java b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/internal/DeviceConnectionListResultImpl.java deleted file mode 100644 index c8414fe0915..00000000000 --- a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/internal/DeviceConnectionListResultImpl.java +++ /dev/null @@ -1,26 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016, 2022 Eurotech and/or its affiliates and others - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Eurotech - initial API and implementation - *******************************************************************************/ -package org.eclipse.kapua.service.device.registry.connection.internal; - -import org.eclipse.kapua.commons.model.query.KapuaListResultImpl; -import org.eclipse.kapua.service.device.registry.connection.DeviceConnection; -import org.eclipse.kapua.service.device.registry.connection.DeviceConnectionListResult; - -/** - * Device connection list. - * - * @since 1.0 - */ -public class DeviceConnectionListResultImpl extends KapuaListResultImpl implements DeviceConnectionListResult { - private static final long serialVersionUID = -4450707993798807403L; -} diff --git a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/internal/DeviceConnectionOptionFactoryImpl.java b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/internal/DeviceConnectionOptionFactoryImpl.java index cc6a3a70378..fb9249787ad 100644 --- a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/internal/DeviceConnectionOptionFactoryImpl.java +++ b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/internal/DeviceConnectionOptionFactoryImpl.java @@ -12,16 +12,15 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.registry.connection.option.internal; +import javax.inject.Singleton; + import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.device.registry.connection.option.DeviceConnectionOption; import org.eclipse.kapua.service.device.registry.connection.option.DeviceConnectionOptionCreator; import org.eclipse.kapua.service.device.registry.connection.option.DeviceConnectionOptionFactory; -import org.eclipse.kapua.service.device.registry.connection.option.DeviceConnectionOptionListResult; import org.eclipse.kapua.service.device.registry.connection.option.DeviceConnectionOptionQuery; -import javax.inject.Singleton; - /** * {@link DeviceConnectionOptionFactory} implementation. * @@ -45,11 +44,6 @@ public DeviceConnectionOption newEntity(KapuaId scopeId) { return new DeviceConnectionOptionImpl(scopeId); } - @Override - public DeviceConnectionOptionListResult newListResult() { - return new DeviceConnectionOptionListResultImpl(); - } - @Override public DeviceConnectionOption clone(DeviceConnectionOption deviceConnectionOption) { try { diff --git a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/internal/DeviceConnectionOptionImplJpaRepository.java b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/internal/DeviceConnectionOptionImplJpaRepository.java index 63375409a5a..930c2344323 100644 --- a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/internal/DeviceConnectionOptionImplJpaRepository.java +++ b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/internal/DeviceConnectionOptionImplJpaRepository.java @@ -21,7 +21,8 @@ public class DeviceConnectionOptionImplJpaRepository extends KapuaUpdatableEntityJpaRepository implements DeviceConnectionOptionRepository { + public DeviceConnectionOptionImplJpaRepository(KapuaJpaRepositoryConfiguration jpaRepoConfig) { - super(DeviceConnectionOptionImpl.class, DeviceConnectionOption.TYPE, () -> new DeviceConnectionOptionListResultImpl(), jpaRepoConfig); + super(DeviceConnectionOptionImpl.class, DeviceConnectionOption.TYPE, () -> new DeviceConnectionOptionListResult(), jpaRepoConfig); } } diff --git a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/internal/DeviceConnectionOptionListResultImpl.java b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/internal/DeviceConnectionOptionListResultImpl.java deleted file mode 100644 index 002d804adcb..00000000000 --- a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/connection/option/internal/DeviceConnectionOptionListResultImpl.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016, 2022 Eurotech and/or its affiliates and others - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Eurotech - initial API and implementation - *******************************************************************************/ -package org.eclipse.kapua.service.device.registry.connection.option.internal; - -import org.eclipse.kapua.commons.model.query.KapuaListResultImpl; -import org.eclipse.kapua.service.device.registry.connection.option.DeviceConnectionOption; -import org.eclipse.kapua.service.device.registry.connection.option.DeviceConnectionOptionListResult; - -/** - * Device connection options list. - * - * @since 1.0.0 - */ -public class DeviceConnectionOptionListResultImpl extends KapuaListResultImpl implements DeviceConnectionOptionListResult { - - private static final long serialVersionUID = -4450707993798807403L; -} diff --git a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/event/internal/DeviceEventFactoryImpl.java b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/event/internal/DeviceEventFactoryImpl.java index 223cc0e63d6..1011a7d50f4 100644 --- a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/event/internal/DeviceEventFactoryImpl.java +++ b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/event/internal/DeviceEventFactoryImpl.java @@ -12,17 +12,17 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.registry.event.internal; +import java.util.Date; + +import javax.inject.Singleton; + import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.device.management.message.KapuaMethod; import org.eclipse.kapua.service.device.registry.event.DeviceEvent; import org.eclipse.kapua.service.device.registry.event.DeviceEventCreator; import org.eclipse.kapua.service.device.registry.event.DeviceEventFactory; -import org.eclipse.kapua.service.device.registry.event.DeviceEventListResult; import org.eclipse.kapua.service.device.registry.event.DeviceEventQuery; -import javax.inject.Singleton; -import java.util.Date; - /** * {@link DeviceEventFactory} implementation. * @@ -58,11 +58,6 @@ public DeviceEventCreator newCreator(KapuaId scopeId) { return new DeviceEventCreatorImpl(scopeId); } - @Override - public DeviceEventListResult newListResult() { - return new DeviceEventListResultImpl(); - } - @Override public DeviceEvent clone(DeviceEvent deviceEvent) { return new DeviceEventImpl(deviceEvent); diff --git a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/event/internal/DeviceEventImplJpaRepository.java b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/event/internal/DeviceEventImplJpaRepository.java index f77f26fadd7..4ff3d01f411 100644 --- a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/event/internal/DeviceEventImplJpaRepository.java +++ b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/event/internal/DeviceEventImplJpaRepository.java @@ -21,7 +21,8 @@ public class DeviceEventImplJpaRepository extends KapuaEntityJpaRepository implements DeviceEventRepository { + public DeviceEventImplJpaRepository(KapuaJpaRepositoryConfiguration configuration) { - super(DeviceEventImpl.class, DeviceEvent.TYPE, () -> new DeviceEventListResultImpl(), configuration); + super(DeviceEventImpl.class, DeviceEvent.TYPE, () -> new DeviceEventListResult(), configuration); } } diff --git a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/event/internal/DeviceEventListResultImpl.java b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/event/internal/DeviceEventListResultImpl.java deleted file mode 100644 index aba3659c2d0..00000000000 --- a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/event/internal/DeviceEventListResultImpl.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016, 2022 Eurotech and/or its affiliates and others - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Eurotech - initial API and implementation - *******************************************************************************/ -package org.eclipse.kapua.service.device.registry.event.internal; - -import org.eclipse.kapua.commons.model.query.KapuaListResultImpl; -import org.eclipse.kapua.service.device.registry.event.DeviceEvent; -import org.eclipse.kapua.service.device.registry.event.DeviceEventListResult; - -/** - * Device event list. - * - * @since 1.0 - */ -public class DeviceEventListResultImpl extends KapuaListResultImpl implements DeviceEventListResult { - - private static final long serialVersionUID = 6537888946643944463L; -} diff --git a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/internal/DeviceFactoryImpl.java b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/internal/DeviceFactoryImpl.java index 70524bf2ba0..b4483e0f333 100644 --- a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/internal/DeviceFactoryImpl.java +++ b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/internal/DeviceFactoryImpl.java @@ -12,17 +12,16 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.registry.internal; +import javax.inject.Singleton; + import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.device.registry.Device; import org.eclipse.kapua.service.device.registry.DeviceCreator; import org.eclipse.kapua.service.device.registry.DeviceExtendedProperty; import org.eclipse.kapua.service.device.registry.DeviceFactory; -import org.eclipse.kapua.service.device.registry.DeviceListResult; import org.eclipse.kapua.service.device.registry.DeviceQuery; -import javax.inject.Singleton; - /** * {@link DeviceFactory} implementation. * @@ -43,11 +42,6 @@ public DeviceQuery newQuery(KapuaId scopeId) { return new DeviceQueryImpl(scopeId); } - @Override - public DeviceListResult newListResult() { - return new DeviceListResultImpl(); - } - @Override public Device newEntity(KapuaId scopeId) { return new DeviceImpl(scopeId); diff --git a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/internal/DeviceImplJpaRepository.java b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/internal/DeviceImplJpaRepository.java index 2be2228b60a..503a877deb1 100644 --- a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/internal/DeviceImplJpaRepository.java +++ b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/internal/DeviceImplJpaRepository.java @@ -12,7 +12,11 @@ *******************************************************************************/ package org.eclipse.kapua.service.device.registry.internal; -import com.google.common.collect.Lists; +import java.util.Optional; + +import javax.persistence.EntityManager; +import javax.persistence.LockModeType; + import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.commons.jpa.JpaAwareTxContext; import org.eclipse.kapua.commons.jpa.KapuaJpaRepositoryConfiguration; @@ -24,15 +28,14 @@ import org.eclipse.kapua.service.device.registry.DeviceRepository; import org.eclipse.kapua.storage.TxContext; -import javax.persistence.EntityManager; -import javax.persistence.LockModeType; -import java.util.Optional; +import com.google.common.collect.Lists; public class DeviceImplJpaRepository extends KapuaUpdatableEntityJpaRepository implements DeviceRepository { + public DeviceImplJpaRepository(KapuaJpaRepositoryConfiguration jpaRepoConfig) { - super(DeviceImpl.class, Device.TYPE, () -> new DeviceListResultImpl(), jpaRepoConfig); + super(DeviceImpl.class, Device.TYPE, () -> new DeviceListResult(), jpaRepoConfig); } @Override diff --git a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/internal/DeviceListResultImpl.java b/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/internal/DeviceListResultImpl.java deleted file mode 100644 index 4f3543482cb..00000000000 --- a/service/device/registry/internal/src/main/java/org/eclipse/kapua/service/device/registry/internal/DeviceListResultImpl.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016, 2022 Eurotech and/or its affiliates and others - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Eurotech - initial API and implementation - *******************************************************************************/ -package org.eclipse.kapua.service.device.registry.internal; - -import org.eclipse.kapua.commons.model.query.KapuaListResultImpl; -import org.eclipse.kapua.service.device.registry.Device; -import org.eclipse.kapua.service.device.registry.DeviceListResult; - -/** - * Device list result implementation. - * - * @since 1.0 - */ -public class DeviceListResultImpl extends KapuaListResultImpl implements DeviceListResult { - - private static final long serialVersionUID = -3870951363076544938L; -} diff --git a/service/device/registry/test-steps/src/main/java/org/eclipse/kapua/service/device/registry/steps/BrokerSteps.java b/service/device/registry/test-steps/src/main/java/org/eclipse/kapua/service/device/registry/steps/BrokerSteps.java index c0e71b9b03b..e6ccc530895 100644 --- a/service/device/registry/test-steps/src/main/java/org/eclipse/kapua/service/device/registry/steps/BrokerSteps.java +++ b/service/device/registry/test-steps/src/main/java/org/eclipse/kapua/service/device/registry/steps/BrokerSteps.java @@ -32,7 +32,6 @@ import org.eclipse.kapua.service.device.management.asset.DeviceAssetChannel; import org.eclipse.kapua.service.device.management.asset.DeviceAssetManagementService; import org.eclipse.kapua.service.device.management.asset.DeviceAssets; -import org.eclipse.kapua.service.device.management.asset.internal.DeviceAssetsImpl; import org.eclipse.kapua.service.device.management.bundle.DeviceBundle; import org.eclipse.kapua.service.device.management.bundle.DeviceBundleManagementService; import org.eclipse.kapua.service.device.management.bundle.DeviceBundles; @@ -72,9 +71,7 @@ import io.cucumber.java.en.When; /** - * Steps used in integration scenarios with running MQTT broker and process of - * registering mocked Kura device registering with Kapua and issuing basic administrative - * commands on Mocked Kura. + * Steps used in integration scenarios with running MQTT broker and process of registering mocked Kura device registering with Kapua and issuing basic administrative commands on Mocked Kura. */ @Singleton public class BrokerSteps extends TestBase { @@ -252,8 +249,10 @@ public void deviceBirthMessage() throws Exception { /** * Checks that the {@link Device} with the given {@link Device#getClientId()} has {@link DeviceConnection#getStatus()} {@link DeviceConnectionStatus#CONNECTED} within the given time. * - * @param clientId The {@link Device#getClientId()} to check - * @param waitSeconds The max time of wait in seconds + * @param clientId + * The {@link Device#getClientId()} to check + * @param waitSeconds + * The max time of wait in seconds * @throws Exception * @since 1.2.0 */ @@ -261,7 +260,7 @@ public void deviceBirthMessage() throws Exception { public void deviceConnected(String clientId, int waitSeconds) throws Exception { long now = System.currentTimeMillis(); - while ((System.currentTimeMillis() - now) < (waitSeconds * 1000L)){ + while ((System.currentTimeMillis() - now) < (waitSeconds * 1000L)) { Device kuraDevice = deviceRegistryService.findByClientId(getCurrentScopeId(), clientId); if (kuraDevice != null && @@ -493,7 +492,6 @@ public void deviceWithServerIp(String serverIp) { Assert.assertEquals(serverIp, deviceConn.getServerIp()); } - @When("Client with name {string} with client id {string} user {string} password {string} is connected") public void clientConnect(String clientName, String clientId, String user, String password) throws Exception { MqttClient mqttClient = null; @@ -570,7 +568,7 @@ public void disconnectConnectionWithClientId(String clientId) throws Exception { @Then("Device(s) status is {string} within {int} second(s) for client id {string}") public void deviceStatusIs(String expectedStatus, int timeout, String clientId) throws Exception { String currentStatus = null; - while(!expectedStatus.equals(currentStatus) && timeout-->0) { + while (!expectedStatus.equals(currentStatus) && timeout-- > 0) { Thread.sleep(1000); logger.info("Device(s) status countdown check: {}", timeout); @@ -619,7 +617,7 @@ public void iAddDeviceToKuraMock(int numberOfDevices) { @And("Device assets are requested") public void deviceAssetsAreRequested() throws Exception { - DeviceAssets deviceAssets = new DeviceAssetsImpl(); + DeviceAssets deviceAssets = new DeviceAssets(); for (KuraDevice kuraDevice : kuraDevices) { Device device = deviceRegistryService.findByClientId(SYS_SCOPE_ID, kuraDevice.getClientId()); Assert.assertNotNull(device); diff --git a/service/device/registry/test-steps/src/main/java/org/eclipse/kapua/service/device/registry/steps/DeviceRegistrySteps.java b/service/device/registry/test-steps/src/main/java/org/eclipse/kapua/service/device/registry/steps/DeviceRegistrySteps.java index a970d78eeff..0f70b334561 100644 --- a/service/device/registry/test-steps/src/main/java/org/eclipse/kapua/service/device/registry/steps/DeviceRegistrySteps.java +++ b/service/device/registry/test-steps/src/main/java/org/eclipse/kapua/service/device/registry/steps/DeviceRegistrySteps.java @@ -23,18 +23,9 @@ import java.util.Set; import java.util.UUID; import java.util.Vector; + import javax.inject.Inject; -import com.google.common.base.Strings; -import com.google.common.collect.Lists; -import com.google.inject.Singleton; -import io.cucumber.java.After; -import io.cucumber.java.Before; -import io.cucumber.java.Scenario; -import io.cucumber.java.en.And; -import io.cucumber.java.en.Given; -import io.cucumber.java.en.Then; -import io.cucumber.java.en.When; import org.apache.commons.lang3.StringUtils; import org.eclipse.kapua.KapuaException; import org.eclipse.kapua.commons.model.id.KapuaEid; @@ -115,12 +106,22 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.google.common.base.Strings; +import com.google.common.collect.Lists; +import com.google.inject.Singleton; + +import io.cucumber.java.After; +import io.cucumber.java.Before; +import io.cucumber.java.Scenario; +import io.cucumber.java.en.And; +import io.cucumber.java.en.Given; +import io.cucumber.java.en.Then; +import io.cucumber.java.en.When; + /** * Implementation of Gherkin steps used in DeviceRegistry.feature scenarios. * - * MockedLocator is used for Location Service. Mockito is used to mock other - * services that the Device Registry services dependent on. Dependent services are: - - * Authorization Service - + * MockedLocator is used for Location Service. Mockito is used to mock other services that the Device Registry services dependent on. Dependent services are: - Authorization Service - */ @Singleton public class DeviceRegistrySteps extends TestBase { @@ -178,7 +179,6 @@ public class DeviceRegistrySteps extends TestBase { private DeviceEventService eventService; private DeviceEventFactory eventFactory; - // Additional service references for integration testing private DeviceLifeCycleService deviceLifeCycleService; private AccountService accountService; @@ -391,7 +391,6 @@ public void createDevicesWithParametersAndConnection(List
devLst) thr createDevicesAsSpecifiedInternal(devLst, deviceConnection); } - private void createDevicesAsSpecifiedInternal(List cucDevices, DeviceConnection deviceConnection) throws Exception { primeException(); try { @@ -1004,7 +1003,7 @@ public void exerciseAllDeviceFactoryFunctions() { tmpDevice = deviceFactory.newEntity(SYS_SCOPE_ID); tmpCreator = deviceFactory.newCreator(SYS_SCOPE_ID); tmpQuery = deviceFactory.newQuery(SYS_SCOPE_ID); - tmpListRes = deviceFactory.newListResult(); + tmpListRes = new DeviceListResult(); Assert.assertNotNull(tmpDevice); Assert.assertNotNull(tmpCreator); Assert.assertNotNull(tmpQuery); @@ -1071,7 +1070,7 @@ public void createConnections(List cucConnections) throws Excepti DeviceConnectionCreator connectionCreator = null; DeviceConnection deviceConnection = null; - DeviceConnectionListResult deviceConnections = deviceConnectionFactory.newListResult(); + DeviceConnectionListResult deviceConnections = new DeviceConnectionListResult(); for (CucConnection cucConnection : cucConnections) { connectionCreator = deviceConnectionFactory.newCreator(scopeId); @@ -1083,7 +1082,8 @@ public void createConnections(List cucConnections) throws Excepti connectionCreator.setServerIp(cucConnection.getServerIp()); connectionCreator.setProtocol(cucConnection.getProtocol()); connectionCreator.setAllowUserChange(false); - connectionCreator.setAuthenticationType(deviceConnectionService.getAvailableAuthTypes().stream().findFirst().orElseThrow(() -> new IllegalStateException("No DeviceConnection authenticationTypes are available for testing"))); + connectionCreator.setAuthenticationType(deviceConnectionService.getAvailableAuthTypes().stream().findFirst() + .orElseThrow(() -> new IllegalStateException("No DeviceConnection authenticationTypes are available for testing"))); deviceConnection = deviceConnectionService.create(connectionCreator); deviceConnections.addItem(deviceConnection); } @@ -1613,14 +1613,14 @@ public void checkEventList(int number) throws Exception { private void printEvents(DeviceEventListResult eventList, int count) throws Exception { logger.info("Events size: {}", eventList.getSize()); eventList.getItems().forEach((event) -> logger.info("\ttype: {} - id: {} - date: {} - {}", event.getType(), event.getDeviceId(), event.getCreatedOn(), event.getEventMessage())); -// if (count > eventList.getSize()) { -// logger.info("++++++++++++++++++++++++++++++++++++++++++++++++\n===========================================================\n\n"); -// Thread.sleep(30000); -// searchForEventsFromDeviceWithClientID("rpione3", "kapua-sys" ); -// eventList = (DeviceEventListResult) stepData.get(DEVICE_EVENT_LIST); -// eventList.getItems().forEach((event) -> logger.info("\ttype: {} - id: {} - date: {} - {}", event.getType(), event.getDeviceId(), event.getCreatedOn(), event.getEventMessage())); -// logger.info("++++++++++++++++++++++++++++++++++++++++++++++++\n===========================================================\n\n"); -// } + // if (count > eventList.getSize()) { + // logger.info("++++++++++++++++++++++++++++++++++++++++++++++++\n===========================================================\n\n"); + // Thread.sleep(30000); + // searchForEventsFromDeviceWithClientID("rpione3", "kapua-sys" ); + // eventList = (DeviceEventListResult) stepData.get(DEVICE_EVENT_LIST); + // eventList.getItems().forEach((event) -> logger.info("\ttype: {} - id: {} - date: {} - {}", event.getType(), event.getDeviceId(), event.getCreatedOn(), event.getEventMessage())); + // logger.info("++++++++++++++++++++++++++++++++++++++++++++++++\n===========================================================\n\n"); + // } } @Then("There is no such event") @@ -1637,7 +1637,7 @@ public void exerciseAllEventFactoryFunctions() { tmpEvent = eventFactory.newEntity(SYS_SCOPE_ID); tmpCreator = eventFactory.newCreator(SYS_SCOPE_ID, getKapuaId(), new Date(), ""); tmpQuery = eventFactory.newQuery(SYS_SCOPE_ID); - tmpList = eventFactory.newListResult(); + tmpList = new DeviceEventListResult(); Assert.assertNotNull(tmpEvent); Assert.assertNotNull(tmpCreator); Assert.assertNotNull(tmpQuery); @@ -1661,7 +1661,7 @@ public void checkDeviceEventDomainUpdate() { @When("I search for the device {string} in account {string}") public void searchForDeviceWithClientID(String clientId, String account) throws Exception { - DeviceListResult tmpList = deviceFactory.newListResult(); + DeviceListResult tmpList = new DeviceListResult(); primeException(); try { stepData.remove(DEVICE); @@ -1886,7 +1886,6 @@ public void createAnApplicationMessage(String clientId) throws Exception { } } - @Given("Such a set of privileged users for account {string}") public void createPrivilegedUsers(String accName, List users) throws Throwable { KapuaSecurityUtils.doPrivileged(() -> { @@ -1935,7 +1934,8 @@ public void createConnectionForDevice(List connections) throws Ka tmpCreator.setReservedUserId(tmpConn.getReservedUserId()); tmpCreator.setAllowUserChange(tmpConn.getAllowUserChange()); tmpCreator.setUserCouplingMode(tmpConn.getUserCouplingMode()); - tmpCreator.setAuthenticationType(deviceConnectionService.getAvailableAuthTypes().stream().findFirst().orElseThrow(() -> new IllegalStateException("No DeviceConnection authenticationTypes are available for testing"))); + tmpCreator.setAuthenticationType(deviceConnectionService.getAvailableAuthTypes().stream().findFirst() + .orElseThrow(() -> new IllegalStateException("No DeviceConnection authenticationTypes are available for testing"))); DeviceConnection tmpDevConn = deviceConnectionService.create(tmpCreator); tmpDevConn.setStatus(DeviceConnectionStatus.DISCONNECTED); deviceConnectionService.update(tmpDevConn); @@ -1953,7 +1953,7 @@ public void searchForConnectionFromDeviceWithClientID(String clientId, String ac KapuaSecurityUtils.doPrivileged(() -> { Account tmpAcc; DeviceConnection tmpConn; - DeviceConnectionListResult tmpConnLst = deviceConnectionFactory.newListResult(); + DeviceConnectionListResult tmpConnLst = new DeviceConnectionListResult(); tmpAcc = accountService.findByName(account); Assert.assertNotNull(tmpAcc); Assert.assertNotNull(tmpAcc.getId()); @@ -1999,7 +1999,8 @@ public void searchForConnectionFromDeviceWithClientIDStatusAndUser(String client searchForConnectionFromDeviceWithClientIDStatusAndUser(clientId, account.getId(), status, connectionUserId.getId(), true); } - private boolean searchForConnectionFromDeviceWithClientIDStatusAndUser(String clientId, KapuaId accountId, String connectionStatus, KapuaId connectionUserId, boolean timeoutOccurred) throws Exception { + private boolean searchForConnectionFromDeviceWithClientIDStatusAndUser(String clientId, KapuaId accountId, String connectionStatus, KapuaId connectionUserId, boolean timeoutOccurred) + throws Exception { try { Device device = deviceRegistryService.findByClientId(accountId, clientId); if (timeoutOccurred) { @@ -2022,7 +2023,7 @@ private boolean searchForConnectionFromDeviceWithClientIDStatusAndUser(String cl } } stepData.put(DEVICE_CONNECTION, deviceConnection); - DeviceConnectionListResult tmpConnLst = deviceConnectionFactory.newListResult(); + DeviceConnectionListResult tmpConnLst = new DeviceConnectionListResult(); Vector dcv = new Vector<>(); dcv.add(deviceConnection); tmpConnLst.addItems(dcv); @@ -2193,7 +2194,8 @@ private DeviceConnectionCreator prepareRegularConnectionCreator(KapuaId scopeId, creator.setServerIp(SERVER_IP); creator.setProtocol("tcp"); creator.setAllowUserChange(false); - creator.setAuthenticationType(deviceConnectionService.getAvailableAuthTypes().stream().findFirst().orElseThrow(() -> new IllegalStateException("No DeviceConnection authenticationTypes are available for testing"))); + creator.setAuthenticationType( + deviceConnectionService.getAvailableAuthTypes().stream().findFirst().orElseThrow(() -> new IllegalStateException("No DeviceConnection authenticationTypes are available for testing"))); return creator; } @@ -2226,24 +2228,24 @@ private DeviceEventCreator prepareRegularDeviceEventCreator(KapuaId accountId, K private KapuaMethod getMethodFromString(String name) { KapuaMethod tmpMeth = null; switch (name.trim().toUpperCase()) { - case "READ": - tmpMeth = KapuaMethod.READ; - break; - case "CREATE": - tmpMeth = KapuaMethod.CREATE; - break; - case "WRITE": - tmpMeth = KapuaMethod.WRITE; - break; - case "DELETE": - tmpMeth = KapuaMethod.DELETE; - break; - case "OPTIONS": - tmpMeth = KapuaMethod.OPTIONS; - break; - case "EXECUTE": - tmpMeth = KapuaMethod.EXECUTE; - break; + case "READ": + tmpMeth = KapuaMethod.READ; + break; + case "CREATE": + tmpMeth = KapuaMethod.CREATE; + break; + case "WRITE": + tmpMeth = KapuaMethod.WRITE; + break; + case "DELETE": + tmpMeth = KapuaMethod.DELETE; + break; + case "OPTIONS": + tmpMeth = KapuaMethod.OPTIONS; + break; + case "EXECUTE": + tmpMeth = KapuaMethod.EXECUTE; + break; } Assert.assertNotNull(tmpMeth); return tmpMeth; @@ -2454,34 +2456,34 @@ private DeviceCreator prepareDeviceCreatorFromCucDevice(CucDevice cucDevice) { DeviceConnectionStatus parseConnectionStatusString(String stat) { switch (stat.trim().toUpperCase()) { - case "CONNECTED": - return DeviceConnectionStatus.CONNECTED; - case "DISCONNECTED": - return DeviceConnectionStatus.DISCONNECTED; - case "MISSING": - return DeviceConnectionStatus.MISSING; + case "CONNECTED": + return DeviceConnectionStatus.CONNECTED; + case "DISCONNECTED": + return DeviceConnectionStatus.DISCONNECTED; + case "MISSING": + return DeviceConnectionStatus.MISSING; } return null; } ConnectionUserCouplingMode parseConnectionCouplingString(String mode) { switch (mode.trim().toUpperCase()) { - case "INHERITED": - return ConnectionUserCouplingMode.INHERITED; - case "LOOSE": - return ConnectionUserCouplingMode.LOOSE; - case "STRICT": - return ConnectionUserCouplingMode.STRICT; + case "INHERITED": + return ConnectionUserCouplingMode.INHERITED; + case "LOOSE": + return ConnectionUserCouplingMode.LOOSE; + case "STRICT": + return ConnectionUserCouplingMode.STRICT; } return null; } boolean parseBooleanFromString(String value) { switch (value.trim().toLowerCase()) { - case "true": - return true; - case "false": - return false; + case "true": + return true; + case "false": + return false; } return false; } @@ -2501,7 +2503,6 @@ public void iCreateADeviceWithName(String clientId) throws Exception { } } - @Then("I create a device with name {string} and tags") public void iCreateADeviceWithName(String clientId, List tags) throws Exception { final HashSet tagIds = new HashSet<>(); @@ -2813,7 +2814,6 @@ private void iChangeDeviceLastEventIdTo(String lastEventId) throws Throwable { } } - @And("The devices display name is {string}") public void theDevicesDisplayNameIs(String displayName) throws Throwable { Device device = (Device) stepData.get(DEVICE); diff --git a/service/endpoint/api/src/main/java/org/eclipse/kapua/service/endpoint/EndpointInfoFactory.java b/service/endpoint/api/src/main/java/org/eclipse/kapua/service/endpoint/EndpointInfoFactory.java index ace01e1d96f..73f8dd57b48 100644 --- a/service/endpoint/api/src/main/java/org/eclipse/kapua/service/endpoint/EndpointInfoFactory.java +++ b/service/endpoint/api/src/main/java/org/eclipse/kapua/service/endpoint/EndpointInfoFactory.java @@ -19,12 +19,13 @@ * * @since 1.0.0 */ -public interface EndpointInfoFactory extends KapuaEntityFactory { +public interface EndpointInfoFactory extends KapuaEntityFactory { /** * Instantiates a new {@link EndpointUsage}. * - * @param name The name to set into the {@link EndpointUsage}. + * @param name + * The name to set into the {@link EndpointUsage}. * @return The newly instantiated {@link EndpointUsage}. * @since 1.0.0 */ diff --git a/service/endpoint/api/src/main/java/org/eclipse/kapua/service/endpoint/EndpointInfoListResult.java b/service/endpoint/api/src/main/java/org/eclipse/kapua/service/endpoint/EndpointInfoListResult.java index 642f0944762..df3f7d48953 100644 --- a/service/endpoint/api/src/main/java/org/eclipse/kapua/service/endpoint/EndpointInfoListResult.java +++ b/service/endpoint/api/src/main/java/org/eclipse/kapua/service/endpoint/EndpointInfoListResult.java @@ -12,18 +12,18 @@ *******************************************************************************/ package org.eclipse.kapua.service.endpoint; -import org.eclipse.kapua.model.query.KapuaListResult; - import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import org.eclipse.kapua.model.query.KapuaListResult; + /** * {@link EndpointInfo} list result definition. * * @since 1.0.0 */ @XmlRootElement(name = "endpointInfos") -@XmlType(factoryClass = EndpointInfoXmlRegistry.class, factoryMethod = "newListResult") -public interface EndpointInfoListResult extends KapuaListResult { +@XmlType +public class EndpointInfoListResult extends KapuaListResult { } diff --git a/service/endpoint/api/src/main/java/org/eclipse/kapua/service/endpoint/EndpointInfoXmlRegistry.java b/service/endpoint/api/src/main/java/org/eclipse/kapua/service/endpoint/EndpointInfoXmlRegistry.java index 334e2f8380f..b6f9cc352bb 100644 --- a/service/endpoint/api/src/main/java/org/eclipse/kapua/service/endpoint/EndpointInfoXmlRegistry.java +++ b/service/endpoint/api/src/main/java/org/eclipse/kapua/service/endpoint/EndpointInfoXmlRegistry.java @@ -12,10 +12,10 @@ *******************************************************************************/ package org.eclipse.kapua.service.endpoint; -import org.eclipse.kapua.locator.KapuaLocator; - import javax.xml.bind.annotation.XmlRegistry; +import org.eclipse.kapua.locator.KapuaLocator; + @XmlRegistry public class EndpointInfoXmlRegistry { @@ -39,15 +39,6 @@ public EndpointInfoCreator newCreator() { return endpointInfoFactory.newCreator(null); } - /** - * Creates a new {@link EndpointInfoListResult} - * - * @return - */ - public EndpointInfoListResult newListResult() { - return endpointInfoFactory.newListResult(); - } - /** * Creates a new {@link EndpointInfoQuery} * diff --git a/service/endpoint/internal/src/main/java/org/eclipse/kapua/service/endpoint/internal/EndpointInfoFactoryImpl.java b/service/endpoint/internal/src/main/java/org/eclipse/kapua/service/endpoint/internal/EndpointInfoFactoryImpl.java index 0bfdb553646..4b2d655a7b8 100644 --- a/service/endpoint/internal/src/main/java/org/eclipse/kapua/service/endpoint/internal/EndpointInfoFactoryImpl.java +++ b/service/endpoint/internal/src/main/java/org/eclipse/kapua/service/endpoint/internal/EndpointInfoFactoryImpl.java @@ -12,17 +12,16 @@ *******************************************************************************/ package org.eclipse.kapua.service.endpoint.internal; +import javax.inject.Singleton; + import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.endpoint.EndpointInfo; import org.eclipse.kapua.service.endpoint.EndpointInfoCreator; import org.eclipse.kapua.service.endpoint.EndpointInfoFactory; -import org.eclipse.kapua.service.endpoint.EndpointInfoListResult; import org.eclipse.kapua.service.endpoint.EndpointInfoQuery; import org.eclipse.kapua.service.endpoint.EndpointUsage; -import javax.inject.Singleton; - /** * {@link EndpointInfoFactory} implementation. * @@ -36,11 +35,6 @@ public EndpointInfo newEntity(KapuaId scopeId) { return new EndpointInfoImpl(scopeId); } - @Override - public EndpointInfoListResult newListResult() { - return new EndpointInfoListResultImpl(); - } - @Override public EndpointInfoQuery newQuery(KapuaId scopeId) { return new EndpointInfoQueryImpl(scopeId); diff --git a/service/endpoint/internal/src/main/java/org/eclipse/kapua/service/endpoint/internal/EndpointInfoImplJpaRepository.java b/service/endpoint/internal/src/main/java/org/eclipse/kapua/service/endpoint/internal/EndpointInfoImplJpaRepository.java index 3f9034dd861..2d83e376a1e 100644 --- a/service/endpoint/internal/src/main/java/org/eclipse/kapua/service/endpoint/internal/EndpointInfoImplJpaRepository.java +++ b/service/endpoint/internal/src/main/java/org/eclipse/kapua/service/endpoint/internal/EndpointInfoImplJpaRepository.java @@ -21,7 +21,8 @@ public class EndpointInfoImplJpaRepository extends KapuaUpdatableEntityJpaRepository implements EndpointInfoRepository { + public EndpointInfoImplJpaRepository(KapuaJpaRepositoryConfiguration jpaRepoConfig) { - super(EndpointInfoImpl.class, EndpointInfo.TYPE, () -> new EndpointInfoListResultImpl(), jpaRepoConfig); + super(EndpointInfoImpl.class, EndpointInfo.TYPE, () -> new EndpointInfoListResult(), jpaRepoConfig); } } diff --git a/service/endpoint/internal/src/main/java/org/eclipse/kapua/service/endpoint/internal/EndpointInfoListResultImpl.java b/service/endpoint/internal/src/main/java/org/eclipse/kapua/service/endpoint/internal/EndpointInfoListResultImpl.java deleted file mode 100644 index 36b624f5730..00000000000 --- a/service/endpoint/internal/src/main/java/org/eclipse/kapua/service/endpoint/internal/EndpointInfoListResultImpl.java +++ /dev/null @@ -1,26 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017, 2022 Eurotech and/or its affiliates and others - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Eurotech - initial API and implementation - *******************************************************************************/ -package org.eclipse.kapua.service.endpoint.internal; - -import org.eclipse.kapua.commons.model.query.KapuaListResultImpl; -import org.eclipse.kapua.service.endpoint.EndpointInfo; -import org.eclipse.kapua.service.endpoint.EndpointInfoListResult; - -/** - * {@link EndpointInfoListResult} implementation. - * - * @since 1.0.0 - */ -public class EndpointInfoListResultImpl extends KapuaListResultImpl implements EndpointInfoListResult { - -} diff --git a/service/job/api/src/main/java/org/eclipse/kapua/service/job/JobFactory.java b/service/job/api/src/main/java/org/eclipse/kapua/service/job/JobFactory.java index 2019e306624..7b985707f04 100644 --- a/service/job/api/src/main/java/org/eclipse/kapua/service/job/JobFactory.java +++ b/service/job/api/src/main/java/org/eclipse/kapua/service/job/JobFactory.java @@ -20,6 +20,6 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface JobFactory extends KapuaEntityFactory { +public interface JobFactory extends KapuaEntityFactory { } diff --git a/service/job/api/src/main/java/org/eclipse/kapua/service/job/JobListResult.java b/service/job/api/src/main/java/org/eclipse/kapua/service/job/JobListResult.java index 8973c004e95..6b070dc7347 100644 --- a/service/job/api/src/main/java/org/eclipse/kapua/service/job/JobListResult.java +++ b/service/job/api/src/main/java/org/eclipse/kapua/service/job/JobListResult.java @@ -23,11 +23,11 @@ * {@link JobListResult} definition. * * @since 1.0.0 - * */ @XmlRootElement(name = "jobListResult") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = JobXmlRegistry.class, factoryMethod = "newJobListResult") -public interface JobListResult extends KapuaListResult { +@XmlType +public class JobListResult extends KapuaListResult { + private static final long serialVersionUID = -7466853155307881848L; } diff --git a/service/job/api/src/main/java/org/eclipse/kapua/service/job/JobXmlRegistry.java b/service/job/api/src/main/java/org/eclipse/kapua/service/job/JobXmlRegistry.java index c8a7ee86d60..74abe55360f 100644 --- a/service/job/api/src/main/java/org/eclipse/kapua/service/job/JobXmlRegistry.java +++ b/service/job/api/src/main/java/org/eclipse/kapua/service/job/JobXmlRegistry.java @@ -12,10 +12,10 @@ *******************************************************************************/ package org.eclipse.kapua.service.job; -import org.eclipse.kapua.locator.KapuaLocator; - import javax.xml.bind.annotation.XmlRegistry; +import org.eclipse.kapua.locator.KapuaLocator; + /** * {@link Job} xml factory class * @@ -44,15 +44,6 @@ public JobCreator newJobCreator() { return jobFactory.newCreator(null); } - /** - * Creates a new job list result instance - * - * @return - */ - public JobListResult newJobListResult() { - return jobFactory.newListResult(); - } - public JobQuery newQuery() { return jobFactory.newQuery(null); } diff --git a/service/job/api/src/main/java/org/eclipse/kapua/service/job/execution/JobExecutionFactory.java b/service/job/api/src/main/java/org/eclipse/kapua/service/job/execution/JobExecutionFactory.java index ff4fb3d0e98..9a73594b5b1 100644 --- a/service/job/api/src/main/java/org/eclipse/kapua/service/job/execution/JobExecutionFactory.java +++ b/service/job/api/src/main/java/org/eclipse/kapua/service/job/execution/JobExecutionFactory.java @@ -20,6 +20,6 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface JobExecutionFactory extends KapuaEntityFactory { +public interface JobExecutionFactory extends KapuaEntityFactory { } diff --git a/service/job/api/src/main/java/org/eclipse/kapua/service/job/execution/JobExecutionListResult.java b/service/job/api/src/main/java/org/eclipse/kapua/service/job/execution/JobExecutionListResult.java index 59a93a12798..02dcea3020c 100644 --- a/service/job/api/src/main/java/org/eclipse/kapua/service/job/execution/JobExecutionListResult.java +++ b/service/job/api/src/main/java/org/eclipse/kapua/service/job/execution/JobExecutionListResult.java @@ -23,11 +23,10 @@ * {@link JobExecutionListResult} definition. * * @since 1.0.0 - * */ @XmlRootElement(name = "jobExecutionListResult") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = JobExecutionXmlRegistry.class, factoryMethod = "newJobExecutionListResult") -public interface JobExecutionListResult extends KapuaListResult { +@XmlType +public class JobExecutionListResult extends KapuaListResult { } diff --git a/service/job/api/src/main/java/org/eclipse/kapua/service/job/execution/JobExecutionXmlRegistry.java b/service/job/api/src/main/java/org/eclipse/kapua/service/job/execution/JobExecutionXmlRegistry.java index b1a6903c338..0de567b3408 100644 --- a/service/job/api/src/main/java/org/eclipse/kapua/service/job/execution/JobExecutionXmlRegistry.java +++ b/service/job/api/src/main/java/org/eclipse/kapua/service/job/execution/JobExecutionXmlRegistry.java @@ -12,10 +12,10 @@ *******************************************************************************/ package org.eclipse.kapua.service.job.execution; -import org.eclipse.kapua.locator.KapuaLocator; - import javax.xml.bind.annotation.XmlRegistry; +import org.eclipse.kapua.locator.KapuaLocator; + /** * {@link JobExecution} xml factory class * @@ -44,15 +44,6 @@ public JobExecutionCreator newJobExecutionCreator() { return jobExecutionFactory.newCreator(null); } - /** - * Creates a new job list result instance - * - * @return - */ - public JobExecutionListResult newJobExecutionListResult() { - return jobExecutionFactory.newListResult(); - } - public JobExecutionQuery newQuery() { return jobExecutionFactory.newQuery(null); } diff --git a/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/JobStepFactory.java b/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/JobStepFactory.java index 8509317161f..fa3b3a8bf5c 100644 --- a/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/JobStepFactory.java +++ b/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/JobStepFactory.java @@ -21,14 +21,17 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface JobStepFactory extends KapuaEntityFactory { +public interface JobStepFactory extends KapuaEntityFactory { /** * Instantiates a new {@link JobStepProperty}. * - * @param name The name to set into the {@link JobStepProperty}. - * @param propertyType The type to set into the {@link JobStepProperty}. - * @param propertyValue The value to set into the {@link JobStepProperty}. + * @param name + * The name to set into the {@link JobStepProperty}. + * @param propertyType + * The type to set into the {@link JobStepProperty}. + * @param propertyValue + * The value to set into the {@link JobStepProperty}. * @return The newly instantiated {@link JobStepProperty} * @since 1.0.0 */ diff --git a/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/JobStepListResult.java b/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/JobStepListResult.java index 8b0dd67edd9..a568f646352 100644 --- a/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/JobStepListResult.java +++ b/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/JobStepListResult.java @@ -23,11 +23,12 @@ * {@link JobStepListResult} definition. * * @since 1.0.0 - * */ @XmlRootElement(name = "jobStepListResult") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = JobStepXmlRegistry.class, factoryMethod = "newJobStepListResult") -public interface JobStepListResult extends KapuaListResult { +@XmlType +public class JobStepListResult extends KapuaListResult { + + private static final long serialVersionUID = -7466853155307881848L; } diff --git a/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/JobStepXmlRegistry.java b/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/JobStepXmlRegistry.java index 9cc8763ba30..13eaf71fe5c 100644 --- a/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/JobStepXmlRegistry.java +++ b/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/JobStepXmlRegistry.java @@ -12,11 +12,11 @@ *******************************************************************************/ package org.eclipse.kapua.service.job.step; +import javax.xml.bind.annotation.XmlRegistry; + import org.eclipse.kapua.locator.KapuaLocator; import org.eclipse.kapua.service.job.step.definition.JobStepProperty; -import javax.xml.bind.annotation.XmlRegistry; - /** * {@link JobStep} xml factory class * @@ -45,15 +45,6 @@ public JobStepCreator newJobStepCreator() { return jobStepFactory.newCreator(null); } - /** - * Creates a new job list result instance - * - * @return - */ - public JobStepListResult newJobStepListResult() { - return jobStepFactory.newListResult(); - } - public JobStepQuery newQuery() { return jobStepFactory.newQuery(null); } diff --git a/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/definition/JobStepDefinitionFactory.java b/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/definition/JobStepDefinitionFactory.java index 7e7d0f9068f..bc1c86a7f8b 100644 --- a/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/definition/JobStepDefinitionFactory.java +++ b/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/definition/JobStepDefinitionFactory.java @@ -20,15 +20,19 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface JobStepDefinitionFactory extends KapuaEntityFactory { +public interface JobStepDefinitionFactory extends KapuaEntityFactory { /** * Instantiates a new {@link JobStepProperty}. * - * @param name The name to set into the {@link JobStepProperty}. - * @param type The type to set into the {@link JobStepProperty}. - * @param value The value to set into the {@link JobStepProperty}. - * @param exampleValue The example value to set into the {@link JobStepProperty} + * @param name + * The name to set into the {@link JobStepProperty}. + * @param type + * The type to set into the {@link JobStepProperty}. + * @param value + * The value to set into the {@link JobStepProperty}. + * @param exampleValue + * The example value to set into the {@link JobStepProperty} * @return The newly instantiated {@link JobStepProperty}. * @since 1.1.0 */ @@ -37,9 +41,12 @@ public interface JobStepDefinitionFactory extends KapuaEntityFactory { +@XmlType +public class JobStepDefinitionListResult extends KapuaListResult { + + private static final long serialVersionUID = 977813250632719295L; } diff --git a/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/definition/JobStepDefinitionXmlRegistry.java b/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/definition/JobStepDefinitionXmlRegistry.java index 019d7fd1776..1ec589e7d1e 100644 --- a/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/definition/JobStepDefinitionXmlRegistry.java +++ b/service/job/api/src/main/java/org/eclipse/kapua/service/job/step/definition/JobStepDefinitionXmlRegistry.java @@ -12,10 +12,10 @@ *******************************************************************************/ package org.eclipse.kapua.service.job.step.definition; -import org.eclipse.kapua.locator.KapuaLocator; - import javax.xml.bind.annotation.XmlRegistry; +import org.eclipse.kapua.locator.KapuaLocator; + /** * {@link JobStepDefinition} xml factory class * @@ -44,15 +44,6 @@ public JobStepDefinitionCreator newJobStepDefinitionCreator() { return jobStepDefinitionFactory.newCreator(null); } - /** - * Creates a new job list result instance - * - * @return - */ - public JobStepDefinitionListResult newJobStepDefinitionListResult() { - return jobStepDefinitionFactory.newListResult(); - } - public JobStepDefinitionQuery newQuery() { return jobStepDefinitionFactory.newQuery(null); } diff --git a/service/job/api/src/main/java/org/eclipse/kapua/service/job/targets/JobTargetFactory.java b/service/job/api/src/main/java/org/eclipse/kapua/service/job/targets/JobTargetFactory.java index 27b4e8dae25..6e6870017c1 100644 --- a/service/job/api/src/main/java/org/eclipse/kapua/service/job/targets/JobTargetFactory.java +++ b/service/job/api/src/main/java/org/eclipse/kapua/service/job/targets/JobTargetFactory.java @@ -20,6 +20,6 @@ * @see org.eclipse.kapua.model.KapuaEntityFactory * @since 1.0.0 */ -public interface JobTargetFactory extends KapuaEntityFactory { +public interface JobTargetFactory extends KapuaEntityFactory { } diff --git a/service/job/api/src/main/java/org/eclipse/kapua/service/job/targets/JobTargetListResult.java b/service/job/api/src/main/java/org/eclipse/kapua/service/job/targets/JobTargetListResult.java index 3ad08fabff5..629c92c318b 100644 --- a/service/job/api/src/main/java/org/eclipse/kapua/service/job/targets/JobTargetListResult.java +++ b/service/job/api/src/main/java/org/eclipse/kapua/service/job/targets/JobTargetListResult.java @@ -23,11 +23,10 @@ * {@link JobTargetListResult} definition. * * @since 1.0.0 - * */ @XmlRootElement(name = "jobTargetListResult") @XmlAccessorType(XmlAccessType.PROPERTY) -@XmlType(factoryClass = JobTargetXmlRegistry.class, factoryMethod = "newJobTargetListResult") -public interface JobTargetListResult extends KapuaListResult { +@XmlType +public class JobTargetListResult extends KapuaListResult { } diff --git a/service/job/api/src/main/java/org/eclipse/kapua/service/job/targets/JobTargetXmlRegistry.java b/service/job/api/src/main/java/org/eclipse/kapua/service/job/targets/JobTargetXmlRegistry.java index 0e09d0c313d..8b6b8407ec1 100644 --- a/service/job/api/src/main/java/org/eclipse/kapua/service/job/targets/JobTargetXmlRegistry.java +++ b/service/job/api/src/main/java/org/eclipse/kapua/service/job/targets/JobTargetXmlRegistry.java @@ -12,10 +12,10 @@ *******************************************************************************/ package org.eclipse.kapua.service.job.targets; -import org.eclipse.kapua.locator.KapuaLocator; - import javax.xml.bind.annotation.XmlRegistry; +import org.eclipse.kapua.locator.KapuaLocator; + /** * {@link JobTarget} xml factory class * @@ -44,15 +44,6 @@ public JobTargetCreator newJobTargetCreator() { return jobTargetFactory.newCreator(null); } - /** - * Creates a new job list result instance - * - * @return - */ - public JobTargetListResult newJobTargetListResult() { - return jobTargetFactory.newListResult(); - } - public JobTargetQuery newQuery() { return jobTargetFactory.newQuery(null); } diff --git a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/execution/internal/JobExecutionFactoryImpl.java b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/execution/internal/JobExecutionFactoryImpl.java index 71fa2a9f3d0..2cb49565760 100644 --- a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/execution/internal/JobExecutionFactoryImpl.java +++ b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/execution/internal/JobExecutionFactoryImpl.java @@ -12,16 +12,15 @@ *******************************************************************************/ package org.eclipse.kapua.service.job.execution.internal; +import javax.inject.Singleton; + import org.eclipse.kapua.KapuaEntityCloneException; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.service.job.execution.JobExecution; import org.eclipse.kapua.service.job.execution.JobExecutionCreator; import org.eclipse.kapua.service.job.execution.JobExecutionFactory; -import org.eclipse.kapua.service.job.execution.JobExecutionListResult; import org.eclipse.kapua.service.job.execution.JobExecutionQuery; -import javax.inject.Singleton; - /** * {@link JobExecutionFactory} implementation. * @@ -45,11 +44,6 @@ public JobExecutionQuery newQuery(KapuaId scopeId) { return new JobExecutionQueryImpl(scopeId); } - @Override - public JobExecutionListResult newListResult() { - return new JobExecutionListResultImpl(); - } - @Override public JobExecution clone(JobExecution jobExecution) { try { diff --git a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/execution/internal/JobExecutionImplJpaRepository.java b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/execution/internal/JobExecutionImplJpaRepository.java index c4224d0d2bd..848c4e5e520 100644 --- a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/execution/internal/JobExecutionImplJpaRepository.java +++ b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/execution/internal/JobExecutionImplJpaRepository.java @@ -25,8 +25,9 @@ public class JobExecutionImplJpaRepository extends KapuaUpdatableEntityJpaRepository implements JobExecutionRepository { + public JobExecutionImplJpaRepository(KapuaJpaRepositoryConfiguration jpaRepoConfig) { - super(JobExecutionImpl.class, JobExecution.TYPE, () -> new JobExecutionListResultImpl(), jpaRepoConfig); + super(JobExecutionImpl.class, JobExecution.TYPE, () -> new JobExecutionListResult(), jpaRepoConfig); } @Override diff --git a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/execution/internal/JobExecutionListResultImpl.java b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/execution/internal/JobExecutionListResultImpl.java deleted file mode 100644 index f0d37bcad5f..00000000000 --- a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/execution/internal/JobExecutionListResultImpl.java +++ /dev/null @@ -1,26 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017, 2022 Eurotech and/or its affiliates and others - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Eurotech - initial API and implementation - *******************************************************************************/ -package org.eclipse.kapua.service.job.execution.internal; - -import org.eclipse.kapua.commons.model.query.KapuaListResultImpl; -import org.eclipse.kapua.service.job.execution.JobExecution; -import org.eclipse.kapua.service.job.execution.JobExecutionListResult; - -/** - * {@link JobExecutionListResult} implementation. - * - * @since 1.0.0 - */ -public class JobExecutionListResultImpl extends KapuaListResultImpl