@Override
    @Modifying
    @Transactional(isolation = Isolation.READ_COMMITTED)
    public Action cancelAction(final long actionId) {
        LOG.debug("cancelAction({})", actionId);

        final JpaAction action = actionRepository.findById(actionId)
                .orElseThrow(() -> new EntityNotFoundException(Action.class, actionId));

        if (action.isCancelingOrCanceled()) {
            throw new CancelActionNotAllowedException("Actions in canceling or canceled state cannot be canceled");
        }

        if (action.isActive()) {
            LOG.debug("action ({}) was still active. Change to {}.", action, Status.CANCELING);
            action.setStatus(Status.CANCELING);

            // document that the status has been retrieved
            actionStatusRepository.save(new JpaActionStatus(action, Status.CANCELING, System.currentTimeMillis(),
                    "manual cancelation requested"));
            final Action saveAction = actionRepository.save(action);
            cancelAssignDistributionSetEvent((JpaTarget) action.getTarget(), action.getId());

            return saveAction;
        } else {
            throw new CancelActionNotAllowedException(
                    "Action [id: " + action.getId() + "] is not active and cannot be canceled");
        }
    }
@ Override @ Modifying @ Transactional ( isolation = Isolation . READ_COMMITTED ) public Action cancelAction ( final long actionId ) { LOG . debug ( "cancelAction({})" , actionId ) ; final JpaAction action = actionRepository . findById ( actionId ) . orElseThrow ( ( ) -> new EntityNotFoundException ( Action . class , actionId ) ) ; if ( action . isCancelingOrCanceled ( ) ) { throw new CancelActionNotAllowedException ( "Actions in canceling or canceled state cannot be canceled" ) ; } if ( action . isActive ( ) ) { LOG . debug ( "action ({}) was still active. Change to {}." , action , Status . CANCELING ) ; action . setStatus ( Status . CANCELING ) ; actionStatusRepository . save ( new JpaActionStatus ( action , Status . CANCELING , System . currentTimeMillis ( ) , "manual cancelation requested" ) ) ; final Action saveAction = actionRepository . save ( action ) ; cancelAssignDistributionSetEvent ( ( JpaTarget ) action . getTarget ( ) , action . getId ( ) ) ; return saveAction ; } else { throw new CancelActionNotAllowedException ( "Action [id: " + action . getId ( ) + "] is not active and cannot be canceled" ) ; } }
Cancels given {@link Action} for this {@link Target}. The method will
immediately add a {@link Status#CANCELED} status to the action. However,
it might be possible that the controller will continue to work on the
cancelation. The controller needs to acknowledge or reject the
cancelation using {@link DdiRootController#postCancelActionFeedback}.

@param actionId
to be canceled

@return canceled {@link Action}

@throws CancelActionNotAllowedException
in case the given action is not active or is already canceled
@throws EntityNotFoundException
if action with given actionId does not exist.