use of org.vcell.util.ConfigurationException in project vcell by virtualcell.
the class PropertyLoader method getOptionalDirectory.
public static final File getOptionalDirectory(String propertyName) throws ConfigurationException {
String directoryString = getProperty(propertyName, null);
if (directoryString == null) {
return null;
}
if (!directoryString.toLowerCase().equals(USE_CURRENT_WORKING_DIRECTORY)) {
return new File(directoryString);
}
File cwd = Paths.get("").toAbsolutePath().toFile();
if (!cwd.isDirectory()) {
throw new ConfigurationException("PropertyLoader::getOptionalDirectory failed to read directory from current working directory " + cwd);
}
return cwd;
}
use of org.vcell.util.ConfigurationException in project vcell by virtualcell.
the class PropertyLoader method getRequiredProperty.
/**
* This method was created in VisualAge.
* @return java.lang.String
* @param propertyName java.lang.String
*/
public static final synchronized String getRequiredProperty(String propertyName) throws ConfigurationException {
if (checkRequired) {
MetaProp mp = propMap.get(propertyName);
if (mp != null) {
if (!mp.sentToMongo && !mp.required) {
report(mp, "PROPERTY: " + propertyName + " not marked required");
}
} else {
mp = new MetaProp(ValueType.GEN);
propMap.put(propertyName, mp);
report(mp, "PROPERTY: required property " + propertyName + " not mapped");
}
}
try {
String propertyValue = System.getProperty(propertyName);
if (propertyValue == null) {
throw new ConfigurationException("required System property \"" + propertyName + "\" not defined");
} else {
return propertyValue.trim();
}
} catch (Exception e) {
throw new ConfigurationException("required System property \"" + propertyName + "\" not defined");
}
}
use of org.vcell.util.ConfigurationException in project vcell by virtualcell.
the class PropertyLoader method getRequiredDirectory.
/**
* return file from property. If property value is {@value #USE_CURRENT_WORKING_DIRECTORY}, return current working directory
* @param propertyName
* @return File object
* @throws ConfigurationException
*/
public static final File getRequiredDirectory(String propertyName) throws ConfigurationException {
String directoryString = getRequiredProperty(propertyName);
if (!directoryString.toLowerCase().equals(USE_CURRENT_WORKING_DIRECTORY)) {
return new File(directoryString);
}
File cwd = Paths.get("").toAbsolutePath().toFile();
if (!cwd.isDirectory()) {
throw new ConfigurationException("PropertyLoader::getRequiredDirectory failed to read directory from current working directory " + cwd);
}
return cwd;
}
use of org.vcell.util.ConfigurationException in project vcell by virtualcell.
the class VCellConfiguration method getConfiguration.
private static synchronized Configuration getConfiguration() throws ConfigurationException {
if (configurationBuilder == null) {
Parameters params = new Parameters();
File propertiesFile = new File(ResourceUtil.getVcellHome(), "vcellconfig.properties");
if (!propertiesFile.exists()) {
try {
propertiesFile.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
FileBasedBuilderParameters thing = params.fileBased().setFile(propertiesFile);
configurationBuilder = new FileBasedConfigurationBuilder<PropertiesConfiguration>(PropertiesConfiguration.class).configure(thing);
configurationBuilder.setAutoSave(true);
try {
propertiesConfiguration = configurationBuilder.getConfiguration();
propertiesConfiguration.setSynchronizer(new ReadWriteSynchronizer());
} catch (org.apache.commons.configuration2.ex.ConfigurationException e) {
e.printStackTrace();
throw new ConfigurationException("failed to create configuration from file " + propertiesFile + ": " + e.getMessage());
}
}
return propertiesConfiguration;
}
use of org.vcell.util.ConfigurationException in project vcell by virtualcell.
the class SimulationControllerImpl method getUserSimulationDirectory.
private File getUserSimulationDirectory(String simDataRoot) {
String userName = localVCellConnection.getUserLoginInfo().getUserName();
File directory = new File(new File(simDataRoot), userName);
if (!directory.exists()) {
if (!directory.mkdirs()) {
String msg = "could not create directory " + directory;
if (lg.isWarnEnabled())
lg.warn(msg);
throw new ConfigurationException(msg);
}
//
// directory create from container (possibly) as root, make this user directory accessible from user "vcell"
//
directory.setWritable(true, false);
directory.setExecutable(true, false);
directory.setReadable(true, false);
}
return directory;
}
Aggregations