/** * Build a {@link fr.jcgay.notification.Notifier}. * * @return notifier based on provided configuration. */ public Notifier initNotifier() { return chooseNotifier().init(); }
@Override protected void fireNotification(MavenExecutionResult event) { Status status = getBuildStatus(event); notifier.send( Notification.builder() .title(buildTitle(event)) .message(buildNotificationMessage(event)) .icon(Icon.create(status.url(), status.name())) .level(toLevel(status)) .subtitle(status.message()) .build() ); }
private String attachments(Notification notification) { return "[{" + "\"fallback\":\"" + notification.message() + "\"," + "\"color\":\"" + colorize(notification) + "\"," + "\"author_name\":\"" + application.name() + "\"," + "\"title\":\"" + notification.title() + "\"," + "\"text\":\"" + notification.message() + "\n" + notification.subtitle() + "\"," + "}]"; }
public BufferedImage toImage() { try { return ImageIO.read(content()); } catch (IOException e) { throw new SendNotificationException("Error while reading status icon.", e); } }
@Override public String getMessage() { return String.format("%s%nCheck your configuration at: %s", super.getMessage(), getURL()); } }
public static Builder builder() { return new AutoValue_Application.Builder() .timeout(-1); }
private static String colorize(Notification notification) { switch (notification.level()) { case INFO: return "good"; case WARNING: return "warning"; case ERROR: return "danger"; default: return "warning"; } }
@Override public boolean isPersistent() { if (notifyWithSecondaryNotifiers) { boolean result = primary.isPersistent(); for (DiscoverableNotifier notifier : secondary) { result |= notifier.isPersistent(); } return result; } return primary.isPersistent(); }
public static Icon create(URL content, String id) { return new AutoValue_Icon(id, content); }
SendNotification(ConfigurationReader configuration, OperatingSystem currentOs) { this(configuration, new NotifierProvider(currentOs)); }
private String attachments(Notification notification) { return "[{" + "\"fallback\":\"" + notification.message() + "\"," + "\"color\":\"" + colorize(notification) + "\"," + "\"author_name\":\"" + application.name() + "\"," + "\"title\":\"" + notification.title() + "\"," + "\"text\":\"" + notification.message() + "\n" + notification.subtitle() + "\"," + "}]"; }
/** * Build a {@link fr.jcgay.notification.Notifier}. * * @return notifier based on provided configuration. */ public Notifier initNotifier() { return chooseNotifier().init(); }
@Override public String getMessage() { return String.format("%s%nCheck your configuration at: %s", super.getMessage(), getURL()); } }
private static String colorize(Notification notification) { switch (notification.level()) { case INFO: return "good"; case WARNING: return "warning"; case ERROR: return "danger"; default: return "warning"; } }
@Override public boolean isPersistent() { if (notifyWithSecondaryNotifiers) { boolean result = primary.isPersistent(); for (DiscoverableNotifier notifier : secondary) { result |= notifier.isPersistent(); } return result; } return primary.isPersistent(); }