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

Cleanup code which used to migrate from non-unicode to unicode #297

Merged
Merged
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 @@ -65,8 +65,6 @@ 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_DEBUG_TENANTS = "NotificationTemplates.DebugTenants.Tenant";
public static final String NOTIFICATION_TEMPLATES_ENABLE_UNICODE_SUPPORT =
"NotificationTemplates.EnableUnicodeSupport";

public static final String SERVICE_PROPERTY_KEY_SERVICE_NAME = "service.name";
public static final String SERVICE_PROPERTY_VAL_EMAIL_TEMPLATE_MANAGER = "EmailTemplateManager";
Expand Down Expand Up @@ -164,9 +162,6 @@ public static class NotificationTableColumns {
public static final String TENANT_ID = "TENANT_ID";
public static final String TEMPLATE_KEY = "TEMPLATE_KEY";
public static final String LOCALE = "LOCALE";
public static final String SUBJECT = "SUBJECT";
public static final String BODY = "BODY";
public static final String FOOTER = "FOOTER";
public static final String CONTENT = "CONTENT";
public static final String CONTENT_TYPE = "CONTENT_TYPE";
public static final String TYPE_ID = "TYPE_ID";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,55 +47,21 @@ public class SQLConstants {
"(TEMPLATE_KEY, LOCALE, CONTENT, CONTENT_TYPE, TYPE_ID, TENANT_ID, VERSION, CREATED_AT, UPDATED_AT) " +
"VALUES (:TEMPLATE_KEY;, :LOCALE;, :CONTENT;, :CONTENT_TYPE;, (" +
GET_NOTIFICATION_TYPE_ID_SQL + "), :TENANT_ID;, :VERSION;, :CREATED_AT;, :UPDATED_AT;)";
public static final String INSERT_ORG_NOTIFICATION_TEMPLATE_WITHOUT_UNICODE_SQL =
"INSERT INTO IDN_NOTIFICATION_ORG_TEMPLATE " +
"(TEMPLATE_KEY, LOCALE, SUBJECT, BODY, FOOTER, CONTENT_TYPE, TYPE_ID, TENANT_ID) " +
"VALUES (:TEMPLATE_KEY;, :LOCALE;, :SUBJECT;, :BODY;, :FOOTER;, :CONTENT_TYPE;, (" +
GET_NOTIFICATION_TYPE_ID_SQL + "), :TENANT_ID;)";
public static final String INSERT_ORG_NOTIFICATION_TEMPLATE_HYBRID_SQL =
"INSERT INTO IDN_NOTIFICATION_ORG_TEMPLATE " +
"(TEMPLATE_KEY, LOCALE, CONTENT, SUBJECT, BODY, FOOTER, CONTENT_TYPE, TYPE_ID, TENANT_ID) " +
"VALUES (:TEMPLATE_KEY;, :LOCALE;, :CONTENT;, :SUBJECT;, :BODY;, :FOOTER;, :CONTENT_TYPE;, (" +
GET_NOTIFICATION_TYPE_ID_SQL + "), :TENANT_ID;)";
public static final String GET_ORG_NOTIFICATION_TEMPLATE_SQL =
"SELECT CONTENT, 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 GET_ORG_NOTIFICATION_TEMPLATE_WITHOUT_UNICODE_SQL =
"SELECT SUBJECT, BODY, 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 GET_ORG_NOTIFICATION_TEMPLATE_HYBRID_SQL =
"SELECT CONTENT, SUBJECT, BODY, 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 IS_ORG_NOTIFICATION_TEMPLATE_EXISTS_SQL =
"SELECT ID FROM IDN_NOTIFICATION_ORG_TEMPLATE " +
"WHERE TEMPLATE_KEY = :TEMPLATE_KEY; AND TYPE_ID = :TYPE_ID; AND TENANT_ID = :TENANT_ID;";
public static final String LIST_ORG_NOTIFICATION_TEMPLATES_BY_TYPE_SQL =
"SELECT CONTENT, 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 LIST_ORG_NOTIFICATION_TEMPLATES_BY_TYPE_WITHOUT_UNICODE_SQL =
"SELECT SUBJECT, BODY, 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 LIST_ORG_NOTIFICATION_TEMPLATES_BY_TYPE_HYBRID_SQL =
"SELECT CONTENT, SUBJECT, BODY, 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 =
"UPDATE IDN_NOTIFICATION_ORG_TEMPLATE " +
"SET CONTENT = :CONTENT;, CONTENT_TYPE = :CONTENT_TYPE;, UPDATED_AT = :UPDATED_AT; " +
"WHERE TEMPLATE_KEY = :TEMPLATE_KEY; AND TYPE_ID = (" + GET_NOTIFICATION_TYPE_ID_SQL +
") AND TENANT_ID = :TENANT_ID;";
public static final String UPDATE_ORG_NOTIFICATION_TEMPLATE_WITHOUT_UNICODE_SQL =
"UPDATE IDN_NOTIFICATION_ORG_TEMPLATE " +
"SET SUBJECT = :SUBJECT;, BODY = :BODY;, FOOTER = :FOOTER;, CONTENT_TYPE = :CONTENT_TYPE; " +
"WHERE TEMPLATE_KEY = :TEMPLATE_KEY; AND TYPE_ID = (" + GET_NOTIFICATION_TYPE_ID_SQL +
") AND TENANT_ID = :TENANT_ID;";
public static final String UPDATE_ORG_NOTIFICATION_TEMPLATE_HYBRID_SQL =
"UPDATE IDN_NOTIFICATION_ORG_TEMPLATE " +
"SET CONTENT = :CONTENT;, SUBJECT = :SUBJECT;, BODY = :BODY;, FOOTER = :FOOTER;, CONTENT_TYPE = :CONTENT_TYPE; " +
"WHERE TEMPLATE_KEY = :TEMPLATE_KEY; AND TYPE_ID = (" + GET_NOTIFICATION_TYPE_ID_SQL +
") AND TENANT_ID = :TENANT_ID;";
public static final String DELETE_ORG_NOTIFICATION_TEMPLATE_SQL =
"DELETE FROM IDN_NOTIFICATION_ORG_TEMPLATE WHERE TEMPLATE_KEY = :TEMPLATE_KEY; AND TYPE_ID = (" +
GET_NOTIFICATION_TYPE_ID_SQL + ") AND TENANT_ID = :TENANT_ID;";
Expand All @@ -109,28 +75,10 @@ public class SQLConstants {
"(TEMPLATE_KEY, LOCALE, CONTENT, CONTENT_TYPE, TYPE_ID, APP_ID, TENANT_ID, VERSION, CREATED_AT, UPDATED_AT) " +
"VALUES (:TEMPLATE_KEY;, :LOCALE;, :CONTENT;, :CONTENT_TYPE;, (" +
GET_NOTIFICATION_TYPE_ID_SQL + "), :APP_ID;, :TENANT_ID;, :VERSION;, :CREATED_AT;, :UPDATED_AT;)";
public static final String INSERT_APP_NOTIFICATION_TEMPLATE_WITHOUT_UNICODE_SQL =
"INSERT INTO IDN_NOTIFICATION_APP_TEMPLATE " +
"(TEMPLATE_KEY, LOCALE, SUBJECT, BODY, FOOTER, 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 INSERT_APP_NOTIFICATION_TEMPLATE_HYBRID_SQL =
"INSERT INTO IDN_NOTIFICATION_APP_TEMPLATE " +
"(TEMPLATE_KEY, LOCALE, CONTENT, SUBJECT, BODY, FOOTER, CONTENT_TYPE, TYPE_ID, APP_ID, TENANT_ID) " +
"VALUES (:TEMPLATE_KEY;, :LOCALE;, :CONTENT;, :SUBJECT;, :BODY;, :FOOTER;, :CONTENT_TYPE;, (" +
GET_NOTIFICATION_TYPE_ID_SQL + "), :APP_ID;, :TENANT_ID;)";
public static final String GET_APP_NOTIFICATION_TEMPLATE_SQL =
"SELECT CONTENT, 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 GET_APP_NOTIFICATION_TEMPLATE_WITHOUT_UNICODE_SQL =
"SELECT SUBJECT, BODY, 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 GET_APP_NOTIFICATION_TEMPLATE_HYBRID_SQL =
"SELECT CONTENT, SUBJECT, BODY, 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 IS_APP_NOTIFICATION_TEMPLATE_EXISTS_SQL =
"SELECT ID FROM IDN_NOTIFICATION_APP_TEMPLATE " +
"WHERE TEMPLATE_KEY = :TEMPLATE_KEY; AND TYPE_ID = :TYPE_ID; AND APP_ID = :APP_ID; " +
Expand All @@ -139,29 +87,11 @@ public class SQLConstants {
"SELECT CONTENT, 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 LIST_APP_NOTIFICATION_TEMPLATES_BY_APP_WITHOUT_UNICODE_SQL =
"SELECT SUBJECT, BODY, 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 LIST_APP_NOTIFICATION_TEMPLATES_BY_APP_HYBRID_SQL =
"SELECT CONTENT, SUBJECT, BODY, 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 =
"UPDATE IDN_NOTIFICATION_APP_TEMPLATE " +
"SET CONTENT = :CONTENT;, CONTENT_TYPE = :CONTENT_TYPE;, UPDATED_AT = :UPDATED_AT; " +
"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 UPDATE_APP_NOTIFICATION_TEMPLATE_WITHOUT_UNICODE_SQL =
"UPDATE IDN_NOTIFICATION_APP_TEMPLATE " +
"SET SUBJECT = :SUBJECT;, BODY = :BODY;, FOOTER = :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;";
public static final String UPDATE_APP_NOTIFICATION_TEMPLATE_HYBRID_SQL =
"UPDATE IDN_NOTIFICATION_APP_TEMPLATE " +
"SET CONTENT = :CONTENT;, SUBJECT = :SUBJECT;, BODY = :BODY;, FOOTER = :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;";
public static final String DELETE_APP_NOTIFICATION_TEMPLATE_SQL =
"DELETE 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;";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ public class I18nMgtDataHolder{
private List<NotificationTemplate> defaultSMSTemplates = new ArrayList<>();
private List<String> legacyTenants = new ArrayList<>();
private List<String> debugTenants = new ArrayList<>();
private boolean isUnicodeSupported = false;
private boolean isUnicodeSupportedInHybridMode = false;

private static I18nMgtDataHolder instance = new I18nMgtDataHolder();

Expand Down Expand Up @@ -205,44 +203,4 @@ public void setOrgResourceResolverService(OrgResourceResolverService orgResource

this.orgResourceResolverService = orgResourceResolverService;
}

/**
* Sets whether the unicode support for template content is enabled or not.
*
* @param isUnicodeSupported true to enable Unicode support, false to disable.
*/
public void setUnicodeSupport(boolean isUnicodeSupported) {

this.isUnicodeSupported = isUnicodeSupported;
}

/**
* Gets whether the unicode support for template content is enabled.
*
* @return true if the unicode support for template content is enabled.
*/
public boolean isUnicodeSupported() {

return isUnicodeSupported;
}

/**
* Sets whether the unicode hybrid support for template content is enabled or not.
*
* @param isUnicodeSupportedInHybridMode true to enable Unicode support in hybrid mode, false to disable.
*/
public void setHybrid(boolean isUnicodeSupportedInHybridMode) {

this.isUnicodeSupportedInHybridMode = isUnicodeSupportedInHybridMode;
}

/**
* Gets whether the unicode hybrid support for template content is enabled.
*
* @return true if the unicode hybrid support for template content is enabled.
*/
public boolean isHybrid() {

return isUnicodeSupportedInHybridMode;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@

import static org.wso2.carbon.email.mgt.constants.I18nMgtConstants.NOTIFICATION_TEMPLATES_DEBUG_TENANTS;
import static org.wso2.carbon.email.mgt.constants.I18nMgtConstants.NOTIFICATION_TEMPLATES_LEGACY_TENANTS;
import static org.wso2.carbon.email.mgt.constants.I18nMgtConstants.NOTIFICATION_TEMPLATES_ENABLE_UNICODE_SUPPORT;
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;
import static org.wso2.carbon.email.mgt.constants.I18nMgtConstants.SERVICE_PROPERTY_VAL_NOTIFICATION_TEMPLATE_MANAGER;
Expand Down Expand Up @@ -104,10 +103,6 @@ protected void activate(ComponentContext context) {
List<String> debugTenants = IdentityUtil.getPropertyAsList(NOTIFICATION_TEMPLATES_DEBUG_TENANTS);
I18nMgtDataHolder.getInstance().setDebugTenants(debugTenants);

String unicodeSupportType = IdentityUtil.getProperty(NOTIFICATION_TEMPLATES_ENABLE_UNICODE_SUPPORT);
I18nMgtDataHolder.getInstance().setUnicodeSupport(Boolean.parseBoolean(unicodeSupportType));
I18nMgtDataHolder.getInstance().setHybrid("hybrid".equalsIgnoreCase(unicodeSupportType));

// Register Email Mgt Service as an OSGi service.
EmailTemplateManagerImpl emailTemplateManager = new EmailTemplateManagerImpl();
ServiceRegistration emailTemplateSR = bundleCtx.registerService(EmailTemplateManager.class.getName(),
Expand Down
Loading
Loading