Commit 2c6e94e2 authored by helene ortiz's avatar helene ortiz
Browse files

Adapt PropertyManager class for compatibility with NomadServerGUI

parent 93beaf9b
......@@ -79,10 +79,12 @@ public class PropertyManager {
private Map<String, String> sizePropertyNames; // KEY=controllerType.propertyName VALUE=size property name
private String nomadHome;
/** -------------------------------------------------------------------------------------------------- **/
private static PropertyManager instance = null;
private PropertyManager() {
}
......@@ -99,6 +101,8 @@ public class PropertyManager {
*
*/
public void init() {
nomadHome = System.getenv("NOMADCLIENT_HOME");
clientFilesFoundPerControllerType = new HashMap<String, Boolean>();
sizePropertyNames = new HashMap<String, String>();
propertyParser = new PropertyParser();
......@@ -114,6 +118,7 @@ public class PropertyManager {
Iterator<ClientServantDescriptor> it = ServantDatabase.getInstance().getDrivers().iterator();
while (it.hasNext()) {
ClientServantDescriptor descriptor = it.next();
boolean clientFilesExist = readPropertiesClientFilesFor(descriptor.getType());
if (clientFilesExist) {
Controller controller = DriverManager.getInstance().getDriver(descriptor.getName());
......@@ -150,8 +155,14 @@ public class PropertyManager {
if (clientFilesFoundPerControllerType.containsKey(controllerType)) {
return clientFilesFoundPerControllerType.get(controllerType);
}
String[] files = FileHelper.getFilesListByExtension(ConfigManager.CONTROLLERS_DIRECTORY + controllerType + ConfigManager.FILE_SEPARATOR, ConfigManager.PROPERTIES_PATTERN, true, true);
// Necessary for NomadServerGUI: the client project of the PropertyManager can be another project that NomadGUI, but the client files remain in NomadGUI
String prefix = "";
if (nomadHome != null) {
prefix = nomadHome + ConfigManager.FILE_SEPARATOR;
}
String[] files = FileHelper.getFilesListByExtension(prefix + ConfigManager.CONTROLLERS_DIRECTORY + controllerType + ConfigManager.FILE_SEPARATOR, ConfigManager.PROPERTIES_PATTERN, true, true);
if (files == null || files.length == 0) {
// Search on server side
......
......@@ -151,8 +151,18 @@ public class ConfigManager {
properties = new Properties();
// Load all properties file from conf directory
List<String> propertiesFiles = new ArrayList<String>(Arrays.asList(FileHelper.getFilesListByExtension(CLIENT_CONF_DIRECTORY, PROPERTIES_EXTENSION, true, true)));
propertiesFiles.addAll(new ArrayList<String>(Arrays.asList(FileHelper.getFilesListByExtension(SERVER_CONF_DIRECTORY, PROPERTIES_EXTENSION, true, true))));
List<String> propertiesFiles = new ArrayList<String>();
String[] files = FileHelper.getFilesListByExtension(CLIENT_CONF_DIRECTORY, PROPERTIES_EXTENSION, true, true);
if (files!= null) {
propertiesFiles.addAll(Arrays.asList(files));
}
files = FileHelper.getFilesListByExtension(SERVER_CONF_DIRECTORY, PROPERTIES_EXTENSION, true, true);
if (files != null) {
propertiesFiles.addAll(Arrays.asList(files));
}
Iterator<String> it = propertiesFiles.iterator();
while (it.hasNext()) {
......@@ -377,8 +387,8 @@ public class ConfigManager {
propertyValue = propertyValue.replace("~cross", SpecialCharacter.cross);
properties.put(propertyName, propertyValue);
}
public String replaceSpecialCharacters(String string) {
string = string.replace("~alpha", SpecialCharacter.alpha);
string = string.replace("~beta", SpecialCharacter.beta);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment