public MCREditorSession() { this(Collections.emptyMap(), new MCRParameterCollector()); }
public MCRXEditorTransformer(MCREditorSession editorSession, MCRParameterCollector transformationParameters) { this.editorSession = editorSession; this.transformationParameters = transformationParameters; this.buildFilterXSL = "true".equals(transformationParameters.getParameter("buildFilterXSL", "false")); }
public MCREditorSession(Map<String, String[]> requestParameters, MCRParameterCollector collector) { // make a copy, the original may be re-used by servlet container this.requestParameters.putAll(requestParameters); this.variables = new HashMap<>(collector.getParameterMap()); removeIllegalVariables(); }
@Override public MCRContent transform(MCRContent json) throws IOException { MCRContent dummy = new MCRStringContent("<dummy/>"); MCRContentTransformer t = MCRContentTransformerFactory.getTransformer("dummy-json2xml"); MCRParameterizedTransformer pt = (MCRParameterizedTransformer) t; MCRParameterCollector params = new MCRParameterCollector(); params.setParameter("json", json.asString()); MCRContent result = pt.transform(dummy, params); return result; } }
MCRViewerConfiguration mcrViewerConfiguration = super.get(request); String baseURL = MCRFrontendUtil.getBaseURL(request); MCRParameterCollector params = new MCRParameterCollector(request); String theme = params.getParameter("MIR.Layout.Theme", "flatmir"); String file = params.getParameter("MIR.DefaultLayout.CSS", "flatly.min"); String mirBootstrapCSSURL = String.format(Locale.ROOT, "%srsc/sass/mir-layout/scss/%s-%s.css", baseURL, theme, file); mcrViewerConfiguration.addCSS(mirBootstrapCSSURL); String customLayout = params.getParameter("MIR.CustomLayout.CSS", ""); if (customLayout.length() > 0) { String customLayoutURL = String.format(Locale.ROOT, "%scss/%s", baseURL, customLayout); String customJS = params.getParameter("MIR.CustomLayout.JS", ""); if (customJS.length() > 0) { mcrViewerConfiguration.addScript(String.format(Locale.ROOT, "%sjs/%s", baseURL, customJS));
public MCRContent transform(MCRContent editorSource) throws IOException, JDOMException, SAXException { editorSession.getValidator().clearRules(); editorSession.getSubmission().clear(); MCRContentTransformer transformer = MCRContentTransformerFactory.getTransformer("xeditor"); if (transformer instanceof MCRParameterizedTransformer) { transformationParameters.setParameter("transformer", this); 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); } }
public static MCRContent doExpandEditorElements(MCRContent content, HttpServletRequest request, HttpServletResponse response, String sessionID, String pageURL) throws IOException, JDOMException, SAXException { MCRParameterCollector pc = new MCRParameterCollector(request, false); MCREditorSession session = null; if (sessionID != null) { session = MCREditorSessionStoreUtils.getSessionStore().getSession(sessionID); if (session == null) { response.sendError(HttpServletResponse.SC_NOT_FOUND, "Editor session timed out."); return null; } } else { session = new MCREditorSession(request.getParameterMap(), pc); session.setPageURL(pageURL); MCREditorSessionStoreUtils.getSessionStore().storeSession(session); } return new MCRXEditorTransformer(session, pc).transform(content); } }