List of usage examples for java.io File toString
public String toString()
From source file:com.flipkart.aesop.runtime.jetty.JettyWebAppContextFactory.java
/** * Interface method implementation. Creates and returns a WebAppContext instance * @see org.springframework.beans.factory.FactoryBean#getObject() *//*w w w .j av a 2s. co m*/ public WebAppContext getObject() throws Exception { String path = null; // get the module name from RuntimeVariables. This would be set by the RuntimeComponentContainer instance's init() method String moduleName = RuntimeVariables.getVariable(RuntimeComponentContainer.RUNTIME_MODULE_VAR); File[] files = FileLocator.findDirectories(this.getContextPath(), null); for (File file : files) { // we need only WEB-INF from the relevant project and none else even by mistake String fileToString = file.toString(); if (fileToString.contains(".jar!") && fileToString.startsWith("file:/")) { fileToString = fileToString.replace("file:/", "jar:file:/"); if (fileToString.contains(moduleName + "-")) { path = fileToString; break; } } else { if (fileToString.contains(moduleName)) { path = fileToString; break; } } } // trim off the "WEB-INF" part as the WebAppContext path should refer to the parent directory if (path.endsWith("WEB-INF")) { path = path.replace("WEB-INF", ""); } WebAppContext webAppContext = new WebAppContext(path, this.getContextName()); webAppContext.setMaxFormContentSize(this.getMaxFormContentSize()); return webAppContext; }
From source file:com.collective.celos.WorkflowConfigurationParser.java
void parseFile(File f, StateDatabaseConnection connection) throws Exception { LOGGER.info("Loading file: " + f); FileReader fileReader = new FileReader(f); String fileName = f.toString(); evaluateReader(fileReader, fileName, connection); }
From source file:com.photon.phresco.framework.param.impl.PerformanceTestResultNamesImpl.java
private String getTestDirPath(String testAgainst, String goal, String rootModulePath, String subModuleName) throws PhrescoException { ProjectInfo info = Utility.getProjectInfo(rootModulePath, ""); File testFolderLocation = Utility.getTestFolderLocation(info, rootModulePath, subModuleName); StringBuilder builder = new StringBuilder(testFolderLocation.toString()); try {/*from ww w .j a va 2 s . c o m*/ String property = ""; if (PHASE_LOAD_TEST.equals(goal)) { property = POM_PROP_KEY_LOADTEST_DIR; } else { property = POM_PROP_KEY_PERFORMANCETEST_DIR; } File pomFileLocation = Utility.getPomFileLocation(rootModulePath, subModuleName); PomProcessor processor = new PomProcessor(pomFileLocation); String performDir = processor.getProperty(property); builder.append(performDir).append(File.separator).append(testAgainst.toString()) .append(FrameworkConstants.SLASH_JSON); return builder.toString(); } catch (PhrescoPomException e) { throw new PhrescoException(e); } }
From source file:ed.util.LicenseHeaderCheck.java
boolean skip(File f) { final String fString = f.toString(); if (fString.contains("/.git")) return true; for (String test : _skip) if (fString.contains(test)) return true; final String name = f.getName(); if (name.endsWith("~")) return true; if (name.equals("db") || name.equals("README")) return true; if (name.equals("_init.js")) return false; if (!Character.isLetterOrDigit(name.charAt(0))) return true; if (name.toLowerCase().startsWith("makefile") || name.toLowerCase().startsWith("oplog")) return true; if (name.contains(".")) { final String ext = ed.appserver.MimeTypes.getExtension(f); if (_skipExtensions.contains(ext)) return true; }/* w ww. j a v a2 s . co m*/ return false; }
From source file:com.flipkart.flux.guice.module.ContainerModule.java
/** * Creates a Jetty {@link WebAppContext} for the Flux dashboard * @return Jetty WebAppContext/*from w w w. jav a2s .c om*/ */ @Named("DashboardContext") @Provides @Singleton WebAppContext getDashboardWebAppContext() { String path = null; File[] files = FileLocator.findDirectories("packaged/webapps/dashboard/WEB-INF", null); for (File file : files) { // we need only WEB-INF from runtime project String fileToString = file.toString(); if (fileToString.contains(".jar!") && fileToString.startsWith("file:/")) { fileToString = fileToString.replace("file:/", "jar:file:/"); if (fileToString.contains("runtime-")) { path = fileToString; break; } } else { if (fileToString.contains(DASHBOARD_VIEW)) { path = fileToString; break; } } } // trim off the "WEB-INF" part as the WebAppContext path should refer to the parent directory if (path.endsWith("WEB-INF")) { path = path.replace("WEB-INF", ""); } WebAppContext webAppContext = new WebAppContext(path, RuntimeConstants.DASHBOARD_CONTEXT_PATH); return webAppContext; }
From source file:com.xtructure.xevolution.tool.data.AbstractGenealogyData.java
/** * Process the observed data.//from ww w . ja v a2 s.c om * * @param manager the manager * @param genome the genome * @param populationFile the population file */ protected void processObserved(XIdObjectManager<D> manager, Genome<?> genome, File populationFile) { put(POPULATION_FILE, populationFile.toString()); put(FITNESS, genome.getFitness()); XId parent1Id = genome.getAttribute(Genome.PARENT1_ID); XId parent2Id = genome.getAttribute(Genome.PARENT2_ID); if (parent1Id != null) { put(PARENT1, genome.getAttribute(Genome.PARENT1_ID).toString()); GenealogyData<D> parent1Data = manager.getObject(getParent1Id()); if (parent1Data != null) { parent1Data.addChildren(manager, getId()); } } if (parent2Id != null) { put(PARENT2, genome.getAttribute(Genome.PARENT2_ID).toString()); GenealogyData<D> parent2Data = manager.getObject(getParent2Id()); if (parent2Data != null) { parent2Data.addChildren(manager, getId()); } } put(APPLIED_OP, genome.getAttribute(Genome.APPLIED_OP_ID)); put(CHILDREN, new JSONArray()); }
From source file:jhttpp2.Jhttpp2Launcher.java
@SuppressWarnings("unchecked") public void restoreSettings()// throws Exception { if (server.getServerProperties() == null) { log.warn("server propertie where not set will not save them"); return;//from w ww . j a v a 2 s. c o m } try { // Restore the WildcardDioctionary and the URLActions with the // ObjectInputStream (settings.dat)... ObjectInputStream obj_in; File file = new File(DATA_FILE); if (!file.exists()) { if (!file.createNewFile() || !file.canWrite()) { log.warn("Can't create or write to file " + file.toString()); } else saveServerSettings(); } obj_in = new ObjectInputStream(new FileInputStream(file)); server.setWildcardDictionary((WildcardDictionary) obj_in.readObject()); server.setURLActions((List<OnURLAction>) obj_in.readObject()); obj_in.close(); } catch (IOException e) { log.warn("restoreSettings(): " + e.getMessage()); } catch (ClassNotFoundException e_class_not_found) { } }
From source file:com.teradata.tempto.sql.SqlResultGenerator.java
private void generateExpectedResults() { LOGGER.info("Reading {}", testFile); String testFileName = testFile.toString(); int dot = testFileName.lastIndexOf('.'); testFileName = testFileName.substring(0, dot); File resultFile = new File(testFileName + EXPECTED_SUFFIX); if (resultFile.exists()) { LOGGER.warn("Result file {} exists. Skipping...", resultFile.toString()); } else {/*from w w w . ja v a2s . com*/ StringBuilder query = new StringBuilder(); try (BufferedReader testFileReader = new BufferedReader(new FileReader(testFile))) { String line; while ((line = testFileReader.readLine()) != null) { line = line.trim(); if (line.isEmpty() || line.startsWith("--")) { continue; } if (query.length() > 0) { query.append(' '); } query.append(line); } // We've read the whole file. Execute the query, if there is one. if (query.length() > 0) { LOGGER.info("Executing query: {}", query.toString()); connection.executeQueryToFile(query.toString(), resultFile); } else { LOGGER.warn("File {} did not contain a query.", testFile); } } catch (SQLException e) { LOGGER.error("Executing: {}", query, e); } catch (IOException e) { LOGGER.error("Reading: {}", testFile, e); } } }
From source file:org.jasig.portlet.announcements.Importer.java
private void importTopics() { try {/*from ww w. jav a 2 s . co m*/ JAXBContext jc = JAXBContext.newInstance(Topic.class); Unmarshaller unmarshaller = jc.createUnmarshaller(); File[] files = dataDirectory.listFiles(new TopicImportFileFilter()); if (files == null) { errors.add("Directory " + dataDirectory + " is not a valid directory"); } else { for (File f : files) { log.info("Processing file " + f.toString()); StreamSource xmlFile = new StreamSource(f.getAbsoluteFile()); try { JAXBElement<Topic> je1 = unmarshaller.unmarshal(xmlFile, Topic.class); Topic topic = je1.getValue(); if (StringUtils.isBlank(topic.getTitle())) { String msg = "Error parsing file " + f.toString() + "; did not get valid record:\n" + topic.toString(); log.error(msg); errors.add(msg); } else { announcementService.addOrSaveTopic(topic); log.info("Successfully imported topic '" + topic.getTitle() + "'"); } } catch (JAXBException e) { String msg = "JAXB exception " + e.getCause().getMessage() + " processing file " + f.toString(); log.error(msg, e); errors.add(msg + ". See stack trace"); } catch (HibernateException e) { String msg = "Hibernate exception " + e.getCause().getMessage() + " processing file " + f.toString(); log.error(msg, e); errors.add(msg + ". See stack trace"); } } } } catch (JAXBException e) { String msg = "Fatal JAXBException in importTopics - no topics imported"; log.fatal(msg, e); errors.add(msg + ". See stack trace"); } }
From source file:eu.openanalytics.rsb.config.BootstrapConfigurationServletContextListenerTestCase.java
@Test public void defaultConfigurationIsValid() throws Exception { final File tempDirectory = FileUtils.getTempDirectory(); final PersistedConfiguration configuration = BootstrapConfigurationServletContextListener .createDefaultConfiguration(tempDirectory); ConfigurationFactory.validate(new PersistedConfigurationAdapter(null, configuration)); final ST defaultConfigurationTestTemplate = Util.newStringTemplate(IOUtils.toString(Thread.currentThread() .getContextClassLoader().getResourceAsStream("rsb-configuration-default.json"))); final File defaultRsbHomeDirectory = BootstrapConfigurationServletContextListener .getDefaultRsbHomeDirectory(tempDirectory); defaultConfigurationTestTemplate.add("RSB_HOME", defaultRsbHomeDirectory.toString()); assertThat(defaultConfigurationTestTemplate.render(), is(Util.toJson(configuration))); }