/** * Returns whether or not an OriginalFile exists on disk. * * @param file The original file metadata. * @return See above. */ public boolean exists(OriginalFile file) { String path = getFilesPath(file.getId()); return new File(path).exists(); } }
public LegacyRepositoryI(Ice.ObjectAdapter oa, Registry reg, Executor ex, Principal p, FileMaker fileMaker, ReadOnlyStatus readOnly, PublicRepositoryI servant) { super(oa, reg, ex, p, fileMaker, readOnly, servant); this.fs = new OriginalFilesService(fileMaker.getDir(), readOnly.isReadOnlyRepo()); }
/** * Returns FileBuffer based on OriginalFile path * * @param file * @return FileBuffer */ public FileBuffer getFileBuffer(OriginalFile file, String mode) { String path = getFilesPath(file.getId()); createSubpath(path); return new FileBuffer(path, mode); }
@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); } }
this.buffer = ioService.getFileBuffer(file, mode); } else { this.buffer = buffer;
/** * Removes files from data repository based on a parameterized List of * Long file ids * * @param fileIds - Long file keys to be deleted * @throws ResourceError If deletion fails. */ public void removeFiles(List<Long> fileIds){ File file; boolean success = false; for (Iterator<Long> iter = fileIds.iterator(); iter.hasNext();) { Long id = iter.next(); String filePath = getFilesPath(id); file = new File(filePath); if (file.exists()) { success = file.delete(); if (!success) { throw new ResourceError("File " + file.getName() + " deletion failed"); } else { if (log.isInfoEnabled()) { log.info("INFO: File " + file.getName() + " deleted."); } } } } }
/** * Attempts to parse the given {@link OriginalFile}. If any of the * necessary components is null, then it will return an empty, but not null * {@link Iterable}. Also looks for the catch all parser under "*" * * @param file * Can be null. * @return will not be null. */ protected Iterable<Reader> parse(final OriginalFile file, final OriginalFilesService files, final Map<String, FileParser> parsers) { if (files != null && parsers != null) { if (file != null && file.getMimetype() != null) { String path = files.getFilesPath(file.getId()); String format = file.getMimetype(); FileParser parser = parsers.get(format); if (parser != null) { return parser.parse(new File(path)); } else { parser = parsers.get("*"); if (parser != null) { return parser.parse(new File(path)); } } } } return FileParser.EMPTY; } }
/** * TODO CACHING */ public String getFilePath(final OriginalFile file, Current __current) throws ServerError { String repo = getFileRepo(file); if (repo != null) { throw new omero.ValidationException(null, null, "Does not belong to this repository"); } return fs.getFilesPath(file.getId().getValue()); }
targetFile = new File(filesService.getFilesPath(source.getId()));
/** * Detects if the given annotation contains an OMERO.table and if so, passes * it off for further processing. */ protected void handleAnnotation(Annotation annotation, RowProcessor proc) { annotation = getProxiedObject(annotation); if (annotation instanceof FileAnnotation) { final OriginalFile file = ((FileAnnotation) annotation).getFile(); final String mimetype = file.getMimetype(); final String path = ofs.getFilesPath(file.getId()); // ///////////////////////////////////////////////// if (OMERO_TABLE.equals(mimetype)) { debug("Handling annotation %s", annotation); handleHdf5(path, proc); } // ////////////////////////////////////////////////// } }