@OperationMethod
 public BlobList run() throws CompileException, RuntimeException {
   if (expr == null) {
     String text = script.replaceAll("&lt;", "<");
     text = text.replaceAll("&gt;", ">");
     text = text.replaceAll("&amp;", "&");
     expr = Scripting.newExpression(text);
   }
   return (BlobList) expr.eval(ctx);
 }
示例#2
0
  protected void send(DocumentModel doc)
      throws TemplateException, RenderingException, OperationException, MessagingException,
          IOException {
    // TODO should sent one by one to each recipient? and have the template
    // rendered for each recipient? Use: "mailto" var name?
    try {
      Map<String, Object> map = Scripting.initBindings(ctx);
      // do not use document wrapper which is working only in mvel.
      map.put("Document", doc);
      map.put("docUrl", MailTemplateHelper.getDocumentUrl(doc, viewId));
      map.put("subject", subject);
      map.put("to", to);
      map.put("toResolved", MailBox.fetchPersonsFromList(to, isStrict));
      map.put("from", from);
      map.put("fromResolved", MailBox.fetchPersonsFromString(from, isStrict));
      map.put("from", cc);
      map.put("fromResolved", MailBox.fetchPersonsFromList(cc, isStrict));
      map.put("from", bcc);
      map.put("fromResolved", MailBox.fetchPersonsFromList(bcc, isStrict));
      map.put("from", replyto);
      map.put("fromResolved", MailBox.fetchPersonsFromList(replyto, isStrict));
      map.put("viewId", viewId);
      map.put("baseUrl", NotificationServiceHelper.getNotificationService().getServerUrlPrefix());
      map.put("Runtime", Framework.getRuntime());
      Mailer.Message msg = createMessage(doc, getContent(), map);
      msg.setSubject(subject, "UTF-8");

      addMailBoxInfo(msg);

      msg.send();
    } catch (ClientException
        | TemplateException
        | RenderingException
        | OperationException
        | MessagingException
        | IOException e) {
      if (rollbackOnError) {
        throw e;
      } else {
        log.warn(
            String.format(
                "An error occured while trying to execute the %s operation, see complete stack trace below. Continuing chain since 'rollbackOnError' was set to false.",
                ID),
            e);
      }
    }
  }