class StackImageUpdateActions {

    @Bean(name = "CHECK_PACKAGE_VERSIONS_STATE")
    public AbstractStackImageUpdateAction<?> checkPackageVersions() {
        return new AbstractStackImageUpdateAction<>(ImageUpdateEvent.class) {
            @Override
            protected void doExecute(StackContext context, ImageUpdateEvent payload, Map<Object, Object> variables) {
                CheckResult checkResult = getStackImageUpdateService().checkPackageVersions(context.getStack(), payload.getImage());
                if (checkResult.getStatus() == EventStatus.FAILED) {
                    throw new OperationException(checkResult.getMessage());
                }
                sendEvent(context, new ImageUpdateEvent(StackImageUpdateEvent.CHECK_PACKAGE_VERSIONS_FINISHED_EVENT.event(),
                        context.getStack().getId(), payload.getImage()));
            }
        };
    }

}