Search in sources :

Example 1 with MCRWrappedContent

use of org.mycore.common.content.MCRWrappedContent in project mycore by MyCoRe-Org.

the class MCRXEditorTransformer method transform.

public MCRContent transform(MCRContent editorSource) throws IOException, JDOMException, SAXException {
    editorSession.getValidator().clearRules();
    editorSession.getSubmission().clear();
    MCRContentTransformer transformer = MCRContentTransformerFactory.getTransformer("xeditor");
    if (transformer instanceof MCRParameterizedTransformer) {
        String key = MCRXEditorTransformerStore.storeTransformer(this);
        transformationParameters.setParameter("XEditorTransformerKey", key);
        MCRContent result = ((MCRParameterizedTransformer) transformer).transform(editorSource, transformationParameters);
        if (result instanceof MCRWrappedContent && result.getClass().getName().contains(MCRXSLTransformer.class.getName())) {
            // lazy transformation make JUnit tests fail
            result = ((MCRWrappedContent) result).getBaseContent();
        }
        editorSession.getValidator().clearValidationResults();
        return result;
    } else {
        throw new MCRException("Xeditor needs parameterized MCRContentTransformer: " + transformer);
    }
}
Also used : MCRException(org.mycore.common.MCRException) MCRParameterizedTransformer(org.mycore.common.content.transformer.MCRParameterizedTransformer) MCRWrappedContent(org.mycore.common.content.MCRWrappedContent) MCRContentTransformer(org.mycore.common.content.transformer.MCRContentTransformer) MCRContent(org.mycore.common.content.MCRContent)

Aggregations

MCRException (org.mycore.common.MCRException)1 MCRContent (org.mycore.common.content.MCRContent)1 MCRWrappedContent (org.mycore.common.content.MCRWrappedContent)1 MCRContentTransformer (org.mycore.common.content.transformer.MCRContentTransformer)1 MCRParameterizedTransformer (org.mycore.common.content.transformer.MCRParameterizedTransformer)1