Skip to content

Commit

Permalink
Handle NPE in checking template existence.
Browse files Browse the repository at this point in the history
  • Loading branch information
dhaura committed Dec 10, 2024
1 parent bebb951 commit 567e38a
Showing 1 changed file with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,8 @@ public void addNotificationTemplateType(String displayName, String notificationC
public boolean isNotificationTemplateTypeExists(String displayName, String notificationChannel, String tenantDomain)
throws NotificationTemplateManagerServerException {

boolean templateTypeExists =
systemDefaultTemplateManager.isNotificationTemplateTypeExists(displayName, notificationChannel,
tenantDomain);

if (templateTypeExists) {
if (systemDefaultTemplateManager.isNotificationTemplateTypeExists(displayName, notificationChannel,
tenantDomain)) {
return true;
}

Expand All @@ -79,12 +76,16 @@ public boolean isNotificationTemplateTypeExists(String displayName, String notif

OrgResourceResolverService orgResourceResolverService =
I18nMgtDataHolder.getInstance().getOrgResourceResolverService();
return orgResourceResolverService.getResourcesFromOrgHierarchy(
Boolean templateTypeExists = orgResourceResolverService.getResourcesFromOrgHierarchy(
organizationId,
LambdaExceptionUtils.rethrowFunction(
orgId -> notificationTemplateTypeExistenceRetriever(displayName, notificationChannel,
orgId)),
new FirstFoundAggregationStrategy<>());
if (templateTypeExists != null) {
return templateTypeExists;
}
return false;
} catch (OrganizationManagementException | OrgResourceHierarchyTraverseException e) {
String errorMsg = String.format("Unexpected server error occurred while checking the existence of " +
"email template type: %s for tenant: %s", displayName, tenantDomain);
Expand Down Expand Up @@ -173,11 +174,8 @@ public boolean isNotificationTemplateExists(String displayName, String locale, S
String applicationUuid, String tenantDomain)
throws NotificationTemplateManagerServerException {

boolean templateExists =
systemDefaultTemplateManager.isNotificationTemplateExists(displayName, locale, notificationChannel,
null, tenantDomain);

if (templateExists) {
if (systemDefaultTemplateManager.isNotificationTemplateExists(displayName, locale, notificationChannel,
null, tenantDomain)) {
return true;
}

Expand All @@ -187,12 +185,16 @@ public boolean isNotificationTemplateExists(String displayName, String locale, S

OrgResourceResolverService orgResourceResolverService =
I18nMgtDataHolder.getInstance().getOrgResourceResolverService();
return orgResourceResolverService.getResourcesFromOrgHierarchy(
Boolean templateExists = orgResourceResolverService.getResourcesFromOrgHierarchy(
organizationId,
LambdaExceptionUtils.rethrowFunction(
orgId -> notificationTemplateExistenceRetriever(displayName, locale, notificationChannel,
applicationUuid, orgId)),
new FirstFoundAggregationStrategy<>());
if (templateExists != null) {
return templateExists;
}
return false;
} catch (OrganizationManagementException | OrgResourceHierarchyTraverseException e) {
String errorMsg = String.format("Unexpected server error occurred while checking the existence of " +
"email template with type: %s for tenant: %s", displayName, tenantDomain);
Expand Down

0 comments on commit 567e38a

Please sign in to comment.