String nickname = ssdUser.getLeaf(HPIConstants.CONFIGURATIONS_USERS_NICKNAME).getValue();
this.addUser(new User(nickname, passphrase));
}
// instantiate the data watcher object, because afeter it will be started to watch some directory(ies)
DataWatcher dataWatcher = new DataWatcher();
// first load to invokers SSD files
SSDObjectArray ssdMappedFolders = ssdSettingsData.getArray(HPIConstants.CONFIGURATIONS_MAPPED_FOLDER);
for (int i = 0; i < ssdMappedFolders.getSize(); i++) {
SSDObjectNode ssdMappedFolder = ssdMappedFolders.getNode(i);
File mappedFolder = null;
if (ssdMappedFolder.get(HPIConstants.CONFIGURATIONS_RELATIVE_SERVER) != null) {
mappedFolder = new File(System.getProperty(HPIConstants.ENV_HPI_BASE),
System.getProperty("file.separator") +
ssdMappedFolder.getLeaf(HPIConstants.CONFIGURATIONS_RELATIVE_SERVER).getValue());
} else if (ssdMappedFolder.get(HPIConstants.CONFIGURATIONS_CANONICAL_PATH) != null) {
mappedFolder = new File(ssdMappedFolder.getLeaf(HPIConstants.CONFIGURATIONS_CANONICAL_PATH).getValue());
} else throw new IllegalStateException("There's some wrong thing in the " + HPIConstants.CONFIGURATIONS_MAPPED_FOLDER);
for (File invokerFile : mappedFolder.listFiles(new FolderFilter())) {
this.addInvokerFile(invokerFile);
}
// mapping the folder to data watcher
FolderMapping folder = new FolderMapping();
folder.setIdentifier(HPIConstants.DATA_WATCHER_FOLDER_MAPPING + i);
folder.setCanonicalPath(mappedFolder.getCanonicalPath());
log.info("Mapping folder to DataWatcher. Folder: " + mappedFolder.getCanonicalPath());
folder.setRegexFilter(HPIConstants.REGEX_FILE);
folder.setCheckChange(new CheckChange(HPIConstants.DATA_WATCHER_CRON_EXPRESSION));
folder.addListeners(new Listener(MappedFolderListener.class.getName()));
dataWatcher.addMapping(folder);
}
log.info("Starting DataWatcher.");
dataWatcher.start();
} catch (Exception e) {
throw new HPIRuntimeException(e);
}
}