Search in sources :

Example 26 with MCRContent

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());
}
Also used : MCRJDOMContent(org.mycore.common.content.MCRJDOMContent) MCRContent(org.mycore.common.content.MCRContent)

Example 27 with MCRContent

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());
}
Also used : MCRJDOMContent(org.mycore.common.content.MCRJDOMContent) MCRContent(org.mycore.common.content.MCRContent)

Example 28 with MCRContent

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);
    }
}
Also used : MCRJDOMContent(org.mycore.common.content.MCRJDOMContent) IOException(java.io.IOException) MCRPath(org.mycore.datamodel.niofs.MCRPath) MCRContent(org.mycore.common.content.MCRContent)

Example 29 with MCRContent

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();
    }
}
Also used : IOException(java.io.IOException) File(java.io.File) MCRContent(org.mycore.common.content.MCRContent) IOException(java.io.IOException) MCRException(org.mycore.common.MCRException)

Example 30 with MCRContent

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);
}
Also used : IOException(java.io.IOException) MCRContent(org.mycore.common.content.MCRContent) IOException(java.io.IOException)

Aggregations

MCRContent (org.mycore.common.content.MCRContent)63 Document (org.jdom2.Document)21 MCRJDOMContent (org.mycore.common.content.MCRJDOMContent)20 IOException (java.io.IOException)16 Element (org.jdom2.Element)13 MCRObjectID (org.mycore.datamodel.metadata.MCRObjectID)11 MCRPath (org.mycore.datamodel.niofs.MCRPath)10 Test (org.junit.Test)8 MCRPathContent (org.mycore.common.content.MCRPathContent)7 MCRParameterCollector (org.mycore.common.xsl.MCRParameterCollector)6 File (java.io.File)5 HttpServletRequest (javax.servlet.http.HttpServletRequest)5 JDOMException (org.jdom2.JDOMException)5 InputStream (java.io.InputStream)4 HashMap (java.util.HashMap)4 HttpServletResponse (javax.servlet.http.HttpServletResponse)4 MCRException (org.mycore.common.MCRException)4 MCRDerivate (org.mycore.datamodel.metadata.MCRDerivate)4 URL (java.net.URL)3 BasicFileAttributes (java.nio.file.attribute.BasicFileAttributes)3