Skip to content

Commit

Permalink
Remove partial deletion for system template types and add deleteCusto…
Browse files Browse the repository at this point in the history
…mizedNotificationTemplates function.
  • Loading branch information
RushanNanayakkara committed Oct 5, 2024
1 parent 269cf57 commit 9d494c3
Showing 1 changed file with 28 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,26 +140,27 @@ public void deleteNotificationTemplateType(String notificationChannel, String te

validateDisplayNameOfTemplateType(templateDisplayName);
assertTemplateTypeExists(templateDisplayName, notificationChannel, tenantDomain);
try {
userDefinedTemplatePersistenceManager.deleteNotificationTemplateType(
templateDisplayName, notificationChannel, tenantDomain);
} catch (NotificationTemplateManagerException ex) {
String errorMsg = String.format
("Error deleting template type %s from %s tenant.", templateDisplayName, tenantDomain);
throw handleServerException(errorMsg, ex);
}
// If delete was executed on a system template type, the type will not be deleted, but the user define
// templates will be deleted. Therefore, this needs to be informed.

// System template types are cannot be deleted since these are hard coded values.
if (systemTemplatePersistenceManager.isNotificationTemplateTypeExists(templateDisplayName, notificationChannel,
null)) {
String code = I18nEmailUtil.prependOperationScenarioToErrorCode(
TemplateMgtConstants.ErrorMessages.ERROR_CODE_SYSTEM_RESOURCE_DELETION_NOT_ALLOWED.getCode(),
TemplateMgtConstants.ErrorScenarios.NOTIFICATION_TEMPLATE_MANAGER);
String message = String.format(
TemplateMgtConstants.ErrorMessages.ERROR_CODE_SYSTEM_RESOURCE_DELETION_NOT_ALLOWED.getMessage(),
"System template type not deleted. User defined templates deleted.");
"System template types are not eligible for deletion.");
throw new NotificationTemplateManagerServerException(code, message);
}

try {
userDefinedTemplatePersistenceManager.deleteNotificationTemplateType(
templateDisplayName, notificationChannel, tenantDomain);
} catch (NotificationTemplateManagerException ex) {
String errorMsg = String.format
("Error deleting template type %s from %s tenant.", templateDisplayName, tenantDomain);
throw handleServerException(errorMsg, ex);
}
}

/**
Expand Down Expand Up @@ -508,6 +509,22 @@ public void deleteNotificationTemplate(String notificationChannel, String templa
}
}

/**
* {@inheritDoc}
*/
@Override
public void deleteCustomizedNotificationTemplates(String notificationChannel, String templateType,
String tenantDomain) throws NotificationTemplateManagerException {
try {
NotificationTemplateManager.super.deleteCustomizedNotificationTemplates(notificationChannel,
templateType, tenantDomain);
} catch (NotificationTemplateManagerException e) {
String msg = String.format("Error deleting custom templates for %s template type %s from %s .",
notificationChannel, templateType, tenantDomain);
throw handleServerException(msg, e);
}
}

/**
* {@inheritDoc}
*/
Expand Down

0 comments on commit 9d494c3

Please sign in to comment.