List of usage examples for org.apache.commons.configuration BaseConfiguration getString
public String getString(String key)
From source file:org.sonar.batch.config.BatchSettingsTest.java
@Test public void shouldForwardToCommonsConfiguration() { ProjectDefinition project = ProjectDefinition.create(); project.setProperty("foo", "bar"); ProjectReactor reactor = new ProjectReactor(project); BaseConfiguration deprecatedConfiguration = new BaseConfiguration(); new BatchSettings(new PropertyDefinitions(), reactor, deprecatedConfiguration); assertThat(deprecatedConfiguration.getString("foo"), is("bar")); }
From source file:org.sonar.server.platform.ServerSettingsTest.java
@Test public void synchronize_deprecated_commons_configuration() { BaseConfiguration deprecated = new BaseConfiguration(); ServerSettings settings = new ServerSettings(new PropertyDefinitions(), deprecated, new File("."), home); assertThat(settings.getString("in_file")).isEqualTo("true"); assertThat(deprecated.getString("in_file")).isEqualTo("true"); assertThat(deprecated.getString("foo")).isNull(); settings.setProperty("foo", "bar"); assertThat(deprecated.getString("foo")).isEqualTo("bar"); settings.removeProperty("foo"); assertThat(deprecated.getString("foo")).isNull(); }
From source file:org.trustedanalytics.atk.giraph.io.titan.GiraphToTitanGraphFactory.java
public static void addFaunusInputConfiguration(Configuration hadoopConfig) { BaseConfiguration titanConfig = createTitanBaseConfiguration(hadoopConfig, GIRAPH_TITAN.get(hadoopConfig)); Iterator keys = titanConfig.getKeys(); String prefix = "titan.hadoop.input.conf."; while (keys.hasNext()) { String key = (String) keys.next(); hadoopConfig.set(prefix + key, titanConfig.getString(key)); }//from w ww.j av a2s . c o m }
From source file:uk.ac.sanger.cgp.wwdocker.actions.Remote.java
private static Session unconnectedSession(BaseConfiguration config, String host) { Session session;// w w w .jav a 2 s. c o m String fSep = System.getProperty("file.separator"); String userKnownHosts = System.getProperty("user.home") + fSep + ".ssh" + fSep + "known_hosts"; try { JSch jsch = new JSch(); jsch.setKnownHosts(userKnownHosts); jsch.addIdentity(privateKeyFile().getAbsolutePath()); Session thisSess = jsch.getSession(config.getString("ssh_user"), host, 22); thisSess.setServerAliveInterval(1000); thisSess.setPassword(config.getString("ssh_pw")); session = thisSess; } catch (JSchException e) { throw new RuntimeException("Failure in SSH connection: " + e.getMessage(), e); } return session; }
From source file:uk.ac.sanger.cgp.wwdocker.actions.Utils.java
public static File expandUserDirPath(BaseConfiguration config, String parameter, boolean checkExists) { File thing = expandUserFilePath(config, parameter, checkExists); if (!thing.isDirectory()) { throw new RuntimeException("Path indicated by '" + parameter + "=" + config.getString(parameter) + "' is not a directory once expanded to '" + thing.getAbsolutePath() + "'"); }/*from w ww .j a v a 2 s. c o m*/ return thing; }
From source file:uk.ac.sanger.cgp.wwdocker.actions.Utils.java
public static File expandUserFile(BaseConfiguration config, String parameter, boolean checkExists) { File thing = expandUserFilePath(config, parameter, checkExists); if (!thing.isFile()) { throw new RuntimeException("Path indicated by '" + parameter + "=" + config.getString(parameter) + "' is not a file once expanded to '" + thing.getAbsolutePath() + "'"); }//from w w w . j av a 2s . co m return thing; }
From source file:uk.ac.sanger.cgp.wwdocker.actions.Utils.java
public static File expandUserFilePath(BaseConfiguration config, String parameter, boolean checkExists) { String localTmp = config.getString(parameter); if (localTmp.startsWith("~")) { logger.trace("Attempting to expand path: " + localTmp); if (localTmp.startsWith("~/")) { localTmp = localTmp.replaceFirst("^~", System.getProperty("user.home")); } else {//from w w w. jav a2 s .c o m throw new RuntimeException( "Config value for '" + parameter + "' must be a full path or begin '~/'"); } logger.trace("Expanded path: " + localTmp); } File expanded = new File(localTmp); if (!expanded.exists()) { throw new RuntimeException("File or path indicated by '" + parameter + "=" + config.getString(parameter) + "' does not exist once expanded to '" + localTmp + "'"); } return expanded; }
From source file:uk.ac.sanger.cgp.wwdocker.actions.Utils.java
public static List<File> getGnosKeys(BaseConfiguration config) { List<File> gnosKeys = new ArrayList(); Path dir = Paths.get(config.getString("gnosKeys")); try (DirectoryStream<Path> stream = Files.newDirectoryStream(dir)) { for (Path item : stream) { File file = item.toFile(); if (file.isFile() && !file.isHidden()) { gnosKeys.add(file);/*w ww .ja v a 2s . co m*/ } } } catch (IOException | DirectoryIteratorException e) { throw new RuntimeException(e.getMessage(), e); } return gnosKeys; }
From source file:uk.ac.sanger.cgp.wwdocker.actions.Utils.java
public static List<File> getWorkInis(BaseConfiguration config) { List<File> iniFiles = new ArrayList(); Path dir = Paths.get(config.getString("wfl_inis")); try (DirectoryStream<Path> stream = Files.newDirectoryStream(dir)) { for (Path item : stream) { File file = item.toFile(); if (file.isFile() && file.canRead() && !file.isHidden()) { if (!file.getName().endsWith(".ini")) { continue; }//w w w . j a va 2 s. com iniFiles.add(file); } } } catch (IOException | DirectoryIteratorException e) { throw new RuntimeException(e.getMessage(), e); } return iniFiles; }
From source file:uk.ac.sanger.cgp.wwdocker.callable.Docker.java
public Docker(WorkflowIni iniFile, BaseConfiguration config) { this.config = config; this.threadName = iniFile.getIniFile().getName(); this.iniFile = iniFile; remoteIni = Paths.get(config.getString("datastoreDir"), threadName).toFile(); workManager = new WorkflowFactory().getWorkflow(config); }