public static void alertUserOnFlowFinished(final ExecutableFlow flow, final AlerterHolder
      alerterHolder, final String[] extraReasons) {
    final ExecutionOptions options = flow.getExecutionOptions();
    final Alerter mailAlerter = alerterHolder.get("email");
    if (flow.getStatus() != Status.SUCCEEDED) {
      if (options.getFailureEmails() != null && !options.getFailureEmails().isEmpty()) {
        try {
          mailAlerter.alertOnError(flow, extraReasons);
        } catch (final Exception e) {
          logger.error("Failed to alert on error for execution " + flow.getExecutionId(), e);
        }
      }
      if (options.getFlowParameters().containsKey("alert.type")) {
        final String alertType = options.getFlowParameters().get("alert.type");
        final Alerter alerter = alerterHolder.get(alertType);
        if (alerter != null) {
          try {
            alerter.alertOnError(flow, extraReasons);
          } catch (final Exception e) {
            logger.error("Failed to alert on error by " + alertType + " for execution " + flow
                .getExecutionId(), e);
          }
        } else {
          logger.error("Alerter type " + alertType + " doesn't exist. Failed to alert.");
        }
      }
    } else {
      if (options.getSuccessEmails() != null && !options.getSuccessEmails().isEmpty()) {
        try {
          mailAlerter.alertOnSuccess(flow);
        } catch (final Exception e) {
          logger.error("Failed to alert on success for execution " + flow.getExecutionId(), e);
        }
      }
      if (options.getFlowParameters().containsKey("alert.type")) {
        final String alertType = options.getFlowParameters().get("alert.type");
        final Alerter alerter = alerterHolder.get(alertType);
        if (alerter != null) {
          try {
            alerter.alertOnSuccess(flow);
          } catch (final Exception e) {
            logger.error("Failed to alert on success by " + alertType + " for execution " + flow
                .getExecutionId(), e);
          }
        } else {
          logger.error("Alerter type " + alertType + " doesn't exist. Failed to alert.");
        }
      }
    }
  }
public static void alertUserOnFlowFinished ( final ExecutableFlow flow , final AlerterHolder alerterHolder , final String [ ] extraReasons ) { final ExecutionOptions options = flow . getExecutionOptions ( ) ; final Alerter mailAlerter = alerterHolder . get ( "email" ) ; if ( flow . getStatus ( ) != Status . SUCCEEDED ) { if ( options . getFailureEmails ( ) != null && ! options . getFailureEmails ( ) . isEmpty ( ) ) { try { mailAlerter . alertOnError ( flow , extraReasons ) ; } catch ( final Exception e ) { logger . error ( "Failed to alert on error for execution " + flow . getExecutionId ( ) , e ) ; } } if ( options . getFlowParameters ( ) . containsKey ( "alert.type" ) ) { final String alertType = options . getFlowParameters ( ) . get ( "alert.type" ) ; final Alerter alerter = alerterHolder . get ( alertType ) ; if ( alerter != null ) { try { alerter . alertOnError ( flow , extraReasons ) ; } catch ( final Exception e ) { logger . error ( "Failed to alert on error by " + alertType + " for execution " + flow . getExecutionId ( ) , e ) ; } } else { logger . error ( "Alerter type " + alertType + " doesn't exist. Failed to alert." ) ; } } } else { if ( options . getSuccessEmails ( ) != null && ! options . getSuccessEmails ( ) . isEmpty ( ) ) { try { mailAlerter . alertOnSuccess ( flow ) ; } catch ( final Exception e ) { logger . error ( "Failed to alert on success for execution " + flow . getExecutionId ( ) , e ) ; } } if ( options . getFlowParameters ( ) . containsKey ( "alert.type" ) ) { final String alertType = options . getFlowParameters ( ) . get ( "alert.type" ) ; final Alerter alerter = alerterHolder . get ( alertType ) ; if ( alerter != null ) { try { alerter . alertOnSuccess ( flow ) ; } catch ( final Exception e ) { logger . error ( "Failed to alert on success by " + alertType + " for execution " + flow . getExecutionId ( ) , e ) ; } } else { logger . error ( "Alerter type " + alertType + " doesn't exist. Failed to alert." ) ; } } } }
When a flow is finished, alert the user as is configured in the execution options.

@param flow the execution
@param alerterHolder the alerter holder
@param extraReasons the extra reasons for alerting