BrightSide Workbench Full Report + Source Code
org.turro.plugin.contacts.MailContact Class Reference

Public Member Functions

 MailContact (IContact contact, String link, String message, String exParam)
 
String getMessage (Date validUntil, String comment)
 
String getEmail ()
 
boolean equals (Object obj)
 
int hashCode ()
 

Static Public Member Functions

static String getEmail (IContact contact)
 
static void sendToIPlayers (List< IContact > contacts, String link, String subject, String message, String comment, String exParam, String implementation)
 
static void poolToIPlayers (List< IContact > contacts, String link, String message, String comment, String exParam, MessagePool pool)
 
static String createLink (String text, String path, boolean live)
 
static String processLinkMacros (String text)
 

Detailed Description

Constructor & Destructor Documentation

◆ MailContact()

org.turro.plugin.contacts.MailContact.MailContact ( IContact  contact,
String  link,
String  message,
String  exParam 
)

Definition at line 45 of file elephant-plugins/src/main/java/org/turro/plugin/contacts/MailContact.java.

45  {
46  this.contact = contact;
47  this.link = link;
48  this.message = message;
49  this.exParam = exParam;
50  }
Here is the caller graph for this function:

Member Function Documentation

◆ createLink()

static String org.turro.plugin.contacts.MailContact.createLink ( String  text,
String  path,
boolean  live 
)
static

Definition at line 156 of file elephant-plugins/src/main/java/org/turro/plugin/contacts/MailContact.java.

156  {
157  if(!Strings.isBlank(text)) {
158  StringBuilder sb = new StringBuilder((live ? "{livelink:" : "{link:"));
159  sb.append(text.replaceAll("\\:", "&colon;").replaceAll("\\}", "&endkey;"));
160  if(!Strings.isBlank(path)) {
161  sb.append(":");
162  sb.append(path);
163  }
164  sb.append("}");
165  return sb.toString();
166  }
167  return "";
168  }

◆ equals()

boolean org.turro.plugin.contacts.MailContact.equals ( Object  obj)

Definition at line 135 of file elephant-plugins/src/main/java/org/turro/plugin/contacts/MailContact.java.

135  {
136  if (obj == null) {
137  return false;
138  }
139  if (getClass() != obj.getClass()) {
140  return false;
141  }
142  final MailContact other = (MailContact) obj;
143  if (this.contact.getId() != other.contact.getId() && (this.contact.getId() == null || !this.contact.getId().equals(other.contact.getId()))) {
144  return false;
145  }
146  return true;
147  }
MailContact(IContact contact, String link, String message, String exParam)
Here is the call graph for this function:

◆ getEmail() [1/2]

String org.turro.plugin.contacts.MailContact.getEmail ( )

◆ getEmail() [2/2]

static String org.turro.plugin.contacts.MailContact.getEmail ( IContact  contact)
static

Definition at line 97 of file elephant-plugins/src/main/java/org/turro/plugin/contacts/MailContact.java.

97  {
98  if (contact == null) {
99  return null;
100  }
101  String email = contact.getConnector(IUser.CONNECTOR_EMAIL);
102  return email == null ? null : (!Contacts.isValidEmail(email) ? null : email);
103  }
Here is the call graph for this function:

◆ getMessage()

String org.turro.plugin.contacts.MailContact.getMessage ( Date  validUntil,
String  comment 
)

Definition at line 52 of file elephant-plugins/src/main/java/org/turro/plugin/contacts/MailContact.java.

