Code refactoring of hawkbit-repository (#2056)
Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -36,14 +36,12 @@ import org.springframework.util.MimeType;
|
||||
public class BusProtoStuffMessageConverter extends AbstractMessageConverter {
|
||||
|
||||
public static final MimeType APPLICATION_BINARY_PROTOSTUFF = new MimeType("application", "binary+protostuff");
|
||||
|
||||
/**
|
||||
* The length of the class type length of the payload.
|
||||
*/
|
||||
private static final byte EVENT_TYPE_LENGTH = 2;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public BusProtoStuffMessageConverter() {
|
||||
super(APPLICATION_BINARY_PROTOSTUFF);
|
||||
}
|
||||
|
||||
@@ -83,6 +83,7 @@ import org.eclipse.hawkbit.repository.event.remote.entity.TenantConfigurationUpd
|
||||
public class EventType {
|
||||
|
||||
private static final Map<Integer, Class<?>> TYPES = new HashMap<>();
|
||||
|
||||
private int value;
|
||||
|
||||
/**
|
||||
|
||||
@@ -111,4 +111,4 @@ public class PropertiesQuotaManagement implements QuotaManagement {
|
||||
public int getMaxDistributionSetTypesPerTargetType() {
|
||||
return securityProperties.getDos().getMaxDistributionSetTypesPerTargetType();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,9 +19,6 @@ import org.springframework.context.annotation.PropertySource;
|
||||
* Default configuration that is common to all repository implementations.
|
||||
*/
|
||||
@Configuration
|
||||
@EnableConfigurationProperties({ RepositoryProperties.class, ControllerPollProperties.class,
|
||||
TenantConfigurationProperties.class })
|
||||
@EnableConfigurationProperties({ RepositoryProperties.class, ControllerPollProperties.class, TenantConfigurationProperties.class })
|
||||
@PropertySource("classpath:/hawkbit-repository-defaults.properties")
|
||||
public class RepositoryDefaultConfiguration {
|
||||
|
||||
}
|
||||
public class RepositoryDefaultConfiguration {}
|
||||
@@ -46,4 +46,4 @@ public interface RolloutApprovalStrategy {
|
||||
* @return identifier of the user that decided on approval
|
||||
*/
|
||||
String getApprovalUser(Rollout rollout);
|
||||
}
|
||||
}
|
||||
@@ -250,4 +250,4 @@ public class RolloutStatusCache {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,16 +29,12 @@ import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties.T
|
||||
public final class TimestampCalculator {
|
||||
|
||||
/**
|
||||
* Calculates the overdue timestamp (<em>overdue_ts</em>) based on the
|
||||
* current timestamp and the intervals for polling and poll-overdue:
|
||||
* Calculates the overdue timestamp (<em>overdue_ts</em>) based on the current timestamp and the intervals for polling and poll-overdue:
|
||||
* <p>
|
||||
* <em>overdue_ts = now_ts - pollingInterval -
|
||||
* pollingOverdueInterval</em>;<br>
|
||||
* <em>pollingInterval</em> and <em>pollingOverdueInterval</em> are
|
||||
* retrieved from tenant-specific system configuration.
|
||||
* <em>overdue_ts = now_ts - pollingInterval - pollingOverdueInterval</em>;<br>
|
||||
* <em>pollingInterval</em> and <em>pollingOverdueInterval</em> are retrieved from tenant-specific system configuration.
|
||||
*
|
||||
* @return <em>overdue_ts</em> in milliseconds since Unix epoch as long
|
||||
* value
|
||||
* @return <em>overdue_ts</em> in milliseconds since Unix epoch as long value
|
||||
*/
|
||||
public static long calculateOverdueTimestamp() {
|
||||
return Instant.now().toEpochMilli() - getDurationForKey(TenantConfigurationKey.POLLING_TIME_INTERVAL).toMillis()
|
||||
|
||||
@@ -18,7 +18,6 @@ import java.util.stream.Collectors;
|
||||
import lombok.Getter;
|
||||
import org.eclipse.hawkbit.repository.ValidString;
|
||||
import org.eclipse.hawkbit.repository.model.Action.Status;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Create and update builder DTO.
|
||||
@@ -28,31 +27,24 @@ import org.springframework.util.StringUtils;
|
||||
public abstract class AbstractActionStatusCreate<T> {
|
||||
|
||||
protected Status status;
|
||||
|
||||
protected Long occurredAt;
|
||||
|
||||
protected Integer code;
|
||||
|
||||
protected List<@ValidString String> messages;
|
||||
|
||||
@Getter
|
||||
protected Long actionId;
|
||||
|
||||
public T status(final Status status) {
|
||||
this.status = status;
|
||||
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public T occurredAt(final long occurredAt) {
|
||||
this.occurredAt = occurredAt;
|
||||
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public T code(final int code) {
|
||||
this.code = code;
|
||||
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
@@ -63,7 +55,6 @@ public abstract class AbstractActionStatusCreate<T> {
|
||||
} else {
|
||||
this.messages.addAll(messages.stream().map(String::strip).toList());
|
||||
}
|
||||
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
@@ -72,7 +63,6 @@ public abstract class AbstractActionStatusCreate<T> {
|
||||
this.messages = new ArrayList<>();
|
||||
}
|
||||
this.messages.add(message.strip());
|
||||
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,5 +19,4 @@ public abstract class AbstractBaseEntityBuilder implements Identifiable<Long> {
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -39,4 +39,4 @@ public abstract class AbstractDistributionSetTypeUpdateCreate<T> extends Abstrac
|
||||
public Optional<Collection<Long>> getOptional() {
|
||||
return Optional.ofNullable(optional);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,6 @@ public abstract class AbstractMetadataUpdateCreate<T> {
|
||||
|
||||
@ValidString
|
||||
protected String key;
|
||||
|
||||
@ValidString
|
||||
protected String value;
|
||||
|
||||
@@ -44,5 +43,4 @@ public abstract class AbstractMetadataUpdateCreate<T> {
|
||||
public Optional<String> getValue() {
|
||||
return Optional.ofNullable(value);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,6 @@ public abstract class AbstractNamedEntityBuilder<T> extends AbstractBaseEntityBu
|
||||
|
||||
@ValidString
|
||||
protected String name;
|
||||
|
||||
@ValidString
|
||||
protected String description;
|
||||
|
||||
|
||||
@@ -45,5 +45,4 @@ public abstract class AbstractRolloutGroupCreate<T> extends AbstractNamedEntityB
|
||||
this.confirmationRequired = confirmationRequired;
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -38,5 +38,4 @@ public abstract class AbstractSoftwareModuleMetadataUpdateCreate<T> extends Abst
|
||||
this.targetVisible = targetVisible;
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -23,10 +23,8 @@ public abstract class AbstractSoftwareModuleUpdateCreate<T> extends AbstractName
|
||||
|
||||
@ValidString
|
||||
protected String version;
|
||||
|
||||
@ValidString
|
||||
protected String vendor;
|
||||
|
||||
@ValidString
|
||||
protected String type;
|
||||
|
||||
@@ -56,5 +54,4 @@ public abstract class AbstractSoftwareModuleUpdateCreate<T> extends AbstractName
|
||||
public Optional<String> getVersion() {
|
||||
return Optional.ofNullable(version);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -32,5 +32,4 @@ public class AbstractTagUpdateCreate<T> extends AbstractNamedEntityBuilder<T> {
|
||||
public Optional<String> getColour() {
|
||||
return Optional.ofNullable(colour);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -29,18 +29,13 @@ public abstract class AbstractTargetFilterQueryUpdateCreate<T> extends AbstractB
|
||||
|
||||
@ValidString
|
||||
protected String name;
|
||||
|
||||
@ValidString
|
||||
protected String query;
|
||||
|
||||
protected Long distributionSetId;
|
||||
|
||||
protected ActionType actionType;
|
||||
|
||||
@Min(Action.WEIGHT_MIN)
|
||||
@Max(Action.WEIGHT_MAX)
|
||||
protected Integer weight;
|
||||
|
||||
protected Boolean confirmationRequired;
|
||||
|
||||
/**
|
||||
@@ -132,4 +127,4 @@ public abstract class AbstractTargetFilterQueryUpdateCreate<T> extends AbstractB
|
||||
public Optional<Boolean> getConfirmationRequired() {
|
||||
return Optional.ofNullable(confirmationRequired);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -36,4 +36,4 @@ public abstract class AbstractTargetTypeUpdateCreate<T> extends AbstractTypeUpda
|
||||
public Optional<Collection<Long>> getCompatible() {
|
||||
return Optional.ofNullable(compatible);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -27,18 +27,13 @@ public class AbstractTargetUpdateCreate<T> extends AbstractNamedEntityBuilder<T>
|
||||
|
||||
@ValidString
|
||||
protected String controllerId;
|
||||
|
||||
protected String address;
|
||||
|
||||
@ToString.Exclude
|
||||
@ValidString
|
||||
protected String securityToken;
|
||||
|
||||
protected Long lastTargetQuery;
|
||||
protected TargetUpdateStatus status;
|
||||
|
||||
protected Boolean requestAttributes;
|
||||
|
||||
protected Long targetTypeId;
|
||||
|
||||
protected AbstractTargetUpdateCreate(final String controllerId) {
|
||||
|
||||
@@ -43,4 +43,4 @@ public abstract class AbstractTypeUpdateCreate<T> extends AbstractNamedEntityBui
|
||||
public Optional<String> getKey() {
|
||||
return Optional.ofNullable(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,5 +18,4 @@ public class GenericDistributionSetTypeUpdate extends AbstractDistributionSetTyp
|
||||
public GenericDistributionSetTypeUpdate(final Long id) {
|
||||
super.id = id;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -23,8 +23,7 @@ import lombok.experimental.Accessors;
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Accessors(fluent = true)
|
||||
public class GenericDistributionSetUpdate extends AbstractDistributionSetUpdateCreate<DistributionSetUpdate>
|
||||
implements DistributionSetUpdate {
|
||||
public class GenericDistributionSetUpdate extends AbstractDistributionSetUpdateCreate<DistributionSetUpdate> implements DistributionSetUpdate {
|
||||
|
||||
@Nullable
|
||||
protected Boolean locked;
|
||||
|
||||
@@ -17,4 +17,4 @@ public class GenericRolloutUpdate extends AbstractNamedEntityBuilder<RolloutUpda
|
||||
public GenericRolloutUpdate(final Long id) {
|
||||
super.id = id;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,5 +18,4 @@ public class GenericSoftwareModuleTypeUpdate extends AbstractSoftwareModuleTypeU
|
||||
public GenericSoftwareModuleTypeUpdate(final Long id) {
|
||||
super.id = id;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -17,4 +17,4 @@ public class GenericTagUpdate extends AbstractTagUpdateCreate<TagUpdate> impleme
|
||||
public GenericTagUpdate(final Long id) {
|
||||
super.id = id;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,5 +18,4 @@ public class GenericTargetFilterQueryUpdate extends AbstractTargetFilterQueryUpd
|
||||
public GenericTargetFilterQueryUpdate(final Long id) {
|
||||
super.id = id;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -21,5 +21,4 @@ public class GenericTargetTypeUpdate extends AbstractTargetTypeUpdateCreate<Targ
|
||||
public GenericTargetTypeUpdate(final Long id) {
|
||||
super.id = id;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -30,10 +30,8 @@ public final class EventPublisherHolder {
|
||||
@Getter
|
||||
@Autowired
|
||||
private ApplicationEventPublisher eventPublisher;
|
||||
|
||||
@Autowired(required = false)
|
||||
private ServiceMatcher serviceMatcher;
|
||||
|
||||
@Autowired
|
||||
private BusProperties bus;
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.rsql;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.time.Instant;
|
||||
|
||||
import org.apache.commons.lang3.text.StrLookup;
|
||||
@@ -43,6 +44,7 @@ import org.eclipse.hawkbit.repository.TimestampCalculator;
|
||||
*/
|
||||
public class VirtualPropertyResolver extends StrLookup<String> implements VirtualPropertyReplacer {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private transient StrSubstitutor substitutor;
|
||||
|
||||
Reference in New Issue
Block a user