use of org.wso2.carbon.identity.api.server.notification.sender.v1.model.EmailSenderUpdateRequest in project identity-api-server by wso2.
the class NotificationSenderManagementService method updateEmailSender.
/**
* Update email sender details by name.
*
* @param senderName Email sender's name.
* @param emailSenderUpdateRequest Email sender's updated configurations.
* @return Updated email sender.
*/
public EmailSender updateEmailSender(String senderName, EmailSenderUpdateRequest emailSenderUpdateRequest) {
Resource emailSenderResource = null;
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
EventPublisherConfiguration publisherInSuperTenant = validateEmailSenderUpdateRequestAndGetPublisherInSuperTenant(senderName, tenantId);
EmailSenderAdd emailSenderAdd = buildEmailSenderAddFromEmailSenderUpdateRequest(senderName, emailSenderUpdateRequest);
addDefaultProperties(emailSenderAdd, publisherInSuperTenant);
try {
InputStream inputStream = generateEmailPublisher(emailSenderAdd);
emailSenderResource = buildResourceFromEmailSenderAdd(emailSenderAdd, inputStream);
NotificationSenderServiceHolder.getNotificationSenderConfigManager().replaceResource(PUBLISHER_RESOURCE_TYPE, emailSenderResource);
reDeployEmailSenderResource(emailSenderResource.getFiles().get(0));
} catch (ConfigurationManagementException e) {
throw handleConfigurationMgtException(e, ERROR_CODE_ERROR_UPDATING_NOTIFICATION_SENDER, senderName);
} catch (ParserConfigurationException e) {
throw handleException(Response.Status.INTERNAL_SERVER_ERROR, ERROR_CODE_PARSER_CONFIG_EXCEPTION, e.getMessage());
} catch (TransformerException e) {
throw handleException(Response.Status.INTERNAL_SERVER_ERROR, ERROR_CODE_TRANSFORMER_EXCEPTION, e.getMessage());
}
return buildEmailSenderFromResource(emailSenderResource);
}
use of org.wso2.carbon.identity.api.server.notification.sender.v1.model.EmailSenderUpdateRequest in project identity-api-server by wso2.
the class NotificationSenderManagementService method buildEmailSenderAddFromEmailSenderUpdateRequest.
/**
* Build email sender add object from email sender update request.
*
* @param senderName Email sender's name.
* @param emailSenderUpdateRequest Email sender's update request body.
* @return Email sender add object
*/
private EmailSenderAdd buildEmailSenderAddFromEmailSenderUpdateRequest(String senderName, EmailSenderUpdateRequest emailSenderUpdateRequest) {
EmailSenderAdd emailSenderAdd = new EmailSenderAdd();
emailSenderAdd.setName(senderName);
emailSenderAdd.setSmtpServerHost(emailSenderUpdateRequest.getSmtpServerHost());
emailSenderAdd.setSmtpPort(emailSenderUpdateRequest.getSmtpPort());
emailSenderAdd.setFromAddress(emailSenderUpdateRequest.getFromAddress());
emailSenderAdd.setUserName(emailSenderUpdateRequest.getUserName());
emailSenderAdd.setPassword(emailSenderUpdateRequest.getPassword());
emailSenderAdd.setProperties(emailSenderUpdateRequest.getProperties());
return emailSenderAdd;
}
Aggregations