Search in sources :

Example 31 with I10nProfileException

use of org.craftercms.profile.api.exceptions.I10nProfileException in project profile by craftercms.

the class VerificationServiceImpl method sendEmail.

@Override
@Async
public void sendEmail(VerificationToken token, Profile profile, String verificationBaseUrl, String from, String subject, String templateName) throws ProfileException {
    String verificationUrl = createVerificationUrl(verificationBaseUrl, token.getId().toString());
    Map<String, String> templateArgs = Collections.singletonMap(VERIFICATION_LINK_TEMPLATE_ARG, verificationUrl);
    String[] to = new String[] { profile.getEmail() };
    try {
        emailFactory.getEmail(from, to, null, null, subject, templateName, templateArgs, true).send();
        logger.debug(LOG_KEY_EMAIL_SENT, profile.getId(), profile.getEmail());
    } catch (EmailException e) {
        throw new I10nProfileException(ERROR_KEY_EMAIL_ERROR, e, profile.getEmail());
    }
}
Also used : I10nProfileException(org.craftercms.profile.api.exceptions.I10nProfileException) EmailException(org.craftercms.commons.mail.EmailException) Async(org.springframework.scheduling.annotation.Async)

Aggregations

I10nProfileException (org.craftercms.profile.api.exceptions.I10nProfileException)31 MongoDataException (org.craftercms.commons.mongo.MongoDataException)26 Profile (org.craftercms.profile.api.Profile)15 Date (java.util.Date)7 Tenant (org.craftercms.profile.api.Tenant)5 Ticket (org.craftercms.profile.api.Ticket)4 URI (java.net.URI)3 URISyntaxException (java.net.URISyntaxException)3 DuplicateKeyException (org.craftercms.commons.mongo.DuplicateKeyException)3 PersistentLogin (org.craftercms.profile.api.PersistentLogin)3 DisabledProfileException (org.craftercms.profile.exceptions.DisabledProfileException)3 UpdateHelper (org.craftercms.commons.mongo.UpdateHelper)2 VerificationToken (org.craftercms.profile.api.VerificationToken)2 File (java.io.File)1 IOException (java.io.IOException)1 EmailException (org.craftercms.commons.mail.EmailException)1 AttributeDefinition (org.craftercms.profile.api.AttributeDefinition)1 AccessTokenExistsException (org.craftercms.profile.exceptions.AccessTokenExistsException)1 BadCredentialsException (org.craftercms.profile.exceptions.BadCredentialsException)1 InvalidEmailAddressException (org.craftercms.profile.exceptions.InvalidEmailAddressException)1