use of org.mycore.oai.pmh.Identify.DeletedRecordPolicy in project mycore by MyCoRe-Org.
the class MCROAIDeletedSearcher method searchDeleted.
/**
* Returns a list with identifiers of the deleted objects within the given date boundary.
* If the record policy indicates that there is no support for tracking deleted an empty
* list is returned.
*
* @param from from date
* @param until to date
*
* @return a list with identifiers of the deleted objects
*/
protected List<Header> searchDeleted(Instant from, Instant until) {
DeletedRecordPolicy deletedRecordPolicy = this.identify.getDeletedRecordPolicy();
if (from == null || DeletedRecordPolicy.No.equals(deletedRecordPolicy) || DeletedRecordPolicy.Transient.equals(deletedRecordPolicy)) {
return new ArrayList<>();
}
LOGGER.info("Getting identifiers of deleted items");
Map<MCRObjectID, Instant> deletedItems = MCRMetadataHistoryManager.getDeletedItems(from, Optional.ofNullable(until));
List<String> types = getConfig().getStrings(getConfigPrefix() + "DeletedRecordTypes", null);
if (types == null || types.isEmpty()) {
return deletedItems.entrySet().stream().map(this::toHeader).collect(Collectors.toList());
}
return deletedItems.entrySet().stream().filter(e -> types.contains(e.getKey().getTypeId())).map(this::toHeader).collect(Collectors.toList());
}
use of org.mycore.oai.pmh.Identify.DeletedRecordPolicy in project mycore by MyCoRe-Org.
the class MCROAIAdapter method getRecord.
/*
* (non-Javadoc)
* @see org.mycore.oai.pmh.dataprovider.OAIAdapter#getRecord(java.lang.String, org.mycore.oai.pmh.MetadataFormat)
*/
@Override
public Record getRecord(String identifier, MetadataFormat format) throws CannotDisseminateFormatException, IdDoesNotExistException {
// Update set for response header
getSetManager().getDirectList();
Optional<Record> possibleRecord = getSearchManager().getHeader(identifier).map(h -> objectManager.getRecord(h, format));
if (possibleRecord.isPresent()) {
return possibleRecord.get();
}
if (!objectManager.exists(identifier)) {
DeletedRecordPolicy rP = getIdentify().getDeletedRecordPolicy();
if (DeletedRecordPolicy.Persistent.equals(rP)) {
// get deleted item
Record deletedRecord = objectManager.getDeletedRecord(objectManager.getMyCoReId(identifier));
if (deletedRecord != null) {
return deletedRecord;
}
}
}
throw new IdDoesNotExistException(identifier);
}
Aggregations