Skip to content

Commit

Permalink
Update template existence check with resolve param in org templates.
Browse files Browse the repository at this point in the history
  • Loading branch information
dhaura committed Dec 10, 2024
1 parent 6d4675c commit eb70b91
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ public SimpleEmailTemplate addEmailTemplate(String templateTypeId, EmailTemplate
try {
boolean isTemplateExists = EmailTemplatesServiceHolder.getEmailTemplateManager()
.isEmailTemplateExists(templateTypeDisplayName, emailTemplateWithID.getId(),
getTenantDomainFromContext());
getTenantDomainFromContext(), null, false);
if (!isTemplateExists) {
// Email template is new, hence add to the system.
addEmailTemplateToTheSystem(templateTypeDisplayName, emailTemplateWithID);
Expand Down Expand Up @@ -308,7 +308,7 @@ public void deleteEmailTemplate(String templateTypeId, String templateId) {
}
try {
boolean isTemplateExists = EmailTemplatesServiceHolder.getEmailTemplateManager().isEmailTemplateExists(
templateTypeDisplayName, templateId, getTenantDomainFromContext());
templateTypeDisplayName, templateId, getTenantDomainFromContext(), null, false);
if (isTemplateExists) {
EmailTemplatesServiceHolder.getEmailTemplateManager().deleteEmailTemplate(templateTypeDisplayName,
templateId, getTenantDomainFromContext());
Expand All @@ -329,9 +329,11 @@ public void updateEmailTemplate(String templateTypeId, String templateId, EmailT

String templateTypeDisplayName = decodeTemplateTypeId(templateTypeId);
try {
// Check whether the email template exists, first.
/* Check whether the email template exists, first. Here, resolve param is specified as true since
resolved org templates are returned in GET endpoint, by default. Therefore, resolved template existence
is checked before updating. */
boolean isTemplateExists = EmailTemplatesServiceHolder.getEmailTemplateManager().isEmailTemplateExists(
templateTypeDisplayName, templateId, getTenantDomainFromContext());
templateTypeDisplayName, templateId, getTenantDomainFromContext(), null, true);
if (isTemplateExists) {
addEmailTemplateToTheSystem(templateTypeDisplayName, emailTemplateWithID);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ public SimpleEmailTemplate addEmailTemplate(String templateTypeId, EmailTemplate
try {
boolean isTemplateExists = EmailTemplatesServiceHolder.getEmailTemplateManager()
.isEmailTemplateExists(templateTypeDisplayName, emailTemplateWithID.getLocale(),
getTenantDomainFromContext());
getTenantDomainFromContext(), null, false);
if (!isTemplateExists) {
// Email template is new, hence add to the system.
addEmailTemplateToTheSystem(templateTypeDisplayName, emailTemplateWithID);
Expand Down Expand Up @@ -332,7 +332,7 @@ public void deleteEmailTemplate(String templateTypeId, String templateId) {
}
try {
boolean isTemplateExists = EmailTemplatesServiceHolder.getEmailTemplateManager().isEmailTemplateExists(
templateTypeDisplayName, templateId, getTenantDomainFromContext());
templateTypeDisplayName, templateId, getTenantDomainFromContext(), null, false);
if (isTemplateExists) {
EmailTemplatesServiceHolder.getEmailTemplateManager().deleteEmailTemplate(templateTypeDisplayName,
templateId, getTenantDomainFromContext());
Expand All @@ -353,9 +353,11 @@ public void updateEmailTemplate(String templateTypeId, String templateId, EmailT

String templateTypeDisplayName = decodeTemplateTypeId(templateTypeId);
try {
// Check whether the email template exists, first.
/* Check whether the email template exists, first. Here, resolve param is specified as true since
resolved org templates are returned in GET endpoint, by default. Therefore, resolved template existence
is checked before updating. */
boolean isTemplateExists = EmailTemplatesServiceHolder.getEmailTemplateManager().isEmailTemplateExists(
templateTypeDisplayName, templateId, getTenantDomainFromContext());
templateTypeDisplayName, templateId, getTenantDomainFromContext(), null, true);
if (isTemplateExists) {
addEmailTemplateToTheSystem(templateTypeDisplayName, emailTemplateWithID);
} else {
Expand Down

0 comments on commit eb70b91

Please sign in to comment.