public void registerEngine(RenderingEngine engine) { RenderingEngine existing = engines.put(engine.getFormatName(), engine); if (existing != null) { log.debug("Replaced existing RenderingEngine " + engine.getFormatName()); } else if (log.isDebugEnabled()) { log.debug("Registered RenderingEngine " + engine.getFormatName()); } }
public Collection<RenderingResult> process(RenderingContext renderingCtx) throws RenderingException { List<RenderingResult> ret = new ArrayList<RenderingResult>(); for (RenderingEngine engine : engines.values()) { if (renderingCtx.accept(engine)) { RenderingResult result = engine.process(renderingCtx); if (result != null) { ret.add(result); } else if (log.isDebugEnabled()) { log.debug("rendering ignored by the engine " + engine.getFormatName()); } } } return ret; }
public RenderingResult process(RenderingContext ctx) throws RenderingException { try { if (cfg == null) { cfg = createConfiguration(); } FreemarkerRenderingJob job = createJob(ctx); cfg.getTemplate(job.getTemplate(), cfg.getDefaultEncoding()).process(ctx, job.getWriter()); return job.getResult(); } catch (IOException | TemplateException e) { throw new RenderingException("Freemarker processing failed", e); } }
DocumentRenderingContext context = new DocumentRenderingContext(); context.remove("doc"); context.putAll(mail); context.setDocument((DocumentModel) mail.get("document")); context.put("Runtime", Framework.getRuntime()); rs.registerEngine(new NotificationsRenderingEngine(customSubjectTemplate)); Collection<RenderingResult> results = rs.process(context); String subjectMail = "<HTML><P>No parsing Succeded !!!</P></HTML>"; subjectMail = (String) result.getOutcome(); rs.registerEngine(new NotificationsRenderingEngine((String) mail.get(NotificationConstants.TEMPLATE_KEY))); Collection<RenderingResult> results = rs.process(context); String bodyMail = "<HTML><P>No parsing Succedeed !!!</P></HTML>"; bodyMail = (String) result.getOutcome(); rs.unregisterEngine("ftl");
DocumentRenderingContext context = new DocumentRenderingContext(); context.remove("doc"); context.putAll(mail); DocumentModel doc = (DocumentModel) mail.get("document"); context.setDocument(doc); context.put("docPermalink", link); context.put("creator",doc.getPropertyValue("dc:creator")); rs.registerEngine(new NotificationsRenderingEngine( customSubjectTemplate)); Collection<RenderingResult> results = rs.process(context); String subjectMail = "<HTML><P>No parsing Succeded !!!</P></HTML>"; subjectMail = (String) result.getOutcome(); rs.registerEngine(new NotificationsRenderingEngine( (String) mail.get(NotificationConstants.TEMPLATE_KEY))); Collection<RenderingResult> results = rs.process(context); String bodyMail = "<HTML><P>No parsing Succedeed !!!</P></HTML>"; bodyMail = (String) result.getOutcome(); rs.unregisterEngine("ftl");
DocumentRenderingContext context = new DocumentRenderingContext(); context.remove("doc"); context.putAll(mail); DocumentModel doc = (DocumentModel) mail.get("document"); context.setDocument(doc); context.put("lastContributor", lastContributor); context.put("portalHost", portalHost); context.put("shortPortalHost", fn.getShortPortalHost(portalHost)); context.put("docPermalink", link); context.put("baseUrl", Framework.getProperty("nuxeo.url")); context.put("creator", doc.getPropertyValue("dc:creator")); context.put("initiator", initiator); context.put("Runtime", Framework.getRuntime()); rs.registerEngine(new NotificationsRenderingEngine( customSubjectTemplate)); Collection<RenderingResult> results = rs.process(context); String subjectMail = "<HTML><P>No parsing Succeded !!!</P></HTML>"; subjectMail = (String) result.getOutcome();