BrightSide Workbench Full Report + Source Code
org.turro.mail.message.MailUtils Class Reference

Static Public Member Functions

static String processMacrosForWeb (IContact contact, String message)
 
static String processMacros (IContact contact, String message)
 
static String processLinks (IContact contact, String message)
 
static String processLinks (String email, String message)
 
static String cleanLinks (String message)
 
static String processLiveLinks (String email, String message)
 
static String processLiveRefs (String email, String message)
 
static String cleanLiveLinks (String message)
 
static String cleanLiveRefs (String message)
 
static String processImgWidth (String message)
 
static String processUser (IContact contact, String message)
 
static String processUser (String email, String name, String message)
 
static String processUser (MailRecipient recipient, String message)
 
static String toAbsolute (String text)
 

Detailed Description

Member Function Documentation

◆ cleanLinks()

static String org.turro.mail.message.MailUtils.cleanLinks ( String  message)
static

Definition at line 69 of file elephant-mail/src/main/java/org/turro/mail/message/MailUtils.java.

69  {
70  message = cleanLiveLinks(message);
71  message = cleanLiveRefs(message);
72  return message;
73  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cleanLiveLinks()

static String org.turro.mail.message.MailUtils.cleanLiveLinks ( String  message)
static

Definition at line 119 of file elephant-mail/src/main/java/org/turro/mail/message/MailUtils.java.

119  {
120  if(message.contains("{livelink")) {
121  Pattern pat = Pattern.compile(LIVE_LINK_PATTERN);
122  Matcher mat = pat.matcher(message);
123  StringBuffer result = new StringBuffer();
124  while(mat.find()) {
125  try {
126  if(mat.groupCount() > 1 && !Strings.isBlank(mat.group(1)) && !Strings.isBlank(mat.group(2))) {
127  mat.appendReplacement(result, "<a href='" + mat.group(2) + "'>" + mat.group(1) + "</a>");
128  }
129  } catch (Exception ex) {
130  WebLoggers.severe(MailUtils.class).exception(ex).log();
131  }
132  }
133  mat.appendTail(result);
134  return result.toString();
135  }
136  return message;
137  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cleanLiveRefs()

static String org.turro.mail.message.MailUtils.cleanLiveRefs ( String  message)
static

Definition at line 139 of file elephant-mail/src/main/java/org/turro/mail/message/MailUtils.java.

139  {
140  if(message.contains("{liveref")) {
141  Pattern pat = Pattern.compile(LIVE_REF_PATTERN);
142  Matcher mat = pat.matcher(message);
143  StringBuffer result = new StringBuffer();
144  while(mat.find()) {
145  try {
146  if(mat.groupCount() > 0 && !Strings.isBlank(mat.group(1))) {
147  mat.appendReplacement(result, mat.group(1));
148  }
149  } catch (Exception ex) {
150  WebLoggers.severe(MailUtils.class).exception(ex).log();
151  }
152  }
153  mat.appendTail(result);
154  return result.toString();
155  }
156  return message;
157  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ processImgWidth()

static String org.turro.mail.message.MailUtils.processImgWidth ( String  message)
static

Definition at line 165 of file elephant-mail/src/main/java/org/turro/mail/message/MailUtils.java.

165  {
166  return message.replaceAll("\\<img ", "<img style=\"max-width:100%\" ");
167  }
Here is the caller graph for this function:

◆ processLinks() [1/2]

static String org.turro.mail.message.MailUtils.processLinks ( IContact  contact,
String  message 
)
static

Definition at line 53 of file elephant-mail/src/main/java/org/turro/mail/message/MailUtils.java.

53  {
54  if(contact != null && contact.isValid() && contact.isWebUser()) {
55  String email = contact.getConnector(IUser.CONNECTOR_EMAIL);
56  message = processLinks(email, message);
57  } else {
58  message = cleanLinks(message);
59  }
60  return message;
61  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ processLinks() [2/2]

static String org.turro.mail.message.MailUtils.processLinks ( String  email,
String  message 
)
static

Definition at line 63 of file elephant-mail/src/main/java/org/turro/mail/message/MailUtils.java.

63  {
64  message = processLiveLinks(email, message);
65  message = processLiveRefs(email, message);
66  return message;
67  }
Here is the call graph for this function:

◆ processLiveLinks()

static String org.turro.mail.message.MailUtils.processLiveLinks ( String  email,
String  message 
)
static

Definition at line 75 of file elephant-mail/src/main/java/org/turro/mail/message/MailUtils.java.

75  {
76  if(message.contains("{livelink")) {
77  Pattern pat = Pattern.compile(LIVE_LINK_PATTERN);
78  Matcher mat = pat.matcher(message);
79  StringBuffer result = new StringBuffer();
80  while(mat.find()) {
81  try {
82  if(mat.groupCount() > 1 && !Strings.isBlank(mat.group(1)) && !Strings.isBlank(mat.group(2))) {
83  String server = ElephantContext.getServerUrl("http") + "?" +
84  Actions.createActionFromElephant(email, URLDecoder.decode(mat.group(2), StandardCharsets.UTF_8.name()));
85  mat.appendReplacement(result, "<a href=\"" + server + "\">" + mat.group(1) + "</a>");
86  }
87  } catch (Exception ex) {
88  WebLoggers.severe(MailUtils.class).exception(ex).log();
89  }
90  }
91  mat.appendTail(result);
92  return result.toString();
93  }
94  return message;
95  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ processLiveRefs()

static String org.turro.mail.message.MailUtils.processLiveRefs ( String  email,
String  message 
)
static

Definition at line 97 of file elephant-mail/src/main/java/org/turro/mail/message/MailUtils.java.

97  {
98  if(message.contains("{liveref")) {
99  Pattern pat = Pattern.compile(LIVE_REF_PATTERN);
100  Matcher mat = pat.matcher(message);
101  StringBuffer result = new StringBuffer();
102  while(mat.find()) {
103  try {
104  if(mat.groupCount() > 0 && !Strings.isBlank(mat.group(1))) {
105  String server = ElephantContext.getServerUrl("http") + "?" +
106  Actions.createActionFromElephant(email, URLDecoder.decode(mat.group(1), StandardCharsets.UTF_8.name()));
107  mat.appendReplacement(result, server);
108  }
109  } catch (Exception ex) {
110  WebLoggers.severe(MailUtils.class).exception(ex).log();
111  }
112  }
113  mat.appendTail(result);
114  return result.toString();
115  }
116  return message;
117  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ processMacros()

static String org.turro.mail.message.MailUtils.processMacros ( IContact  contact,
String  message 
)
static

Definition at line 45 of file elephant-mail/src/main/java/org/turro/mail/message/MailUtils.java.

45  {
46  message = processLinks(contact, message);
47  message = processUser(contact, message);
48  return message;
49  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ processMacrosForWeb()

static String org.turro.mail.message.MailUtils.processMacrosForWeb ( IContact  contact,
String  message 
)
static

Definition at line 39 of file elephant-mail/src/main/java/org/turro/mail/message/MailUtils.java.

39  {
40  message = cleanLinks(message);
41  message = processUser(contact, message);
42  return message;
43  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ processUser() [1/3]

static String org.turro.mail.message.MailUtils.processUser ( IContact  contact,
String  message 
)
static

Definition at line 171 of file elephant-mail/src/main/java/org/turro/mail/message/MailUtils.java.

171  {
172  if(contact != null && contact.isValid() && contact.isWebUser()) {
173  message = processUser(MailRecipient.of(contact), message);
174  }
175  return message;
176  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ processUser() [2/3]

static String org.turro.mail.message.MailUtils.processUser ( MailRecipient  recipient,
String  message 
)
static

Definition at line 182 of file elephant-mail/src/main/java/org/turro/mail/message/MailUtils.java.

182  {
183  if(!recipient.isEmpty()) {
184  message = recipient.parse(message);
185  }
186  return message;
187  }
Here is the call graph for this function:

◆ processUser() [3/3]

static String org.turro.mail.message.MailUtils.processUser ( String  email,
String  name,
String  message 
)
static

Definition at line 178 of file elephant-mail/src/main/java/org/turro/mail/message/MailUtils.java.

178  {
179  return processUser(MailRecipient.of(email, name), message);
180  }
Here is the call graph for this function:

◆ toAbsolute()

static String org.turro.mail.message.MailUtils.toAbsolute ( String  text)
static

Definition at line 191 of file elephant-mail/src/main/java/org/turro/mail/message/MailUtils.java.

191  {
192  String serverBase = ElephantContext.getServerBase("http");
193  return text.replaceAll("href=\\'(?![a-z]+:)(\\/?)\\/?([^\\']*)\\'", "href=\\'" + serverBase + "$1$2\\'")
194  .replaceAll("src=\\'(?![a-z]+:)(\\/?)\\/?([^\\']*)\\'", "src=\\'" + serverBase + "$1$2\\'")
195  .replaceAll("href=\\\"(?![a-z]+:)(\\/?)\\/?([^\\\"]*)\\\"", "href=\\\"" + serverBase + "$1$2\\\"")
196  .replaceAll("src=\\\"(?![a-z]+:)(\\/?)\\/?([^\\\"]*)\\\"", "src=\\\"" + serverBase + "$1$2\\\"");
197  }
Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following file: