Search in sources :

Example 1 with MCRPersistentUniformResourceLocator

use of org.mycore.pi.purl.MCRPersistentUniformResourceLocator in project mycore by MyCoRe-Org.

the class MCRMODSPURLPersistentIdentifierMetadataManager method getIdentifier.

@Override
public Optional<MCRPersistentIdentifier> getIdentifier(MCRBase obj, String additional) throws MCRPersistentIdentifierException {
    MCRObject object = checkObject(obj);
    MCRMODSWrapper wrapper = new MCRMODSWrapper(object);
    Element element = wrapper.getElement(MODS_IDENTIFIER_TYPE_PURL);
    if (element == null) {
        return Optional.empty();
    }
    String purlString = element.getTextNormalize();
    try {
        return Optional.of(new MCRPersistentUniformResourceLocator(new URL(purlString)));
    } catch (MalformedURLException e) {
        return Optional.empty();
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) MCRObject(org.mycore.datamodel.metadata.MCRObject) Element(org.jdom2.Element) MCRPersistentUniformResourceLocator(org.mycore.pi.purl.MCRPersistentUniformResourceLocator) MCRMODSWrapper(org.mycore.mods.MCRMODSWrapper) URL(java.net.URL)

Aggregations

MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 Element (org.jdom2.Element)1 MCRObject (org.mycore.datamodel.metadata.MCRObject)1 MCRMODSWrapper (org.mycore.mods.MCRMODSWrapper)1 MCRPersistentUniformResourceLocator (org.mycore.pi.purl.MCRPersistentUniformResourceLocator)1