protected static void createCropThumbnailFileOnServer( String pathOriginalFile, String pathCropdir, String pathCropFile, ThumbnailDetail thumbnail, int thumbnailWidth, int thumbnailHeight) { try { // Creates folder if not exists File dir = new File(pathCropdir); if (!dir.exists()) { FileFolderManager.createFolder(pathCropdir); } // create empty file File cropFile = new File(pathCropFile); if (!cropFile.exists()) { cropFile.createNewFile(); } File originalFile = new File(pathOriginalFile); BufferedImage bufferOriginal = ImageIO.read(originalFile); // crop image BufferedImage cropPicture = bufferOriginal.getSubimage( thumbnail.getXStart(), thumbnail.getYStart(), thumbnail.getXLength(), thumbnail.getYLength()); BufferedImage cropPictureFinal = new BufferedImage(thumbnailWidth, thumbnailHeight, BufferedImage.TYPE_INT_RGB); // Redimensionnement de l'image Graphics2D g2 = cropPictureFinal.createGraphics(); g2.setRenderingHint( RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); g2.drawImage(cropPicture, 0, 0, thumbnailWidth, thumbnailHeight, null); g2.dispose(); // save crop image String extension = FilenameUtils.getExtension(originalFile.getName()); ImageIO.write(cropPictureFinal, extension, cropFile); } catch (Exception e) { SilverTrace.warn( "thumbnail", "ThumbnailController.createThumbnailFileOnServer()", "thumbnail_MSG_CREATE_CROP_FILE_KO", "originalFileName=" + thumbnail.getOriginalFileName() + " cropFileName = " + thumbnail.getCropFileName(), e); } }
private static void deleteThumbnailFileOnServer(String componentId, String fileName) { String path = getImageDirectory(componentId) + fileName; try { SilverpeasFile image = SilverpeasFileProvider.getFile(path); image.delete(); } catch (Exception e) { SilverTrace.warn( "thumbnail", "ThumbnailController.deleteThumbnailFileOnServer(String componentId, String fileName)", "thumbnail_MSG_NOT_DELETE_FILE", "filePath=" + path, e); } }
@Override public void send(final NotifMediaType mediaType) { if (notification != null) { try { final NotificationSender sender = new NotificationSender(notification.getComponentId()); if (mediaType != null) { sender.notifyUser(mediaType.getId(), notification); } else { sender.notifyUser(notification); } } catch (final NotificationManagerException e) { SilverTrace.warn( "notification", "IUserNotification.send()", "notification.EX_IMPOSSIBLE_DALERTER_LES_UTILISATEURS", "componentId=" + notification.getComponentId(), e); } } }