Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused ConfirmationManagement.autoConfirmActiveActions #2197

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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<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.
* 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()}
Expand All @@ -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<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.
* 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
Expand All @@ -81,8 +48,7 @@ public interface ConfirmationManagement {
Action confirmAction(long actionId, Integer code, Collection<String> 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
Expand All @@ -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<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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,6 @@ public JpaConfirmationManagement(
this.entityFactory = entityFactory;
}

@Override
public List<Action> 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) {
Expand Down Expand Up @@ -108,24 +103,6 @@ public AutoConfirmationStatus activateAutoConfirmation(final String controllerId
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
@Transactional(isolation = Isolation.READ_COMMITTED)
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
Expand Down Expand Up @@ -174,6 +151,17 @@ public void deactivateAutoConfirmation(String controllerId) {
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
protected void onActionStatusUpdate(final JpaActionStatus newActionStatus, final JpaAction action) {
if (newActionStatus.getStatus() == Status.RUNNING && action.isActive()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Loading