Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add unicode data type support for notification templates #274

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ private I18nMgtConstants() {}

public static final String NOTIFICATION_TEMPLATES_STORAGE_CONFIG = "DataStorageType.NotificationTemplates";
public static final String NOTIFICATION_TEMPLATES_LEGACY_TENANTS = "NotificationTemplates.LegacyTenants.Tenant";
public static final String NOTIFICATION_TEMPLATES_USE_UNICODE_DATA_TYPES =
"NotificationTemplates.UseUnicodeDataTypes";

public static final String SERVICE_PROPERTY_KEY_SERVICE_NAME = "service.name";
public static final String SERVICE_PROPERTY_VAL_EMAIL_TEMPLATE_MANAGER = "EmailTemplateManager";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,27 @@ public class SQLConstants {
"DELETE FROM IDN_NOTIFICATION_ORG_TEMPLATE WHERE TYPE_ID = (" + GET_NOTIFICATION_TYPE_ID_SQL +
") AND TENANT_ID = :TENANT_ID;";

// sql constants for org notification template with unicode datatypes
public static final String INSERT_ORG_NOTIFICATION_TEMPLATE_SQL_UNICODE =
"INSERT INTO IDN_NOTIFICATION_ORG_TEMPLATE " +
"(TEMPLATE_KEY, LOCALE, NSUBJECT, NBODY, NFOOTER, CONTENT_TYPE, TYPE_ID, TENANT_ID) " +
UdeshAthukorala marked this conversation as resolved.
Show resolved Hide resolved
"VALUES (:TEMPLATE_KEY;, :LOCALE;, :SUBJECT;, :BODY;, :FOOTER;, :CONTENT_TYPE;, (" +
GET_NOTIFICATION_TYPE_ID_SQL + "), :TENANT_ID;)";
public static final String GET_ORG_NOTIFICATION_TEMPLATE_SQL_UNICODE =
"SELECT NSUBJECT AS SUBJECT, NBODY AS BODY, NFOOTER AS FOOTER, CONTENT_TYPE" +
"FROM IDN_NOTIFICATION_ORG_TEMPLATE " +
"WHERE TEMPLATE_KEY = :TEMPLATE_KEY; AND TYPE_ID = (" + GET_NOTIFICATION_TYPE_ID_SQL +
") AND TENANT_ID = :TENANT_ID;";
public static final String LIST_ORG_NOTIFICATION_TEMPLATES_BY_TYPE_SQL_UNICODE =
"SELECT NSUBJECT AS SUBJECT, NBODY AS BODY, NFOOTER AS FOOTER, CONTENT_TYPE, LOCALE " +
"FROM IDN_NOTIFICATION_ORG_TEMPLATE " +
"WHERE TYPE_ID = (" + GET_NOTIFICATION_TYPE_ID_SQL + ") AND TENANT_ID = :TENANT_ID;";
public static final String UPDATE_ORG_NOTIFICATION_TEMPLATE_SQL_UNICODE =
"UPDATE IDN_NOTIFICATION_ORG_TEMPLATE " +
"SET NSUBJECT = :SUBJECT;, NBODY = :BODY;, NFOOTER = :FOOTER;, CONTENT_TYPE = :CONTENT_TYPE; " +
"WHERE TEMPLATE_KEY = :TEMPLATE_KEY; AND TYPE_ID = (" + GET_NOTIFICATION_TYPE_ID_SQL +
") AND TENANT_ID = :TENANT_ID;";

// sql constants for app notification template
public static final String INSERT_APP_NOTIFICATION_TEMPLATE_SQL =
"INSERT INTO IDN_NOTIFICATION_APP_TEMPLATE " +
Expand Down Expand Up @@ -100,4 +121,26 @@ public class SQLConstants {
public static final String DELETE_ALL_APP_NOTIFICATION_TEMPLATES_BY_TYPE_SQL =
"DELETE FROM IDN_NOTIFICATION_APP_TEMPLATE WHERE TYPE_ID = (" + GET_NOTIFICATION_TYPE_ID_SQL +
") AND TENANT_ID = :TENANT_ID;";

// sql constants for org notification template with unicode datatypes
public static final String INSERT_APP_NOTIFICATION_TEMPLATE_SQL_UNICODE =
"INSERT INTO IDN_NOTIFICATION_APP_TEMPLATE " +
"(TEMPLATE_KEY, LOCALE, NSUBJECT, NBODY, NFOOTER, CONTENT_TYPE, TYPE_ID, APP_ID, TENANT_ID) " +
"VALUES (:TEMPLATE_KEY;, :LOCALE;, :SUBJECT;, :BODY;, :FOOTER;, :CONTENT_TYPE;, (" +
GET_NOTIFICATION_TYPE_ID_SQL + "), :APP_ID;, :TENANT_ID;)";
public static final String GET_APP_NOTIFICATION_TEMPLATE_SQL_UNICODE =
"SELECT NSUBJECT AS SUBJECT, NBODY AS BODY, NFOOTER AS FOOTER, CONTENT_TYPE " +
"FROM IDN_NOTIFICATION_APP_TEMPLATE " +
"WHERE TEMPLATE_KEY = :TEMPLATE_KEY; AND TYPE_ID = (" + GET_NOTIFICATION_TYPE_ID_SQL +
") AND APP_ID = :APP_ID; AND TENANT_ID = :TENANT_ID;";
public static final String LIST_APP_NOTIFICATION_TEMPLATES_BY_APP_SQL_UNICODE =
"SELECT NSUBJECT AS SUBJECT, NBODY AS BODY, NFOOTER AS FOOTER, CONTENT_TYPE, LOCALE " +
"FROM IDN_NOTIFICATION_APP_TEMPLATE " +
"WHERE TYPE_ID = (" + GET_NOTIFICATION_TYPE_ID_SQL +
") AND APP_ID = :APP_ID; AND TENANT_ID = :TENANT_ID;";
public static final String UPDATE_APP_NOTIFICATION_TEMPLATE_SQL_UNICODE =
"UPDATE IDN_NOTIFICATION_APP_TEMPLATE " +
"SET NSUBJECT = :SUBJECT;, NBODY = :BODY;, NFOOTER = :FOOTER;, CONTENT_TYPE = :CONTENT_TYPE; " +
"WHERE TEMPLATE_KEY = :TEMPLATE_KEY; AND TYPE_ID = (" + GET_NOTIFICATION_TYPE_ID_SQL +
") AND APP_ID = :APP_ID; AND TENANT_ID = :TENANT_ID;";
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class I18nMgtDataHolder{
private List<NotificationTemplate> defaultEmailTemplates = new ArrayList<>();
private List<NotificationTemplate> defaultSMSTemplates = new ArrayList<>();
private List<String> legacyTenants = new ArrayList<>();
private boolean useUnicodeDataTypes;

private static I18nMgtDataHolder instance = new I18nMgtDataHolder();

Expand Down Expand Up @@ -160,4 +161,24 @@ public List<String> getLegacyTenants() {

return legacyTenants;
}

/**
* Sets whether the database should use native Unicode data types (e.g., NVARCHAR, NCHAR).
*
* @param useUnicodeDataTypes true to enable Unicode data types, false to disable.
*/
public void setUseUnicodeDataTypes(boolean useUnicodeDataTypes) {

this.useUnicodeDataTypes = useUnicodeDataTypes;
}

/**
* Gets whether the database uses native Unicode data types (e.g., NVARCHAR, NCHAR).
*
* @return true if the database uses Unicode data types; false otherwise.
*/
public boolean isUseUnicodeDataTypes() {

return useUnicodeDataTypes;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,21 @@
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.component.ComponentContext;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.email.mgt.EmailTemplateManager;
import org.wso2.carbon.email.mgt.EmailTemplateManagerImpl;
import org.wso2.carbon.email.mgt.NotificationTemplateManagerImpl;
import org.wso2.carbon.email.mgt.SMSProviderPayloadTemplateManager;
import org.wso2.carbon.email.mgt.SMSProviderPayloadTemplateManagerImpl;
import org.wso2.carbon.email.mgt.constants.I18nMgtConstants;
import org.wso2.carbon.email.mgt.exceptions.I18nEmailMgtException;
import org.wso2.carbon.email.mgt.model.SMSProviderTemplate;
import org.wso2.carbon.identity.application.mgt.ApplicationManagementService;
import org.wso2.carbon.identity.core.persistence.registry.RegistryResourceMgtService;
import org.wso2.carbon.identity.governance.exceptions.notiification.NotificationTemplateManagerException;
import org.wso2.carbon.identity.core.util.IdentityUtil;
import org.wso2.carbon.identity.governance.model.NotificationTemplate;
import org.wso2.carbon.identity.governance.service.notification.NotificationChannels;
import org.wso2.carbon.identity.governance.service.notification.NotificationTemplateManager;
import org.wso2.carbon.identity.organization.management.service.OrganizationManager;
import org.wso2.carbon.registry.core.service.RegistryService;
import org.wso2.carbon.stratos.common.listeners.TenantMgtListener;
import org.wso2.carbon.user.core.service.RealmService;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
Expand Down Expand Up @@ -72,6 +68,7 @@
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;

import static org.wso2.carbon.email.mgt.constants.I18nMgtConstants.NOTIFICATION_TEMPLATES_USE_UNICODE_DATA_TYPES;
import static org.wso2.carbon.email.mgt.constants.I18nMgtConstants.NOTIFICATION_TEMPLATES_LEGACY_TENANTS;
import static org.wso2.carbon.email.mgt.constants.I18nMgtConstants.SERVICE_PROPERTY_KEY_SERVICE_NAME;
import static org.wso2.carbon.email.mgt.constants.I18nMgtConstants.SERVICE_PROPERTY_VAL_EMAIL_TEMPLATE_MANAGER;
Expand Down Expand Up @@ -103,6 +100,9 @@ protected void activate(ComponentContext context) {
List<String> legacyTenants = IdentityUtil.getPropertyAsList(NOTIFICATION_TEMPLATES_LEGACY_TENANTS);
I18nMgtDataHolder.getInstance().setLegacyTenants(legacyTenants);

String useUnicodeDataTypesProp = IdentityUtil.getProperty(NOTIFICATION_TEMPLATES_USE_UNICODE_DATA_TYPES);
I18nMgtDataHolder.getInstance().setUseUnicodeDataTypes(Boolean.parseBoolean(useUnicodeDataTypesProp));

// Register Email Mgt Service as an OSGi service.
EmailTemplateManagerImpl emailTemplateManager = new EmailTemplateManagerImpl();
ServiceRegistration emailTemplateSR = bundleCtx.registerService(EmailTemplateManager.class.getName(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import org.wso2.carbon.database.utils.jdbc.NamedJdbcTemplate;
import org.wso2.carbon.database.utils.jdbc.exceptions.DataAccessException;
import org.wso2.carbon.email.mgt.internal.I18nMgtDataHolder;
import org.wso2.carbon.identity.core.util.JdbcUtils;
import org.wso2.carbon.identity.governance.exceptions.notiification.NotificationTemplateManagerServerException;
import org.wso2.carbon.identity.governance.model.NotificationTemplate;
Expand All @@ -42,17 +43,23 @@
import static org.wso2.carbon.email.mgt.constants.SQLConstants.DELETE_APP_NOTIFICATION_TEMPLATES_BY_TYPE_SQL;
import static org.wso2.carbon.email.mgt.constants.SQLConstants.DELETE_APP_NOTIFICATION_TEMPLATE_SQL;
import static org.wso2.carbon.email.mgt.constants.SQLConstants.GET_APP_NOTIFICATION_TEMPLATE_SQL;
import static org.wso2.carbon.email.mgt.constants.SQLConstants.GET_APP_NOTIFICATION_TEMPLATE_SQL_UNICODE;
import static org.wso2.carbon.email.mgt.constants.SQLConstants.GET_NOTIFICATION_TYPE_ID_SQL;
import static org.wso2.carbon.email.mgt.constants.SQLConstants.INSERT_APP_NOTIFICATION_TEMPLATE_SQL;
import static org.wso2.carbon.email.mgt.constants.SQLConstants.INSERT_APP_NOTIFICATION_TEMPLATE_SQL_UNICODE;
import static org.wso2.carbon.email.mgt.constants.SQLConstants.IS_APP_NOTIFICATION_TEMPLATE_EXISTS_SQL;
import static org.wso2.carbon.email.mgt.constants.SQLConstants.LIST_APP_NOTIFICATION_TEMPLATES_BY_APP_SQL;
import static org.wso2.carbon.email.mgt.constants.SQLConstants.LIST_APP_NOTIFICATION_TEMPLATES_BY_APP_SQL_UNICODE;
import static org.wso2.carbon.email.mgt.constants.SQLConstants.UPDATE_APP_NOTIFICATION_TEMPLATE_SQL;
import static org.wso2.carbon.email.mgt.constants.SQLConstants.UPDATE_APP_NOTIFICATION_TEMPLATE_SQL_UNICODE;

/**
* This class is to perform CRUD operations for Application NotificationTemplates.
*/
public class AppNotificationTemplateDAO {

private boolean useUnicodeDataTypes = I18nMgtDataHolder.getInstance().isUseUnicodeDataTypes();

public void addNotificationTemplate(NotificationTemplate notificationTemplate, String applicationUuid, int tenantId)
throws NotificationTemplateManagerServerException {

Expand All @@ -62,12 +69,21 @@

NamedJdbcTemplate namedJdbcTemplate = JdbcUtils.getNewNamedJdbcTemplate();
try {
namedJdbcTemplate.executeInsert(INSERT_APP_NOTIFICATION_TEMPLATE_SQL, (preparedStatement -> {
String insertAppNotificationTemplateSql =
useUnicodeDataTypes ? INSERT_APP_NOTIFICATION_TEMPLATE_SQL_UNICODE :
INSERT_APP_NOTIFICATION_TEMPLATE_SQL;
namedJdbcTemplate.executeInsert(insertAppNotificationTemplateSql, (preparedStatement -> {

Check warning on line 75 in components/email-mgt/org.wso2.carbon.email.mgt/src/main/java/org/wso2/carbon/email/mgt/store/dao/AppNotificationTemplateDAO.java

View check run for this annotation

Codecov / codecov/patch

components/email-mgt/org.wso2.carbon.email.mgt/src/main/java/org/wso2/carbon/email/mgt/store/dao/AppNotificationTemplateDAO.java#L74-L75

Added lines #L74 - L75 were not covered by tests
preparedStatement.setString(TEMPLATE_KEY, locale.toLowerCase());
preparedStatement.setString(LOCALE, locale);
preparedStatement.setString(SUBJECT, notificationTemplate.getSubject());
preparedStatement.setString(BODY, notificationTemplate.getBody());
preparedStatement.setString(FOOTER, notificationTemplate.getFooter());
if (useUnicodeDataTypes) {
preparedStatement.setNString(SUBJECT, notificationTemplate.getSubject());
preparedStatement.setNString(BODY, notificationTemplate.getBody());
preparedStatement.setNString(FOOTER, notificationTemplate.getFooter());

Check warning on line 81 in components/email-mgt/org.wso2.carbon.email.mgt/src/main/java/org/wso2/carbon/email/mgt/store/dao/AppNotificationTemplateDAO.java

View check run for this annotation

Codecov / codecov/patch

components/email-mgt/org.wso2.carbon.email.mgt/src/main/java/org/wso2/carbon/email/mgt/store/dao/AppNotificationTemplateDAO.java#L79-L81

Added lines #L79 - L81 were not covered by tests
} else {
preparedStatement.setString(SUBJECT, notificationTemplate.getSubject());
preparedStatement.setString(BODY, notificationTemplate.getBody());
preparedStatement.setString(FOOTER, notificationTemplate.getFooter());

Check warning on line 85 in components/email-mgt/org.wso2.carbon.email.mgt/src/main/java/org/wso2/carbon/email/mgt/store/dao/AppNotificationTemplateDAO.java

View check run for this annotation

Codecov / codecov/patch

components/email-mgt/org.wso2.carbon.email.mgt/src/main/java/org/wso2/carbon/email/mgt/store/dao/AppNotificationTemplateDAO.java#L83-L85

Added lines #L83 - L85 were not covered by tests
}
preparedStatement.setString(CONTENT_TYPE, notificationTemplate.getContentType());
preparedStatement.setString(TYPE_KEY, displayName.toLowerCase());
preparedStatement.setString(CHANNEL, channelName);
Expand All @@ -91,12 +107,20 @@
NotificationTemplate notificationTemplate;

try {
notificationTemplate = namedJdbcTemplate.fetchSingleRecord(GET_APP_NOTIFICATION_TEMPLATE_SQL,
String getAppNotificationTemplateSql =
useUnicodeDataTypes ? GET_APP_NOTIFICATION_TEMPLATE_SQL_UNICODE : GET_APP_NOTIFICATION_TEMPLATE_SQL;
notificationTemplate = namedJdbcTemplate.fetchSingleRecord(getAppNotificationTemplateSql,

Check warning on line 112 in components/email-mgt/org.wso2.carbon.email.mgt/src/main/java/org/wso2/carbon/email/mgt/store/dao/AppNotificationTemplateDAO.java

View check run for this annotation

Codecov / codecov/patch

components/email-mgt/org.wso2.carbon.email.mgt/src/main/java/org/wso2/carbon/email/mgt/store/dao/AppNotificationTemplateDAO.java#L112

Added line #L112 was not covered by tests
(resultSet, rowNumber) -> {
NotificationTemplate notificationTemplateResult = new NotificationTemplate();
notificationTemplateResult.setSubject(resultSet.getString(SUBJECT));
notificationTemplateResult.setBody(resultSet.getString(BODY));
notificationTemplateResult.setFooter(resultSet.getString(FOOTER));
if (useUnicodeDataTypes) {
notificationTemplateResult.setSubject(resultSet.getNString(SUBJECT));
notificationTemplateResult.setBody(resultSet.getNString(BODY));
notificationTemplateResult.setFooter(resultSet.getNString(FOOTER));

Check warning on line 118 in components/email-mgt/org.wso2.carbon.email.mgt/src/main/java/org/wso2/carbon/email/mgt/store/dao/AppNotificationTemplateDAO.java

View check run for this annotation

Codecov / codecov/patch

components/email-mgt/org.wso2.carbon.email.mgt/src/main/java/org/wso2/carbon/email/mgt/store/dao/AppNotificationTemplateDAO.java#L116-L118

Added lines #L116 - L118 were not covered by tests
} else {
notificationTemplateResult.setSubject(resultSet.getString(SUBJECT));
notificationTemplateResult.setBody(resultSet.getString(BODY));
notificationTemplateResult.setFooter(resultSet.getString(FOOTER));

Check warning on line 122 in components/email-mgt/org.wso2.carbon.email.mgt/src/main/java/org/wso2/carbon/email/mgt/store/dao/AppNotificationTemplateDAO.java

View check run for this annotation

Codecov / codecov/patch

components/email-mgt/org.wso2.carbon.email.mgt/src/main/java/org/wso2/carbon/email/mgt/store/dao/AppNotificationTemplateDAO.java#L120-L122

Added lines #L120 - L122 were not covered by tests
}
notificationTemplateResult.setContentType(resultSet.getString(CONTENT_TYPE));
notificationTemplateResult.setLocale(locale);
notificationTemplateResult.setType(templateType);
Expand Down Expand Up @@ -173,12 +197,21 @@
List<NotificationTemplate> notificationTemplates;

try {
notificationTemplates = namedJdbcTemplate.executeQuery(LIST_APP_NOTIFICATION_TEMPLATES_BY_APP_SQL,
String listAppNotificationTemplatesByAppSql =
useUnicodeDataTypes ? LIST_APP_NOTIFICATION_TEMPLATES_BY_APP_SQL_UNICODE :
LIST_APP_NOTIFICATION_TEMPLATES_BY_APP_SQL;
notificationTemplates = namedJdbcTemplate.executeQuery(listAppNotificationTemplatesByAppSql,

Check warning on line 203 in components/email-mgt/org.wso2.carbon.email.mgt/src/main/java/org/wso2/carbon/email/mgt/store/dao/AppNotificationTemplateDAO.java

View check run for this annotation

Codecov / codecov/patch

components/email-mgt/org.wso2.carbon.email.mgt/src/main/java/org/wso2/carbon/email/mgt/store/dao/AppNotificationTemplateDAO.java#L202-L203

Added lines #L202 - L203 were not covered by tests
(resultSet, rowNumber) -> {
NotificationTemplate notificationTemplateResult = new NotificationTemplate();
notificationTemplateResult.setSubject(resultSet.getString(SUBJECT));
notificationTemplateResult.setBody(resultSet.getString(BODY));
notificationTemplateResult.setFooter(resultSet.getString(FOOTER));
if (useUnicodeDataTypes) {
notificationTemplateResult.setSubject(resultSet.getNString(SUBJECT));
notificationTemplateResult.setBody(resultSet.getNString(BODY));
notificationTemplateResult.setFooter(resultSet.getNString(FOOTER));

Check warning on line 209 in components/email-mgt/org.wso2.carbon.email.mgt/src/main/java/org/wso2/carbon/email/mgt/store/dao/AppNotificationTemplateDAO.java

View check run for this annotation

Codecov / codecov/patch

components/email-mgt/org.wso2.carbon.email.mgt/src/main/java/org/wso2/carbon/email/mgt/store/dao/AppNotificationTemplateDAO.java#L207-L209

Added lines #L207 - L209 were not covered by tests
} else {
notificationTemplateResult.setSubject(resultSet.getString(SUBJECT));
notificationTemplateResult.setBody(resultSet.getString(BODY));
notificationTemplateResult.setFooter(resultSet.getString(FOOTER));

Check warning on line 213 in components/email-mgt/org.wso2.carbon.email.mgt/src/main/java/org/wso2/carbon/email/mgt/store/dao/AppNotificationTemplateDAO.java

View check run for this annotation

Codecov / codecov/patch

components/email-mgt/org.wso2.carbon.email.mgt/src/main/java/org/wso2/carbon/email/mgt/store/dao/AppNotificationTemplateDAO.java#L211-L213

Added lines #L211 - L213 were not covered by tests
}
notificationTemplateResult.setContentType(resultSet.getString(CONTENT_TYPE));
notificationTemplateResult.setLocale(resultSet.getString(LOCALE));
notificationTemplateResult.setType(templateType.toLowerCase());
Expand Down Expand Up @@ -211,19 +244,27 @@

NamedJdbcTemplate namedJdbcTemplate = JdbcUtils.getNewNamedJdbcTemplate();
try {
namedJdbcTemplate.executeUpdate(UPDATE_APP_NOTIFICATION_TEMPLATE_SQL,
preparedStatement -> {
preparedStatement.setString(SUBJECT, notificationTemplate.getSubject());
preparedStatement.setString(BODY, notificationTemplate.getBody());
preparedStatement.setString(FOOTER, notificationTemplate.getFooter());
preparedStatement.setString(CONTENT_TYPE, notificationTemplate.getContentType());
preparedStatement.setString(TEMPLATE_KEY, locale.toLowerCase());
preparedStatement.setString(TYPE_KEY, displayName.toLowerCase());
preparedStatement.setString(CHANNEL, channelName);
preparedStatement.setInt(TENANT_ID, tenantId);
preparedStatement.setString(APP_ID, applicationUuid);
preparedStatement.setInt(TENANT_ID, tenantId);
});
String updateAppNotificationTemplateSql =
useUnicodeDataTypes ? UPDATE_APP_NOTIFICATION_TEMPLATE_SQL_UNICODE :
UPDATE_APP_NOTIFICATION_TEMPLATE_SQL;
namedJdbcTemplate.executeUpdate(updateAppNotificationTemplateSql, preparedStatement -> {

Check warning on line 250 in components/email-mgt/org.wso2.carbon.email.mgt/src/main/java/org/wso2/carbon/email/mgt/store/dao/AppNotificationTemplateDAO.java

View check run for this annotation

Codecov / codecov/patch

components/email-mgt/org.wso2.carbon.email.mgt/src/main/java/org/wso2/carbon/email/mgt/store/dao/AppNotificationTemplateDAO.java#L249-L250

Added lines #L249 - L250 were not covered by tests
if (useUnicodeDataTypes) {
preparedStatement.setNString(SUBJECT, notificationTemplate.getSubject());
preparedStatement.setNString(BODY, notificationTemplate.getBody());
preparedStatement.setNString(FOOTER, notificationTemplate.getFooter());

Check warning on line 254 in components/email-mgt/org.wso2.carbon.email.mgt/src/main/java/org/wso2/carbon/email/mgt/store/dao/AppNotificationTemplateDAO.java

View check run for this annotation

Codecov / codecov/patch

components/email-mgt/org.wso2.carbon.email.mgt/src/main/java/org/wso2/carbon/email/mgt/store/dao/AppNotificationTemplateDAO.java#L252-L254

Added lines #L252 - L254 were not covered by tests
} else {
preparedStatement.setString(SUBJECT, notificationTemplate.getSubject());
preparedStatement.setString(BODY, notificationTemplate.getBody());
preparedStatement.setString(FOOTER, notificationTemplate.getFooter());

Check warning on line 258 in components/email-mgt/org.wso2.carbon.email.mgt/src/main/java/org/wso2/carbon/email/mgt/store/dao/AppNotificationTemplateDAO.java

View check run for this annotation

Codecov / codecov/patch

components/email-mgt/org.wso2.carbon.email.mgt/src/main/java/org/wso2/carbon/email/mgt/store/dao/AppNotificationTemplateDAO.java#L256-L258

Added lines #L256 - L258 were not covered by tests
}
preparedStatement.setString(CONTENT_TYPE, notificationTemplate.getContentType());
preparedStatement.setString(TEMPLATE_KEY, locale.toLowerCase());
preparedStatement.setString(TYPE_KEY, displayName.toLowerCase());
preparedStatement.setString(CHANNEL, channelName);
preparedStatement.setInt(TENANT_ID, tenantId);
preparedStatement.setString(APP_ID, applicationUuid);
preparedStatement.setInt(TENANT_ID, tenantId);
});

Check warning on line 267 in components/email-mgt/org.wso2.carbon.email.mgt/src/main/java/org/wso2/carbon/email/mgt/store/dao/AppNotificationTemplateDAO.java

View check run for this annotation

Codecov / codecov/patch

components/email-mgt/org.wso2.carbon.email.mgt/src/main/java/org/wso2/carbon/email/mgt/store/dao/AppNotificationTemplateDAO.java#L260-L267

Added lines #L260 - L267 were not covered by tests
} catch (DataAccessException e) {
String error =
String.format("Error while updating %s template %s of type %s from application %s in %s tenant.",
Expand Down
Loading
Loading