public static void successCancellation ( final JpaAction action , final ActionRepository actionRepository , final TargetRepository targetRepository ) { // set action inactive action . setActive ( false ) ; action . setStatus ( Status . CANCELED ) ; final JpaTarget target = ( JpaTarget ) action . getTarget ( ) ; final List < Action > nextActiveActions = actionRepository . findByTargetAndActiveOrderByIdAsc ( target , true ) . stream ( ) . filter ( a -> ! a . getId ( ) . equals ( action . getId ( ) ) ) . collect ( Collectors . toList ( ) ) ; if ( nextActiveActions . isEmpty ( ) ) { target . setAssignedDistributionSet ( target . getInstalledDistributionSet ( ) ) ; target . setUpdateStatus ( TargetUpdateStatus . IN_SYNC ) ; } else { target . setAssignedDistributionSet ( nextActiveActions . get ( 0 ) . getDistributionSet ( ) ) ; } targetRepository . save ( target ) ; }
This method is called when cancellation has been successful . It sets the action to canceled resets the meta data of the target and in case there is a new action this action is triggered .