mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
No effective change - format only
This commit is contained in:
@@ -9,35 +9,35 @@ public class MailAddress {
|
||||
final String alias;
|
||||
|
||||
final String emailAddress;
|
||||
|
||||
/**
|
||||
* Create an address with an optional alias.
|
||||
*/
|
||||
public MailAddress(String alias, String emailAddress){
|
||||
this.alias = alias;
|
||||
this.emailAddress = emailAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the alias.
|
||||
* If the alias is null this returns an empty string.
|
||||
*/
|
||||
public String getAlias() {
|
||||
if (alias == null){
|
||||
return "";
|
||||
}
|
||||
return alias;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the email address.
|
||||
*/
|
||||
public String getEmailAddress(){
|
||||
return emailAddress;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return getAlias() + " " + "<" + getEmailAddress() + ">";
|
||||
|
||||
/**
|
||||
* Create an address with an optional alias.
|
||||
*/
|
||||
public MailAddress(String alias, String emailAddress) {
|
||||
this.alias = alias;
|
||||
this.emailAddress = emailAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the alias.
|
||||
* If the alias is null this returns an empty string.
|
||||
*/
|
||||
public String getAlias() {
|
||||
if (alias == null) {
|
||||
return "";
|
||||
}
|
||||
return alias;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the email address.
|
||||
*/
|
||||
public String getEmailAddress() {
|
||||
return emailAddress;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return getAlias() + " " + "<" + getEmailAddress() + ">";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,44 +6,44 @@ package com.avaje.ebeaninternal.server.lib.util;
|
||||
public class MailEvent {
|
||||
|
||||
|
||||
/**
|
||||
* The error indicating a send failure.
|
||||
*/
|
||||
final Throwable error;
|
||||
|
||||
/**
|
||||
* The message that was sent.
|
||||
*/
|
||||
final MailMessage message;
|
||||
|
||||
|
||||
/**
|
||||
* The message send failed with an error.
|
||||
*/
|
||||
public MailEvent(MailMessage message, Throwable error){
|
||||
this.message = message;
|
||||
this.error = error;
|
||||
}
|
||||
|
||||
/**
|
||||
* The message that we attempted to send.
|
||||
*/
|
||||
public MailMessage getMailMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the message was sent successfully.
|
||||
*/
|
||||
public boolean wasSuccessful() {
|
||||
return (error == null);
|
||||
}
|
||||
|
||||
/**
|
||||
* The error indicating the send failed.
|
||||
*/
|
||||
public Throwable getError() {
|
||||
return error;
|
||||
}
|
||||
/**
|
||||
* The error indicating a send failure.
|
||||
*/
|
||||
final Throwable error;
|
||||
|
||||
/**
|
||||
* The message that was sent.
|
||||
*/
|
||||
final MailMessage message;
|
||||
|
||||
|
||||
/**
|
||||
* The message send failed with an error.
|
||||
*/
|
||||
public MailEvent(MailMessage message, Throwable error) {
|
||||
this.message = message;
|
||||
this.error = error;
|
||||
}
|
||||
|
||||
/**
|
||||
* The message that we attempted to send.
|
||||
*/
|
||||
public MailMessage getMailMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the message was sent successfully.
|
||||
*/
|
||||
public boolean wasSuccessful() {
|
||||
return (error == null);
|
||||
}
|
||||
|
||||
/**
|
||||
* The error indicating the send failed.
|
||||
*/
|
||||
public Throwable getError() {
|
||||
return error;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,9 +5,9 @@ package com.avaje.ebeaninternal.server.lib.util;
|
||||
*/
|
||||
public interface MailListener {
|
||||
|
||||
/**
|
||||
* Handle the message event.
|
||||
*/
|
||||
void handleEvent(MailEvent event);
|
||||
|
||||
/**
|
||||
* Handle the message event.
|
||||
*/
|
||||
void handleEvent(MailEvent event);
|
||||
|
||||
}
|
||||
|
||||
@@ -11,141 +11,142 @@ import java.util.List;
|
||||
*/
|
||||
public class MailMessage {
|
||||
|
||||
/**
|
||||
* The body content.
|
||||
*/
|
||||
final ArrayList<String> bodylines;
|
||||
/**
|
||||
* The body content.
|
||||
*/
|
||||
final ArrayList<String> bodylines;
|
||||
|
||||
/**
|
||||
* The sender email address.
|
||||
*/
|
||||
MailAddress senderAddress;
|
||||
/**
|
||||
* The sender email address.
|
||||
*/
|
||||
MailAddress senderAddress;
|
||||
|
||||
/**
|
||||
* The headers.
|
||||
*/
|
||||
final HashMap<String,String> header = new HashMap<String, String>();
|
||||
/**
|
||||
* The headers.
|
||||
*/
|
||||
final HashMap<String, String> header = new HashMap<String, String>();
|
||||
|
||||
/**
|
||||
* the recipient of the email.
|
||||
*/
|
||||
MailAddress currentRecipient;
|
||||
|
||||
/**
|
||||
* The list of recipients.
|
||||
*/
|
||||
final ArrayList<MailAddress> recipientList = new ArrayList<MailAddress>();
|
||||
|
||||
/**
|
||||
* Create the message.
|
||||
*/
|
||||
public MailMessage() {
|
||||
bodylines = new ArrayList<String>();
|
||||
}
|
||||
/**
|
||||
* the recipient of the email.
|
||||
*/
|
||||
MailAddress currentRecipient;
|
||||
|
||||
/**
|
||||
* Set the current recipient.
|
||||
*/
|
||||
public void setCurrentRecipient(MailAddress currentRecipient){
|
||||
this.currentRecipient = currentRecipient;
|
||||
}
|
||||
/**
|
||||
* The list of recipients.
|
||||
*/
|
||||
final ArrayList<MailAddress> recipientList = new ArrayList<MailAddress>();
|
||||
|
||||
/**
|
||||
* Return the current recipient.
|
||||
*/
|
||||
public MailAddress getCurrentRecipient() {
|
||||
return currentRecipient;
|
||||
}
|
||||
/**
|
||||
* Create the message.
|
||||
*/
|
||||
public MailMessage() {
|
||||
bodylines = new ArrayList<String>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a recipient.
|
||||
*/
|
||||
public void addRecipient(String alias, String emailAddress){
|
||||
recipientList.add(new MailAddress(alias, emailAddress));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the sender details.
|
||||
*/
|
||||
public void setSender(String alias, String senderEmail){
|
||||
this.senderAddress = new MailAddress(alias, senderEmail);
|
||||
}
|
||||
/**
|
||||
* Return the sender address.
|
||||
*/
|
||||
public MailAddress getSender() {
|
||||
return senderAddress;
|
||||
}
|
||||
/**
|
||||
* Set the current recipient.
|
||||
*/
|
||||
public void setCurrentRecipient(MailAddress currentRecipient) {
|
||||
this.currentRecipient = currentRecipient;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the recipient list.
|
||||
*/
|
||||
public List<MailAddress> getRecipientList() {
|
||||
return recipientList;
|
||||
}
|
||||
/**
|
||||
* Return the current recipient.
|
||||
*/
|
||||
public MailAddress getCurrentRecipient() {
|
||||
return currentRecipient;
|
||||
}
|
||||
|
||||
/**
|
||||
* add a header to the message.
|
||||
*/
|
||||
public void addHeader(String key, String val) {
|
||||
header.put(key, val);
|
||||
}
|
||||
/**
|
||||
* Add a recipient.
|
||||
*/
|
||||
public void addRecipient(String alias, String emailAddress) {
|
||||
recipientList.add(new MailAddress(alias, emailAddress));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the subject text.
|
||||
*/
|
||||
public void setSubject(String subject){
|
||||
addHeader("Subject", subject);
|
||||
}
|
||||
/**
|
||||
* Set the sender details.
|
||||
*/
|
||||
public void setSender(String alias, String senderEmail) {
|
||||
this.senderAddress = new MailAddress(alias, senderEmail);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the subject text.
|
||||
*/
|
||||
public String getSubject() {
|
||||
return getHeader("Subject");
|
||||
}
|
||||
/**
|
||||
* Return the sender address.
|
||||
*/
|
||||
public MailAddress getSender() {
|
||||
return senderAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add text to the body.
|
||||
*/
|
||||
public void addBodyLine(String line) {
|
||||
bodylines.add(line);
|
||||
}
|
||||
/**
|
||||
* Return the recipient list.
|
||||
*/
|
||||
public List<MailAddress> getRecipientList() {
|
||||
return recipientList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the body text.
|
||||
*/
|
||||
public List<String> getBodyLines() {
|
||||
return bodylines;
|
||||
}
|
||||
/**
|
||||
* add a header to the message.
|
||||
*/
|
||||
public void addHeader(String key, String val) {
|
||||
header.put(key, val);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the headers.
|
||||
*/
|
||||
public Collection<String> getHeaderFields() {
|
||||
return header.keySet();
|
||||
}
|
||||
/**
|
||||
* Set the subject text.
|
||||
*/
|
||||
public void setSubject(String subject) {
|
||||
addHeader("Subject", subject);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a given header.
|
||||
*/
|
||||
public String getHeader(String key) {
|
||||
return header.get(key);
|
||||
}
|
||||
/**
|
||||
* Return the subject text.
|
||||
*/
|
||||
public String getSubject() {
|
||||
return getHeader("Subject");
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder(100);
|
||||
sb.append("Sender: ").append(senderAddress ).append("\tRecipient: ").append(recipientList).append("\n");
|
||||
for (String key : header.keySet()) {
|
||||
String hline = key + ": " + header.get(key) + "\n";
|
||||
sb.append(hline);
|
||||
}
|
||||
sb.append("\n");
|
||||
for (String line : bodylines) {
|
||||
sb.append(line).append("\n");
|
||||
}
|
||||
return sb.toString();
|
||||
/**
|
||||
* Add text to the body.
|
||||
*/
|
||||
public void addBodyLine(String line) {
|
||||
bodylines.add(line);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the body text.
|
||||
*/
|
||||
public List<String> getBodyLines() {
|
||||
return bodylines;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the headers.
|
||||
*/
|
||||
public Collection<String> getHeaderFields() {
|
||||
return header.keySet();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a given header.
|
||||
*/
|
||||
public String getHeader(String key) {
|
||||
return header.get(key);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder(100);
|
||||
sb.append("Sender: ").append(senderAddress).append("\tRecipient: ").append(recipientList).append("\n");
|
||||
for (String key : header.keySet()) {
|
||||
String hline = key + ": " + header.get(key) + "\n";
|
||||
sb.append(hline);
|
||||
}
|
||||
sb.append("\n");
|
||||
for (String line : bodylines) {
|
||||
sb.append(line).append("\n");
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package com.avaje.ebeaninternal.server.lib.util;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
@@ -8,9 +11,6 @@ import java.net.InetAddress;
|
||||
import java.net.Socket;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Sends simple MailMessages via smtp.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user