Remove unused ConfirmationManagement.autoConfirmActiveActions (#2197)
Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -27,18 +27,7 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
|||||||
public interface ConfirmationManagement {
|
public interface ConfirmationManagement {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find active actions in the {@link Action.Status#WAIT_FOR_CONFIRMATION} state
|
* Activate auto confirmation for a given controller ID. In case auto confirmation is active already, this method will fail with an exception.
|
||||||
* 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<Action> 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.
|
|
||||||
*
|
*
|
||||||
* @param controllerId to activate the feature for
|
* @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()}
|
* @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);
|
AutoConfirmationStatus activateAutoConfirmation(@NotEmpty String controllerId, final String initiator, final String remark);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the current state of auto-confirmation for a given controllerId
|
* Confirm a given action to put it from {@link Action.Status#WAIT_FOR_CONFIRMATION} to {@link Action.Status#RUNNING} state.
|
||||||
*
|
|
||||||
* @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<AutoConfirmationStatus> 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<Action> autoConfirmActiveActions(@NotEmpty String controllerId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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 actionId mandatory to know which action to confirm
|
||||||
* @param code optional value to specify a code for the created action status
|
* @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<String> messages);
|
Action confirmAction(long actionId, Integer code, Collection<String> messages);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deny a given action and leave it in
|
* Deny a given action and leave it in {@link Action.Status#WAIT_FOR_CONFIRMATION} state.
|
||||||
* {@link Action.Status#WAIT_FOR_CONFIRMATION} state.
|
|
||||||
*
|
*
|
||||||
* @param actionId mandatory to know which action to deny
|
* @param actionId mandatory to know which action to deny
|
||||||
* @param code optional value to specify a code for the created action status
|
* @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)
|
@PreAuthorize(SpPermission.SpringEvalExpressions.IS_CONTROLLER_OR_HAS_AUTH_READ_REPOSITORY_AND_UPDATE_TARGET)
|
||||||
void deactivateAutoConfirmation(@NotEmpty String controllerId);
|
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<AutoConfirmationStatus> 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<Action> findActiveActionsWaitingConfirmation(@NotEmpty String controllerId);
|
||||||
}
|
}
|
||||||
@@ -75,11 +75,6 @@ public class JpaConfirmationManagement extends JpaActionManagement implements Co
|
|||||||
this.entityFactory = entityFactory;
|
this.entityFactory = entityFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Action> findActiveActionsWaitingConfirmation(final String controllerId) {
|
|
||||||
return Collections.unmodifiableList(findActiveActionsHavingStatus(controllerId, Status.WAIT_FOR_CONFIRMATION));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public AutoConfirmationStatus activateAutoConfirmation(final String controllerId, final String initiator, final String remark) {
|
public AutoConfirmationStatus activateAutoConfirmation(final String controllerId, final String initiator, final String remark) {
|
||||||
@@ -108,24 +103,6 @@ public class JpaConfirmationManagement extends JpaActionManagement implements Co
|
|||||||
return autoConfStatus;
|
return autoConfStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<AutoConfirmationStatus> getStatus(final String controllerId) {
|
|
||||||
return Optional.of(targetRepository.getWithDetailsByControllerId(controllerId, JpaTarget_.GRAPH_TARGET_AUTO_CONFIRMATION_STATUS))
|
|
||||||
.map(JpaTarget::getAutoConfirmationStatus);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
public List<Action> 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
|
@Override
|
||||||
@Transactional(isolation = Isolation.READ_COMMITTED)
|
@Transactional(isolation = Isolation.READ_COMMITTED)
|
||||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
@@ -174,6 +151,17 @@ public class JpaConfirmationManagement extends JpaActionManagement implements Co
|
|||||||
targetRepository.save(target);
|
targetRepository.save(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<AutoConfirmationStatus> getStatus(final String controllerId) {
|
||||||
|
return Optional.of(targetRepository.getWithDetailsByControllerId(controllerId, JpaTarget_.GRAPH_TARGET_AUTO_CONFIRMATION_STATUS))
|
||||||
|
.map(JpaTarget::getAutoConfirmationStatus);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Action> findActiveActionsWaitingConfirmation(final String controllerId) {
|
||||||
|
return Collections.unmodifiableList(findActiveActionsHavingStatus(controllerId, Status.WAIT_FOR_CONFIRMATION));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onActionStatusUpdate(final JpaActionStatus newActionStatus, final JpaAction action) {
|
protected void onActionStatusUpdate(final JpaActionStatus newActionStatus, final JpaAction action) {
|
||||||
if (newActionStatus.getStatus() == Status.RUNNING && action.isActive()) {
|
if (newActionStatus.getStatus() == Status.RUNNING && action.isActive()) {
|
||||||
|
|||||||
@@ -43,13 +43,6 @@ class ConfirmationManagementSecurityTest extends AbstractJpaIntegrationTest {
|
|||||||
assertPermissions(() -> confirmationManagement.getStatus("controllerId"), List.of(SpPermission.SpringEvalExpressions.CONTROLLER_ROLE), List.of(SpPermission.CREATE_TARGET));
|
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
|
@Test
|
||||||
@Description("Tests ConfirmationManagement#confirmAction() method")
|
@Description("Tests ConfirmationManagement#confirmAction() method")
|
||||||
void confirmActionPermissionsCheck() {
|
void confirmActionPermissionsCheck() {
|
||||||
|
|||||||
Reference in New Issue
Block a user