use of net.viperfish.journal.framework.errors.FailToExportEntriesException in project vsDiaryWriter by shilongdai.
the class ExportJournalOperation method execute.
@Override
public void execute() {
// get all entries
List<Journal> allJournals = db().getAll();
Journal[] toExport = allJournals.toArray(new Journal[0]);
// set the id to null to reassign id when importing
for (Journal i : toExport) {
i.setId(null);
}
// serialize to JSON and write
try {
String result = generator.toJson(toExport);
outputTarget.write(result, StandardCharsets.UTF_16);
} catch (IOException e) {
FailToExportEntriesException f = new FailToExportEntriesException("Cannot export entries to:" + outputTarget + " message:" + e.getMessage());
f.initCause(e);
throw new RuntimeException(f);
}
}
Aggregations