List of usage examples for org.apache.commons.io FilenameUtils getFullPath
public static String getFullPath(String filename)
From source file:pt.webdetails.cdf.dd.model.meta.reader.cdexml.XmlComponentTypeReader.java
public void read(ComponentType.Builder builder, XmlFsPluginThingReaderFactory factory, //just need property type here Element elem, String sourcePath) throws ThingReadException { //TODO: methods instead of comments for separation String compDir = FilenameUtils.getFullPath(sourcePath); String componentName = readBaseProperties(builder, elem, sourcePath); // model stuff and header type, better names welcome here readModel(builder, elem);/*from ww w . j a v a2 s . com*/ readResourceDependencies(builder, elem, compDir, componentName); readComponentSupportType(builder, elem); String srcPath = Utils.getNodeText("Contents/Implementation/Code/@src", elem); if (StringUtils.isNotEmpty(srcPath)) { builder.setImplementationPath(Utils.joinPath(compDir, srcPath)); } readCustomProperties(builder, factory, elem, sourcePath); readModelProperties(builder, elem); List<Element> attributeElems = Utils.selectNodes(elem, "Metadata/*"); for (Element attributeElem : attributeElems) { builder.addAttribute(Utils.getNodeText("@name", attributeElem), Utils.getNodeText(".", attributeElem)); } }
From source file:pt.webdetails.cpf.repository.pentaho.PentahoLegacySolutionAccess.java
@Override public boolean saveFile(String path, InputStream contents) { try {// w w w . j a v a2 s.c om path = getPath(path); int status = getRepository().publish( FilenameUtils.separatorsToUnix(PentahoSystem.getApplicationContext().getSolutionPath("")), FilenameUtils.getFullPath(path), FilenameUtils.getName(path), IOUtils.toByteArray(contents), true); switch (status) { case ISolutionRepository.FILE_ADD_SUCCESSFUL: return true; case ISolutionRepository.FILE_ADD_FAILED: case ISolutionRepository.FILE_ADD_INVALID_PUBLISH_PASSWORD: case ISolutionRepository.FILE_ADD_INVALID_USER_CREDENTIALS: default: return false; } } catch (PentahoAccessControlException e) { logger.error(e); return false; } catch (IOException e) { logger.error(e); return false; } }
From source file:pt.webdetails.cpf.utils.PluginUtils.java
/** * From a full path, returns the relative path * * @param fullPath//from w ww .ja va 2 s. c om * @param includePluginDir * @return The relative path */ @Override public String getPluginRelativeDirectory(String fullPath, boolean includePluginDir) throws FileNotFoundException { // Get directory name. We need to make sure we're not allowing this to fetch other resources File pluginDir = getPluginDirectory(); if (includePluginDir) { pluginDir = pluginDir.getParentFile(); } String basePath = null; String elementFullPath = null; try { basePath = URLDecoder.decode(FilenameUtils.normalize(pluginDir.getAbsolutePath()), CharsetHelper.getEncoding()); elementFullPath = URLDecoder.decode(FilenameUtils.getFullPath(FilenameUtils.normalize(fullPath)), CharsetHelper.getEncoding()); } catch (UnsupportedEncodingException e) { //CharseHelper.getEncoding() returns a valid encoding } if (elementFullPath.indexOf(basePath) < 0) { throw new FileNotFoundException("Can't extract relative path from file " + fullPath); } return elementFullPath.substring(basePath.length()); }
From source file:pt.webdetails.cpk.sitemap.LinkGenerator.java
private Map<String, File> getTopLevelDirectories(Collection<IElement> elements) { HashMap<String, File> directories = new HashMap<String, File>(); for (IElement element : elements) { File directory = new File(FilenameUtils.getFullPath(element.getLocation())); if (directory != null) { try { directories.put(directory.getCanonicalPath(), directory); } catch (Exception e) { }/*w ww . j a v a2 s . c om*/ } } return directories; }
From source file:pt.webdetails.cpk.testUtils.PluginUtilsForTesting.java
/** * From a full path, returns the relative path * * @param fullPath/*w w w . j ava 2 s . c om*/ * @param includePluginDir * @return The relative path */ @Override public String getPluginRelativeDirectory(String fullPath, boolean includePluginDir) throws FileNotFoundException { // Get directory name. We need to make sure we're not allowing this to fetch other resources File pluginDir = getPluginDirectory(); if (includePluginDir) { pluginDir = pluginDir.getParentFile(); } String basePath = FilenameUtils.normalize(pluginDir.getAbsolutePath()); String elementFullPath = FilenameUtils.getFullPath(FilenameUtils.normalize(fullPath)); if (elementFullPath.indexOf(basePath) < 0) { throw new FileNotFoundException("Can't extract relative path from file " + fullPath); } return elementFullPath.substring(basePath.length()); }
From source file:sernet.gs.ui.rcp.main.logging.LoggerInitializer.java
private void createParentDirectories(File file) throws IOException { new File(FilenameUtils.getFullPath(file.getCanonicalPath())).mkdirs(); }
From source file:sernet.gs.ui.rcp.main.logging.WindowsLogDirectory.java
@Override public String getLogDirectory() { String directory = FilenameUtils.getFullPath(FilenameUtils.separatorsToSystem(filePath)); return removeInvalidPrefix(directory); }
From source file:Wrapper.ExportWithEstimatedFDR.java
/** * @param args the command line arguments */// www . j a v a 2 s . c o m public static void main(String[] args) throws ParserConfigurationException, SAXException, IOException, ClassNotFoundException, XmlPullParserException, InterruptedException, SQLException { System.out.println( "================================================================================================="); System.out.println("Umpire search result parser(version: v1.1, 2015.06)"); if (args.length == 0) { System.out.println( "command : java -jar -Xmx1G Umpire-SearchResultParser.jar [Options] [Combined ProtXML file] [PepXML files...]"); System.out.println(""); System.out.println("ProtXML extension: *.prot.xml or *.ProtXML"); System.out.println("PepXML extension: *.pep.xml or *.PepXML"); System.out.println("\nOptions"); System.out.println("\t-fP\tProtein FDR\tex: -fP0.01 (default: 0.01, no filtering: -1)"); System.out.println("\t-fp\tPeptide FDR\tex: -fp0.05 (default: 0.01, no filtering: -1)"); System.out.println("\t-d\tDecoy tag prefix\tex: -dDECOY (default: rev_)"); System.out.println("\t-fa\tFasta file"); System.out.println("\t-N\tOutput filename"); System.out.println( "\t-pt\tInitial protein probability filtering threshold\tex: -pt0.5 (default: 0.5, no filtering : -1)"); System.out.println( "\t-rf\tR factor threshold, proteins with protein probablity less than the threshold will be used to estimate the R factor \n\t\tex: -rf0.2 (default: 0.2, do not use R factor: -1)"); return; } ConsoleLogger.SetConsoleLogger(Level.INFO); ConsoleLogger.SetFileLogger(Level.DEBUG, FilenameUtils.getFullPath(args[0]) + "parser_debug.log"); float protFDR = 0.01f; float pepFDR = 0.01f; String DecoyTag = "rev_"; String Fasta = ""; String Outputname = ""; float protprob = 0.5f; float rfthreshold = 0.2f; String ProtXML = ""; ArrayList<String> PepXML = new ArrayList<>(); for (int i = 0; i < args.length; i++) { if (args[i].startsWith("-")) { if (args[i].startsWith("-fP")) { protFDR = Float.parseFloat(args[i].substring(3)); Logger.getRootLogger().info("Protein FDR:" + protFDR); } if (args[i].startsWith("-fp")) { pepFDR = Float.parseFloat(args[i].substring(3)); Logger.getRootLogger().info("Peptide FDR:" + pepFDR); } if (args[i].startsWith("-d")) { DecoyTag = args[i].substring(2); Logger.getRootLogger().info("Decoy tag: " + DecoyTag); } if (args[i].startsWith("-fa")) { Fasta = args[i].substring(3); Logger.getRootLogger().info("Fasta file: " + Fasta); } if (args[i].startsWith("-N")) { Outputname = args[i].substring(2); Logger.getRootLogger().info("Output filename: " + Outputname); } if (args[i].startsWith("-pt")) { protprob = Float.parseFloat(args[i].substring(3)); Logger.getRootLogger().info("Initial protein probablity filtering threshold: " + protprob); } if (args[i].startsWith("-rf")) { rfthreshold = Float.parseFloat(args[i].substring(3)); Logger.getRootLogger().info("R factor threshold: " + rfthreshold); } } if (args[i].endsWith(".pep.xml") || args[i].endsWith(".PepXML")) { PepXML.add(args[i]); } if (args[i].endsWith(".prot.xml") || args[i].endsWith(".ProtXML")) { ProtXML = args[i]; } } LCMSID lcmsid = new LCMSID(Outputname, DecoyTag, Fasta); for (String pepxml : PepXML) { LCMSID pepxmlid = new LCMSID(pepxml, DecoyTag, Fasta); PepXMLParser pepxmlparser = new PepXMLParser(pepxmlid, pepxml, 0f); if (pepFDR != -1f) { pepxmlid.FilterByPepDecoyFDR(DecoyTag, pepFDR); } Logger.getRootLogger().info("peptide No.:" + pepxmlid.GetPepIonList().size() + "; Peptide level threshold: " + pepxmlid.PepProbThreshold); for (PepIonID pepID : pepxmlid.GetPepIonList().values()) { lcmsid.AddPeptideID(pepID); } } if (!"".equals(ProtXML)) { ProtXMLParser protxmlparser = new ProtXMLParser(lcmsid, ProtXML, 0f); lcmsid.DecoyTag = DecoyTag; if (protprob != -1f) { lcmsid.RemoveLowLocalPWProtein(protprob); } float rf = 1f; if (rfthreshold != -1f) { rf = lcmsid.GetRFactor(rfthreshold); } if (protFDR != -1f) { lcmsid.FilterByProteinDecoyFDRUsingMaxIniProb(lcmsid.DecoyTag, protFDR / rf); } if (!"".equals(Fasta)) { lcmsid.LoadSequence(); } lcmsid.ReMapProPep(); } lcmsid.CreateInstanceForAllPepIon(); lcmsid.ExportProtID(); lcmsid.ExportPepID(); Logger.getRootLogger().info("Protein No.:" + lcmsid.ProteinList.size() + "; All peptide ions.:" + lcmsid.GetPepIonList().size()); }