From 95cd25c31c9b1315c41a322d4163a82c9412eb5b Mon Sep 17 00:00:00 2001 From: Avgustin Marinov Date: Tue, 14 Jan 2025 10:55:28 +0200 Subject: [PATCH] Remove unused ConfirmationManagement.autoConfirmActiveActions Signed-off-by: Avgustin Marinov --- .../repository/ConfirmationManagement.java | 60 +++++++------------ .../management/JpaConfirmationManagement.java | 34 ++++------- .../ConfirmationManagementSecurityTest.java | 7 --- 3 files changed, 33 insertions(+), 68 deletions(-) diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/ConfirmationManagement.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/ConfirmationManagement.java index d82369fdaa..00e2feb7f6 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/ConfirmationManagement.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/ConfirmationManagement.java @@ -27,18 +27,7 @@ public interface ConfirmationManagement { /** - * Find active actions in the {@link Action.Status#WAIT_FOR_CONFIRMATION} state - * for a specific target with a specified controllerId. - * - * @param controllerId of the target to check - * @return a list of {@link Action} - */ - @PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_READ_TARGET) - List findActiveActionsWaitingConfirmation(@NotEmpty String controllerId); - - /** - * Activate auto confirmation for a given controller ID. In case auto - * confirmation is active already, this method will fail with an exception. + * Activate auto confirmation for a given controller ID. In case auto confirmation is active already, this method will fail with an exception. * * @param controllerId to activate the feature for * @param initiator who initiated this operation. If 'null' we will take the current user from {@link TenantAware#getCurrentUsername()} @@ -49,29 +38,7 @@ public interface ConfirmationManagement { AutoConfirmationStatus activateAutoConfirmation(@NotEmpty String controllerId, final String initiator, final String remark); /** - * Get the current state of auto-confirmation for a given controllerId - * - * @param controllerId to check the state for - * @return instance of {@link AutoConfirmationStatus} wrapped in an {@link Optional}. Present if active and empty if disabled. - */ - @PreAuthorize(SpPermission.SpringEvalExpressions.IS_CONTROLLER + SpPermission.SpringEvalExpressions.HAS_AUTH_OR + - SpPermission.SpringEvalExpressions.HAS_AUTH_READ_TARGET) - Optional getStatus(@NotEmpty String controllerId); - - /** - * Auto confirm active actions for a specific controller ID having the - * {@link Action.Status#WAIT_FOR_CONFIRMATION} status. - * - * @param controllerId to confirm actions for - * @return a list of confirmed actions - */ - @PreAuthorize(SpPermission.SpringEvalExpressions.IS_CONTROLLER_OR_HAS_AUTH_READ_REPOSITORY_AND_UPDATE_TARGET) - List autoConfirmActiveActions(@NotEmpty String controllerId); - - /** - * Confirm a given action to put it from - * {@link Action.Status#WAIT_FOR_CONFIRMATION} to {@link Action.Status#RUNNING} - * state. + * Confirm a given action to put it from {@link Action.Status#WAIT_FOR_CONFIRMATION} to {@link Action.Status#RUNNING} state. * * @param actionId mandatory to know which action to confirm * @param code optional value to specify a code for the created action status @@ -81,8 +48,7 @@ public interface ConfirmationManagement { Action confirmAction(long actionId, Integer code, Collection messages); /** - * Deny a given action and leave it in - * {@link Action.Status#WAIT_FOR_CONFIRMATION} state. + * Deny a given action and leave it in {@link Action.Status#WAIT_FOR_CONFIRMATION} state. * * @param actionId mandatory to know which action to deny * @param code optional value to specify a code for the created action status @@ -99,4 +65,22 @@ public interface ConfirmationManagement { @PreAuthorize(SpPermission.SpringEvalExpressions.IS_CONTROLLER_OR_HAS_AUTH_READ_REPOSITORY_AND_UPDATE_TARGET) void deactivateAutoConfirmation(@NotEmpty String controllerId); -} + /** + * Get the current state of auto-confirmation for a given controllerId + * + * @param controllerId to check the state for + * @return instance of {@link AutoConfirmationStatus} wrapped in an {@link Optional}. Present if active and empty if disabled. + */ + @PreAuthorize(SpPermission.SpringEvalExpressions.IS_CONTROLLER + SpPermission.SpringEvalExpressions.HAS_AUTH_OR + + SpPermission.SpringEvalExpressions.HAS_AUTH_READ_TARGET) + Optional getStatus(@NotEmpty String controllerId); + + /** + * Find active actions in the {@link Action.Status#WAIT_FOR_CONFIRMATION} state for a specific target with a specified controllerId. + * + * @param controllerId of the target to check + * @return a list of {@link Action} + */ + @PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_READ_TARGET) + List findActiveActionsWaitingConfirmation(@NotEmpty String controllerId); +} \ No newline at end of file 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 6f90b70648..7a801847ad 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 @@ -75,11 +75,6 @@ public JpaConfirmationManagement( this.entityFactory = entityFactory; } - @Override - public List findActiveActionsWaitingConfirmation(final String controllerId) { - return Collections.unmodifiableList(findActiveActionsHavingStatus(controllerId, Status.WAIT_FOR_CONFIRMATION)); - } - @Override @Transactional public AutoConfirmationStatus activateAutoConfirmation(final String controllerId, final String initiator, final String remark) { @@ -108,24 +103,6 @@ public AutoConfirmationStatus activateAutoConfirmation(final String controllerId return autoConfStatus; } - @Override - public Optional getStatus(final String controllerId) { - return Optional.of(targetRepository.getWithDetailsByControllerId(controllerId, JpaTarget_.GRAPH_TARGET_AUTO_CONFIRMATION_STATUS)) - .map(JpaTarget::getAutoConfirmationStatus); - } - - @Override - @Transactional - public List autoConfirmActiveActions(final String controllerId) { - final JpaTarget target = targetRepository.getWithDetailsByControllerId(controllerId, JpaTarget_.GRAPH_TARGET_AUTO_CONFIRMATION_STATUS); - if (target.getAutoConfirmationStatus() == null) { - // auto-confirmation is not active - return Collections.emptyList(); - } else { - return giveConfirmationForActiveActions(target.getAutoConfirmationStatus()); - } - } - @Override @Transactional(isolation = Isolation.READ_COMMITTED) @Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, @@ -174,6 +151,17 @@ public void deactivateAutoConfirmation(String controllerId) { targetRepository.save(target); } + @Override + public Optional getStatus(final String controllerId) { + return Optional.of(targetRepository.getWithDetailsByControllerId(controllerId, JpaTarget_.GRAPH_TARGET_AUTO_CONFIRMATION_STATUS)) + .map(JpaTarget::getAutoConfirmationStatus); + } + + @Override + public List findActiveActionsWaitingConfirmation(final String controllerId) { + return Collections.unmodifiableList(findActiveActionsHavingStatus(controllerId, Status.WAIT_FOR_CONFIRMATION)); + } + @Override protected void onActionStatusUpdate(final JpaActionStatus newActionStatus, final JpaAction action) { if (newActionStatus.getStatus() == Status.RUNNING && action.isActive()) { diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/ConfirmationManagementSecurityTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/ConfirmationManagementSecurityTest.java index 567c1df182..44f4327ff2 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/ConfirmationManagementSecurityTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/ConfirmationManagementSecurityTest.java @@ -43,13 +43,6 @@ void getStatusPermissionsCheck() { assertPermissions(() -> confirmationManagement.getStatus("controllerId"), List.of(SpPermission.SpringEvalExpressions.CONTROLLER_ROLE), List.of(SpPermission.CREATE_TARGET)); } - @Test - @Description("Tests ConfirmationManagement#autoConfirmActiveActions() method") - void autoConfirmActiveActionsPermissionsCheck() { - assertPermissions(() -> confirmationManagement.autoConfirmActiveActions("controllerId"), - List.of(SpPermission.READ_REPOSITORY, SpPermission.UPDATE_TARGET)); - } - @Test @Description("Tests ConfirmationManagement#confirmAction() method") void confirmActionPermissionsCheck() {