Code format hawkbit-repository-core (#1927)

Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
This commit is contained in:
Avgustin Marinov
2024-11-05 09:46:55 +02:00
committed by GitHub
parent 67eb170f7c
commit da7fa9e022
27 changed files with 182 additions and 233 deletions

View File

@@ -9,7 +9,8 @@
SPDX-License-Identifier: EPL-2.0 SPDX-License-Identifier: EPL-2.0
--> -->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
<groupId>org.eclipse.hawkbit</groupId> <groupId>org.eclipse.hawkbit</groupId>

View File

@@ -9,6 +9,10 @@
*/ */
package org.eclipse.hawkbit.event; package org.eclipse.hawkbit.event;
import io.protostuff.LinkedBuffer;
import io.protostuff.ProtobufIOUtil;
import io.protostuff.Schema;
import io.protostuff.runtime.RuntimeSchema;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.bus.event.RemoteApplicationEvent; import org.springframework.cloud.bus.event.RemoteApplicationEvent;
import org.springframework.messaging.Message; import org.springframework.messaging.Message;
@@ -17,11 +21,6 @@ import org.springframework.messaging.converter.AbstractMessageConverter;
import org.springframework.messaging.converter.MessageConversionException; import org.springframework.messaging.converter.MessageConversionException;
import org.springframework.util.MimeType; import org.springframework.util.MimeType;
import io.protostuff.LinkedBuffer;
import io.protostuff.ProtobufIOUtil;
import io.protostuff.Schema;
import io.protostuff.runtime.RuntimeSchema;
/** /**
* A customize message converter for the spring cloud events. The converter is * A customize message converter for the spring cloud events. The converter is
* registered for the application/binary+protostuff type. * registered for the application/binary+protostuff type.
@@ -85,8 +84,7 @@ public class BusProtoStuffMessageConverter extends AbstractMessageConverter {
log.error("Cannot read clazz header for given EventType value {}, missing mapping", eventType.getValue()); log.error("Cannot read clazz header for given EventType value {}, missing mapping", eventType.getValue());
throw new MessageConversionException("Missing mapping of EventType for value " + eventType.getValue()); throw new MessageConversionException("Missing mapping of EventType for value " + eventType.getValue());
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked") final Schema<Object> schema = (Schema<Object>) RuntimeSchema.getSchema(targetClass);
final Schema<Object> schema = (Schema<Object>) RuntimeSchema.getSchema(targetClass);
final Object deserializeEvent = schema.newMessage(); final Object deserializeEvent = schema.newMessage();
ProtobufIOUtil.mergeFrom(content, deserializeEvent, schema); ProtobufIOUtil.mergeFrom(content, deserializeEvent, schema);
return deserializeEvent; return deserializeEvent;
@@ -120,8 +118,7 @@ public class BusProtoStuffMessageConverter extends AbstractMessageConverter {
private static byte[] writeContent(final Object payload) { private static byte[] writeContent(final Object payload) {
final Class<?> serializeClass = payload.getClass(); final Class<?> serializeClass = payload.getClass();
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked") final Schema<Object> schema = (Schema<Object>) RuntimeSchema.getSchema(serializeClass);
final Schema<Object> schema = (Schema<Object>) RuntimeSchema.getSchema(serializeClass);
final LinkedBuffer buffer = LinkedBuffer.allocate(); final LinkedBuffer buffer = LinkedBuffer.allocate();
return ProtobufIOUtil.toByteArray(payload, schema, buffer); return ProtobufIOUtil.toByteArray(payload, schema, buffer);
} }
@@ -132,8 +129,7 @@ public class BusProtoStuffMessageConverter extends AbstractMessageConverter {
log.error("There is no mapping to EventType for the given class {}", clazz); log.error("There is no mapping to EventType for the given class {}", clazz);
throw new MessageConversionException("Missing EventType for given class : " + clazz); throw new MessageConversionException("Missing EventType for given class : " + clazz);
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked") final Schema<Object> schema = (Schema<Object>) RuntimeSchema
final Schema<Object> schema = (Schema<Object>) RuntimeSchema
.getSchema((Class<?>) EventType.class); .getSchema((Class<?>) EventType.class);
final LinkedBuffer buffer = LinkedBuffer.allocate(); final LinkedBuffer buffer = LinkedBuffer.allocate();
return ProtobufIOUtil.toByteArray(clazzEventType, schema, buffer); return ProtobufIOUtil.toByteArray(clazzEventType, schema, buffer);

View File

@@ -19,6 +19,7 @@ import lombok.EqualsAndHashCode;
import lombok.Getter; import lombok.Getter;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.ToString; import lombok.ToString;
import org.eclipse.hawkbit.repository.event.remote.CancelTargetAssignmentEvent;
import org.eclipse.hawkbit.repository.event.remote.DistributionSetDeletedEvent; import org.eclipse.hawkbit.repository.event.remote.DistributionSetDeletedEvent;
import org.eclipse.hawkbit.repository.event.remote.DistributionSetTagDeletedEvent; import org.eclipse.hawkbit.repository.event.remote.DistributionSetTagDeletedEvent;
import org.eclipse.hawkbit.repository.event.remote.DistributionSetTypeDeletedEvent; import org.eclipse.hawkbit.repository.event.remote.DistributionSetTypeDeletedEvent;
@@ -40,7 +41,6 @@ import org.eclipse.hawkbit.repository.event.remote.TargetTypeDeletedEvent;
import org.eclipse.hawkbit.repository.event.remote.TenantConfigurationDeletedEvent; import org.eclipse.hawkbit.repository.event.remote.TenantConfigurationDeletedEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.ActionCreatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.ActionCreatedEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.ActionUpdatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.ActionUpdatedEvent;
import org.eclipse.hawkbit.repository.event.remote.CancelTargetAssignmentEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetCreatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetCreatedEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetTagCreatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetTagCreatedEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetTagUpdatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetTagUpdatedEvent;
@@ -83,6 +83,7 @@ import org.eclipse.hawkbit.repository.event.remote.entity.TenantConfigurationUpd
public class EventType { public class EventType {
private static final Map<Integer, Class<?>> TYPES = new HashMap<>(); private static final Map<Integer, Class<?>> TYPES = new HashMap<>();
private int value;
/** /**
* The associated event-type-value must remain the same as initially * The associated event-type-value must remain the same as initially
@@ -170,27 +171,19 @@ public class EventType {
TYPES.put(46, TargetTypeDeletedEvent.class); TYPES.put(46, TargetTypeDeletedEvent.class);
} }
private int value;
/** /**
* Constructor. * Constructor.
* *
* @param value * @param value the value to initialize
* the value to initialize
*/ */
public EventType(final int value) { public EventType(final int value) {
this.value = value; this.value = value;
} }
public Class<?> getTargetClass() {
return TYPES.get(value);
}
/** /**
* Returns a {@link EventType} based on the given class type. * Returns a {@link EventType} based on the given class type.
* *
* @param clazz * @param clazz the clazz type to retrieve the corresponding {@link EventType}
* the clazz type to retrieve the corresponding {@link EventType}
* . * .
* @return the corresponding {@link EventType} or {@code null} if the clazz * @return the corresponding {@link EventType} or {@code null} if the clazz
* does not have a {@link EventType}. * does not have a {@link EventType}.
@@ -201,4 +194,8 @@ public class EventType {
return foundEventType.map(EventType::new).orElse(null); return foundEventType.map(EventType::new).orElse(null);
} }
public Class<?> getTargetClass() {
return TYPES.get(value);
}
} }

View File

@@ -15,15 +15,13 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
/** /**
* {@link QuotaManagement} implementation based on spring boot * {@link QuotaManagement} implementation based on spring boot
* {@link ConfigurationProperties}. * {@link ConfigurationProperties}.
*
*/ */
public class PropertiesQuotaManagement implements QuotaManagement { public class PropertiesQuotaManagement implements QuotaManagement {
private final HawkbitSecurityProperties securityProperties; private final HawkbitSecurityProperties securityProperties;
/** /**
* @param securityProperties * @param securityProperties that holds the quota definitions
* that holds the quota definitions
*/ */
public PropertiesQuotaManagement(final HawkbitSecurityProperties securityProperties) { public PropertiesQuotaManagement(final HawkbitSecurityProperties securityProperties) {
this.securityProperties = securityProperties; this.securityProperties = securityProperties;
@@ -84,11 +82,6 @@ public class PropertiesQuotaManagement implements QuotaManagement {
return securityProperties.getDos().getMaxTargetsPerRolloutGroup(); return securityProperties.getDos().getMaxTargetsPerRolloutGroup();
} }
@Override
public int getMaxActionsPerTarget() {
return securityProperties.getDos().getMaxActionsPerTarget();
}
@Override @Override
public int getMaxTargetDistributionSetAssignmentsPerManualAssignment() { public int getMaxTargetDistributionSetAssignmentsPerManualAssignment() {
return securityProperties.getDos().getMaxTargetDistributionSetAssignmentsPerManualAssignment(); return securityProperties.getDos().getMaxTargetDistributionSetAssignmentsPerManualAssignment();
@@ -99,6 +92,11 @@ public class PropertiesQuotaManagement implements QuotaManagement {
return securityProperties.getDos().getMaxTargetsPerAutoAssignment(); return securityProperties.getDos().getMaxTargetsPerAutoAssignment();
} }
@Override
public int getMaxActionsPerTarget() {
return securityProperties.getDos().getMaxActionsPerTarget();
}
@Override @Override
public long getMaxArtifactSize() { public long getMaxArtifactSize() {
return securityProperties.getDos().getMaxArtifactSize(); return securityProperties.getDos().getMaxArtifactSize();

View File

@@ -17,7 +17,6 @@ import org.springframework.context.annotation.PropertySource;
/** /**
* Default configuration that is common to all repository implementations. * Default configuration that is common to all repository implementations.
*
*/ */
@Configuration @Configuration
@EnableConfigurationProperties({ RepositoryProperties.class, ControllerPollProperties.class, @EnableConfigurationProperties({ RepositoryProperties.class, ControllerPollProperties.class,

View File

@@ -22,8 +22,7 @@ public interface RolloutApprovalStrategy {
* important according to the implementation, e.g. user roles of the rollout * important according to the implementation, e.g. user roles of the rollout
* creator, state of the system, .... * creator, state of the system, ....
* *
* @param rollout * @param rollout rollout to decide for whether approval is needed.
* rollout to decide for whether approval is needed.
* @return true if the rollout according to this strategy needs approval. * @return true if the rollout according to this strategy needs approval.
*/ */
boolean isApprovalNeeded(Rollout rollout); boolean isApprovalNeeded(Rollout rollout);
@@ -34,8 +33,7 @@ public interface RolloutApprovalStrategy {
* Implementations may also decide to provide an empty implementation for this * Implementations may also decide to provide an empty implementation for this
* method. * method.
* *
* @param rollout * @param rollout rollout to create approval task for.
* rollout to create approval task for.
*/ */
void onApprovalRequired(Rollout rollout); void onApprovalRequired(Rollout rollout);
@@ -44,8 +42,7 @@ public interface RolloutApprovalStrategy {
* Depending on the implementation this may be different to the current user eg. * Depending on the implementation this may be different to the current user eg.
* when the decision is made in an external system. * when the decision is made in an external system.
* *
* @param rollout * @param rollout target rollout
* target rollout
* @return identifier of the user that decided on approval * @return identifier of the user that decided on approval
*/ */
String getApprovalUser(Rollout rollout); String getApprovalUser(Rollout rollout);

View File

@@ -187,16 +187,6 @@ public final class RolloutHelper {
return baseFilter; return baseFilter;
} }
private static boolean isTargetFilterInGroups(final String groupFilter, final List<RolloutGroup> groups) {
return !StringUtils.isEmpty(groupFilter)
&& groups.stream().anyMatch(prevGroup -> !StringUtils.isEmpty(prevGroup.getTargetFilterQuery())
&& prevGroup.getTargetFilterQuery().equals(groupFilter));
}
private static String concatAndTargetFilters(final String... filters) {
return "(" + Arrays.stream(filters).collect(Collectors.joining(");(")) + ")";
}
/** /**
* @param baseFilter the base filter from the rollout * @param baseFilter the base filter from the rollout
* @param group group for which the filter string should be created * @param group group for which the filter string should be created
@@ -254,4 +244,14 @@ public final class RolloutHelper {
public static String getIdFromRetriedTargetFilter(final String targetFilter) { public static String getIdFromRetriedTargetFilter(final String targetFilter) {
return targetFilter.substring("failedrollout==".length()); return targetFilter.substring("failedrollout==".length());
} }
private static boolean isTargetFilterInGroups(final String groupFilter, final List<RolloutGroup> groups) {
return !StringUtils.isEmpty(groupFilter)
&& groups.stream().anyMatch(prevGroup -> !StringUtils.isEmpty(prevGroup.getTargetFilterQuery())
&& prevGroup.getTargetFilterQuery().equals(groupFilter));
}
private static String concatAndTargetFilters(final String... filters) {
return "(" + Arrays.stream(filters).collect(Collectors.joining(");(")) + ")";
}
} }

View File

@@ -17,6 +17,7 @@ import java.util.stream.Collectors;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import com.github.benmanes.caffeine.cache.Caffeine;
import org.eclipse.hawkbit.cache.TenancyCacheManager; import org.eclipse.hawkbit.cache.TenancyCacheManager;
import org.eclipse.hawkbit.cache.TenantAwareCacheManager; import org.eclipse.hawkbit.cache.TenantAwareCacheManager;
import org.eclipse.hawkbit.repository.event.remote.RolloutDeletedEvent; import org.eclipse.hawkbit.repository.event.remote.RolloutDeletedEvent;
@@ -31,11 +32,8 @@ import org.springframework.cache.Cache;
import org.springframework.cache.caffeine.CaffeineCacheManager; import org.springframework.cache.caffeine.CaffeineCacheManager;
import org.springframework.context.event.EventListener; import org.springframework.context.event.EventListener;
import com.github.benmanes.caffeine.cache.Caffeine;
/** /**
* Internal cache for Rollout status. * Internal cache for Rollout status.
*
*/ */
public class RolloutStatusCache { public class RolloutStatusCache {
@@ -47,10 +45,8 @@ public class RolloutStatusCache {
private final TenantAware tenantAware; private final TenantAware tenantAware;
/** /**
* @param tenantAware * @param tenantAware to get current tenant
* to get current tenant * @param size the maximum size of the cache
* @param size
* the maximum size of the cache
*/ */
public RolloutStatusCache(final TenantAware tenantAware, final long size) { public RolloutStatusCache(final TenantAware tenantAware, final long size) {
this.tenantAware = tenantAware; this.tenantAware = tenantAware;
@@ -63,8 +59,7 @@ public class RolloutStatusCache {
} }
/** /**
* @param tenantAware * @param tenantAware to get current tenant
* to get current tenant
*/ */
public RolloutStatusCache(final TenantAware tenantAware) { public RolloutStatusCache(final TenantAware tenantAware) {
this(tenantAware, DEFAULT_SIZE); this(tenantAware, DEFAULT_SIZE);
@@ -74,8 +69,7 @@ public class RolloutStatusCache {
* Retrieves cached list of {@link TotalTargetCountActionStatus} of * Retrieves cached list of {@link TotalTargetCountActionStatus} of
* {@link Rollout}s. * {@link Rollout}s.
* *
* @param rollouts * @param rollouts rolloutIds to retrieve cache entries for
* rolloutIds to retrieve cache entries for
* @return map of cached entries * @return map of cached entries
*/ */
public Map<Long, List<TotalTargetCountActionStatus>> getRolloutStatus(final List<Long> rollouts) { public Map<Long, List<TotalTargetCountActionStatus>> getRolloutStatus(final List<Long> rollouts) {
@@ -86,8 +80,7 @@ public class RolloutStatusCache {
* Retrieves cached list of {@link TotalTargetCountActionStatus} of * Retrieves cached list of {@link TotalTargetCountActionStatus} of
* {@link Rollout}s. * {@link Rollout}s.
* *
* @param rolloutId * @param rolloutId to retrieve cache entries for
* to retrieve cache entries for
* @return map of cached entries * @return map of cached entries
*/ */
public List<TotalTargetCountActionStatus> getRolloutStatus(final Long rolloutId) { public List<TotalTargetCountActionStatus> getRolloutStatus(final Long rolloutId) {
@@ -98,8 +91,7 @@ public class RolloutStatusCache {
* Retrieves cached list of {@link TotalTargetCountActionStatus} of * Retrieves cached list of {@link TotalTargetCountActionStatus} of
* {@link RolloutGroup}s. * {@link RolloutGroup}s.
* *
* @param rolloutGroups * @param rolloutGroups rolloutGroupsIds to retrieve cache entries for
* rolloutGroupsIds to retrieve cache entries for
* @return map of cached entries * @return map of cached entries
*/ */
public Map<Long, List<TotalTargetCountActionStatus>> getRolloutGroupStatus(final List<Long> rolloutGroups) { public Map<Long, List<TotalTargetCountActionStatus>> getRolloutGroupStatus(final List<Long> rolloutGroups) {
@@ -110,8 +102,7 @@ public class RolloutStatusCache {
* Retrieves cached list of {@link TotalTargetCountActionStatus} of * Retrieves cached list of {@link TotalTargetCountActionStatus} of
* {@link RolloutGroup}. * {@link RolloutGroup}.
* *
* @param groupId * @param groupId to retrieve cache entries for
* to retrieve cache entries for
* @return map of cached entries * @return map of cached entries
*/ */
public List<TotalTargetCountActionStatus> getRolloutGroupStatus(final Long groupId) { public List<TotalTargetCountActionStatus> getRolloutGroupStatus(final Long groupId) {
@@ -122,8 +113,7 @@ public class RolloutStatusCache {
* Put map of {@link TotalTargetCountActionStatus} for multiple * Put map of {@link TotalTargetCountActionStatus} for multiple
* {@link Rollout}s into cache. * {@link Rollout}s into cache.
* *
* @param put * @param put map of cached entries
* map of cached entries
*/ */
public void putRolloutStatus(final Map<Long, List<TotalTargetCountActionStatus>> put) { public void putRolloutStatus(final Map<Long, List<TotalTargetCountActionStatus>> put) {
putIntoCache(put, getRolloutStatusCache()); putIntoCache(put, getRolloutStatusCache());
@@ -133,23 +123,18 @@ public class RolloutStatusCache {
* Put {@link TotalTargetCountActionStatus} for one {@link Rollout}s into * Put {@link TotalTargetCountActionStatus} for one {@link Rollout}s into
* cache. * cache.
* *
* @param rolloutId * @param rolloutId the cache entries belong to
* the cache entries belong to * @param status list to cache
* @param status
* list to cache
*
*/ */
public void putRolloutStatus(final Long rolloutId, final List<TotalTargetCountActionStatus> status) { public void putRolloutStatus(final Long rolloutId, final List<TotalTargetCountActionStatus> status) {
putIntoCache(rolloutId, status, getRolloutStatusCache()); putIntoCache(rolloutId, status, getRolloutStatusCache());
} }
/** /**
* Put {@link TotalTargetCountActionStatus} for multiple * Put {@link TotalTargetCountActionStatus} for multiple
* {@link RolloutGroup}s into cache. * {@link RolloutGroup}s into cache.
* *
* @param put * @param put map of cached entries
* map of cached entries
*/ */
public void putRolloutGroupStatus(final Map<Long, List<TotalTargetCountActionStatus>> put) { public void putRolloutGroupStatus(final Map<Long, List<TotalTargetCountActionStatus>> put) {
putIntoCache(put, getGroupStatusCache()); putIntoCache(put, getGroupStatusCache());
@@ -159,41 +144,13 @@ public class RolloutStatusCache {
* Put {@link TotalTargetCountActionStatus} for multiple * Put {@link TotalTargetCountActionStatus} for multiple
* {@link RolloutGroup}s into cache. * {@link RolloutGroup}s into cache.
* *
* @param groupId * @param groupId the cache entries belong to
* the cache entries belong to * @param status list to cache
* @param status
* list to cache
*/ */
public void putRolloutGroupStatus(final Long groupId, final List<TotalTargetCountActionStatus> status) { public void putRolloutGroupStatus(final Long groupId, final List<TotalTargetCountActionStatus> status) {
putIntoCache(groupId, status, getGroupStatusCache()); putIntoCache(groupId, status, getGroupStatusCache());
} }
private Map<Long, List<TotalTargetCountActionStatus>> retrieveFromCache(final List<Long> ids,
@NotNull final Cache cache) {
return ids.stream().map(id -> cache.get(id, CachedTotalTargetCountActionStatus.class)).filter(Objects::nonNull)
.collect(Collectors.toMap(CachedTotalTargetCountActionStatus::getId,
CachedTotalTargetCountActionStatus::getStatus));
}
private List<TotalTargetCountActionStatus> retrieveFromCache(final Long id, @NotNull final Cache cache) {
final CachedTotalTargetCountActionStatus cacheItem = cache.get(id, CachedTotalTargetCountActionStatus.class);
if (cacheItem == null) {
return Collections.emptyList();
}
return cacheItem.getStatus();
}
private void putIntoCache(final Long id, final List<TotalTargetCountActionStatus> status,
@NotNull final Cache cache) {
cache.put(id, new CachedTotalTargetCountActionStatus(id, status));
}
private void putIntoCache(final Map<Long, List<TotalTargetCountActionStatus>> put, @NotNull final Cache cache) {
put.forEach((k, v) -> cache.put(k, new CachedTotalTargetCountActionStatus(k, v)));
}
@EventListener(classes = AbstractActionEvent.class) @EventListener(classes = AbstractActionEvent.class)
public void invalidateCachedTotalTargetCountActionStatus(final AbstractActionEvent event) { public void invalidateCachedTotalTargetCountActionStatus(final AbstractActionEvent event) {
if (event.getRolloutId() != null) { if (event.getRolloutId() != null) {
@@ -235,13 +192,38 @@ public class RolloutStatusCache {
* Evicts all caches for a given tenant. All caches under a certain tenant * Evicts all caches for a given tenant. All caches under a certain tenant
* gets evicted. * gets evicted.
* *
* @param tenant * @param tenant the tenant to evict caches
* the tenant to evict caches
*/ */
public void evictCaches(final String tenant) { public void evictCaches(final String tenant) {
cacheManager.evictCaches(tenant); cacheManager.evictCaches(tenant);
} }
private Map<Long, List<TotalTargetCountActionStatus>> retrieveFromCache(final List<Long> ids,
@NotNull final Cache cache) {
return ids.stream().map(id -> cache.get(id, CachedTotalTargetCountActionStatus.class)).filter(Objects::nonNull)
.collect(Collectors.toMap(CachedTotalTargetCountActionStatus::getId,
CachedTotalTargetCountActionStatus::getStatus));
}
private List<TotalTargetCountActionStatus> retrieveFromCache(final Long id, @NotNull final Cache cache) {
final CachedTotalTargetCountActionStatus cacheItem = cache.get(id, CachedTotalTargetCountActionStatus.class);
if (cacheItem == null) {
return Collections.emptyList();
}
return cacheItem.getStatus();
}
private void putIntoCache(final Long id, final List<TotalTargetCountActionStatus> status,
@NotNull final Cache cache) {
cache.put(id, new CachedTotalTargetCountActionStatus(id, status));
}
private void putIntoCache(final Map<Long, List<TotalTargetCountActionStatus>> put, @NotNull final Cache cache) {
put.forEach((k, v) -> cache.put(k, new CachedTotalTargetCountActionStatus(k, v)));
}
private @NotNull Cache getRolloutStatusCache() { private @NotNull Cache getRolloutStatusCache() {
return Objects.requireNonNull(cacheManager.getCache(CACHE_RO_NAME), "Cache '" + CACHE_RO_NAME + "' is null!"); return Objects.requireNonNull(cacheManager.getCache(CACHE_RO_NAME), "Cache '" + CACHE_RO_NAME + "' is null!");
} }
@@ -251,6 +233,7 @@ public class RolloutStatusCache {
} }
private static final class CachedTotalTargetCountActionStatus { private static final class CachedTotalTargetCountActionStatus {
private final long id; private final long id;
private final List<TotalTargetCountActionStatus> status; private final List<TotalTargetCountActionStatus> status;

View File

@@ -22,8 +22,7 @@ import org.springframework.util.StringUtils;
/** /**
* Create and update builder DTO. * Create and update builder DTO.
* *
* @param <T> * @param <T> update or create builder interface
* update or create builder interface
*/ */
public abstract class AbstractActionStatusCreate<T> { public abstract class AbstractActionStatusCreate<T> {

View File

@@ -12,14 +12,10 @@ package org.eclipse.hawkbit.repository.builder;
import java.util.Collection; import java.util.Collection;
import java.util.Optional; import java.util.Optional;
import org.eclipse.hawkbit.repository.ValidString;
import org.springframework.util.StringUtils;
/** /**
* Create and update builder DTO. * Create and update builder DTO.
* *
* @param <T> * @param <T> update or create builder interface
* update or create builder interface
*/ */
public abstract class AbstractDistributionSetTypeUpdateCreate<T> extends AbstractTypeUpdateCreate<T> { public abstract class AbstractDistributionSetTypeUpdateCreate<T> extends AbstractTypeUpdateCreate<T> {

View File

@@ -17,10 +17,10 @@ import org.springframework.util.StringUtils;
/** /**
* Create and update builder DTO. * Create and update builder DTO.
* *
* @param <T> * @param <T> update or create builder interface
* update or create builder interface
*/ */
public abstract class AbstractMetadataUpdateCreate<T> { public abstract class AbstractMetadataUpdateCreate<T> {
@ValidString @ValidString
protected String key; protected String key;

View File

@@ -11,8 +11,6 @@ package org.eclipse.hawkbit.repository.builder;
import java.util.Optional; import java.util.Optional;
import jakarta.annotation.Nullable;
import jakarta.validation.constraints.Null;
import org.eclipse.hawkbit.repository.ValidString; import org.eclipse.hawkbit.repository.ValidString;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;

View File

@@ -16,10 +16,10 @@ import org.springframework.util.StringUtils;
/** /**
* Create builder DTO. * Create builder DTO.
* *
* @param <T> * @param <T> update or create builder interface
* update or create builder interface
*/ */
public abstract class AbstractRolloutGroupCreate<T> extends AbstractNamedEntityBuilder<T> { public abstract class AbstractRolloutGroupCreate<T> extends AbstractNamedEntityBuilder<T> {
@ValidString @ValidString
protected String targetFilterQuery; protected String targetFilterQuery;
protected Float targetPercentage; protected Float targetPercentage;

View File

@@ -14,10 +14,10 @@ import java.util.Optional;
/** /**
* Create and update builder DTO. * Create and update builder DTO.
* *
* @param <T> * @param <T> update or create builder interface
* update or create builder interface
*/ */
public abstract class AbstractSoftwareModuleMetadataUpdateCreate<T> extends AbstractMetadataUpdateCreate<T> { public abstract class AbstractSoftwareModuleMetadataUpdateCreate<T> extends AbstractMetadataUpdateCreate<T> {
protected Boolean targetVisible; protected Boolean targetVisible;
protected long softwareModuleId; protected long softwareModuleId;

View File

@@ -12,8 +12,7 @@ package org.eclipse.hawkbit.repository.builder;
/** /**
* Create and update builder DTO. * Create and update builder DTO.
* *
* @param <T> * @param <T> update or create builder interface
* update or create builder interface
*/ */
public abstract class AbstractSoftwareModuleTypeUpdateCreate<T> extends AbstractTypeUpdateCreate<T> { public abstract class AbstractSoftwareModuleTypeUpdateCreate<T> extends AbstractTypeUpdateCreate<T> {

View File

@@ -17,10 +17,10 @@ import org.springframework.util.StringUtils;
/** /**
* Create and update builder DTO. * Create and update builder DTO.
* *
* @param <T> * @param <T> update or create builder interface
* update or create builder interface
*/ */
public abstract class AbstractSoftwareModuleUpdateCreate<T> extends AbstractNamedEntityBuilder<T> { public abstract class AbstractSoftwareModuleUpdateCreate<T> extends AbstractNamedEntityBuilder<T> {
@ValidString @ValidString
protected String version; protected String version;

View File

@@ -17,10 +17,10 @@ import org.springframework.util.StringUtils;
/** /**
* Create and update builder DTO. * Create and update builder DTO.
* *
* @param <T> * @param <T> update or create builder interface
* update or create builder interface
*/ */
public class AbstractTagUpdateCreate<T> extends AbstractNamedEntityBuilder<T> { public class AbstractTagUpdateCreate<T> extends AbstractNamedEntityBuilder<T> {
@ValidString @ValidString
protected String colour; protected String colour;

View File

@@ -23,10 +23,10 @@ import org.springframework.util.StringUtils;
/** /**
* Create and update builder DTO. * Create and update builder DTO.
* *
* @param <T> * @param <T> update or create builder interface
* update or create builder interface
*/ */
public abstract class AbstractTargetFilterQueryUpdateCreate<T> extends AbstractBaseEntityBuilder { public abstract class AbstractTargetFilterQueryUpdateCreate<T> extends AbstractBaseEntityBuilder {
@ValidString @ValidString
protected String name; protected String name;
@@ -46,8 +46,7 @@ public abstract class AbstractTargetFilterQueryUpdateCreate<T> extends AbstractB
/** /**
* Set DS ID of the {@link Action} created during auto assignment * Set DS ID of the {@link Action} created during auto assignment
* *
* @param distributionSetId * @param distributionSetId of the {@link TargetFilterQuery}
* of the {@link TargetFilterQuery}
* @return this builder * @return this builder
*/ */
public T autoAssignDistributionSet(final Long distributionSetId) { public T autoAssignDistributionSet(final Long distributionSetId) {
@@ -63,8 +62,7 @@ public abstract class AbstractTargetFilterQueryUpdateCreate<T> extends AbstractB
* Set {@link ActionType} of the {@link Action} created during auto * Set {@link ActionType} of the {@link Action} created during auto
* assignment * assignment
* *
* @param actionType * @param actionType of the {@link TargetFilterQuery}
* of the {@link TargetFilterQuery}
* @return this builder * @return this builder
*/ */
public T autoAssignActionType(final ActionType actionType) { public T autoAssignActionType(final ActionType actionType) {
@@ -75,8 +73,7 @@ public abstract class AbstractTargetFilterQueryUpdateCreate<T> extends AbstractB
/** /**
* Set weight of the {@link Action} created during auto assignment * Set weight of the {@link Action} created during auto assignment
* *
* @param weight * @param weight of the {@link TargetFilterQuery}
* of the {@link TargetFilterQuery}
* @return this builder * @return this builder
*/ */
public T autoAssignWeight(final Integer weight) { public T autoAssignWeight(final Integer weight) {
@@ -95,8 +92,7 @@ public abstract class AbstractTargetFilterQueryUpdateCreate<T> extends AbstractB
/** /**
* Set name of the filter * Set name of the filter
* *
* @param name * @param name of the {@link TargetFilterQuery}
* of the {@link TargetFilterQuery}
* @return this builder * @return this builder
*/ */
public T name(final String name) { public T name(final String name) {
@@ -111,8 +107,7 @@ public abstract class AbstractTargetFilterQueryUpdateCreate<T> extends AbstractB
/** /**
* Set query used by the filter * Set query used by the filter
* *
* @param query * @param query of the {@link TargetFilterQuery}
* of the {@link TargetFilterQuery}
* @return this builder * @return this builder
*/ */
public T query(final String query) { public T query(final String query) {
@@ -125,8 +120,7 @@ public abstract class AbstractTargetFilterQueryUpdateCreate<T> extends AbstractB
} }
/** /**
* @param confirmationRequired * @param confirmationRequired if confirmation is required for configured auto assignment
* if confirmation is required for configured auto assignment
* (considered with confirmation flow active) * (considered with confirmation flow active)
* @return updated builder instance * @return updated builder instance
*/ */

View File

@@ -9,25 +9,20 @@
*/ */
package org.eclipse.hawkbit.repository.builder; package org.eclipse.hawkbit.repository.builder;
import org.eclipse.hawkbit.repository.ValidString;
import org.springframework.util.StringUtils;
import java.util.Collection; import java.util.Collection;
import java.util.Optional; import java.util.Optional;
/** /**
* Create and update builder DTO. * Create and update builder DTO.
* *
* @param <T> * @param <T> update or create builder interface
* update or create builder interface
*/ */
public abstract class AbstractTargetTypeUpdateCreate<T> extends AbstractTypeUpdateCreate<T> { public abstract class AbstractTargetTypeUpdateCreate<T> extends AbstractTypeUpdateCreate<T> {
protected Collection<Long> compatible; protected Collection<Long> compatible;
/** /**
* @param compatible * @param compatible list of ID
* list of ID
* @return generic type * @return generic type
*/ */
public T compatible(final Collection<Long> compatible) { public T compatible(final Collection<Long> compatible) {

View File

@@ -21,10 +21,10 @@ import org.springframework.util.StringUtils;
/** /**
* Create and update builder DTO. * Create and update builder DTO.
* *
* @param <T> * @param <T> update or create builder interface
* update or create builder interface
*/ */
public class AbstractTargetUpdateCreate<T> extends AbstractNamedEntityBuilder<T> { public class AbstractTargetUpdateCreate<T> extends AbstractNamedEntityBuilder<T> {
@ValidString @ValidString
protected String controllerId; protected String controllerId;

View File

@@ -9,16 +9,15 @@
*/ */
package org.eclipse.hawkbit.repository.builder; package org.eclipse.hawkbit.repository.builder;
import java.util.Optional;
import org.eclipse.hawkbit.repository.ValidString; import org.eclipse.hawkbit.repository.ValidString;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.util.Optional;
/** /**
* Create and update builder DTO. * Create and update builder DTO.
* *
* @param <T> * @param <T> update or create builder interface
* update or create builder interface
*/ */
public abstract class AbstractTypeUpdateCreate<T> extends AbstractNamedEntityBuilder<T> { public abstract class AbstractTypeUpdateCreate<T> extends AbstractNamedEntityBuilder<T> {

View File

@@ -10,13 +10,12 @@
package org.eclipse.hawkbit.repository.builder; package org.eclipse.hawkbit.repository.builder;
import jakarta.annotation.Nullable; import jakarta.annotation.Nullable;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.ToString; import lombok.ToString;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import java.util.Optional;
/** /**
* Update implementation. * Update implementation.
*/ */

View File

@@ -10,13 +10,12 @@
package org.eclipse.hawkbit.repository.builder; package org.eclipse.hawkbit.repository.builder;
import jakarta.annotation.Nullable; import jakarta.annotation.Nullable;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.ToString; import lombok.ToString;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import java.util.Optional;
/** /**
* Update implementation. * Update implementation.
*/ */

View File

@@ -13,6 +13,7 @@ package org.eclipse.hawkbit.repository.builder;
* Update implementation. * Update implementation.
*/ */
public class GenericTagUpdate extends AbstractTagUpdateCreate<TagUpdate> implements TagUpdate { public class GenericTagUpdate extends AbstractTagUpdateCreate<TagUpdate> implements TagUpdate {
public GenericTagUpdate(final Long id) { public GenericTagUpdate(final Long id) {
super.id = id; super.id = id;
} }

View File

@@ -16,8 +16,7 @@ public class GenericTargetTypeUpdate extends AbstractTargetTypeUpdateCreate<Targ
implements TargetTypeUpdate { implements TargetTypeUpdate {
/** /**
* @param id * @param id Target type ID
* Target type ID
*/ */
public GenericTargetTypeUpdate(final Long id) { public GenericTargetTypeUpdate(final Long id) {
super.id = id; super.id = id;

View File

@@ -25,7 +25,8 @@ public final class SystemManagementHolder {
private static final SystemManagementHolder INSTANCE = new SystemManagementHolder(); private static final SystemManagementHolder INSTANCE = new SystemManagementHolder();
@Getter @Setter @Getter
@Setter
@Autowired @Autowired
private SystemManagement systemManagement; private SystemManagement systemManagement;

View File

@@ -15,6 +15,7 @@ import static org.mockito.Mockito.when;
import java.util.HashMap; import java.util.HashMap;
import io.qameta.allure.Description;
import org.eclipse.hawkbit.repository.event.remote.entity.RemoteEntityEvent; import org.eclipse.hawkbit.repository.event.remote.entity.RemoteEntityEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.TargetCreatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.TargetCreatedEvent;
import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.Target;
@@ -28,8 +29,6 @@ import org.springframework.messaging.Message;
import org.springframework.messaging.MessageHeaders; import org.springframework.messaging.MessageHeaders;
import org.springframework.messaging.converter.MessageConversionException; import org.springframework.messaging.converter.MessageConversionException;
import io.qameta.allure.Description;
@ExtendWith(MockitoExtension.class) @ExtendWith(MockitoExtension.class)
public class BusProtoStuffMessageConverterTest { public class BusProtoStuffMessageConverterTest {