52  {
53  if(contact == null) return null;
54 
55  if(message.indexOf("{linkTmpSes}") > -1) {
56  try {
57 // String key = createTmpKey(validUntil);
58 // String server = ElephantContext.getServerUrl("http") +
59 // (exParam == null ? "?" : exParam + "&") + "tmpses=" + key;
60  String server = ElephantContext.getServerUrl("http") + "?" +
61  Actions.createAction(contact.getConnector(IUser.CONNECTOR_EMAIL), exParam);
62  message = message.replaceAll("\\{linkTmpSes\\}", "<a style=\"color:inherit\" href=\"" + server + "\">" + link + "</a>");
63  } catch (Exception ex) {
64  Logger.getLogger(MailContact.class.getName()).log(Level.SEVERE, null, ex);
65  }
66  }
67  message = processWebLiveLinks(validUntil, message);
68  message = processWebLinks(message);
69  message = processLinkMacros(message);
70 
71  message = message.replaceAll("\\{login\\}", contact.getLogin())
72  .replaceAll("\\{name\\}", contact.getName())
73  .replaceAll("\\{comment\\}", comment);
74 
75  String serverBase = ElephantContext.getServerBase("http");
76  return message.replaceAll("href=\\'(?![a-z]+:)(\\/?)\\/?([^\\']*)\\'", "href=\\'" + serverBase + "$1$2\\'")
77  .replaceAll("src=\\'(?![a-z]+:)(\\/?)\\/?([^\\']*)\\'", "src=\\'" + serverBase + "$1$2\\'")
78  .replaceAll("href=\\\"(?![a-z]+:)(\\/?)\\/?([^\\\"]*)\\\"", "href=\\\"" + serverBase + "$1$2\\\"")
79  .replaceAll("src=\\\"(?![a-z]+:)(\\/?)\\/?([^\\\"]*)\\\"", "src=\\\"" + serverBase + "$1$2\\\"");
80  }
Here is the call graph for this function:

◆ hashCode()

int org.turro.plugin.contacts.MailContact.hashCode ( )

Definition at line 150 of file elephant-plugins/src/main/java/org/turro/plugin/contacts/MailContact.java.

150  {
151  int hash = 7;
152  hash = 31 * hash + (this.contact != null && this.contact.getId() != null ? this.contact.getId().hashCode() : 0);
153  return hash;
154  }
Here is the call graph for this function:

◆ poolToIPlayers()

static void org.turro.plugin.contacts.MailContact.poolToIPlayers ( List< IContact contacts,
String  link,
String  message,
String  comment,
String  exParam,
MessagePool  pool 
)
static

Definition at line 123 of file elephant-plugins/src/main/java/org/turro/plugin/contacts/MailContact.java.

124  {
125  Set<MailContact> emails = new HashSet<MailContact>();
126  for(IContact contact : contacts) {
127  emails.add(new MailContact(contact, link, message, exParam));
128  }
129  for(MailContact mc : emails) {
130  pool.addMessage(mc.getEmail(), mc.getMessage(null, comment));
131  }
132  }
Here is the call graph for this function:

◆ processLinkMacros()

static String org.turro.plugin.contacts.MailContact.processLinkMacros ( String  text)
static

Definition at line 170 of file elephant-plugins/src/main/java/org/turro/plugin/contacts/MailContact.java.

170  {
171  if(!Strings.isBlank(text)) {
172  return text.replaceAll("\\&colon\\;", ":").replaceAll("\\&endkey\\;", "}");
173  }
174  return "";
175  }
Here is the caller graph for this function:

◆ sendToIPlayers()

static void org.turro.plugin.contacts.MailContact.sendToIPlayers ( List< IContact contacts,
String  link,
String  subject,
String  message,
String  comment,
String  exParam,
String  implementation 
)
static

Definition at line 105 of file elephant-plugins/src/main/java/org/turro/plugin/contacts/MailContact.java.

106  {
107  MailPool mp = (MailPool) HeadlessApplication.getInstance().getImplementation(implementation);
108  if(mp != null) {
109  mp.setEncoding(ElephantContext.getEncoding());
110  mp.addCssFile(ElephantContext.getRealPath("/_internal/css/mail.css"));
111 
112  Set<MailContact> emails = new HashSet<MailContact>();
113  for(IContact contact : contacts) {
114  emails.add(new MailContact(contact, link, message, exParam));
115  }
116  for(MailContact mc : emails) {
117  mp.addToPool(null, mc.getEmail(), null, subject, mc.getMessage(null, comment), "text/html");
118  }
119  mp.sendPool();
120  }
121  }

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