Code refactoring of hawkbit-repository (#2056)
Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -65,4 +65,4 @@ public class ErrorController extends BasicErrorController {
|
||||
}
|
||||
return body;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -42,8 +42,7 @@ public class Start {
|
||||
public static class RedirectController {
|
||||
|
||||
@GetMapping("/")
|
||||
public RedirectView redirectToSwagger(
|
||||
RedirectAttributes attributes) {
|
||||
public RedirectView redirectToSwagger(final RedirectAttributes attributes) {
|
||||
attributes.addFlashAttribute("flashAttribute", "redirectWithRedirectView");
|
||||
attributes.addAttribute("attribute", "redirectWithRedirectView");
|
||||
return new RedirectView("swagger-ui/index.html");
|
||||
@@ -52,7 +51,5 @@ public class Start {
|
||||
|
||||
@Configuration
|
||||
@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")
|
||||
@WithUser(authorities = { SpPermission.READ_TARGET })
|
||||
public void failIfNoRole() throws Exception {
|
||||
mvc.perform(get("/rest/v1/distributionsets")).andExpect(result ->
|
||||
assertThat(result.getResponse().getStatus()).isEqualTo(HttpStatus.FORBIDDEN.value()));
|
||||
mvc.perform(get("/rest/v1/distributionsets"))
|
||||
.andExpect(result ->
|
||||
assertThat(result.getResponse().getStatus()).isEqualTo(HttpStatus.FORBIDDEN.value()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests whether request succeed if a role is granted for the user")
|
||||
@WithUser(authorities = { SpPermission.READ_REPOSITORY })
|
||||
public void successIfHasRole() throws Exception {
|
||||
mvc.perform(get("/rest/v1/distributionsets")).andExpect(result -> {
|
||||
assertThat(result.getResponse().getStatus()).isEqualTo(HttpStatus.OK.value());
|
||||
});
|
||||
mvc.perform(get("/rest/v1/distributionsets"))
|
||||
.andExpect(result -> {
|
||||
assertThat(result.getResponse().getStatus()).isEqualTo(HttpStatus.OK.value());
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests whether request succeed if a role is granted for the user")
|
||||
@WithUser(authorities = { SpRole.TENANT_ADMIN })
|
||||
public void successIfHasTenantAdminRole() throws Exception {
|
||||
mvc.perform(get("/rest/v1/distributionsets")).andExpect(result -> {
|
||||
assertThat(result.getResponse().getStatus()).isEqualTo(HttpStatus.OK.value());
|
||||
});
|
||||
mvc.perform(get("/rest/v1/distributionsets"))
|
||||
.andExpect(result -> {
|
||||
assertThat(result.getResponse().getStatus()).isEqualTo(HttpStatus.OK.value());
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -59,14 +62,15 @@ public class PreAuthorizeEnabledTest extends AbstractSecurityTest {
|
||||
"granted for the user")
|
||||
@WithUser(authorities = { SpPermission.READ_TARGET })
|
||||
public void onlyDSIfNoTenantConfig() throws Exception {
|
||||
mvc.perform(get("/rest/v1/system/configs")).andExpect(result -> {
|
||||
// returns default DS type because of READ_TARGET
|
||||
assertThat(result.getResponse().getStatus()).isEqualTo(HttpStatus.OK.value());
|
||||
assertThat(
|
||||
new ObjectMapper().reader().readValue(result.getResponse().getContentAsString(), HashMap.class)
|
||||
.size())
|
||||
.isEqualTo(1);
|
||||
});
|
||||
mvc.perform(get("/rest/v1/system/configs"))
|
||||
.andExpect(result -> {
|
||||
// returns default DS type because of READ_TARGET
|
||||
assertThat(result.getResponse().getStatus()).isEqualTo(HttpStatus.OK.value());
|
||||
assertThat(
|
||||
new ObjectMapper().reader().readValue(result.getResponse().getContentAsString(), HashMap.class)
|
||||
.size())
|
||||
.isEqualTo(1);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -74,7 +78,8 @@ public class PreAuthorizeEnabledTest extends AbstractSecurityTest {
|
||||
"granted for the user")
|
||||
@WithUser(authorities = { SpPermission.TENANT_CONFIGURATION })
|
||||
public void successIfHasTenantConfig() throws Exception {
|
||||
mvc.perform(get("/rest/v1/system/configs")).andExpect(result ->
|
||||
assertThat(result.getResponse().getStatus()).isEqualTo(HttpStatus.OK.value()));
|
||||
mvc.perform(get("/rest/v1/system/configs"))
|
||||
.andExpect(result ->
|
||||
assertThat(result.getResponse().getStatus()).isEqualTo(HttpStatus.OK.value()));
|
||||
}
|
||||
}
|
||||
@@ -33,14 +33,6 @@
|
||||
<version>${project.version}</version>
|
||||
</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>
|
||||
<groupId>org.springframework.hateoas</groupId>
|
||||
<artifactId>spring-hateoas</artifactId>
|
||||
@@ -71,6 +63,16 @@
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</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>
|
||||
<groupId>com.cronutils</groupId>
|
||||
<artifactId>cron-utils</artifactId>
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Sort;
|
||||
@@ -23,6 +25,7 @@ import org.springframework.data.domain.Sort;
|
||||
@Data
|
||||
public final class OffsetBasedPageRequest extends PageRequest {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final long offset;
|
||||
|
||||
@@ -18,12 +18,12 @@ import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
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.Target;
|
||||
import org.eclipse.hawkbit.repository.model.TenantConfigurationValue;
|
||||
import org.eclipse.hawkbit.tenancy.configuration.DurationHelper;
|
||||
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.env.Environment;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
|
||||
@@ -54,4 +54,4 @@ public interface ActionStatusCreate {
|
||||
* @return peek on current state of {@link ActionStatus} in the builder
|
||||
*/
|
||||
ActionStatus build();
|
||||
}
|
||||
}
|
||||
@@ -26,13 +26,11 @@ import org.eclipse.hawkbit.repository.model.MetaData;
|
||||
@Getter
|
||||
public class EntityNotFoundException extends AbstractServerRtException {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static final String KEY = "key";
|
||||
public static final String ENTITY_ID = "entityId";
|
||||
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 int ENTITY_STRING_MAX_LENGTH = 100;
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ public class IncompatibleTargetTypeException extends AbstractServerRtException {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
private final Collection<String> targetTypeNames;
|
||||
private final Collection<String> distributionSetTypeNames;
|
||||
|
||||
|
||||
@@ -12,9 +12,9 @@ package org.eclipse.hawkbit.tenancy.configuration.validator;
|
||||
import java.time.Duration;
|
||||
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.DurationHelper;
|
||||
import org.eclipse.hawkbit.repository.exception.TenantConfigurationValidatorException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
|
||||
@@ -36,14 +36,12 @@ import org.springframework.util.MimeType;
|
||||
public class BusProtoStuffMessageConverter extends AbstractMessageConverter {
|
||||
|
||||
public static final MimeType APPLICATION_BINARY_PROTOSTUFF = new MimeType("application", "binary+protostuff");
|
||||
|
||||
/**
|
||||
* The length of the class type length of the payload.
|
||||
*/
|
||||
private static final byte EVENT_TYPE_LENGTH = 2;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public BusProtoStuffMessageConverter() {
|
||||
super(APPLICATION_BINARY_PROTOSTUFF);
|
||||
}
|
||||
|
||||
@@ -83,6 +83,7 @@ import org.eclipse.hawkbit.repository.event.remote.entity.TenantConfigurationUpd
|
||||
public class EventType {
|
||||
|
||||
private static final Map<Integer, Class<?>> TYPES = new HashMap<>();
|
||||
|
||||
private int value;
|
||||
|
||||
/**
|
||||
|
||||
@@ -111,4 +111,4 @@ public class PropertiesQuotaManagement implements QuotaManagement {
|
||||
public int getMaxDistributionSetTypesPerTargetType() {
|
||||
return securityProperties.getDos().getMaxDistributionSetTypesPerTargetType();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,9 +19,6 @@ import org.springframework.context.annotation.PropertySource;
|
||||
* Default configuration that is common to all repository implementations.
|
||||
*/
|
||||
@Configuration
|
||||
@EnableConfigurationProperties({ RepositoryProperties.class, ControllerPollProperties.class,
|
||||
TenantConfigurationProperties.class })
|
||||
@EnableConfigurationProperties({ RepositoryProperties.class, ControllerPollProperties.class, TenantConfigurationProperties.class })
|
||||
@PropertySource("classpath:/hawkbit-repository-defaults.properties")
|
||||
public class RepositoryDefaultConfiguration {
|
||||
|
||||
}
|
||||
public class RepositoryDefaultConfiguration {}
|
||||
@@ -46,4 +46,4 @@ public interface RolloutApprovalStrategy {
|
||||
* @return identifier of the user that decided on approval
|
||||
*/
|
||||
String getApprovalUser(Rollout rollout);
|
||||
}
|
||||
}
|
||||
@@ -250,4 +250,4 @@ public class RolloutStatusCache {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,16 +29,12 @@ import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties.T
|
||||
public final class TimestampCalculator {
|
||||
|
||||
/**
|
||||
* Calculates the overdue timestamp (<em>overdue_ts</em>) based on the
|
||||
* current timestamp and the intervals for polling and poll-overdue:
|
||||
* Calculates the overdue timestamp (<em>overdue_ts</em>) based on the current timestamp and the intervals for polling and poll-overdue:
|
||||
* <p>
|
||||
* <em>overdue_ts = now_ts - pollingInterval -
|
||||
* pollingOverdueInterval</em>;<br>
|
||||
* <em>pollingInterval</em> and <em>pollingOverdueInterval</em> are
|
||||
* retrieved from tenant-specific system configuration.
|
||||
* <em>overdue_ts = now_ts - pollingInterval - pollingOverdueInterval</em>;<br>
|
||||
* <em>pollingInterval</em> and <em>pollingOverdueInterval</em> are retrieved from tenant-specific system configuration.
|
||||
*
|
||||
* @return <em>overdue_ts</em> in milliseconds since Unix epoch as long
|
||||
* value
|
||||
* @return <em>overdue_ts</em> in milliseconds since Unix epoch as long value
|
||||
*/
|
||||
public static long calculateOverdueTimestamp() {
|
||||
return Instant.now().toEpochMilli() - getDurationForKey(TenantConfigurationKey.POLLING_TIME_INTERVAL).toMillis()
|
||||
|
||||
@@ -18,7 +18,6 @@ import java.util.stream.Collectors;
|
||||
import lombok.Getter;
|
||||
import org.eclipse.hawkbit.repository.ValidString;
|
||||
import org.eclipse.hawkbit.repository.model.Action.Status;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Create and update builder DTO.
|
||||
@@ -28,31 +27,24 @@ import org.springframework.util.StringUtils;
|
||||
public abstract class AbstractActionStatusCreate<T> {
|
||||
|
||||
protected Status status;
|
||||
|
||||
protected Long occurredAt;
|
||||
|
||||
protected Integer code;
|
||||
|
||||
protected List<@ValidString String> messages;
|
||||
|
||||
@Getter
|
||||
protected Long actionId;
|
||||
|
||||
public T status(final Status status) {
|
||||
this.status = status;
|
||||
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public T occurredAt(final long occurredAt) {
|
||||
this.occurredAt = occurredAt;
|
||||
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public T code(final int code) {
|
||||
this.code = code;
|
||||
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
@@ -63,7 +55,6 @@ public abstract class AbstractActionStatusCreate<T> {
|
||||
} else {
|
||||
this.messages.addAll(messages.stream().map(String::strip).toList());
|
||||
}
|
||||
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
@@ -72,7 +63,6 @@ public abstract class AbstractActionStatusCreate<T> {
|
||||
this.messages = new ArrayList<>();
|
||||
}
|
||||
this.messages.add(message.strip());
|
||||
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,5 +19,4 @@ public abstract class AbstractBaseEntityBuilder implements Identifiable<Long> {
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -39,4 +39,4 @@ public abstract class AbstractDistributionSetTypeUpdateCreate<T> extends Abstrac
|
||||
public Optional<Collection<Long>> getOptional() {
|
||||
return Optional.ofNullable(optional);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,6 @@ public abstract class AbstractMetadataUpdateCreate<T> {
|
||||
|
||||
@ValidString
|
||||
protected String key;
|
||||
|
||||
@ValidString
|
||||
protected String value;
|
||||
|
||||
@@ -44,5 +43,4 @@ public abstract class AbstractMetadataUpdateCreate<T> {
|
||||
public Optional<String> getValue() {
|
||||
return Optional.ofNullable(value);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,6 @@ public abstract class AbstractNamedEntityBuilder<T> extends AbstractBaseEntityBu
|
||||
|
||||
@ValidString
|
||||
protected String name;
|
||||
|
||||
@ValidString
|
||||
protected String description;
|
||||
|
||||
|
||||
@@ -45,5 +45,4 @@ public abstract class AbstractRolloutGroupCreate<T> extends AbstractNamedEntityB
|
||||
this.confirmationRequired = confirmationRequired;
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -38,5 +38,4 @@ public abstract class AbstractSoftwareModuleMetadataUpdateCreate<T> extends Abst
|
||||
this.targetVisible = targetVisible;
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -23,10 +23,8 @@ public abstract class AbstractSoftwareModuleUpdateCreate<T> extends AbstractName
|
||||
|
||||
@ValidString
|
||||
protected String version;
|
||||
|
||||
@ValidString
|
||||
protected String vendor;
|
||||
|
||||
@ValidString
|
||||
protected String type;
|
||||
|
||||
@@ -56,5 +54,4 @@ public abstract class AbstractSoftwareModuleUpdateCreate<T> extends AbstractName
|
||||
public Optional<String> getVersion() {
|
||||
return Optional.ofNullable(version);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -32,5 +32,4 @@ public class AbstractTagUpdateCreate<T> extends AbstractNamedEntityBuilder<T> {
|
||||
public Optional<String> getColour() {
|
||||
return Optional.ofNullable(colour);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -29,18 +29,13 @@ public abstract class AbstractTargetFilterQueryUpdateCreate<T> extends AbstractB
|
||||
|
||||
@ValidString
|
||||
protected String name;
|
||||
|
||||
@ValidString
|
||||
protected String query;
|
||||
|
||||
protected Long distributionSetId;
|
||||
|
||||
protected ActionType actionType;
|
||||
|
||||
@Min(Action.WEIGHT_MIN)
|
||||
@Max(Action.WEIGHT_MAX)
|
||||
protected Integer weight;
|
||||
|
||||
protected Boolean confirmationRequired;
|
||||
|
||||
/**
|
||||
@@ -132,4 +127,4 @@ public abstract class AbstractTargetFilterQueryUpdateCreate<T> extends AbstractB
|
||||
public Optional<Boolean> getConfirmationRequired() {
|
||||
return Optional.ofNullable(confirmationRequired);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -36,4 +36,4 @@ public abstract class AbstractTargetTypeUpdateCreate<T> extends AbstractTypeUpda
|
||||
public Optional<Collection<Long>> getCompatible() {
|
||||
return Optional.ofNullable(compatible);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -27,18 +27,13 @@ public class AbstractTargetUpdateCreate<T> extends AbstractNamedEntityBuilder<T>
|
||||
|
||||
@ValidString
|
||||
protected String controllerId;
|
||||
|
||||
protected String address;
|
||||
|
||||
@ToString.Exclude
|
||||
@ValidString
|
||||
protected String securityToken;
|
||||
|
||||
protected Long lastTargetQuery;
|
||||
protected TargetUpdateStatus status;
|
||||
|
||||
protected Boolean requestAttributes;
|
||||
|
||||
protected Long targetTypeId;
|
||||
|
||||
protected AbstractTargetUpdateCreate(final String controllerId) {
|
||||
|
||||
@@ -43,4 +43,4 @@ public abstract class AbstractTypeUpdateCreate<T> extends AbstractNamedEntityBui
|
||||
public Optional<String> getKey() {
|
||||
return Optional.ofNullable(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,5 +18,4 @@ public class GenericDistributionSetTypeUpdate extends AbstractDistributionSetTyp
|
||||
public GenericDistributionSetTypeUpdate(final Long id) {
|
||||
super.id = id;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -23,8 +23,7 @@ import lombok.experimental.Accessors;
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Accessors(fluent = true)
|
||||
public class GenericDistributionSetUpdate extends AbstractDistributionSetUpdateCreate<DistributionSetUpdate>
|
||||
implements DistributionSetUpdate {
|
||||
public class GenericDistributionSetUpdate extends AbstractDistributionSetUpdateCreate<DistributionSetUpdate> implements DistributionSetUpdate {
|
||||
|
||||
@Nullable
|
||||
protected Boolean locked;
|
||||
|
||||
@@ -17,4 +17,4 @@ public class GenericRolloutUpdate extends AbstractNamedEntityBuilder<RolloutUpda
|
||||
public GenericRolloutUpdate(final Long id) {
|
||||
super.id = id;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,5 +18,4 @@ public class GenericSoftwareModuleTypeUpdate extends AbstractSoftwareModuleTypeU
|
||||
public GenericSoftwareModuleTypeUpdate(final Long id) {
|
||||
super.id = id;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -17,4 +17,4 @@ public class GenericTagUpdate extends AbstractTagUpdateCreate<TagUpdate> impleme
|
||||
public GenericTagUpdate(final Long id) {
|
||||
super.id = id;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,5 +18,4 @@ public class GenericTargetFilterQueryUpdate extends AbstractTargetFilterQueryUpd
|
||||
public GenericTargetFilterQueryUpdate(final Long id) {
|
||||
super.id = id;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -21,5 +21,4 @@ public class GenericTargetTypeUpdate extends AbstractTargetTypeUpdateCreate<Targ
|
||||
public GenericTargetTypeUpdate(final Long id) {
|
||||
super.id = id;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -30,10 +30,8 @@ public final class EventPublisherHolder {
|
||||
@Getter
|
||||
@Autowired
|
||||
private ApplicationEventPublisher eventPublisher;
|
||||
|
||||
@Autowired(required = false)
|
||||
private ServiceMatcher serviceMatcher;
|
||||
|
||||
@Autowired
|
||||
private BusProperties bus;
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.rsql;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.time.Instant;
|
||||
|
||||
import org.apache.commons.lang3.text.StrLookup;
|
||||
@@ -43,6 +44,7 @@ import org.eclipse.hawkbit.repository.TimestampCalculator;
|
||||
*/
|
||||
public class VirtualPropertyResolver extends StrLookup<String> implements VirtualPropertyReplacer {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private transient StrSubstitutor substitutor;
|
||||
|
||||
@@ -35,7 +35,6 @@ import org.eclipse.hawkbit.repository.RolloutGroupManagement;
|
||||
import org.eclipse.hawkbit.repository.RolloutHelper;
|
||||
import org.eclipse.hawkbit.repository.RolloutManagement;
|
||||
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.entity.RolloutUpdatedEvent;
|
||||
import org.eclipse.hawkbit.repository.exception.AssignmentQuotaExceededException;
|
||||
@@ -232,7 +231,8 @@ public class JpaRolloutExecutor implements RolloutExecutor {
|
||||
if (readyGroups == rolloutGroups.size()) {
|
||||
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
|
||||
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)) {
|
||||
|
||||
@@ -174,7 +174,6 @@ import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||
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.ConditionalOnProperty;
|
||||
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.transaction.TransactionManagerCustomizers;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Conditional;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.EnableAspectJAutoProxy;
|
||||
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.
|
||||
*
|
||||
* @return a new specification limiting the access, if empty no access restrictions
|
||||
* are to be applied
|
||||
* @return a new specification limiting the access, if empty no access restrictions are to be applied
|
||||
*/
|
||||
Optional<Specification<T>> getAccessRules(Operation operation);
|
||||
|
||||
/**
|
||||
* Append the resource limitation on an already existing specification.
|
||||
*
|
||||
* @param specification is the root specification which needs to be appended by the
|
||||
* resource limitation
|
||||
* @param specification is the root specification which needs to be appended by the resource limitation
|
||||
* @return a new appended specification
|
||||
*/
|
||||
@Nullable
|
||||
@@ -79,17 +77,14 @@ public interface AccessController<T> {
|
||||
* Entity creation
|
||||
*/
|
||||
CREATE,
|
||||
|
||||
/**
|
||||
* Read entities
|
||||
*/
|
||||
READ,
|
||||
|
||||
/**
|
||||
* Entity modification (e.g. name/description change, tag/type assignment, etc.)
|
||||
*/
|
||||
UPDATE,
|
||||
|
||||
/**
|
||||
* Entity deletion
|
||||
*/
|
||||
|
||||
@@ -49,24 +49,20 @@ public class ExceptionMappingAspectHandler implements Ordered {
|
||||
private static final List<Class<?>> MAPPED_EXCEPTION_ORDER = new ArrayList<>(4);
|
||||
|
||||
static {
|
||||
|
||||
MAPPED_EXCEPTION_ORDER.add(DuplicateKeyException.class);
|
||||
MAPPED_EXCEPTION_ORDER.add(DataIntegrityViolationException.class);
|
||||
MAPPED_EXCEPTION_ORDER.add(OptimisticLockingFailureException.class);
|
||||
MAPPED_EXCEPTION_ORDER.add(AccessDeniedException.class);
|
||||
|
||||
EXCEPTION_MAPPING.put(DuplicateKeyException.class.getName(), EntityAlreadyExistsException.class.getName());
|
||||
EXCEPTION_MAPPING.put(DataIntegrityViolationException.class.getName(),
|
||||
EntityAlreadyExistsException.class.getName());
|
||||
EXCEPTION_MAPPING.put(DataIntegrityViolationException.class.getName(), EntityAlreadyExistsException.class.getName());
|
||||
|
||||
EXCEPTION_MAPPING.put(OptimisticLockingFailureException.class.getName(),
|
||||
ConcurrentModificationException.class.getName());
|
||||
EXCEPTION_MAPPING.put(OptimisticLockingFailureException.class.getName(), ConcurrentModificationException.class.getName());
|
||||
EXCEPTION_MAPPING.put(AccessDeniedException.class.getName(), InsufficientPermissionException.class.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* catch exceptions of the {@link TransactionManager} and wrap them to
|
||||
* custom exceptions.
|
||||
* catch exceptions of the {@link TransactionManager} and wrap them to custom exceptions.
|
||||
*
|
||||
* @param ex the thrown and catched exception
|
||||
* @throws Throwable
|
||||
@@ -119,4 +115,4 @@ public class ExceptionMappingAspectHandler implements Ordered {
|
||||
|
||||
return rex;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -47,11 +47,8 @@ public abstract class AbstractAutoAssignExecutor implements AutoAssignExecutor {
|
||||
private static final int PAGE_SIZE = 1000;
|
||||
|
||||
private final TargetFilterQueryManagement targetFilterQueryManagement;
|
||||
|
||||
private final DeploymentManagement deploymentManagement;
|
||||
|
||||
private final PlatformTransactionManager transactionManager;
|
||||
|
||||
private final ContextAware contextAware;
|
||||
|
||||
/**
|
||||
@@ -177,4 +174,4 @@ public abstract class AbstractAutoAssignExecutor implements AutoAssignExecutor {
|
||||
.setConfirmationRequired(filterQuery.isConfirmationRequired()).build())
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -66,11 +66,9 @@ public class AutoAssignChecker extends AbstractAutoAssignExecutor {
|
||||
|
||||
@Override
|
||||
public void checkSingleTarget(String controllerId) {
|
||||
log.debug("Auto assign check call for tenant {} and device {} started", getContextAware().getCurrentTenant(),
|
||||
controllerId);
|
||||
log.debug("Auto assign check call for tenant {} and device {} started", getContextAware().getCurrentTenant(), controllerId);
|
||||
forEachFilterWithAutoAssignDS(filter -> checkForDevice(controllerId, filter));
|
||||
log.debug("Auto assign check call for tenant {} and device {} finished", getContextAware().getCurrentTenant(),
|
||||
controllerId);
|
||||
log.debug("Auto assign check call for tenant {} and device {} finished", getContextAware().getCurrentTenant(), controllerId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -27,11 +27,8 @@ public class AutoAssignScheduler {
|
||||
private static final String PROP_SCHEDULER_DELAY_PLACEHOLDER = "${hawkbit.autoassign.scheduler.fixedDelay:2000}";
|
||||
|
||||
private final SystemManagement systemManagement;
|
||||
|
||||
private final SystemSecurityContext systemSecurityContext;
|
||||
|
||||
private final AutoAssignExecutor autoAssignExecutor;
|
||||
|
||||
private final LockRegistry lockRegistry;
|
||||
|
||||
/**
|
||||
@@ -52,10 +49,8 @@ public class AutoAssignScheduler {
|
||||
}
|
||||
|
||||
/**
|
||||
* Scheduler method called by the spring-async mechanism. Retrieves all
|
||||
* tenants and runs for each
|
||||
* tenant the auto assignments defined in the target filter queries
|
||||
* {@link SystemSecurityContext}.
|
||||
* Scheduler method called by the spring-async mechanism. Retrieves all tenants and runs for each
|
||||
* tenant the auto assignments defined in the target filter queries {@link SystemSecurityContext}.
|
||||
*/
|
||||
@Scheduled(initialDelayString = PROP_SCHEDULER_DELAY_PLACEHOLDER, fixedDelayString = PROP_SCHEDULER_DELAY_PLACEHOLDER)
|
||||
public void autoAssignScheduler() {
|
||||
@@ -87,4 +82,4 @@ public class AutoAssignScheduler {
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -53,15 +53,13 @@ public class AutoActionCleanup implements CleanupTask {
|
||||
* @param deploymentMgmt The {@link DeploymentManagement} to operate on.
|
||||
* @param configMgmt The {@link TenantConfigurationManagement} service.
|
||||
*/
|
||||
public AutoActionCleanup(final DeploymentManagement deploymentMgmt,
|
||||
final TenantConfigurationManagement configMgmt) {
|
||||
public AutoActionCleanup(final DeploymentManagement deploymentMgmt, final TenantConfigurationManagement configMgmt) {
|
||||
this.deploymentMgmt = deploymentMgmt;
|
||||
this.config = configMgmt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
if (!isEnabled()) {
|
||||
log.debug("Action cleanup is disabled for this tenant...");
|
||||
return;
|
||||
@@ -104,5 +102,4 @@ public class AutoActionCleanup implements CleanupTask {
|
||||
final Class<T> valueType) {
|
||||
return config.getConfigurationValue(key, valueType);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -34,15 +34,15 @@ public class AutoCleanupScheduler {
|
||||
private final List<CleanupTask> cleanupTasks;
|
||||
|
||||
/**
|
||||
* Constructs the cleanup schedulers and initializes it with a set of
|
||||
* cleanup handlers.
|
||||
* Constructs the cleanup schedulers and initializes it with a set of cleanup handlers.
|
||||
*
|
||||
* @param systemManagement Management APIs to invoke actions in a certain tenant context.
|
||||
* @param systemSecurityContext The system security context.
|
||||
* @param lockRegistry A registry for shared locks.
|
||||
* @param cleanupTasks A list of cleanup tasks.
|
||||
*/
|
||||
public AutoCleanupScheduler(final SystemManagement systemManagement,
|
||||
public AutoCleanupScheduler(
|
||||
final SystemManagement systemManagement,
|
||||
final SystemSecurityContext systemSecurityContext, final LockRegistry lockRegistry,
|
||||
final List<CleanupTask> cleanupTasks) {
|
||||
this.systemManagement = systemManagement;
|
||||
@@ -88,5 +88,4 @@ public class AutoCleanupScheduler {
|
||||
private Lock obtainLock(final CleanupTask task, final String 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.
|
||||
*/
|
||||
String getId();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -22,5 +22,4 @@ public class JpaActionStatusBuilder implements ActionStatusBuilder {
|
||||
public ActionStatusCreate create(final long actionId) {
|
||||
return new JpaActionStatusCreate(actionId);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -33,4 +33,4 @@ public class JpaActionStatusCreate extends AbstractActionStatusCreate<ActionStat
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -40,5 +40,4 @@ public class JpaDistributionSetBuilder implements DistributionSetBuilder {
|
||||
public DistributionSetCreate create() {
|
||||
return new JpaDistributionSetCreate(distributionSetTypeManagement, softwareModuleManagement);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Optional;
|
||||
|
||||
import lombok.Getter;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetTypeManagement;
|
||||
import org.eclipse.hawkbit.repository.SoftwareModuleManagement;
|
||||
import org.eclipse.hawkbit.repository.ValidString;
|
||||
@@ -28,11 +29,11 @@ import org.springframework.util.StringUtils;
|
||||
/**
|
||||
* Create/build implementation.
|
||||
*/
|
||||
public class JpaDistributionSetCreate extends AbstractDistributionSetUpdateCreate<DistributionSetCreate>
|
||||
implements DistributionSetCreate {
|
||||
public class JpaDistributionSetCreate extends AbstractDistributionSetUpdateCreate<DistributionSetCreate> implements DistributionSetCreate {
|
||||
|
||||
private final DistributionSetTypeManagement distributionSetTypeManagement;
|
||||
private final SoftwareModuleManagement softwareModuleManagement;
|
||||
@Getter
|
||||
@ValidString
|
||||
private String type;
|
||||
|
||||
@@ -56,10 +57,6 @@ public class JpaDistributionSetCreate extends AbstractDistributionSetUpdateCreat
|
||||
Optional.ofNullable(requiredMigrationStep).orElse(Boolean.FALSE));
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
private DistributionSetType findDistributionSetTypeWithExceptionIfNotFound(final String distributionSetTypekey) {
|
||||
return distributionSetTypeManagement.getByKey(distributionSetTypekey)
|
||||
.orElseThrow(() -> new EntityNotFoundException(DistributionSetType.class, distributionSetTypekey));
|
||||
@@ -78,5 +75,4 @@ public class JpaDistributionSetCreate extends AbstractDistributionSetUpdateCreat
|
||||
|
||||
return module;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -36,5 +36,4 @@ public class JpaDistributionSetTypeBuilder implements DistributionSetTypeBuilder
|
||||
public DistributionSetTypeCreate create() {
|
||||
return new JpaDistributionSetTypeCreate(softwareModuleTypeManagement);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -55,5 +55,4 @@ public class JpaDistributionSetTypeCreate extends AbstractDistributionSetTypeUpd
|
||||
|
||||
return module;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -36,5 +36,4 @@ public class JpaRolloutBuilder implements RolloutBuilder {
|
||||
public RolloutCreate create() {
|
||||
return new JpaRolloutCreate(distributionSetManagement);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -22,5 +22,4 @@ public class JpaRolloutGroupBuilder implements RolloutGroupBuilder {
|
||||
public RolloutGroupCreate create() {
|
||||
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.RolloutGroupConditions;
|
||||
|
||||
public class JpaRolloutGroupCreate extends AbstractRolloutGroupCreate<RolloutGroupCreate>
|
||||
implements RolloutGroupCreate {
|
||||
public class JpaRolloutGroupCreate extends AbstractRolloutGroupCreate<RolloutGroupCreate> implements RolloutGroupCreate {
|
||||
|
||||
/**
|
||||
* Set the Success And Error conditions for the rollout group
|
||||
@@ -84,5 +83,4 @@ public class JpaRolloutGroupCreate extends AbstractRolloutGroupCreate<RolloutGro
|
||||
|
||||
return group;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -36,5 +36,4 @@ public class JpaSoftwareModuleBuilder implements SoftwareModuleBuilder {
|
||||
public SoftwareModuleCreate create() {
|
||||
return new JpaSoftwareModuleCreate(softwareModuleTypeManagement);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -21,11 +21,9 @@ import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
||||
/**
|
||||
* Create/build implementation.
|
||||
*/
|
||||
public class JpaSoftwareModuleCreate extends AbstractSoftwareModuleUpdateCreate<SoftwareModuleCreate>
|
||||
implements SoftwareModuleCreate {
|
||||
public class JpaSoftwareModuleCreate extends AbstractSoftwareModuleUpdateCreate<SoftwareModuleCreate> implements SoftwareModuleCreate {
|
||||
|
||||
private final SoftwareModuleTypeManagement softwareModuleTypeManagement;
|
||||
|
||||
private boolean encrypted;
|
||||
|
||||
JpaSoftwareModuleCreate(final SoftwareModuleTypeManagement softwareModuleTypeManagement) {
|
||||
@@ -56,4 +54,4 @@ public class JpaSoftwareModuleCreate extends AbstractSoftwareModuleUpdateCreate<
|
||||
return softwareModuleTypeManagement.getByKey(type.trim())
|
||||
.orElseThrow(() -> new EntityNotFoundException(SoftwareModuleType.class, type.trim()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -36,5 +36,4 @@ public class JpaSoftwareModuleMetadataBuilder implements SoftwareModuleMetadataB
|
||||
public SoftwareModuleMetadataCreate create(final long softwareModuleId) {
|
||||
return new JpaSoftwareModuleMetadataCreate(softwareModuleId, softwareModuleManagement);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -25,8 +25,7 @@ public class JpaSoftwareModuleMetadataCreate
|
||||
|
||||
private final SoftwareModuleManagement softwareModuleManagement;
|
||||
|
||||
JpaSoftwareModuleMetadataCreate(final long softwareModuleId,
|
||||
final SoftwareModuleManagement softwareModuleManagement) {
|
||||
JpaSoftwareModuleMetadataCreate(final long softwareModuleId, final SoftwareModuleManagement softwareModuleManagement) {
|
||||
this.softwareModuleManagement = softwareModuleManagement;
|
||||
this.softwareModuleId = softwareModuleId;
|
||||
}
|
||||
@@ -42,5 +41,4 @@ public class JpaSoftwareModuleMetadataCreate
|
||||
|
||||
return new JpaSoftwareModuleMetadata(key, module, value, isTargetVisible().orElse(false));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -29,5 +29,4 @@ public class JpaSoftwareModuleTypeBuilder implements SoftwareModuleTypeBuilder {
|
||||
public SoftwareModuleTypeCreate create() {
|
||||
return new JpaSoftwareModuleTypeCreate();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,8 @@
|
||||
*/
|
||||
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.SoftwareModuleTypeCreate;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaSoftwareModuleType;
|
||||
@@ -16,15 +18,12 @@ import org.eclipse.hawkbit.repository.jpa.model.JpaSoftwareModuleType;
|
||||
/**
|
||||
* Create/build implementation.
|
||||
*/
|
||||
@NoArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
public class JpaSoftwareModuleTypeCreate extends AbstractSoftwareModuleTypeUpdateCreate<SoftwareModuleTypeCreate>
|
||||
implements SoftwareModuleTypeCreate {
|
||||
|
||||
JpaSoftwareModuleTypeCreate() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public JpaSoftwareModuleType build() {
|
||||
return new JpaSoftwareModuleType(key, name, description, maxAssignments, colour);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,5 +29,4 @@ public class JpaTagBuilder implements TagBuilder {
|
||||
public TagCreate create() {
|
||||
return new JpaTagCreate();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,8 @@
|
||||
*/
|
||||
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.TagCreate;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSetTag;
|
||||
@@ -19,12 +21,9 @@ import org.eclipse.hawkbit.repository.model.Tag;
|
||||
/**
|
||||
* Create/build implementation.
|
||||
*/
|
||||
@NoArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
public class JpaTagCreate extends AbstractTagUpdateCreate<TagCreate> implements TagCreate {
|
||||
|
||||
JpaTagCreate() {
|
||||
|
||||
}
|
||||
|
||||
public JpaDistributionSetTag buildDistributionSetTag() {
|
||||
return new JpaDistributionSetTag(name, description, colour);
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import org.eclipse.hawkbit.repository.model.Target;
|
||||
*/
|
||||
public class JpaTargetBuilder implements TargetBuilder {
|
||||
|
||||
final private TargetTypeManagement targetTypeManagement;
|
||||
private final TargetTypeManagement targetTypeManagement;
|
||||
|
||||
/**
|
||||
* @param targetTypeManagement Target type management
|
||||
@@ -38,5 +38,4 @@ public class JpaTargetBuilder implements TargetBuilder {
|
||||
public TargetCreate create() {
|
||||
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.model.TargetType;
|
||||
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
* Create/build implementation.
|
||||
@@ -37,20 +37,19 @@ public class JpaTargetCreate extends AbstractTargetUpdateCreate<TargetCreate> im
|
||||
|
||||
@Override
|
||||
public JpaTarget build() {
|
||||
JpaTarget target;
|
||||
|
||||
if (StringUtils.isEmpty(securityToken)) {
|
||||
final JpaTarget target;
|
||||
if (ObjectUtils.isEmpty(securityToken)) {
|
||||
target = new JpaTarget(controllerId);
|
||||
} else {
|
||||
target = new JpaTarget(controllerId, securityToken);
|
||||
}
|
||||
|
||||
if (!StringUtils.isEmpty(name)) {
|
||||
if (!ObjectUtils.isEmpty(name)) {
|
||||
target.setName(name);
|
||||
}
|
||||
|
||||
if (targetTypeId != null) {
|
||||
TargetType targetType = targetTypeManagement.get(targetTypeId)
|
||||
final TargetType targetType = targetTypeManagement.get(targetTypeId)
|
||||
.orElseThrow(() -> new EntityNotFoundException(TargetType.class, targetTypeId));
|
||||
target.setTargetType(targetType);
|
||||
}
|
||||
@@ -62,5 +61,4 @@ public class JpaTargetCreate extends AbstractTargetUpdateCreate<TargetCreate> im
|
||||
|
||||
return target;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -42,5 +42,4 @@ public class JpaTargetFilterQueryBuilder implements TargetFilterQueryBuilder {
|
||||
public TargetFilterQueryCreate create() {
|
||||
return new JpaTargetFilterQueryCreate(distributionSetManagement);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -44,5 +44,4 @@ public class JpaTargetFilterQueryCreate extends AbstractTargetFilterQueryUpdateC
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -41,4 +41,4 @@ public class JpaTargetTypeBuilder implements TargetTypeBuilder {
|
||||
public TargetTypeCreate create() {
|
||||
return new JpaTargetTypeCreate(distributionSetTypeManagement);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,8 +25,7 @@ import org.springframework.util.CollectionUtils;
|
||||
/**
|
||||
* Create/build implementation.
|
||||
*/
|
||||
public class JpaTargetTypeCreate extends AbstractTargetTypeUpdateCreate<TargetTypeCreate>
|
||||
implements TargetTypeCreate {
|
||||
public class JpaTargetTypeCreate extends AbstractTargetTypeUpdateCreate<TargetTypeCreate> implements TargetTypeCreate {
|
||||
|
||||
private final DistributionSetTypeManagement distributionSetTypeManagement;
|
||||
|
||||
|
||||
@@ -17,5 +17,4 @@ public class JpaTargetUpdate extends AbstractTargetUpdateCreate<TargetUpdate> im
|
||||
JpaTargetUpdate(final String controllerId) {
|
||||
super(controllerId);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -36,4 +36,4 @@ public final class Constants {
|
||||
* @see Backoff#delay()
|
||||
*/
|
||||
public static final long TX_RT_DELAY = 100;
|
||||
}
|
||||
}
|
||||
@@ -51,4 +51,4 @@ public class MultiTenantJpaTransactionManager extends JpaTransactionManager {
|
||||
em.setProperty(PersistenceUnitProperties.MULTITENANT_PROPERTY_DEFAULT, currentTenant.toUpperCase());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,8 +21,7 @@ import org.springframework.transaction.support.TransactionSynchronizationManager
|
||||
* successful spring transaction commit.The class is thread safe.
|
||||
*/
|
||||
@Slf4j
|
||||
public class AfterTransactionCommitDefaultServiceExecutor extends TransactionSynchronizationAdapter
|
||||
implements AfterTransactionCommitExecutor {
|
||||
public class AfterTransactionCommitDefaultServiceExecutor extends TransactionSynchronizationAdapter implements AfterTransactionCommitExecutor {
|
||||
|
||||
private static final ThreadLocal<List<Runnable>> THREAD_LOCAL_RUNNABLES = new ThreadLocal<>();
|
||||
|
||||
@@ -69,5 +68,4 @@ public class AfterTransactionCommitDefaultServiceExecutor extends TransactionSyn
|
||||
|
||||
runnable.run();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -23,4 +23,4 @@ public interface AfterTransactionCommitExecutor {
|
||||
* @param runnable the after commit runnable
|
||||
*/
|
||||
void afterCommit(Runnable runnable);
|
||||
}
|
||||
}
|
||||
@@ -67,7 +67,8 @@ public abstract class AbstractDsAssignmentStrategy {
|
||||
private final BooleanSupplier confirmationFlowConfig;
|
||||
private final RepositoryProperties repositoryProperties;
|
||||
|
||||
AbstractDsAssignmentStrategy(final TargetRepository targetRepository,
|
||||
AbstractDsAssignmentStrategy(
|
||||
final TargetRepository targetRepository,
|
||||
final AfterTransactionCommitExecutor afterCommit, final EventPublisherHolder eventPublisherHolder,
|
||||
final ActionRepository actionRepository, final ActionStatusRepository actionStatusRepository,
|
||||
final QuotaManagement quotaManagement, final BooleanSupplier multiAssignmentsConfig,
|
||||
@@ -83,7 +84,8 @@ public abstract class AbstractDsAssignmentStrategy {
|
||||
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 Optional<JpaTarget> optTarget = targets.stream()
|
||||
.filter(t -> t.getControllerId().equals(targetWithActionType.getControllerId())).findFirst();
|
||||
@@ -95,8 +97,9 @@ public abstract class AbstractDsAssignmentStrategy {
|
||||
actionForTarget.setActionType(targetWithActionType.getActionType());
|
||||
actionForTarget.setForcedTime(targetWithActionType.getForceTime());
|
||||
actionForTarget.setWeight(
|
||||
targetWithActionType.getWeight() == null ?
|
||||
repositoryProperties.getActionWeightIfAbsent() : targetWithActionType.getWeight());
|
||||
targetWithActionType.getWeight() == null
|
||||
? repositoryProperties.getActionWeightIfAbsent()
|
||||
: targetWithActionType.getWeight());
|
||||
actionForTarget.setActive(true);
|
||||
actionForTarget.setTarget(target);
|
||||
actionForTarget.setDistributionSet(set);
|
||||
@@ -294,7 +297,6 @@ public abstract class AbstractDsAssignmentStrategy {
|
||||
|
||||
private void assertActionsPerTargetQuota(final Target target, final int requested) {
|
||||
final int quota = quotaManagement.getMaxActionsPerTarget();
|
||||
QuotaHelper.assertAssignmentQuota(target.getId(), requested, quota, Action.class, Target.class,
|
||||
actionRepository::countByTargetId);
|
||||
QuotaHelper.assertAssignmentQuota(target.getId(), requested, quota, Action.class, Target.class, actionRepository::countByTargetId);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -47,7 +47,8 @@ public class JpaActionManagement {
|
||||
protected final QuotaManagement quotaManagement;
|
||||
protected final RepositoryProperties repositoryProperties;
|
||||
|
||||
public JpaActionManagement(final ActionRepository actionRepository,
|
||||
public JpaActionManagement(
|
||||
final ActionRepository actionRepository,
|
||||
final ActionStatusRepository actionStatusRepository, final QuotaManagement quotaManagement,
|
||||
final RepositoryProperties repositoryProperties) {
|
||||
this.actionRepository = actionRepository;
|
||||
@@ -172,4 +173,4 @@ public class JpaActionManagement {
|
||||
action.setLastActionStatusCode(actionStatus.getCode().orElse(null));
|
||||
return actionRepository.save(action);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -70,19 +70,15 @@ import org.springframework.validation.annotation.Validated;
|
||||
public class JpaArtifactManagement implements ArtifactManagement {
|
||||
|
||||
private final EntityManager entityManager;
|
||||
|
||||
private final LocalArtifactRepository localArtifactRepository;
|
||||
|
||||
private final SoftwareModuleRepository softwareModuleRepository;
|
||||
|
||||
@Nullable
|
||||
private final ArtifactRepository artifactRepository;
|
||||
|
||||
private final TenantAware tenantAware;
|
||||
|
||||
private final QuotaManagement quotaManagement;
|
||||
|
||||
public JpaArtifactManagement(final EntityManager entityManager,
|
||||
public JpaArtifactManagement(
|
||||
final EntityManager entityManager,
|
||||
final LocalArtifactRepository localArtifactRepository,
|
||||
final SoftwareModuleRepository softwareModuleRepository, @Nullable final ArtifactRepository artifactRepository,
|
||||
final QuotaManagement quotaManagement, final TenantAware tenantAware) {
|
||||
@@ -101,8 +97,8 @@ public class JpaArtifactManagement implements ArtifactManagement {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public Artifact create(final ArtifactUpload artifactUpload) {
|
||||
assertArtifactRepositoryAvailable();
|
||||
|
||||
@@ -138,8 +134,8 @@ public class JpaArtifactManagement implements ArtifactManagement {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public void delete(final long id) {
|
||||
final JpaArtifact toDelete = (JpaArtifact) get(id)
|
||||
.orElseThrow(() -> new EntityNotFoundException(Artifact.class, id));
|
||||
|
||||
@@ -61,10 +61,8 @@ public class JpaConfirmationManagement extends JpaActionManagement implements Co
|
||||
private final EntityFactory entityFactory;
|
||||
private final TargetRepository targetRepository;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public JpaConfirmationManagement(final TargetRepository targetRepository,
|
||||
public JpaConfirmationManagement(
|
||||
final TargetRepository targetRepository,
|
||||
final ActionRepository actionRepository, final ActionStatusRepository actionStatusRepository,
|
||||
final RepositoryProperties repositoryProperties, final QuotaManagement quotaManagement,
|
||||
final EntityFactory entityFactory) {
|
||||
@@ -80,14 +78,12 @@ public class JpaConfirmationManagement extends JpaActionManagement implements Co
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public AutoConfirmationStatus activateAutoConfirmation(final String controllerId, final String initiator,
|
||||
final String remark) {
|
||||
log.trace("'activateAutoConfirmation' was called with values: controllerId={}; initiator={}; remark={}",
|
||||
controllerId, initiator, remark);
|
||||
public AutoConfirmationStatus activateAutoConfirmation(final String controllerId, final String initiator, final String remark) {
|
||||
log.trace(
|
||||
"'activateAutoConfirmation' was called with values: controllerId={}; initiator={}; remark={}", controllerId, initiator, remark);
|
||||
final JpaTarget target = getTargetByControllerIdAndThrowIfNotFound(controllerId);
|
||||
if (target.getAutoConfirmationStatus() != null) {
|
||||
log.debug("'activateAutoConfirmation' was called for an controller id {} with active auto confirmation.",
|
||||
controllerId);
|
||||
log.debug("'activateAutoConfirmation' was called for an controller id {} with active auto confirmation.", controllerId);
|
||||
throw new AutoConfirmationAlreadyActiveException(controllerId);
|
||||
}
|
||||
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 AutoConfirmationStatus autoConfStatus = updatedTarget.getAutoConfirmationStatus();
|
||||
if (autoConfStatus == null) {
|
||||
final String message = String.format("Persisted auto confirmation status is null. "
|
||||
+ "Cannot proceed with giving confirmations for active actions for device %s with initiator %s.",
|
||||
final String message = String.format(
|
||||
"Persisted auto confirmation status is null. " +
|
||||
"Cannot proceed with giving confirmations for active actions for device %s with initiator %s.",
|
||||
controllerId, initiator);
|
||||
log.error("message");
|
||||
throw new IllegalStateException(message);
|
||||
@@ -123,8 +120,8 @@ public class JpaConfirmationManagement extends JpaActionManagement implements Co
|
||||
|
||||
@Override
|
||||
@Transactional(isolation = Isolation.READ_COMMITTED)
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public Action confirmAction(final long actionId, final Integer code, final Collection<String> deviceMessages) {
|
||||
log.trace("Action with id {} confirm request is triggered.", actionId);
|
||||
final Action action = getActionAndThrowExceptionIfNotFound(actionId);
|
||||
@@ -142,8 +139,8 @@ public class JpaConfirmationManagement extends JpaActionManagement implements Co
|
||||
|
||||
@Override
|
||||
@Transactional(isolation = Isolation.READ_COMMITTED)
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public Action denyAction(final long actionId, final Integer code, final Collection<String> deviceMessages) {
|
||||
log.trace("Action with id {} deny request is triggered.", actionId);
|
||||
final Action action = getActionAndThrowExceptionIfNotFound(actionId);
|
||||
@@ -152,8 +149,7 @@ public class JpaConfirmationManagement extends JpaActionManagement implements Co
|
||||
if (deviceMessages != null) {
|
||||
messages.addAll(deviceMessages);
|
||||
}
|
||||
messages.add(RepositoryConstants.SERVER_MESSAGE_PREFIX + "Target rejected action."
|
||||
+ " Action will stay in confirmation pending state.");
|
||||
messages.add(RepositoryConstants.SERVER_MESSAGE_PREFIX + "Target rejected action. Action will stay in confirmation pending state.");
|
||||
final ActionStatusCreate statusCreate = createConfirmationActionStatus(action.getId(), code, messages)
|
||||
.status(Status.WAIT_FOR_CONFIRMATION);
|
||||
return addActionStatus((JpaActionStatusCreate) statusCreate);
|
||||
@@ -191,8 +187,7 @@ public class JpaConfirmationManagement extends JpaActionManagement implements Co
|
||||
}
|
||||
}
|
||||
|
||||
private ActionStatusCreate createConfirmationActionStatus(final long actionId, final Integer code,
|
||||
final Collection<String> messages) {
|
||||
private ActionStatusCreate createConfirmationActionStatus(final long actionId, final Integer code, final Collection<String> messages) {
|
||||
final ActionStatusCreate statusCreate = entityFactory.actionStatus().create(actionId);
|
||||
if (!CollectionUtils.isEmpty(messages)) {
|
||||
statusCreate.messages(messages);
|
||||
@@ -207,25 +202,27 @@ public class JpaConfirmationManagement extends JpaActionManagement implements Co
|
||||
private List<Action> giveConfirmationForActiveActions(final AutoConfirmationStatus autoConfirmationStatus) {
|
||||
final Target target = autoConfirmationStatus.getTarget();
|
||||
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) {
|
||||
if (!action.isWaitingConfirmation()) {
|
||||
log.debug("Auto-confirming action is not necessary, since action {} is in RUNNING state already.",
|
||||
action.getId());
|
||||
log.debug("Auto-confirming action is not necessary, since action {} is in RUNNING state already.", action.getId());
|
||||
return action;
|
||||
}
|
||||
final JpaActionStatus actionStatus = (JpaActionStatus) entityFactory.actionStatus().create(action.getId())
|
||||
final JpaActionStatus actionStatus = (JpaActionStatus) entityFactory.actionStatus()
|
||||
.create(action.getId())
|
||||
.status(Status.RUNNING)
|
||||
.messages(Collections.singletonList(autoConfirmationStatus.constructActionMessage())).build();
|
||||
.messages(Collections.singletonList(autoConfirmationStatus.constructActionMessage()))
|
||||
.build();
|
||||
log.debug(
|
||||
"Automatically confirm actionId '{}' due to active auto-confirmation initiated by '{}' and rollouts system user '{}'",
|
||||
action.getId(), autoConfirmationStatus.getInitiator(), autoConfirmationStatus.getCreatedBy());
|
||||
|
||||
// do not make use of
|
||||
// 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.
|
||||
action.setStatus(Status.RUNNING);
|
||||
actionStatus.setAction(action);
|
||||
@@ -238,4 +235,4 @@ public class JpaConfirmationManagement extends JpaActionManagement implements Co
|
||||
return targetRepository.findOne(TargetSpecifications.hasControllerId(controllerId))
|
||||
.orElseThrow(() -> new EntityNotFoundException(Target.class, controllerId));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -127,46 +127,32 @@ public class JpaControllerManagement extends JpaActionManagement implements Cont
|
||||
|
||||
@Autowired
|
||||
private EntityManager entityManager;
|
||||
|
||||
@Autowired
|
||||
private TargetRepository targetRepository;
|
||||
|
||||
@Autowired
|
||||
private SoftwareModuleRepository softwareModuleRepository;
|
||||
|
||||
@Autowired
|
||||
private TenantConfigurationManagement tenantConfigurationManagement;
|
||||
|
||||
@Autowired
|
||||
private SystemSecurityContext systemSecurityContext;
|
||||
|
||||
@Autowired
|
||||
private EntityFactory entityFactory;
|
||||
|
||||
@Autowired
|
||||
private EventPublisherHolder eventPublisherHolder;
|
||||
|
||||
@Autowired
|
||||
private AfterTransactionCommitExecutor afterCommit;
|
||||
|
||||
@Autowired
|
||||
private SoftwareModuleMetadataRepository softwareModuleMetadataRepository;
|
||||
|
||||
@Autowired
|
||||
private PlatformTransactionManager txManager;
|
||||
|
||||
@Autowired
|
||||
private TenantAware tenantAware;
|
||||
|
||||
@Autowired
|
||||
private ConfirmationManagement confirmationManagement;
|
||||
|
||||
@Autowired
|
||||
private TargetTypeManagement targetTypeManagement;
|
||||
|
||||
@Autowired
|
||||
private DeploymentManagement deploymentManagement;
|
||||
|
||||
@Autowired
|
||||
private DistributionSetManagement distributionSetManagement;
|
||||
|
||||
@@ -179,7 +165,6 @@ public class JpaControllerManagement extends JpaActionManagement implements Cont
|
||||
executorService.scheduleWithFixedDelay(this::flushUpdateQueue,
|
||||
repositoryProperties.getPollPersistenceFlushTime(),
|
||||
repositoryProperties.getPollPersistenceFlushTime(), TimeUnit.MILLISECONDS);
|
||||
|
||||
queue = new LinkedBlockingDeque<>(repositoryProperties.getPollPersistenceQueueSize());
|
||||
} else {
|
||||
queue = null;
|
||||
@@ -194,26 +179,30 @@ public class JpaControllerManagement extends JpaActionManagement implements Cont
|
||||
@Override
|
||||
protected void onActionStatusUpdate(final Action.Status updatedActionStatus, final JpaAction action) {
|
||||
switch (updatedActionStatus) {
|
||||
case ERROR:
|
||||
case ERROR: {
|
||||
final JpaTarget target = (JpaTarget) action.getTarget();
|
||||
target.setUpdateStatus(TargetUpdateStatus.ERROR);
|
||||
handleErrorOnAction(action, target);
|
||||
break;
|
||||
case FINISHED:
|
||||
}
|
||||
case FINISHED: {
|
||||
handleFinishedAndStoreInTargetStatus(action).ifPresent(this::requestControllerAttributes);
|
||||
break;
|
||||
case DOWNLOADED:
|
||||
}
|
||||
case DOWNLOADED: {
|
||||
handleDownloadedActionStatus(action).ifPresent(this::requestControllerAttributes);
|
||||
break;
|
||||
default:
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(isolation = Isolation.READ_COMMITTED)
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public Action addCancelActionStatus(final ActionStatusCreate c) {
|
||||
final JpaActionStatusCreate create = (JpaActionStatusCreate) c;
|
||||
|
||||
@@ -227,19 +216,22 @@ public class JpaControllerManagement extends JpaActionManagement implements Cont
|
||||
|
||||
switch (actionStatus.getStatus()) {
|
||||
case CANCELED:
|
||||
case FINISHED:
|
||||
case FINISHED: {
|
||||
handleFinishedCancelation(actionStatus, action);
|
||||
break;
|
||||
}
|
||||
case ERROR:
|
||||
case CANCEL_REJECTED:
|
||||
case CANCEL_REJECTED: {
|
||||
// Cancellation rejected. Back to running.
|
||||
action.setStatus(Status.RUNNING);
|
||||
break;
|
||||
default:
|
||||
}
|
||||
default: {
|
||||
// information status entry - check for a potential DOS attack
|
||||
assertActionStatusQuota(actionStatus, action);
|
||||
assertActionStatusMessageQuota(actionStatus);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
actionStatus.setAction(actionRepository.save(action));
|
||||
@@ -250,24 +242,22 @@ public class JpaControllerManagement extends JpaActionManagement implements Cont
|
||||
|
||||
@Override
|
||||
public Optional<SoftwareModule> getSoftwareModule(final long id) {
|
||||
return softwareModuleRepository.findById(id).map(s -> (SoftwareModule) s);
|
||||
return softwareModuleRepository.findById(id).map(SoftwareModule.class::cast);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Long, List<SoftwareModuleMetadata>> findTargetVisibleMetaDataBySoftwareModuleId(
|
||||
final Collection<Long> moduleId) {
|
||||
|
||||
public Map<Long, List<SoftwareModuleMetadata>> findTargetVisibleMetaDataBySoftwareModuleId(final Collection<Long> moduleId) {
|
||||
return softwareModuleMetadataRepository
|
||||
.findBySoftwareModuleIdInAndTargetVisible(PageRequest.of(0, RepositoryConstants.MAX_META_DATA_COUNT),
|
||||
moduleId, true)
|
||||
.getContent().stream().collect(Collectors.groupingBy(o -> (Long) o[0],
|
||||
Collectors.mapping(o -> (SoftwareModuleMetadata) o[1], Collectors.toList())));
|
||||
.findBySoftwareModuleIdInAndTargetVisible(
|
||||
PageRequest.of(0, RepositoryConstants.MAX_META_DATA_COUNT), moduleId, true)
|
||||
.getContent().stream()
|
||||
.collect(Collectors.groupingBy(o -> (Long) o[0], Collectors.mapping(o -> (SoftwareModuleMetadata) o[1], Collectors.toList())));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public ActionStatus addInformationalActionStatus(final ActionStatusCreate c) {
|
||||
final JpaActionStatusCreate create = (JpaActionStatusCreate) c;
|
||||
final JpaAction action = getActionAndThrowExceptionIfNotFound(create.getActionId());
|
||||
@@ -282,8 +272,8 @@ public class JpaControllerManagement extends JpaActionManagement implements Cont
|
||||
|
||||
@Override
|
||||
@Transactional(isolation = Isolation.READ_COMMITTED)
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public Action addUpdateActionStatus(final ActionStatusCreate statusCreate) {
|
||||
return addActionStatus((JpaActionStatusCreate) statusCreate);
|
||||
}
|
||||
@@ -314,14 +304,14 @@ public class JpaControllerManagement extends JpaActionManagement implements Cont
|
||||
|
||||
@Override
|
||||
@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) {
|
||||
return findOrRegisterTargetIfItDoesNotExist(controllerId, address, null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@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,
|
||||
final String name, final String type) {
|
||||
final Specification<JpaTarget> spec =
|
||||
@@ -332,8 +322,7 @@ public class JpaControllerManagement extends JpaActionManagement implements Cont
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Action> getActionForDownloadByTargetAndSoftwareModule(final String controllerId,
|
||||
final long moduleId) {
|
||||
public Optional<Action> getActionForDownloadByTargetAndSoftwareModule(final String controllerId, final long moduleId) {
|
||||
throwExceptionIfTargetDoesNotExist(controllerId);
|
||||
throwExceptionIfSoftwareModuleDoesNotExist(moduleId);
|
||||
|
||||
@@ -409,16 +398,16 @@ public class JpaControllerManagement extends JpaActionManagement implements Cont
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public Action registerRetrieved(final long actionId, final String message) {
|
||||
return handleRegisterRetrieved(actionId, message);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public Target updateControllerAttributes(final String controllerId, final Map<String, String> data,
|
||||
final UpdateMode mode) {
|
||||
|
||||
|
||||
@@ -122,11 +122,10 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
|
||||
* Maximum amount of Actions that are started at once.
|
||||
*/
|
||||
private static final int ACTION_PAGE_LIMIT = 1000;
|
||||
|
||||
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 "
|
||||
+ ACTION_PAGE_LIMIT;
|
||||
|
||||
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 " + ACTION_PAGE_LIMIT;
|
||||
private static final EnumMap<Database, String> QUERY_DELETE_ACTIONS_BY_STATE_AND_LAST_MODIFIED;
|
||||
|
||||
private final EntityManager entityManager;
|
||||
private final DistributionSetManagement distributionSetManagement;
|
||||
private final TargetRepository targetRepository;
|
||||
@@ -144,14 +143,18 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
|
||||
|
||||
static {
|
||||
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
|
||||
+ ") FROM sp_action WHERE tenant=#tenant AND status IN (%s) AND last_modified_at<#last_modified_at ");
|
||||
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 + ")");
|
||||
QUERY_DELETE_ACTIONS_BY_STATE_AND_LAST_MODIFIED.put(
|
||||
Database.SQL_SERVER,
|
||||
"DELETE TOP (" + ACTION_PAGE_LIMIT + ") FROM sp_action " +
|
||||
"WHERE tenant=#tenant AND status IN (%s) AND last_modified_at<#last_modified_at ");
|
||||
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 ActionStatusRepository actionStatusRepository, final AuditorAware<String> auditorProvider,
|
||||
final EventPublisherHolder eventPublisherHolder, final AfterTransactionCommitExecutor afterCommit,
|
||||
@@ -182,17 +185,15 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
|
||||
|
||||
@Override
|
||||
@Transactional(isolation = Isolation.READ_COMMITTED)
|
||||
public List<DistributionSetAssignmentResult> assignDistributionSets(
|
||||
final List<DeploymentRequest> deploymentRequests) {
|
||||
public List<DistributionSetAssignmentResult> assignDistributionSets(final List<DeploymentRequest> deploymentRequests) {
|
||||
return assignDistributionSets(tenantAware.getCurrentUsername(), deploymentRequests, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(isolation = Isolation.READ_COMMITTED)
|
||||
public List<DistributionSetAssignmentResult> assignDistributionSets(final String initiatedBy,
|
||||
final List<DeploymentRequest> deploymentRequests, final String actionMessage) {
|
||||
WeightValidationHelper.usingContext(systemSecurityContext, tenantConfigurationManagement)
|
||||
.validate(deploymentRequests);
|
||||
public List<DistributionSetAssignmentResult> assignDistributionSets(
|
||||
final String initiatedBy, final List<DeploymentRequest> deploymentRequests, final String actionMessage) {
|
||||
WeightValidationHelper.usingContext(systemSecurityContext, tenantConfigurationManagement).validate(deploymentRequests);
|
||||
return assignDistributionSets(initiatedBy, deploymentRequests, actionMessage, onlineDsAssignmentStrategy);
|
||||
}
|
||||
|
||||
@@ -213,15 +214,14 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
|
||||
|
||||
@Override
|
||||
@Transactional(isolation = Isolation.READ_COMMITTED)
|
||||
public List<DistributionSetAssignmentResult> offlineAssignedDistributionSets(
|
||||
final Collection<Entry<String, Long>> assignments) {
|
||||
public List<DistributionSetAssignmentResult> offlineAssignedDistributionSets(final Collection<Entry<String, Long>> assignments) {
|
||||
return offlineAssignedDistributionSets(assignments, tenantAware.getCurrentUsername());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(isolation = Isolation.READ_COMMITTED)
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public Action cancelAction(final long actionId) {
|
||||
log.debug("cancelAction({})", actionId);
|
||||
|
||||
@@ -381,15 +381,14 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
|
||||
|
||||
@Override
|
||||
@Transactional(isolation = Isolation.READ_COMMITTED)
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public Action forceQuitAction(final long actionId) {
|
||||
final JpaAction action = actionRepository.findById(actionId)
|
||||
.orElseThrow(() -> new EntityNotFoundException(Action.class, actionId));
|
||||
|
||||
if (!action.isCancelingOrCanceled()) {
|
||||
throw new ForceQuitActionNotAllowedException(
|
||||
action.getId() + " is not canceled yet and cannot be force quit");
|
||||
throw new ForceQuitActionNotAllowedException(action.getId() + " is not canceled yet and cannot be force quit");
|
||||
}
|
||||
|
||||
if (!action.isActive()) {
|
||||
@@ -411,8 +410,8 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public Action forceTargetAction(final long actionId) {
|
||||
final JpaAction action = actionRepository.findById(actionId).map(this::assertTargetUpdateAllowed)
|
||||
.orElseThrow(() -> new EntityNotFoundException(Action.class, actionId));
|
||||
@@ -426,13 +425,12 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
|
||||
|
||||
@Override
|
||||
@Transactional(isolation = Isolation.READ_COMMITTED)
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public void cancelInactiveScheduledActionsForTargets(final List<Long> targetIds) {
|
||||
if (!isMultiAssignmentsEnabled()) {
|
||||
targetRepository.getAccessController().ifPresent(v -> {
|
||||
if (targetRepository.count(AccessController.Operation.UPDATE,
|
||||
TargetSpecifications.hasIdIn(targetIds)) != targetIds.size()) {
|
||||
if (targetRepository.count(AccessController.Operation.UPDATE, TargetSpecifications.hasIdIn(targetIds)) != targetIds.size()) {
|
||||
throw new EntityNotFoundException(Target.class, targetIds);
|
||||
}
|
||||
});
|
||||
@@ -443,8 +441,7 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startScheduledActionsByRolloutGroupParent(final long rolloutId, final long distributionSetId,
|
||||
final Long rolloutGroupParentId) {
|
||||
public void startScheduledActionsByRolloutGroupParent(final long rolloutId, final long distributionSetId, final Long rolloutGroupParentId) {
|
||||
while (DeploymentHelper.runInNewTransaction(
|
||||
txManager,
|
||||
"startScheduledActions-" + rolloutId,
|
||||
@@ -540,10 +537,8 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void cancelActionsForDistributionSet(final CancelationType cancelationType,
|
||||
final DistributionSet distributionSet) {
|
||||
actionRepository.findAll(ActionSpecifications
|
||||
.byDistributionSetIdAndActiveAndStatusIsNot(distributionSet.getId(), Status.CANCELING))
|
||||
public void cancelActionsForDistributionSet(final CancelationType cancelationType, final DistributionSet distributionSet) {
|
||||
actionRepository.findAll(ActionSpecifications.byDistributionSetIdAndActiveAndStatusIsNot(distributionSet.getId(), Status.CANCELING))
|
||||
.forEach(action -> {
|
||||
try {
|
||||
assertTargetUpdateAllowed(action);
|
||||
@@ -580,24 +575,24 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
|
||||
return getConfigValue(REPOSITORY_ACTIONS_AUTOCLOSE_ENABLED, Boolean.class);
|
||||
}
|
||||
|
||||
private static Map<Long, List<TargetWithActionType>> convertRequest(
|
||||
final Collection<DeploymentRequest> deploymentRequests) {
|
||||
return deploymentRequests.stream().collect(Collectors.groupingBy(DeploymentRequest::getDistributionSetId,
|
||||
Collectors.mapping(DeploymentRequest::getTargetWithActionType, Collectors.toList())));
|
||||
private static Map<Long, List<TargetWithActionType>> convertRequest(final Collection<DeploymentRequest> deploymentRequests) {
|
||||
return deploymentRequests.stream().collect(
|
||||
Collectors.groupingBy(DeploymentRequest::getDistributionSetId,
|
||||
Collectors.mapping(DeploymentRequest::getTargetWithActionType, Collectors.toList())));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
* statements
|
||||
*/
|
||||
private static List<List<Long>> getTargetEntitiesAsChunks(final List<JpaTarget> targetEntities) {
|
||||
return ListUtils.partition(targetEntities.stream().map(Target::getId).collect(Collectors.toList()),
|
||||
Constants.MAX_ENTRIES_IN_STATEMENT);
|
||||
return ListUtils.partition(targetEntities.stream().map(Target::getId).collect(Collectors.toList()), 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 int alreadyAssignedTargetsCount = totalTargetsForAssignment - assignedActions.size();
|
||||
|
||||
@@ -631,15 +626,16 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
|
||||
return template;
|
||||
}
|
||||
|
||||
private List<DistributionSetAssignmentResult> assignDistributionSets(final String initiatedBy,
|
||||
private List<DistributionSetAssignmentResult> assignDistributionSets(
|
||||
final String initiatedBy,
|
||||
final List<DeploymentRequest> deploymentRequests, final String actionMessage,
|
||||
final AbstractDsAssignmentStrategy strategy) {
|
||||
final List<DeploymentRequest> validatedRequests = validateAndFilterRequestForAssignments(deploymentRequests);
|
||||
final Map<Long, List<TargetWithActionType>> assignmentsByDsIds = convertRequest(validatedRequests);
|
||||
|
||||
final List<DistributionSetAssignmentResult> results = assignmentsByDsIds.entrySet().stream()
|
||||
.map(entry -> assignDistributionSetToTargetsWithRetry(initiatedBy, entry.getKey(), entry.getValue(),
|
||||
actionMessage, strategy))
|
||||
.map(entry -> assignDistributionSetToTargetsWithRetry(
|
||||
initiatedBy, entry.getKey(), entry.getValue(), actionMessage, strategy))
|
||||
.toList();
|
||||
strategy.sendDeploymentEvents(results);
|
||||
return results;
|
||||
@@ -663,7 +659,9 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
|
||||
private void checkForMultiAssignment(final Collection<DeploymentRequest> deploymentRequests) {
|
||||
if (!isMultiAssignmentsEnabled()) {
|
||||
final long distinctTargetsInRequest = deploymentRequests.stream()
|
||||
.map(request -> request.getTargetWithActionType().getControllerId()).distinct().count();
|
||||
.map(request -> request.getTargetWithActionType().getControllerId())
|
||||
.distinct()
|
||||
.count();
|
||||
if (distinctTargetsInRequest < deploymentRequests.size()) {
|
||||
throw new MultiAssignmentIsNotEnabledException();
|
||||
}
|
||||
@@ -676,14 +674,16 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
|
||||
}
|
||||
|
||||
private void checkForTargetTypeCompatibility(final List<DeploymentRequest> deploymentRequests) {
|
||||
final List<String> controllerIds = deploymentRequests.stream().map(DeploymentRequest::getControllerId)
|
||||
.distinct().toList();
|
||||
final List<String> controllerIds = deploymentRequests.stream()
|
||||
.map(DeploymentRequest::getControllerId)
|
||||
.distinct()
|
||||
.toList();
|
||||
final List<Long> distSetIds = deploymentRequests.stream().map(DeploymentRequest::getDistributionSetId)
|
||||
.distinct().toList();
|
||||
.distinct()
|
||||
.toList();
|
||||
|
||||
if (controllerIds.size() > 1 && distSetIds.size() > 1) {
|
||||
throw new IllegalStateException(
|
||||
"Assigning multiple Distribution Sets to multiple Targets simultaneously is not allowed!");
|
||||
throw new IllegalStateException("Assigning multiple Distribution Sets to multiple Targets simultaneously is not allowed!");
|
||||
}
|
||||
|
||||
if (distSetIds.size() == 1) {
|
||||
@@ -699,7 +699,10 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
|
||||
.stream()
|
||||
.map(ids -> targetRepository.findAll(TargetSpecifications.hasControllerIdIn(ids)
|
||||
.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()) {
|
||||
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
|
||||
// MAX_ENTRIES_IN_STATEMENT
|
||||
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());
|
||||
|
||||
if (!incompatibleDistSetTypes.isEmpty()) {
|
||||
final Set<String> distSetTypeNames = incompatibleDistSetTypes.stream().map(DistributionSetType::getName)
|
||||
final Set<String> distSetTypeNames = incompatibleDistSetTypes.stream()
|
||||
.map(DistributionSetType::getName)
|
||||
.collect(Collectors.toSet());
|
||||
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) {
|
||||
final List<String> controllerIds = deploymentRequests.stream().map(DeploymentRequest::getControllerId)
|
||||
.distinct().toList();
|
||||
final List<String> controllerIds = deploymentRequests.stream()
|
||||
.map(DeploymentRequest::getControllerId)
|
||||
.distinct()
|
||||
.toList();
|
||||
|
||||
final List<String> found = targetRepository
|
||||
.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,
|
||||
final Collection<TargetWithActionType> targetsWithActionType, final String actionMessage,
|
||||
final AbstractDsAssignmentStrategy assignmentStrategy) {
|
||||
final JpaDistributionSet distributionSet =
|
||||
(JpaDistributionSet) distributionSetManagement.getValidAndComplete(dsId);
|
||||
final JpaDistributionSet distributionSet = (JpaDistributionSet) distributionSetManagement.getValidAndComplete(dsId);
|
||||
|
||||
if (((JpaDistributionSetManagement) distributionSetManagement).isImplicitLockApplicable(distributionSet)) {
|
||||
// without new transaction DS changed event is not thrown
|
||||
|
||||
@@ -183,4 +183,4 @@ public class JpaDistributionSetInvalidationManagement implements DistributionSet
|
||||
.countByDistributionSetIdAndActiveIsTrueAndStatusIsNot(distributionSet, Status.CANCELING))
|
||||
.sum();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -151,8 +151,8 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public List<DistributionSet> create(final Collection<DistributionSetCreate> creates) {
|
||||
final List<JpaDistributionSet> toCreate = creates.stream().map(JpaDistributionSetCreate.class::cast)
|
||||
.map(this::setDefaultTypeIfMissing).map(JpaDistributionSetCreate::build).toList();
|
||||
@@ -162,8 +162,8 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public DistributionSet create(final DistributionSetCreate c) {
|
||||
final JpaDistributionSetCreate create = (JpaDistributionSetCreate) c;
|
||||
setDefaultTypeIfMissing(create);
|
||||
@@ -173,8 +173,8 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public DistributionSet update(final DistributionSetUpdate u) {
|
||||
final GenericDistributionSetUpdate update = (GenericDistributionSetUpdate) u;
|
||||
|
||||
@@ -212,16 +212,16 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public void delete(final long id) {
|
||||
delete(List.of(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public void delete(final Collection<Long> distributionSetIDs) {
|
||||
getDistributionSets(distributionSetIDs); // throws EntityNotFoundException if any of these do not exists
|
||||
final List<JpaDistributionSet> setsFound = distributionSetRepository.findAll(
|
||||
@@ -288,8 +288,8 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public DistributionSet assignSoftwareModules(final long id, final Collection<Long> softwareModuleId) {
|
||||
final JpaDistributionSet set = (JpaDistributionSet) getValid(id);
|
||||
assertDistributionSetIsNotAssignedToTargets(id);
|
||||
@@ -308,8 +308,8 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public List<DistributionSet> assignTag(final Collection<Long> ids, final long dsTagId) {
|
||||
return updateTag(ids, dsTagId, (tag, distributionSet) -> {
|
||||
if (distributionSet.getTags().contains(tag)) {
|
||||
@@ -323,8 +323,8 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public List<DistributionSet> unassignTag(final Collection<Long> ids, final long dsTagId) {
|
||||
return updateTag(ids, dsTagId, (tag, distributionSet) -> {
|
||||
if (distributionSet.getTags().contains(tag)) {
|
||||
@@ -338,8 +338,8 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public List<DistributionSetMetadata> createMetaData(final long id, final Collection<MetaData> md) {
|
||||
final JpaDistributionSet distributionSet = (JpaDistributionSet) getValid(id);
|
||||
assertMetaDataQuota(id, md.size());
|
||||
@@ -357,8 +357,8 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public void deleteMetaData(final long id, final String key) {
|
||||
final JpaDistributionSetMetadata metadata = (JpaDistributionSetMetadata) getMetaDataByDistributionSetId(
|
||||
id, key)
|
||||
@@ -373,8 +373,8 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public void lock(final long id) {
|
||||
final JpaDistributionSet distributionSet = getById(id);
|
||||
if (!distributionSet.isLocked()) {
|
||||
@@ -386,8 +386,8 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public void unlock(final long id) {
|
||||
final JpaDistributionSet distributionSet = getById(id);
|
||||
if (distributionSet.isLocked()) {
|
||||
@@ -570,8 +570,8 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public DistributionSet unassignSoftwareModule(final long id, final long moduleId) {
|
||||
final JpaDistributionSet set = (JpaDistributionSet) getValid(id);
|
||||
assertDistributionSetIsNotAssignedToTargets(id);
|
||||
@@ -584,8 +584,8 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public DistributionSetMetadata updateMetaData(final long id, final MetaData md) {
|
||||
// check if exists otherwise throw entity not found exception
|
||||
final JpaDistributionSetMetadata toUpdate = (JpaDistributionSetMetadata) getMetaDataByDistributionSetId(id,
|
||||
@@ -641,8 +641,8 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public DistributionSetTagAssignmentResult toggleTagAssignment(final Collection<Long> ids, final String tagName) {
|
||||
return updateTag(
|
||||
ids,
|
||||
@@ -678,8 +678,8 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public DistributionSet unassignTag(final long id, final long dsTagId) {
|
||||
final JpaDistributionSet set = (JpaDistributionSet) getWithDetails(id)
|
||||
.orElseThrow(() -> new EntityNotFoundException(DistributionSet.class, id));
|
||||
|
||||
@@ -54,14 +54,12 @@ import org.springframework.validation.annotation.Validated;
|
||||
public class JpaDistributionSetTagManagement implements DistributionSetTagManagement {
|
||||
|
||||
private final DistributionSetTagRepository distributionSetTagRepository;
|
||||
|
||||
private final DistributionSetRepository distributionSetRepository;
|
||||
|
||||
private final VirtualPropertyReplacer virtualPropertyReplacer;
|
||||
|
||||
private final Database database;
|
||||
|
||||
public JpaDistributionSetTagManagement(final DistributionSetTagRepository distributionSetTagRepository,
|
||||
public JpaDistributionSetTagManagement(
|
||||
final DistributionSetTagRepository distributionSetTagRepository,
|
||||
final DistributionSetRepository distributionSetRepository,
|
||||
final VirtualPropertyReplacer virtualPropertyReplacer, final Database database) {
|
||||
this.distributionSetTagRepository = distributionSetTagRepository;
|
||||
@@ -72,8 +70,8 @@ public class JpaDistributionSetTagManagement implements DistributionSetTagManage
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public List<DistributionSetTag> create(final Collection<TagCreate> dst) {
|
||||
final List<JpaDistributionSetTag> toCreate = dst.stream().map(JpaTagCreate.class::cast)
|
||||
.map(JpaTagCreate::buildDistributionSetTag).toList();
|
||||
@@ -83,8 +81,8 @@ public class JpaDistributionSetTagManagement implements DistributionSetTagManage
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public DistributionSetTag create(final TagCreate c) {
|
||||
final JpaTagCreate create = (JpaTagCreate) c;
|
||||
return distributionSetTagRepository.save(AccessController.Operation.CREATE, create.buildDistributionSetTag());
|
||||
@@ -92,8 +90,8 @@ public class JpaDistributionSetTagManagement implements DistributionSetTagManage
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public DistributionSetTag update(final TagUpdate u) {
|
||||
final GenericTagUpdate update = (GenericTagUpdate) u;
|
||||
|
||||
@@ -114,16 +112,16 @@ public class JpaDistributionSetTagManagement implements DistributionSetTagManage
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public void delete(final long id) {
|
||||
distributionSetTagRepository.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public void delete(final Collection<Long> ids) {
|
||||
final List<JpaDistributionSetTag> setsFound = distributionSetTagRepository.findAllById(ids);
|
||||
|
||||
@@ -166,8 +164,8 @@ public class JpaDistributionSetTagManagement implements DistributionSetTagManage
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public void delete(final String tagName) {
|
||||
final JpaDistributionSetTag dsTag = distributionSetTagRepository
|
||||
.findOne(DistributionSetTagSpecifications.byName(tagName))
|
||||
|
||||
@@ -105,8 +105,8 @@ public class JpaDistributionSetTypeManagement implements DistributionSetTypeMana
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public DistributionSetType assignOptionalSoftwareModuleTypes(final long id,
|
||||
final Collection<Long> softwareModulesTypeIds) {
|
||||
return assignSoftwareModuleTypes(id, softwareModulesTypeIds, false);
|
||||
@@ -114,8 +114,8 @@ public class JpaDistributionSetTypeManagement implements DistributionSetTypeMana
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public DistributionSetType assignMandatorySoftwareModuleTypes(final long id,
|
||||
final Collection<Long> softwareModuleTypeIds) {
|
||||
return assignSoftwareModuleTypes(id, softwareModuleTypeIds, true);
|
||||
@@ -123,8 +123,8 @@ public class JpaDistributionSetTypeManagement implements DistributionSetTypeMana
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public DistributionSetType unassignSoftwareModuleType(final long id, final long softwareModuleTypeId) {
|
||||
final JpaDistributionSetType type = findDistributionSetTypeAndThrowExceptionIfNotFound(id);
|
||||
|
||||
@@ -137,8 +137,8 @@ public class JpaDistributionSetTypeManagement implements DistributionSetTypeMana
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public List<DistributionSetType> create(final Collection<DistributionSetTypeCreate> types) {
|
||||
final List<JpaDistributionSetType> typesToCreate = types.stream().map(JpaDistributionSetTypeCreate.class::cast)
|
||||
.map(JpaDistributionSetTypeCreate::build).toList();
|
||||
@@ -149,8 +149,8 @@ public class JpaDistributionSetTypeManagement implements DistributionSetTypeMana
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public DistributionSetType create(final DistributionSetTypeCreate c) {
|
||||
final JpaDistributionSetType distributionSetType = ((JpaDistributionSetTypeCreate) c).build();
|
||||
|
||||
@@ -159,8 +159,8 @@ public class JpaDistributionSetTypeManagement implements DistributionSetTypeMana
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public DistributionSetType update(final DistributionSetTypeUpdate u) {
|
||||
final GenericDistributionSetTypeUpdate update = (GenericDistributionSetTypeUpdate) u;
|
||||
|
||||
@@ -202,8 +202,8 @@ public class JpaDistributionSetTypeManagement implements DistributionSetTypeMana
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public void delete(final long id) {
|
||||
final JpaDistributionSetType toDelete = distributionSetTypeRepository.findById(id)
|
||||
.orElseThrow(() -> new EntityNotFoundException(DistributionSetType.class, id));
|
||||
@@ -220,8 +220,8 @@ public class JpaDistributionSetTypeManagement implements DistributionSetTypeMana
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public void delete(final Collection<Long> ids) {
|
||||
distributionSetTypeRepository.deleteAllById(ids);
|
||||
}
|
||||
|
||||
@@ -106,10 +106,10 @@ public class JpaRolloutManagement implements RolloutManagement {
|
||||
private static final List<RolloutStatus> ACTIVE_ROLLOUTS = Arrays.asList(RolloutStatus.CREATING,
|
||||
RolloutStatus.DELETING, RolloutStatus.STARTING, RolloutStatus.READY, RolloutStatus.RUNNING,
|
||||
RolloutStatus.STOPPING);
|
||||
|
||||
private static final List<RolloutStatus> ROLLOUT_STATUS_STOPPABLE = Arrays.asList(RolloutStatus.RUNNING,
|
||||
RolloutStatus.CREATING, RolloutStatus.PAUSED, RolloutStatus.READY, RolloutStatus.STARTING,
|
||||
RolloutStatus.WAITING_FOR_APPROVAL, RolloutStatus.APPROVAL_DENIED);
|
||||
|
||||
private final TargetManagement targetManagement;
|
||||
private final DistributionSetManagement distributionSetManagement;
|
||||
private final VirtualPropertyReplacer virtualPropertyReplacer;
|
||||
@@ -181,8 +181,8 @@ public class JpaRolloutManagement implements RolloutManagement {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public Rollout create(final RolloutCreate rollout, final int amountGroup, final boolean confirmationRequired,
|
||||
final RolloutGroupConditions conditions, final DynamicRolloutGroupTemplate dynamicRolloutGroupTemplate) {
|
||||
if (amountGroup < 0) {
|
||||
@@ -207,8 +207,8 @@ public class JpaRolloutManagement implements RolloutManagement {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public Rollout create(@NotNull @Valid RolloutCreate create, int amountGroup, boolean confirmationRequired,
|
||||
@NotNull RolloutGroupConditions conditions) {
|
||||
return create(create, amountGroup, confirmationRequired, conditions, null);
|
||||
@@ -216,8 +216,8 @@ public class JpaRolloutManagement implements RolloutManagement {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public Rollout create(final RolloutCreate rollout, final List<RolloutGroupCreate> groups,
|
||||
final RolloutGroupConditions conditions) {
|
||||
if (groups.isEmpty()) {
|
||||
@@ -324,8 +324,8 @@ public class JpaRolloutManagement implements RolloutManagement {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public void pauseRollout(final long rolloutId) {
|
||||
final JpaRollout rollout = getRolloutOrThrowExceptionIfNotFound(rolloutId);
|
||||
if (RolloutStatus.RUNNING != rollout.getStatus()) {
|
||||
@@ -343,8 +343,8 @@ public class JpaRolloutManagement implements RolloutManagement {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public void resumeRollout(final long rolloutId) {
|
||||
final JpaRollout rollout = getRolloutOrThrowExceptionIfNotFound(rolloutId);
|
||||
if (RolloutStatus.PAUSED != rollout.getStatus()) {
|
||||
@@ -357,29 +357,32 @@ public class JpaRolloutManagement implements RolloutManagement {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public Rollout approveOrDeny(final long rolloutId, final Rollout.ApprovalDecision decision) {
|
||||
return this.approveOrDeny(rolloutId, decision, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public Rollout approveOrDeny(final long rolloutId, final Rollout.ApprovalDecision decision, final String remark) {
|
||||
log.debug("approveOrDeny rollout called for rollout {} with decision {}", rolloutId, decision);
|
||||
final JpaRollout rollout = getRolloutOrThrowExceptionIfNotFound(rolloutId);
|
||||
RolloutHelper.verifyRolloutInStatus(rollout, RolloutStatus.WAITING_FOR_APPROVAL);
|
||||
switch (decision) {
|
||||
case APPROVED:
|
||||
case APPROVED: {
|
||||
rollout.setStatus(RolloutStatus.READY);
|
||||
break;
|
||||
case DENIED:
|
||||
}
|
||||
case DENIED: {
|
||||
rollout.setStatus(RolloutStatus.APPROVAL_DENIED);
|
||||
break;
|
||||
default:
|
||||
}
|
||||
default: {
|
||||
throw new IllegalArgumentException("Unknown approval decision: " + decision);
|
||||
}
|
||||
}
|
||||
rollout.setApprovalDecidedBy(rolloutApprovalStrategy.getApprovalUser(rollout));
|
||||
if (remark != null) {
|
||||
@@ -390,8 +393,8 @@ public class JpaRolloutManagement implements RolloutManagement {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public Rollout start(final long rolloutId) {
|
||||
log.debug("startRollout called for rollout {}", rolloutId);
|
||||
|
||||
@@ -404,8 +407,8 @@ public class JpaRolloutManagement implements RolloutManagement {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public Rollout update(final RolloutUpdate u) {
|
||||
final GenericRolloutUpdate update = (GenericRolloutUpdate) u;
|
||||
final JpaRollout rollout = getRolloutOrThrowExceptionIfNotFound(update.getId());
|
||||
@@ -419,8 +422,8 @@ public class JpaRolloutManagement implements RolloutManagement {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public void delete(final long rolloutId) {
|
||||
final JpaRollout jpaRollout = rolloutRepository.findById(rolloutId)
|
||||
.orElseThrow(() -> new EntityNotFoundException(Rollout.class, rolloutId));
|
||||
@@ -451,8 +454,8 @@ public class JpaRolloutManagement implements RolloutManagement {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public void triggerNextGroup(final long rolloutId) {
|
||||
final JpaRollout rollout = getRolloutOrThrowExceptionIfNotFound(rolloutId);
|
||||
if (RolloutStatus.RUNNING != rollout.getStatus()) {
|
||||
@@ -479,8 +482,7 @@ public class JpaRolloutManagement implements RolloutManagement {
|
||||
@Override
|
||||
public void setRolloutStatusDetails(final Slice<Rollout> rollouts) {
|
||||
final List<Long> rolloutIds = rollouts.getContent().stream().map(Rollout::getId).collect(Collectors.toList());
|
||||
final Map<Long, List<TotalTargetCountActionStatus>> allStatesForRollout = getStatusCountItemForRollout(
|
||||
rolloutIds);
|
||||
final Map<Long, List<TotalTargetCountActionStatus>> allStatesForRollout = getStatusCountItemForRollout(rolloutIds);
|
||||
|
||||
if (allStatesForRollout != null) {
|
||||
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
|
||||
* from the supplied default conditions.
|
||||
* In case the given group is missing conditions or actions, they will be set from the supplied default conditions.
|
||||
*
|
||||
* @param create group to check
|
||||
* @param conditions default conditions and actions
|
||||
*/
|
||||
private static JpaRolloutGroup prepareRolloutGroupWithDefaultConditions(final RolloutGroupCreate create,
|
||||
final RolloutGroupConditions conditions) {
|
||||
private static JpaRolloutGroup prepareRolloutGroupWithDefaultConditions(
|
||||
final RolloutGroupCreate create, final RolloutGroupConditions conditions) {
|
||||
final JpaRolloutGroup group = ((JpaRolloutGroupCreate) create).build();
|
||||
|
||||
if (group.getSuccessCondition() == null) {
|
||||
|
||||
@@ -115,8 +115,8 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public List<SoftwareModule> create(final Collection<SoftwareModuleCreate> swModules) {
|
||||
final List<JpaSoftwareModule> modulesToCreate = swModules.stream().map(JpaSoftwareModuleCreate.class::cast)
|
||||
.map(JpaSoftwareModuleCreate::build).toList();
|
||||
@@ -135,8 +135,8 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public SoftwareModule create(final SoftwareModuleCreate c) {
|
||||
final JpaSoftwareModuleCreate create = (JpaSoftwareModuleCreate) c;
|
||||
|
||||
@@ -152,8 +152,8 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public SoftwareModule update(final SoftwareModuleUpdate u) {
|
||||
final GenericSoftwareModuleUpdate update = (GenericSoftwareModuleUpdate) u;
|
||||
|
||||
@@ -180,16 +180,16 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public void delete(final long id) {
|
||||
delete(List.of(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public void delete(final Collection<Long> ids) {
|
||||
final List<JpaSoftwareModule> swModulesToDelete = softwareModuleRepository.findAllById(ids);
|
||||
if (swModulesToDelete.size() < ids.size()) {
|
||||
@@ -267,8 +267,8 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public List<SoftwareModuleMetadata> createMetaData(final Collection<SoftwareModuleMetadataCreate> create) {
|
||||
if (!create.isEmpty()) {
|
||||
// check if all metadata entries refer to the same software module
|
||||
@@ -304,8 +304,8 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public SoftwareModuleMetadata createMetaData(final SoftwareModuleMetadataCreate c) {
|
||||
final JpaSoftwareModuleMetadataCreate create = (JpaSoftwareModuleMetadataCreate) c;
|
||||
final Long id = create.getSoftwareModuleId();
|
||||
@@ -321,8 +321,8 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public void deleteMetaData(final long id, final String key) {
|
||||
final JpaSoftwareModuleMetadata metadata = (JpaSoftwareModuleMetadata) getMetaDataBySoftwareModuleId(id,
|
||||
key).orElseThrow(() -> new EntityNotFoundException(SoftwareModuleMetadata.class, id, key));
|
||||
@@ -439,8 +439,8 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public void lock(final long id) {
|
||||
final JpaSoftwareModule softwareModule = softwareModuleRepository
|
||||
.findById(id)
|
||||
@@ -453,8 +453,8 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public void unlock(final long id) {
|
||||
final JpaSoftwareModule softwareModule = softwareModuleRepository
|
||||
.findById(id)
|
||||
@@ -467,8 +467,8 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public SoftwareModuleMetadata updateMetaData(final SoftwareModuleMetadataUpdate u) {
|
||||
final GenericSoftwareModuleMetadataUpdate update = (GenericSoftwareModuleMetadataUpdate) u;
|
||||
|
||||
|
||||
@@ -79,8 +79,8 @@ public class JpaSoftwareModuleTypeManagement implements SoftwareModuleTypeManage
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public List<SoftwareModuleType> create(final Collection<SoftwareModuleTypeCreate> c) {
|
||||
final List<JpaSoftwareModuleType> creates = c.stream().map(JpaSoftwareModuleTypeCreate.class::cast)
|
||||
.map(JpaSoftwareModuleTypeCreate::build).toList();
|
||||
@@ -90,8 +90,8 @@ public class JpaSoftwareModuleTypeManagement implements SoftwareModuleTypeManage
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public SoftwareModuleType create(final SoftwareModuleTypeCreate c) {
|
||||
final JpaSoftwareModuleTypeCreate create = (JpaSoftwareModuleTypeCreate) c;
|
||||
|
||||
@@ -100,8 +100,8 @@ public class JpaSoftwareModuleTypeManagement implements SoftwareModuleTypeManage
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public SoftwareModuleType update(final SoftwareModuleTypeUpdate u) {
|
||||
final GenericSoftwareModuleTypeUpdate update = (GenericSoftwareModuleTypeUpdate) u;
|
||||
|
||||
@@ -121,8 +121,8 @@ public class JpaSoftwareModuleTypeManagement implements SoftwareModuleTypeManage
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public void delete(final long id) {
|
||||
final JpaSoftwareModuleType toDelete = softwareModuleTypeRepository.findById(id)
|
||||
.orElseThrow(() -> new EntityNotFoundException(SoftwareModuleType.class, id));
|
||||
@@ -132,8 +132,8 @@ public class JpaSoftwareModuleTypeManagement implements SoftwareModuleTypeManage
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public void delete(final Collection<Long> ids) {
|
||||
softwareModuleTypeRepository
|
||||
.findAll(AccessController.Operation.DELETE, softwareModuleTypeRepository.byIdsSpec(ids))
|
||||
|
||||
@@ -153,8 +153,8 @@ public class JpaSystemManagement implements CurrentTenantCacheKeyGenerator, Syst
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public void deleteTenant(final String t) {
|
||||
if (artifactRepository == null) {
|
||||
throw new IllegalStateException("Artifact repository is not available. Can't delete tenant.");
|
||||
@@ -278,8 +278,8 @@ public class JpaSystemManagement implements CurrentTenantCacheKeyGenerator, Syst
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public TenantMetaData updateTenantMetadata(final long defaultDsType) {
|
||||
final JpaTenantMetaData data = (JpaTenantMetaData) getTenantMetadata();
|
||||
|
||||
|
||||
@@ -106,8 +106,8 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public TargetFilterQuery create(final TargetFilterQueryCreate c) {
|
||||
final JpaTargetFilterQueryCreate create = (JpaTargetFilterQueryCreate) c;
|
||||
|
||||
@@ -129,8 +129,8 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public void delete(final long targetFilterQueryId) {
|
||||
if (!targetFilterQueryRepository.existsById(targetFilterQueryId)) {
|
||||
throw new EntityNotFoundException(TargetFilterQuery.class, targetFilterQueryId);
|
||||
|
||||
@@ -236,8 +236,8 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public Target create(final TargetCreate c) {
|
||||
final JpaTargetCreate create = (JpaTargetCreate) c;
|
||||
return targetRepository.save(AccessController.Operation.CREATE, create.build());
|
||||
@@ -245,8 +245,8 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public List<Target> create(final Collection<TargetCreate> targets) {
|
||||
final List<JpaTarget> targetList = targets.stream().map(JpaTargetCreate.class::cast).map(JpaTargetCreate::build)
|
||||
.toList();
|
||||
@@ -255,8 +255,8 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public void delete(final Collection<Long> ids) {
|
||||
final List<JpaTarget> targets = targetRepository.findAllById(ids);
|
||||
if (targets.size() < ids.size()) {
|
||||
@@ -269,8 +269,8 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public void deleteByControllerID(final String controllerId) {
|
||||
targetRepository.delete(getByControllerIdAndThrowIfNotFound(controllerId));
|
||||
}
|
||||
@@ -500,8 +500,8 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public TargetTypeAssignmentResult assignType(final Collection<String> controllerIds, final Long typeId) {
|
||||
final JpaTargetType type = targetTypeRepository.findById(typeId)
|
||||
.orElseThrow(() -> new EntityNotFoundException(TargetType.class, typeId));
|
||||
@@ -525,8 +525,8 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public TargetTypeAssignmentResult unassignType(final Collection<String> controllerIds) {
|
||||
final List<JpaTarget> allTargets = findTargetsByInSpecification(controllerIds, null);
|
||||
|
||||
@@ -543,8 +543,8 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public List<Target> assignTag(final Collection<String> controllerIds, final long targetTagId,
|
||||
final Consumer<Collection<String>> notFoundHandler) {
|
||||
return updateTag(controllerIds, targetTagId, notFoundHandler, (tag, target) -> {
|
||||
@@ -559,8 +559,8 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public List<Target> unassignTag(final Collection<String> controllerIds, final long targetTagId,
|
||||
final Consumer<Collection<String>> notFoundHandler) {
|
||||
return updateTag(controllerIds, targetTagId, notFoundHandler, (tag, target) -> {
|
||||
@@ -575,8 +575,8 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public Target unassignType(final String controllerId) {
|
||||
final JpaTarget target = getByControllerIdAndThrowIfNotFound(controllerId);
|
||||
target.setTargetType(null);
|
||||
@@ -585,8 +585,8 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public Target assignType(final String controllerId, final Long targetTypeId) {
|
||||
final JpaTarget target = getByControllerIdAndThrowIfNotFound(controllerId);
|
||||
|
||||
@@ -601,8 +601,8 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public Target update(final TargetUpdate u) {
|
||||
final JpaTargetUpdate update = (JpaTargetUpdate) u;
|
||||
|
||||
@@ -708,8 +708,8 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public List<TargetMetadata> createMetaData(final String controllerId, final Collection<MetaData> md) {
|
||||
final JpaTarget target = getByControllerIdAndThrowIfNotFound(controllerId);
|
||||
|
||||
@@ -735,8 +735,8 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public void deleteMetaData(final String controllerId, final String key) {
|
||||
final JpaTargetMetadata metadata = (JpaTargetMetadata) getMetaDataByControllerId(controllerId, key)
|
||||
.orElseThrow(() -> new EntityNotFoundException(TargetMetadata.class, controllerId, key));
|
||||
@@ -791,8 +791,8 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public TargetMetadata updateMetadata(final String controllerId, final MetaData md) {
|
||||
|
||||
// check if exists otherwise throw entity not found exception
|
||||
@@ -815,8 +815,8 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public TargetTagAssignmentResult toggleTagAssignment(final Collection<String> controllerIds, final String tagName) {
|
||||
final TargetTag tag = targetTagRepository
|
||||
.findByNameEquals(tagName)
|
||||
@@ -852,8 +852,8 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public Target unassignTag(final String controllerId, final long targetTagId) {
|
||||
final JpaTarget target = getByControllerIdAndThrowIfNotFound(controllerId);
|
||||
|
||||
|
||||
@@ -67,8 +67,8 @@ public class JpaTargetTagManagement implements TargetTagManagement {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public TargetTag create(final TagCreate c) {
|
||||
final JpaTagCreate create = (JpaTagCreate) c;
|
||||
|
||||
@@ -77,8 +77,8 @@ public class JpaTargetTagManagement implements TargetTagManagement {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public List<TargetTag> create(final Collection<TagCreate> tt) {
|
||||
final List<JpaTargetTag> targetTagList = tt.stream().map(JpaTagCreate.class::cast)
|
||||
.map(JpaTagCreate::buildTargetTag).toList();
|
||||
@@ -88,8 +88,8 @@ public class JpaTargetTagManagement implements TargetTagManagement {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public void delete(final String targetTagName) {
|
||||
targetTagRepository.delete(
|
||||
targetTagRepository
|
||||
@@ -125,8 +125,8 @@ public class JpaTargetTagManagement implements TargetTagManagement {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public TargetTag update(final TagUpdate u) {
|
||||
final GenericTagUpdate update = (GenericTagUpdate) u;
|
||||
|
||||
|
||||
@@ -106,8 +106,8 @@ public class JpaTargetTypeManagement implements TargetTypeManagement {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public TargetType create(final TargetTypeCreate create) {
|
||||
final JpaTargetType typeCreate = ((JpaTargetTypeCreate) create).build();
|
||||
return targetTypeRepository.save(AccessController.Operation.CREATE, typeCreate);
|
||||
@@ -115,8 +115,8 @@ public class JpaTargetTypeManagement implements TargetTypeManagement {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public List<TargetType> create(final Collection<TargetTypeCreate> creates) {
|
||||
final List<JpaTargetType> typeCreate =
|
||||
creates.stream().map(create -> ((JpaTargetTypeCreate) create).build()).toList();
|
||||
@@ -125,8 +125,8 @@ public class JpaTargetTypeManagement implements TargetTypeManagement {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public void delete(final Long id) {
|
||||
getByIdAndThrowIfNotFound(id);
|
||||
|
||||
@@ -168,8 +168,8 @@ public class JpaTargetTypeManagement implements TargetTypeManagement {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public TargetType update(final TargetTypeUpdate update) {
|
||||
final GenericTargetTypeUpdate typeUpdate = (GenericTargetTypeUpdate) update;
|
||||
|
||||
@@ -184,8 +184,8 @@ public class JpaTargetTypeManagement implements TargetTypeManagement {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public TargetType assignCompatibleDistributionSetTypes(final long id,
|
||||
final Collection<Long> distributionSetTypeIds) {
|
||||
final Collection<JpaDistributionSetType> dsTypes = distributionSetTypeRepository
|
||||
@@ -205,8 +205,8 @@ public class JpaTargetTypeManagement implements TargetTypeManagement {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public TargetType unassignDistributionSetType(final long id, final long distributionSetTypeId) {
|
||||
final JpaTargetType type = getByIdAndThrowIfNotFound(id);
|
||||
assertDistributionSetTypeExists(distributionSetTypeId);
|
||||
|
||||
@@ -24,6 +24,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.hawkbit.im.authentication.SpPermission;
|
||||
import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
|
||||
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.jpa.configuration.Constants;
|
||||
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.tenancy.configuration.TenantConfigurationProperties;
|
||||
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.cache.Cache;
|
||||
import org.springframework.cache.CacheManager;
|
||||
@@ -73,8 +73,8 @@ public class JpaTenantConfigurationManagement implements TenantConfigurationMana
|
||||
@Override
|
||||
@CacheEvict(value = "tenantConfiguration", key = "#configurationKeyName")
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public <T extends Serializable> TenantConfigurationValue<T> addOrUpdateConfiguration(
|
||||
final String configurationKeyName, final T value) {
|
||||
return addOrUpdateConfiguration0(Collections.singletonMap(configurationKeyName, value)).values().iterator().next();
|
||||
@@ -82,8 +82,8 @@ public class JpaTenantConfigurationManagement implements TenantConfigurationMana
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
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
|
||||
afterCommitExecutor.afterCommit(() -> {
|
||||
@@ -99,8 +99,8 @@ public class JpaTenantConfigurationManagement implements TenantConfigurationMana
|
||||
@Override
|
||||
@CacheEvict(value = "tenantConfiguration", key = "#configurationKeyName")
|
||||
@Transactional
|
||||
@Retryable(include = {
|
||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public void deleteConfiguration(final String configurationKeyName) {
|
||||
tenantConfigurationRepository.deleteByKey(configurationKeyName);
|
||||
}
|
||||
|
||||
@@ -28,13 +28,10 @@ public class JpaTenantStatsManagement implements TenantStatsManagement {
|
||||
|
||||
@Autowired
|
||||
private TargetRepository targetRepository;
|
||||
|
||||
@Autowired
|
||||
private LocalArtifactRepository artifactRepository;
|
||||
|
||||
@Autowired
|
||||
private ActionRepository actionRepository;
|
||||
|
||||
@Autowired
|
||||
private TenantAware tenantAware;
|
||||
|
||||
@@ -52,4 +49,4 @@ public class JpaTenantStatsManagement implements TenantStatsManagement {
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -47,7 +47,8 @@ import org.eclipse.hawkbit.repository.model.helper.EventPublisherHolder;
|
||||
*/
|
||||
public class OfflineDsAssignmentStrategy extends AbstractDsAssignmentStrategy {
|
||||
|
||||
OfflineDsAssignmentStrategy(final TargetRepository targetRepository,
|
||||
OfflineDsAssignmentStrategy(
|
||||
final TargetRepository targetRepository,
|
||||
final AfterTransactionCommitExecutor afterCommit, final EventPublisherHolder eventPublisherHolder,
|
||||
final ActionRepository actionRepository, final ActionStatusRepository actionStatusRepository,
|
||||
final QuotaManagement quotaManagement, final BooleanSupplier multiAssignmentsConfig,
|
||||
|
||||
@@ -24,8 +24,8 @@ import jakarta.persistence.Version;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import org.eclipse.hawkbit.tenancy.TenantAwareAuthenticationDetails;
|
||||
import org.eclipse.hawkbit.repository.model.BaseEntity;
|
||||
import org.eclipse.hawkbit.tenancy.TenantAwareAuthenticationDetails;
|
||||
import org.springframework.data.annotation.CreatedBy;
|
||||
import org.springframework.data.annotation.CreatedDate;
|
||||
import org.springframework.data.annotation.LastModifiedBy;
|
||||
@@ -96,19 +96,22 @@ public abstract class AbstractJpaBaseEntity implements BaseEntity {
|
||||
return optLockRevision;
|
||||
}
|
||||
|
||||
@CreatedBy
|
||||
public void setCreatedBy(final String createdBy) {
|
||||
@LastModifiedDate
|
||||
public void setLastModifiedAt(final long lastModifiedAt) {
|
||||
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;
|
||||
}
|
||||
|
||||
this.createdBy = createdBy;
|
||||
this.lastModifiedAt = lastModifiedAt;
|
||||
}
|
||||
|
||||
@LastModifiedBy
|
||||
public void setLastModifiedBy(final String lastModifiedBy) {
|
||||
if (isController()) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.lastModifiedBy = lastModifiedBy;
|
||||
}
|
||||
|
||||
@CreatedDate
|
||||
@@ -123,22 +126,19 @@ public abstract class AbstractJpaBaseEntity implements BaseEntity {
|
||||
}
|
||||
}
|
||||
|
||||
@LastModifiedBy
|
||||
public void setLastModifiedBy(final String lastModifiedBy) {
|
||||
@CreatedBy
|
||||
public void setCreatedBy(final String createdBy) {
|
||||
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;
|
||||
}
|
||||
|
||||
this.lastModifiedBy = lastModifiedBy;
|
||||
}
|
||||
|
||||
@LastModifiedDate
|
||||
public void setLastModifiedAt(final long lastModifiedAt) {
|
||||
if (isController()) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.lastModifiedAt = lastModifiedAt;
|
||||
this.createdBy = createdBy;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -201,7 +201,8 @@ public abstract class AbstractJpaBaseEntity implements BaseEntity {
|
||||
|
||||
private boolean isController() {
|
||||
return SecurityContextHolder.getContext().getAuthentication() != null
|
||||
&& SecurityContextHolder.getContext().getAuthentication().getDetails() instanceof TenantAwareAuthenticationDetails tenantAwareDetails
|
||||
&& SecurityContextHolder.getContext().getAuthentication()
|
||||
.getDetails() instanceof TenantAwareAuthenticationDetails tenantAwareDetails
|
||||
&& tenantAwareDetails.isController();
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,6 @@ package org.eclipse.hawkbit.repository.jpa.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import jakarta.persistence.CascadeType;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.ConstraintMode;
|
||||
import jakarta.persistence.EmbeddedId;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user