use of org.alfresco.repo.template.I18NMessageMethod in project acs-community-packaging by Alfresco.
the class NodeInfoBean method getModel.
// ------------------------------------------------------------------------------
// Helper methods
private Map<String, Object> getModel(NodeRef nodeRef, Map<String, String> requestMap) throws ContentIOException {
FacesContext context = FacesContext.getCurrentInstance();
Map<String, Object> model = new HashMap<String, Object>(8, 1.0f);
I18NUtil.registerResourceBundle("alfresco.messages.webclient");
// create api methods
model.put("date", new Date());
model.put("msg", new I18NMessageMethod());
model.put("url", new BaseTemplateContentServlet.URLHelper(context));
model.put("locale", I18NUtil.getLocale());
if (nodeRef != null) {
model.put("node", new TemplateNode(nodeRef, Repository.getServiceRegistry(context), this.imageResolver));
}
// add URL arguments as a map called 'args' to the root of the model
Map<String, String> args = new HashMap<String, String>(4, 1.0f);
for (String name : requestMap.keySet()) {
args.put(name, requestMap.get(name));
}
model.put("args", args);
return model;
}
use of org.alfresco.repo.template.I18NMessageMethod in project acs-community-packaging by Alfresco.
the class TaskInfoBean method getModel.
// ------------------------------------------------------------------------------
// Helper methods
private Map<String, Object> getModel(WorkflowTask task) {
FacesContext context = FacesContext.getCurrentInstance();
Map<String, Object> model = new HashMap<String, Object>(8, 1.0f);
I18NUtil.registerResourceBundle("alfresco.messages.webclient");
// create template api methods and objects
model.put("date", new Date());
model.put("msg", new I18NMessageMethod());
model.put("url", new BaseTemplateContentServlet.URLHelper(context));
model.put("locale", I18NUtil.getLocale());
model.put("task", new Workflow.WorkflowTaskItem(Repository.getServiceRegistry(context), this.imageResolver, task));
return model;
}
use of org.alfresco.repo.template.I18NMessageMethod in project acs-community-packaging by Alfresco.
the class TemplateMailHelperBean method notifyUser.
/**
* Send an email notification to the specified User authority
*
* @param person Person node representing the user
* @param node Node they are invited too
* @param from From text message
* @param roleText The role display label for the user invite notification
*/
public void notifyUser(NodeRef person, NodeRef node, final String from, String roleText) {
final String to = (String) this.getNodeService().getProperty(person, ContentModel.PROP_EMAIL);
if (to != null && to.length() != 0) {
String body = this.body;
if (this.usingTemplate != null) {
FacesContext fc = FacesContext.getCurrentInstance();
// use template service to format the email
NodeRef templateRef = new NodeRef(Repository.getStoreRef(), this.usingTemplate);
ServiceRegistry services = Repository.getServiceRegistry(fc);
Map<String, Object> model = DefaultModelHelper.buildDefaultModel(services, Application.getCurrentUser(fc), templateRef);
model.put("role", roleText);
model.put("space", node);
// object to allow client urls to be generated in emails
model.put("url", new BaseTemplateContentServlet.URLHelper(fc));
model.put("msg", new I18NMessageMethod());
model.put("document", node);
if (nodeService.getType(node).equals(ContentModel.TYPE_CONTENT)) {
NodeRef parentNodeRef = nodeService.getParentAssocs(node).get(0).getParentRef();
if (parentNodeRef == null) {
throw new IllegalArgumentException("Parent folder doesn't exists for node: " + node);
}
model.put("space", parentNodeRef);
}
model.put("shareUrl", UrlUtil.getShareUrl(services.getSysAdminParams()));
body = services.getTemplateService().processTemplate("freemarker", templateRef.toString(), model);
}
this.finalBody = body;
MimeMessagePreparator mailPreparer = new MimeMessagePreparator() {
public void prepare(MimeMessage mimeMessage) throws MessagingException {
MimeMessageHelper message = new MimeMessageHelper(mimeMessage);
message.setTo(to);
message.setSubject(subject);
message.setText(finalBody, MailActionExecuter.isHTML(finalBody));
message.setFrom(from);
}
};
if (logger.isDebugEnabled())
logger.debug("Sending notification email to: " + to + "\n...with subject:\n" + subject + "\n...with body:\n" + body);
try {
// Send the message
this.getMailSender().send(mailPreparer);
} catch (Throwable e) {
// don't stop the action but let admins know email is not getting sent
logger.error("Failed to send email to " + to, e);
}
}
}
Aggregations