use of org.mycore.common.MCRException in project mycore by MyCoRe-Org.
the class MCRMODSWrapper method removeElements.
public void removeElements(String xPath) {
Iterator<Element> selected;
try {
selected = buildXPath(xPath).evaluate(getMODS()).iterator();
} catch (JDOMException ex) {
String msg = "Could not remove elements at " + xPath;
throw new MCRException(msg, ex);
}
while (selected.hasNext()) {
Element element = selected.next();
element.detach();
}
}
use of org.mycore.common.MCRException in project mycore by MyCoRe-Org.
the class MCRMODSClassificationSupport method getClassCategParentLink.
public static String getClassCategParentLink(final NodeList sources) {
if (sources.getLength() == 0) {
LOGGER.warn("Cannot get first element of node list 'sources'.");
return "";
}
final Element source = (Element) sources.item(0);
MCRCategoryID category = MCRClassMapper.getCategoryID(source);
if (category == null) {
return "";
}
String id;
try {
id = MCRXMLFunctions.encodeURIPath(category.getID());
} catch (URISyntaxException e) {
/* This should be impossible! */
throw new MCRException(e);
}
return MessageFormat.format("classification:metadata:0:parents:{0}:{1}", category.getRootID(), id);
}
use of org.mycore.common.MCRException in project mycore by MyCoRe-Org.
the class MCRMODSClassificationSupport method getClassCategLink.
public static String getClassCategLink(final NodeList sources) {
if (sources.getLength() == 0) {
LOGGER.warn("Cannot get first element of node list 'sources'.");
return "";
}
final Element source = (Element) sources.item(0);
MCRCategoryID category = MCRClassMapper.getCategoryID(source);
if (category == null) {
return "";
}
String id;
try {
id = MCRXMLFunctions.encodeURIPath(category.getID());
} catch (URISyntaxException e) {
/* This should be impossible! */
throw new MCRException(e);
}
return MessageFormat.format("classification:metadata:0:children:{0}:{1}", category.getRootID(), id);
}
use of org.mycore.common.MCRException in project mycore by MyCoRe-Org.
the class MCRMODSURNPersistentIdentifierMetadataManager method insertIdentifier.
@Override
public void insertIdentifier(MCRUniformResourceName identifier, MCRBase obj, String additional) throws MCRPersistentIdentifierException {
MCRObject object = checkObject(obj);
MCRMODSWrapper wrapper = new MCRMODSWrapper(object);
wrapper.setElement("identifier", "type", "urn", identifier.asString()).orElseThrow(() -> new MCRException("Could not insert urn into mods document!"));
}
use of org.mycore.common.MCRException in project mycore by MyCoRe-Org.
the class MCRExternalValidator method invokeMethod.
private Boolean invokeMethod(Method method, Object param) {
try {
Object[] params = { param };
Object result = method.invoke(null, params);
return (Boolean) result;
} catch (Exception ex) {
throw new MCRException(ex);
}
}
Aggregations