/** * Return byte array of Thumbnail * * @param thumbnail * @return a byte array * @throws IOException */ public byte[] getThumbnail(Thumbnail thumbnail) throws IOException { byte[] buf = new byte[(int) getThumbnailLength(thumbnail)]; return getThumbnail(thumbnail, buf); }
/** * Returns length of Thumbnail on disk * * @param thumbnail */ public long getThumbnailLength(Thumbnail thumbnail) { File f = new File(getThumbnailPath(thumbnail.getId())); return f.length(); }
/** * Return FileOutputStream of Thumbnail * * @param thumbnail * @return a {@link FileOutputStream} * @throws IOException */ public FileOutputStream getThumbnailOutputStream(Thumbnail thumbnail) throws IOException { String path = getThumbnailPath(thumbnail.getId()); createSubpath(path); return new FileOutputStream(path); }
byte[] thumbnail = ioService.getThumbnail(thumbnailMetadata); ioService.removeThumbnails( Arrays.asList(new Long[] { thumbnailMetadata.getId() }));
return ioService.getThumbnail(thumbMetaData); } catch (IOException e) { if (log.isDebugEnabled()) { return ioService.getThumbnail(thumbnailMetadata); } catch (IOException e) { log.error("Could not obtain thumbnail", e);
@RolesAllowed("user") public void removeUnusedFiles() { RepositoryTask task = new RepositoryTask(sql); // get ids for any objects marked as deleted List<Long> files = task.getFileIds(); List<Long> pixels = task.getPixelIds(); List<Long> thumbs = task.getThumbnailIds(); // cleanup any files if (files != null && files.size() > 0) { log.info("Removing files: " + files); fileService.removeFiles(files); } // cleanup any pixels if (pixels != null && pixels.size() > 0) { log.info("Removing pixels: " + pixels); pixelsService.removePixels(pixels); } // cleanup any thumbnails if (thumbs != null && thumbs.size() > 0) { log.info("Removing thumbnails: " + thumbs); thumbnailService.removeThumbnails(thumbs); } }
thumbnailService.getThumbnailExists(metadata); final boolean isExtendedGraphCritical = new ExtendedGraphCriticalCheck(pixelsId).isCritical; Long metadataOwnerId = metadata.getDetails().getOwner().getId();
/** * Compresses a buffered image thumbnail to disk. * * @param metadata the thumbnail metadata. * @param image the thumbnail's buffered image. * @param inProgress if set to true, writes inProgressImageResource to disk * @throws ResourceError if there is a problem writing to disk. */ private void compressThumbnailToDisk(Thumbnail metadata, BufferedImage image, boolean inProgress) throws IOException, ResourceError { if (diskSpaceChecking) { iRepositoryInfo.sanityCheckRepository(); } try (FileOutputStream stream = ioService.getThumbnailOutputStream(metadata)) { if (inProgress) { compressInProgressImageToStream(metadata.getSizeX(), metadata.getSizeY(), stream, inProgressImageResource); } else { compressionService.compressToStream(image, stream); } } }
/** * Returns whether or not a thumbnail exists on disk. * * @param thumbnail The thumbnail metadata. * @return See above. */ public boolean getThumbnailExists(Thumbnail thumbnail) throws IOException { String path = getThumbnailPath(thumbnail.getId()); return new File(path).exists(); }
/** * Creates thumbnail on disk using byte array * * @param thumbnail * @param buf * @throws IOException */ public void createThumbnail(Thumbnail thumbnail, byte[] buf) throws IOException { String path = getThumbnailPath(thumbnail.getId()); createSubpath(path); FileOutputStream stream = new FileOutputStream(path); stream.write(buf); stream.close(); }
String thumbnailPath = getThumbnailPath(id); file = new File(thumbnailPath); if (file.exists())
/** * Return byte array of Thumbnail, providing byte array * * @param thumbnail * @param buf * @return a byte array * @throws IOException */ public byte[] getThumbnail(Thumbnail thumbnail, byte[] buf) throws IOException { String path = getThumbnailPath(thumbnail.getId()); FileInputStream stream = new FileInputStream(path); try { stream.read(buf, 0, buf.length); } finally { Utils.closeQuietly(stream); } return buf; }
final Long ownerId = (Long) resultRow[1]; final Long groupId = (Long) resultRow[2]; final String thumbnailPath = thumbnailService.getThumbnailPath(thumbnailId); usage.bumpTotals().add(ownerId, groupId, className, getFileSize(thumbnailPath));
final Long ownerId = (Long) resultRow[1]; final Long groupId = (Long) resultRow[2]; final String thumbnailPath = thumbnailService.getThumbnailPath(thumbnailId); usage.bumpTotals().add(ownerId, groupId, className, getFileSize(thumbnailPath));