From 5b3b94cf50e2a5cd5e39f8152ab0f249887b3d5b Mon Sep 17 00:00:00 2001 From: rushannanayakkara Date: Tue, 9 Jul 2024 23:09:27 +0530 Subject: [PATCH 1/3] Add notification template management functions --- .../NotificationTemplateManager.java | 214 ++++++++++++++++-- 1 file changed, 197 insertions(+), 17 deletions(-) diff --git a/components/org.wso2.carbon.identity.governance/src/main/java/org/wso2/carbon/identity/governance/service/notification/NotificationTemplateManager.java b/components/org.wso2.carbon.identity.governance/src/main/java/org/wso2/carbon/identity/governance/service/notification/NotificationTemplateManager.java index abf5eca938..a73ca294bb 100644 --- a/components/org.wso2.carbon.identity.governance/src/main/java/org/wso2/carbon/identity/governance/service/notification/NotificationTemplateManager.java +++ b/components/org.wso2.carbon.identity.governance/src/main/java/org/wso2/carbon/identity/governance/service/notification/NotificationTemplateManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2019-2024, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,6 +25,124 @@ */ public interface NotificationTemplateManager { + + /** + * Add a new notification template to the system (db/ registry). + * + * @param notificationChannel Notification channel + * @param displayName Notification template display name + * @param tenantDomain Tenant domain + * @throws NotificationTemplateManagerException If an error occurred while adding the template to the registry + */ + default void addNotificationTemplateType(String notificationChannel, String displayName, String tenantDomain) + throws NotificationTemplateManagerException { + + } + + /** + * Add a new notification template to the system (db/ registry). + * + * @param notificationChannel Notification channel (Eg: SMS, EMAIL). + * @param displayName Notification template display name. + * @param tenantDomain Tenant domain. + * @param applicationUuid Application UUID. + * @throws NotificationTemplateManagerException If an error occurred while adding the template to the registry. + */ + default void addNotificationTemplateType(String notificationChannel, String displayName, + String tenantDomain, String applicationUuid) + throws NotificationTemplateManagerException { + + } + + /** + * Get all available notification template types for the tenant. + * + * @param notificationChannel Notification channel (Eg: SMS, EMAIL). + * @param tenantDomain Tenant domain. + * @return List of notification template types. + * @throws NotificationTemplateManagerException If an error occurred while getting the notification template types. + */ + default List getAllNotificationTemplateTypes(String notificationChannel, String tenantDomain) + throws NotificationTemplateManagerException { + + return null; + } + + /** + * Delete a notification template type from the tenant registry. + * + * @param notificationChannel Notification channel. + * @param templateDisplayName Display name of the template type. + * @param tenantDomain Tenant domain. + * @throws NotificationTemplateManagerException If an error occurred while deleting the notification template type. + */ + default void deleteNotificationTemplateType(String notificationChannel, String templateDisplayName, + String tenantDomain) + throws NotificationTemplateManagerException { + + } + + /** + * Check whether the given notification template type exists in the system. + * + * @param notificationChannel Notification channel. + * @param templateTypeDisplayName Display name of the template type. + * @param tenantDomain Tenant Domain. + * @throws NotificationTemplateManagerException If an error occurred while checking if template type exists. + */ + default boolean isNotificationTemplateTypeExists(String notificationChannel, String templateTypeDisplayName, + String tenantDomain) + throws NotificationTemplateManagerException { + + return false; + } + + /** + * Get all available notification template types for the tenant. + * + * @param notificationChannel Notification channel (Eg: SMS, EMAIL). + * @param tenantDomain Tenant domain. + * @throws NotificationTemplateManagerException If an error occurred while getting the notification template types. + */ + default List getAllNotificationTemplates(String notificationChannel, String tenantDomain) + throws NotificationTemplateManagerException { + + return null; + } + + /** + * Get all notification templates of the given type. + * + * @param notificationChannel Notification channel (Eg: SMS, EMAIL). + * @param templateDisplayName Display name of the template. + * @param tenantDomain Tenant domain. + * @return List of notification templates. + * @throws NotificationTemplateManagerException If an error occurred while getting the notification templates. + */ + default List getNotificationTemplatesOfType(String notificationChannel, + String templateDisplayName, String tenantDomain) + throws NotificationTemplateManagerException { + + return null; + } + + /** + * Get all notification templates of the given type. + * + * @param notificationChannel Notification channel (Eg: SMS, EMAIL). + * @param templateDisplayName Display name of the template. + * @param tenantDomain Tenant domain. + * @param applicationUuid Application UUID. + * @return List of notification templates. + * @throws NotificationTemplateManagerException If an error occurred while getting the notification templates. + */ + default List getNotificationTemplatesOfType(String notificationChannel, + String templateDisplayName, String tenantDomain, String applicationUuid) + throws NotificationTemplateManagerException { + + return null; + } + /** * Return the notification template from the tenant registry which matches the given channel and template name. * @@ -61,7 +179,7 @@ default NotificationTemplate getNotificationTemplate(String notificationChannel, } /** - * Add the notification template to the registry. + * Add the notification template. * * @param notificationTemplate Notification template * {@link org.wso2.carbon.identity.governance.model.NotificationTemplate} @@ -74,7 +192,7 @@ default void addNotificationTemplate(NotificationTemplate notificationTemplate, } /** - * Add the notification template to the registry. + * Add the notification template. * * @param notificationTemplate Notification template. * @param tenantDomain Tenant domain. @@ -87,14 +205,59 @@ default void addNotificationTemplate(NotificationTemplate notificationTemplate, } /** - * Add a new notification template to the registry to the corresponding notification channel root directory. + * Update notification template. * - * @param displayName Notification template display name - * @param notificationChannel Notification channel - * @param tenantDomain Tenant domain - * @throws NotificationTemplateManagerException If an error occurred while adding the template to the registry + * @param notificationTemplate Notification template + * {@link org.wso2.carbon.identity.governance.model.NotificationTemplate} + * @param tenantDomain Tenant domain + * @throws NotificationTemplateManagerException If an error occurred while updating the notification template */ - default void addNotificationTemplateType(String displayName, String notificationChannel, String tenantDomain) + default void updateNotificationTemplate(NotificationTemplate notificationTemplate, String tenantDomain) + throws NotificationTemplateManagerException { + + } + + /** + * Update notification template of application. + * + * @param notificationTemplate Notification template. + * @param tenantDomain Tenant domain. + * @param applicationUuid Application UUID. + * @throws NotificationTemplateManagerException If an error occurred while updating the notification template. + */ + default void updateNotificationTemplate(NotificationTemplate notificationTemplate, String tenantDomain, + String applicationUuid) throws NotificationTemplateManagerException { + + } + + /** + * Delete a notification template from the system. + * + * @param notificationChannel Notification channel (Eg: SMS, EMAIL). + * @param templateDisplayName Display name of the template. + * @param locale Locale of the template. + * @param tenantDomain Tenant domain. + * @throws NotificationTemplateManagerException If an error occurred while deleting the notification template. + */ + default void deleteNotificationTemplate(String notificationChannel, String templateDisplayName, String locale, + String tenantDomain) + throws NotificationTemplateManagerException { + + } + + + /** + * Delete an application notification template from the system. + * + * @param notificationChannel Notification channel (Eg: SMS, EMAIL). + * @param templateDisplayName Display name of the template. + * @param locale Locale of the template. + * @param tenantDomain Tenant domain. + * @param applicationUuid Application UUID. + * @throws NotificationTemplateManagerException If an error occurred while deleting the notification template. + */ + default void deleteNotificationTemplate(String notificationChannel, String templateDisplayName, String locale, + String tenantDomain, String applicationUuid) throws NotificationTemplateManagerException { } @@ -124,17 +287,34 @@ default List getDefaultNotificationTemplates(String notifi } /** - * Add a new notification template to the registry to the corresponding notification channel root directory. + * Check whether the given notification template exists in the system. * - * @param displayName Notification template display name. - * @param notificationChannel Notification channel (Eg: SMS, EMAIL). - * @param tenantDomain Tenant domain. - * @param applicationUuid Application UUID. - * @throws NotificationTemplateManagerException If an error occurred while adding the template to the registry. + * @param notificationChannel Notification channel. + * @param templateDisplayName Display name of the template. + * @param tenantDomain Tenant Domain. + * @throws NotificationTemplateManagerException If an error occurred while checking if template type exists. */ - default void addNotificationTemplateType(String displayName, String notificationChannel, - String tenantDomain, String applicationUuid) + default boolean isNotificationTemplateExists(String notificationChannel, String templateDisplayName, String locale, + String tenantDomain) + throws NotificationTemplateManagerException { + + return false; + } + + /** + * Check whether the given notification template exists in the system. + * + * @param notificationChannel Notification channel. + * @param templateDisplayName Display name of the template. + * @param tenantDomain Tenant Domain. + * @param applicationUuid Application UUID. + * @return True if the template exists, false otherwise. + * @throws NotificationTemplateManagerException If an error occurred while checking if template type exists. + */ + default boolean isNotificationTemplateExists(String notificationChannel, String templateDisplayName, String locale, + String tenantDomain, String applicationUuid) throws NotificationTemplateManagerException { + return false; } } From 513390b6c7973dda8ddac9110f012055538cad7e Mon Sep 17 00:00:00 2001 From: rushannanayakkara Date: Thu, 26 Sep 2024 22:36:37 +0530 Subject: [PATCH 2/3] Add NotificationTemplateManager.getSystemNotificationTemplate function --- .../NotificationTemplateManager.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/components/org.wso2.carbon.identity.governance/src/main/java/org/wso2/carbon/identity/governance/service/notification/NotificationTemplateManager.java b/components/org.wso2.carbon.identity.governance/src/main/java/org/wso2/carbon/identity/governance/service/notification/NotificationTemplateManager.java index a3f2be4ec1..30a92ba231 100644 --- a/components/org.wso2.carbon.identity.governance/src/main/java/org/wso2/carbon/identity/governance/service/notification/NotificationTemplateManager.java +++ b/components/org.wso2.carbon.identity.governance/src/main/java/org/wso2/carbon/identity/governance/service/notification/NotificationTemplateManager.java @@ -287,6 +287,22 @@ default List getDefaultNotificationTemplates(String notifi return null; } + /** + * Return the default system notification template which matches the given channel and template name. + * + * @param notificationChannel Notification Channel Name (Eg: SMS or EMAIL) + * @param templateType Display name of the template + * @param locale Locale + * @return Return {@link org.wso2.carbon.identity.governance.model.NotificationTemplate} object + * @throws NotificationTemplateManagerException If an error occurred while getting the notification template + */ + default NotificationTemplate getSystemNotificationTemplate(String notificationChannel, String templateType, + String locale) + throws NotificationTemplateManagerException { + + return null; + } + /** * Check whether the given notification template exists in the system. * From d08b1e59cc3525ed6dabe185bce9af884903a1b6 Mon Sep 17 00:00:00 2001 From: rushannanayakkara Date: Sun, 29 Sep 2024 19:01:55 +0530 Subject: [PATCH 3/3] Add NotificationTemplateManager.getAllSystemNotificationTemplatesOfType function --- .../notification/NotificationTemplateManager.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/components/org.wso2.carbon.identity.governance/src/main/java/org/wso2/carbon/identity/governance/service/notification/NotificationTemplateManager.java b/components/org.wso2.carbon.identity.governance/src/main/java/org/wso2/carbon/identity/governance/service/notification/NotificationTemplateManager.java index 30a92ba231..8b589ab3a2 100644 --- a/components/org.wso2.carbon.identity.governance/src/main/java/org/wso2/carbon/identity/governance/service/notification/NotificationTemplateManager.java +++ b/components/org.wso2.carbon.identity.governance/src/main/java/org/wso2/carbon/identity/governance/service/notification/NotificationTemplateManager.java @@ -110,6 +110,18 @@ default List getAllNotificationTemplates(String notificati return null; } + /** + * Get all available system notification templates of given type. + * + * @param notificationChannel Notification channel (Eg: SMS, EMAIL). + * @return List of system notification templates. + */ + default List getAllSystemNotificationTemplatesOfType(String notificationChannel, + String templateDisplayName) throws NotificationTemplateManagerException { + + return null; + } + /** * Get all notification templates of the given type. *