Search in sources :

Example 1 with IdDoesNotExistException

use of com.lyncode.xoai.dataprovider.exceptions.IdDoesNotExistException in project dataverse by IQSS.

the class XgetRecordHandler method handle.

@Override
public GetRecord handle(OAICompiledRequest parameters) throws OAIException, HandlerException {
    MetadataFormat format = getContext().formatForPrefix(parameters.getMetadataPrefix());
    Item item = getRepository().getItemRepository().getItem(parameters.getIdentifier());
    if (getContext().hasCondition() && !getContext().getCondition().getFilter(getRepository().getFilterResolver()).isItemShown(item))
        throw new IdDoesNotExistException("This context does not include this item");
    if (format.hasCondition() && !format.getCondition().getFilter(getRepository().getFilterResolver()).isItemShown(item))
        throw new CannotDisseminateRecordException("Format not applicable to this item");
    Xrecord record = this.createRecord(parameters, item);
    GetRecord result = new XgetRecord(record);
    return result;
}
Also used : Item(com.lyncode.xoai.dataprovider.model.Item) MetadataFormat(com.lyncode.xoai.dataprovider.model.MetadataFormat) IdDoesNotExistException(com.lyncode.xoai.dataprovider.exceptions.IdDoesNotExistException) CannotDisseminateRecordException(com.lyncode.xoai.dataprovider.exceptions.CannotDisseminateRecordException)

Example 2 with IdDoesNotExistException

use of com.lyncode.xoai.dataprovider.exceptions.IdDoesNotExistException in project dataverse by IQSS.

the class XitemRepository method getItem.

@Override
public Item getItem(String identifier) throws IdDoesNotExistException, OAIException {
    logger.fine("getItem; calling findOaiRecordsByGlobalId, identifier " + identifier);
    List<OAIRecord> oaiRecords = recordService.findOaiRecordsByGlobalId(identifier);
    if (oaiRecords != null && !oaiRecords.isEmpty()) {
        Xitem xoaiItem = null;
        for (OAIRecord record : oaiRecords) {
            if (xoaiItem == null) {
                Dataset dataset = datasetService.findByGlobalId(record.getGlobalId());
                if (dataset != null) {
                    xoaiItem = new Xitem(record).withDataset(dataset);
                }
            } else {
                // is part of multiple sets:
                if (!StringUtil.isEmpty(record.getSetName())) {
                    xoaiItem.getSets().add(new Set(record.getSetName()));
                }
            }
        }
        if (xoaiItem != null) {
            return xoaiItem;
        }
    }
    throw new IdDoesNotExistException();
}
Also used : Set(com.lyncode.xoai.dataprovider.model.Set) OAIRecord(edu.harvard.iq.dataverse.harvest.server.OAIRecord) Dataset(edu.harvard.iq.dataverse.Dataset) IdDoesNotExistException(com.lyncode.xoai.dataprovider.exceptions.IdDoesNotExistException)

Aggregations

IdDoesNotExistException (com.lyncode.xoai.dataprovider.exceptions.IdDoesNotExistException)2 CannotDisseminateRecordException (com.lyncode.xoai.dataprovider.exceptions.CannotDisseminateRecordException)1 Item (com.lyncode.xoai.dataprovider.model.Item)1 MetadataFormat (com.lyncode.xoai.dataprovider.model.MetadataFormat)1 Set (com.lyncode.xoai.dataprovider.model.Set)1 Dataset (edu.harvard.iq.dataverse.Dataset)1 OAIRecord (edu.harvard.iq.dataverse.harvest.server.OAIRecord)1