Search in sources :

Example 1 with IdDoesNotExistException

use of org.mycore.oai.pmh.IdDoesNotExistException 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);
}
Also used : DeletedRecordPolicy(org.mycore.oai.pmh.Identify.DeletedRecordPolicy) IdDoesNotExistException(org.mycore.oai.pmh.IdDoesNotExistException) Record(org.mycore.oai.pmh.Record)

Aggregations

IdDoesNotExistException (org.mycore.oai.pmh.IdDoesNotExistException)1 DeletedRecordPolicy (org.mycore.oai.pmh.Identify.DeletedRecordPolicy)1 Record (org.mycore.oai.pmh.Record)1