Search in sources :

Example 1 with MetadataFormat

use of com.lyncode.xoai.dataprovider.model.MetadataFormat in project dataverse by IQSS.

the class XlistRecordsHandler method createRecord.

private Record createRecord(OAICompiledRequest parameters, Item item) throws BadArgumentException, CannotDisseminateRecordException, OAIException, NoMetadataFormatsException, CannotDisseminateFormatException {
    MetadataFormat format = getContext().formatForPrefix(parameters.getMetadataPrefix());
    Header header = new Header();
    Dataset dataset = ((Xitem) item).getDataset();
    Xrecord xrecord = new Xrecord().withFormatName(parameters.getMetadataPrefix()).withDataset(dataset);
    header.withIdentifier(item.getIdentifier());
    ItemHelper itemHelperWrap = new ItemHelper(item);
    header.withDatestamp(item.getDatestamp());
    for (Set set : itemHelperWrap.getSets(getContext(), getRepository().getFilterResolver())) header.withSetSpec(set.getSpec());
    if (item.isDeleted())
        header.withStatus(Header.Status.DELETED);
    xrecord.withHeader(header);
    xrecord.withMetadata(item.getMetadata());
    return xrecord;
}
Also used : ItemHelper(com.lyncode.xoai.dataprovider.handlers.helpers.ItemHelper) MetadataFormat(com.lyncode.xoai.dataprovider.model.MetadataFormat) Set(com.lyncode.xoai.dataprovider.model.Set) Dataset(edu.harvard.iq.dataverse.Dataset)

Example 2 with MetadataFormat

use of com.lyncode.xoai.dataprovider.model.MetadataFormat 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 3 with MetadataFormat

use of com.lyncode.xoai.dataprovider.model.MetadataFormat in project dataverse by IQSS.

the class OAIServlet method addDataverseJsonMetadataFormat.

private Context addDataverseJsonMetadataFormat(Context context) {
    MetadataFormat metadataFormat = MetadataFormat.metadataFormat(DATAVERSE_EXTENDED_METADATA_FORMAT);
    metadataFormat.withNamespace(DATAVERSE_EXTENDED_METADATA_INFO);
    metadataFormat.withSchemaLocation(DATAVERSE_EXTENDED_METADATA_SCHEMA);
    context.withMetadataFormat(metadataFormat);
    return context;
}
Also used : MetadataFormat(com.lyncode.xoai.dataprovider.model.MetadataFormat)

Example 4 with MetadataFormat

use of com.lyncode.xoai.dataprovider.model.MetadataFormat in project dataverse by IQSS.

the class OAIServlet method addSupportedMetadataFormats.

private void addSupportedMetadataFormats(Context context) {
    for (String[] provider : ExportService.getInstance(settingsService).getExportersLabels()) {
        String formatName = provider[1];
        Exporter exporter;
        try {
            exporter = ExportService.getInstance(settingsService).getExporter(formatName);
        } catch (ExportException ex) {
            exporter = null;
        }
        if (exporter != null && exporter.isXMLFormat() && exporter.isHarvestable()) {
            MetadataFormat metadataFormat;
            try {
                metadataFormat = MetadataFormat.metadataFormat(formatName);
                metadataFormat.withNamespace(exporter.getXMLNameSpace());
                metadataFormat.withSchemaLocation(exporter.getXMLSchemaLocation());
            } catch (ExportException ex) {
                metadataFormat = null;
            }
            if (metadataFormat != null) {
                context.withMetadataFormat(metadataFormat);
            }
        }
    }
// return context;
}
Also used : MetadataFormat(com.lyncode.xoai.dataprovider.model.MetadataFormat) Exporter(edu.harvard.iq.dataverse.export.spi.Exporter) ExportException(edu.harvard.iq.dataverse.export.ExportException)

Example 5 with MetadataFormat

use of com.lyncode.xoai.dataprovider.model.MetadataFormat in project dataverse by IQSS.

the class XgetRecordHandler method createRecord.

private Xrecord createRecord(OAICompiledRequest parameters, Item item) throws BadArgumentException, CannotDisseminateRecordException, OAIException, NoMetadataFormatsException, CannotDisseminateFormatException {
    MetadataFormat format = getContext().formatForPrefix(parameters.getMetadataPrefix());
    Header header = new Header();
    Dataset dataset = ((Xitem) item).getDataset();
    Xrecord xrecord = new Xrecord().withFormatName(parameters.getMetadataPrefix()).withDataset(dataset);
    header.withIdentifier(item.getIdentifier());
    ItemHelper itemHelperWrap = new ItemHelper(item);
    header.withDatestamp(item.getDatestamp());
    for (Set set : itemHelperWrap.getSets(getContext(), getRepository().getFilterResolver())) header.withSetSpec(set.getSpec());
    if (item.isDeleted())
        header.withStatus(Header.Status.DELETED);
    xrecord.withHeader(header);
    xrecord.withMetadata(item.getMetadata());
    return xrecord;
}
Also used : ItemHelper(com.lyncode.xoai.dataprovider.handlers.helpers.ItemHelper) MetadataFormat(com.lyncode.xoai.dataprovider.model.MetadataFormat) Set(com.lyncode.xoai.dataprovider.model.Set) Dataset(edu.harvard.iq.dataverse.Dataset)

Aggregations

MetadataFormat (com.lyncode.xoai.dataprovider.model.MetadataFormat)5 ItemHelper (com.lyncode.xoai.dataprovider.handlers.helpers.ItemHelper)2 Set (com.lyncode.xoai.dataprovider.model.Set)2 Dataset (edu.harvard.iq.dataverse.Dataset)2 CannotDisseminateRecordException (com.lyncode.xoai.dataprovider.exceptions.CannotDisseminateRecordException)1 IdDoesNotExistException (com.lyncode.xoai.dataprovider.exceptions.IdDoesNotExistException)1 Item (com.lyncode.xoai.dataprovider.model.Item)1 ExportException (edu.harvard.iq.dataverse.export.ExportException)1 Exporter (edu.harvard.iq.dataverse.export.spi.Exporter)1