Code refactoring of hawkbit-repository (#2056)
Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -42,8 +42,7 @@ public class Start {
|
|||||||
public static class RedirectController {
|
public static class RedirectController {
|
||||||
|
|
||||||
@GetMapping("/")
|
@GetMapping("/")
|
||||||
public RedirectView redirectToSwagger(
|
public RedirectView redirectToSwagger(final RedirectAttributes attributes) {
|
||||||
RedirectAttributes attributes) {
|
|
||||||
attributes.addFlashAttribute("flashAttribute", "redirectWithRedirectView");
|
attributes.addFlashAttribute("flashAttribute", "redirectWithRedirectView");
|
||||||
attributes.addAttribute("attribute", "redirectWithRedirectView");
|
attributes.addAttribute("attribute", "redirectWithRedirectView");
|
||||||
return new RedirectView("swagger-ui/index.html");
|
return new RedirectView("swagger-ui/index.html");
|
||||||
@@ -52,7 +51,5 @@ public class Start {
|
|||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true, proxyTargetClass = true)
|
@EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true, proxyTargetClass = true)
|
||||||
public static class MethodSecurityConfig {
|
public static class MethodSecurityConfig {}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -32,26 +32,29 @@ public class PreAuthorizeEnabledTest extends AbstractSecurityTest {
|
|||||||
@Description("Tests whether request fail if a role is forbidden for the user")
|
@Description("Tests whether request fail if a role is forbidden for the user")
|
||||||
@WithUser(authorities = { SpPermission.READ_TARGET })
|
@WithUser(authorities = { SpPermission.READ_TARGET })
|
||||||
public void failIfNoRole() throws Exception {
|
public void failIfNoRole() throws Exception {
|
||||||
mvc.perform(get("/rest/v1/distributionsets")).andExpect(result ->
|
mvc.perform(get("/rest/v1/distributionsets"))
|
||||||
assertThat(result.getResponse().getStatus()).isEqualTo(HttpStatus.FORBIDDEN.value()));
|
.andExpect(result ->
|
||||||
|
assertThat(result.getResponse().getStatus()).isEqualTo(HttpStatus.FORBIDDEN.value()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Description("Tests whether request succeed if a role is granted for the user")
|
@Description("Tests whether request succeed if a role is granted for the user")
|
||||||
@WithUser(authorities = { SpPermission.READ_REPOSITORY })
|
@WithUser(authorities = { SpPermission.READ_REPOSITORY })
|
||||||
public void successIfHasRole() throws Exception {
|
public void successIfHasRole() throws Exception {
|
||||||
mvc.perform(get("/rest/v1/distributionsets")).andExpect(result -> {
|
mvc.perform(get("/rest/v1/distributionsets"))
|
||||||
assertThat(result.getResponse().getStatus()).isEqualTo(HttpStatus.OK.value());
|
.andExpect(result -> {
|
||||||
});
|
assertThat(result.getResponse().getStatus()).isEqualTo(HttpStatus.OK.value());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Description("Tests whether request succeed if a role is granted for the user")
|
@Description("Tests whether request succeed if a role is granted for the user")
|
||||||
@WithUser(authorities = { SpRole.TENANT_ADMIN })
|
@WithUser(authorities = { SpRole.TENANT_ADMIN })
|
||||||
public void successIfHasTenantAdminRole() throws Exception {
|
public void successIfHasTenantAdminRole() throws Exception {
|
||||||
mvc.perform(get("/rest/v1/distributionsets")).andExpect(result -> {
|
mvc.perform(get("/rest/v1/distributionsets"))
|
||||||
assertThat(result.getResponse().getStatus()).isEqualTo(HttpStatus.OK.value());
|
.andExpect(result -> {
|
||||||
});
|
assertThat(result.getResponse().getStatus()).isEqualTo(HttpStatus.OK.value());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -59,14 +62,15 @@ public class PreAuthorizeEnabledTest extends AbstractSecurityTest {
|
|||||||
"granted for the user")
|
"granted for the user")
|
||||||
@WithUser(authorities = { SpPermission.READ_TARGET })
|
@WithUser(authorities = { SpPermission.READ_TARGET })
|
||||||
public void onlyDSIfNoTenantConfig() throws Exception {
|
public void onlyDSIfNoTenantConfig() throws Exception {
|
||||||
mvc.perform(get("/rest/v1/system/configs")).andExpect(result -> {
|
mvc.perform(get("/rest/v1/system/configs"))
|
||||||
// returns default DS type because of READ_TARGET
|
.andExpect(result -> {
|
||||||
assertThat(result.getResponse().getStatus()).isEqualTo(HttpStatus.OK.value());
|
// returns default DS type because of READ_TARGET
|
||||||
assertThat(
|
assertThat(result.getResponse().getStatus()).isEqualTo(HttpStatus.OK.value());
|
||||||
new ObjectMapper().reader().readValue(result.getResponse().getContentAsString(), HashMap.class)
|
assertThat(
|
||||||
.size())
|
new ObjectMapper().reader().readValue(result.getResponse().getContentAsString(), HashMap.class)
|
||||||
.isEqualTo(1);
|
.size())
|
||||||
});
|
.isEqualTo(1);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -74,7 +78,8 @@ public class PreAuthorizeEnabledTest extends AbstractSecurityTest {
|
|||||||
"granted for the user")
|
"granted for the user")
|
||||||
@WithUser(authorities = { SpPermission.TENANT_CONFIGURATION })
|
@WithUser(authorities = { SpPermission.TENANT_CONFIGURATION })
|
||||||
public void successIfHasTenantConfig() throws Exception {
|
public void successIfHasTenantConfig() throws Exception {
|
||||||
mvc.perform(get("/rest/v1/system/configs")).andExpect(result ->
|
mvc.perform(get("/rest/v1/system/configs"))
|
||||||
assertThat(result.getResponse().getStatus()).isEqualTo(HttpStatus.OK.value()));
|
.andExpect(result ->
|
||||||
|
assertThat(result.getResponse().getStatus()).isEqualTo(HttpStatus.OK.value()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -33,14 +33,6 @@
|
|||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
|
||||||
<artifactId>jackson-annotations</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>jakarta.validation</groupId>
|
|
||||||
<artifactId>jakarta.validation-api</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.hateoas</groupId>
|
<groupId>org.springframework.hateoas</groupId>
|
||||||
<artifactId>spring-hateoas</artifactId>
|
<artifactId>spring-hateoas</artifactId>
|
||||||
@@ -71,6 +63,16 @@
|
|||||||
</exclusion>
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>jakarta.validation</groupId>
|
||||||
|
<artifactId>jakarta.validation-api</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
|
<artifactId>jackson-annotations</artifactId>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.cronutils</groupId>
|
<groupId>com.cronutils</groupId>
|
||||||
<artifactId>cron-utils</artifactId>
|
<artifactId>cron-utils</artifactId>
|
||||||
|
|||||||
@@ -9,6 +9,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.repository;
|
package org.eclipse.hawkbit.repository;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.springframework.data.domain.PageRequest;
|
import org.springframework.data.domain.PageRequest;
|
||||||
import org.springframework.data.domain.Sort;
|
import org.springframework.data.domain.Sort;
|
||||||
@@ -23,6 +25,7 @@ import org.springframework.data.domain.Sort;
|
|||||||
@Data
|
@Data
|
||||||
public final class OffsetBasedPageRequest extends PageRequest {
|
public final class OffsetBasedPageRequest extends PageRequest {
|
||||||
|
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private final long offset;
|
private final long offset;
|
||||||
|
|||||||
@@ -18,12 +18,12 @@ import java.util.Map;
|
|||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
|
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
|
||||||
|
import org.eclipse.hawkbit.repository.exception.TenantConfigurationValidatorException;
|
||||||
import org.eclipse.hawkbit.repository.model.PollStatus;
|
import org.eclipse.hawkbit.repository.model.PollStatus;
|
||||||
import org.eclipse.hawkbit.repository.model.Target;
|
import org.eclipse.hawkbit.repository.model.Target;
|
||||||
import org.eclipse.hawkbit.repository.model.TenantConfigurationValue;
|
import org.eclipse.hawkbit.repository.model.TenantConfigurationValue;
|
||||||
import org.eclipse.hawkbit.tenancy.configuration.DurationHelper;
|
import org.eclipse.hawkbit.tenancy.configuration.DurationHelper;
|
||||||
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties.TenantConfigurationKey;
|
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties.TenantConfigurationKey;
|
||||||
import org.eclipse.hawkbit.repository.exception.TenantConfigurationValidatorException;
|
|
||||||
import org.springframework.core.convert.ConversionFailedException;
|
import org.springframework.core.convert.ConversionFailedException;
|
||||||
import org.springframework.core.env.Environment;
|
import org.springframework.core.env.Environment;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
|||||||
@@ -26,13 +26,11 @@ import org.eclipse.hawkbit.repository.model.MetaData;
|
|||||||
@Getter
|
@Getter
|
||||||
public class EntityNotFoundException extends AbstractServerRtException {
|
public class EntityNotFoundException extends AbstractServerRtException {
|
||||||
|
|
||||||
@Serial
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
public static final String KEY = "key";
|
public static final String KEY = "key";
|
||||||
public static final String ENTITY_ID = "entityId";
|
public static final String ENTITY_ID = "entityId";
|
||||||
public static final String TYPE = "type";
|
public static final String TYPE = "type";
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
private static final SpServerError THIS_ERROR = SpServerError.SP_REPO_ENTITY_NOT_EXISTS;
|
private static final SpServerError THIS_ERROR = SpServerError.SP_REPO_ENTITY_NOT_EXISTS;
|
||||||
private static final int ENTITY_STRING_MAX_LENGTH = 100;
|
private static final int ENTITY_STRING_MAX_LENGTH = 100;
|
||||||
|
|
||||||
|
|||||||
@@ -12,9 +12,9 @@ package org.eclipse.hawkbit.tenancy.configuration.validator;
|
|||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.time.format.DateTimeParseException;
|
import java.time.format.DateTimeParseException;
|
||||||
|
|
||||||
|
import org.eclipse.hawkbit.repository.exception.TenantConfigurationValidatorException;
|
||||||
import org.eclipse.hawkbit.tenancy.configuration.ControllerPollProperties;
|
import org.eclipse.hawkbit.tenancy.configuration.ControllerPollProperties;
|
||||||
import org.eclipse.hawkbit.tenancy.configuration.DurationHelper;
|
import org.eclipse.hawkbit.tenancy.configuration.DurationHelper;
|
||||||
import org.eclipse.hawkbit.repository.exception.TenantConfigurationValidatorException;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -36,14 +36,12 @@ import org.springframework.util.MimeType;
|
|||||||
public class BusProtoStuffMessageConverter extends AbstractMessageConverter {
|
public class BusProtoStuffMessageConverter extends AbstractMessageConverter {
|
||||||
|
|
||||||
public static final MimeType APPLICATION_BINARY_PROTOSTUFF = new MimeType("application", "binary+protostuff");
|
public static final MimeType APPLICATION_BINARY_PROTOSTUFF = new MimeType("application", "binary+protostuff");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The length of the class type length of the payload.
|
* The length of the class type length of the payload.
|
||||||
*/
|
*/
|
||||||
private static final byte EVENT_TYPE_LENGTH = 2;
|
private static final byte EVENT_TYPE_LENGTH = 2;
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor.
|
|
||||||
*/
|
|
||||||
public BusProtoStuffMessageConverter() {
|
public BusProtoStuffMessageConverter() {
|
||||||
super(APPLICATION_BINARY_PROTOSTUFF);
|
super(APPLICATION_BINARY_PROTOSTUFF);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
private int value;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -19,9 +19,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, TenantConfigurationProperties.class })
|
||||||
TenantConfigurationProperties.class })
|
|
||||||
@PropertySource("classpath:/hawkbit-repository-defaults.properties")
|
@PropertySource("classpath:/hawkbit-repository-defaults.properties")
|
||||||
public class RepositoryDefaultConfiguration {
|
public class RepositoryDefaultConfiguration {}
|
||||||
|
|
||||||
}
|
|
||||||
@@ -29,16 +29,12 @@ import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties.T
|
|||||||
public final class TimestampCalculator {
|
public final class TimestampCalculator {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculates the overdue timestamp (<em>overdue_ts</em>) based on the
|
* Calculates the overdue timestamp (<em>overdue_ts</em>) based on the current timestamp and the intervals for polling and poll-overdue:
|
||||||
* current timestamp and the intervals for polling and poll-overdue:
|
|
||||||
* <p>
|
* <p>
|
||||||
* <em>overdue_ts = now_ts - pollingInterval -
|
* <em>overdue_ts = now_ts - pollingInterval - pollingOverdueInterval</em>;<br>
|
||||||
* pollingOverdueInterval</em>;<br>
|
* <em>pollingInterval</em> and <em>pollingOverdueInterval</em> are retrieved from tenant-specific system configuration.
|
||||||
* <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
|
* @return <em>overdue_ts</em> in milliseconds since Unix epoch as long value
|
||||||
* value
|
|
||||||
*/
|
*/
|
||||||
public static long calculateOverdueTimestamp() {
|
public static long calculateOverdueTimestamp() {
|
||||||
return Instant.now().toEpochMilli() - getDurationForKey(TenantConfigurationKey.POLLING_TIME_INTERVAL).toMillis()
|
return Instant.now().toEpochMilli() - getDurationForKey(TenantConfigurationKey.POLLING_TIME_INTERVAL).toMillis()
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ import java.util.stream.Collectors;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.eclipse.hawkbit.repository.ValidString;
|
import org.eclipse.hawkbit.repository.ValidString;
|
||||||
import org.eclipse.hawkbit.repository.model.Action.Status;
|
import org.eclipse.hawkbit.repository.model.Action.Status;
|
||||||
import org.springframework.util.StringUtils;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create and update builder DTO.
|
* Create and update builder DTO.
|
||||||
@@ -28,31 +27,24 @@ import org.springframework.util.StringUtils;
|
|||||||
public abstract class AbstractActionStatusCreate<T> {
|
public abstract class AbstractActionStatusCreate<T> {
|
||||||
|
|
||||||
protected Status status;
|
protected Status status;
|
||||||
|
|
||||||
protected Long occurredAt;
|
protected Long occurredAt;
|
||||||
|
|
||||||
protected Integer code;
|
protected Integer code;
|
||||||
|
|
||||||
protected List<@ValidString String> messages;
|
protected List<@ValidString String> messages;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
protected Long actionId;
|
protected Long actionId;
|
||||||
|
|
||||||
public T status(final Status status) {
|
public T status(final Status status) {
|
||||||
this.status = status;
|
this.status = status;
|
||||||
|
|
||||||
return (T) this;
|
return (T) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public T occurredAt(final long occurredAt) {
|
public T occurredAt(final long occurredAt) {
|
||||||
this.occurredAt = occurredAt;
|
this.occurredAt = occurredAt;
|
||||||
|
|
||||||
return (T) this;
|
return (T) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public T code(final int code) {
|
public T code(final int code) {
|
||||||
this.code = code;
|
this.code = code;
|
||||||
|
|
||||||
return (T) this;
|
return (T) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,7 +55,6 @@ public abstract class AbstractActionStatusCreate<T> {
|
|||||||
} else {
|
} else {
|
||||||
this.messages.addAll(messages.stream().map(String::strip).toList());
|
this.messages.addAll(messages.stream().map(String::strip).toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
return (T) this;
|
return (T) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,7 +63,6 @@ public abstract class AbstractActionStatusCreate<T> {
|
|||||||
this.messages = new ArrayList<>();
|
this.messages = new ArrayList<>();
|
||||||
}
|
}
|
||||||
this.messages.add(message.strip());
|
this.messages.add(message.strip());
|
||||||
|
|
||||||
return (T) this;
|
return (T) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,5 +19,4 @@ public abstract class AbstractBaseEntityBuilder implements Identifiable<Long> {
|
|||||||
public Long getId() {
|
public Long getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -23,7 +23,6 @@ public abstract class AbstractMetadataUpdateCreate<T> {
|
|||||||
|
|
||||||
@ValidString
|
@ValidString
|
||||||
protected String key;
|
protected String key;
|
||||||
|
|
||||||
@ValidString
|
@ValidString
|
||||||
protected String value;
|
protected String value;
|
||||||
|
|
||||||
@@ -44,5 +43,4 @@ public abstract class AbstractMetadataUpdateCreate<T> {
|
|||||||
public Optional<String> getValue() {
|
public Optional<String> getValue() {
|
||||||
return Optional.ofNullable(value);
|
return Optional.ofNullable(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -18,7 +18,6 @@ public abstract class AbstractNamedEntityBuilder<T> extends AbstractBaseEntityBu
|
|||||||
|
|
||||||
@ValidString
|
@ValidString
|
||||||
protected String name;
|
protected String name;
|
||||||
|
|
||||||
@ValidString
|
@ValidString
|
||||||
protected String description;
|
protected String description;
|
||||||
|
|
||||||
|
|||||||
@@ -45,5 +45,4 @@ public abstract class AbstractRolloutGroupCreate<T> extends AbstractNamedEntityB
|
|||||||
this.confirmationRequired = confirmationRequired;
|
this.confirmationRequired = confirmationRequired;
|
||||||
return (T) this;
|
return (T) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -38,5 +38,4 @@ public abstract class AbstractSoftwareModuleMetadataUpdateCreate<T> extends Abst
|
|||||||
this.targetVisible = targetVisible;
|
this.targetVisible = targetVisible;
|
||||||
return (T) this;
|
return (T) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -23,10 +23,8 @@ public abstract class AbstractSoftwareModuleUpdateCreate<T> extends AbstractName
|
|||||||
|
|
||||||
@ValidString
|
@ValidString
|
||||||
protected String version;
|
protected String version;
|
||||||
|
|
||||||
@ValidString
|
@ValidString
|
||||||
protected String vendor;
|
protected String vendor;
|
||||||
|
|
||||||
@ValidString
|
@ValidString
|
||||||
protected String type;
|
protected String type;
|
||||||
|
|
||||||
@@ -56,5 +54,4 @@ public abstract class AbstractSoftwareModuleUpdateCreate<T> extends AbstractName
|
|||||||
public Optional<String> getVersion() {
|
public Optional<String> getVersion() {
|
||||||
return Optional.ofNullable(version);
|
return Optional.ofNullable(version);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -32,5 +32,4 @@ public class AbstractTagUpdateCreate<T> extends AbstractNamedEntityBuilder<T> {
|
|||||||
public Optional<String> getColour() {
|
public Optional<String> getColour() {
|
||||||
return Optional.ofNullable(colour);
|
return Optional.ofNullable(colour);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -29,18 +29,13 @@ public abstract class AbstractTargetFilterQueryUpdateCreate<T> extends AbstractB
|
|||||||
|
|
||||||
@ValidString
|
@ValidString
|
||||||
protected String name;
|
protected String name;
|
||||||
|
|
||||||
@ValidString
|
@ValidString
|
||||||
protected String query;
|
protected String query;
|
||||||
|
|
||||||
protected Long distributionSetId;
|
protected Long distributionSetId;
|
||||||
|
|
||||||
protected ActionType actionType;
|
protected ActionType actionType;
|
||||||
|
|
||||||
@Min(Action.WEIGHT_MIN)
|
@Min(Action.WEIGHT_MIN)
|
||||||
@Max(Action.WEIGHT_MAX)
|
@Max(Action.WEIGHT_MAX)
|
||||||
protected Integer weight;
|
protected Integer weight;
|
||||||
|
|
||||||
protected Boolean confirmationRequired;
|
protected Boolean confirmationRequired;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -27,18 +27,13 @@ public class AbstractTargetUpdateCreate<T> extends AbstractNamedEntityBuilder<T>
|
|||||||
|
|
||||||
@ValidString
|
@ValidString
|
||||||
protected String controllerId;
|
protected String controllerId;
|
||||||
|
|
||||||
protected String address;
|
protected String address;
|
||||||
|
|
||||||
@ToString.Exclude
|
@ToString.Exclude
|
||||||
@ValidString
|
@ValidString
|
||||||
protected String securityToken;
|
protected String securityToken;
|
||||||
|
|
||||||
protected Long lastTargetQuery;
|
protected Long lastTargetQuery;
|
||||||
protected TargetUpdateStatus status;
|
protected TargetUpdateStatus status;
|
||||||
|
|
||||||
protected Boolean requestAttributes;
|
protected Boolean requestAttributes;
|
||||||
|
|
||||||
protected Long targetTypeId;
|
protected Long targetTypeId;
|
||||||
|
|
||||||
protected AbstractTargetUpdateCreate(final String controllerId) {
|
protected AbstractTargetUpdateCreate(final String controllerId) {
|
||||||
|
|||||||
@@ -18,5 +18,4 @@ public class GenericDistributionSetTypeUpdate extends AbstractDistributionSetTyp
|
|||||||
public GenericDistributionSetTypeUpdate(final Long id) {
|
public GenericDistributionSetTypeUpdate(final Long id) {
|
||||||
super.id = id;
|
super.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -23,8 +23,7 @@ import lombok.experimental.Accessors;
|
|||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@ToString(callSuper = true)
|
@ToString(callSuper = true)
|
||||||
@Accessors(fluent = true)
|
@Accessors(fluent = true)
|
||||||
public class GenericDistributionSetUpdate extends AbstractDistributionSetUpdateCreate<DistributionSetUpdate>
|
public class GenericDistributionSetUpdate extends AbstractDistributionSetUpdateCreate<DistributionSetUpdate> implements DistributionSetUpdate {
|
||||||
implements DistributionSetUpdate {
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
protected Boolean locked;
|
protected Boolean locked;
|
||||||
|
|||||||
@@ -18,5 +18,4 @@ public class GenericSoftwareModuleTypeUpdate extends AbstractSoftwareModuleTypeU
|
|||||||
public GenericSoftwareModuleTypeUpdate(final Long id) {
|
public GenericSoftwareModuleTypeUpdate(final Long id) {
|
||||||
super.id = id;
|
super.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -18,5 +18,4 @@ public class GenericTargetFilterQueryUpdate extends AbstractTargetFilterQueryUpd
|
|||||||
public GenericTargetFilterQueryUpdate(final Long id) {
|
public GenericTargetFilterQueryUpdate(final Long id) {
|
||||||
super.id = id;
|
super.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -21,5 +21,4 @@ public class GenericTargetTypeUpdate extends AbstractTargetTypeUpdateCreate<Targ
|
|||||||
public GenericTargetTypeUpdate(final Long id) {
|
public GenericTargetTypeUpdate(final Long id) {
|
||||||
super.id = id;
|
super.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -30,10 +30,8 @@ public final class EventPublisherHolder {
|
|||||||
@Getter
|
@Getter
|
||||||
@Autowired
|
@Autowired
|
||||||
private ApplicationEventPublisher eventPublisher;
|
private ApplicationEventPublisher eventPublisher;
|
||||||
|
|
||||||
@Autowired(required = false)
|
@Autowired(required = false)
|
||||||
private ServiceMatcher serviceMatcher;
|
private ServiceMatcher serviceMatcher;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private BusProperties bus;
|
private BusProperties bus;
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.repository.rsql;
|
package org.eclipse.hawkbit.repository.rsql;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
|
||||||
import org.apache.commons.lang3.text.StrLookup;
|
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 {
|
public class VirtualPropertyResolver extends StrLookup<String> implements VirtualPropertyReplacer {
|
||||||
|
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private transient StrSubstitutor substitutor;
|
private transient StrSubstitutor substitutor;
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ import org.eclipse.hawkbit.repository.RolloutGroupManagement;
|
|||||||
import org.eclipse.hawkbit.repository.RolloutHelper;
|
import org.eclipse.hawkbit.repository.RolloutHelper;
|
||||||
import org.eclipse.hawkbit.repository.RolloutManagement;
|
import org.eclipse.hawkbit.repository.RolloutManagement;
|
||||||
import org.eclipse.hawkbit.repository.TargetManagement;
|
import org.eclipse.hawkbit.repository.TargetManagement;
|
||||||
import org.eclipse.hawkbit.repository.event.remote.RolloutGroupDeletedEvent;
|
|
||||||
import org.eclipse.hawkbit.repository.event.remote.RolloutStoppedEvent;
|
import org.eclipse.hawkbit.repository.event.remote.RolloutStoppedEvent;
|
||||||
import org.eclipse.hawkbit.repository.event.remote.entity.RolloutUpdatedEvent;
|
import org.eclipse.hawkbit.repository.event.remote.entity.RolloutUpdatedEvent;
|
||||||
import org.eclipse.hawkbit.repository.exception.AssignmentQuotaExceededException;
|
import org.eclipse.hawkbit.repository.exception.AssignmentQuotaExceededException;
|
||||||
@@ -232,7 +231,8 @@ public class JpaRolloutExecutor implements RolloutExecutor {
|
|||||||
if (readyGroups == rolloutGroups.size()) {
|
if (readyGroups == rolloutGroups.size()) {
|
||||||
if (rollout.isDynamic() && !rolloutGroups.get(rolloutGroups.size() - 1).isDynamic()) {
|
if (rollout.isDynamic() && !rolloutGroups.get(rolloutGroups.size() - 1).isDynamic()) {
|
||||||
// add first dynamic group one by using the last as a parent and as a pattern
|
// add first dynamic group one by using the last as a parent and as a pattern
|
||||||
createDynamicGroup(rollout, (JpaRolloutGroup) rolloutGroups.get(rolloutGroups.size() - 1), rolloutGroups.size(), RolloutGroupStatus.READY);
|
createDynamicGroup(rollout, (JpaRolloutGroup) rolloutGroups.get(rolloutGroups.size() - 1), rolloutGroups.size(),
|
||||||
|
RolloutGroupStatus.READY);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!rolloutApprovalStrategy.isApprovalNeeded(rollout)) {
|
if (!rolloutApprovalStrategy.isApprovalNeeded(rollout)) {
|
||||||
|
|||||||
@@ -174,7 +174,6 @@ import org.springframework.beans.factory.ObjectProvider;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.config.BeanPostProcessor;
|
import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
import org.springframework.boot.autoconfigure.domain.EntityScan;
|
import org.springframework.boot.autoconfigure.domain.EntityScan;
|
||||||
@@ -183,7 +182,6 @@ import org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration;
|
|||||||
import org.springframework.boot.autoconfigure.orm.jpa.JpaProperties;
|
import org.springframework.boot.autoconfigure.orm.jpa.JpaProperties;
|
||||||
import org.springframework.boot.autoconfigure.transaction.TransactionManagerCustomizers;
|
import org.springframework.boot.autoconfigure.transaction.TransactionManagerCustomizers;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Conditional;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.EnableAspectJAutoProxy;
|
import org.springframework.context.annotation.EnableAspectJAutoProxy;
|
||||||
import org.springframework.context.annotation.Import;
|
import org.springframework.context.annotation.Import;
|
||||||
|
|||||||
@@ -32,16 +32,14 @@ public interface AccessController<T> {
|
|||||||
/**
|
/**
|
||||||
* Introduce a new specification to limit the access to a specific entity.
|
* Introduce a new specification to limit the access to a specific entity.
|
||||||
*
|
*
|
||||||
* @return a new specification limiting the access, if empty no access restrictions
|
* @return a new specification limiting the access, if empty no access restrictions are to be applied
|
||||||
* are to be applied
|
|
||||||
*/
|
*/
|
||||||
Optional<Specification<T>> getAccessRules(Operation operation);
|
Optional<Specification<T>> getAccessRules(Operation operation);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Append the resource limitation on an already existing specification.
|
* Append the resource limitation on an already existing specification.
|
||||||
*
|
*
|
||||||
* @param specification is the root specification which needs to be appended by the
|
* @param specification is the root specification which needs to be appended by the resource limitation
|
||||||
* resource limitation
|
|
||||||
* @return a new appended specification
|
* @return a new appended specification
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
@@ -79,17 +77,14 @@ public interface AccessController<T> {
|
|||||||
* Entity creation
|
* Entity creation
|
||||||
*/
|
*/
|
||||||
CREATE,
|
CREATE,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read entities
|
* Read entities
|
||||||
*/
|
*/
|
||||||
READ,
|
READ,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Entity modification (e.g. name/description change, tag/type assignment, etc.)
|
* Entity modification (e.g. name/description change, tag/type assignment, etc.)
|
||||||
*/
|
*/
|
||||||
UPDATE,
|
UPDATE,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Entity deletion
|
* Entity deletion
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -49,24 +49,20 @@ public class ExceptionMappingAspectHandler implements Ordered {
|
|||||||
private static final List<Class<?>> MAPPED_EXCEPTION_ORDER = new ArrayList<>(4);
|
private static final List<Class<?>> MAPPED_EXCEPTION_ORDER = new ArrayList<>(4);
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
|
||||||
MAPPED_EXCEPTION_ORDER.add(DuplicateKeyException.class);
|
MAPPED_EXCEPTION_ORDER.add(DuplicateKeyException.class);
|
||||||
MAPPED_EXCEPTION_ORDER.add(DataIntegrityViolationException.class);
|
MAPPED_EXCEPTION_ORDER.add(DataIntegrityViolationException.class);
|
||||||
MAPPED_EXCEPTION_ORDER.add(OptimisticLockingFailureException.class);
|
MAPPED_EXCEPTION_ORDER.add(OptimisticLockingFailureException.class);
|
||||||
MAPPED_EXCEPTION_ORDER.add(AccessDeniedException.class);
|
MAPPED_EXCEPTION_ORDER.add(AccessDeniedException.class);
|
||||||
|
|
||||||
EXCEPTION_MAPPING.put(DuplicateKeyException.class.getName(), EntityAlreadyExistsException.class.getName());
|
EXCEPTION_MAPPING.put(DuplicateKeyException.class.getName(), EntityAlreadyExistsException.class.getName());
|
||||||
EXCEPTION_MAPPING.put(DataIntegrityViolationException.class.getName(),
|
EXCEPTION_MAPPING.put(DataIntegrityViolationException.class.getName(), EntityAlreadyExistsException.class.getName());
|
||||||
EntityAlreadyExistsException.class.getName());
|
|
||||||
|
|
||||||
EXCEPTION_MAPPING.put(OptimisticLockingFailureException.class.getName(),
|
EXCEPTION_MAPPING.put(OptimisticLockingFailureException.class.getName(), ConcurrentModificationException.class.getName());
|
||||||
ConcurrentModificationException.class.getName());
|
|
||||||
EXCEPTION_MAPPING.put(AccessDeniedException.class.getName(), InsufficientPermissionException.class.getName());
|
EXCEPTION_MAPPING.put(AccessDeniedException.class.getName(), InsufficientPermissionException.class.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* catch exceptions of the {@link TransactionManager} and wrap them to
|
* catch exceptions of the {@link TransactionManager} and wrap them to custom exceptions.
|
||||||
* custom exceptions.
|
|
||||||
*
|
*
|
||||||
* @param ex the thrown and catched exception
|
* @param ex the thrown and catched exception
|
||||||
* @throws Throwable
|
* @throws Throwable
|
||||||
|
|||||||
@@ -47,11 +47,8 @@ public abstract class AbstractAutoAssignExecutor implements AutoAssignExecutor {
|
|||||||
private static final int PAGE_SIZE = 1000;
|
private static final int PAGE_SIZE = 1000;
|
||||||
|
|
||||||
private final TargetFilterQueryManagement targetFilterQueryManagement;
|
private final TargetFilterQueryManagement targetFilterQueryManagement;
|
||||||
|
|
||||||
private final DeploymentManagement deploymentManagement;
|
private final DeploymentManagement deploymentManagement;
|
||||||
|
|
||||||
private final PlatformTransactionManager transactionManager;
|
private final PlatformTransactionManager transactionManager;
|
||||||
|
|
||||||
private final ContextAware contextAware;
|
private final ContextAware contextAware;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -66,11 +66,9 @@ public class AutoAssignChecker extends AbstractAutoAssignExecutor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void checkSingleTarget(String controllerId) {
|
public void checkSingleTarget(String controllerId) {
|
||||||
log.debug("Auto assign check call for tenant {} and device {} started", getContextAware().getCurrentTenant(),
|
log.debug("Auto assign check call for tenant {} and device {} started", getContextAware().getCurrentTenant(), controllerId);
|
||||||
controllerId);
|
|
||||||
forEachFilterWithAutoAssignDS(filter -> checkForDevice(controllerId, filter));
|
forEachFilterWithAutoAssignDS(filter -> checkForDevice(controllerId, filter));
|
||||||
log.debug("Auto assign check call for tenant {} and device {} finished", getContextAware().getCurrentTenant(),
|
log.debug("Auto assign check call for tenant {} and device {} finished", getContextAware().getCurrentTenant(), controllerId);
|
||||||
controllerId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -27,11 +27,8 @@ public class AutoAssignScheduler {
|
|||||||
private static final String PROP_SCHEDULER_DELAY_PLACEHOLDER = "${hawkbit.autoassign.scheduler.fixedDelay:2000}";
|
private static final String PROP_SCHEDULER_DELAY_PLACEHOLDER = "${hawkbit.autoassign.scheduler.fixedDelay:2000}";
|
||||||
|
|
||||||
private final SystemManagement systemManagement;
|
private final SystemManagement systemManagement;
|
||||||
|
|
||||||
private final SystemSecurityContext systemSecurityContext;
|
private final SystemSecurityContext systemSecurityContext;
|
||||||
|
|
||||||
private final AutoAssignExecutor autoAssignExecutor;
|
private final AutoAssignExecutor autoAssignExecutor;
|
||||||
|
|
||||||
private final LockRegistry lockRegistry;
|
private final LockRegistry lockRegistry;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -52,10 +49,8 @@ public class AutoAssignScheduler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scheduler method called by the spring-async mechanism. Retrieves all
|
* Scheduler method called by the spring-async mechanism. Retrieves all tenants and runs for each
|
||||||
* tenants and runs for each
|
* tenant the auto assignments defined in the target filter queries {@link SystemSecurityContext}.
|
||||||
* tenant the auto assignments defined in the target filter queries
|
|
||||||
* {@link SystemSecurityContext}.
|
|
||||||
*/
|
*/
|
||||||
@Scheduled(initialDelayString = PROP_SCHEDULER_DELAY_PLACEHOLDER, fixedDelayString = PROP_SCHEDULER_DELAY_PLACEHOLDER)
|
@Scheduled(initialDelayString = PROP_SCHEDULER_DELAY_PLACEHOLDER, fixedDelayString = PROP_SCHEDULER_DELAY_PLACEHOLDER)
|
||||||
public void autoAssignScheduler() {
|
public void autoAssignScheduler() {
|
||||||
|
|||||||
@@ -53,15 +53,13 @@ public class AutoActionCleanup implements CleanupTask {
|
|||||||
* @param deploymentMgmt The {@link DeploymentManagement} to operate on.
|
* @param deploymentMgmt The {@link DeploymentManagement} to operate on.
|
||||||
* @param configMgmt The {@link TenantConfigurationManagement} service.
|
* @param configMgmt The {@link TenantConfigurationManagement} service.
|
||||||
*/
|
*/
|
||||||
public AutoActionCleanup(final DeploymentManagement deploymentMgmt,
|
public AutoActionCleanup(final DeploymentManagement deploymentMgmt, final TenantConfigurationManagement configMgmt) {
|
||||||
final TenantConfigurationManagement configMgmt) {
|
|
||||||
this.deploymentMgmt = deploymentMgmt;
|
this.deploymentMgmt = deploymentMgmt;
|
||||||
this.config = configMgmt;
|
this.config = configMgmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
||||||
if (!isEnabled()) {
|
if (!isEnabled()) {
|
||||||
log.debug("Action cleanup is disabled for this tenant...");
|
log.debug("Action cleanup is disabled for this tenant...");
|
||||||
return;
|
return;
|
||||||
@@ -104,5 +102,4 @@ public class AutoActionCleanup implements CleanupTask {
|
|||||||
final Class<T> valueType) {
|
final Class<T> valueType) {
|
||||||
return config.getConfigurationValue(key, valueType);
|
return config.getConfigurationValue(key, valueType);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -34,15 +34,15 @@ public class AutoCleanupScheduler {
|
|||||||
private final List<CleanupTask> cleanupTasks;
|
private final List<CleanupTask> cleanupTasks;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs the cleanup schedulers and initializes it with a set of
|
* Constructs the cleanup schedulers and initializes it with a set of cleanup handlers.
|
||||||
* cleanup handlers.
|
|
||||||
*
|
*
|
||||||
* @param systemManagement Management APIs to invoke actions in a certain tenant context.
|
* @param systemManagement Management APIs to invoke actions in a certain tenant context.
|
||||||
* @param systemSecurityContext The system security context.
|
* @param systemSecurityContext The system security context.
|
||||||
* @param lockRegistry A registry for shared locks.
|
* @param lockRegistry A registry for shared locks.
|
||||||
* @param cleanupTasks A list of cleanup tasks.
|
* @param cleanupTasks A list of cleanup tasks.
|
||||||
*/
|
*/
|
||||||
public AutoCleanupScheduler(final SystemManagement systemManagement,
|
public AutoCleanupScheduler(
|
||||||
|
final SystemManagement systemManagement,
|
||||||
final SystemSecurityContext systemSecurityContext, final LockRegistry lockRegistry,
|
final SystemSecurityContext systemSecurityContext, final LockRegistry lockRegistry,
|
||||||
final List<CleanupTask> cleanupTasks) {
|
final List<CleanupTask> cleanupTasks) {
|
||||||
this.systemManagement = systemManagement;
|
this.systemManagement = systemManagement;
|
||||||
@@ -88,5 +88,4 @@ public class AutoCleanupScheduler {
|
|||||||
private Lock obtainLock(final CleanupTask task, final String tenant) {
|
private Lock obtainLock(final CleanupTask task, final String tenant) {
|
||||||
return lockRegistry.obtain(AUTO_CLEANUP + SEP + task.getId() + SEP + tenant);
|
return lockRegistry.obtain(AUTO_CLEANUP + SEP + task.getId() + SEP + tenant);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -24,5 +24,4 @@ public interface CleanupTask extends Runnable {
|
|||||||
* @return The identifier of this cleanup task. Never null.
|
* @return The identifier of this cleanup task. Never null.
|
||||||
*/
|
*/
|
||||||
String getId();
|
String getId();
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -22,5 +22,4 @@ public class JpaActionStatusBuilder implements ActionStatusBuilder {
|
|||||||
public ActionStatusCreate create(final long actionId) {
|
public ActionStatusCreate create(final long actionId) {
|
||||||
return new JpaActionStatusCreate(actionId);
|
return new JpaActionStatusCreate(actionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -40,5 +40,4 @@ public class JpaDistributionSetBuilder implements DistributionSetBuilder {
|
|||||||
public DistributionSetCreate create() {
|
public DistributionSetCreate create() {
|
||||||
return new JpaDistributionSetCreate(distributionSetTypeManagement, softwareModuleManagement);
|
return new JpaDistributionSetCreate(distributionSetTypeManagement, softwareModuleManagement);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -13,6 +13,7 @@ import java.util.Collection;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
import org.eclipse.hawkbit.repository.DistributionSetTypeManagement;
|
import org.eclipse.hawkbit.repository.DistributionSetTypeManagement;
|
||||||
import org.eclipse.hawkbit.repository.SoftwareModuleManagement;
|
import org.eclipse.hawkbit.repository.SoftwareModuleManagement;
|
||||||
import org.eclipse.hawkbit.repository.ValidString;
|
import org.eclipse.hawkbit.repository.ValidString;
|
||||||
@@ -28,11 +29,11 @@ import org.springframework.util.StringUtils;
|
|||||||
/**
|
/**
|
||||||
* Create/build implementation.
|
* Create/build implementation.
|
||||||
*/
|
*/
|
||||||
public class JpaDistributionSetCreate extends AbstractDistributionSetUpdateCreate<DistributionSetCreate>
|
public class JpaDistributionSetCreate extends AbstractDistributionSetUpdateCreate<DistributionSetCreate> implements DistributionSetCreate {
|
||||||
implements DistributionSetCreate {
|
|
||||||
|
|
||||||
private final DistributionSetTypeManagement distributionSetTypeManagement;
|
private final DistributionSetTypeManagement distributionSetTypeManagement;
|
||||||
private final SoftwareModuleManagement softwareModuleManagement;
|
private final SoftwareModuleManagement softwareModuleManagement;
|
||||||
|
@Getter
|
||||||
@ValidString
|
@ValidString
|
||||||
private String type;
|
private String type;
|
||||||
|
|
||||||
@@ -56,10 +57,6 @@ public class JpaDistributionSetCreate extends AbstractDistributionSetUpdateCreat
|
|||||||
Optional.ofNullable(requiredMigrationStep).orElse(Boolean.FALSE));
|
Optional.ofNullable(requiredMigrationStep).orElse(Boolean.FALSE));
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
private DistributionSetType findDistributionSetTypeWithExceptionIfNotFound(final String distributionSetTypekey) {
|
private DistributionSetType findDistributionSetTypeWithExceptionIfNotFound(final String distributionSetTypekey) {
|
||||||
return distributionSetTypeManagement.getByKey(distributionSetTypekey)
|
return distributionSetTypeManagement.getByKey(distributionSetTypekey)
|
||||||
.orElseThrow(() -> new EntityNotFoundException(DistributionSetType.class, distributionSetTypekey));
|
.orElseThrow(() -> new EntityNotFoundException(DistributionSetType.class, distributionSetTypekey));
|
||||||
@@ -78,5 +75,4 @@ public class JpaDistributionSetCreate extends AbstractDistributionSetUpdateCreat
|
|||||||
|
|
||||||
return module;
|
return module;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -36,5 +36,4 @@ public class JpaDistributionSetTypeBuilder implements DistributionSetTypeBuilder
|
|||||||
public DistributionSetTypeCreate create() {
|
public DistributionSetTypeCreate create() {
|
||||||
return new JpaDistributionSetTypeCreate(softwareModuleTypeManagement);
|
return new JpaDistributionSetTypeCreate(softwareModuleTypeManagement);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -55,5 +55,4 @@ public class JpaDistributionSetTypeCreate extends AbstractDistributionSetTypeUpd
|
|||||||
|
|
||||||
return module;
|
return module;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -36,5 +36,4 @@ public class JpaRolloutBuilder implements RolloutBuilder {
|
|||||||
public RolloutCreate create() {
|
public RolloutCreate create() {
|
||||||
return new JpaRolloutCreate(distributionSetManagement);
|
return new JpaRolloutCreate(distributionSetManagement);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -22,5 +22,4 @@ public class JpaRolloutGroupBuilder implements RolloutGroupBuilder {
|
|||||||
public RolloutGroupCreate create() {
|
public RolloutGroupCreate create() {
|
||||||
return new JpaRolloutGroupCreate();
|
return new JpaRolloutGroupCreate();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -15,8 +15,7 @@ import org.eclipse.hawkbit.repository.jpa.model.JpaRolloutGroup;
|
|||||||
import org.eclipse.hawkbit.repository.model.RolloutGroup;
|
import org.eclipse.hawkbit.repository.model.RolloutGroup;
|
||||||
import org.eclipse.hawkbit.repository.model.RolloutGroupConditions;
|
import org.eclipse.hawkbit.repository.model.RolloutGroupConditions;
|
||||||
|
|
||||||
public class JpaRolloutGroupCreate extends AbstractRolloutGroupCreate<RolloutGroupCreate>
|
public class JpaRolloutGroupCreate extends AbstractRolloutGroupCreate<RolloutGroupCreate> implements RolloutGroupCreate {
|
||||||
implements RolloutGroupCreate {
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the Success And Error conditions for the rollout group
|
* Set the Success And Error conditions for the rollout group
|
||||||
@@ -84,5 +83,4 @@ public class JpaRolloutGroupCreate extends AbstractRolloutGroupCreate<RolloutGro
|
|||||||
|
|
||||||
return group;
|
return group;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -36,5 +36,4 @@ public class JpaSoftwareModuleBuilder implements SoftwareModuleBuilder {
|
|||||||
public SoftwareModuleCreate create() {
|
public SoftwareModuleCreate create() {
|
||||||
return new JpaSoftwareModuleCreate(softwareModuleTypeManagement);
|
return new JpaSoftwareModuleCreate(softwareModuleTypeManagement);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -21,11 +21,9 @@ import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
|||||||
/**
|
/**
|
||||||
* Create/build implementation.
|
* Create/build implementation.
|
||||||
*/
|
*/
|
||||||
public class JpaSoftwareModuleCreate extends AbstractSoftwareModuleUpdateCreate<SoftwareModuleCreate>
|
public class JpaSoftwareModuleCreate extends AbstractSoftwareModuleUpdateCreate<SoftwareModuleCreate> implements SoftwareModuleCreate {
|
||||||
implements SoftwareModuleCreate {
|
|
||||||
|
|
||||||
private final SoftwareModuleTypeManagement softwareModuleTypeManagement;
|
private final SoftwareModuleTypeManagement softwareModuleTypeManagement;
|
||||||
|
|
||||||
private boolean encrypted;
|
private boolean encrypted;
|
||||||
|
|
||||||
JpaSoftwareModuleCreate(final SoftwareModuleTypeManagement softwareModuleTypeManagement) {
|
JpaSoftwareModuleCreate(final SoftwareModuleTypeManagement softwareModuleTypeManagement) {
|
||||||
|
|||||||
@@ -36,5 +36,4 @@ public class JpaSoftwareModuleMetadataBuilder implements SoftwareModuleMetadataB
|
|||||||
public SoftwareModuleMetadataCreate create(final long softwareModuleId) {
|
public SoftwareModuleMetadataCreate create(final long softwareModuleId) {
|
||||||
return new JpaSoftwareModuleMetadataCreate(softwareModuleId, softwareModuleManagement);
|
return new JpaSoftwareModuleMetadataCreate(softwareModuleId, softwareModuleManagement);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -25,8 +25,7 @@ public class JpaSoftwareModuleMetadataCreate
|
|||||||
|
|
||||||
private final SoftwareModuleManagement softwareModuleManagement;
|
private final SoftwareModuleManagement softwareModuleManagement;
|
||||||
|
|
||||||
JpaSoftwareModuleMetadataCreate(final long softwareModuleId,
|
JpaSoftwareModuleMetadataCreate(final long softwareModuleId, final SoftwareModuleManagement softwareModuleManagement) {
|
||||||
final SoftwareModuleManagement softwareModuleManagement) {
|
|
||||||
this.softwareModuleManagement = softwareModuleManagement;
|
this.softwareModuleManagement = softwareModuleManagement;
|
||||||
this.softwareModuleId = softwareModuleId;
|
this.softwareModuleId = softwareModuleId;
|
||||||
}
|
}
|
||||||
@@ -42,5 +41,4 @@ public class JpaSoftwareModuleMetadataCreate
|
|||||||
|
|
||||||
return new JpaSoftwareModuleMetadata(key, module, value, isTargetVisible().orElse(false));
|
return new JpaSoftwareModuleMetadata(key, module, value, isTargetVisible().orElse(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -29,5 +29,4 @@ public class JpaSoftwareModuleTypeBuilder implements SoftwareModuleTypeBuilder {
|
|||||||
public SoftwareModuleTypeCreate create() {
|
public SoftwareModuleTypeCreate create() {
|
||||||
return new JpaSoftwareModuleTypeCreate();
|
return new JpaSoftwareModuleTypeCreate();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -9,6 +9,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.repository.jpa.builder;
|
package org.eclipse.hawkbit.repository.jpa.builder;
|
||||||
|
|
||||||
|
import lombok.AccessLevel;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
import org.eclipse.hawkbit.repository.builder.AbstractSoftwareModuleTypeUpdateCreate;
|
import org.eclipse.hawkbit.repository.builder.AbstractSoftwareModuleTypeUpdateCreate;
|
||||||
import org.eclipse.hawkbit.repository.builder.SoftwareModuleTypeCreate;
|
import org.eclipse.hawkbit.repository.builder.SoftwareModuleTypeCreate;
|
||||||
import org.eclipse.hawkbit.repository.jpa.model.JpaSoftwareModuleType;
|
import org.eclipse.hawkbit.repository.jpa.model.JpaSoftwareModuleType;
|
||||||
@@ -16,13 +18,10 @@ import org.eclipse.hawkbit.repository.jpa.model.JpaSoftwareModuleType;
|
|||||||
/**
|
/**
|
||||||
* Create/build implementation.
|
* Create/build implementation.
|
||||||
*/
|
*/
|
||||||
|
@NoArgsConstructor(access = AccessLevel.PACKAGE)
|
||||||
public class JpaSoftwareModuleTypeCreate extends AbstractSoftwareModuleTypeUpdateCreate<SoftwareModuleTypeCreate>
|
public class JpaSoftwareModuleTypeCreate extends AbstractSoftwareModuleTypeUpdateCreate<SoftwareModuleTypeCreate>
|
||||||
implements SoftwareModuleTypeCreate {
|
implements SoftwareModuleTypeCreate {
|
||||||
|
|
||||||
JpaSoftwareModuleTypeCreate() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JpaSoftwareModuleType build() {
|
public JpaSoftwareModuleType build() {
|
||||||
return new JpaSoftwareModuleType(key, name, description, maxAssignments, colour);
|
return new JpaSoftwareModuleType(key, name, description, maxAssignments, colour);
|
||||||
|
|||||||
@@ -29,5 +29,4 @@ public class JpaTagBuilder implements TagBuilder {
|
|||||||
public TagCreate create() {
|
public TagCreate create() {
|
||||||
return new JpaTagCreate();
|
return new JpaTagCreate();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -9,6 +9,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.repository.jpa.builder;
|
package org.eclipse.hawkbit.repository.jpa.builder;
|
||||||
|
|
||||||
|
import lombok.AccessLevel;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
import org.eclipse.hawkbit.repository.builder.AbstractTagUpdateCreate;
|
import org.eclipse.hawkbit.repository.builder.AbstractTagUpdateCreate;
|
||||||
import org.eclipse.hawkbit.repository.builder.TagCreate;
|
import org.eclipse.hawkbit.repository.builder.TagCreate;
|
||||||
import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSetTag;
|
import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSetTag;
|
||||||
@@ -19,12 +21,9 @@ import org.eclipse.hawkbit.repository.model.Tag;
|
|||||||
/**
|
/**
|
||||||
* Create/build implementation.
|
* Create/build implementation.
|
||||||
*/
|
*/
|
||||||
|
@NoArgsConstructor(access = AccessLevel.PACKAGE)
|
||||||
public class JpaTagCreate extends AbstractTagUpdateCreate<TagCreate> implements TagCreate {
|
public class JpaTagCreate extends AbstractTagUpdateCreate<TagCreate> implements TagCreate {
|
||||||
|
|
||||||
JpaTagCreate() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public JpaDistributionSetTag buildDistributionSetTag() {
|
public JpaDistributionSetTag buildDistributionSetTag() {
|
||||||
return new JpaDistributionSetTag(name, description, colour);
|
return new JpaDistributionSetTag(name, description, colour);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import org.eclipse.hawkbit.repository.model.Target;
|
|||||||
*/
|
*/
|
||||||
public class JpaTargetBuilder implements TargetBuilder {
|
public class JpaTargetBuilder implements TargetBuilder {
|
||||||
|
|
||||||
final private TargetTypeManagement targetTypeManagement;
|
private final TargetTypeManagement targetTypeManagement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param targetTypeManagement Target type management
|
* @param targetTypeManagement Target type management
|
||||||
@@ -38,5 +38,4 @@ public class JpaTargetBuilder implements TargetBuilder {
|
|||||||
public TargetCreate create() {
|
public TargetCreate create() {
|
||||||
return new JpaTargetCreate(targetTypeManagement);
|
return new JpaTargetCreate(targetTypeManagement);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -16,7 +16,7 @@ import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
|||||||
import org.eclipse.hawkbit.repository.jpa.model.JpaTarget;
|
import org.eclipse.hawkbit.repository.jpa.model.JpaTarget;
|
||||||
import org.eclipse.hawkbit.repository.model.TargetType;
|
import org.eclipse.hawkbit.repository.model.TargetType;
|
||||||
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
|
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.ObjectUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create/build implementation.
|
* Create/build implementation.
|
||||||
@@ -37,20 +37,19 @@ public class JpaTargetCreate extends AbstractTargetUpdateCreate<TargetCreate> im
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JpaTarget build() {
|
public JpaTarget build() {
|
||||||
JpaTarget target;
|
final JpaTarget target;
|
||||||
|
if (ObjectUtils.isEmpty(securityToken)) {
|
||||||
if (StringUtils.isEmpty(securityToken)) {
|
|
||||||
target = new JpaTarget(controllerId);
|
target = new JpaTarget(controllerId);
|
||||||
} else {
|
} else {
|
||||||
target = new JpaTarget(controllerId, securityToken);
|
target = new JpaTarget(controllerId, securityToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!StringUtils.isEmpty(name)) {
|
if (!ObjectUtils.isEmpty(name)) {
|
||||||
target.setName(name);
|
target.setName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (targetTypeId != null) {
|
if (targetTypeId != null) {
|
||||||
TargetType targetType = targetTypeManagement.get(targetTypeId)
|
final TargetType targetType = targetTypeManagement.get(targetTypeId)
|
||||||
.orElseThrow(() -> new EntityNotFoundException(TargetType.class, targetTypeId));
|
.orElseThrow(() -> new EntityNotFoundException(TargetType.class, targetTypeId));
|
||||||
target.setTargetType(targetType);
|
target.setTargetType(targetType);
|
||||||
}
|
}
|
||||||
@@ -62,5 +61,4 @@ public class JpaTargetCreate extends AbstractTargetUpdateCreate<TargetCreate> im
|
|||||||
|
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -42,5 +42,4 @@ public class JpaTargetFilterQueryBuilder implements TargetFilterQueryBuilder {
|
|||||||
public TargetFilterQueryCreate create() {
|
public TargetFilterQueryCreate create() {
|
||||||
return new JpaTargetFilterQueryCreate(distributionSetManagement);
|
return new JpaTargetFilterQueryCreate(distributionSetManagement);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -44,5 +44,4 @@ public class JpaTargetFilterQueryCreate extends AbstractTargetFilterQueryUpdateC
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -25,8 +25,7 @@ import org.springframework.util.CollectionUtils;
|
|||||||
/**
|
/**
|
||||||
* Create/build implementation.
|
* Create/build implementation.
|
||||||
*/
|
*/
|
||||||
public class JpaTargetTypeCreate extends AbstractTargetTypeUpdateCreate<TargetTypeCreate>
|
public class JpaTargetTypeCreate extends AbstractTargetTypeUpdateCreate<TargetTypeCreate> implements TargetTypeCreate {
|
||||||
implements TargetTypeCreate {
|
|
||||||
|
|
||||||
private final DistributionSetTypeManagement distributionSetTypeManagement;
|
private final DistributionSetTypeManagement distributionSetTypeManagement;
|
||||||
|
|
||||||
|
|||||||
@@ -17,5 +17,4 @@ public class JpaTargetUpdate extends AbstractTargetUpdateCreate<TargetUpdate> im
|
|||||||
JpaTargetUpdate(final String controllerId) {
|
JpaTargetUpdate(final String controllerId) {
|
||||||
super(controllerId);
|
super(controllerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -21,8 +21,7 @@ import org.springframework.transaction.support.TransactionSynchronizationManager
|
|||||||
* successful spring transaction commit.The class is thread safe.
|
* successful spring transaction commit.The class is thread safe.
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class AfterTransactionCommitDefaultServiceExecutor extends TransactionSynchronizationAdapter
|
public class AfterTransactionCommitDefaultServiceExecutor extends TransactionSynchronizationAdapter implements AfterTransactionCommitExecutor {
|
||||||
implements AfterTransactionCommitExecutor {
|
|
||||||
|
|
||||||
private static final ThreadLocal<List<Runnable>> THREAD_LOCAL_RUNNABLES = new ThreadLocal<>();
|
private static final ThreadLocal<List<Runnable>> THREAD_LOCAL_RUNNABLES = new ThreadLocal<>();
|
||||||
|
|
||||||
@@ -69,5 +68,4 @@ public class AfterTransactionCommitDefaultServiceExecutor extends TransactionSyn
|
|||||||
|
|
||||||
runnable.run();
|
runnable.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -67,7 +67,8 @@ public abstract class AbstractDsAssignmentStrategy {
|
|||||||
private final BooleanSupplier confirmationFlowConfig;
|
private final BooleanSupplier confirmationFlowConfig;
|
||||||
private final RepositoryProperties repositoryProperties;
|
private final RepositoryProperties repositoryProperties;
|
||||||
|
|
||||||
AbstractDsAssignmentStrategy(final TargetRepository targetRepository,
|
AbstractDsAssignmentStrategy(
|
||||||
|
final TargetRepository targetRepository,
|
||||||
final AfterTransactionCommitExecutor afterCommit, final EventPublisherHolder eventPublisherHolder,
|
final AfterTransactionCommitExecutor afterCommit, final EventPublisherHolder eventPublisherHolder,
|
||||||
final ActionRepository actionRepository, final ActionStatusRepository actionStatusRepository,
|
final ActionRepository actionRepository, final ActionStatusRepository actionStatusRepository,
|
||||||
final QuotaManagement quotaManagement, final BooleanSupplier multiAssignmentsConfig,
|
final QuotaManagement quotaManagement, final BooleanSupplier multiAssignmentsConfig,
|
||||||
@@ -83,7 +84,8 @@ public abstract class AbstractDsAssignmentStrategy {
|
|||||||
this.repositoryProperties = repositoryProperties;
|
this.repositoryProperties = repositoryProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
public JpaAction createTargetAction(final String initiatedBy, final TargetWithActionType targetWithActionType,
|
public JpaAction createTargetAction(
|
||||||
|
final String initiatedBy, final TargetWithActionType targetWithActionType,
|
||||||
final List<JpaTarget> targets, final JpaDistributionSet set) {
|
final List<JpaTarget> targets, final JpaDistributionSet set) {
|
||||||
final Optional<JpaTarget> optTarget = targets.stream()
|
final Optional<JpaTarget> optTarget = targets.stream()
|
||||||
.filter(t -> t.getControllerId().equals(targetWithActionType.getControllerId())).findFirst();
|
.filter(t -> t.getControllerId().equals(targetWithActionType.getControllerId())).findFirst();
|
||||||
@@ -95,8 +97,9 @@ public abstract class AbstractDsAssignmentStrategy {
|
|||||||
actionForTarget.setActionType(targetWithActionType.getActionType());
|
actionForTarget.setActionType(targetWithActionType.getActionType());
|
||||||
actionForTarget.setForcedTime(targetWithActionType.getForceTime());
|
actionForTarget.setForcedTime(targetWithActionType.getForceTime());
|
||||||
actionForTarget.setWeight(
|
actionForTarget.setWeight(
|
||||||
targetWithActionType.getWeight() == null ?
|
targetWithActionType.getWeight() == null
|
||||||
repositoryProperties.getActionWeightIfAbsent() : targetWithActionType.getWeight());
|
? repositoryProperties.getActionWeightIfAbsent()
|
||||||
|
: targetWithActionType.getWeight());
|
||||||
actionForTarget.setActive(true);
|
actionForTarget.setActive(true);
|
||||||
actionForTarget.setTarget(target);
|
actionForTarget.setTarget(target);
|
||||||
actionForTarget.setDistributionSet(set);
|
actionForTarget.setDistributionSet(set);
|
||||||
@@ -294,7 +297,6 @@ public abstract class AbstractDsAssignmentStrategy {
|
|||||||
|
|
||||||
private void assertActionsPerTargetQuota(final Target target, final int requested) {
|
private void assertActionsPerTargetQuota(final Target target, final int requested) {
|
||||||
final int quota = quotaManagement.getMaxActionsPerTarget();
|
final int quota = quotaManagement.getMaxActionsPerTarget();
|
||||||
QuotaHelper.assertAssignmentQuota(target.getId(), requested, quota, Action.class, Target.class,
|
QuotaHelper.assertAssignmentQuota(target.getId(), requested, quota, Action.class, Target.class, actionRepository::countByTargetId);
|
||||||
actionRepository::countByTargetId);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -47,7 +47,8 @@ public class JpaActionManagement {
|
|||||||
protected final QuotaManagement quotaManagement;
|
protected final QuotaManagement quotaManagement;
|
||||||
protected final RepositoryProperties repositoryProperties;
|
protected final RepositoryProperties repositoryProperties;
|
||||||
|
|
||||||
public JpaActionManagement(final ActionRepository actionRepository,
|
public JpaActionManagement(
|
||||||
|
final ActionRepository actionRepository,
|
||||||
final ActionStatusRepository actionStatusRepository, final QuotaManagement quotaManagement,
|
final ActionStatusRepository actionStatusRepository, final QuotaManagement quotaManagement,
|
||||||
final RepositoryProperties repositoryProperties) {
|
final RepositoryProperties repositoryProperties) {
|
||||||
this.actionRepository = actionRepository;
|
this.actionRepository = actionRepository;
|
||||||
|
|||||||
@@ -70,19 +70,15 @@ import org.springframework.validation.annotation.Validated;
|
|||||||
public class JpaArtifactManagement implements ArtifactManagement {
|
public class JpaArtifactManagement implements ArtifactManagement {
|
||||||
|
|
||||||
private final EntityManager entityManager;
|
private final EntityManager entityManager;
|
||||||
|
|
||||||
private final LocalArtifactRepository localArtifactRepository;
|
private final LocalArtifactRepository localArtifactRepository;
|
||||||
|
|
||||||
private final SoftwareModuleRepository softwareModuleRepository;
|
private final SoftwareModuleRepository softwareModuleRepository;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private final ArtifactRepository artifactRepository;
|
private final ArtifactRepository artifactRepository;
|
||||||
|
|
||||||
private final TenantAware tenantAware;
|
private final TenantAware tenantAware;
|
||||||
|
|
||||||
private final QuotaManagement quotaManagement;
|
private final QuotaManagement quotaManagement;
|
||||||
|
|
||||||
public JpaArtifactManagement(final EntityManager entityManager,
|
public JpaArtifactManagement(
|
||||||
|
final EntityManager entityManager,
|
||||||
final LocalArtifactRepository localArtifactRepository,
|
final LocalArtifactRepository localArtifactRepository,
|
||||||
final SoftwareModuleRepository softwareModuleRepository, @Nullable final ArtifactRepository artifactRepository,
|
final SoftwareModuleRepository softwareModuleRepository, @Nullable final ArtifactRepository artifactRepository,
|
||||||
final QuotaManagement quotaManagement, final TenantAware tenantAware) {
|
final QuotaManagement quotaManagement, final TenantAware tenantAware) {
|
||||||
@@ -101,8 +97,8 @@ public class JpaArtifactManagement implements ArtifactManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public Artifact create(final ArtifactUpload artifactUpload) {
|
public Artifact create(final ArtifactUpload artifactUpload) {
|
||||||
assertArtifactRepositoryAvailable();
|
assertArtifactRepositoryAvailable();
|
||||||
|
|
||||||
@@ -138,8 +134,8 @@ public class JpaArtifactManagement implements ArtifactManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public void delete(final long id) {
|
public void delete(final long id) {
|
||||||
final JpaArtifact toDelete = (JpaArtifact) get(id)
|
final JpaArtifact toDelete = (JpaArtifact) get(id)
|
||||||
.orElseThrow(() -> new EntityNotFoundException(Artifact.class, id));
|
.orElseThrow(() -> new EntityNotFoundException(Artifact.class, id));
|
||||||
|
|||||||
@@ -61,10 +61,8 @@ public class JpaConfirmationManagement extends JpaActionManagement implements Co
|
|||||||
private final EntityFactory entityFactory;
|
private final EntityFactory entityFactory;
|
||||||
private final TargetRepository targetRepository;
|
private final TargetRepository targetRepository;
|
||||||
|
|
||||||
/**
|
public JpaConfirmationManagement(
|
||||||
* Constructor
|
final TargetRepository targetRepository,
|
||||||
*/
|
|
||||||
public JpaConfirmationManagement(final TargetRepository targetRepository,
|
|
||||||
final ActionRepository actionRepository, final ActionStatusRepository actionStatusRepository,
|
final ActionRepository actionRepository, final ActionStatusRepository actionStatusRepository,
|
||||||
final RepositoryProperties repositoryProperties, final QuotaManagement quotaManagement,
|
final RepositoryProperties repositoryProperties, final QuotaManagement quotaManagement,
|
||||||
final EntityFactory entityFactory) {
|
final EntityFactory entityFactory) {
|
||||||
@@ -80,14 +78,12 @@ public class JpaConfirmationManagement extends JpaActionManagement implements Co
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public AutoConfirmationStatus activateAutoConfirmation(final String controllerId, final String initiator,
|
public AutoConfirmationStatus activateAutoConfirmation(final String controllerId, final String initiator, final String remark) {
|
||||||
final String remark) {
|
log.trace(
|
||||||
log.trace("'activateAutoConfirmation' was called with values: controllerId={}; initiator={}; remark={}",
|
"'activateAutoConfirmation' was called with values: controllerId={}; initiator={}; remark={}", controllerId, initiator, remark);
|
||||||
controllerId, initiator, remark);
|
|
||||||
final JpaTarget target = getTargetByControllerIdAndThrowIfNotFound(controllerId);
|
final JpaTarget target = getTargetByControllerIdAndThrowIfNotFound(controllerId);
|
||||||
if (target.getAutoConfirmationStatus() != null) {
|
if (target.getAutoConfirmationStatus() != null) {
|
||||||
log.debug("'activateAutoConfirmation' was called for an controller id {} with active auto confirmation.",
|
log.debug("'activateAutoConfirmation' was called for an controller id {} with active auto confirmation.", controllerId);
|
||||||
controllerId);
|
|
||||||
throw new AutoConfirmationAlreadyActiveException(controllerId);
|
throw new AutoConfirmationAlreadyActiveException(controllerId);
|
||||||
}
|
}
|
||||||
final JpaAutoConfirmationStatus confirmationStatus = new JpaAutoConfirmationStatus(initiator, remark, target);
|
final JpaAutoConfirmationStatus confirmationStatus = new JpaAutoConfirmationStatus(initiator, remark, target);
|
||||||
@@ -95,8 +91,9 @@ public class JpaConfirmationManagement extends JpaActionManagement implements Co
|
|||||||
final JpaTarget updatedTarget = targetRepository.save(target);
|
final JpaTarget updatedTarget = targetRepository.save(target);
|
||||||
final AutoConfirmationStatus autoConfStatus = updatedTarget.getAutoConfirmationStatus();
|
final AutoConfirmationStatus autoConfStatus = updatedTarget.getAutoConfirmationStatus();
|
||||||
if (autoConfStatus == null) {
|
if (autoConfStatus == null) {
|
||||||
final String message = String.format("Persisted auto confirmation status is null. "
|
final String message = String.format(
|
||||||
+ "Cannot proceed with giving confirmations for active actions for device %s with initiator %s.",
|
"Persisted auto confirmation status is null. " +
|
||||||
|
"Cannot proceed with giving confirmations for active actions for device %s with initiator %s.",
|
||||||
controllerId, initiator);
|
controllerId, initiator);
|
||||||
log.error("message");
|
log.error("message");
|
||||||
throw new IllegalStateException(message);
|
throw new IllegalStateException(message);
|
||||||
@@ -123,8 +120,8 @@ public class JpaConfirmationManagement extends JpaActionManagement implements Co
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(isolation = Isolation.READ_COMMITTED)
|
@Transactional(isolation = Isolation.READ_COMMITTED)
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public Action confirmAction(final long actionId, final Integer code, final Collection<String> deviceMessages) {
|
public Action confirmAction(final long actionId, final Integer code, final Collection<String> deviceMessages) {
|
||||||
log.trace("Action with id {} confirm request is triggered.", actionId);
|
log.trace("Action with id {} confirm request is triggered.", actionId);
|
||||||
final Action action = getActionAndThrowExceptionIfNotFound(actionId);
|
final Action action = getActionAndThrowExceptionIfNotFound(actionId);
|
||||||
@@ -142,8 +139,8 @@ public class JpaConfirmationManagement extends JpaActionManagement implements Co
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(isolation = Isolation.READ_COMMITTED)
|
@Transactional(isolation = Isolation.READ_COMMITTED)
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public Action denyAction(final long actionId, final Integer code, final Collection<String> deviceMessages) {
|
public Action denyAction(final long actionId, final Integer code, final Collection<String> deviceMessages) {
|
||||||
log.trace("Action with id {} deny request is triggered.", actionId);
|
log.trace("Action with id {} deny request is triggered.", actionId);
|
||||||
final Action action = getActionAndThrowExceptionIfNotFound(actionId);
|
final Action action = getActionAndThrowExceptionIfNotFound(actionId);
|
||||||
@@ -152,8 +149,7 @@ public class JpaConfirmationManagement extends JpaActionManagement implements Co
|
|||||||
if (deviceMessages != null) {
|
if (deviceMessages != null) {
|
||||||
messages.addAll(deviceMessages);
|
messages.addAll(deviceMessages);
|
||||||
}
|
}
|
||||||
messages.add(RepositoryConstants.SERVER_MESSAGE_PREFIX + "Target rejected action."
|
messages.add(RepositoryConstants.SERVER_MESSAGE_PREFIX + "Target rejected action. Action will stay in confirmation pending state.");
|
||||||
+ " Action will stay in confirmation pending state.");
|
|
||||||
final ActionStatusCreate statusCreate = createConfirmationActionStatus(action.getId(), code, messages)
|
final ActionStatusCreate statusCreate = createConfirmationActionStatus(action.getId(), code, messages)
|
||||||
.status(Status.WAIT_FOR_CONFIRMATION);
|
.status(Status.WAIT_FOR_CONFIRMATION);
|
||||||
return addActionStatus((JpaActionStatusCreate) statusCreate);
|
return addActionStatus((JpaActionStatusCreate) statusCreate);
|
||||||
@@ -191,8 +187,7 @@ public class JpaConfirmationManagement extends JpaActionManagement implements Co
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ActionStatusCreate createConfirmationActionStatus(final long actionId, final Integer code,
|
private ActionStatusCreate createConfirmationActionStatus(final long actionId, final Integer code, final Collection<String> messages) {
|
||||||
final Collection<String> messages) {
|
|
||||||
final ActionStatusCreate statusCreate = entityFactory.actionStatus().create(actionId);
|
final ActionStatusCreate statusCreate = entityFactory.actionStatus().create(actionId);
|
||||||
if (!CollectionUtils.isEmpty(messages)) {
|
if (!CollectionUtils.isEmpty(messages)) {
|
||||||
statusCreate.messages(messages);
|
statusCreate.messages(messages);
|
||||||
@@ -207,25 +202,27 @@ public class JpaConfirmationManagement extends JpaActionManagement implements Co
|
|||||||
private List<Action> giveConfirmationForActiveActions(final AutoConfirmationStatus autoConfirmationStatus) {
|
private List<Action> giveConfirmationForActiveActions(final AutoConfirmationStatus autoConfirmationStatus) {
|
||||||
final Target target = autoConfirmationStatus.getTarget();
|
final Target target = autoConfirmationStatus.getTarget();
|
||||||
return findActiveActionsHavingStatus(target.getControllerId(), Status.WAIT_FOR_CONFIRMATION).stream()
|
return findActiveActionsHavingStatus(target.getControllerId(), Status.WAIT_FOR_CONFIRMATION).stream()
|
||||||
.map(action -> autoConfirmAction(action, autoConfirmationStatus)).collect(Collectors.toList());
|
.map(action -> autoConfirmAction(action, autoConfirmationStatus))
|
||||||
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
private Action autoConfirmAction(final JpaAction action, final AutoConfirmationStatus autoConfirmationStatus) {
|
private Action autoConfirmAction(final JpaAction action, final AutoConfirmationStatus autoConfirmationStatus) {
|
||||||
if (!action.isWaitingConfirmation()) {
|
if (!action.isWaitingConfirmation()) {
|
||||||
log.debug("Auto-confirming action is not necessary, since action {} is in RUNNING state already.",
|
log.debug("Auto-confirming action is not necessary, since action {} is in RUNNING state already.", action.getId());
|
||||||
action.getId());
|
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
final JpaActionStatus actionStatus = (JpaActionStatus) entityFactory.actionStatus().create(action.getId())
|
final JpaActionStatus actionStatus = (JpaActionStatus) entityFactory.actionStatus()
|
||||||
|
.create(action.getId())
|
||||||
.status(Status.RUNNING)
|
.status(Status.RUNNING)
|
||||||
.messages(Collections.singletonList(autoConfirmationStatus.constructActionMessage())).build();
|
.messages(Collections.singletonList(autoConfirmationStatus.constructActionMessage()))
|
||||||
|
.build();
|
||||||
log.debug(
|
log.debug(
|
||||||
"Automatically confirm actionId '{}' due to active auto-confirmation initiated by '{}' and rollouts system user '{}'",
|
"Automatically confirm actionId '{}' due to active auto-confirmation initiated by '{}' and rollouts system user '{}'",
|
||||||
action.getId(), autoConfirmationStatus.getInitiator(), autoConfirmationStatus.getCreatedBy());
|
action.getId(), autoConfirmationStatus.getInitiator(), autoConfirmationStatus.getCreatedBy());
|
||||||
|
|
||||||
// do not make use of
|
// do not make use of
|
||||||
// org.eclipse.hawkbit.repository.jpa.management.JpaActionManagement.handleAddUpdateActionStatus
|
// org.eclipse.hawkbit.repository.jpa.management.JpaActionManagement.handleAddUpdateActionStatus
|
||||||
// to bypass the quota check. Otherwise the action will not be confirmed in case
|
// to bypass the quota check. Otherwise, the action will not be confirmed in case
|
||||||
// of exceeded action status quota.
|
// of exceeded action status quota.
|
||||||
action.setStatus(Status.RUNNING);
|
action.setStatus(Status.RUNNING);
|
||||||
actionStatus.setAction(action);
|
actionStatus.setAction(action);
|
||||||
|
|||||||
@@ -127,46 +127,32 @@ public class JpaControllerManagement extends JpaActionManagement implements Cont
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private EntityManager entityManager;
|
private EntityManager entityManager;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private TargetRepository targetRepository;
|
private TargetRepository targetRepository;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SoftwareModuleRepository softwareModuleRepository;
|
private SoftwareModuleRepository softwareModuleRepository;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private TenantConfigurationManagement tenantConfigurationManagement;
|
private TenantConfigurationManagement tenantConfigurationManagement;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SystemSecurityContext systemSecurityContext;
|
private SystemSecurityContext systemSecurityContext;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private EntityFactory entityFactory;
|
private EntityFactory entityFactory;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private EventPublisherHolder eventPublisherHolder;
|
private EventPublisherHolder eventPublisherHolder;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private AfterTransactionCommitExecutor afterCommit;
|
private AfterTransactionCommitExecutor afterCommit;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SoftwareModuleMetadataRepository softwareModuleMetadataRepository;
|
private SoftwareModuleMetadataRepository softwareModuleMetadataRepository;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private PlatformTransactionManager txManager;
|
private PlatformTransactionManager txManager;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private TenantAware tenantAware;
|
private TenantAware tenantAware;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ConfirmationManagement confirmationManagement;
|
private ConfirmationManagement confirmationManagement;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private TargetTypeManagement targetTypeManagement;
|
private TargetTypeManagement targetTypeManagement;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private DeploymentManagement deploymentManagement;
|
private DeploymentManagement deploymentManagement;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private DistributionSetManagement distributionSetManagement;
|
private DistributionSetManagement distributionSetManagement;
|
||||||
|
|
||||||
@@ -179,7 +165,6 @@ public class JpaControllerManagement extends JpaActionManagement implements Cont
|
|||||||
executorService.scheduleWithFixedDelay(this::flushUpdateQueue,
|
executorService.scheduleWithFixedDelay(this::flushUpdateQueue,
|
||||||
repositoryProperties.getPollPersistenceFlushTime(),
|
repositoryProperties.getPollPersistenceFlushTime(),
|
||||||
repositoryProperties.getPollPersistenceFlushTime(), TimeUnit.MILLISECONDS);
|
repositoryProperties.getPollPersistenceFlushTime(), TimeUnit.MILLISECONDS);
|
||||||
|
|
||||||
queue = new LinkedBlockingDeque<>(repositoryProperties.getPollPersistenceQueueSize());
|
queue = new LinkedBlockingDeque<>(repositoryProperties.getPollPersistenceQueueSize());
|
||||||
} else {
|
} else {
|
||||||
queue = null;
|
queue = null;
|
||||||
@@ -194,26 +179,30 @@ public class JpaControllerManagement extends JpaActionManagement implements Cont
|
|||||||
@Override
|
@Override
|
||||||
protected void onActionStatusUpdate(final Action.Status updatedActionStatus, final JpaAction action) {
|
protected void onActionStatusUpdate(final Action.Status updatedActionStatus, final JpaAction action) {
|
||||||
switch (updatedActionStatus) {
|
switch (updatedActionStatus) {
|
||||||
case ERROR:
|
case ERROR: {
|
||||||
final JpaTarget target = (JpaTarget) action.getTarget();
|
final JpaTarget target = (JpaTarget) action.getTarget();
|
||||||
target.setUpdateStatus(TargetUpdateStatus.ERROR);
|
target.setUpdateStatus(TargetUpdateStatus.ERROR);
|
||||||
handleErrorOnAction(action, target);
|
handleErrorOnAction(action, target);
|
||||||
break;
|
break;
|
||||||
case FINISHED:
|
}
|
||||||
|
case FINISHED: {
|
||||||
handleFinishedAndStoreInTargetStatus(action).ifPresent(this::requestControllerAttributes);
|
handleFinishedAndStoreInTargetStatus(action).ifPresent(this::requestControllerAttributes);
|
||||||
break;
|
break;
|
||||||
case DOWNLOADED:
|
}
|
||||||
|
case DOWNLOADED: {
|
||||||
handleDownloadedActionStatus(action).ifPresent(this::requestControllerAttributes);
|
handleDownloadedActionStatus(action).ifPresent(this::requestControllerAttributes);
|
||||||
break;
|
break;
|
||||||
default:
|
}
|
||||||
|
default: {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(isolation = Isolation.READ_COMMITTED)
|
@Transactional(isolation = Isolation.READ_COMMITTED)
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public Action addCancelActionStatus(final ActionStatusCreate c) {
|
public Action addCancelActionStatus(final ActionStatusCreate c) {
|
||||||
final JpaActionStatusCreate create = (JpaActionStatusCreate) c;
|
final JpaActionStatusCreate create = (JpaActionStatusCreate) c;
|
||||||
|
|
||||||
@@ -227,19 +216,22 @@ public class JpaControllerManagement extends JpaActionManagement implements Cont
|
|||||||
|
|
||||||
switch (actionStatus.getStatus()) {
|
switch (actionStatus.getStatus()) {
|
||||||
case CANCELED:
|
case CANCELED:
|
||||||
case FINISHED:
|
case FINISHED: {
|
||||||
handleFinishedCancelation(actionStatus, action);
|
handleFinishedCancelation(actionStatus, action);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case ERROR:
|
case ERROR:
|
||||||
case CANCEL_REJECTED:
|
case CANCEL_REJECTED: {
|
||||||
// Cancellation rejected. Back to running.
|
// Cancellation rejected. Back to running.
|
||||||
action.setStatus(Status.RUNNING);
|
action.setStatus(Status.RUNNING);
|
||||||
break;
|
break;
|
||||||
default:
|
}
|
||||||
|
default: {
|
||||||
// information status entry - check for a potential DOS attack
|
// information status entry - check for a potential DOS attack
|
||||||
assertActionStatusQuota(actionStatus, action);
|
assertActionStatusQuota(actionStatus, action);
|
||||||
assertActionStatusMessageQuota(actionStatus);
|
assertActionStatusMessageQuota(actionStatus);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
actionStatus.setAction(actionRepository.save(action));
|
actionStatus.setAction(actionRepository.save(action));
|
||||||
@@ -250,24 +242,22 @@ public class JpaControllerManagement extends JpaActionManagement implements Cont
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<SoftwareModule> getSoftwareModule(final long id) {
|
public Optional<SoftwareModule> getSoftwareModule(final long id) {
|
||||||
return softwareModuleRepository.findById(id).map(s -> (SoftwareModule) s);
|
return softwareModuleRepository.findById(id).map(SoftwareModule.class::cast);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<Long, List<SoftwareModuleMetadata>> findTargetVisibleMetaDataBySoftwareModuleId(
|
public Map<Long, List<SoftwareModuleMetadata>> findTargetVisibleMetaDataBySoftwareModuleId(final Collection<Long> moduleId) {
|
||||||
final Collection<Long> moduleId) {
|
|
||||||
|
|
||||||
return softwareModuleMetadataRepository
|
return softwareModuleMetadataRepository
|
||||||
.findBySoftwareModuleIdInAndTargetVisible(PageRequest.of(0, RepositoryConstants.MAX_META_DATA_COUNT),
|
.findBySoftwareModuleIdInAndTargetVisible(
|
||||||
moduleId, true)
|
PageRequest.of(0, RepositoryConstants.MAX_META_DATA_COUNT), moduleId, true)
|
||||||
.getContent().stream().collect(Collectors.groupingBy(o -> (Long) o[0],
|
.getContent().stream()
|
||||||
Collectors.mapping(o -> (SoftwareModuleMetadata) o[1], Collectors.toList())));
|
.collect(Collectors.groupingBy(o -> (Long) o[0], Collectors.mapping(o -> (SoftwareModuleMetadata) o[1], Collectors.toList())));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public ActionStatus addInformationalActionStatus(final ActionStatusCreate c) {
|
public ActionStatus addInformationalActionStatus(final ActionStatusCreate c) {
|
||||||
final JpaActionStatusCreate create = (JpaActionStatusCreate) c;
|
final JpaActionStatusCreate create = (JpaActionStatusCreate) c;
|
||||||
final JpaAction action = getActionAndThrowExceptionIfNotFound(create.getActionId());
|
final JpaAction action = getActionAndThrowExceptionIfNotFound(create.getActionId());
|
||||||
@@ -282,8 +272,8 @@ public class JpaControllerManagement extends JpaActionManagement implements Cont
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(isolation = Isolation.READ_COMMITTED)
|
@Transactional(isolation = Isolation.READ_COMMITTED)
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public Action addUpdateActionStatus(final ActionStatusCreate statusCreate) {
|
public Action addUpdateActionStatus(final ActionStatusCreate statusCreate) {
|
||||||
return addActionStatus((JpaActionStatusCreate) statusCreate);
|
return addActionStatus((JpaActionStatusCreate) statusCreate);
|
||||||
}
|
}
|
||||||
@@ -314,14 +304,14 @@ public class JpaControllerManagement extends JpaActionManagement implements Cont
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(isolation = Isolation.READ_COMMITTED)
|
@Transactional(isolation = Isolation.READ_COMMITTED)
|
||||||
@Retryable(include = ConcurrencyFailureException.class, exclude = EntityAlreadyExistsException.class, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
@Retryable(retryFor = ConcurrencyFailureException.class, exclude = EntityAlreadyExistsException.class, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public Target findOrRegisterTargetIfItDoesNotExist(final String controllerId, final URI address) {
|
public Target findOrRegisterTargetIfItDoesNotExist(final String controllerId, final URI address) {
|
||||||
return findOrRegisterTargetIfItDoesNotExist(controllerId, address, null, null);
|
return findOrRegisterTargetIfItDoesNotExist(controllerId, address, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(isolation = Isolation.READ_COMMITTED)
|
@Transactional(isolation = Isolation.READ_COMMITTED)
|
||||||
@Retryable(include = ConcurrencyFailureException.class, exclude = EntityAlreadyExistsException.class, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
@Retryable(retryFor = ConcurrencyFailureException.class, exclude = EntityAlreadyExistsException.class, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public Target findOrRegisterTargetIfItDoesNotExist(final String controllerId, final URI address,
|
public Target findOrRegisterTargetIfItDoesNotExist(final String controllerId, final URI address,
|
||||||
final String name, final String type) {
|
final String name, final String type) {
|
||||||
final Specification<JpaTarget> spec =
|
final Specification<JpaTarget> spec =
|
||||||
@@ -332,8 +322,7 @@ public class JpaControllerManagement extends JpaActionManagement implements Cont
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<Action> getActionForDownloadByTargetAndSoftwareModule(final String controllerId,
|
public Optional<Action> getActionForDownloadByTargetAndSoftwareModule(final String controllerId, final long moduleId) {
|
||||||
final long moduleId) {
|
|
||||||
throwExceptionIfTargetDoesNotExist(controllerId);
|
throwExceptionIfTargetDoesNotExist(controllerId);
|
||||||
throwExceptionIfSoftwareModuleDoesNotExist(moduleId);
|
throwExceptionIfSoftwareModuleDoesNotExist(moduleId);
|
||||||
|
|
||||||
@@ -409,16 +398,16 @@ public class JpaControllerManagement extends JpaActionManagement implements Cont
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public Action registerRetrieved(final long actionId, final String message) {
|
public Action registerRetrieved(final long actionId, final String message) {
|
||||||
return handleRegisterRetrieved(actionId, message);
|
return handleRegisterRetrieved(actionId, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public Target updateControllerAttributes(final String controllerId, final Map<String, String> data,
|
public Target updateControllerAttributes(final String controllerId, final Map<String, String> data,
|
||||||
final UpdateMode mode) {
|
final UpdateMode mode) {
|
||||||
|
|
||||||
|
|||||||
@@ -122,11 +122,10 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
|
|||||||
* Maximum amount of Actions that are started at once.
|
* Maximum amount of Actions that are started at once.
|
||||||
*/
|
*/
|
||||||
private static final int ACTION_PAGE_LIMIT = 1000;
|
private static final int ACTION_PAGE_LIMIT = 1000;
|
||||||
|
private static final String QUERY_DELETE_ACTIONS_BY_STATE_AND_LAST_MODIFIED_DEFAULT =
|
||||||
private static final String QUERY_DELETE_ACTIONS_BY_STATE_AND_LAST_MODIFIED_DEFAULT = "DELETE FROM sp_action WHERE tenant=#tenant AND status IN (%s) AND last_modified_at<#last_modified_at LIMIT "
|
"DELETE FROM sp_action WHERE tenant=#tenant AND status IN (%s) AND last_modified_at<#last_modified_at LIMIT " + ACTION_PAGE_LIMIT;
|
||||||
+ ACTION_PAGE_LIMIT;
|
|
||||||
|
|
||||||
private static final EnumMap<Database, String> QUERY_DELETE_ACTIONS_BY_STATE_AND_LAST_MODIFIED;
|
private static final EnumMap<Database, String> QUERY_DELETE_ACTIONS_BY_STATE_AND_LAST_MODIFIED;
|
||||||
|
|
||||||
private final EntityManager entityManager;
|
private final EntityManager entityManager;
|
||||||
private final DistributionSetManagement distributionSetManagement;
|
private final DistributionSetManagement distributionSetManagement;
|
||||||
private final TargetRepository targetRepository;
|
private final TargetRepository targetRepository;
|
||||||
@@ -144,14 +143,18 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
|
|||||||
|
|
||||||
static {
|
static {
|
||||||
QUERY_DELETE_ACTIONS_BY_STATE_AND_LAST_MODIFIED = new EnumMap<>(Database.class);
|
QUERY_DELETE_ACTIONS_BY_STATE_AND_LAST_MODIFIED = new EnumMap<>(Database.class);
|
||||||
QUERY_DELETE_ACTIONS_BY_STATE_AND_LAST_MODIFIED.put(Database.SQL_SERVER, "DELETE TOP (" + ACTION_PAGE_LIMIT
|
QUERY_DELETE_ACTIONS_BY_STATE_AND_LAST_MODIFIED.put(
|
||||||
+ ") FROM sp_action WHERE tenant=#tenant AND status IN (%s) AND last_modified_at<#last_modified_at ");
|
Database.SQL_SERVER,
|
||||||
QUERY_DELETE_ACTIONS_BY_STATE_AND_LAST_MODIFIED.put(Database.POSTGRESQL,
|
"DELETE TOP (" + ACTION_PAGE_LIMIT + ") FROM sp_action " +
|
||||||
"DELETE FROM sp_action WHERE id IN (SELECT id FROM sp_action WHERE tenant=#tenant AND status IN (%s) AND last_modified_at<#last_modified_at LIMIT "
|
"WHERE tenant=#tenant AND status IN (%s) AND last_modified_at<#last_modified_at ");
|
||||||
+ ACTION_PAGE_LIMIT + ")");
|
QUERY_DELETE_ACTIONS_BY_STATE_AND_LAST_MODIFIED.put(
|
||||||
|
Database.POSTGRESQL,
|
||||||
|
"DELETE FROM sp_action " +
|
||||||
|
"WHERE id IN (SELECT id FROM sp_action WHERE tenant=#tenant AND status IN (%s) AND last_modified_at<#last_modified_at LIMIT " + ACTION_PAGE_LIMIT + ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
public JpaDeploymentManagement(final EntityManager entityManager, final ActionRepository actionRepository,
|
public JpaDeploymentManagement(
|
||||||
|
final EntityManager entityManager, final ActionRepository actionRepository,
|
||||||
final DistributionSetManagement distributionSetManagement, final TargetRepository targetRepository,
|
final DistributionSetManagement distributionSetManagement, final TargetRepository targetRepository,
|
||||||
final ActionStatusRepository actionStatusRepository, final AuditorAware<String> auditorProvider,
|
final ActionStatusRepository actionStatusRepository, final AuditorAware<String> auditorProvider,
|
||||||
final EventPublisherHolder eventPublisherHolder, final AfterTransactionCommitExecutor afterCommit,
|
final EventPublisherHolder eventPublisherHolder, final AfterTransactionCommitExecutor afterCommit,
|
||||||
@@ -182,17 +185,15 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(isolation = Isolation.READ_COMMITTED)
|
@Transactional(isolation = Isolation.READ_COMMITTED)
|
||||||
public List<DistributionSetAssignmentResult> assignDistributionSets(
|
public List<DistributionSetAssignmentResult> assignDistributionSets(final List<DeploymentRequest> deploymentRequests) {
|
||||||
final List<DeploymentRequest> deploymentRequests) {
|
|
||||||
return assignDistributionSets(tenantAware.getCurrentUsername(), deploymentRequests, null);
|
return assignDistributionSets(tenantAware.getCurrentUsername(), deploymentRequests, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(isolation = Isolation.READ_COMMITTED)
|
@Transactional(isolation = Isolation.READ_COMMITTED)
|
||||||
public List<DistributionSetAssignmentResult> assignDistributionSets(final String initiatedBy,
|
public List<DistributionSetAssignmentResult> assignDistributionSets(
|
||||||
final List<DeploymentRequest> deploymentRequests, final String actionMessage) {
|
final String initiatedBy, final List<DeploymentRequest> deploymentRequests, final String actionMessage) {
|
||||||
WeightValidationHelper.usingContext(systemSecurityContext, tenantConfigurationManagement)
|
WeightValidationHelper.usingContext(systemSecurityContext, tenantConfigurationManagement).validate(deploymentRequests);
|
||||||
.validate(deploymentRequests);
|
|
||||||
return assignDistributionSets(initiatedBy, deploymentRequests, actionMessage, onlineDsAssignmentStrategy);
|
return assignDistributionSets(initiatedBy, deploymentRequests, actionMessage, onlineDsAssignmentStrategy);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,15 +214,14 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(isolation = Isolation.READ_COMMITTED)
|
@Transactional(isolation = Isolation.READ_COMMITTED)
|
||||||
public List<DistributionSetAssignmentResult> offlineAssignedDistributionSets(
|
public List<DistributionSetAssignmentResult> offlineAssignedDistributionSets(final Collection<Entry<String, Long>> assignments) {
|
||||||
final Collection<Entry<String, Long>> assignments) {
|
|
||||||
return offlineAssignedDistributionSets(assignments, tenantAware.getCurrentUsername());
|
return offlineAssignedDistributionSets(assignments, tenantAware.getCurrentUsername());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(isolation = Isolation.READ_COMMITTED)
|
@Transactional(isolation = Isolation.READ_COMMITTED)
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public Action cancelAction(final long actionId) {
|
public Action cancelAction(final long actionId) {
|
||||||
log.debug("cancelAction({})", actionId);
|
log.debug("cancelAction({})", actionId);
|
||||||
|
|
||||||
@@ -381,15 +381,14 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(isolation = Isolation.READ_COMMITTED)
|
@Transactional(isolation = Isolation.READ_COMMITTED)
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public Action forceQuitAction(final long actionId) {
|
public Action forceQuitAction(final long actionId) {
|
||||||
final JpaAction action = actionRepository.findById(actionId)
|
final JpaAction action = actionRepository.findById(actionId)
|
||||||
.orElseThrow(() -> new EntityNotFoundException(Action.class, actionId));
|
.orElseThrow(() -> new EntityNotFoundException(Action.class, actionId));
|
||||||
|
|
||||||
if (!action.isCancelingOrCanceled()) {
|
if (!action.isCancelingOrCanceled()) {
|
||||||
throw new ForceQuitActionNotAllowedException(
|
throw new ForceQuitActionNotAllowedException(action.getId() + " is not canceled yet and cannot be force quit");
|
||||||
action.getId() + " is not canceled yet and cannot be force quit");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!action.isActive()) {
|
if (!action.isActive()) {
|
||||||
@@ -411,8 +410,8 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public Action forceTargetAction(final long actionId) {
|
public Action forceTargetAction(final long actionId) {
|
||||||
final JpaAction action = actionRepository.findById(actionId).map(this::assertTargetUpdateAllowed)
|
final JpaAction action = actionRepository.findById(actionId).map(this::assertTargetUpdateAllowed)
|
||||||
.orElseThrow(() -> new EntityNotFoundException(Action.class, actionId));
|
.orElseThrow(() -> new EntityNotFoundException(Action.class, actionId));
|
||||||
@@ -426,13 +425,12 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(isolation = Isolation.READ_COMMITTED)
|
@Transactional(isolation = Isolation.READ_COMMITTED)
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public void cancelInactiveScheduledActionsForTargets(final List<Long> targetIds) {
|
public void cancelInactiveScheduledActionsForTargets(final List<Long> targetIds) {
|
||||||
if (!isMultiAssignmentsEnabled()) {
|
if (!isMultiAssignmentsEnabled()) {
|
||||||
targetRepository.getAccessController().ifPresent(v -> {
|
targetRepository.getAccessController().ifPresent(v -> {
|
||||||
if (targetRepository.count(AccessController.Operation.UPDATE,
|
if (targetRepository.count(AccessController.Operation.UPDATE, TargetSpecifications.hasIdIn(targetIds)) != targetIds.size()) {
|
||||||
TargetSpecifications.hasIdIn(targetIds)) != targetIds.size()) {
|
|
||||||
throw new EntityNotFoundException(Target.class, targetIds);
|
throw new EntityNotFoundException(Target.class, targetIds);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -443,8 +441,7 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void startScheduledActionsByRolloutGroupParent(final long rolloutId, final long distributionSetId,
|
public void startScheduledActionsByRolloutGroupParent(final long rolloutId, final long distributionSetId, final Long rolloutGroupParentId) {
|
||||||
final Long rolloutGroupParentId) {
|
|
||||||
while (DeploymentHelper.runInNewTransaction(
|
while (DeploymentHelper.runInNewTransaction(
|
||||||
txManager,
|
txManager,
|
||||||
"startScheduledActions-" + rolloutId,
|
"startScheduledActions-" + rolloutId,
|
||||||
@@ -540,10 +537,8 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public void cancelActionsForDistributionSet(final CancelationType cancelationType,
|
public void cancelActionsForDistributionSet(final CancelationType cancelationType, final DistributionSet distributionSet) {
|
||||||
final DistributionSet distributionSet) {
|
actionRepository.findAll(ActionSpecifications.byDistributionSetIdAndActiveAndStatusIsNot(distributionSet.getId(), Status.CANCELING))
|
||||||
actionRepository.findAll(ActionSpecifications
|
|
||||||
.byDistributionSetIdAndActiveAndStatusIsNot(distributionSet.getId(), Status.CANCELING))
|
|
||||||
.forEach(action -> {
|
.forEach(action -> {
|
||||||
try {
|
try {
|
||||||
assertTargetUpdateAllowed(action);
|
assertTargetUpdateAllowed(action);
|
||||||
@@ -580,24 +575,24 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
|
|||||||
return getConfigValue(REPOSITORY_ACTIONS_AUTOCLOSE_ENABLED, Boolean.class);
|
return getConfigValue(REPOSITORY_ACTIONS_AUTOCLOSE_ENABLED, Boolean.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Map<Long, List<TargetWithActionType>> convertRequest(
|
private static Map<Long, List<TargetWithActionType>> convertRequest(final Collection<DeploymentRequest> deploymentRequests) {
|
||||||
final Collection<DeploymentRequest> deploymentRequests) {
|
return deploymentRequests.stream().collect(
|
||||||
return deploymentRequests.stream().collect(Collectors.groupingBy(DeploymentRequest::getDistributionSetId,
|
Collectors.groupingBy(DeploymentRequest::getDistributionSetId,
|
||||||
Collectors.mapping(DeploymentRequest::getTargetWithActionType, Collectors.toList())));
|
Collectors.mapping(DeploymentRequest::getTargetWithActionType, Collectors.toList())));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* split tIDs length into max entries in-statement because many database have
|
* split tIDs length into max entries in-statement because many database have
|
||||||
* constraint of max entries in in-statements e.g. Oracle with maximum 1000
|
* a constraint of max entries in in-statements e.g. Oracle with maximum 1000
|
||||||
* elements, so we need to split the entries here and execute multiple
|
* elements, so we need to split the entries here and execute multiple
|
||||||
* statements
|
* statements
|
||||||
*/
|
*/
|
||||||
private static List<List<Long>> getTargetEntitiesAsChunks(final List<JpaTarget> targetEntities) {
|
private static List<List<Long>> getTargetEntitiesAsChunks(final List<JpaTarget> targetEntities) {
|
||||||
return ListUtils.partition(targetEntities.stream().map(Target::getId).collect(Collectors.toList()),
|
return ListUtils.partition(targetEntities.stream().map(Target::getId).collect(Collectors.toList()), Constants.MAX_ENTRIES_IN_STATEMENT);
|
||||||
Constants.MAX_ENTRIES_IN_STATEMENT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static DistributionSetAssignmentResult buildAssignmentResult(final JpaDistributionSet distributionSet,
|
private static DistributionSetAssignmentResult buildAssignmentResult(
|
||||||
|
final JpaDistributionSet distributionSet,
|
||||||
final List<JpaAction> assignedActions, final int totalTargetsForAssignment) {
|
final List<JpaAction> assignedActions, final int totalTargetsForAssignment) {
|
||||||
final int alreadyAssignedTargetsCount = totalTargetsForAssignment - assignedActions.size();
|
final int alreadyAssignedTargetsCount = totalTargetsForAssignment - assignedActions.size();
|
||||||
|
|
||||||
@@ -631,15 +626,16 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
|
|||||||
return template;
|
return template;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<DistributionSetAssignmentResult> assignDistributionSets(final String initiatedBy,
|
private List<DistributionSetAssignmentResult> assignDistributionSets(
|
||||||
|
final String initiatedBy,
|
||||||
final List<DeploymentRequest> deploymentRequests, final String actionMessage,
|
final List<DeploymentRequest> deploymentRequests, final String actionMessage,
|
||||||
final AbstractDsAssignmentStrategy strategy) {
|
final AbstractDsAssignmentStrategy strategy) {
|
||||||
final List<DeploymentRequest> validatedRequests = validateAndFilterRequestForAssignments(deploymentRequests);
|
final List<DeploymentRequest> validatedRequests = validateAndFilterRequestForAssignments(deploymentRequests);
|
||||||
final Map<Long, List<TargetWithActionType>> assignmentsByDsIds = convertRequest(validatedRequests);
|
final Map<Long, List<TargetWithActionType>> assignmentsByDsIds = convertRequest(validatedRequests);
|
||||||
|
|
||||||
final List<DistributionSetAssignmentResult> results = assignmentsByDsIds.entrySet().stream()
|
final List<DistributionSetAssignmentResult> results = assignmentsByDsIds.entrySet().stream()
|
||||||
.map(entry -> assignDistributionSetToTargetsWithRetry(initiatedBy, entry.getKey(), entry.getValue(),
|
.map(entry -> assignDistributionSetToTargetsWithRetry(
|
||||||
actionMessage, strategy))
|
initiatedBy, entry.getKey(), entry.getValue(), actionMessage, strategy))
|
||||||
.toList();
|
.toList();
|
||||||
strategy.sendDeploymentEvents(results);
|
strategy.sendDeploymentEvents(results);
|
||||||
return results;
|
return results;
|
||||||
@@ -663,7 +659,9 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
|
|||||||
private void checkForMultiAssignment(final Collection<DeploymentRequest> deploymentRequests) {
|
private void checkForMultiAssignment(final Collection<DeploymentRequest> deploymentRequests) {
|
||||||
if (!isMultiAssignmentsEnabled()) {
|
if (!isMultiAssignmentsEnabled()) {
|
||||||
final long distinctTargetsInRequest = deploymentRequests.stream()
|
final long distinctTargetsInRequest = deploymentRequests.stream()
|
||||||
.map(request -> request.getTargetWithActionType().getControllerId()).distinct().count();
|
.map(request -> request.getTargetWithActionType().getControllerId())
|
||||||
|
.distinct()
|
||||||
|
.count();
|
||||||
if (distinctTargetsInRequest < deploymentRequests.size()) {
|
if (distinctTargetsInRequest < deploymentRequests.size()) {
|
||||||
throw new MultiAssignmentIsNotEnabledException();
|
throw new MultiAssignmentIsNotEnabledException();
|
||||||
}
|
}
|
||||||
@@ -676,14 +674,16 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void checkForTargetTypeCompatibility(final List<DeploymentRequest> deploymentRequests) {
|
private void checkForTargetTypeCompatibility(final List<DeploymentRequest> deploymentRequests) {
|
||||||
final List<String> controllerIds = deploymentRequests.stream().map(DeploymentRequest::getControllerId)
|
final List<String> controllerIds = deploymentRequests.stream()
|
||||||
.distinct().toList();
|
.map(DeploymentRequest::getControllerId)
|
||||||
|
.distinct()
|
||||||
|
.toList();
|
||||||
final List<Long> distSetIds = deploymentRequests.stream().map(DeploymentRequest::getDistributionSetId)
|
final List<Long> distSetIds = deploymentRequests.stream().map(DeploymentRequest::getDistributionSetId)
|
||||||
.distinct().toList();
|
.distinct()
|
||||||
|
.toList();
|
||||||
|
|
||||||
if (controllerIds.size() > 1 && distSetIds.size() > 1) {
|
if (controllerIds.size() > 1 && distSetIds.size() > 1) {
|
||||||
throw new IllegalStateException(
|
throw new IllegalStateException("Assigning multiple Distribution Sets to multiple Targets simultaneously is not allowed!");
|
||||||
"Assigning multiple Distribution Sets to multiple Targets simultaneously is not allowed!");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (distSetIds.size() == 1) {
|
if (distSetIds.size() == 1) {
|
||||||
@@ -699,7 +699,10 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
|
|||||||
.stream()
|
.stream()
|
||||||
.map(ids -> targetRepository.findAll(TargetSpecifications.hasControllerIdIn(ids)
|
.map(ids -> targetRepository.findAll(TargetSpecifications.hasControllerIdIn(ids)
|
||||||
.and(TargetSpecifications.notCompatibleWithDistributionSetType(distSetType.getId()))))
|
.and(TargetSpecifications.notCompatibleWithDistributionSetType(distSetType.getId()))))
|
||||||
.flatMap(List::stream).map(Target::getTargetType).map(TargetType::getName).collect(Collectors.toSet());
|
.flatMap(List::stream)
|
||||||
|
.map(Target::getTargetType)
|
||||||
|
.map(TargetType::getName)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
if (!incompatibleTargetTypes.isEmpty()) {
|
if (!incompatibleTargetTypes.isEmpty()) {
|
||||||
throw new IncompatibleTargetTypeException(incompatibleTargetTypes, distSetType.getName());
|
throw new IncompatibleTargetTypeException(incompatibleTargetTypes, distSetType.getName());
|
||||||
@@ -714,11 +717,13 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
|
|||||||
// we assume that list of assigned DS is less than
|
// we assume that list of assigned DS is less than
|
||||||
// MAX_ENTRIES_IN_STATEMENT
|
// MAX_ENTRIES_IN_STATEMENT
|
||||||
final Set<DistributionSetType> incompatibleDistSetTypes = distributionSetManagement.get(distSetIds).stream()
|
final Set<DistributionSetType> incompatibleDistSetTypes = distributionSetManagement.get(distSetIds).stream()
|
||||||
.map(DistributionSet::getType).collect(Collectors.toSet());
|
.map(DistributionSet::getType)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
incompatibleDistSetTypes.removeAll(target.getTargetType().getCompatibleDistributionSetTypes());
|
incompatibleDistSetTypes.removeAll(target.getTargetType().getCompatibleDistributionSetTypes());
|
||||||
|
|
||||||
if (!incompatibleDistSetTypes.isEmpty()) {
|
if (!incompatibleDistSetTypes.isEmpty()) {
|
||||||
final Set<String> distSetTypeNames = incompatibleDistSetTypes.stream().map(DistributionSetType::getName)
|
final Set<String> distSetTypeNames = incompatibleDistSetTypes.stream()
|
||||||
|
.map(DistributionSetType::getName)
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
throw new IncompatibleTargetTypeException(target.getTargetType().getName(), distSetTypeNames);
|
throw new IncompatibleTargetTypeException(target.getTargetType().getName(), distSetTypeNames);
|
||||||
}
|
}
|
||||||
@@ -726,8 +731,10 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<DeploymentRequest> filterByTargetUpdatable(final List<DeploymentRequest> deploymentRequests) {
|
private List<DeploymentRequest> filterByTargetUpdatable(final List<DeploymentRequest> deploymentRequests) {
|
||||||
final List<String> controllerIds = deploymentRequests.stream().map(DeploymentRequest::getControllerId)
|
final List<String> controllerIds = deploymentRequests.stream()
|
||||||
.distinct().toList();
|
.map(DeploymentRequest::getControllerId)
|
||||||
|
.distinct()
|
||||||
|
.toList();
|
||||||
|
|
||||||
final List<String> found = targetRepository
|
final List<String> found = targetRepository
|
||||||
.findAll(AccessController.Operation.UPDATE, TargetSpecifications.hasControllerIdIn(controllerIds))
|
.findAll(AccessController.Operation.UPDATE, TargetSpecifications.hasControllerIdIn(controllerIds))
|
||||||
@@ -773,8 +780,7 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
|
|||||||
private DistributionSetAssignmentResult assignDistributionSetToTargets(final String initiatedBy, final Long dsId,
|
private DistributionSetAssignmentResult assignDistributionSetToTargets(final String initiatedBy, final Long dsId,
|
||||||
final Collection<TargetWithActionType> targetsWithActionType, final String actionMessage,
|
final Collection<TargetWithActionType> targetsWithActionType, final String actionMessage,
|
||||||
final AbstractDsAssignmentStrategy assignmentStrategy) {
|
final AbstractDsAssignmentStrategy assignmentStrategy) {
|
||||||
final JpaDistributionSet distributionSet =
|
final JpaDistributionSet distributionSet = (JpaDistributionSet) distributionSetManagement.getValidAndComplete(dsId);
|
||||||
(JpaDistributionSet) distributionSetManagement.getValidAndComplete(dsId);
|
|
||||||
|
|
||||||
if (((JpaDistributionSetManagement) distributionSetManagement).isImplicitLockApplicable(distributionSet)) {
|
if (((JpaDistributionSetManagement) distributionSetManagement).isImplicitLockApplicable(distributionSet)) {
|
||||||
// without new transaction DS changed event is not thrown
|
// without new transaction DS changed event is not thrown
|
||||||
|
|||||||
@@ -151,8 +151,8 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public List<DistributionSet> create(final Collection<DistributionSetCreate> creates) {
|
public List<DistributionSet> create(final Collection<DistributionSetCreate> creates) {
|
||||||
final List<JpaDistributionSet> toCreate = creates.stream().map(JpaDistributionSetCreate.class::cast)
|
final List<JpaDistributionSet> toCreate = creates.stream().map(JpaDistributionSetCreate.class::cast)
|
||||||
.map(this::setDefaultTypeIfMissing).map(JpaDistributionSetCreate::build).toList();
|
.map(this::setDefaultTypeIfMissing).map(JpaDistributionSetCreate::build).toList();
|
||||||
@@ -162,8 +162,8 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public DistributionSet create(final DistributionSetCreate c) {
|
public DistributionSet create(final DistributionSetCreate c) {
|
||||||
final JpaDistributionSetCreate create = (JpaDistributionSetCreate) c;
|
final JpaDistributionSetCreate create = (JpaDistributionSetCreate) c;
|
||||||
setDefaultTypeIfMissing(create);
|
setDefaultTypeIfMissing(create);
|
||||||
@@ -173,8 +173,8 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public DistributionSet update(final DistributionSetUpdate u) {
|
public DistributionSet update(final DistributionSetUpdate u) {
|
||||||
final GenericDistributionSetUpdate update = (GenericDistributionSetUpdate) u;
|
final GenericDistributionSetUpdate update = (GenericDistributionSetUpdate) u;
|
||||||
|
|
||||||
@@ -212,16 +212,16 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public void delete(final long id) {
|
public void delete(final long id) {
|
||||||
delete(List.of(id));
|
delete(List.of(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public void delete(final Collection<Long> distributionSetIDs) {
|
public void delete(final Collection<Long> distributionSetIDs) {
|
||||||
getDistributionSets(distributionSetIDs); // throws EntityNotFoundException if any of these do not exists
|
getDistributionSets(distributionSetIDs); // throws EntityNotFoundException if any of these do not exists
|
||||||
final List<JpaDistributionSet> setsFound = distributionSetRepository.findAll(
|
final List<JpaDistributionSet> setsFound = distributionSetRepository.findAll(
|
||||||
@@ -288,8 +288,8 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public DistributionSet assignSoftwareModules(final long id, final Collection<Long> softwareModuleId) {
|
public DistributionSet assignSoftwareModules(final long id, final Collection<Long> softwareModuleId) {
|
||||||
final JpaDistributionSet set = (JpaDistributionSet) getValid(id);
|
final JpaDistributionSet set = (JpaDistributionSet) getValid(id);
|
||||||
assertDistributionSetIsNotAssignedToTargets(id);
|
assertDistributionSetIsNotAssignedToTargets(id);
|
||||||
@@ -308,8 +308,8 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public List<DistributionSet> assignTag(final Collection<Long> ids, final long dsTagId) {
|
public List<DistributionSet> assignTag(final Collection<Long> ids, final long dsTagId) {
|
||||||
return updateTag(ids, dsTagId, (tag, distributionSet) -> {
|
return updateTag(ids, dsTagId, (tag, distributionSet) -> {
|
||||||
if (distributionSet.getTags().contains(tag)) {
|
if (distributionSet.getTags().contains(tag)) {
|
||||||
@@ -323,8 +323,8 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public List<DistributionSet> unassignTag(final Collection<Long> ids, final long dsTagId) {
|
public List<DistributionSet> unassignTag(final Collection<Long> ids, final long dsTagId) {
|
||||||
return updateTag(ids, dsTagId, (tag, distributionSet) -> {
|
return updateTag(ids, dsTagId, (tag, distributionSet) -> {
|
||||||
if (distributionSet.getTags().contains(tag)) {
|
if (distributionSet.getTags().contains(tag)) {
|
||||||
@@ -338,8 +338,8 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public List<DistributionSetMetadata> createMetaData(final long id, final Collection<MetaData> md) {
|
public List<DistributionSetMetadata> createMetaData(final long id, final Collection<MetaData> md) {
|
||||||
final JpaDistributionSet distributionSet = (JpaDistributionSet) getValid(id);
|
final JpaDistributionSet distributionSet = (JpaDistributionSet) getValid(id);
|
||||||
assertMetaDataQuota(id, md.size());
|
assertMetaDataQuota(id, md.size());
|
||||||
@@ -357,8 +357,8 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public void deleteMetaData(final long id, final String key) {
|
public void deleteMetaData(final long id, final String key) {
|
||||||
final JpaDistributionSetMetadata metadata = (JpaDistributionSetMetadata) getMetaDataByDistributionSetId(
|
final JpaDistributionSetMetadata metadata = (JpaDistributionSetMetadata) getMetaDataByDistributionSetId(
|
||||||
id, key)
|
id, key)
|
||||||
@@ -373,8 +373,8 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public void lock(final long id) {
|
public void lock(final long id) {
|
||||||
final JpaDistributionSet distributionSet = getById(id);
|
final JpaDistributionSet distributionSet = getById(id);
|
||||||
if (!distributionSet.isLocked()) {
|
if (!distributionSet.isLocked()) {
|
||||||
@@ -386,8 +386,8 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public void unlock(final long id) {
|
public void unlock(final long id) {
|
||||||
final JpaDistributionSet distributionSet = getById(id);
|
final JpaDistributionSet distributionSet = getById(id);
|
||||||
if (distributionSet.isLocked()) {
|
if (distributionSet.isLocked()) {
|
||||||
@@ -570,8 +570,8 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public DistributionSet unassignSoftwareModule(final long id, final long moduleId) {
|
public DistributionSet unassignSoftwareModule(final long id, final long moduleId) {
|
||||||
final JpaDistributionSet set = (JpaDistributionSet) getValid(id);
|
final JpaDistributionSet set = (JpaDistributionSet) getValid(id);
|
||||||
assertDistributionSetIsNotAssignedToTargets(id);
|
assertDistributionSetIsNotAssignedToTargets(id);
|
||||||
@@ -584,8 +584,8 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public DistributionSetMetadata updateMetaData(final long id, final MetaData md) {
|
public DistributionSetMetadata updateMetaData(final long id, final MetaData md) {
|
||||||
// check if exists otherwise throw entity not found exception
|
// check if exists otherwise throw entity not found exception
|
||||||
final JpaDistributionSetMetadata toUpdate = (JpaDistributionSetMetadata) getMetaDataByDistributionSetId(id,
|
final JpaDistributionSetMetadata toUpdate = (JpaDistributionSetMetadata) getMetaDataByDistributionSetId(id,
|
||||||
@@ -641,8 +641,8 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public DistributionSetTagAssignmentResult toggleTagAssignment(final Collection<Long> ids, final String tagName) {
|
public DistributionSetTagAssignmentResult toggleTagAssignment(final Collection<Long> ids, final String tagName) {
|
||||||
return updateTag(
|
return updateTag(
|
||||||
ids,
|
ids,
|
||||||
@@ -678,8 +678,8 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public DistributionSet unassignTag(final long id, final long dsTagId) {
|
public DistributionSet unassignTag(final long id, final long dsTagId) {
|
||||||
final JpaDistributionSet set = (JpaDistributionSet) getWithDetails(id)
|
final JpaDistributionSet set = (JpaDistributionSet) getWithDetails(id)
|
||||||
.orElseThrow(() -> new EntityNotFoundException(DistributionSet.class, id));
|
.orElseThrow(() -> new EntityNotFoundException(DistributionSet.class, id));
|
||||||
|
|||||||
@@ -54,14 +54,12 @@ import org.springframework.validation.annotation.Validated;
|
|||||||
public class JpaDistributionSetTagManagement implements DistributionSetTagManagement {
|
public class JpaDistributionSetTagManagement implements DistributionSetTagManagement {
|
||||||
|
|
||||||
private final DistributionSetTagRepository distributionSetTagRepository;
|
private final DistributionSetTagRepository distributionSetTagRepository;
|
||||||
|
|
||||||
private final DistributionSetRepository distributionSetRepository;
|
private final DistributionSetRepository distributionSetRepository;
|
||||||
|
|
||||||
private final VirtualPropertyReplacer virtualPropertyReplacer;
|
private final VirtualPropertyReplacer virtualPropertyReplacer;
|
||||||
|
|
||||||
private final Database database;
|
private final Database database;
|
||||||
|
|
||||||
public JpaDistributionSetTagManagement(final DistributionSetTagRepository distributionSetTagRepository,
|
public JpaDistributionSetTagManagement(
|
||||||
|
final DistributionSetTagRepository distributionSetTagRepository,
|
||||||
final DistributionSetRepository distributionSetRepository,
|
final DistributionSetRepository distributionSetRepository,
|
||||||
final VirtualPropertyReplacer virtualPropertyReplacer, final Database database) {
|
final VirtualPropertyReplacer virtualPropertyReplacer, final Database database) {
|
||||||
this.distributionSetTagRepository = distributionSetTagRepository;
|
this.distributionSetTagRepository = distributionSetTagRepository;
|
||||||
@@ -72,8 +70,8 @@ public class JpaDistributionSetTagManagement implements DistributionSetTagManage
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public List<DistributionSetTag> create(final Collection<TagCreate> dst) {
|
public List<DistributionSetTag> create(final Collection<TagCreate> dst) {
|
||||||
final List<JpaDistributionSetTag> toCreate = dst.stream().map(JpaTagCreate.class::cast)
|
final List<JpaDistributionSetTag> toCreate = dst.stream().map(JpaTagCreate.class::cast)
|
||||||
.map(JpaTagCreate::buildDistributionSetTag).toList();
|
.map(JpaTagCreate::buildDistributionSetTag).toList();
|
||||||
@@ -83,8 +81,8 @@ public class JpaDistributionSetTagManagement implements DistributionSetTagManage
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public DistributionSetTag create(final TagCreate c) {
|
public DistributionSetTag create(final TagCreate c) {
|
||||||
final JpaTagCreate create = (JpaTagCreate) c;
|
final JpaTagCreate create = (JpaTagCreate) c;
|
||||||
return distributionSetTagRepository.save(AccessController.Operation.CREATE, create.buildDistributionSetTag());
|
return distributionSetTagRepository.save(AccessController.Operation.CREATE, create.buildDistributionSetTag());
|
||||||
@@ -92,8 +90,8 @@ public class JpaDistributionSetTagManagement implements DistributionSetTagManage
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public DistributionSetTag update(final TagUpdate u) {
|
public DistributionSetTag update(final TagUpdate u) {
|
||||||
final GenericTagUpdate update = (GenericTagUpdate) u;
|
final GenericTagUpdate update = (GenericTagUpdate) u;
|
||||||
|
|
||||||
@@ -114,16 +112,16 @@ public class JpaDistributionSetTagManagement implements DistributionSetTagManage
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public void delete(final long id) {
|
public void delete(final long id) {
|
||||||
distributionSetTagRepository.deleteById(id);
|
distributionSetTagRepository.deleteById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public void delete(final Collection<Long> ids) {
|
public void delete(final Collection<Long> ids) {
|
||||||
final List<JpaDistributionSetTag> setsFound = distributionSetTagRepository.findAllById(ids);
|
final List<JpaDistributionSetTag> setsFound = distributionSetTagRepository.findAllById(ids);
|
||||||
|
|
||||||
@@ -166,8 +164,8 @@ public class JpaDistributionSetTagManagement implements DistributionSetTagManage
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public void delete(final String tagName) {
|
public void delete(final String tagName) {
|
||||||
final JpaDistributionSetTag dsTag = distributionSetTagRepository
|
final JpaDistributionSetTag dsTag = distributionSetTagRepository
|
||||||
.findOne(DistributionSetTagSpecifications.byName(tagName))
|
.findOne(DistributionSetTagSpecifications.byName(tagName))
|
||||||
|
|||||||
@@ -105,8 +105,8 @@ public class JpaDistributionSetTypeManagement implements DistributionSetTypeMana
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public DistributionSetType assignOptionalSoftwareModuleTypes(final long id,
|
public DistributionSetType assignOptionalSoftwareModuleTypes(final long id,
|
||||||
final Collection<Long> softwareModulesTypeIds) {
|
final Collection<Long> softwareModulesTypeIds) {
|
||||||
return assignSoftwareModuleTypes(id, softwareModulesTypeIds, false);
|
return assignSoftwareModuleTypes(id, softwareModulesTypeIds, false);
|
||||||
@@ -114,8 +114,8 @@ public class JpaDistributionSetTypeManagement implements DistributionSetTypeMana
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public DistributionSetType assignMandatorySoftwareModuleTypes(final long id,
|
public DistributionSetType assignMandatorySoftwareModuleTypes(final long id,
|
||||||
final Collection<Long> softwareModuleTypeIds) {
|
final Collection<Long> softwareModuleTypeIds) {
|
||||||
return assignSoftwareModuleTypes(id, softwareModuleTypeIds, true);
|
return assignSoftwareModuleTypes(id, softwareModuleTypeIds, true);
|
||||||
@@ -123,8 +123,8 @@ public class JpaDistributionSetTypeManagement implements DistributionSetTypeMana
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public DistributionSetType unassignSoftwareModuleType(final long id, final long softwareModuleTypeId) {
|
public DistributionSetType unassignSoftwareModuleType(final long id, final long softwareModuleTypeId) {
|
||||||
final JpaDistributionSetType type = findDistributionSetTypeAndThrowExceptionIfNotFound(id);
|
final JpaDistributionSetType type = findDistributionSetTypeAndThrowExceptionIfNotFound(id);
|
||||||
|
|
||||||
@@ -137,8 +137,8 @@ public class JpaDistributionSetTypeManagement implements DistributionSetTypeMana
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public List<DistributionSetType> create(final Collection<DistributionSetTypeCreate> types) {
|
public List<DistributionSetType> create(final Collection<DistributionSetTypeCreate> types) {
|
||||||
final List<JpaDistributionSetType> typesToCreate = types.stream().map(JpaDistributionSetTypeCreate.class::cast)
|
final List<JpaDistributionSetType> typesToCreate = types.stream().map(JpaDistributionSetTypeCreate.class::cast)
|
||||||
.map(JpaDistributionSetTypeCreate::build).toList();
|
.map(JpaDistributionSetTypeCreate::build).toList();
|
||||||
@@ -149,8 +149,8 @@ public class JpaDistributionSetTypeManagement implements DistributionSetTypeMana
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public DistributionSetType create(final DistributionSetTypeCreate c) {
|
public DistributionSetType create(final DistributionSetTypeCreate c) {
|
||||||
final JpaDistributionSetType distributionSetType = ((JpaDistributionSetTypeCreate) c).build();
|
final JpaDistributionSetType distributionSetType = ((JpaDistributionSetTypeCreate) c).build();
|
||||||
|
|
||||||
@@ -159,8 +159,8 @@ public class JpaDistributionSetTypeManagement implements DistributionSetTypeMana
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public DistributionSetType update(final DistributionSetTypeUpdate u) {
|
public DistributionSetType update(final DistributionSetTypeUpdate u) {
|
||||||
final GenericDistributionSetTypeUpdate update = (GenericDistributionSetTypeUpdate) u;
|
final GenericDistributionSetTypeUpdate update = (GenericDistributionSetTypeUpdate) u;
|
||||||
|
|
||||||
@@ -202,8 +202,8 @@ public class JpaDistributionSetTypeManagement implements DistributionSetTypeMana
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public void delete(final long id) {
|
public void delete(final long id) {
|
||||||
final JpaDistributionSetType toDelete = distributionSetTypeRepository.findById(id)
|
final JpaDistributionSetType toDelete = distributionSetTypeRepository.findById(id)
|
||||||
.orElseThrow(() -> new EntityNotFoundException(DistributionSetType.class, id));
|
.orElseThrow(() -> new EntityNotFoundException(DistributionSetType.class, id));
|
||||||
@@ -220,8 +220,8 @@ public class JpaDistributionSetTypeManagement implements DistributionSetTypeMana
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public void delete(final Collection<Long> ids) {
|
public void delete(final Collection<Long> ids) {
|
||||||
distributionSetTypeRepository.deleteAllById(ids);
|
distributionSetTypeRepository.deleteAllById(ids);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -106,10 +106,10 @@ public class JpaRolloutManagement implements RolloutManagement {
|
|||||||
private static final List<RolloutStatus> ACTIVE_ROLLOUTS = Arrays.asList(RolloutStatus.CREATING,
|
private static final List<RolloutStatus> ACTIVE_ROLLOUTS = Arrays.asList(RolloutStatus.CREATING,
|
||||||
RolloutStatus.DELETING, RolloutStatus.STARTING, RolloutStatus.READY, RolloutStatus.RUNNING,
|
RolloutStatus.DELETING, RolloutStatus.STARTING, RolloutStatus.READY, RolloutStatus.RUNNING,
|
||||||
RolloutStatus.STOPPING);
|
RolloutStatus.STOPPING);
|
||||||
|
|
||||||
private static final List<RolloutStatus> ROLLOUT_STATUS_STOPPABLE = Arrays.asList(RolloutStatus.RUNNING,
|
private static final List<RolloutStatus> ROLLOUT_STATUS_STOPPABLE = Arrays.asList(RolloutStatus.RUNNING,
|
||||||
RolloutStatus.CREATING, RolloutStatus.PAUSED, RolloutStatus.READY, RolloutStatus.STARTING,
|
RolloutStatus.CREATING, RolloutStatus.PAUSED, RolloutStatus.READY, RolloutStatus.STARTING,
|
||||||
RolloutStatus.WAITING_FOR_APPROVAL, RolloutStatus.APPROVAL_DENIED);
|
RolloutStatus.WAITING_FOR_APPROVAL, RolloutStatus.APPROVAL_DENIED);
|
||||||
|
|
||||||
private final TargetManagement targetManagement;
|
private final TargetManagement targetManagement;
|
||||||
private final DistributionSetManagement distributionSetManagement;
|
private final DistributionSetManagement distributionSetManagement;
|
||||||
private final VirtualPropertyReplacer virtualPropertyReplacer;
|
private final VirtualPropertyReplacer virtualPropertyReplacer;
|
||||||
@@ -181,8 +181,8 @@ public class JpaRolloutManagement implements RolloutManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public Rollout create(final RolloutCreate rollout, final int amountGroup, final boolean confirmationRequired,
|
public Rollout create(final RolloutCreate rollout, final int amountGroup, final boolean confirmationRequired,
|
||||||
final RolloutGroupConditions conditions, final DynamicRolloutGroupTemplate dynamicRolloutGroupTemplate) {
|
final RolloutGroupConditions conditions, final DynamicRolloutGroupTemplate dynamicRolloutGroupTemplate) {
|
||||||
if (amountGroup < 0) {
|
if (amountGroup < 0) {
|
||||||
@@ -207,8 +207,8 @@ public class JpaRolloutManagement implements RolloutManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public Rollout create(@NotNull @Valid RolloutCreate create, int amountGroup, boolean confirmationRequired,
|
public Rollout create(@NotNull @Valid RolloutCreate create, int amountGroup, boolean confirmationRequired,
|
||||||
@NotNull RolloutGroupConditions conditions) {
|
@NotNull RolloutGroupConditions conditions) {
|
||||||
return create(create, amountGroup, confirmationRequired, conditions, null);
|
return create(create, amountGroup, confirmationRequired, conditions, null);
|
||||||
@@ -216,8 +216,8 @@ public class JpaRolloutManagement implements RolloutManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public Rollout create(final RolloutCreate rollout, final List<RolloutGroupCreate> groups,
|
public Rollout create(final RolloutCreate rollout, final List<RolloutGroupCreate> groups,
|
||||||
final RolloutGroupConditions conditions) {
|
final RolloutGroupConditions conditions) {
|
||||||
if (groups.isEmpty()) {
|
if (groups.isEmpty()) {
|
||||||
@@ -324,8 +324,8 @@ public class JpaRolloutManagement implements RolloutManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public void pauseRollout(final long rolloutId) {
|
public void pauseRollout(final long rolloutId) {
|
||||||
final JpaRollout rollout = getRolloutOrThrowExceptionIfNotFound(rolloutId);
|
final JpaRollout rollout = getRolloutOrThrowExceptionIfNotFound(rolloutId);
|
||||||
if (RolloutStatus.RUNNING != rollout.getStatus()) {
|
if (RolloutStatus.RUNNING != rollout.getStatus()) {
|
||||||
@@ -343,8 +343,8 @@ public class JpaRolloutManagement implements RolloutManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public void resumeRollout(final long rolloutId) {
|
public void resumeRollout(final long rolloutId) {
|
||||||
final JpaRollout rollout = getRolloutOrThrowExceptionIfNotFound(rolloutId);
|
final JpaRollout rollout = getRolloutOrThrowExceptionIfNotFound(rolloutId);
|
||||||
if (RolloutStatus.PAUSED != rollout.getStatus()) {
|
if (RolloutStatus.PAUSED != rollout.getStatus()) {
|
||||||
@@ -357,29 +357,32 @@ public class JpaRolloutManagement implements RolloutManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public Rollout approveOrDeny(final long rolloutId, final Rollout.ApprovalDecision decision) {
|
public Rollout approveOrDeny(final long rolloutId, final Rollout.ApprovalDecision decision) {
|
||||||
return this.approveOrDeny(rolloutId, decision, null);
|
return this.approveOrDeny(rolloutId, decision, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public Rollout approveOrDeny(final long rolloutId, final Rollout.ApprovalDecision decision, final String remark) {
|
public Rollout approveOrDeny(final long rolloutId, final Rollout.ApprovalDecision decision, final String remark) {
|
||||||
log.debug("approveOrDeny rollout called for rollout {} with decision {}", rolloutId, decision);
|
log.debug("approveOrDeny rollout called for rollout {} with decision {}", rolloutId, decision);
|
||||||
final JpaRollout rollout = getRolloutOrThrowExceptionIfNotFound(rolloutId);
|
final JpaRollout rollout = getRolloutOrThrowExceptionIfNotFound(rolloutId);
|
||||||
RolloutHelper.verifyRolloutInStatus(rollout, RolloutStatus.WAITING_FOR_APPROVAL);
|
RolloutHelper.verifyRolloutInStatus(rollout, RolloutStatus.WAITING_FOR_APPROVAL);
|
||||||
switch (decision) {
|
switch (decision) {
|
||||||
case APPROVED:
|
case APPROVED: {
|
||||||
rollout.setStatus(RolloutStatus.READY);
|
rollout.setStatus(RolloutStatus.READY);
|
||||||
break;
|
break;
|
||||||
case DENIED:
|
}
|
||||||
|
case DENIED: {
|
||||||
rollout.setStatus(RolloutStatus.APPROVAL_DENIED);
|
rollout.setStatus(RolloutStatus.APPROVAL_DENIED);
|
||||||
break;
|
break;
|
||||||
default:
|
}
|
||||||
|
default: {
|
||||||
throw new IllegalArgumentException("Unknown approval decision: " + decision);
|
throw new IllegalArgumentException("Unknown approval decision: " + decision);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
rollout.setApprovalDecidedBy(rolloutApprovalStrategy.getApprovalUser(rollout));
|
rollout.setApprovalDecidedBy(rolloutApprovalStrategy.getApprovalUser(rollout));
|
||||||
if (remark != null) {
|
if (remark != null) {
|
||||||
@@ -390,8 +393,8 @@ public class JpaRolloutManagement implements RolloutManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public Rollout start(final long rolloutId) {
|
public Rollout start(final long rolloutId) {
|
||||||
log.debug("startRollout called for rollout {}", rolloutId);
|
log.debug("startRollout called for rollout {}", rolloutId);
|
||||||
|
|
||||||
@@ -404,8 +407,8 @@ public class JpaRolloutManagement implements RolloutManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public Rollout update(final RolloutUpdate u) {
|
public Rollout update(final RolloutUpdate u) {
|
||||||
final GenericRolloutUpdate update = (GenericRolloutUpdate) u;
|
final GenericRolloutUpdate update = (GenericRolloutUpdate) u;
|
||||||
final JpaRollout rollout = getRolloutOrThrowExceptionIfNotFound(update.getId());
|
final JpaRollout rollout = getRolloutOrThrowExceptionIfNotFound(update.getId());
|
||||||
@@ -419,8 +422,8 @@ public class JpaRolloutManagement implements RolloutManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public void delete(final long rolloutId) {
|
public void delete(final long rolloutId) {
|
||||||
final JpaRollout jpaRollout = rolloutRepository.findById(rolloutId)
|
final JpaRollout jpaRollout = rolloutRepository.findById(rolloutId)
|
||||||
.orElseThrow(() -> new EntityNotFoundException(Rollout.class, rolloutId));
|
.orElseThrow(() -> new EntityNotFoundException(Rollout.class, rolloutId));
|
||||||
@@ -451,8 +454,8 @@ public class JpaRolloutManagement implements RolloutManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public void triggerNextGroup(final long rolloutId) {
|
public void triggerNextGroup(final long rolloutId) {
|
||||||
final JpaRollout rollout = getRolloutOrThrowExceptionIfNotFound(rolloutId);
|
final JpaRollout rollout = getRolloutOrThrowExceptionIfNotFound(rolloutId);
|
||||||
if (RolloutStatus.RUNNING != rollout.getStatus()) {
|
if (RolloutStatus.RUNNING != rollout.getStatus()) {
|
||||||
@@ -479,8 +482,7 @@ public class JpaRolloutManagement implements RolloutManagement {
|
|||||||
@Override
|
@Override
|
||||||
public void setRolloutStatusDetails(final Slice<Rollout> rollouts) {
|
public void setRolloutStatusDetails(final Slice<Rollout> rollouts) {
|
||||||
final List<Long> rolloutIds = rollouts.getContent().stream().map(Rollout::getId).collect(Collectors.toList());
|
final List<Long> rolloutIds = rollouts.getContent().stream().map(Rollout::getId).collect(Collectors.toList());
|
||||||
final Map<Long, List<TotalTargetCountActionStatus>> allStatesForRollout = getStatusCountItemForRollout(
|
final Map<Long, List<TotalTargetCountActionStatus>> allStatesForRollout = getStatusCountItemForRollout(rolloutIds);
|
||||||
rolloutIds);
|
|
||||||
|
|
||||||
if (allStatesForRollout != null) {
|
if (allStatesForRollout != null) {
|
||||||
rollouts.forEach(rollout -> {
|
rollouts.forEach(rollout -> {
|
||||||
@@ -492,14 +494,13 @@ public class JpaRolloutManagement implements RolloutManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In case the given group is missing conditions or actions, they will be set
|
* In case the given group is missing conditions or actions, they will be set from the supplied default conditions.
|
||||||
* from the supplied default conditions.
|
|
||||||
*
|
*
|
||||||
* @param create group to check
|
* @param create group to check
|
||||||
* @param conditions default conditions and actions
|
* @param conditions default conditions and actions
|
||||||
*/
|
*/
|
||||||
private static JpaRolloutGroup prepareRolloutGroupWithDefaultConditions(final RolloutGroupCreate create,
|
private static JpaRolloutGroup prepareRolloutGroupWithDefaultConditions(
|
||||||
final RolloutGroupConditions conditions) {
|
final RolloutGroupCreate create, final RolloutGroupConditions conditions) {
|
||||||
final JpaRolloutGroup group = ((JpaRolloutGroupCreate) create).build();
|
final JpaRolloutGroup group = ((JpaRolloutGroupCreate) create).build();
|
||||||
|
|
||||||
if (group.getSuccessCondition() == null) {
|
if (group.getSuccessCondition() == null) {
|
||||||
|
|||||||
@@ -115,8 +115,8 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public List<SoftwareModule> create(final Collection<SoftwareModuleCreate> swModules) {
|
public List<SoftwareModule> create(final Collection<SoftwareModuleCreate> swModules) {
|
||||||
final List<JpaSoftwareModule> modulesToCreate = swModules.stream().map(JpaSoftwareModuleCreate.class::cast)
|
final List<JpaSoftwareModule> modulesToCreate = swModules.stream().map(JpaSoftwareModuleCreate.class::cast)
|
||||||
.map(JpaSoftwareModuleCreate::build).toList();
|
.map(JpaSoftwareModuleCreate::build).toList();
|
||||||
@@ -135,8 +135,8 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public SoftwareModule create(final SoftwareModuleCreate c) {
|
public SoftwareModule create(final SoftwareModuleCreate c) {
|
||||||
final JpaSoftwareModuleCreate create = (JpaSoftwareModuleCreate) c;
|
final JpaSoftwareModuleCreate create = (JpaSoftwareModuleCreate) c;
|
||||||
|
|
||||||
@@ -152,8 +152,8 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public SoftwareModule update(final SoftwareModuleUpdate u) {
|
public SoftwareModule update(final SoftwareModuleUpdate u) {
|
||||||
final GenericSoftwareModuleUpdate update = (GenericSoftwareModuleUpdate) u;
|
final GenericSoftwareModuleUpdate update = (GenericSoftwareModuleUpdate) u;
|
||||||
|
|
||||||
@@ -180,16 +180,16 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public void delete(final long id) {
|
public void delete(final long id) {
|
||||||
delete(List.of(id));
|
delete(List.of(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public void delete(final Collection<Long> ids) {
|
public void delete(final Collection<Long> ids) {
|
||||||
final List<JpaSoftwareModule> swModulesToDelete = softwareModuleRepository.findAllById(ids);
|
final List<JpaSoftwareModule> swModulesToDelete = softwareModuleRepository.findAllById(ids);
|
||||||
if (swModulesToDelete.size() < ids.size()) {
|
if (swModulesToDelete.size() < ids.size()) {
|
||||||
@@ -267,8 +267,8 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public List<SoftwareModuleMetadata> createMetaData(final Collection<SoftwareModuleMetadataCreate> create) {
|
public List<SoftwareModuleMetadata> createMetaData(final Collection<SoftwareModuleMetadataCreate> create) {
|
||||||
if (!create.isEmpty()) {
|
if (!create.isEmpty()) {
|
||||||
// check if all metadata entries refer to the same software module
|
// check if all metadata entries refer to the same software module
|
||||||
@@ -304,8 +304,8 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public SoftwareModuleMetadata createMetaData(final SoftwareModuleMetadataCreate c) {
|
public SoftwareModuleMetadata createMetaData(final SoftwareModuleMetadataCreate c) {
|
||||||
final JpaSoftwareModuleMetadataCreate create = (JpaSoftwareModuleMetadataCreate) c;
|
final JpaSoftwareModuleMetadataCreate create = (JpaSoftwareModuleMetadataCreate) c;
|
||||||
final Long id = create.getSoftwareModuleId();
|
final Long id = create.getSoftwareModuleId();
|
||||||
@@ -321,8 +321,8 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public void deleteMetaData(final long id, final String key) {
|
public void deleteMetaData(final long id, final String key) {
|
||||||
final JpaSoftwareModuleMetadata metadata = (JpaSoftwareModuleMetadata) getMetaDataBySoftwareModuleId(id,
|
final JpaSoftwareModuleMetadata metadata = (JpaSoftwareModuleMetadata) getMetaDataBySoftwareModuleId(id,
|
||||||
key).orElseThrow(() -> new EntityNotFoundException(SoftwareModuleMetadata.class, id, key));
|
key).orElseThrow(() -> new EntityNotFoundException(SoftwareModuleMetadata.class, id, key));
|
||||||
@@ -439,8 +439,8 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public void lock(final long id) {
|
public void lock(final long id) {
|
||||||
final JpaSoftwareModule softwareModule = softwareModuleRepository
|
final JpaSoftwareModule softwareModule = softwareModuleRepository
|
||||||
.findById(id)
|
.findById(id)
|
||||||
@@ -453,8 +453,8 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public void unlock(final long id) {
|
public void unlock(final long id) {
|
||||||
final JpaSoftwareModule softwareModule = softwareModuleRepository
|
final JpaSoftwareModule softwareModule = softwareModuleRepository
|
||||||
.findById(id)
|
.findById(id)
|
||||||
@@ -467,8 +467,8 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public SoftwareModuleMetadata updateMetaData(final SoftwareModuleMetadataUpdate u) {
|
public SoftwareModuleMetadata updateMetaData(final SoftwareModuleMetadataUpdate u) {
|
||||||
final GenericSoftwareModuleMetadataUpdate update = (GenericSoftwareModuleMetadataUpdate) u;
|
final GenericSoftwareModuleMetadataUpdate update = (GenericSoftwareModuleMetadataUpdate) u;
|
||||||
|
|
||||||
|
|||||||
@@ -79,8 +79,8 @@ public class JpaSoftwareModuleTypeManagement implements SoftwareModuleTypeManage
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public List<SoftwareModuleType> create(final Collection<SoftwareModuleTypeCreate> c) {
|
public List<SoftwareModuleType> create(final Collection<SoftwareModuleTypeCreate> c) {
|
||||||
final List<JpaSoftwareModuleType> creates = c.stream().map(JpaSoftwareModuleTypeCreate.class::cast)
|
final List<JpaSoftwareModuleType> creates = c.stream().map(JpaSoftwareModuleTypeCreate.class::cast)
|
||||||
.map(JpaSoftwareModuleTypeCreate::build).toList();
|
.map(JpaSoftwareModuleTypeCreate::build).toList();
|
||||||
@@ -90,8 +90,8 @@ public class JpaSoftwareModuleTypeManagement implements SoftwareModuleTypeManage
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public SoftwareModuleType create(final SoftwareModuleTypeCreate c) {
|
public SoftwareModuleType create(final SoftwareModuleTypeCreate c) {
|
||||||
final JpaSoftwareModuleTypeCreate create = (JpaSoftwareModuleTypeCreate) c;
|
final JpaSoftwareModuleTypeCreate create = (JpaSoftwareModuleTypeCreate) c;
|
||||||
|
|
||||||
@@ -100,8 +100,8 @@ public class JpaSoftwareModuleTypeManagement implements SoftwareModuleTypeManage
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public SoftwareModuleType update(final SoftwareModuleTypeUpdate u) {
|
public SoftwareModuleType update(final SoftwareModuleTypeUpdate u) {
|
||||||
final GenericSoftwareModuleTypeUpdate update = (GenericSoftwareModuleTypeUpdate) u;
|
final GenericSoftwareModuleTypeUpdate update = (GenericSoftwareModuleTypeUpdate) u;
|
||||||
|
|
||||||
@@ -121,8 +121,8 @@ public class JpaSoftwareModuleTypeManagement implements SoftwareModuleTypeManage
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public void delete(final long id) {
|
public void delete(final long id) {
|
||||||
final JpaSoftwareModuleType toDelete = softwareModuleTypeRepository.findById(id)
|
final JpaSoftwareModuleType toDelete = softwareModuleTypeRepository.findById(id)
|
||||||
.orElseThrow(() -> new EntityNotFoundException(SoftwareModuleType.class, id));
|
.orElseThrow(() -> new EntityNotFoundException(SoftwareModuleType.class, id));
|
||||||
@@ -132,8 +132,8 @@ public class JpaSoftwareModuleTypeManagement implements SoftwareModuleTypeManage
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public void delete(final Collection<Long> ids) {
|
public void delete(final Collection<Long> ids) {
|
||||||
softwareModuleTypeRepository
|
softwareModuleTypeRepository
|
||||||
.findAll(AccessController.Operation.DELETE, softwareModuleTypeRepository.byIdsSpec(ids))
|
.findAll(AccessController.Operation.DELETE, softwareModuleTypeRepository.byIdsSpec(ids))
|
||||||
|
|||||||
@@ -153,8 +153,8 @@ public class JpaSystemManagement implements CurrentTenantCacheKeyGenerator, Syst
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public void deleteTenant(final String t) {
|
public void deleteTenant(final String t) {
|
||||||
if (artifactRepository == null) {
|
if (artifactRepository == null) {
|
||||||
throw new IllegalStateException("Artifact repository is not available. Can't delete tenant.");
|
throw new IllegalStateException("Artifact repository is not available. Can't delete tenant.");
|
||||||
@@ -278,8 +278,8 @@ public class JpaSystemManagement implements CurrentTenantCacheKeyGenerator, Syst
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public TenantMetaData updateTenantMetadata(final long defaultDsType) {
|
public TenantMetaData updateTenantMetadata(final long defaultDsType) {
|
||||||
final JpaTenantMetaData data = (JpaTenantMetaData) getTenantMetadata();
|
final JpaTenantMetaData data = (JpaTenantMetaData) getTenantMetadata();
|
||||||
|
|
||||||
|
|||||||
@@ -106,8 +106,8 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public TargetFilterQuery create(final TargetFilterQueryCreate c) {
|
public TargetFilterQuery create(final TargetFilterQueryCreate c) {
|
||||||
final JpaTargetFilterQueryCreate create = (JpaTargetFilterQueryCreate) c;
|
final JpaTargetFilterQueryCreate create = (JpaTargetFilterQueryCreate) c;
|
||||||
|
|
||||||
@@ -129,8 +129,8 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public void delete(final long targetFilterQueryId) {
|
public void delete(final long targetFilterQueryId) {
|
||||||
if (!targetFilterQueryRepository.existsById(targetFilterQueryId)) {
|
if (!targetFilterQueryRepository.existsById(targetFilterQueryId)) {
|
||||||
throw new EntityNotFoundException(TargetFilterQuery.class, targetFilterQueryId);
|
throw new EntityNotFoundException(TargetFilterQuery.class, targetFilterQueryId);
|
||||||
|
|||||||
@@ -236,8 +236,8 @@ public class JpaTargetManagement implements TargetManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public Target create(final TargetCreate c) {
|
public Target create(final TargetCreate c) {
|
||||||
final JpaTargetCreate create = (JpaTargetCreate) c;
|
final JpaTargetCreate create = (JpaTargetCreate) c;
|
||||||
return targetRepository.save(AccessController.Operation.CREATE, create.build());
|
return targetRepository.save(AccessController.Operation.CREATE, create.build());
|
||||||
@@ -245,8 +245,8 @@ public class JpaTargetManagement implements TargetManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public List<Target> create(final Collection<TargetCreate> targets) {
|
public List<Target> create(final Collection<TargetCreate> targets) {
|
||||||
final List<JpaTarget> targetList = targets.stream().map(JpaTargetCreate.class::cast).map(JpaTargetCreate::build)
|
final List<JpaTarget> targetList = targets.stream().map(JpaTargetCreate.class::cast).map(JpaTargetCreate::build)
|
||||||
.toList();
|
.toList();
|
||||||
@@ -255,8 +255,8 @@ public class JpaTargetManagement implements TargetManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public void delete(final Collection<Long> ids) {
|
public void delete(final Collection<Long> ids) {
|
||||||
final List<JpaTarget> targets = targetRepository.findAllById(ids);
|
final List<JpaTarget> targets = targetRepository.findAllById(ids);
|
||||||
if (targets.size() < ids.size()) {
|
if (targets.size() < ids.size()) {
|
||||||
@@ -269,8 +269,8 @@ public class JpaTargetManagement implements TargetManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public void deleteByControllerID(final String controllerId) {
|
public void deleteByControllerID(final String controllerId) {
|
||||||
targetRepository.delete(getByControllerIdAndThrowIfNotFound(controllerId));
|
targetRepository.delete(getByControllerIdAndThrowIfNotFound(controllerId));
|
||||||
}
|
}
|
||||||
@@ -500,8 +500,8 @@ public class JpaTargetManagement implements TargetManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public TargetTypeAssignmentResult assignType(final Collection<String> controllerIds, final Long typeId) {
|
public TargetTypeAssignmentResult assignType(final Collection<String> controllerIds, final Long typeId) {
|
||||||
final JpaTargetType type = targetTypeRepository.findById(typeId)
|
final JpaTargetType type = targetTypeRepository.findById(typeId)
|
||||||
.orElseThrow(() -> new EntityNotFoundException(TargetType.class, typeId));
|
.orElseThrow(() -> new EntityNotFoundException(TargetType.class, typeId));
|
||||||
@@ -525,8 +525,8 @@ public class JpaTargetManagement implements TargetManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public TargetTypeAssignmentResult unassignType(final Collection<String> controllerIds) {
|
public TargetTypeAssignmentResult unassignType(final Collection<String> controllerIds) {
|
||||||
final List<JpaTarget> allTargets = findTargetsByInSpecification(controllerIds, null);
|
final List<JpaTarget> allTargets = findTargetsByInSpecification(controllerIds, null);
|
||||||
|
|
||||||
@@ -543,8 +543,8 @@ public class JpaTargetManagement implements TargetManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public List<Target> assignTag(final Collection<String> controllerIds, final long targetTagId,
|
public List<Target> assignTag(final Collection<String> controllerIds, final long targetTagId,
|
||||||
final Consumer<Collection<String>> notFoundHandler) {
|
final Consumer<Collection<String>> notFoundHandler) {
|
||||||
return updateTag(controllerIds, targetTagId, notFoundHandler, (tag, target) -> {
|
return updateTag(controllerIds, targetTagId, notFoundHandler, (tag, target) -> {
|
||||||
@@ -559,8 +559,8 @@ public class JpaTargetManagement implements TargetManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public List<Target> unassignTag(final Collection<String> controllerIds, final long targetTagId,
|
public List<Target> unassignTag(final Collection<String> controllerIds, final long targetTagId,
|
||||||
final Consumer<Collection<String>> notFoundHandler) {
|
final Consumer<Collection<String>> notFoundHandler) {
|
||||||
return updateTag(controllerIds, targetTagId, notFoundHandler, (tag, target) -> {
|
return updateTag(controllerIds, targetTagId, notFoundHandler, (tag, target) -> {
|
||||||
@@ -575,8 +575,8 @@ public class JpaTargetManagement implements TargetManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public Target unassignType(final String controllerId) {
|
public Target unassignType(final String controllerId) {
|
||||||
final JpaTarget target = getByControllerIdAndThrowIfNotFound(controllerId);
|
final JpaTarget target = getByControllerIdAndThrowIfNotFound(controllerId);
|
||||||
target.setTargetType(null);
|
target.setTargetType(null);
|
||||||
@@ -585,8 +585,8 @@ public class JpaTargetManagement implements TargetManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public Target assignType(final String controllerId, final Long targetTypeId) {
|
public Target assignType(final String controllerId, final Long targetTypeId) {
|
||||||
final JpaTarget target = getByControllerIdAndThrowIfNotFound(controllerId);
|
final JpaTarget target = getByControllerIdAndThrowIfNotFound(controllerId);
|
||||||
|
|
||||||
@@ -601,8 +601,8 @@ public class JpaTargetManagement implements TargetManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public Target update(final TargetUpdate u) {
|
public Target update(final TargetUpdate u) {
|
||||||
final JpaTargetUpdate update = (JpaTargetUpdate) u;
|
final JpaTargetUpdate update = (JpaTargetUpdate) u;
|
||||||
|
|
||||||
@@ -708,8 +708,8 @@ public class JpaTargetManagement implements TargetManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public List<TargetMetadata> createMetaData(final String controllerId, final Collection<MetaData> md) {
|
public List<TargetMetadata> createMetaData(final String controllerId, final Collection<MetaData> md) {
|
||||||
final JpaTarget target = getByControllerIdAndThrowIfNotFound(controllerId);
|
final JpaTarget target = getByControllerIdAndThrowIfNotFound(controllerId);
|
||||||
|
|
||||||
@@ -735,8 +735,8 @@ public class JpaTargetManagement implements TargetManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public void deleteMetaData(final String controllerId, final String key) {
|
public void deleteMetaData(final String controllerId, final String key) {
|
||||||
final JpaTargetMetadata metadata = (JpaTargetMetadata) getMetaDataByControllerId(controllerId, key)
|
final JpaTargetMetadata metadata = (JpaTargetMetadata) getMetaDataByControllerId(controllerId, key)
|
||||||
.orElseThrow(() -> new EntityNotFoundException(TargetMetadata.class, controllerId, key));
|
.orElseThrow(() -> new EntityNotFoundException(TargetMetadata.class, controllerId, key));
|
||||||
@@ -791,8 +791,8 @@ public class JpaTargetManagement implements TargetManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public TargetMetadata updateMetadata(final String controllerId, final MetaData md) {
|
public TargetMetadata updateMetadata(final String controllerId, final MetaData md) {
|
||||||
|
|
||||||
// check if exists otherwise throw entity not found exception
|
// check if exists otherwise throw entity not found exception
|
||||||
@@ -815,8 +815,8 @@ public class JpaTargetManagement implements TargetManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public TargetTagAssignmentResult toggleTagAssignment(final Collection<String> controllerIds, final String tagName) {
|
public TargetTagAssignmentResult toggleTagAssignment(final Collection<String> controllerIds, final String tagName) {
|
||||||
final TargetTag tag = targetTagRepository
|
final TargetTag tag = targetTagRepository
|
||||||
.findByNameEquals(tagName)
|
.findByNameEquals(tagName)
|
||||||
@@ -852,8 +852,8 @@ public class JpaTargetManagement implements TargetManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public Target unassignTag(final String controllerId, final long targetTagId) {
|
public Target unassignTag(final String controllerId, final long targetTagId) {
|
||||||
final JpaTarget target = getByControllerIdAndThrowIfNotFound(controllerId);
|
final JpaTarget target = getByControllerIdAndThrowIfNotFound(controllerId);
|
||||||
|
|
||||||
|
|||||||
@@ -67,8 +67,8 @@ public class JpaTargetTagManagement implements TargetTagManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public TargetTag create(final TagCreate c) {
|
public TargetTag create(final TagCreate c) {
|
||||||
final JpaTagCreate create = (JpaTagCreate) c;
|
final JpaTagCreate create = (JpaTagCreate) c;
|
||||||
|
|
||||||
@@ -77,8 +77,8 @@ public class JpaTargetTagManagement implements TargetTagManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public List<TargetTag> create(final Collection<TagCreate> tt) {
|
public List<TargetTag> create(final Collection<TagCreate> tt) {
|
||||||
final List<JpaTargetTag> targetTagList = tt.stream().map(JpaTagCreate.class::cast)
|
final List<JpaTargetTag> targetTagList = tt.stream().map(JpaTagCreate.class::cast)
|
||||||
.map(JpaTagCreate::buildTargetTag).toList();
|
.map(JpaTagCreate::buildTargetTag).toList();
|
||||||
@@ -88,8 +88,8 @@ public class JpaTargetTagManagement implements TargetTagManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public void delete(final String targetTagName) {
|
public void delete(final String targetTagName) {
|
||||||
targetTagRepository.delete(
|
targetTagRepository.delete(
|
||||||
targetTagRepository
|
targetTagRepository
|
||||||
@@ -125,8 +125,8 @@ public class JpaTargetTagManagement implements TargetTagManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public TargetTag update(final TagUpdate u) {
|
public TargetTag update(final TagUpdate u) {
|
||||||
final GenericTagUpdate update = (GenericTagUpdate) u;
|
final GenericTagUpdate update = (GenericTagUpdate) u;
|
||||||
|
|
||||||
|
|||||||
@@ -106,8 +106,8 @@ public class JpaTargetTypeManagement implements TargetTypeManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public TargetType create(final TargetTypeCreate create) {
|
public TargetType create(final TargetTypeCreate create) {
|
||||||
final JpaTargetType typeCreate = ((JpaTargetTypeCreate) create).build();
|
final JpaTargetType typeCreate = ((JpaTargetTypeCreate) create).build();
|
||||||
return targetTypeRepository.save(AccessController.Operation.CREATE, typeCreate);
|
return targetTypeRepository.save(AccessController.Operation.CREATE, typeCreate);
|
||||||
@@ -115,8 +115,8 @@ public class JpaTargetTypeManagement implements TargetTypeManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public List<TargetType> create(final Collection<TargetTypeCreate> creates) {
|
public List<TargetType> create(final Collection<TargetTypeCreate> creates) {
|
||||||
final List<JpaTargetType> typeCreate =
|
final List<JpaTargetType> typeCreate =
|
||||||
creates.stream().map(create -> ((JpaTargetTypeCreate) create).build()).toList();
|
creates.stream().map(create -> ((JpaTargetTypeCreate) create).build()).toList();
|
||||||
@@ -125,8 +125,8 @@ public class JpaTargetTypeManagement implements TargetTypeManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public void delete(final Long id) {
|
public void delete(final Long id) {
|
||||||
getByIdAndThrowIfNotFound(id);
|
getByIdAndThrowIfNotFound(id);
|
||||||
|
|
||||||
@@ -168,8 +168,8 @@ public class JpaTargetTypeManagement implements TargetTypeManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public TargetType update(final TargetTypeUpdate update) {
|
public TargetType update(final TargetTypeUpdate update) {
|
||||||
final GenericTargetTypeUpdate typeUpdate = (GenericTargetTypeUpdate) update;
|
final GenericTargetTypeUpdate typeUpdate = (GenericTargetTypeUpdate) update;
|
||||||
|
|
||||||
@@ -184,8 +184,8 @@ public class JpaTargetTypeManagement implements TargetTypeManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public TargetType assignCompatibleDistributionSetTypes(final long id,
|
public TargetType assignCompatibleDistributionSetTypes(final long id,
|
||||||
final Collection<Long> distributionSetTypeIds) {
|
final Collection<Long> distributionSetTypeIds) {
|
||||||
final Collection<JpaDistributionSetType> dsTypes = distributionSetTypeRepository
|
final Collection<JpaDistributionSetType> dsTypes = distributionSetTypeRepository
|
||||||
@@ -205,8 +205,8 @@ public class JpaTargetTypeManagement implements TargetTypeManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public TargetType unassignDistributionSetType(final long id, final long distributionSetTypeId) {
|
public TargetType unassignDistributionSetType(final long id, final long distributionSetTypeId) {
|
||||||
final JpaTargetType type = getByIdAndThrowIfNotFound(id);
|
final JpaTargetType type = getByIdAndThrowIfNotFound(id);
|
||||||
assertDistributionSetTypeExists(distributionSetTypeId);
|
assertDistributionSetTypeExists(distributionSetTypeId);
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import org.eclipse.hawkbit.im.authentication.SpPermission;
|
import org.eclipse.hawkbit.im.authentication.SpPermission;
|
||||||
import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
|
import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
|
||||||
import org.eclipse.hawkbit.repository.exception.InsufficientPermissionException;
|
import org.eclipse.hawkbit.repository.exception.InsufficientPermissionException;
|
||||||
|
import org.eclipse.hawkbit.repository.exception.TenantConfigurationValidatorException;
|
||||||
import org.eclipse.hawkbit.repository.exception.TenantConfigurationValueChangeNotAllowedException;
|
import org.eclipse.hawkbit.repository.exception.TenantConfigurationValueChangeNotAllowedException;
|
||||||
import org.eclipse.hawkbit.repository.jpa.configuration.Constants;
|
import org.eclipse.hawkbit.repository.jpa.configuration.Constants;
|
||||||
import org.eclipse.hawkbit.repository.jpa.executor.AfterTransactionCommitExecutor;
|
import org.eclipse.hawkbit.repository.jpa.executor.AfterTransactionCommitExecutor;
|
||||||
@@ -35,7 +36,6 @@ import org.eclipse.hawkbit.repository.model.helper.SystemSecurityContextHolder;
|
|||||||
import org.eclipse.hawkbit.security.SystemSecurityContext;
|
import org.eclipse.hawkbit.security.SystemSecurityContext;
|
||||||
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties;
|
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties;
|
||||||
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties.TenantConfigurationKey;
|
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties.TenantConfigurationKey;
|
||||||
import org.eclipse.hawkbit.repository.exception.TenantConfigurationValidatorException;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.cache.Cache;
|
import org.springframework.cache.Cache;
|
||||||
import org.springframework.cache.CacheManager;
|
import org.springframework.cache.CacheManager;
|
||||||
@@ -73,8 +73,8 @@ public class JpaTenantConfigurationManagement implements TenantConfigurationMana
|
|||||||
@Override
|
@Override
|
||||||
@CacheEvict(value = "tenantConfiguration", key = "#configurationKeyName")
|
@CacheEvict(value = "tenantConfiguration", key = "#configurationKeyName")
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public <T extends Serializable> TenantConfigurationValue<T> addOrUpdateConfiguration(
|
public <T extends Serializable> TenantConfigurationValue<T> addOrUpdateConfiguration(
|
||||||
final String configurationKeyName, final T value) {
|
final String configurationKeyName, final T value) {
|
||||||
return addOrUpdateConfiguration0(Collections.singletonMap(configurationKeyName, value)).values().iterator().next();
|
return addOrUpdateConfiguration0(Collections.singletonMap(configurationKeyName, value)).values().iterator().next();
|
||||||
@@ -82,8 +82,8 @@ public class JpaTenantConfigurationManagement implements TenantConfigurationMana
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public <T extends Serializable> Map<String, TenantConfigurationValue<T>> addOrUpdateConfiguration(Map<String, T> configurations) {
|
public <T extends Serializable> Map<String, TenantConfigurationValue<T>> addOrUpdateConfiguration(Map<String, T> configurations) {
|
||||||
// Register a callback to be invoked after the transaction is committed - for cache eviction
|
// Register a callback to be invoked after the transaction is committed - for cache eviction
|
||||||
afterCommitExecutor.afterCommit(() -> {
|
afterCommitExecutor.afterCommit(() -> {
|
||||||
@@ -99,8 +99,8 @@ public class JpaTenantConfigurationManagement implements TenantConfigurationMana
|
|||||||
@Override
|
@Override
|
||||||
@CacheEvict(value = "tenantConfiguration", key = "#configurationKeyName")
|
@CacheEvict(value = "tenantConfiguration", key = "#configurationKeyName")
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public void deleteConfiguration(final String configurationKeyName) {
|
public void deleteConfiguration(final String configurationKeyName) {
|
||||||
tenantConfigurationRepository.deleteByKey(configurationKeyName);
|
tenantConfigurationRepository.deleteByKey(configurationKeyName);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,13 +28,10 @@ public class JpaTenantStatsManagement implements TenantStatsManagement {
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private TargetRepository targetRepository;
|
private TargetRepository targetRepository;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private LocalArtifactRepository artifactRepository;
|
private LocalArtifactRepository artifactRepository;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ActionRepository actionRepository;
|
private ActionRepository actionRepository;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private TenantAware tenantAware;
|
private TenantAware tenantAware;
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,8 @@ import org.eclipse.hawkbit.repository.model.helper.EventPublisherHolder;
|
|||||||
*/
|
*/
|
||||||
public class OfflineDsAssignmentStrategy extends AbstractDsAssignmentStrategy {
|
public class OfflineDsAssignmentStrategy extends AbstractDsAssignmentStrategy {
|
||||||
|
|
||||||
OfflineDsAssignmentStrategy(final TargetRepository targetRepository,
|
OfflineDsAssignmentStrategy(
|
||||||
|
final TargetRepository targetRepository,
|
||||||
final AfterTransactionCommitExecutor afterCommit, final EventPublisherHolder eventPublisherHolder,
|
final AfterTransactionCommitExecutor afterCommit, final EventPublisherHolder eventPublisherHolder,
|
||||||
final ActionRepository actionRepository, final ActionStatusRepository actionStatusRepository,
|
final ActionRepository actionRepository, final ActionStatusRepository actionStatusRepository,
|
||||||
final QuotaManagement quotaManagement, final BooleanSupplier multiAssignmentsConfig,
|
final QuotaManagement quotaManagement, final BooleanSupplier multiAssignmentsConfig,
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ import jakarta.persistence.Version;
|
|||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import org.eclipse.hawkbit.tenancy.TenantAwareAuthenticationDetails;
|
|
||||||
import org.eclipse.hawkbit.repository.model.BaseEntity;
|
import org.eclipse.hawkbit.repository.model.BaseEntity;
|
||||||
|
import org.eclipse.hawkbit.tenancy.TenantAwareAuthenticationDetails;
|
||||||
import org.springframework.data.annotation.CreatedBy;
|
import org.springframework.data.annotation.CreatedBy;
|
||||||
import org.springframework.data.annotation.CreatedDate;
|
import org.springframework.data.annotation.CreatedDate;
|
||||||
import org.springframework.data.annotation.LastModifiedBy;
|
import org.springframework.data.annotation.LastModifiedBy;
|
||||||
@@ -96,19 +96,22 @@ public abstract class AbstractJpaBaseEntity implements BaseEntity {
|
|||||||
return optLockRevision;
|
return optLockRevision;
|
||||||
}
|
}
|
||||||
|
|
||||||
@CreatedBy
|
@LastModifiedDate
|
||||||
public void setCreatedBy(final String createdBy) {
|
public void setLastModifiedAt(final long lastModifiedAt) {
|
||||||
if (isController()) {
|
if (isController()) {
|
||||||
this.createdBy = "CONTROLLER_PLUG_AND_PLAY";
|
|
||||||
|
|
||||||
// In general modification audit entry is not changed by the
|
|
||||||
// controller. However, we want to stay consistent with
|
|
||||||
// EnableJpaAuditing#modifyOnCreate=true.
|
|
||||||
this.lastModifiedBy = this.createdBy;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.createdBy = createdBy;
|
this.lastModifiedAt = lastModifiedAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
@LastModifiedBy
|
||||||
|
public void setLastModifiedBy(final String lastModifiedBy) {
|
||||||
|
if (isController()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.lastModifiedBy = lastModifiedBy;
|
||||||
}
|
}
|
||||||
|
|
||||||
@CreatedDate
|
@CreatedDate
|
||||||
@@ -123,22 +126,19 @@ public abstract class AbstractJpaBaseEntity implements BaseEntity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@LastModifiedBy
|
@CreatedBy
|
||||||
public void setLastModifiedBy(final String lastModifiedBy) {
|
public void setCreatedBy(final String createdBy) {
|
||||||
if (isController()) {
|
if (isController()) {
|
||||||
|
this.createdBy = "CONTROLLER_PLUG_AND_PLAY";
|
||||||
|
|
||||||
|
// In general modification audit entry is not changed by the
|
||||||
|
// controller. However, we want to stay consistent with
|
||||||
|
// EnableJpaAuditing#modifyOnCreate=true.
|
||||||
|
this.lastModifiedBy = this.createdBy;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.lastModifiedBy = lastModifiedBy;
|
this.createdBy = createdBy;
|
||||||
}
|
|
||||||
|
|
||||||
@LastModifiedDate
|
|
||||||
public void setLastModifiedAt(final long lastModifiedAt) {
|
|
||||||
if (isController()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.lastModifiedAt = lastModifiedAt;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -201,7 +201,8 @@ public abstract class AbstractJpaBaseEntity implements BaseEntity {
|
|||||||
|
|
||||||
private boolean isController() {
|
private boolean isController() {
|
||||||
return SecurityContextHolder.getContext().getAuthentication() != null
|
return SecurityContextHolder.getContext().getAuthentication() != null
|
||||||
&& SecurityContextHolder.getContext().getAuthentication().getDetails() instanceof TenantAwareAuthenticationDetails tenantAwareDetails
|
&& SecurityContextHolder.getContext().getAuthentication()
|
||||||
|
.getDetails() instanceof TenantAwareAuthenticationDetails tenantAwareDetails
|
||||||
&& tenantAwareDetails.isController();
|
&& tenantAwareDetails.isController();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -11,7 +11,6 @@ package org.eclipse.hawkbit.repository.jpa.model;
|
|||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
import jakarta.persistence.CascadeType;
|
|
||||||
import jakarta.persistence.Column;
|
import jakarta.persistence.Column;
|
||||||
import jakarta.persistence.ConstraintMode;
|
import jakarta.persistence.ConstraintMode;
|
||||||
import jakarta.persistence.EmbeddedId;
|
import jakarta.persistence.EmbeddedId;
|
||||||
|
|||||||
@@ -93,87 +93,42 @@ public class JpaAction extends AbstractJpaTenantAwareBaseEntity implements Actio
|
|||||||
|
|
||||||
@Column(name = "active")
|
@Column(name = "active")
|
||||||
private boolean active;
|
private boolean active;
|
||||||
|
|
||||||
@Converter
|
|
||||||
public static class ActionTypeConverter extends MapAttributeConverter<ActionType, Integer> {
|
|
||||||
|
|
||||||
public ActionTypeConverter() {
|
|
||||||
super(Map.of(
|
|
||||||
ActionType.FORCED, 0,
|
|
||||||
ActionType.SOFT, 1,
|
|
||||||
ActionType.TIMEFORCED, 2,
|
|
||||||
ActionType.DOWNLOAD_ONLY, 3
|
|
||||||
), null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@Column(name = "action_type", nullable = false)
|
@Column(name = "action_type", nullable = false)
|
||||||
@Convert(converter = ActionTypeConverter.class)
|
@Convert(converter = ActionTypeConverter.class)
|
||||||
@NotNull
|
@NotNull
|
||||||
private ActionType actionType;
|
private ActionType actionType;
|
||||||
|
|
||||||
@Column(name = "forced_time")
|
@Column(name = "forced_time")
|
||||||
private long forcedTime;
|
private long forcedTime;
|
||||||
|
|
||||||
@Column(name = "weight")
|
@Column(name = "weight")
|
||||||
@Min(Action.WEIGHT_MIN)
|
@Min(Action.WEIGHT_MIN)
|
||||||
@Max(Action.WEIGHT_MAX)
|
@Max(Action.WEIGHT_MAX)
|
||||||
private Integer weight;
|
private Integer weight;
|
||||||
|
|
||||||
@Converter
|
|
||||||
public static class StatusConverter extends MapAttributeConverter<Status, Integer> {
|
|
||||||
|
|
||||||
public StatusConverter() {
|
|
||||||
super(new HashMap<>() {{
|
|
||||||
put(Status.FINISHED, 0);
|
|
||||||
put(Status.ERROR, 1);
|
|
||||||
put(Status.WARNING, 2);
|
|
||||||
put(Status.RUNNING, 3);
|
|
||||||
put(Status.CANCELED, 4);
|
|
||||||
put(Status.CANCELING, 5);
|
|
||||||
put(Status.RETRIEVED, 6);
|
|
||||||
put(Status.DOWNLOAD, 7);
|
|
||||||
put(Status.SCHEDULED, 8);
|
|
||||||
put(Status.CANCEL_REJECTED, 9);
|
|
||||||
put(Status.DOWNLOADED, 10);
|
|
||||||
put(Status.WAIT_FOR_CONFIRMATION, 11);
|
|
||||||
}}, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@Column(name = "status", nullable = false)
|
@Column(name = "status", nullable = false)
|
||||||
@Convert(converter = StatusConverter.class)
|
@Convert(converter = StatusConverter.class)
|
||||||
@NotNull
|
@NotNull
|
||||||
private Status status;
|
private Status status;
|
||||||
|
|
||||||
@OneToMany(mappedBy = "action", targetEntity = JpaActionStatus.class, fetch = FetchType.LAZY, cascade = { CascadeType.REMOVE })
|
@OneToMany(mappedBy = "action", targetEntity = JpaActionStatus.class, fetch = FetchType.LAZY, cascade = { CascadeType.REMOVE })
|
||||||
private List<JpaActionStatus> actionStatus;
|
private List<JpaActionStatus> actionStatus;
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
@ManyToOne(fetch = FetchType.LAZY)
|
||||||
@JoinColumn(
|
@JoinColumn(
|
||||||
name = "rolloutgroup", updatable = false,
|
name = "rolloutgroup", updatable = false,
|
||||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_action_rolloutgroup"))
|
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_action_rolloutgroup"))
|
||||||
private JpaRolloutGroup rolloutGroup;
|
private JpaRolloutGroup rolloutGroup;
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
@ManyToOne(fetch = FetchType.LAZY)
|
||||||
@JoinColumn(
|
@JoinColumn(
|
||||||
name = "rollout", updatable = false,
|
name = "rollout", updatable = false,
|
||||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_action_rollout"))
|
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_action_rollout"))
|
||||||
private JpaRollout rollout;
|
private JpaRollout rollout;
|
||||||
|
|
||||||
@Column(name = "maintenance_cron_schedule", updatable = false, length = Action.MAINTENANCE_WINDOW_SCHEDULE_LENGTH)
|
@Column(name = "maintenance_cron_schedule", updatable = false, length = Action.MAINTENANCE_WINDOW_SCHEDULE_LENGTH)
|
||||||
private String maintenanceWindowSchedule;
|
private String maintenanceWindowSchedule;
|
||||||
|
|
||||||
@Column(name = "maintenance_duration", updatable = false, length = Action.MAINTENANCE_WINDOW_DURATION_LENGTH)
|
@Column(name = "maintenance_duration", updatable = false, length = Action.MAINTENANCE_WINDOW_DURATION_LENGTH)
|
||||||
private String maintenanceWindowDuration;
|
private String maintenanceWindowDuration;
|
||||||
|
|
||||||
@Column(name = "maintenance_time_zone", updatable = false, length = Action.MAINTENANCE_WINDOW_TIMEZONE_LENGTH)
|
@Column(name = "maintenance_time_zone", updatable = false, length = Action.MAINTENANCE_WINDOW_TIMEZONE_LENGTH)
|
||||||
private String maintenanceWindowTimeZone;
|
private String maintenanceWindowTimeZone;
|
||||||
|
|
||||||
@Column(name = "external_ref", length = Action.EXTERNAL_REF_MAX_LENGTH)
|
@Column(name = "external_ref", length = Action.EXTERNAL_REF_MAX_LENGTH)
|
||||||
private String externalRef;
|
private String externalRef;
|
||||||
|
|
||||||
@Column(name = "initiated_by", updatable = false, nullable = false, length = USERNAME_FIELD_LENGTH)
|
@Column(name = "initiated_by", updatable = false, nullable = false, length = USERNAME_FIELD_LENGTH)
|
||||||
private String initiatedBy;
|
private String initiatedBy;
|
||||||
|
|
||||||
@Column(name = "last_action_status_code", nullable = true, updatable = true)
|
@Column(name = "last_action_status_code", nullable = true, updatable = true)
|
||||||
private Integer lastActionStatusCode;
|
private Integer lastActionStatusCode;
|
||||||
|
|
||||||
@@ -423,4 +378,38 @@ public class JpaAction extends AbstractJpaTenantAwareBaseEntity implements Actio
|
|||||||
return getMaintenanceWindowStartTime()
|
return getMaintenanceWindowStartTime()
|
||||||
.map(start -> start.plus(MaintenanceScheduleHelper.convertToISODuration(maintenanceWindowDuration)));
|
.map(start -> start.plus(MaintenanceScheduleHelper.convertToISODuration(maintenanceWindowDuration)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Converter
|
||||||
|
public static class ActionTypeConverter extends MapAttributeConverter<ActionType, Integer> {
|
||||||
|
|
||||||
|
public ActionTypeConverter() {
|
||||||
|
super(Map.of(
|
||||||
|
ActionType.FORCED, 0,
|
||||||
|
ActionType.SOFT, 1,
|
||||||
|
ActionType.TIMEFORCED, 2,
|
||||||
|
ActionType.DOWNLOAD_ONLY, 3
|
||||||
|
), null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Converter
|
||||||
|
public static class StatusConverter extends MapAttributeConverter<Status, Integer> {
|
||||||
|
|
||||||
|
public StatusConverter() {
|
||||||
|
super(new HashMap<>() {{
|
||||||
|
put(Status.FINISHED, 0);
|
||||||
|
put(Status.ERROR, 1);
|
||||||
|
put(Status.WARNING, 2);
|
||||||
|
put(Status.RUNNING, 3);
|
||||||
|
put(Status.CANCELED, 4);
|
||||||
|
put(Status.CANCELING, 5);
|
||||||
|
put(Status.RETRIEVED, 6);
|
||||||
|
put(Status.DOWNLOAD, 7);
|
||||||
|
put(Status.SCHEDULED, 8);
|
||||||
|
put(Status.CANCEL_REJECTED, 9);
|
||||||
|
put(Status.DOWNLOADED, 10);
|
||||||
|
put(Status.WAIT_FOR_CONFIRMATION, 11);
|
||||||
|
}}, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -58,7 +58,8 @@ public class JpaActionStatus extends AbstractJpaTenantAwareBaseEntity implements
|
|||||||
|
|
||||||
private static final int MESSAGE_ENTRY_LENGTH = 512;
|
private static final int MESSAGE_ENTRY_LENGTH = 512;
|
||||||
|
|
||||||
@Setter @Getter
|
@Setter
|
||||||
|
@Getter
|
||||||
@Column(name = "target_occurred_at", nullable = false, updatable = false)
|
@Column(name = "target_occurred_at", nullable = false, updatable = false)
|
||||||
private long occurredAt;
|
private long occurredAt;
|
||||||
|
|
||||||
@@ -69,7 +70,8 @@ public class JpaActionStatus extends AbstractJpaTenantAwareBaseEntity implements
|
|||||||
@NotNull
|
@NotNull
|
||||||
private JpaAction action;
|
private JpaAction action;
|
||||||
|
|
||||||
@Setter @Getter
|
@Setter
|
||||||
|
@Getter
|
||||||
@Column(name = "status", nullable = false, updatable = false)
|
@Column(name = "status", nullable = false, updatable = false)
|
||||||
@Convert(converter = JpaAction.StatusConverter.class)
|
@Convert(converter = JpaAction.StatusConverter.class)
|
||||||
@NotNull
|
@NotNull
|
||||||
|
|||||||
@@ -108,7 +108,8 @@ public class JpaDistributionSet extends AbstractJpaNamedVersionedEntity implemen
|
|||||||
private Set<DistributionSetTag> tags;
|
private Set<DistributionSetTag> tags;
|
||||||
|
|
||||||
@ToString.Exclude
|
@ToString.Exclude
|
||||||
@OneToMany(mappedBy = "distributionSet", fetch = FetchType.LAZY, cascade = { CascadeType.REMOVE }, targetEntity = JpaDistributionSetMetadata.class)
|
@OneToMany(mappedBy = "distributionSet", fetch = FetchType.LAZY, cascade = {
|
||||||
|
CascadeType.REMOVE }, targetEntity = JpaDistributionSetMetadata.class)
|
||||||
private List<DistributionSetMetadata> metadata;
|
private List<DistributionSetMetadata> metadata;
|
||||||
|
|
||||||
@Column(name = "complete")
|
@Column(name = "complete")
|
||||||
|
|||||||
@@ -56,7 +56,8 @@ public class JpaDistributionSetType extends AbstractJpaTypeEntity implements Dis
|
|||||||
@Serial
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@OneToMany(mappedBy = "dsType", targetEntity = DistributionSetTypeElement.class, fetch = FetchType.EAGER, cascade = { CascadeType.PERSIST, CascadeType.REMOVE }, orphanRemoval = true)
|
@OneToMany(mappedBy = "dsType", targetEntity = DistributionSetTypeElement.class, fetch = FetchType.EAGER, cascade = { CascadeType.PERSIST,
|
||||||
|
CascadeType.REMOVE }, orphanRemoval = true)
|
||||||
private Set<DistributionSetTypeElement> elements;
|
private Set<DistributionSetTypeElement> elements;
|
||||||
|
|
||||||
@Column(name = "deleted")
|
@Column(name = "deleted")
|
||||||
|
|||||||
@@ -72,75 +72,40 @@ public class JpaRollout extends AbstractJpaNamedEntity implements Rollout, Event
|
|||||||
@JoinColumn(name = "distribution_set", nullable = false, updatable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_rolltout_ds"))
|
@JoinColumn(name = "distribution_set", nullable = false, updatable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_rolltout_ds"))
|
||||||
@NotNull
|
@NotNull
|
||||||
private JpaDistributionSet distributionSet;
|
private JpaDistributionSet distributionSet;
|
||||||
|
|
||||||
@Converter
|
|
||||||
public static class RolloutStatusConverter extends MapAttributeConverter<RolloutStatus, Integer> {
|
|
||||||
|
|
||||||
public RolloutStatusConverter() {
|
|
||||||
super(new HashMap<>() {{
|
|
||||||
put(RolloutStatus.CREATING, 0);
|
|
||||||
put(RolloutStatus.READY, 1);
|
|
||||||
put(RolloutStatus.PAUSED, 2);
|
|
||||||
put(RolloutStatus.STARTING, 3);
|
|
||||||
put(RolloutStatus.STOPPED, 4);
|
|
||||||
put(RolloutStatus.RUNNING, 5);
|
|
||||||
put(RolloutStatus.FINISHED, 6);
|
|
||||||
put(RolloutStatus.ERROR_CREATING, 7);
|
|
||||||
put(RolloutStatus.ERROR_STARTING, 8);
|
|
||||||
put(RolloutStatus.DELETING, 9);
|
|
||||||
put(RolloutStatus.DELETED, 10);
|
|
||||||
put(RolloutStatus.WAITING_FOR_APPROVAL, 11);
|
|
||||||
put(RolloutStatus.APPROVAL_DENIED, 12);
|
|
||||||
put(RolloutStatus.STOPPING, 13);
|
|
||||||
}}, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@Column(name = "status", nullable = false)
|
@Column(name = "status", nullable = false)
|
||||||
@Convert(converter = RolloutStatusConverter.class)
|
@Convert(converter = RolloutStatusConverter.class)
|
||||||
@NotNull
|
@NotNull
|
||||||
private RolloutStatus status = RolloutStatus.CREATING;
|
private RolloutStatus status = RolloutStatus.CREATING;
|
||||||
@Column(name = "last_check")
|
@Column(name = "last_check")
|
||||||
private long lastCheck;
|
private long lastCheck;
|
||||||
|
|
||||||
@Column(name = "action_type", nullable = false)
|
@Column(name = "action_type", nullable = false)
|
||||||
@Convert(converter = JpaAction.ActionTypeConverter.class)
|
@Convert(converter = JpaAction.ActionTypeConverter.class)
|
||||||
@NotNull
|
@NotNull
|
||||||
private ActionType actionType = ActionType.FORCED;
|
private ActionType actionType = ActionType.FORCED;
|
||||||
|
|
||||||
@Column(name = "forced_time")
|
@Column(name = "forced_time")
|
||||||
private long forcedTime;
|
private long forcedTime;
|
||||||
|
|
||||||
@Column(name = "total_targets")
|
@Column(name = "total_targets")
|
||||||
private long totalTargets;
|
private long totalTargets;
|
||||||
|
|
||||||
@Column(name = "rollout_groups_created")
|
@Column(name = "rollout_groups_created")
|
||||||
private int rolloutGroupsCreated;
|
private int rolloutGroupsCreated;
|
||||||
|
|
||||||
@Column(name = "deleted")
|
@Column(name = "deleted")
|
||||||
private boolean deleted;
|
private boolean deleted;
|
||||||
|
|
||||||
@Column(name = "start_at")
|
@Column(name = "start_at")
|
||||||
private Long startAt;
|
private Long startAt;
|
||||||
|
|
||||||
@Column(name = "approval_decided_by")
|
@Column(name = "approval_decided_by")
|
||||||
@Size(min = 1, max = Rollout.APPROVED_BY_MAX_SIZE)
|
@Size(min = 1, max = Rollout.APPROVED_BY_MAX_SIZE)
|
||||||
private String approvalDecidedBy;
|
private String approvalDecidedBy;
|
||||||
|
|
||||||
@Column(name = "approval_remark")
|
@Column(name = "approval_remark")
|
||||||
@Size(max = Rollout.APPROVAL_REMARK_MAX_SIZE)
|
@Size(max = Rollout.APPROVAL_REMARK_MAX_SIZE)
|
||||||
private String approvalRemark;
|
private String approvalRemark;
|
||||||
|
|
||||||
@Column(name = "weight")
|
@Column(name = "weight")
|
||||||
@Min(Action.WEIGHT_MIN)
|
@Min(Action.WEIGHT_MIN)
|
||||||
@Max(Action.WEIGHT_MAX)
|
@Max(Action.WEIGHT_MAX)
|
||||||
private Integer weight;
|
private Integer weight;
|
||||||
|
|
||||||
@Column(name = "is_dynamic") // dynamic is reserved keyword in some databases
|
@Column(name = "is_dynamic") // dynamic is reserved keyword in some databases
|
||||||
private Boolean dynamic;
|
private Boolean dynamic;
|
||||||
|
|
||||||
@Column(name = "access_control_context", nullable = true)
|
@Column(name = "access_control_context", nullable = true)
|
||||||
private String accessControlContext;
|
private String accessControlContext;
|
||||||
|
|
||||||
@Transient
|
@Transient
|
||||||
private transient TotalTargetCountStatus totalTargetCountStatus;
|
private transient TotalTargetCountStatus totalTargetCountStatus;
|
||||||
|
|
||||||
@@ -331,4 +296,27 @@ public class JpaRollout extends AbstractJpaNamedEntity implements Rollout, Event
|
|||||||
public void setDeleted(final boolean deleted) {
|
public void setDeleted(final boolean deleted) {
|
||||||
this.deleted = deleted;
|
this.deleted = deleted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Converter
|
||||||
|
public static class RolloutStatusConverter extends MapAttributeConverter<RolloutStatus, Integer> {
|
||||||
|
|
||||||
|
public RolloutStatusConverter() {
|
||||||
|
super(new HashMap<>() {{
|
||||||
|
put(RolloutStatus.CREATING, 0);
|
||||||
|
put(RolloutStatus.READY, 1);
|
||||||
|
put(RolloutStatus.PAUSED, 2);
|
||||||
|
put(RolloutStatus.STARTING, 3);
|
||||||
|
put(RolloutStatus.STOPPED, 4);
|
||||||
|
put(RolloutStatus.RUNNING, 5);
|
||||||
|
put(RolloutStatus.FINISHED, 6);
|
||||||
|
put(RolloutStatus.ERROR_CREATING, 7);
|
||||||
|
put(RolloutStatus.ERROR_STARTING, 8);
|
||||||
|
put(RolloutStatus.DELETING, 9);
|
||||||
|
put(RolloutStatus.DELETED, 10);
|
||||||
|
put(RolloutStatus.WAITING_FOR_APPROVAL, 11);
|
||||||
|
put(RolloutStatus.APPROVAL_DENIED, 12);
|
||||||
|
put(RolloutStatus.STOPPING, 13);
|
||||||
|
}}, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -57,110 +57,80 @@ public class JpaRolloutGroup extends AbstractJpaNamedEntity implements RolloutGr
|
|||||||
@ManyToOne(fetch = FetchType.LAZY)
|
@ManyToOne(fetch = FetchType.LAZY)
|
||||||
@JoinColumn(name = "rollout", nullable = false, updatable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_rolloutgroup_rollout"))
|
@JoinColumn(name = "rollout", nullable = false, updatable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_rolloutgroup_rollout"))
|
||||||
private JpaRollout rollout;
|
private JpaRollout rollout;
|
||||||
|
|
||||||
@Converter
|
|
||||||
public static class RolloutGroupStatusConverter extends MapAttributeConverter<RolloutGroupStatus, Integer> {
|
|
||||||
|
|
||||||
public RolloutGroupStatusConverter() {
|
|
||||||
super(Map.of(
|
|
||||||
RolloutGroupStatus.READY, 0,
|
|
||||||
RolloutGroupStatus.SCHEDULED, 1,
|
|
||||||
RolloutGroupStatus.FINISHED, 2,
|
|
||||||
RolloutGroupStatus.ERROR, 3,
|
|
||||||
RolloutGroupStatus.RUNNING, 4,
|
|
||||||
RolloutGroupStatus.CREATING, 5
|
|
||||||
), null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Setter
|
@Setter
|
||||||
@Getter
|
@Getter
|
||||||
@Column(name = "status", nullable = false)
|
@Column(name = "status", nullable = false)
|
||||||
@Convert(converter = RolloutGroupStatusConverter.class)
|
@Convert(converter = RolloutGroupStatusConverter.class)
|
||||||
private RolloutGroupStatus status = RolloutGroupStatus.CREATING;
|
private RolloutGroupStatus status = RolloutGroupStatus.CREATING;
|
||||||
|
@OneToMany(mappedBy = "rolloutGroup", fetch = FetchType.LAZY, cascade = { CascadeType.PERSIST,
|
||||||
@OneToMany(mappedBy = "rolloutGroup", fetch = FetchType.LAZY, cascade = { CascadeType.PERSIST, CascadeType.REMOVE }, targetEntity = RolloutTargetGroup.class)
|
CascadeType.REMOVE }, targetEntity = RolloutTargetGroup.class)
|
||||||
private List<RolloutTargetGroup> rolloutTargetGroup;
|
private List<RolloutTargetGroup> rolloutTargetGroup;
|
||||||
|
|
||||||
// No foreign key to avoid to many nested cascades on delete which some DBs cannot handle
|
// No foreign key to avoid to many nested cascades on delete which some DBs cannot handle
|
||||||
@Setter
|
@Setter
|
||||||
@Getter
|
@Getter
|
||||||
@ManyToOne(fetch = FetchType.LAZY, cascade = { CascadeType.PERSIST })
|
@ManyToOne(fetch = FetchType.LAZY, cascade = { CascadeType.PERSIST })
|
||||||
@JoinColumn(name = "parent_id")
|
@JoinColumn(name = "parent_id")
|
||||||
private JpaRolloutGroup parent;
|
private JpaRolloutGroup parent;
|
||||||
|
@Setter
|
||||||
@Setter @Getter
|
@Getter
|
||||||
@Column(name = "is_dynamic") // dynamic is reserved keyword in some databases
|
@Column(name = "is_dynamic") // dynamic is reserved keyword in some databases
|
||||||
private boolean dynamic;
|
private boolean dynamic;
|
||||||
|
|
||||||
@Setter
|
@Setter
|
||||||
@Getter
|
@Getter
|
||||||
@Column(name = "success_condition", nullable = false)
|
@Column(name = "success_condition", nullable = false)
|
||||||
@NotNull
|
@NotNull
|
||||||
private RolloutGroupSuccessCondition successCondition = RolloutGroupSuccessCondition.THRESHOLD;
|
private RolloutGroupSuccessCondition successCondition = RolloutGroupSuccessCondition.THRESHOLD;
|
||||||
|
|
||||||
@Setter
|
@Setter
|
||||||
@Getter
|
@Getter
|
||||||
@Column(name = "success_condition_exp", length = 512, nullable = false)
|
@Column(name = "success_condition_exp", length = 512, nullable = false)
|
||||||
@Size(max = 512)
|
@Size(max = 512)
|
||||||
@NotNull
|
@NotNull
|
||||||
private String successConditionExp;
|
private String successConditionExp;
|
||||||
|
|
||||||
@Setter
|
@Setter
|
||||||
@Getter
|
@Getter
|
||||||
@Column(name = "success_action", nullable = false)
|
@Column(name = "success_action", nullable = false)
|
||||||
@NotNull
|
@NotNull
|
||||||
private RolloutGroupSuccessAction successAction = RolloutGroupSuccessAction.NEXTGROUP;
|
private RolloutGroupSuccessAction successAction = RolloutGroupSuccessAction.NEXTGROUP;
|
||||||
|
|
||||||
@Setter
|
@Setter
|
||||||
@Getter
|
@Getter
|
||||||
@Column(name = "success_action_exp", length = 512)
|
@Column(name = "success_action_exp", length = 512)
|
||||||
@Size(max = 512)
|
@Size(max = 512)
|
||||||
private String successActionExp;
|
private String successActionExp;
|
||||||
|
|
||||||
@Setter
|
@Setter
|
||||||
@Getter
|
@Getter
|
||||||
@Column(name = "error_condition")
|
@Column(name = "error_condition")
|
||||||
private RolloutGroupErrorCondition errorCondition;
|
private RolloutGroupErrorCondition errorCondition;
|
||||||
|
|
||||||
@Setter
|
@Setter
|
||||||
@Getter
|
@Getter
|
||||||
@Column(name = "error_condition_exp", length = 512)
|
@Column(name = "error_condition_exp", length = 512)
|
||||||
@Size(max = 512)
|
@Size(max = 512)
|
||||||
private String errorConditionExp;
|
private String errorConditionExp;
|
||||||
|
|
||||||
@Setter
|
@Setter
|
||||||
@Getter
|
@Getter
|
||||||
@Column(name = "error_action")
|
@Column(name = "error_action")
|
||||||
private RolloutGroupErrorAction errorAction;
|
private RolloutGroupErrorAction errorAction;
|
||||||
|
|
||||||
@Setter
|
@Setter
|
||||||
@Getter
|
@Getter
|
||||||
@Column(name = "error_action_exp", length = 512)
|
@Column(name = "error_action_exp", length = 512)
|
||||||
@Size(max = 512)
|
@Size(max = 512)
|
||||||
private String errorActionExp;
|
private String errorActionExp;
|
||||||
|
|
||||||
@Setter
|
@Setter
|
||||||
@Getter
|
@Getter
|
||||||
@Column(name = "total_targets")
|
@Column(name = "total_targets")
|
||||||
private int totalTargets;
|
private int totalTargets;
|
||||||
|
|
||||||
@Setter
|
@Setter
|
||||||
@Getter
|
@Getter
|
||||||
@Column(name = "target_filter", length = 1024)
|
@Column(name = "target_filter", length = 1024)
|
||||||
@Size(max = 1024)
|
@Size(max = 1024)
|
||||||
private String targetFilterQuery = "";
|
private String targetFilterQuery = "";
|
||||||
|
|
||||||
@Setter
|
@Setter
|
||||||
@Getter
|
@Getter
|
||||||
@Column(name = "target_percentage")
|
@Column(name = "target_percentage")
|
||||||
private float targetPercentage = 100;
|
private float targetPercentage = 100;
|
||||||
|
|
||||||
@Setter
|
@Setter
|
||||||
@Getter
|
@Getter
|
||||||
@Column(name = "confirmation_required")
|
@Column(name = "confirmation_required")
|
||||||
private boolean confirmationRequired;
|
private boolean confirmationRequired;
|
||||||
|
|
||||||
@Setter
|
@Setter
|
||||||
@Transient
|
@Transient
|
||||||
private transient TotalTargetCountStatus totalTargetCountStatus;
|
private transient TotalTargetCountStatus totalTargetCountStatus;
|
||||||
@@ -219,4 +189,19 @@ public class JpaRolloutGroup extends AbstractJpaNamedEntity implements RolloutGr
|
|||||||
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(
|
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(
|
||||||
new RolloutGroupDeletedEvent(getTenant(), getId(), getClass(), EventPublisherHolder.getInstance().getApplicationId()));
|
new RolloutGroupDeletedEvent(getTenant(), getId(), getClass(), EventPublisherHolder.getInstance().getApplicationId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Converter
|
||||||
|
public static class RolloutGroupStatusConverter extends MapAttributeConverter<RolloutGroupStatus, Integer> {
|
||||||
|
|
||||||
|
public RolloutGroupStatusConverter() {
|
||||||
|
super(Map.of(
|
||||||
|
RolloutGroupStatus.READY, 0,
|
||||||
|
RolloutGroupStatus.SCHEDULED, 1,
|
||||||
|
RolloutGroupStatus.FINISHED, 2,
|
||||||
|
RolloutGroupStatus.ERROR, 3,
|
||||||
|
RolloutGroupStatus.RUNNING, 4,
|
||||||
|
RolloutGroupStatus.CREATING, 5
|
||||||
|
), null);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -77,7 +77,8 @@ public class JpaSoftwareModule extends AbstractJpaNamedVersionedEntity implement
|
|||||||
@NotNull
|
@NotNull
|
||||||
private JpaSoftwareModuleType type;
|
private JpaSoftwareModuleType type;
|
||||||
|
|
||||||
@OneToMany(fetch = FetchType.LAZY, mappedBy = "softwareModule", cascade = { CascadeType.PERSIST, CascadeType.REMOVE }, targetEntity = JpaArtifact.class, orphanRemoval = true)
|
@OneToMany(fetch = FetchType.LAZY, mappedBy = "softwareModule", cascade = { CascadeType.PERSIST,
|
||||||
|
CascadeType.REMOVE }, targetEntity = JpaArtifact.class, orphanRemoval = true)
|
||||||
private List<JpaArtifact> artifacts;
|
private List<JpaArtifact> artifacts;
|
||||||
|
|
||||||
@Setter
|
@Setter
|
||||||
@@ -90,7 +91,8 @@ public class JpaSoftwareModule extends AbstractJpaNamedVersionedEntity implement
|
|||||||
private boolean encrypted;
|
private boolean encrypted;
|
||||||
|
|
||||||
@ToString.Exclude
|
@ToString.Exclude
|
||||||
@OneToMany(mappedBy = "softwareModule", fetch = FetchType.LAZY, cascade = { CascadeType.REMOVE }, targetEntity = JpaSoftwareModuleMetadata.class)
|
@OneToMany(mappedBy = "softwareModule", fetch = FetchType.LAZY, cascade = {
|
||||||
|
CascadeType.REMOVE }, targetEntity = JpaSoftwareModuleMetadata.class)
|
||||||
private List<JpaSoftwareModuleMetadata> metadata;
|
private List<JpaSoftwareModuleMetadata> metadata;
|
||||||
|
|
||||||
@Column(name = "locked")
|
@Column(name = "locked")
|
||||||
|
|||||||
@@ -118,45 +118,25 @@ public class JpaTarget extends AbstractJpaNamedEntity implements Target, EventAw
|
|||||||
|
|
||||||
@Column(name = "install_date")
|
@Column(name = "install_date")
|
||||||
private Long installationDate;
|
private Long installationDate;
|
||||||
|
|
||||||
@Converter
|
|
||||||
public static class TargetUpdateStatusConverter extends MapAttributeConverter<TargetUpdateStatus, Integer> {
|
|
||||||
|
|
||||||
public TargetUpdateStatusConverter() {
|
|
||||||
super(Map.of(
|
|
||||||
TargetUpdateStatus.UNKNOWN, 0,
|
|
||||||
TargetUpdateStatus.IN_SYNC, 1,
|
|
||||||
TargetUpdateStatus.PENDING, 2,
|
|
||||||
TargetUpdateStatus.ERROR, 3,
|
|
||||||
TargetUpdateStatus.REGISTERED, 4
|
|
||||||
), null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@Column(name = "update_status", nullable = false)
|
@Column(name = "update_status", nullable = false)
|
||||||
@Convert(converter = TargetUpdateStatusConverter.class)
|
@Convert(converter = TargetUpdateStatusConverter.class)
|
||||||
@NotNull
|
@NotNull
|
||||||
private TargetUpdateStatus updateStatus = TargetUpdateStatus.UNKNOWN;
|
private TargetUpdateStatus updateStatus = TargetUpdateStatus.UNKNOWN;
|
||||||
|
|
||||||
@ManyToOne(optional = true, fetch = FetchType.LAZY)
|
@ManyToOne(optional = true, fetch = FetchType.LAZY)
|
||||||
@JoinColumn(name = "installed_distribution_set", nullable = true, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_target_inst_ds"))
|
@JoinColumn(name = "installed_distribution_set", nullable = true, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_target_inst_ds"))
|
||||||
private JpaDistributionSet installedDistributionSet;
|
private JpaDistributionSet installedDistributionSet;
|
||||||
|
|
||||||
@ManyToOne(optional = true, fetch = FetchType.LAZY)
|
@ManyToOne(optional = true, fetch = FetchType.LAZY)
|
||||||
@JoinColumn(name = "assigned_distribution_set", nullable = true, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_target_assign_ds"))
|
@JoinColumn(name = "assigned_distribution_set", nullable = true, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_target_assign_ds"))
|
||||||
private JpaDistributionSet assignedDistributionSet;
|
private JpaDistributionSet assignedDistributionSet;
|
||||||
|
|
||||||
// set default request controller attributes to true, because we want to request them the first time
|
// set default request controller attributes to true, because we want to request them the first time
|
||||||
@Column(name = "request_controller_attributes", nullable = false)
|
@Column(name = "request_controller_attributes", nullable = false)
|
||||||
private boolean requestControllerAttributes = true;
|
private boolean requestControllerAttributes = true;
|
||||||
|
|
||||||
@OneToOne(fetch = FetchType.LAZY, mappedBy = "target", orphanRemoval = true)
|
@OneToOne(fetch = FetchType.LAZY, mappedBy = "target", orphanRemoval = true)
|
||||||
@PrimaryKeyJoinColumn
|
@PrimaryKeyJoinColumn
|
||||||
private JpaAutoConfirmationStatus autoConfirmationStatus;
|
private JpaAutoConfirmationStatus autoConfirmationStatus;
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY, targetEntity = JpaTargetType.class)
|
@ManyToOne(fetch = FetchType.LAZY, targetEntity = JpaTargetType.class)
|
||||||
@JoinColumn(name = "target_type", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_target_relation_target_type"))
|
@JoinColumn(name = "target_type", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_target_relation_target_type"))
|
||||||
private TargetType targetType;
|
private TargetType targetType;
|
||||||
|
|
||||||
@ManyToMany(targetEntity = JpaTargetTag.class)
|
@ManyToMany(targetEntity = JpaTargetTag.class)
|
||||||
@JoinTable(
|
@JoinTable(
|
||||||
name = "sp_target_target_tag",
|
name = "sp_target_target_tag",
|
||||||
@@ -170,7 +150,6 @@ public class JpaTarget extends AbstractJpaNamedEntity implements Target, EventAw
|
|||||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_targ_targtag_tag"))
|
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_targ_targtag_tag"))
|
||||||
})
|
})
|
||||||
private Set<TargetTag> tags;
|
private Set<TargetTag> tags;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Supplied / committed by the controller. Read-only via management API.
|
* Supplied / committed by the controller. Read-only via management API.
|
||||||
*/
|
*/
|
||||||
@@ -183,7 +162,6 @@ public class JpaTarget extends AbstractJpaNamedEntity implements Target, EventAw
|
|||||||
joinColumns = { @JoinColumn(name = "target_id", nullable = false, insertable = false, updatable = false) },
|
joinColumns = { @JoinColumn(name = "target_id", nullable = false, insertable = false, updatable = false) },
|
||||||
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_targ_attrib_target"))
|
foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_targ_attrib_target"))
|
||||||
private Map<String, String> controllerAttributes;
|
private Map<String, String> controllerAttributes;
|
||||||
|
|
||||||
@OneToMany(mappedBy = "target", fetch = FetchType.LAZY, cascade = { CascadeType.REMOVE }, targetEntity = JpaTargetMetadata.class)
|
@OneToMany(mappedBy = "target", fetch = FetchType.LAZY, cascade = { CascadeType.REMOVE }, targetEntity = JpaTargetMetadata.class)
|
||||||
private List<TargetMetadata> metadata;
|
private List<TargetMetadata> metadata;
|
||||||
|
|
||||||
@@ -496,4 +474,18 @@ public class JpaTarget extends AbstractJpaNamedEntity implements Target, EventAw
|
|||||||
public List<String> getUpdateIgnoreFields() {
|
public List<String> getUpdateIgnoreFields() {
|
||||||
return TARGET_UPDATE_EVENT_IGNORE_FIELDS;
|
return TARGET_UPDATE_EVENT_IGNORE_FIELDS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Converter
|
||||||
|
public static class TargetUpdateStatusConverter extends MapAttributeConverter<TargetUpdateStatus, Integer> {
|
||||||
|
|
||||||
|
public TargetUpdateStatusConverter() {
|
||||||
|
super(Map.of(
|
||||||
|
TargetUpdateStatus.UNKNOWN, 0,
|
||||||
|
TargetUpdateStatus.IN_SYNC, 1,
|
||||||
|
TargetUpdateStatus.PENDING, 2,
|
||||||
|
TargetUpdateStatus.ERROR, 3,
|
||||||
|
TargetUpdateStatus.REGISTERED, 4
|
||||||
|
), null);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ import java.util.Collection;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import io.qameta.allure.Description;
|
import io.qameta.allure.Description;
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ import org.springframework.util.CollectionUtils;
|
|||||||
class RolloutGroupManagementTest extends AbstractJpaIntegrationTest {
|
class RolloutGroupManagementTest extends AbstractJpaIntegrationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Description("Verifies that management get access reacts as specified on calls for non existing entities by means " +
|
@Description("Verifies that management get access reacts as specified on calls for non existing entities by means " +
|
||||||
"of Optional not present.")
|
"of Optional not present.")
|
||||||
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) })
|
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) })
|
||||||
void nonExistingEntityAccessReturnsNotPresent() {
|
void nonExistingEntityAccessReturnsNotPresent() {
|
||||||
@@ -227,7 +227,7 @@ class RolloutGroupManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
final JpaRolloutGroup rolloutGroup = ((JpaRolloutGroup) rolloutGroupManagement.get(id).orElseThrow());
|
final JpaRolloutGroup rolloutGroup = ((JpaRolloutGroup) rolloutGroupManagement.get(id).orElseThrow());
|
||||||
rolloutGroup.setStatus(status);
|
rolloutGroup.setStatus(status);
|
||||||
rolloutGroupRepository.save(rolloutGroup);
|
rolloutGroupRepository.save(rolloutGroup);
|
||||||
assertThat( rolloutGroupManagement.get(id).orElseThrow().getStatus()).isEqualTo(status);
|
assertThat(rolloutGroupManagement.get(id).orElseThrow().getStatus()).isEqualTo(status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2086,7 +2086,7 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
void testRolloutStatusConvert() {
|
void testRolloutStatusConvert() {
|
||||||
final long id = testdataFactory.createAndStartRollout(1, 0, 1, "100", "80").getId();
|
final long id = testdataFactory.createAndStartRollout(1, 0, 1, "100", "80").getId();
|
||||||
for (final RolloutStatus status : RolloutStatus.values()) {
|
for (final RolloutStatus status : RolloutStatus.values()) {
|
||||||
final JpaRollout rollout = ((JpaRollout)rolloutManagement.get(id).orElseThrow());
|
final JpaRollout rollout = ((JpaRollout) rolloutManagement.get(id).orElseThrow());
|
||||||
rollout.setStatus(status);
|
rollout.setStatus(status);
|
||||||
rolloutRepository.save(rollout);
|
rolloutRepository.save(rollout);
|
||||||
assertThat(rolloutManagement.get(id).orElseThrow().getStatus()).isEqualTo(status);
|
assertThat(rolloutManagement.get(id).orElseThrow().getStatus()).isEqualTo(status);
|
||||||
@@ -2098,7 +2098,7 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
void testActionTypeConvert() {
|
void testActionTypeConvert() {
|
||||||
final long id = testdataFactory.createAndStartRollout(1, 0, 1, "100", "80").getId();
|
final long id = testdataFactory.createAndStartRollout(1, 0, 1, "100", "80").getId();
|
||||||
for (final ActionType actionType : ActionType.values()) {
|
for (final ActionType actionType : ActionType.values()) {
|
||||||
final JpaRollout rollout = ((JpaRollout)rolloutManagement.get(id).orElseThrow());
|
final JpaRollout rollout = ((JpaRollout) rolloutManagement.get(id).orElseThrow());
|
||||||
rollout.setActionType(actionType);
|
rollout.setActionType(actionType);
|
||||||
rolloutRepository.save(rollout);
|
rolloutRepository.save(rollout);
|
||||||
assertThat(rolloutManagement.get(id).orElseThrow().getActionType()).isEqualTo(actionType);
|
assertThat(rolloutManagement.get(id).orElseThrow().getActionType()).isEqualTo(actionType);
|
||||||
|
|||||||
@@ -21,11 +21,11 @@ import io.qameta.allure.Description;
|
|||||||
import io.qameta.allure.Feature;
|
import io.qameta.allure.Feature;
|
||||||
import io.qameta.allure.Story;
|
import io.qameta.allure.Story;
|
||||||
import org.eclipse.hawkbit.repository.exception.InvalidTenantConfigurationKeyException;
|
import org.eclipse.hawkbit.repository.exception.InvalidTenantConfigurationKeyException;
|
||||||
|
import org.eclipse.hawkbit.repository.exception.TenantConfigurationValidatorException;
|
||||||
import org.eclipse.hawkbit.repository.jpa.AbstractJpaIntegrationTest;
|
import org.eclipse.hawkbit.repository.jpa.AbstractJpaIntegrationTest;
|
||||||
import org.eclipse.hawkbit.repository.model.TenantConfigurationValue;
|
import org.eclipse.hawkbit.repository.model.TenantConfigurationValue;
|
||||||
import org.eclipse.hawkbit.tenancy.configuration.DurationHelper;
|
import org.eclipse.hawkbit.tenancy.configuration.DurationHelper;
|
||||||
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties.TenantConfigurationKey;
|
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties.TenantConfigurationKey;
|
||||||
import org.eclipse.hawkbit.repository.exception.TenantConfigurationValidatorException;
|
|
||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.context.EnvironmentAware;
|
import org.springframework.context.EnvironmentAware;
|
||||||
|
|||||||
@@ -17,12 +17,11 @@ import java.util.concurrent.ScheduledExecutorService;
|
|||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
|
||||||
import org.eclipse.hawkbit.ContextAware;
|
import org.eclipse.hawkbit.ContextAware;
|
||||||
import org.eclipse.hawkbit.tenancy.configuration.ControllerPollProperties;
|
|
||||||
import org.eclipse.hawkbit.artifact.repository.urlhandler.ArtifactUrlHandlerProperties;
|
|
||||||
import org.eclipse.hawkbit.artifact.repository.urlhandler.PropertyBasedArtifactUrlHandler;
|
|
||||||
import org.eclipse.hawkbit.artifact.repository.ArtifactFilesystemProperties;
|
import org.eclipse.hawkbit.artifact.repository.ArtifactFilesystemProperties;
|
||||||
import org.eclipse.hawkbit.artifact.repository.ArtifactFilesystemRepository;
|
import org.eclipse.hawkbit.artifact.repository.ArtifactFilesystemRepository;
|
||||||
import org.eclipse.hawkbit.artifact.repository.ArtifactRepository;
|
import org.eclipse.hawkbit.artifact.repository.ArtifactRepository;
|
||||||
|
import org.eclipse.hawkbit.artifact.repository.urlhandler.ArtifactUrlHandlerProperties;
|
||||||
|
import org.eclipse.hawkbit.artifact.repository.urlhandler.PropertyBasedArtifactUrlHandler;
|
||||||
import org.eclipse.hawkbit.cache.TenantAwareCacheManager;
|
import org.eclipse.hawkbit.cache.TenantAwareCacheManager;
|
||||||
import org.eclipse.hawkbit.event.BusProtoStuffMessageConverter;
|
import org.eclipse.hawkbit.event.BusProtoStuffMessageConverter;
|
||||||
import org.eclipse.hawkbit.im.authentication.SpRole;
|
import org.eclipse.hawkbit.im.authentication.SpRole;
|
||||||
@@ -43,6 +42,7 @@ import org.eclipse.hawkbit.security.SpringSecurityAuditorAware;
|
|||||||
import org.eclipse.hawkbit.security.SystemSecurityContext;
|
import org.eclipse.hawkbit.security.SystemSecurityContext;
|
||||||
import org.eclipse.hawkbit.tenancy.TenantAware;
|
import org.eclipse.hawkbit.tenancy.TenantAware;
|
||||||
import org.eclipse.hawkbit.tenancy.UserAuthoritiesResolver;
|
import org.eclipse.hawkbit.tenancy.UserAuthoritiesResolver;
|
||||||
|
import org.eclipse.hawkbit.tenancy.configuration.ControllerPollProperties;
|
||||||
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties;
|
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties;
|
||||||
import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
|
import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
|
||||||
import org.springframework.aop.interceptor.SimpleAsyncUncaughtExceptionHandler;
|
import org.springframework.aop.interceptor.SimpleAsyncUncaughtExceptionHandler;
|
||||||
|
|||||||
@@ -112,9 +112,7 @@ import org.springframework.test.context.TestPropertySource;
|
|||||||
public abstract class AbstractIntegrationTest {
|
public abstract class AbstractIntegrationTest {
|
||||||
|
|
||||||
protected static final Pageable PAGE = PageRequest.of(0, 500, Sort.by(Direction.ASC, "id"));
|
protected static final Pageable PAGE = PageRequest.of(0, 500, Sort.by(Direction.ASC, "id"));
|
||||||
|
|
||||||
protected static final URI LOCALHOST = URI.create("http://127.0.0.1");
|
protected static final URI LOCALHOST = URI.create("http://127.0.0.1");
|
||||||
|
|
||||||
protected static final int DEFAULT_TEST_WEIGHT = 500;
|
protected static final int DEFAULT_TEST_WEIGHT = 500;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -125,80 +123,58 @@ public abstract class AbstractIntegrationTest {
|
|||||||
*/
|
*/
|
||||||
protected static final int DEFAULT_DS_TYPES = RepositoryConstants.DEFAULT_DS_TYPES_IN_TENANT + 1;
|
protected static final int DEFAULT_DS_TYPES = RepositoryConstants.DEFAULT_DS_TYPES_IN_TENANT + 1;
|
||||||
|
|
||||||
|
private static final String ARTIFACT_DIRECTORY = createTempDir();
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
protected EntityFactory entityFactory;
|
protected EntityFactory entityFactory;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
protected SoftwareModuleManagement softwareModuleManagement;
|
protected SoftwareModuleManagement softwareModuleManagement;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
protected SoftwareModuleTypeManagement softwareModuleTypeManagement;
|
protected SoftwareModuleTypeManagement softwareModuleTypeManagement;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
protected DistributionSetManagement distributionSetManagement;
|
protected DistributionSetManagement distributionSetManagement;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
protected DistributionSetTypeManagement distributionSetTypeManagement;
|
protected DistributionSetTypeManagement distributionSetTypeManagement;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
protected ControllerManagement controllerManagement;
|
protected ControllerManagement controllerManagement;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
protected TargetManagement targetManagement;
|
protected TargetManagement targetManagement;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
protected TargetTypeManagement targetTypeManagement;
|
protected TargetTypeManagement targetTypeManagement;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
protected TargetFilterQueryManagement targetFilterQueryManagement;
|
protected TargetFilterQueryManagement targetFilterQueryManagement;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
protected TargetTagManagement targetTagManagement;
|
protected TargetTagManagement targetTagManagement;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
protected DistributionSetTagManagement distributionSetTagManagement;
|
protected DistributionSetTagManagement distributionSetTagManagement;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
protected DeploymentManagement deploymentManagement;
|
protected DeploymentManagement deploymentManagement;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
protected ConfirmationManagement confirmationManagement;
|
protected ConfirmationManagement confirmationManagement;
|
||||||
@Autowired
|
@Autowired
|
||||||
protected DistributionSetInvalidationManagement distributionSetInvalidationManagement;
|
protected DistributionSetInvalidationManagement distributionSetInvalidationManagement;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
protected ArtifactManagement artifactManagement;
|
protected ArtifactManagement artifactManagement;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
protected AuditingHandler auditingHandler;
|
protected AuditingHandler auditingHandler;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
protected TenantAware tenantAware;
|
protected TenantAware tenantAware;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
protected SystemManagement systemManagement;
|
protected SystemManagement systemManagement;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
protected TenantConfigurationManagement tenantConfigurationManagement;
|
protected TenantConfigurationManagement tenantConfigurationManagement;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
protected RolloutManagement rolloutManagement;
|
protected RolloutManagement rolloutManagement;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
protected RolloutHandler rolloutHandler;
|
protected RolloutHandler rolloutHandler;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
protected RolloutGroupManagement rolloutGroupManagement;
|
protected RolloutGroupManagement rolloutGroupManagement;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
protected SystemSecurityContext systemSecurityContext;
|
protected SystemSecurityContext systemSecurityContext;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
protected ArtifactRepository binaryArtifactRepository;
|
protected ArtifactRepository binaryArtifactRepository;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
protected TenantAwareCacheManager cacheManager;
|
protected TenantAwareCacheManager cacheManager;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
protected QuotaManagement quotaManagement;
|
protected QuotaManagement quotaManagement;
|
||||||
|
|
||||||
@@ -210,13 +186,10 @@ public abstract class AbstractIntegrationTest {
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
protected TestdataFactory testdataFactory;
|
protected TestdataFactory testdataFactory;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
protected ServiceMatcher serviceMatcher;
|
protected ServiceMatcher serviceMatcher;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
protected ApplicationEventPublisher eventPublisher;
|
protected ApplicationEventPublisher eventPublisher;
|
||||||
private static final String ARTIFACT_DIRECTORY = createTempDir();
|
|
||||||
|
|
||||||
@BeforeAll
|
@BeforeAll
|
||||||
public static void beforeClass() {
|
public static void beforeClass() {
|
||||||
|
|||||||
@@ -18,9 +18,9 @@ import java.util.Objects;
|
|||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
import org.eclipse.hawkbit.im.authentication.SpPermission;
|
import org.eclipse.hawkbit.im.authentication.SpPermission;
|
||||||
|
import org.eclipse.hawkbit.repository.model.helper.SystemManagementHolder;
|
||||||
import org.eclipse.hawkbit.tenancy.TenantAwareAuthenticationDetails;
|
import org.eclipse.hawkbit.tenancy.TenantAwareAuthenticationDetails;
|
||||||
import org.eclipse.hawkbit.tenancy.TenantAwareUser;
|
import org.eclipse.hawkbit.tenancy.TenantAwareUser;
|
||||||
import org.eclipse.hawkbit.repository.model.helper.SystemManagementHolder;
|
|
||||||
import org.springframework.security.authentication.TestingAuthenticationToken;
|
import org.springframework.security.authentication.TestingAuthenticationToken;
|
||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
import org.springframework.security.core.context.SecurityContext;
|
import org.springframework.security.core.context.SecurityContext;
|
||||||
|
|||||||
Reference in New Issue
Block a user