From f9bb48d6970f515643730baca7dbbe56ba9d73fe Mon Sep 17 00:00:00 2001 From: Avgustin Marinov Date: Sun, 17 Nov 2024 15:03:03 +0200 Subject: [PATCH] Code refactoring of hawkbit-repository (#2056) Signed-off-by: Avgustin Marinov --- .../eclipse/hawkbit/app/ErrorController.java | 2 +- .../java/org/eclipse/hawkbit/app/Start.java | 7 +- .../hawkbit/app/PreAuthorizeEnabledTest.java | 41 +++--- .../hawkbit-repository-api/pom.xml | 18 +-- .../repository/OffsetBasedPageRequest.java | 3 + .../TenantConfigurationManagement.java | 2 +- .../builder/ActionStatusCreate.java | 2 +- .../exception/EntityNotFoundException.java | 6 +- .../IncompatibleTargetTypeException.java | 2 +- ...ConfigurationPollingDurationValidator.java | 2 +- .../event/BusProtoStuffMessageConverter.java | 4 +- .../org/eclipse/hawkbit/event/EventType.java | 1 + .../repository/PropertiesQuotaManagement.java | 2 +- .../RepositoryDefaultConfiguration.java | 7 +- .../repository/RolloutApprovalStrategy.java | 2 +- .../repository/RolloutStatusCache.java | 2 +- .../repository/TimestampCalculator.java | 12 +- .../builder/AbstractActionStatusCreate.java | 10 -- .../builder/AbstractBaseEntityBuilder.java | 3 +- ...stractDistributionSetTypeUpdateCreate.java | 2 +- .../builder/AbstractMetadataUpdateCreate.java | 4 +- .../builder/AbstractNamedEntityBuilder.java | 1 - .../builder/AbstractRolloutGroupCreate.java | 3 +- ...actSoftwareModuleMetadataUpdateCreate.java | 3 +- .../AbstractSoftwareModuleUpdateCreate.java | 5 +- .../builder/AbstractTagUpdateCreate.java | 3 +- ...AbstractTargetFilterQueryUpdateCreate.java | 7 +- .../AbstractTargetTypeUpdateCreate.java | 2 +- .../builder/AbstractTargetUpdateCreate.java | 5 - .../builder/AbstractTypeUpdateCreate.java | 2 +- .../GenericDistributionSetTypeUpdate.java | 3 +- .../builder/GenericDistributionSetUpdate.java | 3 +- .../builder/GenericRolloutUpdate.java | 2 +- .../GenericSoftwareModuleTypeUpdate.java | 3 +- .../repository/builder/GenericTagUpdate.java | 2 +- .../GenericTargetFilterQueryUpdate.java | 3 +- .../builder/GenericTargetTypeUpdate.java | 3 +- .../model/helper/EventPublisherHolder.java | 2 - .../rsql/VirtualPropertyResolver.java | 2 + .../repository/jpa/JpaRolloutExecutor.java | 4 +- .../RepositoryApplicationConfiguration.java | 2 - .../repository/jpa/acm/AccessController.java | 9 +- .../ExceptionMappingAspectHandler.java | 12 +- .../AbstractAutoAssignExecutor.java | 5 +- .../jpa/autoassign/AutoAssignChecker.java | 6 +- .../jpa/autoassign/AutoAssignScheduler.java | 11 +- .../jpa/autocleanup/AutoActionCleanup.java | 7 +- .../jpa/autocleanup/AutoCleanupScheduler.java | 9 +- .../jpa/autocleanup/CleanupTask.java | 3 +- .../jpa/builder/JpaActionStatusBuilder.java | 3 +- .../jpa/builder/JpaActionStatusCreate.java | 2 +- .../builder/JpaDistributionSetBuilder.java | 3 +- .../jpa/builder/JpaDistributionSetCreate.java | 12 +- .../JpaDistributionSetTypeBuilder.java | 3 +- .../builder/JpaDistributionSetTypeCreate.java | 3 +- .../jpa/builder/JpaRolloutBuilder.java | 3 +- .../jpa/builder/JpaRolloutGroupBuilder.java | 3 +- .../jpa/builder/JpaRolloutGroupCreate.java | 6 +- .../jpa/builder/JpaSoftwareModuleBuilder.java | 3 +- .../jpa/builder/JpaSoftwareModuleCreate.java | 6 +- .../JpaSoftwareModuleMetadataBuilder.java | 3 +- .../JpaSoftwareModuleMetadataCreate.java | 6 +- .../builder/JpaSoftwareModuleTypeBuilder.java | 3 +- .../builder/JpaSoftwareModuleTypeCreate.java | 9 +- .../repository/jpa/builder/JpaTagBuilder.java | 3 +- .../repository/jpa/builder/JpaTagCreate.java | 7 +- .../jpa/builder/JpaTargetBuilder.java | 5 +- .../jpa/builder/JpaTargetCreate.java | 14 +- .../builder/JpaTargetFilterQueryBuilder.java | 3 +- .../builder/JpaTargetFilterQueryCreate.java | 3 +- .../jpa/builder/JpaTargetTypeBuilder.java | 2 +- .../jpa/builder/JpaTargetTypeCreate.java | 3 +- .../jpa/builder/JpaTargetUpdate.java | 3 +- .../jpa/configuration/Constants.java | 2 +- .../MultiTenantJpaTransactionManager.java | 2 +- ...ansactionCommitDefaultServiceExecutor.java | 6 +- .../AfterTransactionCommitExecutor.java | 2 +- .../AbstractDsAssignmentStrategy.java | 16 ++- .../jpa/management/JpaActionManagement.java | 5 +- .../jpa/management/JpaArtifactManagement.java | 16 +-- .../management/JpaConfirmationManagement.java | 51 ++++--- .../management/JpaControllerManagement.java | 77 +++++------ .../management/JpaDeploymentManagement.java | 126 +++++++++--------- ...DistributionSetInvalidationManagement.java | 2 +- .../JpaDistributionSetManagement.java | 64 ++++----- .../JpaDistributionSetTagManagement.java | 30 ++--- .../JpaDistributionSetTypeManagement.java | 32 ++--- .../jpa/management/JpaRolloutManagement.java | 65 ++++----- .../JpaSoftwareModuleManagement.java | 44 +++--- .../JpaSoftwareModuleTypeManagement.java | 20 +-- .../jpa/management/JpaSystemManagement.java | 8 +- .../JpaTargetFilterQueryManagement.java | 8 +- .../jpa/management/JpaTargetManagement.java | 64 ++++----- .../management/JpaTargetTagManagement.java | 16 +-- .../management/JpaTargetTypeManagement.java | 24 ++-- .../JpaTenantConfigurationManagement.java | 14 +- .../management/JpaTenantStatsManagement.java | 5 +- .../OfflineDsAssignmentStrategy.java | 3 +- .../jpa/model/AbstractJpaBaseEntity.java | 47 +++---- .../jpa/model/DistributionSetTypeElement.java | 1 - .../repository/jpa/model/JpaAction.java | 79 +++++------ .../repository/jpa/model/JpaActionStatus.java | 6 +- .../jpa/model/JpaAutoConfirmationStatus.java | 4 +- .../jpa/model/JpaDistributionSet.java | 3 +- .../jpa/model/JpaDistributionSetType.java | 3 +- .../repository/jpa/model/JpaRollout.java | 58 ++++---- .../repository/jpa/model/JpaRolloutGroup.java | 53 +++----- .../jpa/model/JpaSoftwareModule.java | 6 +- .../repository/jpa/model/JpaTarget.java | 36 ++--- .../DistributionSetTagManagementTest.java | 1 - .../RolloutGroupManagementTest.java | 4 +- .../jpa/management/RolloutManagementTest.java | 4 +- .../TenantConfigurationManagementTest.java | 2 +- .../repository/test/TestConfiguration.java | 6 +- .../test/util/AbstractIntegrationTest.java | 31 +---- .../test/util/AbstractSqlTestDatabase.java | 2 +- .../util/CleanupTestExecutionListener.java | 2 +- .../test/util/SecurityContextSwitch.java | 2 +- 118 files changed, 622 insertions(+), 797 deletions(-) diff --git a/hawkbit-monolith/hawkbit-update-server/src/main/java/org/eclipse/hawkbit/app/ErrorController.java b/hawkbit-monolith/hawkbit-update-server/src/main/java/org/eclipse/hawkbit/app/ErrorController.java index def878ee8..5ea1fd340 100644 --- a/hawkbit-monolith/hawkbit-update-server/src/main/java/org/eclipse/hawkbit/app/ErrorController.java +++ b/hawkbit-monolith/hawkbit-update-server/src/main/java/org/eclipse/hawkbit/app/ErrorController.java @@ -65,4 +65,4 @@ public class ErrorController extends BasicErrorController { } return body; } -} +} \ No newline at end of file diff --git a/hawkbit-monolith/hawkbit-update-server/src/main/java/org/eclipse/hawkbit/app/Start.java b/hawkbit-monolith/hawkbit-update-server/src/main/java/org/eclipse/hawkbit/app/Start.java index 12fed2d39..c7120f1ff 100644 --- a/hawkbit-monolith/hawkbit-update-server/src/main/java/org/eclipse/hawkbit/app/Start.java +++ b/hawkbit-monolith/hawkbit-update-server/src/main/java/org/eclipse/hawkbit/app/Start.java @@ -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 {} } \ No newline at end of file diff --git a/hawkbit-monolith/hawkbit-update-server/src/test/java/org/eclipse/hawkbit/app/PreAuthorizeEnabledTest.java b/hawkbit-monolith/hawkbit-update-server/src/test/java/org/eclipse/hawkbit/app/PreAuthorizeEnabledTest.java index f5c2100a3..1ef0bb055 100644 --- a/hawkbit-monolith/hawkbit-update-server/src/test/java/org/eclipse/hawkbit/app/PreAuthorizeEnabledTest.java +++ b/hawkbit-monolith/hawkbit-update-server/src/test/java/org/eclipse/hawkbit/app/PreAuthorizeEnabledTest.java @@ -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())); } } \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-api/pom.xml b/hawkbit-repository/hawkbit-repository-api/pom.xml index 9f498473b..92aa81d06 100644 --- a/hawkbit-repository/hawkbit-repository-api/pom.xml +++ b/hawkbit-repository/hawkbit-repository-api/pom.xml @@ -33,14 +33,6 @@ ${project.version} - - com.fasterxml.jackson.core - jackson-annotations - - - jakarta.validation - jakarta.validation-api - org.springframework.hateoas spring-hateoas @@ -71,6 +63,16 @@ + + + jakarta.validation + jakarta.validation-api + + + + com.fasterxml.jackson.core + jackson-annotations + com.cronutils cron-utils diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/OffsetBasedPageRequest.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/OffsetBasedPageRequest.java index 17a947c1f..32dd28061 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/OffsetBasedPageRequest.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/OffsetBasedPageRequest.java @@ -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; diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/TenantConfigurationManagement.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/TenantConfigurationManagement.java index f4f18ba4a..5390e7287 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/TenantConfigurationManagement.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/TenantConfigurationManagement.java @@ -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; diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/builder/ActionStatusCreate.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/builder/ActionStatusCreate.java index e232f8fdc..bbf9a8df5 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/builder/ActionStatusCreate.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/builder/ActionStatusCreate.java @@ -54,4 +54,4 @@ public interface ActionStatusCreate { * @return peek on current state of {@link ActionStatus} in the builder */ ActionStatus build(); -} +} \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/exception/EntityNotFoundException.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/exception/EntityNotFoundException.java index 27648704b..5c226562c 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/exception/EntityNotFoundException.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/exception/EntityNotFoundException.java @@ -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; diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/exception/IncompatibleTargetTypeException.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/exception/IncompatibleTargetTypeException.java index dde8e0f87..110455104 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/exception/IncompatibleTargetTypeException.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/exception/IncompatibleTargetTypeException.java @@ -27,7 +27,7 @@ public class IncompatibleTargetTypeException extends AbstractServerRtException { @Serial private static final long serialVersionUID = 1L; - + private final Collection targetTypeNames; private final Collection distributionSetTypeNames; diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/tenancy/configuration/validator/TenantConfigurationPollingDurationValidator.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/tenancy/configuration/validator/TenantConfigurationPollingDurationValidator.java index bd8a09ca7..8369a18b8 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/tenancy/configuration/validator/TenantConfigurationPollingDurationValidator.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/tenancy/configuration/validator/TenantConfigurationPollingDurationValidator.java @@ -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; /** diff --git a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/event/BusProtoStuffMessageConverter.java b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/event/BusProtoStuffMessageConverter.java index 3b65d75b8..364285acd 100644 --- a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/event/BusProtoStuffMessageConverter.java +++ b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/event/BusProtoStuffMessageConverter.java @@ -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); } diff --git a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/event/EventType.java b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/event/EventType.java index 12b10db5f..869d291f9 100644 --- a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/event/EventType.java +++ b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/event/EventType.java @@ -83,6 +83,7 @@ import org.eclipse.hawkbit.repository.event.remote.entity.TenantConfigurationUpd public class EventType { private static final Map> TYPES = new HashMap<>(); + private int value; /** diff --git a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/PropertiesQuotaManagement.java b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/PropertiesQuotaManagement.java index 4e15559de..c9601ec66 100644 --- a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/PropertiesQuotaManagement.java +++ b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/PropertiesQuotaManagement.java @@ -111,4 +111,4 @@ public class PropertiesQuotaManagement implements QuotaManagement { public int getMaxDistributionSetTypesPerTargetType() { return securityProperties.getDos().getMaxDistributionSetTypesPerTargetType(); } -} +} \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/RepositoryDefaultConfiguration.java b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/RepositoryDefaultConfiguration.java index 2709ddb18..6bcfc008a 100644 --- a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/RepositoryDefaultConfiguration.java +++ b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/RepositoryDefaultConfiguration.java @@ -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 {} \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/RolloutApprovalStrategy.java b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/RolloutApprovalStrategy.java index fbf667e6b..8c769f323 100644 --- a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/RolloutApprovalStrategy.java +++ b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/RolloutApprovalStrategy.java @@ -46,4 +46,4 @@ public interface RolloutApprovalStrategy { * @return identifier of the user that decided on approval */ String getApprovalUser(Rollout rollout); -} +} \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/RolloutStatusCache.java b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/RolloutStatusCache.java index fae592a9e..110b8a554 100644 --- a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/RolloutStatusCache.java +++ b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/RolloutStatusCache.java @@ -250,4 +250,4 @@ public class RolloutStatusCache { return status; } } -} +} \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/TimestampCalculator.java b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/TimestampCalculator.java index 97212a3a8..e2bc7932e 100644 --- a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/TimestampCalculator.java +++ b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/TimestampCalculator.java @@ -29,16 +29,12 @@ import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties.T public final class TimestampCalculator { /** - * Calculates the overdue timestamp (overdue_ts) based on the - * current timestamp and the intervals for polling and poll-overdue: + * Calculates the overdue timestamp (overdue_ts) based on the current timestamp and the intervals for polling and poll-overdue: *

- * overdue_ts = now_ts - pollingInterval - - * pollingOverdueInterval;
- * pollingInterval and pollingOverdueInterval are - * retrieved from tenant-specific system configuration. + * overdue_ts = now_ts - pollingInterval - pollingOverdueInterval;
+ * pollingInterval and pollingOverdueInterval are retrieved from tenant-specific system configuration. * - * @return overdue_ts in milliseconds since Unix epoch as long - * value + * @return overdue_ts in milliseconds since Unix epoch as long value */ public static long calculateOverdueTimestamp() { return Instant.now().toEpochMilli() - getDurationForKey(TenantConfigurationKey.POLLING_TIME_INTERVAL).toMillis() diff --git a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractActionStatusCreate.java b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractActionStatusCreate.java index ccdf39b10..9301c9132 100644 --- a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractActionStatusCreate.java +++ b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractActionStatusCreate.java @@ -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 { 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 { } else { this.messages.addAll(messages.stream().map(String::strip).toList()); } - return (T) this; } @@ -72,7 +63,6 @@ public abstract class AbstractActionStatusCreate { this.messages = new ArrayList<>(); } this.messages.add(message.strip()); - return (T) this; } diff --git a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractBaseEntityBuilder.java b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractBaseEntityBuilder.java index 13f910981..e0622ec6e 100644 --- a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractBaseEntityBuilder.java +++ b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractBaseEntityBuilder.java @@ -19,5 +19,4 @@ public abstract class AbstractBaseEntityBuilder implements Identifiable { public Long getId() { return id; } - -} +} \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractDistributionSetTypeUpdateCreate.java b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractDistributionSetTypeUpdateCreate.java index d8c7d920e..284e40ee3 100644 --- a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractDistributionSetTypeUpdateCreate.java +++ b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractDistributionSetTypeUpdateCreate.java @@ -39,4 +39,4 @@ public abstract class AbstractDistributionSetTypeUpdateCreate extends Abstrac public Optional> getOptional() { return Optional.ofNullable(optional); } -} +} \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractMetadataUpdateCreate.java b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractMetadataUpdateCreate.java index 6010d060c..72feb137b 100644 --- a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractMetadataUpdateCreate.java +++ b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractMetadataUpdateCreate.java @@ -23,7 +23,6 @@ public abstract class AbstractMetadataUpdateCreate { @ValidString protected String key; - @ValidString protected String value; @@ -44,5 +43,4 @@ public abstract class AbstractMetadataUpdateCreate { public Optional getValue() { return Optional.ofNullable(value); } - -} +} \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractNamedEntityBuilder.java b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractNamedEntityBuilder.java index 8a7299531..008197e47 100644 --- a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractNamedEntityBuilder.java +++ b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractNamedEntityBuilder.java @@ -18,7 +18,6 @@ public abstract class AbstractNamedEntityBuilder extends AbstractBaseEntityBu @ValidString protected String name; - @ValidString protected String description; diff --git a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractRolloutGroupCreate.java b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractRolloutGroupCreate.java index 91ea1de82..57d87b1bb 100644 --- a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractRolloutGroupCreate.java +++ b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractRolloutGroupCreate.java @@ -45,5 +45,4 @@ public abstract class AbstractRolloutGroupCreate extends AbstractNamedEntityB this.confirmationRequired = confirmationRequired; return (T) this; } - -} +} \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractSoftwareModuleMetadataUpdateCreate.java b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractSoftwareModuleMetadataUpdateCreate.java index e7ff5f4f0..ac555b072 100644 --- a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractSoftwareModuleMetadataUpdateCreate.java +++ b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractSoftwareModuleMetadataUpdateCreate.java @@ -38,5 +38,4 @@ public abstract class AbstractSoftwareModuleMetadataUpdateCreate extends Abst this.targetVisible = targetVisible; return (T) this; } - -} +} \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractSoftwareModuleUpdateCreate.java b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractSoftwareModuleUpdateCreate.java index 598a8deff..586c6ac11 100644 --- a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractSoftwareModuleUpdateCreate.java +++ b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractSoftwareModuleUpdateCreate.java @@ -23,10 +23,8 @@ public abstract class AbstractSoftwareModuleUpdateCreate extends AbstractName @ValidString protected String version; - @ValidString protected String vendor; - @ValidString protected String type; @@ -56,5 +54,4 @@ public abstract class AbstractSoftwareModuleUpdateCreate extends AbstractName public Optional getVersion() { return Optional.ofNullable(version); } - -} +} \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractTagUpdateCreate.java b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractTagUpdateCreate.java index b29dbf7cf..6b58c09a5 100644 --- a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractTagUpdateCreate.java +++ b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractTagUpdateCreate.java @@ -32,5 +32,4 @@ public class AbstractTagUpdateCreate extends AbstractNamedEntityBuilder { public Optional getColour() { return Optional.ofNullable(colour); } - -} +} \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractTargetFilterQueryUpdateCreate.java b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractTargetFilterQueryUpdateCreate.java index 6ce3bcb2d..fe52fbf22 100644 --- a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractTargetFilterQueryUpdateCreate.java +++ b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractTargetFilterQueryUpdateCreate.java @@ -29,18 +29,13 @@ public abstract class AbstractTargetFilterQueryUpdateCreate 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 extends AbstractB public Optional getConfirmationRequired() { return Optional.ofNullable(confirmationRequired); } -} +} \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractTargetTypeUpdateCreate.java b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractTargetTypeUpdateCreate.java index 5501463d5..445ca605d 100644 --- a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractTargetTypeUpdateCreate.java +++ b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractTargetTypeUpdateCreate.java @@ -36,4 +36,4 @@ public abstract class AbstractTargetTypeUpdateCreate extends AbstractTypeUpda public Optional> getCompatible() { return Optional.ofNullable(compatible); } -} +} \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractTargetUpdateCreate.java b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractTargetUpdateCreate.java index c926b4865..a0a7134d3 100644 --- a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractTargetUpdateCreate.java +++ b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractTargetUpdateCreate.java @@ -27,18 +27,13 @@ public class AbstractTargetUpdateCreate extends AbstractNamedEntityBuilder @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) { diff --git a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractTypeUpdateCreate.java b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractTypeUpdateCreate.java index a734b5ea5..0d1422b79 100644 --- a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractTypeUpdateCreate.java +++ b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractTypeUpdateCreate.java @@ -43,4 +43,4 @@ public abstract class AbstractTypeUpdateCreate extends AbstractNamedEntityBui public Optional getKey() { return Optional.ofNullable(key); } -} +} \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/GenericDistributionSetTypeUpdate.java b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/GenericDistributionSetTypeUpdate.java index 2da56ed11..70ac5e496 100644 --- a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/GenericDistributionSetTypeUpdate.java +++ b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/GenericDistributionSetTypeUpdate.java @@ -18,5 +18,4 @@ public class GenericDistributionSetTypeUpdate extends AbstractDistributionSetTyp public GenericDistributionSetTypeUpdate(final Long id) { super.id = id; } - -} +} \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/GenericDistributionSetUpdate.java b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/GenericDistributionSetUpdate.java index be62fb0ab..0a8031e14 100644 --- a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/GenericDistributionSetUpdate.java +++ b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/GenericDistributionSetUpdate.java @@ -23,8 +23,7 @@ import lombok.experimental.Accessors; @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) @Accessors(fluent = true) -public class GenericDistributionSetUpdate extends AbstractDistributionSetUpdateCreate - implements DistributionSetUpdate { +public class GenericDistributionSetUpdate extends AbstractDistributionSetUpdateCreate implements DistributionSetUpdate { @Nullable protected Boolean locked; diff --git a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/GenericRolloutUpdate.java b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/GenericRolloutUpdate.java index 97cc631d7..29716f9fc 100644 --- a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/GenericRolloutUpdate.java +++ b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/GenericRolloutUpdate.java @@ -17,4 +17,4 @@ public class GenericRolloutUpdate extends AbstractNamedEntityBuilder impleme public GenericTagUpdate(final Long id) { super.id = id; } -} +} \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/GenericTargetFilterQueryUpdate.java b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/GenericTargetFilterQueryUpdate.java index cb7895045..5c7213c5f 100644 --- a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/GenericTargetFilterQueryUpdate.java +++ b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/GenericTargetFilterQueryUpdate.java @@ -18,5 +18,4 @@ public class GenericTargetFilterQueryUpdate extends AbstractTargetFilterQueryUpd public GenericTargetFilterQueryUpdate(final Long id) { super.id = id; } - -} +} \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/GenericTargetTypeUpdate.java b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/GenericTargetTypeUpdate.java index 1a67f17b7..d6f77d6f4 100644 --- a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/GenericTargetTypeUpdate.java +++ b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/GenericTargetTypeUpdate.java @@ -21,5 +21,4 @@ public class GenericTargetTypeUpdate extends AbstractTargetTypeUpdateCreate implements VirtualPropertyReplacer { + @Serial private static final long serialVersionUID = 1L; private transient StrSubstitutor substitutor; diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaRolloutExecutor.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaRolloutExecutor.java index 151e4b634..f4ffbffe3 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaRolloutExecutor.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaRolloutExecutor.java @@ -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)) { diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/RepositoryApplicationConfiguration.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/RepositoryApplicationConfiguration.java index d2af7ebac..2eb6a3fa1 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/RepositoryApplicationConfiguration.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/RepositoryApplicationConfiguration.java @@ -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; diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/acm/AccessController.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/acm/AccessController.java index 1cc10c022..70d42d576 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/acm/AccessController.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/acm/AccessController.java @@ -32,16 +32,14 @@ public interface AccessController { /** * 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> 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 { * Entity creation */ CREATE, - /** * Read entities */ READ, - /** * Entity modification (e.g. name/description change, tag/type assignment, etc.) */ UPDATE, - /** * Entity deletion */ diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/aspects/ExceptionMappingAspectHandler.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/aspects/ExceptionMappingAspectHandler.java index 9788376ee..2c4360654 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/aspects/ExceptionMappingAspectHandler.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/aspects/ExceptionMappingAspectHandler.java @@ -49,24 +49,20 @@ public class ExceptionMappingAspectHandler implements Ordered { private static final List> 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; } -} +} \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/autoassign/AbstractAutoAssignExecutor.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/autoassign/AbstractAutoAssignExecutor.java index 44ab49f0c..5f77ef460 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/autoassign/AbstractAutoAssignExecutor.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/autoassign/AbstractAutoAssignExecutor.java @@ -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(); } -} +} \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/autoassign/AutoAssignChecker.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/autoassign/AutoAssignChecker.java index 2bbe35ab6..bc39d0c04 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/autoassign/AutoAssignChecker.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/autoassign/AutoAssignChecker.java @@ -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); } /** diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/autoassign/AutoAssignScheduler.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/autoassign/AutoAssignScheduler.java index 0d2b6b09e..66f427708 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/autoassign/AutoAssignScheduler.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/autoassign/AutoAssignScheduler.java @@ -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; } -} +} \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/autocleanup/AutoActionCleanup.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/autocleanup/AutoActionCleanup.java index e186d631f..70efdbe12 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/autocleanup/AutoActionCleanup.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/autocleanup/AutoActionCleanup.java @@ -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 valueType) { return config.getConfigurationValue(key, valueType); } - -} +} \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/autocleanup/AutoCleanupScheduler.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/autocleanup/AutoCleanupScheduler.java index e283c961a..40bfdc1e6 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/autocleanup/AutoCleanupScheduler.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/autocleanup/AutoCleanupScheduler.java @@ -34,15 +34,15 @@ public class AutoCleanupScheduler { private final List 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 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); } - -} +} \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/autocleanup/CleanupTask.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/autocleanup/CleanupTask.java index 3c45d534e..c7b55db9f 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/autocleanup/CleanupTask.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/autocleanup/CleanupTask.java @@ -24,5 +24,4 @@ public interface CleanupTask extends Runnable { * @return The identifier of this cleanup task. Never null. */ String getId(); - -} +} \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaActionStatusBuilder.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaActionStatusBuilder.java index 8a2c791c4..eb93944ff 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaActionStatusBuilder.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaActionStatusBuilder.java @@ -22,5 +22,4 @@ public class JpaActionStatusBuilder implements ActionStatusBuilder { public ActionStatusCreate create(final long actionId) { return new JpaActionStatusCreate(actionId); } - -} +} \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaActionStatusCreate.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaActionStatusCreate.java index 2cf8cdb78..a3a27b5df 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaActionStatusCreate.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaActionStatusCreate.java @@ -33,4 +33,4 @@ public class JpaActionStatusCreate extends AbstractActionStatusCreate - implements DistributionSetCreate { +public class JpaDistributionSetCreate extends AbstractDistributionSetUpdateCreate 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; } - -} +} \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaDistributionSetTypeBuilder.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaDistributionSetTypeBuilder.java index f992808db..81980ac7f 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaDistributionSetTypeBuilder.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaDistributionSetTypeBuilder.java @@ -36,5 +36,4 @@ public class JpaDistributionSetTypeBuilder implements DistributionSetTypeBuilder public DistributionSetTypeCreate create() { return new JpaDistributionSetTypeCreate(softwareModuleTypeManagement); } - -} +} \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaDistributionSetTypeCreate.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaDistributionSetTypeCreate.java index 27fbf422c..5f285ecf5 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaDistributionSetTypeCreate.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaDistributionSetTypeCreate.java @@ -55,5 +55,4 @@ public class JpaDistributionSetTypeCreate extends AbstractDistributionSetTypeUpd return module; } - -} +} \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaRolloutBuilder.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaRolloutBuilder.java index 11811de71..81d1b6370 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaRolloutBuilder.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaRolloutBuilder.java @@ -36,5 +36,4 @@ public class JpaRolloutBuilder implements RolloutBuilder { public RolloutCreate create() { return new JpaRolloutCreate(distributionSetManagement); } - -} +} \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaRolloutGroupBuilder.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaRolloutGroupBuilder.java index ea937e2ee..742ffbd95 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaRolloutGroupBuilder.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaRolloutGroupBuilder.java @@ -22,5 +22,4 @@ public class JpaRolloutGroupBuilder implements RolloutGroupBuilder { public RolloutGroupCreate create() { return new JpaRolloutGroupCreate(); } - -} +} \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaRolloutGroupCreate.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaRolloutGroupCreate.java index 5cb56821a..829ad7f13 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaRolloutGroupCreate.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaRolloutGroupCreate.java @@ -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 - implements RolloutGroupCreate { +public class JpaRolloutGroupCreate extends AbstractRolloutGroupCreate implements RolloutGroupCreate { /** * Set the Success And Error conditions for the rollout group @@ -84,5 +83,4 @@ public class JpaRolloutGroupCreate extends AbstractRolloutGroupCreate - implements SoftwareModuleCreate { +public class JpaSoftwareModuleCreate extends AbstractSoftwareModuleUpdateCreate 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())); } -} +} \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaSoftwareModuleMetadataBuilder.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaSoftwareModuleMetadataBuilder.java index 0ee173f7b..e4e63a318 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaSoftwareModuleMetadataBuilder.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaSoftwareModuleMetadataBuilder.java @@ -36,5 +36,4 @@ public class JpaSoftwareModuleMetadataBuilder implements SoftwareModuleMetadataB public SoftwareModuleMetadataCreate create(final long softwareModuleId) { return new JpaSoftwareModuleMetadataCreate(softwareModuleId, softwareModuleManagement); } - -} +} \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaSoftwareModuleMetadataCreate.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaSoftwareModuleMetadataCreate.java index 8b83dccb9..947976e10 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaSoftwareModuleMetadataCreate.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaSoftwareModuleMetadataCreate.java @@ -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)); } - -} +} \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaSoftwareModuleTypeBuilder.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaSoftwareModuleTypeBuilder.java index 4ad36bae1..d22284765 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaSoftwareModuleTypeBuilder.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaSoftwareModuleTypeBuilder.java @@ -29,5 +29,4 @@ public class JpaSoftwareModuleTypeBuilder implements SoftwareModuleTypeBuilder { public SoftwareModuleTypeCreate create() { return new JpaSoftwareModuleTypeCreate(); } - -} +} \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaSoftwareModuleTypeCreate.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaSoftwareModuleTypeCreate.java index 9f618205b..7b3d582a0 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaSoftwareModuleTypeCreate.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaSoftwareModuleTypeCreate.java @@ -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 implements SoftwareModuleTypeCreate { - JpaSoftwareModuleTypeCreate() { - - } - @Override public JpaSoftwareModuleType build() { return new JpaSoftwareModuleType(key, name, description, maxAssignments, colour); } -} +} \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaTagBuilder.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaTagBuilder.java index b6b3c1c08..9334c954c 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaTagBuilder.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaTagBuilder.java @@ -29,5 +29,4 @@ public class JpaTagBuilder implements TagBuilder { public TagCreate create() { return new JpaTagCreate(); } - -} +} \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaTagCreate.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaTagCreate.java index 049e668de..f2d859538 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaTagCreate.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaTagCreate.java @@ -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 implements TagCreate { - JpaTagCreate() { - - } - public JpaDistributionSetTag buildDistributionSetTag() { return new JpaDistributionSetTag(name, description, colour); } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaTargetBuilder.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaTargetBuilder.java index 20f6b1339..0c5dd0e98 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaTargetBuilder.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaTargetBuilder.java @@ -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); } - -} +} \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaTargetCreate.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaTargetCreate.java index 03ea57b87..4e76151b7 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaTargetCreate.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaTargetCreate.java @@ -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 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 im return target; } - -} +} \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaTargetFilterQueryBuilder.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaTargetFilterQueryBuilder.java index 0981f6c8e..92a6460e4 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaTargetFilterQueryBuilder.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaTargetFilterQueryBuilder.java @@ -42,5 +42,4 @@ public class JpaTargetFilterQueryBuilder implements TargetFilterQueryBuilder { public TargetFilterQueryCreate create() { return new JpaTargetFilterQueryCreate(distributionSetManagement); } - -} +} \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaTargetFilterQueryCreate.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaTargetFilterQueryCreate.java index a7f6c806a..0cc8b3014 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaTargetFilterQueryCreate.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaTargetFilterQueryCreate.java @@ -44,5 +44,4 @@ public class JpaTargetFilterQueryCreate extends AbstractTargetFilterQueryUpdateC return true; } - -} +} \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaTargetTypeBuilder.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaTargetTypeBuilder.java index 46a57bace..a92414326 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaTargetTypeBuilder.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaTargetTypeBuilder.java @@ -41,4 +41,4 @@ public class JpaTargetTypeBuilder implements TargetTypeBuilder { public TargetTypeCreate create() { return new JpaTargetTypeCreate(distributionSetTypeManagement); } -} +} \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaTargetTypeCreate.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaTargetTypeCreate.java index fc7a7c935..50005c7cb 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaTargetTypeCreate.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaTargetTypeCreate.java @@ -25,8 +25,7 @@ import org.springframework.util.CollectionUtils; /** * Create/build implementation. */ -public class JpaTargetTypeCreate extends AbstractTargetTypeUpdateCreate - implements TargetTypeCreate { +public class JpaTargetTypeCreate extends AbstractTargetTypeUpdateCreate implements TargetTypeCreate { private final DistributionSetTypeManagement distributionSetTypeManagement; diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaTargetUpdate.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaTargetUpdate.java index 179ed8f62..1a58d240f 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaTargetUpdate.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/builder/JpaTargetUpdate.java @@ -17,5 +17,4 @@ public class JpaTargetUpdate extends AbstractTargetUpdateCreate im JpaTargetUpdate(final String controllerId) { super(controllerId); } - -} +} \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/configuration/Constants.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/configuration/Constants.java index 77c0c3ae0..71d1d529a 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/configuration/Constants.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/configuration/Constants.java @@ -36,4 +36,4 @@ public final class Constants { * @see Backoff#delay() */ public static final long TX_RT_DELAY = 100; -} +} \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/configuration/MultiTenantJpaTransactionManager.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/configuration/MultiTenantJpaTransactionManager.java index ae657458c..1f25b4109 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/configuration/MultiTenantJpaTransactionManager.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/configuration/MultiTenantJpaTransactionManager.java @@ -51,4 +51,4 @@ public class MultiTenantJpaTransactionManager extends JpaTransactionManager { em.setProperty(PersistenceUnitProperties.MULTITENANT_PROPERTY_DEFAULT, currentTenant.toUpperCase()); } } -} +} \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/executor/AfterTransactionCommitDefaultServiceExecutor.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/executor/AfterTransactionCommitDefaultServiceExecutor.java index 883bc2d95..e3123c571 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/executor/AfterTransactionCommitDefaultServiceExecutor.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/executor/AfterTransactionCommitDefaultServiceExecutor.java @@ -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> THREAD_LOCAL_RUNNABLES = new ThreadLocal<>(); @@ -69,5 +68,4 @@ public class AfterTransactionCommitDefaultServiceExecutor extends TransactionSyn runnable.run(); } - -} +} \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/executor/AfterTransactionCommitExecutor.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/executor/AfterTransactionCommitExecutor.java index a63a6ba34..d902085b3 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/executor/AfterTransactionCommitExecutor.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/executor/AfterTransactionCommitExecutor.java @@ -23,4 +23,4 @@ public interface AfterTransactionCommitExecutor { * @param runnable the after commit runnable */ void afterCommit(Runnable runnable); -} +} \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/AbstractDsAssignmentStrategy.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/AbstractDsAssignmentStrategy.java index b2ea16f65..47baf0765 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/AbstractDsAssignmentStrategy.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/AbstractDsAssignmentStrategy.java @@ -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 targets, final JpaDistributionSet set) { final Optional 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); } -} +} \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaActionManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaActionManagement.java index a8344bd1b..782037a71 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaActionManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaActionManagement.java @@ -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); } -} +} \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaArtifactManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaArtifactManagement.java index 61fd33dfd..ed83c8a36 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaArtifactManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaArtifactManagement.java @@ -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)); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaConfirmationManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaConfirmationManagement.java index 3dd974d1c..2a160c499 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaConfirmationManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaConfirmationManagement.java @@ -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 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 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 messages) { + private ActionStatusCreate createConfirmationActionStatus(final long actionId, final Integer code, final Collection 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 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)); } -} +} \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaControllerManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaControllerManagement.java index e82a9f292..73185e7b9 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaControllerManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaControllerManagement.java @@ -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 getSoftwareModule(final long id) { - return softwareModuleRepository.findById(id).map(s -> (SoftwareModule) s); + return softwareModuleRepository.findById(id).map(SoftwareModule.class::cast); } @Override - public Map> findTargetVisibleMetaDataBySoftwareModuleId( - final Collection moduleId) { - + public Map> findTargetVisibleMetaDataBySoftwareModuleId(final Collection 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 spec = @@ -332,8 +322,7 @@ public class JpaControllerManagement extends JpaActionManagement implements Cont } @Override - public Optional getActionForDownloadByTargetAndSoftwareModule(final String controllerId, - final long moduleId) { + public Optional 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 data, final UpdateMode mode) { diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaDeploymentManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaDeploymentManagement.java index 93a43ca7f..116c9c468 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaDeploymentManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaDeploymentManagement.java @@ -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 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 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 assignDistributionSets( - final List deploymentRequests) { + public List assignDistributionSets(final List deploymentRequests) { return assignDistributionSets(tenantAware.getCurrentUsername(), deploymentRequests, null); } @Override @Transactional(isolation = Isolation.READ_COMMITTED) - public List assignDistributionSets(final String initiatedBy, - final List deploymentRequests, final String actionMessage) { - WeightValidationHelper.usingContext(systemSecurityContext, tenantConfigurationManagement) - .validate(deploymentRequests); + public List assignDistributionSets( + final String initiatedBy, final List 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 offlineAssignedDistributionSets( - final Collection> assignments) { + public List offlineAssignedDistributionSets(final Collection> 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 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> convertRequest( - final Collection deploymentRequests) { - return deploymentRequests.stream().collect(Collectors.groupingBy(DeploymentRequest::getDistributionSetId, - Collectors.mapping(DeploymentRequest::getTargetWithActionType, Collectors.toList()))); + private static Map> convertRequest(final Collection 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> getTargetEntitiesAsChunks(final List 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 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 assignDistributionSets(final String initiatedBy, + private List assignDistributionSets( + final String initiatedBy, final List deploymentRequests, final String actionMessage, final AbstractDsAssignmentStrategy strategy) { final List validatedRequests = validateAndFilterRequestForAssignments(deploymentRequests); final Map> assignmentsByDsIds = convertRequest(validatedRequests); final List 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 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 deploymentRequests) { - final List controllerIds = deploymentRequests.stream().map(DeploymentRequest::getControllerId) - .distinct().toList(); + final List controllerIds = deploymentRequests.stream() + .map(DeploymentRequest::getControllerId) + .distinct() + .toList(); final List 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 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 distSetTypeNames = incompatibleDistSetTypes.stream().map(DistributionSetType::getName) + final Set 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 filterByTargetUpdatable(final List deploymentRequests) { - final List controllerIds = deploymentRequests.stream().map(DeploymentRequest::getControllerId) - .distinct().toList(); + final List controllerIds = deploymentRequests.stream() + .map(DeploymentRequest::getControllerId) + .distinct() + .toList(); final List 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 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 diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaDistributionSetInvalidationManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaDistributionSetInvalidationManagement.java index ce418ac79..7cd89bb82 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaDistributionSetInvalidationManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaDistributionSetInvalidationManagement.java @@ -183,4 +183,4 @@ public class JpaDistributionSetInvalidationManagement implements DistributionSet .countByDistributionSetIdAndActiveIsTrueAndStatusIsNot(distributionSet, Status.CANCELING)) .sum(); } -} +} \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaDistributionSetManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaDistributionSetManagement.java index 9e1a5ca00..08b5c35f5 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaDistributionSetManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaDistributionSetManagement.java @@ -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 create(final Collection creates) { final List 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 distributionSetIDs) { getDistributionSets(distributionSetIDs); // throws EntityNotFoundException if any of these do not exists final List 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 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 assignTag(final Collection 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 unassignTag(final Collection 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 createMetaData(final long id, final Collection 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 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)); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaDistributionSetTagManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaDistributionSetTagManagement.java index 5f775a008..cbcdf3085 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaDistributionSetTagManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaDistributionSetTagManagement.java @@ -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 create(final Collection dst) { final List 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 ids) { final List 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)) diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaDistributionSetTypeManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaDistributionSetTypeManagement.java index 288fabe85..fb9c42345 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaDistributionSetTypeManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaDistributionSetTypeManagement.java @@ -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 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 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 create(final Collection types) { final List 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 ids) { distributionSetTypeRepository.deleteAllById(ids); } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaRolloutManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaRolloutManagement.java index 256597126..c72f43c09 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaRolloutManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaRolloutManagement.java @@ -106,10 +106,10 @@ public class JpaRolloutManagement implements RolloutManagement { private static final List ACTIVE_ROLLOUTS = Arrays.asList(RolloutStatus.CREATING, RolloutStatus.DELETING, RolloutStatus.STARTING, RolloutStatus.READY, RolloutStatus.RUNNING, RolloutStatus.STOPPING); - private static final List 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 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 rollouts) { final List rolloutIds = rollouts.getContent().stream().map(Rollout::getId).collect(Collectors.toList()); - final Map> allStatesForRollout = getStatusCountItemForRollout( - rolloutIds); + final Map> 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) { diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaSoftwareModuleManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaSoftwareModuleManagement.java index 7d0d3eb35..878645a9c 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaSoftwareModuleManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaSoftwareModuleManagement.java @@ -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 create(final Collection swModules) { final List 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 ids) { final List 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 createMetaData(final Collection 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; diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaSoftwareModuleTypeManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaSoftwareModuleTypeManagement.java index b3822b6d0..1e37a0dcd 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaSoftwareModuleTypeManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaSoftwareModuleTypeManagement.java @@ -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 create(final Collection c) { final List 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 ids) { softwareModuleTypeRepository .findAll(AccessController.Operation.DELETE, softwareModuleTypeRepository.byIdsSpec(ids)) diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaSystemManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaSystemManagement.java index 6e04187f7..d66da34cb 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaSystemManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaSystemManagement.java @@ -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(); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaTargetFilterQueryManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaTargetFilterQueryManagement.java index 24d83db99..202d50b02 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaTargetFilterQueryManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaTargetFilterQueryManagement.java @@ -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); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaTargetManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaTargetManagement.java index 8233203aa..fee718386 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaTargetManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaTargetManagement.java @@ -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 create(final Collection targets) { final List 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 ids) { final List 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 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 controllerIds) { final List 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 assignTag(final Collection controllerIds, final long targetTagId, final Consumer> 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 unassignTag(final Collection controllerIds, final long targetTagId, final Consumer> 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 createMetaData(final String controllerId, final Collection 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 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); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaTargetTagManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaTargetTagManagement.java index 380d070fc..b984f0f02 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaTargetTagManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaTargetTagManagement.java @@ -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 create(final Collection tt) { final List 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; diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaTargetTypeManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaTargetTypeManagement.java index 47a344e7d..dede04823 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaTargetTypeManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaTargetTypeManagement.java @@ -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 create(final Collection creates) { final List 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 distributionSetTypeIds) { final Collection 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); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaTenantConfigurationManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaTenantConfigurationManagement.java index f9fd34ee4..f7e763179 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaTenantConfigurationManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaTenantConfigurationManagement.java @@ -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 TenantConfigurationValue 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 Map> addOrUpdateConfiguration(Map 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); } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaTenantStatsManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaTenantStatsManagement.java index 14bce52e8..a18e1d870 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaTenantStatsManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaTenantStatsManagement.java @@ -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; } -} +} \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/OfflineDsAssignmentStrategy.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/OfflineDsAssignmentStrategy.java index beb1d9934..9c94a592e 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/OfflineDsAssignmentStrategy.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/OfflineDsAssignmentStrategy.java @@ -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, diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/AbstractJpaBaseEntity.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/AbstractJpaBaseEntity.java index 7161a39e9..08103a2fb 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/AbstractJpaBaseEntity.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/AbstractJpaBaseEntity.java @@ -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(); } } \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/DistributionSetTypeElement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/DistributionSetTypeElement.java index bfa47fc51..40ca85776 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/DistributionSetTypeElement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/DistributionSetTypeElement.java @@ -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; diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaAction.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaAction.java index 4e175fd3c..27f1a83d4 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaAction.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaAction.java @@ -93,87 +93,42 @@ public class JpaAction extends AbstractJpaTenantAwareBaseEntity implements Actio @Column(name = "active") private boolean active; - - @Converter - public static class ActionTypeConverter extends MapAttributeConverter { - - public ActionTypeConverter() { - super(Map.of( - ActionType.FORCED, 0, - ActionType.SOFT, 1, - ActionType.TIMEFORCED, 2, - ActionType.DOWNLOAD_ONLY, 3 - ), null); - } - } @Column(name = "action_type", nullable = false) @Convert(converter = ActionTypeConverter.class) @NotNull private ActionType actionType; - @Column(name = "forced_time") private long forcedTime; - @Column(name = "weight") @Min(Action.WEIGHT_MIN) @Max(Action.WEIGHT_MAX) private Integer weight; - - @Converter - public static class StatusConverter extends MapAttributeConverter { - - public StatusConverter() { - super(new HashMap<>() {{ - put(Status.FINISHED, 0); - put(Status.ERROR, 1); - put(Status.WARNING, 2); - put(Status.RUNNING, 3); - put(Status.CANCELED, 4); - put(Status.CANCELING, 5); - put(Status.RETRIEVED, 6); - put(Status.DOWNLOAD, 7); - put(Status.SCHEDULED, 8); - put(Status.CANCEL_REJECTED, 9); - put(Status.DOWNLOADED, 10); - put(Status.WAIT_FOR_CONFIRMATION, 11); - }}, null); - } - } @Column(name = "status", nullable = false) @Convert(converter = StatusConverter.class) @NotNull private Status status; - @OneToMany(mappedBy = "action", targetEntity = JpaActionStatus.class, fetch = FetchType.LAZY, cascade = { CascadeType.REMOVE }) private List actionStatus; - @ManyToOne(fetch = FetchType.LAZY) @JoinColumn( name = "rolloutgroup", updatable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_action_rolloutgroup")) private JpaRolloutGroup rolloutGroup; - @ManyToOne(fetch = FetchType.LAZY) @JoinColumn( name = "rollout", updatable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_action_rollout")) private JpaRollout rollout; - @Column(name = "maintenance_cron_schedule", updatable = false, length = Action.MAINTENANCE_WINDOW_SCHEDULE_LENGTH) private String maintenanceWindowSchedule; - @Column(name = "maintenance_duration", updatable = false, length = Action.MAINTENANCE_WINDOW_DURATION_LENGTH) private String maintenanceWindowDuration; - @Column(name = "maintenance_time_zone", updatable = false, length = Action.MAINTENANCE_WINDOW_TIMEZONE_LENGTH) private String maintenanceWindowTimeZone; - @Column(name = "external_ref", length = Action.EXTERNAL_REF_MAX_LENGTH) private String externalRef; - @Column(name = "initiated_by", updatable = false, nullable = false, length = USERNAME_FIELD_LENGTH) private String initiatedBy; - @Column(name = "last_action_status_code", nullable = true, updatable = true) private Integer lastActionStatusCode; @@ -423,4 +378,38 @@ public class JpaAction extends AbstractJpaTenantAwareBaseEntity implements Actio return getMaintenanceWindowStartTime() .map(start -> start.plus(MaintenanceScheduleHelper.convertToISODuration(maintenanceWindowDuration))); } + + @Converter + public static class ActionTypeConverter extends MapAttributeConverter { + + public ActionTypeConverter() { + super(Map.of( + ActionType.FORCED, 0, + ActionType.SOFT, 1, + ActionType.TIMEFORCED, 2, + ActionType.DOWNLOAD_ONLY, 3 + ), null); + } + } + + @Converter + public static class StatusConverter extends MapAttributeConverter { + + public StatusConverter() { + super(new HashMap<>() {{ + put(Status.FINISHED, 0); + put(Status.ERROR, 1); + put(Status.WARNING, 2); + put(Status.RUNNING, 3); + put(Status.CANCELED, 4); + put(Status.CANCELING, 5); + put(Status.RETRIEVED, 6); + put(Status.DOWNLOAD, 7); + put(Status.SCHEDULED, 8); + put(Status.CANCEL_REJECTED, 9); + put(Status.DOWNLOADED, 10); + put(Status.WAIT_FOR_CONFIRMATION, 11); + }}, null); + } + } } \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaActionStatus.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaActionStatus.java index 2018ba35c..22ae2b8a2 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaActionStatus.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaActionStatus.java @@ -58,7 +58,8 @@ public class JpaActionStatus extends AbstractJpaTenantAwareBaseEntity implements private static final int MESSAGE_ENTRY_LENGTH = 512; - @Setter @Getter + @Setter + @Getter @Column(name = "target_occurred_at", nullable = false, updatable = false) private long occurredAt; @@ -69,7 +70,8 @@ public class JpaActionStatus extends AbstractJpaTenantAwareBaseEntity implements @NotNull private JpaAction action; - @Setter @Getter + @Setter + @Getter @Column(name = "status", nullable = false, updatable = false) @Convert(converter = JpaAction.StatusConverter.class) @NotNull diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaAutoConfirmationStatus.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaAutoConfirmationStatus.java index fef648450..4f5b88df7 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaAutoConfirmationStatus.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaAutoConfirmationStatus.java @@ -82,9 +82,9 @@ public class JpaAutoConfirmationStatus extends AbstractJpaTenantAwareBaseEntity // nevertheless of the end of line of the file (\r\n, \n or \r) the result will contains \n return """ Assignment automatically confirmed by initiator '%s'.\040 - + Auto confirmation activated by system user: '%s'\040 - + Remark: %s""".formatted(formattedInitiator, createdByRolloutsUser, remarkMessage); } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaDistributionSet.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaDistributionSet.java index d58583c3a..98f58fb97 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaDistributionSet.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaDistributionSet.java @@ -108,7 +108,8 @@ public class JpaDistributionSet extends AbstractJpaNamedVersionedEntity implemen private Set tags; @ToString.Exclude - @OneToMany(mappedBy = "distributionSet", fetch = FetchType.LAZY, cascade = { CascadeType.REMOVE }, targetEntity = JpaDistributionSetMetadata.class) + @OneToMany(mappedBy = "distributionSet", fetch = FetchType.LAZY, cascade = { + CascadeType.REMOVE }, targetEntity = JpaDistributionSetMetadata.class) private List metadata; @Column(name = "complete") diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaDistributionSetType.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaDistributionSetType.java index 3f4bfc996..c35febaeb 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaDistributionSetType.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaDistributionSetType.java @@ -56,7 +56,8 @@ public class JpaDistributionSetType extends AbstractJpaTypeEntity implements Dis @Serial private static final long serialVersionUID = 1L; - @OneToMany(mappedBy = "dsType", targetEntity = DistributionSetTypeElement.class, fetch = FetchType.EAGER, cascade = { CascadeType.PERSIST, CascadeType.REMOVE }, orphanRemoval = true) + @OneToMany(mappedBy = "dsType", targetEntity = DistributionSetTypeElement.class, fetch = FetchType.EAGER, cascade = { CascadeType.PERSIST, + CascadeType.REMOVE }, orphanRemoval = true) private Set elements; @Column(name = "deleted") diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaRollout.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaRollout.java index 042d7d616..e01ec111a 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaRollout.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaRollout.java @@ -72,75 +72,40 @@ public class JpaRollout extends AbstractJpaNamedEntity implements Rollout, Event @JoinColumn(name = "distribution_set", nullable = false, updatable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_rolltout_ds")) @NotNull private JpaDistributionSet distributionSet; - - @Converter - public static class RolloutStatusConverter extends MapAttributeConverter { - - public RolloutStatusConverter() { - super(new HashMap<>() {{ - put(RolloutStatus.CREATING, 0); - put(RolloutStatus.READY, 1); - put(RolloutStatus.PAUSED, 2); - put(RolloutStatus.STARTING, 3); - put(RolloutStatus.STOPPED, 4); - put(RolloutStatus.RUNNING, 5); - put(RolloutStatus.FINISHED, 6); - put(RolloutStatus.ERROR_CREATING, 7); - put(RolloutStatus.ERROR_STARTING, 8); - put(RolloutStatus.DELETING, 9); - put(RolloutStatus.DELETED, 10); - put(RolloutStatus.WAITING_FOR_APPROVAL, 11); - put(RolloutStatus.APPROVAL_DENIED, 12); - put(RolloutStatus.STOPPING, 13); - }}, null); - } - } @Column(name = "status", nullable = false) @Convert(converter = RolloutStatusConverter.class) @NotNull private RolloutStatus status = RolloutStatus.CREATING; @Column(name = "last_check") private long lastCheck; - @Column(name = "action_type", nullable = false) @Convert(converter = JpaAction.ActionTypeConverter.class) @NotNull private ActionType actionType = ActionType.FORCED; - @Column(name = "forced_time") private long forcedTime; - @Column(name = "total_targets") private long totalTargets; - @Column(name = "rollout_groups_created") private int rolloutGroupsCreated; - @Column(name = "deleted") private boolean deleted; - @Column(name = "start_at") private Long startAt; - @Column(name = "approval_decided_by") @Size(min = 1, max = Rollout.APPROVED_BY_MAX_SIZE) private String approvalDecidedBy; - @Column(name = "approval_remark") @Size(max = Rollout.APPROVAL_REMARK_MAX_SIZE) private String approvalRemark; - @Column(name = "weight") @Min(Action.WEIGHT_MIN) @Max(Action.WEIGHT_MAX) private Integer weight; - @Column(name = "is_dynamic") // dynamic is reserved keyword in some databases private Boolean dynamic; - @Column(name = "access_control_context", nullable = true) private String accessControlContext; - @Transient private transient TotalTargetCountStatus totalTargetCountStatus; @@ -331,4 +296,27 @@ public class JpaRollout extends AbstractJpaNamedEntity implements Rollout, Event public void setDeleted(final boolean deleted) { this.deleted = deleted; } + + @Converter + public static class RolloutStatusConverter extends MapAttributeConverter { + + public RolloutStatusConverter() { + super(new HashMap<>() {{ + put(RolloutStatus.CREATING, 0); + put(RolloutStatus.READY, 1); + put(RolloutStatus.PAUSED, 2); + put(RolloutStatus.STARTING, 3); + put(RolloutStatus.STOPPED, 4); + put(RolloutStatus.RUNNING, 5); + put(RolloutStatus.FINISHED, 6); + put(RolloutStatus.ERROR_CREATING, 7); + put(RolloutStatus.ERROR_STARTING, 8); + put(RolloutStatus.DELETING, 9); + put(RolloutStatus.DELETED, 10); + put(RolloutStatus.WAITING_FOR_APPROVAL, 11); + put(RolloutStatus.APPROVAL_DENIED, 12); + put(RolloutStatus.STOPPING, 13); + }}, null); + } + } } \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaRolloutGroup.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaRolloutGroup.java index 906a232af..2cd19782a 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaRolloutGroup.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaRolloutGroup.java @@ -57,110 +57,80 @@ public class JpaRolloutGroup extends AbstractJpaNamedEntity implements RolloutGr @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "rollout", nullable = false, updatable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_rolloutgroup_rollout")) private JpaRollout rollout; - - @Converter - public static class RolloutGroupStatusConverter extends MapAttributeConverter { - - public RolloutGroupStatusConverter() { - super(Map.of( - RolloutGroupStatus.READY, 0, - RolloutGroupStatus.SCHEDULED, 1, - RolloutGroupStatus.FINISHED, 2, - RolloutGroupStatus.ERROR, 3, - RolloutGroupStatus.RUNNING, 4, - RolloutGroupStatus.CREATING, 5 - ), null); - } - } - @Setter @Getter @Column(name = "status", nullable = false) @Convert(converter = RolloutGroupStatusConverter.class) private RolloutGroupStatus status = RolloutGroupStatus.CREATING; - - @OneToMany(mappedBy = "rolloutGroup", fetch = FetchType.LAZY, cascade = { CascadeType.PERSIST, CascadeType.REMOVE }, targetEntity = RolloutTargetGroup.class) + @OneToMany(mappedBy = "rolloutGroup", fetch = FetchType.LAZY, cascade = { CascadeType.PERSIST, + CascadeType.REMOVE }, targetEntity = RolloutTargetGroup.class) private List rolloutTargetGroup; - // No foreign key to avoid to many nested cascades on delete which some DBs cannot handle @Setter @Getter @ManyToOne(fetch = FetchType.LAZY, cascade = { CascadeType.PERSIST }) @JoinColumn(name = "parent_id") private JpaRolloutGroup parent; - - @Setter @Getter + @Setter + @Getter @Column(name = "is_dynamic") // dynamic is reserved keyword in some databases private boolean dynamic; - @Setter @Getter @Column(name = "success_condition", nullable = false) @NotNull private RolloutGroupSuccessCondition successCondition = RolloutGroupSuccessCondition.THRESHOLD; - @Setter @Getter @Column(name = "success_condition_exp", length = 512, nullable = false) @Size(max = 512) @NotNull private String successConditionExp; - @Setter @Getter @Column(name = "success_action", nullable = false) @NotNull private RolloutGroupSuccessAction successAction = RolloutGroupSuccessAction.NEXTGROUP; - @Setter @Getter @Column(name = "success_action_exp", length = 512) @Size(max = 512) private String successActionExp; - @Setter @Getter @Column(name = "error_condition") private RolloutGroupErrorCondition errorCondition; - @Setter @Getter @Column(name = "error_condition_exp", length = 512) @Size(max = 512) private String errorConditionExp; - @Setter @Getter @Column(name = "error_action") private RolloutGroupErrorAction errorAction; - @Setter @Getter @Column(name = "error_action_exp", length = 512) @Size(max = 512) private String errorActionExp; - @Setter @Getter @Column(name = "total_targets") private int totalTargets; - @Setter @Getter @Column(name = "target_filter", length = 1024) @Size(max = 1024) private String targetFilterQuery = ""; - @Setter @Getter @Column(name = "target_percentage") private float targetPercentage = 100; - @Setter @Getter @Column(name = "confirmation_required") private boolean confirmationRequired; - @Setter @Transient private transient TotalTargetCountStatus totalTargetCountStatus; @@ -219,4 +189,19 @@ public class JpaRolloutGroup extends AbstractJpaNamedEntity implements RolloutGr EventPublisherHolder.getInstance().getEventPublisher().publishEvent( new RolloutGroupDeletedEvent(getTenant(), getId(), getClass(), EventPublisherHolder.getInstance().getApplicationId())); } + + @Converter + public static class RolloutGroupStatusConverter extends MapAttributeConverter { + + public RolloutGroupStatusConverter() { + super(Map.of( + RolloutGroupStatus.READY, 0, + RolloutGroupStatus.SCHEDULED, 1, + RolloutGroupStatus.FINISHED, 2, + RolloutGroupStatus.ERROR, 3, + RolloutGroupStatus.RUNNING, 4, + RolloutGroupStatus.CREATING, 5 + ), null); + } + } } \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaSoftwareModule.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaSoftwareModule.java index 2b43455ec..383fadb61 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaSoftwareModule.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaSoftwareModule.java @@ -77,7 +77,8 @@ public class JpaSoftwareModule extends AbstractJpaNamedVersionedEntity implement @NotNull private JpaSoftwareModuleType type; - @OneToMany(fetch = FetchType.LAZY, mappedBy = "softwareModule", cascade = { CascadeType.PERSIST, CascadeType.REMOVE }, targetEntity = JpaArtifact.class, orphanRemoval = true) + @OneToMany(fetch = FetchType.LAZY, mappedBy = "softwareModule", cascade = { CascadeType.PERSIST, + CascadeType.REMOVE }, targetEntity = JpaArtifact.class, orphanRemoval = true) private List artifacts; @Setter @@ -90,7 +91,8 @@ public class JpaSoftwareModule extends AbstractJpaNamedVersionedEntity implement private boolean encrypted; @ToString.Exclude - @OneToMany(mappedBy = "softwareModule", fetch = FetchType.LAZY, cascade = { CascadeType.REMOVE }, targetEntity = JpaSoftwareModuleMetadata.class) + @OneToMany(mappedBy = "softwareModule", fetch = FetchType.LAZY, cascade = { + CascadeType.REMOVE }, targetEntity = JpaSoftwareModuleMetadata.class) private List metadata; @Column(name = "locked") diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaTarget.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaTarget.java index c3896d476..f09e7db78 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaTarget.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaTarget.java @@ -118,45 +118,25 @@ public class JpaTarget extends AbstractJpaNamedEntity implements Target, EventAw @Column(name = "install_date") private Long installationDate; - - @Converter - public static class TargetUpdateStatusConverter extends MapAttributeConverter { - - public TargetUpdateStatusConverter() { - super(Map.of( - TargetUpdateStatus.UNKNOWN, 0, - TargetUpdateStatus.IN_SYNC, 1, - TargetUpdateStatus.PENDING, 2, - TargetUpdateStatus.ERROR, 3, - TargetUpdateStatus.REGISTERED, 4 - ), null); - } - } @Column(name = "update_status", nullable = false) @Convert(converter = TargetUpdateStatusConverter.class) @NotNull private TargetUpdateStatus updateStatus = TargetUpdateStatus.UNKNOWN; - @ManyToOne(optional = true, fetch = FetchType.LAZY) @JoinColumn(name = "installed_distribution_set", nullable = true, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_target_inst_ds")) private JpaDistributionSet installedDistributionSet; - @ManyToOne(optional = true, fetch = FetchType.LAZY) @JoinColumn(name = "assigned_distribution_set", nullable = true, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_target_assign_ds")) private JpaDistributionSet assignedDistributionSet; - // set default request controller attributes to true, because we want to request them the first time @Column(name = "request_controller_attributes", nullable = false) private boolean requestControllerAttributes = true; - @OneToOne(fetch = FetchType.LAZY, mappedBy = "target", orphanRemoval = true) @PrimaryKeyJoinColumn private JpaAutoConfirmationStatus autoConfirmationStatus; - @ManyToOne(fetch = FetchType.LAZY, targetEntity = JpaTargetType.class) @JoinColumn(name = "target_type", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_target_relation_target_type")) private TargetType targetType; - @ManyToMany(targetEntity = JpaTargetTag.class) @JoinTable( name = "sp_target_target_tag", @@ -170,7 +150,6 @@ public class JpaTarget extends AbstractJpaNamedEntity implements Target, EventAw foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_targ_targtag_tag")) }) private Set tags; - /** * Supplied / committed by the controller. Read-only via management API. */ @@ -183,7 +162,6 @@ public class JpaTarget extends AbstractJpaNamedEntity implements Target, EventAw joinColumns = { @JoinColumn(name = "target_id", nullable = false, insertable = false, updatable = false) }, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_targ_attrib_target")) private Map controllerAttributes; - @OneToMany(mappedBy = "target", fetch = FetchType.LAZY, cascade = { CascadeType.REMOVE }, targetEntity = JpaTargetMetadata.class) private List metadata; @@ -496,4 +474,18 @@ public class JpaTarget extends AbstractJpaNamedEntity implements Target, EventAw public List getUpdateIgnoreFields() { return TARGET_UPDATE_EVENT_IGNORE_FIELDS; } + + @Converter + public static class TargetUpdateStatusConverter extends MapAttributeConverter { + + public TargetUpdateStatusConverter() { + super(Map.of( + TargetUpdateStatus.UNKNOWN, 0, + TargetUpdateStatus.IN_SYNC, 1, + TargetUpdateStatus.PENDING, 2, + TargetUpdateStatus.ERROR, 3, + TargetUpdateStatus.REGISTERED, 4 + ), null); + } + } } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DistributionSetTagManagementTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DistributionSetTagManagementTest.java index 3540f3430..3cef72444 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DistributionSetTagManagementTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DistributionSetTagManagementTest.java @@ -19,7 +19,6 @@ import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Random; -import java.util.stream.Collectors; import java.util.stream.Stream; import io.qameta.allure.Description; diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/RolloutGroupManagementTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/RolloutGroupManagementTest.java index c0804b0a3..99cc22953 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/RolloutGroupManagementTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/RolloutGroupManagementTest.java @@ -47,7 +47,7 @@ import org.springframework.util.CollectionUtils; class RolloutGroupManagementTest extends AbstractJpaIntegrationTest { @Test - @Description("Verifies that management get access reacts as specified on calls for non existing entities by means " + + @Description("Verifies that management get access reacts as specified on calls for non existing entities by means " + "of Optional not present.") @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) }) void nonExistingEntityAccessReturnsNotPresent() { @@ -227,7 +227,7 @@ class RolloutGroupManagementTest extends AbstractJpaIntegrationTest { final JpaRolloutGroup rolloutGroup = ((JpaRolloutGroup) rolloutGroupManagement.get(id).orElseThrow()); rolloutGroup.setStatus(status); rolloutGroupRepository.save(rolloutGroup); - assertThat( rolloutGroupManagement.get(id).orElseThrow().getStatus()).isEqualTo(status); + assertThat(rolloutGroupManagement.get(id).orElseThrow().getStatus()).isEqualTo(status); } } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/RolloutManagementTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/RolloutManagementTest.java index 330b7fa15..e946efb1c 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/RolloutManagementTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/RolloutManagementTest.java @@ -2086,7 +2086,7 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest { void testRolloutStatusConvert() { final long id = testdataFactory.createAndStartRollout(1, 0, 1, "100", "80").getId(); for (final RolloutStatus status : RolloutStatus.values()) { - final JpaRollout rollout = ((JpaRollout)rolloutManagement.get(id).orElseThrow()); + final JpaRollout rollout = ((JpaRollout) rolloutManagement.get(id).orElseThrow()); rollout.setStatus(status); rolloutRepository.save(rollout); assertThat(rolloutManagement.get(id).orElseThrow().getStatus()).isEqualTo(status); @@ -2098,7 +2098,7 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest { void testActionTypeConvert() { final long id = testdataFactory.createAndStartRollout(1, 0, 1, "100", "80").getId(); for (final ActionType actionType : ActionType.values()) { - final JpaRollout rollout = ((JpaRollout)rolloutManagement.get(id).orElseThrow()); + final JpaRollout rollout = ((JpaRollout) rolloutManagement.get(id).orElseThrow()); rollout.setActionType(actionType); rolloutRepository.save(rollout); assertThat(rolloutManagement.get(id).orElseThrow().getActionType()).isEqualTo(actionType); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TenantConfigurationManagementTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TenantConfigurationManagementTest.java index ec00406b0..ceaf08f18 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TenantConfigurationManagementTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TenantConfigurationManagementTest.java @@ -21,11 +21,11 @@ import io.qameta.allure.Description; import io.qameta.allure.Feature; import io.qameta.allure.Story; import org.eclipse.hawkbit.repository.exception.InvalidTenantConfigurationKeyException; +import org.eclipse.hawkbit.repository.exception.TenantConfigurationValidatorException; import org.eclipse.hawkbit.repository.jpa.AbstractJpaIntegrationTest; import org.eclipse.hawkbit.repository.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.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.springframework.context.EnvironmentAware; diff --git a/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/TestConfiguration.java b/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/TestConfiguration.java index 8ca3df395..17811ec12 100644 --- a/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/TestConfiguration.java +++ b/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/TestConfiguration.java @@ -17,12 +17,11 @@ import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.atomic.AtomicLong; import org.eclipse.hawkbit.ContextAware; -import org.eclipse.hawkbit.tenancy.configuration.ControllerPollProperties; -import org.eclipse.hawkbit.artifact.repository.urlhandler.ArtifactUrlHandlerProperties; -import org.eclipse.hawkbit.artifact.repository.urlhandler.PropertyBasedArtifactUrlHandler; import org.eclipse.hawkbit.artifact.repository.ArtifactFilesystemProperties; import org.eclipse.hawkbit.artifact.repository.ArtifactFilesystemRepository; import org.eclipse.hawkbit.artifact.repository.ArtifactRepository; +import org.eclipse.hawkbit.artifact.repository.urlhandler.ArtifactUrlHandlerProperties; +import org.eclipse.hawkbit.artifact.repository.urlhandler.PropertyBasedArtifactUrlHandler; import org.eclipse.hawkbit.cache.TenantAwareCacheManager; import org.eclipse.hawkbit.event.BusProtoStuffMessageConverter; import org.eclipse.hawkbit.im.authentication.SpRole; @@ -43,6 +42,7 @@ import org.eclipse.hawkbit.security.SpringSecurityAuditorAware; import org.eclipse.hawkbit.security.SystemSecurityContext; import org.eclipse.hawkbit.tenancy.TenantAware; import org.eclipse.hawkbit.tenancy.UserAuthoritiesResolver; +import org.eclipse.hawkbit.tenancy.configuration.ControllerPollProperties; import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties; import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler; import org.springframework.aop.interceptor.SimpleAsyncUncaughtExceptionHandler; diff --git a/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/AbstractIntegrationTest.java b/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/AbstractIntegrationTest.java index 7e0f95e48..89ddb7e63 100644 --- a/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/AbstractIntegrationTest.java +++ b/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/AbstractIntegrationTest.java @@ -112,9 +112,7 @@ import org.springframework.test.context.TestPropertySource; public abstract class AbstractIntegrationTest { protected static final Pageable PAGE = PageRequest.of(0, 500, Sort.by(Direction.ASC, "id")); - protected static final URI LOCALHOST = URI.create("http://127.0.0.1"); - protected static final int DEFAULT_TEST_WEIGHT = 500; /** @@ -125,80 +123,58 @@ public abstract class AbstractIntegrationTest { */ protected static final int DEFAULT_DS_TYPES = RepositoryConstants.DEFAULT_DS_TYPES_IN_TENANT + 1; + private static final String ARTIFACT_DIRECTORY = createTempDir(); + @Autowired protected EntityFactory entityFactory; - @Autowired protected SoftwareModuleManagement softwareModuleManagement; - @Autowired protected SoftwareModuleTypeManagement softwareModuleTypeManagement; - @Autowired protected DistributionSetManagement distributionSetManagement; - @Autowired protected DistributionSetTypeManagement distributionSetTypeManagement; - @Autowired protected ControllerManagement controllerManagement; - @Autowired protected TargetManagement targetManagement; - @Autowired protected TargetTypeManagement targetTypeManagement; - @Autowired protected TargetFilterQueryManagement targetFilterQueryManagement; - @Autowired protected TargetTagManagement targetTagManagement; - @Autowired protected DistributionSetTagManagement distributionSetTagManagement; - @Autowired protected DeploymentManagement deploymentManagement; - @Autowired protected ConfirmationManagement confirmationManagement; @Autowired protected DistributionSetInvalidationManagement distributionSetInvalidationManagement; - @Autowired protected ArtifactManagement artifactManagement; - @Autowired protected AuditingHandler auditingHandler; - @Autowired protected TenantAware tenantAware; - @Autowired protected SystemManagement systemManagement; - @Autowired protected TenantConfigurationManagement tenantConfigurationManagement; - @Autowired protected RolloutManagement rolloutManagement; - @Autowired protected RolloutHandler rolloutHandler; - @Autowired protected RolloutGroupManagement rolloutGroupManagement; - @Autowired protected SystemSecurityContext systemSecurityContext; - @Autowired protected ArtifactRepository binaryArtifactRepository; - @Autowired protected TenantAwareCacheManager cacheManager; - @Autowired protected QuotaManagement quotaManagement; @@ -210,13 +186,10 @@ public abstract class AbstractIntegrationTest { @Autowired protected TestdataFactory testdataFactory; - @Autowired protected ServiceMatcher serviceMatcher; - @Autowired protected ApplicationEventPublisher eventPublisher; - private static final String ARTIFACT_DIRECTORY = createTempDir(); @BeforeAll public static void beforeClass() { diff --git a/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/AbstractSqlTestDatabase.java b/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/AbstractSqlTestDatabase.java index 0701a63eb..8cf2dde37 100644 --- a/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/AbstractSqlTestDatabase.java +++ b/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/AbstractSqlTestDatabase.java @@ -51,4 +51,4 @@ public abstract class AbstractSqlTestDatabase extends AbstractTestExecutionListe log.error("Execution of statement '{}' on uri {} failed!", statement, uri, e); } } -} +} \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/CleanupTestExecutionListener.java b/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/CleanupTestExecutionListener.java index c309692cd..87909f2dc 100644 --- a/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/CleanupTestExecutionListener.java +++ b/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/CleanupTestExecutionListener.java @@ -33,4 +33,4 @@ public class CleanupTestExecutionListener extends AbstractTestExecutionListener return null; }); } -} +} \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/SecurityContextSwitch.java b/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/SecurityContextSwitch.java index f860abd3c..ac9d2ad0b 100644 --- a/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/SecurityContextSwitch.java +++ b/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/SecurityContextSwitch.java @@ -18,9 +18,9 @@ import java.util.Objects; import java.util.concurrent.Callable; import org.eclipse.hawkbit.im.authentication.SpPermission; +import org.eclipse.hawkbit.repository.model.helper.SystemManagementHolder; import org.eclipse.hawkbit.tenancy.TenantAwareAuthenticationDetails; import org.eclipse.hawkbit.tenancy.TenantAwareUser; -import org.eclipse.hawkbit.repository.model.helper.SystemManagementHolder; import org.springframework.security.authentication.TestingAuthenticationToken; import org.springframework.security.core.Authentication; import org.springframework.security.core.context.SecurityContext;