Search in sources :

Example 1 with SimpleMetadata

use of org.mycore.oai.pmh.SimpleMetadata in project mycore by MyCoRe-Org.

the class MCROAIObjectManager method getRecord.

public Record getRecord(Header header, MetadataFormat format) {
    Element recordElement;
    if (header.isDeleted()) {
        return new Record(header);
    }
    try {
        recordElement = getJDOMRecord(getMyCoReId(header.getId()), format);
    } catch (Exception exc) {
        LOGGER.error("unable to get record {} ({})", header.getId(), format.getPrefix(), exc);
        return null;
    }
    Record record = new Record(header);
    if (recordElement.getNamespace().equals(OAIConstants.NS_OAI)) {
        Element metadataElement = recordElement.getChild("metadata", OAIConstants.NS_OAI);
        if (metadataElement != null && !metadataElement.getChildren().isEmpty()) {
            Element metadataChild = metadataElement.getChildren().get(0);
            record.setMetadata(new SimpleMetadata(metadataChild.detach()));
        }
        Element aboutElement = recordElement.getChild("about", OAIConstants.NS_OAI);
        if (aboutElement != null) {
            for (Element aboutChild : aboutElement.getChildren()) {
                record.getAboutList().add(aboutChild.detach());
            }
        }
    } else {
        // handle as metadata
        record.setMetadata(new SimpleMetadata(recordElement));
    }
    return record;
}
Also used : Element(org.jdom2.Element) Record(org.mycore.oai.pmh.Record) SimpleMetadata(org.mycore.oai.pmh.SimpleMetadata)

Aggregations

Element (org.jdom2.Element)1 Record (org.mycore.oai.pmh.Record)1 SimpleMetadata (org.mycore.oai.pmh.SimpleMetadata)1