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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations