use of org.apache.commons.vfs2.FileChangeEvent in project motech by motech.
the class ConfigFileMonitorTest method shouldSaveConfigWhenFileIsChanged.
@Test
public void shouldSaveConfigWhenFileIsChanged() throws IOException {
final String fileName = "res:config/org.motechproject.motech-module1/somemodule.properties";
FileObject fileObject = VFS.getManager().resolveFile(fileName);
configFileMonitor.fileChanged(new FileChangeEvent(fileObject));
verify(configurationService).addOrUpdate(new File(fileObject.getName().getPath()));
}
use of org.apache.commons.vfs2.FileChangeEvent in project motech by motech.
the class ConfigFileMonitorTest method shouldDeleteConfigWhenFileIsDeleted.
@Test
public void shouldDeleteConfigWhenFileIsDeleted() throws FileSystemException {
final String fileName = "res:config/org.motechproject.motech-module1/somemodule.properties";
FileObject fileObject = VFS.getManager().resolveFile(fileName);
configFileMonitor.fileDeleted(new FileChangeEvent(fileObject));
verify(configurationService).deleteByBundle(new File(fileObject.getName().getPath()).getParentFile().getName());
}
use of org.apache.commons.vfs2.FileChangeEvent in project motech by motech.
the class ConfigFileMonitor method fileChanged.
@Override
public void fileChanged(FileChangeEvent fileChangeEvent) {
FileObject fileObject = fileChangeEvent.getFile();
LOGGER.info(String.format("Received file update event for file: %s", fileObject));
File file = new File(fileObject.getName().getPath());
if (ConfigFileFilter.isFileSupported(file)) {
configurationService.addOrUpdate(file);
Map<String, Object> params = new HashMap<>();
params.put(ConfigurationConstants.FILE_PATH, file.getAbsolutePath());
sendEvent(ConfigurationConstants.FILE_CHANGED_EVENT_SUBJECT, params);
}
}
use of org.apache.commons.vfs2.FileChangeEvent in project motech by motech.
the class ConfigFileMonitor method fileDeleted.
@Override
public void fileDeleted(FileChangeEvent fileChangeEvent) throws FileSystemException {
FileObject fileObject = fileChangeEvent.getFile();
LOGGER.info(String.format("Received file deletion event for file: %s", fileObject));
File file = new File(fileObject.getName().getPath());
if (ConfigFileFilter.isFileSupported(file)) {
configurationService.deleteByBundle(file.getParentFile().getName());
Map<String, Object> params = new HashMap<>();
params.put(ConfigurationConstants.FILE_PATH, file.getAbsolutePath());
sendEvent(ConfigurationConstants.FILE_DELETED_EVENT_SUBJECT, params);
}
}
use of org.apache.commons.vfs2.FileChangeEvent in project motech by motech.
the class ConfigFileMonitor method fileCreated.
@Override
public void fileCreated(FileChangeEvent fileChangeEvent) throws IOException {
FileObject fileObject = fileChangeEvent.getFile();
LOGGER.info(String.format("Received file creation event for file: %s", fileObject));
File file = new File(fileObject.getName().getPath());
if (ConfigFileFilter.isFileSupported(file)) {
configurationService.addOrUpdate(file);
Map<String, Object> params = new HashMap<>();
params.put(ConfigurationConstants.FILE_PATH, file.getAbsolutePath());
sendEvent(ConfigurationConstants.FILE_CREATED_EVENT_SUBJECT, params);
}
}
Aggregations