use of cz.mzk.recordmanager.server.marc.InvalidMarcException in project RecordManager2 by moravianlibrary.
the class RegenerateDedupKeysWriter method write.
@Override
public void write(List<? extends Long> ids) {
for (Long id : ids) {
HarvestedRecord rec = harvestedRecordDao.get(id);
if (rec.getDedupKeysHash() != null || !rec.getHarvestedFrom().isGenerateDedupKeys() || rec.getRawRecord() == null || rec.getRawRecord().length == 0) {
continue;
}
try {
rec = dedupKeysParser.parse(rec);
harvestedRecordDao.persist(rec);
++totalCount;
logProgress();
} catch (InvalidMarcException ime) {
logger.warn("Invalid Marc in record: " + rec.getId());
} catch (Exception e) {
logger.warn("Skipping record due to error: " + e.toString());
}
}
}
use of cz.mzk.recordmanager.server.marc.InvalidMarcException 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);
}
use of cz.mzk.recordmanager.server.marc.InvalidMarcException in project RecordManager2 by moravianlibrary.
the class MarcInterceptorFactory method getInterceptor.
public MarcRecordInterceptor getInterceptor(ImportConfiguration configuration, String recordId, byte[] rawRecord) {
String prefix = configuration.getIdPrefix();
try {
Record record = parseRecord(rawRecord);
switch(prefix) {
case Constants.PREFIX_CASLIN:
MarcRecordInterceptor mri = new SkatMarcInterceptor(record);
appCtx.getAutowireCapableBeanFactory().autowireBean(mri);
return mri;
case Constants.PREFIX_MZKNORMS:
return new MzkNormsMarcInterceptor(record);
case Constants.PREFIX_NLK:
return new NlkMarcInterceptor(record, configuration, recordId);
case Constants.PREFIX_OPENLIB:
return new OpenlibMarcInterceptor(record);
case Constants.PREFIX_KKVY:
return new KkvyMarcInterceptor(record, configuration, recordId);
case Constants.PREFIX_CBVK:
return new CbvkMarcInterceptor(record, configuration, recordId);
case Constants.PREFIX_BMC:
return new BmcMarcInterceptor(record);
case Constants.PREFIX_TDKIV:
return new TdkivMarcInterceptor(record);
case Constants.PREFIX_CELITEBIB:
return new CelitebibMarcInterceptor(record);
default:
return new DefaultMarcInterceptor(record, configuration, recordId);
}
} catch (InvalidMarcException ime) {
return null;
}
}
Aggregations