web.identity-mgt.email-template-config-finish-ajaxprocessor.jsp Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of org.wso2.carbon.identity.mgt.ui Show documentation
Show all versions of org.wso2.carbon.identity.mgt.ui Show documentation
A custom wso2 products or solution
The newest version!
<%@page import="org.apache.axis2.context.ConfigurationContext"%>
<%@page import="org.wso2.carbon.CarbonConstants"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib uri="http://wso2.org/projects/carbon/taglibs/carbontags.jar" prefix="carbon" %>
<%@page import="org.wso2.carbon.identity.mgt.stub.dto.EmailTemplateDTO"%>
<%@page import="org.wso2.carbon.identity.mgt.ui.AccountCredentialMgtConfigClient" %>
<%@page import="org.wso2.carbon.identity.mgt.ui.EmailConfigDTO" %>
<%@ page import="org.wso2.carbon.ui.CarbonUIMessage" %>
<%@ page import="org.wso2.carbon.ui.CarbonUIUtil" %>
<%@ page import="org.wso2.carbon.utils.ServerConstants"%>
<%
String httpMethod = request.getMethod();
if (!"post".equalsIgnoreCase(httpMethod)) {
response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
return;
}
String emailSubject = request.getParameter("emailSubject");
String emailBody = request.getParameter("emailBody");
String emailFooter = request.getParameter("emailFooter");
String templateName = request.getParameter("templateName");
EmailConfigDTO emailConfig = null;
EmailTemplateDTO templateChanged = new EmailTemplateDTO();
if(emailSubject != null && emailSubject.trim().length() > 0){
templateChanged.setSubject(emailSubject);
}
if(emailBody != null && emailBody.trim().length() > 0){
templateChanged.setBody(emailBody);
}
if(emailFooter != null && emailFooter.trim().length() > 0){
templateChanged.setFooter(emailFooter);
}
if(templateName != null && templateName.trim().length() > 0){
templateChanged.setName(templateName);
}
try {
String cookie = (String) session
.getAttribute(ServerConstants.ADMIN_SERVICE_COOKIE);
String backendServerURL = CarbonUIUtil.getServerURL(config.getServletContext(),
session);
ConfigurationContext configContext = (ConfigurationContext) config
.getServletContext()
.getAttribute(CarbonConstants.CONFIGURATION_CONTEXT);
AccountCredentialMgtConfigClient configClient =
new AccountCredentialMgtConfigClient(cookie, backendServerURL, configContext);
// Load the configuration with all the templates.
emailConfig = configClient.loadEmailConfig();
// Set the changed template.
emailConfig.setTemplate(templateChanged);
// Now save the configuration with changed tempalate.
configClient.saveEmailConfig(emailConfig);
%>
<%
} catch (Exception e) {
CarbonUIMessage.sendCarbonUIMessage(e.getMessage(), CarbonUIMessage.ERROR,
request);
%>
<%
return;
}
%>