Search in sources :

Example 1 with DedupKeyParserException

use of cz.mzk.recordmanager.server.dedup.DedupKeyParserException in project RecordManager2 by moravianlibrary.

the class HarvestedRecordWriter method writeRecord.

public void writeRecord(HarvestedRecord record) {
    if (record == null) {
        return;
    }
    if (!record.getShouldBeProcessed()) {
        recordDao.updateTimestampOnly(record);
        return;
    }
    if (record.getDeleted() == null) {
        try {
            if (record.getId() == null) {
                recordDao.persist(record);
            }
            dedupKeysParser.parse(record);
            if (record.getHarvestedFrom().isFilteringEnabled() && !record.getShouldBeProcessed()) {
                logger.debug("Filtered record: " + record.getUniqueId());
                record.setDeleted(new Date());
            }
        } catch (DedupKeyParserException dkpe) {
            logger.error("Dedup keys could not be generated for {}, exception thrown.", record, dkpe);
        } catch (InvalidMarcException ime) {
            logger.warn("Skipping record due to invalid MARC {}", record.getUniqueId());
        } catch (InvalidDcException dce) {
            logger.warn("Skipping record due to invalid DublinCore {}", record.getUniqueId());
        }
    } else {
        // deleted records by institution - drop dedup kyes, metadata
        recordDao.dropDedupKeys(record);
        record.setRawRecord(new byte[0]);
        record.setDedupKeysHash("");
        record.setNextDedupFlag(true);
    }
    recordDao.persist(record);
}
Also used : InvalidMarcException(cz.mzk.recordmanager.server.marc.InvalidMarcException) InvalidDcException(cz.mzk.recordmanager.server.dc.InvalidDcException) DedupKeyParserException(cz.mzk.recordmanager.server.dedup.DedupKeyParserException) Date(java.util.Date)

Aggregations

InvalidDcException (cz.mzk.recordmanager.server.dc.InvalidDcException)1 DedupKeyParserException (cz.mzk.recordmanager.server.dedup.DedupKeyParserException)1 InvalidMarcException (cz.mzk.recordmanager.server.marc.InvalidMarcException)1 Date (java.util.Date)1