/** * Removes files from data repository based on a parameterized List of Long * pixels ids * * @param pixelIds Long file keys to be deleted * @throws ResourceError If deletion fails. */ public void removePixels(List<Long> pixelIds) { File file; String fileName; boolean success = false; for (Iterator<Long> iter = pixelIds.iterator(); iter.hasNext();) { Long id = iter.next(); String pixelPath = getPixelsPath(id); file = new File(pixelPath); fileName = file.getName(); if (file.exists()) { success = file.delete(); if (!success) { throw new ResourceError( "Pixels " + fileName + " deletion failed"); } else { if (log.isInfoEnabled()) { log.info("INFO: Pixels " + fileName + " deleted."); } } } } }
/** * Creates a PixelBuffer for a given pixels set. * * @param pixels Pixels set to create a pixel buffer for. * @return Allocated pixel buffer ready to be used. * @throws IOException If there is an I/O error creating the pixel buffer * backing file. */ public PixelBuffer createPixelBuffer(Pixels pixels) throws IOException { RomioPixelBuffer pixbuf = new RomioPixelBuffer(getPixelsPath(pixels .getId()), pixels, true); initPixelBuffer(pixbuf); return pixbuf; }
String path = getPixelsPath(pixbuf.getId()); createSubpath(path); Integer size = RomioPixelBuffer.safeLongToInteger(pixbuf.getPlaneSize());
final Long ownerId = (Long) resultRow[1]; final Long groupId = (Long) resultRow[2]; final String pixelsPath = pixelsService.getPixelsPath(pixelsId); usage.bumpTotals().add(ownerId, groupId, className, getFileSize(pixelsPath)); usage.bumpTotals().add(ownerId, groupId, className, getFileSize(pixelsPath + PixelsService.PYRAMID_SUFFIX));
final Long ownerId = (Long) resultRow[1]; final Long groupId = (Long) resultRow[2]; final String pixelsPath = pixelsService.getPixelsPath(pixelsId); usage.bumpTotals().add(ownerId, groupId, className, getFileSize(pixelsPath)); usage.bumpTotals().add(ownerId, groupId, className, getFileSize(pixelsPath + PixelsService.PYRAMID_SUFFIX));
/** * Use {@link PixelsService} to find pre-FS binary files under * "/OMERO/Files", "/OMERO/Pixels", and "/OMERO/Thumbnails", * and store their size in the response. */ private void findBinary() { IQuery query = helper.getServiceFactory().getQueryService(); Pixels pixels = query.get(Image.class, imageId).getPrimaryPixels(); List<Thumbnail> thumbs = query.findAllByQuery( "select tb from Thumbnail tb where " + "tb.pixels.id = :id", new Parameters().addId(pixels.getId())); String path = pixelsService.getPixelsPath(pixels.getId()); files = new PixelFiles(path); files.update(rsp); for (Thumbnail tb: thumbs) { path = pixelsService.getThumbnailPath(tb.getId()); File thumbnailFile = new File(path); thumbnailFiles.add(thumbnailFile); rsp.thumbnailSize += thumbnailFile.length(); } }
final String pixelsFilePath = getPixelsPath(pixels.getId()); final File pixelsFile = new File(pixelsFilePath); final String pixelsPyramidFilePath = pixelsFilePath + PYRAMID_SUFFIX;
final String pixelsFilePath = getPixelsPath(pixels.getId()); final File pixelsFile = new File(pixelsFilePath); final String pixelsPyramidFilePath = pixelsFilePath + PYRAMID_SUFFIX;