use of com.infiniteautomation.asciifile.vo.AsciiFileDataSourceVO in project ma-modules-public by infiniteautomation.
the class AsciiFileEditDwr method saveFileDataSource.
@DwrPermission(user = true)
public ProcessResult saveFileDataSource(BasicDataSourceVO basic, int updatePeriods, int updatePeriodType, String filePath) {
AsciiFileDataSourceVO ds = (AsciiFileDataSourceVO) Common.getHttpUser().getEditDataSource();
setBasicProps(ds, basic);
ds.setUpdatePeriods(updatePeriods);
ds.setUpdatePeriodType(updatePeriodType);
try {
ds.setFilePath(new File(filePath).getCanonicalPath());
} catch (IOException e) {
ProcessResult pr = new ProcessResult();
pr.addContextualMessage("filePath", "dsEdit.file.ioexceptionCanonical", filePath);
return pr;
}
return tryDataSourceSave(ds);
}
use of com.infiniteautomation.asciifile.vo.AsciiFileDataSourceVO in project ma-modules-public by infiniteautomation.
the class AsciiFileDataSourceRT method connect.
/**
* Load a file path
*
* @throws Exception
*/
public boolean connect() throws Exception {
AsciiFileDataSourceVO vo = (AsciiFileDataSourceVO) this.getVo();
this.file = new File(vo.getFilePath());
if (!file.exists()) {
raiseEvent(DATA_SOURCE_EXCEPTION_EVENT, System.currentTimeMillis(), true, new TranslatableMessage("file.event.fileNotFound", vo.getFilePath()));
return false;
} else if (!file.canRead()) {
raiseEvent(DATA_SOURCE_EXCEPTION_EVENT, System.currentTimeMillis(), true, new TranslatableMessage("file.event.readFailed", vo.getFilePath()));
return false;
} else {
this.fobs = new FileAlterationObserver(this.file);
this.fobs.initialize();
this.fobs.addListener(this);
return true;
}
}
Aggregations