use of org.mycore.common.content.MCRContent in project mycore by MyCoRe-Org.
the class MCRMailEventHandler method handleDerivateEvent.
private void handleDerivateEvent(MCREvent evt, MCRDerivate der) {
MCRContent xml = new MCRJDOMContent(der.createXML());
handleEvent(evt, xml, der.getId().toString());
}
use of org.mycore.common.content.MCRContent in project mycore by MyCoRe-Org.
the class MCRMailEventHandler method handleObjectEvent.
private void handleObjectEvent(MCREvent evt, MCRObject obj) {
MCRContent xml = new MCRJDOMContent(obj.createXML());
handleEvent(evt, xml, obj.getId().toString());
}
use of org.mycore.common.content.MCRContent in project mycore by MyCoRe-Org.
the class MCRMailEventHandler method handlePathEvent.
private void handlePathEvent(MCREvent evt, Path file, BasicFileAttributes attrs) {
if (!(file instanceof MCRPath)) {
return;
}
MCRPath path = MCRPath.toMCRPath(file);
MCRContent xml;
try {
xml = new MCRJDOMContent(MCRPathXML.getFileXML(path, attrs));
handleEvent(evt, xml, path.toString());
} catch (IOException e) {
LOGGER.error("Error while generating mail for {}", file, e);
}
}
use of org.mycore.common.content.MCRContent in project mycore by MyCoRe-Org.
the class MCRBibUtilsTransformer method transform.
@Override
public MCRContent transform(MCRContent source) throws IOException {
File modsFile = File.createTempFile("mods", ".xml");
source.sendTo(modsFile);
try {
MCRContent export = export(modsFile);
export.setLastModified(source.lastModified());
export.setMimeType(getMimeType());
return export;
} catch (Exception e) {
if (e instanceof IOException) {
throw (IOException) e;
}
if (e instanceof RuntimeException) {
throw (RuntimeException) e;
}
throw new IOException(e);
} finally {
modsFile.delete();
}
}
use of org.mycore.common.content.MCRContent in project mycore by MyCoRe-Org.
the class MCRContentTransformer method transform.
public void transform(MCRContent source, OutputStream out) throws IOException {
MCRContent content = transform(source);
try {
if (getEncoding() != null) {
content.setEncoding(getEncoding());
}
} catch (RuntimeException | IOException e) {
throw e;
} catch (Exception e) {
throw new IOException(e);
}
content.sendTo(out);
}
Aggregations