use of net.viperfish.journal.framework.errors.FailToImportEntriesException in project vsDiaryWriter by shilongdai.
the class ImportEntriesOperation method execute.
@Override
public void execute() {
// load the file
try {
String json = importFile.read(StandardCharsets.UTF_16);
// de-serialize and add
Journal[] result = generator.fromJson(Journal[].class, json);
for (Journal i : result) {
db().addEntry(i);
indexer().add(i);
}
} catch (IOException e) {
FailToImportEntriesException f = new FailToImportEntriesException("Cannot import from:" + importFile.getFile() + " message:" + e.getMessage());
f.initCause(e);
throw new RuntimeException(f);
}
}
Aggregations