List of usage examples for org.apache.commons.io FilenameUtils EXTENSION_SEPARATOR_STR
String EXTENSION_SEPARATOR_STR
To view the source code for org.apache.commons.io FilenameUtils EXTENSION_SEPARATOR_STR.
Click Source Link
From source file:es.urjc.mctwp.image.impl.collection.fs.ImageContentFileFilter.java
@Override public boolean accept(File pathname) { String ext = StringUtils.substringAfterLast(pathname.getName(), FilenameUtils.EXTENSION_SEPARATOR_STR); return (ext == null) ? false : (!ext.equals(ThumbNail.TBN_EXT)); }
From source file:com.hs.mail.container.config.Config.java
public static File getDataFile(Date date, long physmessageid) throws IOException { File directory = new File(dataDirectory, getSubDirectory(date, physmessageid)); FileUtils.forceMkdir(directory);/*from w w w . ja v a2s . co m*/ File zipped = new File(directory, Long.toString(physmessageid) + FilenameUtils.EXTENSION_SEPARATOR_STR + ZIPFILE_EXTENSION); return (zipped.exists()) ? zipped : new File(directory, Long.toString(physmessageid)); }
From source file:es.urjc.mctwp.bbeans.research.image.AbstractViewImages.java
/** * It prepares a valid thumbnail for JSF from a valid ImageDate. * It writes the thumbnail image into a file contained in the * user session dir.//from ww w.j a v a2s . c om * * @param image * @return * @throws IOException * @throws SQLException * @throws FileNotFoundException */ protected ThumbSelectItem getThumbnailContent(ImageData image) throws IOException, SQLException, FileNotFoundException { String base = getSession().getAbsoluteThumbDir(); String name = image.getImageId() + FilenameUtils.EXTENSION_SEPARATOR_STR + ThumbNail.TBN_EXT; int length = image.getThumbnailSize(); //Create file for thumbnail and get output stream to write it File file = new File(FilenameUtils.concat(base, name)); FileOutputStream fos = new FileOutputStream(file); //write thumbnail content into file byte[] thContent = new byte[length]; image.getThumbnailStream().read(thContent, 0, length); fos.write(thContent); fos.close(); //Create thumbnail and view layer thumbnail. It is neccesary to //reference the thumbnail from a relative path in order to work //into view base = getSession().getRelativeThumbDir(); file = new File(FilenameUtils.concat(base, name)); ThumbNail tn = new ThumbNail(); tn.setContent(file); tn.setId(image.getImageId()); ThumbSelectItem tsi = new ThumbSelectItem(); tsi.setThumbId(tn.getId()); tsi.setPath(tn.getContent().getPath()); tsi.setImageId(image.getCode()); return tsi; }
From source file:es.urjc.mctwp.image.management.ImageCollectionManager.java
/** * It parses and stores temporarily, a list of files. * /* w w w .j a v a2s . c o m*/ * @param colName * @param files * @throws ImageCollectionException * @throws ImageException * @throws IOException */ public void storeTemporalImages(String colName, List<File> files) throws ImageCollectionException, ImageException, IOException { for (File file : files) { Image image = impm.createImage(file); if (image != null) { if (image instanceof SingleImage) { SingleImage simg = (SingleImage) image; String ext = ImageUtils.getFileExtension(simg.getContent()); File tmpFile = new File(FilenameUtils.concat(sysTempDir.getAbsolutePath(), image.getId() + FilenameUtils.EXTENSION_SEPARATOR_STR + ext)); if (tmpFile.exists()) tmpFile.delete(); FileUtils.copyFile(simg.getContent(), tmpFile); imcc.storeContent(colName, tmpFile, true); tmpFile.delete(); } else { //Create temp directory where put all file content of Image File tmpDir = new File(FilenameUtils.concat(sysTempDir.getAbsolutePath(), image.getId() + FilenameUtils.EXTENSION_SEPARATOR_STR + image.getType())); if (tmpDir.exists()) FileUtils.deleteDirectory(tmpDir); tmpDir.mkdir(); if (image instanceof SeriesImage) { List<Image> images = ((SeriesImage) image).getImages(); if (images != null && !images.isEmpty()) { for (Image img : images) copyToDirectory(tmpDir, img); } } else if (image instanceof ComplexImage) { List<File> auxFiles = ((ComplexImage) image).getContent(); if (auxFiles != null && !auxFiles.isEmpty()) { for (File auxFile : auxFiles) copyToDirectory(tmpDir, auxFile); } } //Store content and delete temporal directory imcc.storeContent(colName, tmpDir, true); FileUtils.deleteDirectory(tmpDir); } } } }
From source file:com.alibaba.otter.node.etl.common.pipe.impl.http.AttachmentHttpPipe.java
private File unpackFile(HttpPipeKey key) { Pipeline pipeline = configClientService.findPipeline(key.getIdentity().getPipelineId()); DataRetriever dataRetriever = dataRetrieverFactory.createRetriever(pipeline.getParameters().getRetriever(), key.getUrl(), downloadDir);/*ww w .j a v a 2s .c om*/ File archiveFile = null; try { dataRetriever.connect(); dataRetriever.doRetrieve(); archiveFile = dataRetriever.getDataAsFile(); } catch (Exception e) { dataRetriever.abort(); throw new PipeException("download_error", e); } finally { dataRetriever.disconnect(); } // ?? if (StringUtils.isNotEmpty(key.getKey()) && StringUtils.isNotEmpty(key.getCrc())) { decodeFile(archiveFile, key.getKey(), key.getCrc()); } // .gzip?? String dir = StringUtils.removeEnd(archiveFile.getPath(), FilenameUtils.EXTENSION_SEPARATOR_STR + FilenameUtils.getExtension(archiveFile.getPath())); File unpackDir = new File(dir); // getArchiveBean().unpack(archiveFile, unpackDir); return unpackDir; }
From source file:es.urjc.mctwp.bbeans.research.SessionInvBean.java
/** * Configure temporary directories for user's images work *//*from w ww. java 2s . co m*/ private void configPaths() { File tempDir = null; tempDir = SessionUtils.getOrCreateFile(getServletContext().getRealPath("/"), thumbDirName); thumbDir = SessionUtils.getOrCreateFile(tempDir.getAbsolutePath(), getLogin()); //Obtain web context relative path for thumbnails String aux = thumbDir.getAbsolutePath(); aux = aux.substring(getServletContext().getRealPath(FilenameUtils.EXTENSION_SEPARATOR_STR).length() - 1); ctxThumbDir = new File(aux); }
From source file:eu.cloud4soa.cli.profiles.grammar.visitor.core.CoreDepthFirstVoidVisitor.java
@Override public void visit(File n) { String fileName = trimQuotes(n.f2.tokenImage); String extension = FilenameUtils.getExtension(fileName); String baseName = FilenameUtils.getBaseName(fileName); applicationInstance.setArchiveFileName(baseName); applicationInstance.setArchiveExtensionName(FilenameUtils.EXTENSION_SEPARATOR_STR + extension); if (n.f3.present()) n.f3.accept(this); }
From source file:es.urjc.mctwp.image.management.ImagePluginManager.java
private List<ImagePlugin> getPlugins(File file) { List<ImagePlugin> result = null; if (file != null) { String ext = StringUtils.substringAfterLast(file.getName(), FilenameUtils.EXTENSION_SEPARATOR_STR); result = plugins.get(ImageUtils.normalizeExtension(ext)); }/* ww w. j a v a2 s.co m*/ return result; }
From source file:au.com.permeance.liferay.portlet.documentlibrary.service.impl.DLFolderExportZipHelper.java
/** * Returns a ZIP entry name for the file entry. * /*from w ww. ja va 2 s .co m*/ * @param fileEntry file entry * @param folderPath file path * @param zipWriter ZIP writer * * @return ZIP entry name * * @throws SystemException * @throws PortalException */ public static String buildZipEntryName(FileEntry fileEntry, String folderPath, ZipWriter zipWriter) throws SystemException, PortalException { // Use file entry title as file name String fileEntryBaseName = fileEntry.getTitle(); // normalize base name by stripping extension and replacing non-alphanum chars with underscore fileEntryBaseName = FilenameUtils.getBaseName(fileEntryBaseName); fileEntryBaseName = fileEntryBaseName.replaceAll("\\W+", "_"); // build zip entry name String zipEntryName = folderPath + fileEntryBaseName + FilenameUtils.EXTENSION_SEPARATOR_STR + fileEntry.getExtension(); if (zipWriter.hasAllocatedPath(zipEntryName)) { String oldZipEntryName = zipEntryName; int counter = 1; while (true) { zipEntryName = folderPath + fileEntryBaseName + StringPool.OPEN_BRACKET + counter + StringPool.CLOSE_BRACKET + FilenameUtils.EXTENSION_SEPARATOR_STR + fileEntry.getExtension(); if (!zipWriter.hasAllocatedPath(zipEntryName)) { break; } counter++; } if (s_log.isDebugEnabled()) { s_log.debug(oldZipEntryName + " already exists in ZIP file, renaming to " + zipEntryName); } } return zipEntryName; }
From source file:de.ingrid.interfaces.csw.server.cswt.impl.GenericServerCSWT.java
/** * Get a Document from a class path location. The actual name of the file is * retrieved from the config.properties file. * * With variant a specific variant (like a localization) can be retrieved. * The file name is extended by the variant in the form * [name]_[variant].[extension].// w ww . ja v a2 s . co m * * If the variant could not be retrieved, the base file is returned as a * fall back. * * The content is cached. The cache can be controlled by the * config.properties entry 'cache.enable'. * * @param key * One of the keys config.properties, defining the actual * filename to be retrieved. * @param variant * The variant of the file. * @return The Document instance */ protected Document getDocument(String key, String variant) { // fetch the document from the file system if it is not cached String filename = ApplicationProperties.getMandatory(key); String filenameVariant = filename; if (variant != null && variant.length() > 0) { if (filename.contains(FilenameUtils.EXTENSION_SEPARATOR_STR)) { filenameVariant = FilenameUtils.getBaseName(filename) + "_" + variant + FilenameUtils.EXTENSION_SEPARATOR_STR + FilenameUtils.getExtension(filename); } else { filenameVariant = FilenameUtils.getBaseName(filename) + "_" + variant; } } Document doc = null; Scanner scanner = null; try { URL resource = this.getClass().getClassLoader().getResource(filenameVariant); if (resource == null) { log.warn("Document '" + filenameVariant + "' could not be found in class path."); resource = this.getClass().getClassLoader().getResource(filename); } String path = resource.getPath().replaceAll("%20", " "); File file = new File(path); scanner = new Scanner(file); scanner.useDelimiter("\\A"); String content = scanner.next(); scanner.close(); doc = StringUtils.stringToDocument(content); } catch (Exception e) { log.error("Error reading document configured in configuration key '" + key + "': " + filename + ", " + variant, e); throw new RuntimeException("Error reading document configured in configuration key '" + key + "': " + filename + ", " + variant, e); } finally { if (scanner != null) { scanner.close(); } } return doc; }