Commit b977f17f authored by helene ortiz's avatar helene ortiz
Browse files

Minor modifications for NomadServerGUI

parent b3bf8aae
......@@ -79,6 +79,8 @@ public class PropertyManager {
private Map<String, String> sizePropertyNames; // KEY=controllerType.propertyName VALUE=size property name
private String nomadHome;
/** -------------------------------------------------------------------------------------------------- **/
private static PropertyManager instance = null;
......@@ -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
......@@ -781,8 +792,8 @@ public class PropertyManager {
/**
* Returns a sorted set containing all property names for given controller.
* @param controllerType controller type
* @return a set containing all property names for given controller type
* @param controllerName controller name
* @return a set containing all property names for given controller name
*/
public Set<String> getPropertiesForController(String controllerName) {
int servantId = ServantDatabase.getInstance().getServantId(controllerName);
......@@ -798,6 +809,25 @@ public class PropertyManager {
return properties;
}
/**
* Returns a sorted set containing all dynamic property names for given controller.
* @param controllerName controller name
* @return a set containing all dynamic property names for given controller name
*/
public Set<String> getDynamicPropertiesForController(String controllerName) {
int servantId = ServantDatabase.getInstance().getServantId(controllerName);
SortedSet<String> properties = new TreeSet<String>();
Map<String, String> namesAndTypes = PropertyDatabase.getInstance().getDynamicPropertyNamesAndTypes(servantId);
if (namesAndTypes != null) {
properties.addAll(namesAndTypes.keySet());
} else {
System.out.println("property map has no entries for " + controllerName);
}
return properties;
}
/**
*
* @param controller
......
......@@ -163,6 +163,26 @@ public class PropertyDatabase {
}
return namesAndTypes;
}
/**
*
* @param servantId
* @return
*/
public Map<String, String> getDynamicPropertyNamesAndTypes(int servantId) {
Map<String, String> namesAndTypes = new HashMap<String, String>();
Set<DynamicPropertyDescriptor> propertyDescriptors = dynamicPropertiesByServant.get(servantId);
if (propertyDescriptors != null) {
Iterator<DynamicPropertyDescriptor> it = propertyDescriptors.iterator();
while (it.hasNext()) {
DynamicPropertyDescriptor descriptor = it.next();
namesAndTypes.put(descriptor.getName(), descriptor.getType());
}
}
return namesAndTypes;
}
/**
......
......@@ -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()) {
......
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