public void init(WOVariables variables, Map<Object, Object> existingProperties) {
_wolipsPropertiesDefaults = new Properties();
if (variables == null) {
_wolipsProperties = new ToHellWithProperties();
String wolipsPropertiesPath;
if (existingProperties != null) {
wolipsPropertiesPath = (String) existingProperties.get(WOVariables.WOLIPS_PROPERTIES);
if (wolipsPropertiesPath == null) {
wolipsPropertiesPath = (String) existingProperties.get("wolips.global.properties");
}
}
else {
wolipsPropertiesPath = System.getProperty(WOVariables.WOLIPS_PROPERTIES);
}
if (wolipsPropertiesPath == null) {
wolipsPropertiesPath = System.getenv(WOVariables.WOLIPS_PROPERTIES);
}
File wolipsPropertiesFile = null;
if (wolipsPropertiesPath != null) {
wolipsPropertiesFile = getWOLipsPropertiesFile(wolipsPropertiesPath);
if (!isValidWOlipsPropertiesFile(wolipsPropertiesFile)) {
wolipsPropertiesFile = null;
}
}
else {
String environmentName = null;
String woVersion = null;
if (existingProperties != null) {
environmentName = (String) existingProperties.get("wolips.environment");
woVersion = (String) existingProperties.get("wo.version");
}
if (woVersion != null) {
if (environmentName != null) {
wolipsPropertiesPath = "wolips." + environmentName + "." + woVersion + ".properties";
}
else {
wolipsPropertiesPath = "wolips." + woVersion + ".properties";
}
wolipsPropertiesFile = getWOLipsPropertiesFile(wolipsPropertiesPath);
if (!isValidWOlipsPropertiesFile(wolipsPropertiesFile)) {
wolipsPropertiesFile = null;
}
}
if (wolipsPropertiesFile == null) {
if (environmentName != null) {
wolipsPropertiesPath = "wolips." + environmentName + ".properties";
wolipsPropertiesFile = getWOLipsPropertiesFile(wolipsPropertiesPath);
if (!isValidWOlipsPropertiesFile(wolipsPropertiesFile)) {
wolipsPropertiesPath = "wolips.properties";
wolipsPropertiesFile = getWOLipsPropertiesFile(wolipsPropertiesPath);
}
}
else {
wolipsPropertiesPath = "wolips.properties";
wolipsPropertiesFile = getWOLipsPropertiesFile(wolipsPropertiesPath);
}
}
}
_wolipsPropertiesFile = wolipsPropertiesFile;
if (isValidWOlipsPropertiesFile(_wolipsPropertiesFile)) {
CachedProperties cachedProperties;
synchronized (_cachedProperties) {
cachedProperties = _cachedProperties.get(_wolipsPropertiesFile);
if (cachedProperties == null) {
cachedProperties = new CachedProperties(_wolipsPropertiesFile);
_cachedProperties.put(_wolipsPropertiesFile, cachedProperties);
}
}
cachedProperties.reloadIfNecessary();
_wolipsProperties = new ToHellWithProperties();
Properties backingProperties = cachedProperties.properties();
synchronized(backingProperties) {
_wolipsProperties.putAll(backingProperties);
}
}
else if (_wolipsProperties == null || _wolipsProperties.isEmpty()) {
createDefaultProperties();
if (wolipsPropertiesPath != null) {
_wolipsPropertiesFile = getWOLipsPropertiesFile(wolipsPropertiesPath);
}
save();
/*
if (existingProperties != null) {
String wolipsPropertiesName = (String)existingProperties.get("wolips.properties");
if (wolipsPropertiesName != null && "wolips.properties".equals(wolipsPropertiesName)) {
_wolipsPropertiesFile = getWOLipsPropertiesFile(wolipsPropertiesName);
save();
}
}
else {
_wolipsPropertiesFile = getWOLipsPropertiesFile("wolips.properties");
save();
}
*/
}
}
else {
_wolipsProperties = new ToHellWithProperties();
_wolipsProperties.putAll(variables._wolipsProperties);
}
if (existingProperties != null) {
for (Map.Entry<Object, Object> entry : existingProperties.entrySet()) {