/** * Return the information to determine the entry point for the Microsoft FrontPage Server * Extensions. * * @param request HTTP request * @param response HTTP response */ public void execute(HttpServletRequest request, HttpServletResponse response) { // Build the model Map<String, Object> model = new HashMap<String, Object>(); model.put("alfrescoUrl", UrlUtil.getAlfrescoUrl(sysAdminParams)); model.put("shareUrl", UrlUtil.getShareUrl(sysAdminParams)); model.put("vtiUrl", getVtiUrl(request)); // Get the welcome template InputStream templateStream = getClass().getResourceAsStream(template); if (templateStream == null) { logger.warn("Welcome template missing: " + template); return; } StringBuilder template = new StringBuilder(); try { InputStreamReader r = new InputStreamReader(templateStream, Charset.forName("UTF-8")); int read; char[] c = new char[4096]; while ((read = r.read(c)) != -1) { template.append(c, 0, read); } r.close(); } catch (IOException e) { if (logger.isDebugEnabled()) { logger.debug("Action IO exception", e); } } finally { try { templateStream.close(); } catch (Exception e) { } } try { String res = templateService.processTemplateString("freemarker", template.toString(), model); PrintWriter r = response.getWriter(); r.append(res); r.close(); } catch (IOException e) { if (logger.isDebugEnabled()) { logger.debug("Action IO exception", e); } } }
/** * @param ref The node representing the current document ref (or null) * @return Model map for email templates */ private Map<String, Object> createEmailTemplateModel( NodeRef ref, Map<String, Object> suppliedModel, NodeRef fromPerson) { Map<String, Object> model = new HashMap<String, Object>(8, 1.0f); if (fromPerson != null) { model.put("person", new TemplateNode(fromPerson, serviceRegistry, null)); } if (ref != null) { model.put("document", new TemplateNode(ref, serviceRegistry, null)); NodeRef parent = serviceRegistry.getNodeService().getPrimaryParent(ref).getParentRef(); model.put("space", new TemplateNode(parent, serviceRegistry, null)); } // current date/time is useful to have and isn't supplied by FreeMarker by default model.put("date", new Date()); // add custom method objects model.put("hasAspect", new HasAspectMethod()); model.put("message", new I18NMessageMethod()); model.put("dateCompare", new DateCompareMethod()); // add URLs model.put("url", new URLHelper(repoRemoteUrl)); model.put( TemplateService.KEY_SHARE_URL, UrlUtil.getShareUrl(this.serviceRegistry.getSysAdminParams())); // if the caller specified a model, use it without overriding if (suppliedModel != null && suppliedModel.size() > 0) { for (String key : suppliedModel.keySet()) { if (model.containsKey(key)) { if (logger.isDebugEnabled()) { logger.debug("Not allowing overwriting of built in model parameter " + key); } } else { model.put(key, suppliedModel.get(key)); } } } // all done return model; }