/** * Utility that deletes any temporary uploads that were performed during editing, but were not * saved. * * @throws IOException if there was a problem reading the uploads directory or deleting any * temporary uploads */ private void deleteTempUploads() throws IOException { if (selected != null) { for (Variant variant : selected.getVariants()) { Collection<File> tmpFiles = FileUtils.listFiles( UploadsServlet.getUploadsDirectory(), FileFilterUtils.prefixFileFilter("tmp-" + variant.getUuid()), null); for (File tmpFile : tmpFiles) { FileUtils.forceDelete(tmpFile); } } } }
private String getWallPaperURL(String spaceId) { String id = getShortSpaceId(spaceId); String basePath = getSpaceBasePath(id); File dir = new File(basePath); if (dir.exists() && dir.isDirectory()) { Collection<File> wallpapers = FileUtils.listFiles( dir, FileFilterUtils.prefixFileFilter("wallPaper", IOCase.INSENSITIVE), null); for (File wallpaper : wallpapers) { if (wallpaper.isFile() && FileUtil.isImage(wallpaper.getName())) { return getURLOfElement(id, wallpaper.getName()); } } } return null; }
@Override protected Object[] doInBackground() throws Exception { IOFileFilter pdfFilter = FileFilterUtils.asFileFilter(this); IOFileFilter suffixFilter = FileFilterUtils.notFileFilter(new SuffixFileFilter(".fo")); IOFileFilter sheetFilter = FileFilterUtils.prefixFileFilter(Constants.CHARACTER_TEMPLATE_PREFIX); IOFileFilter fileFilter = FileFilterUtils.and(pdfFilter, suffixFilter, sheetFilter); IOFileFilter dirFilter = FileFilterUtils.makeSVNAware(TrueFileFilter.INSTANCE); File dir = new File(ConfigurationSettings.getOutputSheetsDir()); Collection<File> files = FileUtils.listFiles(dir, fileFilter, dirFilter); URI osPath = new File(ConfigurationSettings.getOutputSheetsDir()).toURI(); Object[] uriList = new Object[files.size()]; int i = 0; for (File file : files) { uriList[i] = osPath.relativize(file.toURI()); i++; } return uriList; }