Search in sources :

Example 1 with FailToImportEntriesException

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);
    }
}
Also used : FailToImportEntriesException(net.viperfish.journal.framework.errors.FailToImportEntriesException) Journal(net.viperfish.journal.framework.Journal) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 Journal (net.viperfish.journal.framework.Journal)1 FailToImportEntriesException (net.viperfish.journal.framework.errors.FailToImportEntriesException)1