-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e40dc34
commit 664d826
Showing
10 changed files
with
782 additions
and
260 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
188 changes: 188 additions & 0 deletions
188
modules/core/core-api/src/main/java/com/enonic/xp/mail/MailMessageParams.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,188 @@ | ||
package com.enonic.xp.mail; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Objects; | ||
|
||
import com.enonic.xp.annotation.PublicApi; | ||
|
||
@PublicApi | ||
public class MailMessageParams | ||
{ | ||
private final String[] to; | ||
|
||
private final String[] from; | ||
|
||
private final String[] cc; | ||
|
||
private final String[] bcc; | ||
|
||
private final String[] replyTo; | ||
|
||
private final String subject; | ||
|
||
private final String contentType; | ||
|
||
private final String body; | ||
|
||
private final Map<String, String> headers; | ||
|
||
private final List<Map<String, Object>> attachments; | ||
|
||
private MailMessageParams( Builder builder ) | ||
{ | ||
this.to = Objects.requireNonNullElse( builder.to, new String[]{} ); | ||
this.from = Objects.requireNonNullElse( builder.from, new String[]{} ); | ||
this.cc = Objects.requireNonNullElse( builder.cc, new String[]{} ); | ||
this.bcc = Objects.requireNonNullElse( builder.bcc, new String[]{} ); | ||
this.replyTo = Objects.requireNonNullElse( builder.replyTo, new String[]{} ); | ||
this.subject = builder.subject; | ||
this.contentType = builder.contentType; | ||
this.body = builder.body; | ||
this.headers = builder.headers; | ||
this.attachments = builder.attachments; | ||
} | ||
|
||
public static Builder create() | ||
{ | ||
return new Builder(); | ||
} | ||
|
||
public String[] getTo() | ||
{ | ||
return to; | ||
} | ||
|
||
public String[] getFrom() | ||
{ | ||
return from; | ||
} | ||
|
||
public String[] getCc() | ||
{ | ||
return cc; | ||
} | ||
|
||
public String[] getBcc() | ||
{ | ||
return bcc; | ||
} | ||
|
||
public String[] getReplyTo() | ||
{ | ||
return replyTo; | ||
} | ||
|
||
public String getSubject() | ||
{ | ||
return subject; | ||
} | ||
|
||
public String getContentType() | ||
{ | ||
return contentType; | ||
} | ||
|
||
public String getBody() | ||
{ | ||
return body; | ||
} | ||
|
||
public Map<String, String> getHeaders() | ||
{ | ||
return headers; | ||
} | ||
|
||
public List<Map<String, Object>> getAttachments() | ||
{ | ||
return attachments; | ||
} | ||
|
||
public static class Builder | ||
{ | ||
private String[] to; | ||
|
||
private String[] from; | ||
|
||
private String[] cc; | ||
|
||
private String[] bcc; | ||
|
||
private String[] replyTo; | ||
|
||
private String subject; | ||
|
||
private String contentType; | ||
|
||
private String body; | ||
|
||
private Map<String, String> headers; | ||
|
||
private List<Map<String, Object>> attachments; | ||
|
||
public Builder setTo( final String[] to ) | ||
{ | ||
this.to = to; | ||
return this; | ||
} | ||
|
||
public Builder setFrom( final String[] from ) | ||
{ | ||
this.from = from; | ||
return this; | ||
} | ||
|
||
public Builder setCc( final String[] cc ) | ||
{ | ||
this.cc = cc; | ||
return this; | ||
} | ||
|
||
public Builder setBcc( final String[] bcc ) | ||
{ | ||
this.bcc = bcc; | ||
return this; | ||
} | ||
|
||
public Builder setReplyTo( final String[] replyTo ) | ||
{ | ||
this.replyTo = replyTo; | ||
return this; | ||
} | ||
|
||
public Builder setSubject( final String subject ) | ||
{ | ||
this.subject = subject; | ||
return this; | ||
} | ||
|
||
public Builder setContentType( final String contentType ) | ||
{ | ||
this.contentType = contentType; | ||
return this; | ||
} | ||
|
||
public Builder setBody( final String body ) | ||
{ | ||
this.body = body; | ||
return this; | ||
} | ||
|
||
public Builder setHeaders( final Map<String, String> headers ) | ||
{ | ||
this.headers = headers; | ||
return this; | ||
} | ||
|
||
public Builder setAttachments( final List<Map<String, Object>> attachments ) | ||
{ | ||
this.attachments = attachments; | ||
return this; | ||
} | ||
|
||
public MailMessageParams build() | ||
{ | ||
return new MailMessageParams( this ); | ||
} | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
modules/core/core-api/src/main/java/com/enonic/xp/mail/MailService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,12 @@ | ||
package com.enonic.xp.mail; | ||
|
||
import com.enonic.xp.annotation.PublicApi; | ||
|
||
@PublicApi | ||
public interface MailService | ||
{ | ||
@Deprecated | ||
void send( MailMessage message ); | ||
|
||
void send( MailMessageParams message ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.