List of usage examples for org.apache.commons.io FilenameUtils normalize
public static String normalize(String filename, boolean unixSeparator)
From source file:org.walkmod.writers.AbstractFileWriter.java
public void write(Object n, VisitorContext vc) throws Exception { File out = null;/* w ww .jav a 2s .com*/ boolean createdEmptyFile = false; if (vc != null) { out = (File) vc.get(AbstractWalker.ORIGINAL_FILE_KEY); } if (out == null) { log.debug("Creating the target source file. This is not the original source file."); out = createOutputDirectory(n); createdEmptyFile = true; } else { log.debug("The system will overwrite the original source file."); } boolean write = true; if (out != null) { log.debug("Analyzing exclude and include rules"); String aux = FilenameUtils.normalize(out.getCanonicalPath(), true); if (excludes != null) { for (int i = 0; i < excludes.length && write; i++) { if (!excludes[i].startsWith(normalizedOutputDirectory)) { excludes[i] = normalizedOutputDirectory + "/" + excludes[i]; if (excludes[i].endsWith("\\*\\*")) { excludes[i] = excludes[i].substring(0, excludes[i].length() - 2); } } write = !(excludes[i].startsWith(aux) || FilenameUtils.wildcardMatch(aux, excludes[i])); } } if (includes != null && write) { write = false; for (int i = 0; i < includes.length && !write; i++) { if (!includes[i].startsWith(normalizedOutputDirectory)) { includes[i] = normalizedOutputDirectory + "/" + includes[i]; if (includes[i].endsWith("\\*\\*")) { includes[i] = includes[i].substring(0, includes[i].length() - 2); } } write = includes[i].startsWith(aux) || FilenameUtils.wildcardMatch(aux, includes[i]); } } if (write) { Writer writer = null; try { vc.put("outFile", out); String content = getContent(n, vc); vc.remove("outFile"); if (content != null && !"".equals(content)) { char endLineChar = getEndLineChar(out); writer = new BufferedWriter( new OutputStreamWriter(new FileOutputStream(out), getEncoding())); if (vc.get("append") == null) { write(content, writer, endLineChar); } else { if (Boolean.TRUE.equals(vc.get("append"))) { append(content, writer, endLineChar); } else { write(content, writer, endLineChar); } } Summary.getInstance().addFile(out); log.debug(out.getPath() + " written "); } } finally { if (writer != null) { writer.close(); } } } else { if (createdEmptyFile && out != null && out.isFile()) { out.delete(); } log.debug("skipping " + out.getParent()); } } else { log.debug("There is no place where to write."); } }
From source file:org.walkmod.writers.AbstractFileWriter.java
@Override public void setExcludes(String[] excludes) { if (excludes != null && System.getProperty("os.name").toLowerCase().contains("windows")) { for (int i = 0; i < excludes.length; i++) { excludes[i] = FilenameUtils.normalize(excludes[i], true); }//from w ww . ja v a 2 s . c o m } this.excludes = excludes; }
From source file:org.walkmod.writers.AbstractFileWriter.java
@Override public void setIncludes(String[] includes) { if (includes != null && System.getProperty("os.name").toLowerCase().contains("windows")) { for (int i = 0; i < includes.length; i++) { includes[i] = FilenameUtils.normalize(includes[i], true); }/*from ww w .j av a2 s . com*/ } this.includes = includes; }
From source file:org.whitesource.bamboo.agent.GenericOssInfoExtractor.java
private void extractOssInfo(final File absoluteRoot, final File root, final Collection<DependencyInfo> dependencyInfos) { final File[] files = root.listFiles(); if (files == null) { return;//w w w.java2 s. c o m } for (File file : files) { if (file.isFile()) { final String path = FilenameUtils.normalize( ResourceUtils.getRelativePath(file.getPath(), absoluteRoot.getPath(), File.separator), true); boolean process = matchAny(path, includePatterns); if (process) { process = !matchAny(path, excludePatterns); } if (process) { dependencyInfos.add(extractDepependencyInfo(file)); } } else { extractOssInfo(absoluteRoot, file, dependencyInfos); } } }
From source file:org.yamj.common.model.YamjInfo.java
/** * Create the URL to the web server based on the core IP address and port * * @param additionalPath//from w w w. ja v a2 s . c o m * @return The generated URL */ private String buildBaseUrl(String additionalPath) { try { StringBuilder path = new StringBuilder("/"); path.append(FilenameUtils.normalize(additionalPath, true)); if (!path.toString().endsWith("/")) { path.append("/"); } URI uri = new URI("http", null, coreIp, corePort, path.toString(), null, null); return uri.toString(); } catch (URISyntaxException ex) { LOG.warn("Failed to encode base URL: {}", ex.getMessage()); return ""; } }
From source file:org.yamj.core.api.model.dto.ApiArtworkDTO.java
public String getFilename() { if (StringUtils.isBlank(this.filename)) { this.filename = FilenameUtils.normalize(FilenameUtils.concat(this.cacheDir, this.cacheFilename), Boolean.TRUE);// w ww . ja v a 2 s.c o m } return filename; }
From source file:org.yamj.core.api.model.dto.ApiEpisodeDTO.java
public String getVideoimage() { if (StringUtils.isBlank(videoimage) && (StringUtils.isNotBlank(cacheDir) && StringUtils.isNotBlank(cacheFilename))) { this.videoimage = FilenameUtils.normalize(FilenameUtils.concat(this.cacheDir, this.cacheFilename), Boolean.TRUE);//from w w w.ja va 2 s . com } return videoimage; }
From source file:org.yamj.core.api.model.Skin.java
public void setPath(String path) { this.path = FilenameUtils.normalize(path, Boolean.TRUE); }
From source file:org.yamj.core.service.file.FileStorageService.java
@Value("${yamj3.file.storage.resources}") public void setStorageResourceDir(String storageResourceDir) { this.storageResourceDir = FilenameUtils.normalize(storageResourceDir, Boolean.TRUE); LOG.info("Resource path set to '{}'", this.storageResourceDir); }
From source file:org.yamj.core.service.file.FileStorageService.java
@Value("${yamj3.file.storage.artwork}") public void setStoragePathArtwork(String storagePathArtwork) { this.storagePathArtwork = FilenameUtils .normalize(FilenameUtils.concat(storageResourceDir, storagePathArtwork), Boolean.TRUE); if (!this.storagePathArtwork.endsWith("/")) { this.storagePathArtwork += "/"; }//from w ww . j a v a 2 s . c o m LOG.info("Artwork storage path set to '{}'", this.storagePathArtwork); }