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 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 byte[] toByteArray() { try (InputStream is = content().openStream()) { return ByteStreams.toByteArray(is); } catch (IOException e) { throw new SendNotificationException("Error while reading status icon.", e); } }
public byte[] toByteArray() { try (InputStream is = content().openStream()) { return ByteStreams.toByteArray(is); } catch (IOException e) { throw new SendNotificationException("Error while reading status icon.", e); } }
private Icon notificationIcon() { try { return Icon.create(icon.toURI().toURL(), "send-notification-" + icon.getName()); } catch (MalformedURLException e) { throw new SendNotificationException("Cannot build URL from file: " + icon, e); } }
public String asPath() { String folder = System.getProperty("java.io.tmpdir") + "/send-notifications-icons/"; String extension = extension(); File icon = new File(folder + id() + "." + extension); if (!icon.exists()) { new File(folder).mkdirs(); try { write(icon); } catch (IOException e) { throw new SendNotificationException("Can't write notification icon : " + icon.getPath(), e); } } return icon.getPath(); }
public String asPath() { String folder = System.getProperty("java.io.tmpdir") + "/send-notifications-icons/"; String extension = extension(); File icon = new File(folder + id() + "." + extension); if (!icon.exists()) { new File(folder).mkdirs(); try { write(icon); } catch (IOException e) { throw new SendNotificationException("Can't write notification icon : " + icon.getPath(), e); } } return icon.getPath(); }
@Override public void write(Icon icon) { for (Dimension dimension : Dimension.values()) { File resizedIcon = new File(destination + icon.id() + dimension.fileNameSuffix + "." + icon.extension()); if (!resizedIcon.exists()) { new File(destination).mkdirs(); try (InputStream input = icon.content().openStream(); FileOutputStream output = new FileOutputStream(resizedIcon)) { Thumbnailator.createThumbnail(input, output, dimension.width, dimension.height); } catch (IOException e) { throw new SendNotificationException("Can't write notification icon: " + resizedIcon.getPath(), e); } } } }
@Override public void write(Icon icon) { for (Dimension dimension : Dimension.values()) { File resizedIcon = new File(destination + icon.id() + dimension.fileNameSuffix + "." + icon.extension()); if (!resizedIcon.exists()) { new File(destination).mkdirs(); try (InputStream input = icon.content().openStream(); FileOutputStream output = new FileOutputStream(resizedIcon)) { Thumbnailator.createThumbnail(input, output, dimension.width, dimension.height); } catch (IOException e) { throw new SendNotificationException("Can't write notification icon: " + resizedIcon.getPath(), e); } } } }
String message = "Command <[" + logCommand(command) + "]> returns code: " + returnCode + ".\n" + asString(execution.getInputStream()); LOGGER.debug(message); throw new SendNotificationException(message);
String message = "Command <[" + logCommand(command) + "]> returns code: " + returnCode + ".\n" + asString(execution.getInputStream()); LOGGER.debug(message); throw new SendNotificationException(message);