Class EmailService
- java.lang.Object
-
- org.pentaho.platform.plugin.services.email.EmailService
-
- All Implemented Interfaces:
org.pentaho.platform.api.email.IEmailService
public class EmailService extends Object implements org.pentaho.platform.api.email.IEmailService
Manages the email connection information- Author:
- David M. Kincade
-
-
Field Summary
Fields Modifier and Type Field Description static String
CLIENT_ID
static String
CLIENT_SECRET
static String
CODE
static String
GRANT_TYPE
static String
REDIRECT_URI
static String
SCOPE
static String
TEST_EMAIL_FAIL
static String
TEST_EMAIL_SUCCESS
-
Constructor Summary
Constructors Constructor Description EmailService()
Constructs an instance of this class using the default settings location as defined by PentahoSystemEmailService(File emailConfigFile)
Constructs an instance of this class using the specified file location as the source of the email configuration
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description EmailConfiguration
getEmailConfig()
TODO documentprotected org.pentaho.platform.api.email.IEmailAuthenticationResponse
getOAuthToken(org.pentaho.platform.api.email.IEmailConfiguration emailConfig)
boolean
isValid()
protected boolean
isValid(EmailConfiguration c)
void
sendEmail(javax.mail.Session session, javax.mail.internet.MimeMessage msg)
String
sendEmailTest(org.pentaho.platform.api.email.IEmailConfiguration emailConfig)
Tests the provided email configuration by sending a test email.protected void
sendMailGraphApi(String uri, String accessToken, String message)
protected void
sendMailGraphApi(org.pentaho.platform.api.email.IEmailConfiguration emailConfig, String accessToken, String message)
void
setEmailConfig(org.pentaho.platform.api.email.IEmailConfiguration emailConfiguration)
protected void
setEmailConfigFile(File emailConfigFile)
Validates and sets the email configuration file to the specified value.
-
-
-
Field Detail
-
GRANT_TYPE
public static final String GRANT_TYPE
- See Also:
- Constant Field Values
-
SCOPE
public static final String SCOPE
- See Also:
- Constant Field Values
-
CLIENT_ID
public static final String CLIENT_ID
- See Also:
- Constant Field Values
-
CLIENT_SECRET
public static final String CLIENT_SECRET
- See Also:
- Constant Field Values
-
CODE
public static final String CODE
- See Also:
- Constant Field Values
-
REDIRECT_URI
public static final String REDIRECT_URI
- See Also:
- Constant Field Values
-
TEST_EMAIL_FAIL
public static final String TEST_EMAIL_FAIL
- See Also:
- Constant Field Values
-
TEST_EMAIL_SUCCESS
public static final String TEST_EMAIL_SUCCESS
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
EmailService
public EmailService() throws IllegalArgumentException
Constructs an instance of this class using the default settings location as defined by PentahoSystem- Throws:
IllegalArgumentException
- Indicates that the default location for the email configuration file is invalid
-
EmailService
public EmailService(File emailConfigFile) throws IllegalArgumentException
Constructs an instance of this class using the specified file location as the source of the email configuration- Parameters:
emailConfigFile
- the file reference to the email configuration- Throws:
IllegalArgumentException
- indicates the argument is either null or references a location which is invalid (the parent folder of the specified file doesn't exist)
-
-
Method Detail
-
setEmailConfig
public void setEmailConfig(org.pentaho.platform.api.email.IEmailConfiguration emailConfiguration)
- Specified by:
setEmailConfig
in interfaceorg.pentaho.platform.api.email.IEmailService
-
getEmailConfig
public EmailConfiguration getEmailConfig()
TODO document- Specified by:
getEmailConfig
in interfaceorg.pentaho.platform.api.email.IEmailService
- Returns:
-
sendEmailTest
public String sendEmailTest(org.pentaho.platform.api.email.IEmailConfiguration emailConfig)
Tests the provided email configuration by sending a test email. This will just indicate that the server configuration is correct and a test email was successfully sent. It does not test the destination address.- Specified by:
sendEmailTest
in interfaceorg.pentaho.platform.api.email.IEmailService
- Parameters:
emailConfig
- the email configuration to test- Throws:
Exception
- indicates an error running the test (as in an invalid configuration)
-
sendEmail
public void sendEmail(javax.mail.Session session, javax.mail.internet.MimeMessage msg) throws org.pentaho.platform.api.email.EmailServiceException
- Specified by:
sendEmail
in interfaceorg.pentaho.platform.api.email.IEmailService
- Throws:
org.pentaho.platform.api.email.EmailServiceException
-
setEmailConfigFile
protected void setEmailConfigFile(File emailConfigFile) throws IllegalArgumentException
Validates and sets the email configuration file to the specified value.- Parameters:
emailConfigFile
- the email configuration file to use- Throws:
IllegalArgumentException
- indicates that the provided value is invalid (the value is null or the parent folder does not exist)
-
isValid
public boolean isValid()
- Specified by:
isValid
in interfaceorg.pentaho.platform.api.email.IEmailService
-
isValid
protected boolean isValid(EmailConfiguration c)
-
getOAuthToken
protected org.pentaho.platform.api.email.IEmailAuthenticationResponse getOAuthToken(org.pentaho.platform.api.email.IEmailConfiguration emailConfig) throws IOException, org.apache.http.HttpException
- Throws:
IOException
org.apache.http.HttpException
-
sendMailGraphApi
protected void sendMailGraphApi(org.pentaho.platform.api.email.IEmailConfiguration emailConfig, String accessToken, String message) throws org.apache.http.HttpException, IOException
- Throws:
org.apache.http.HttpException
IOException
-
sendMailGraphApi
protected void sendMailGraphApi(String uri, String accessToken, String message) throws org.apache.http.HttpException, IOException
- Throws:
org.apache.http.HttpException
IOException
-
-