From 02c581a0605a3ba0f01e25b0697ab5845facbf99 Mon Sep 17 00:00:00 2001 From: dhaura Date: Thu, 5 Dec 2024 11:19:38 +0530 Subject: [PATCH 1/5] Introduce template resolving capabilities to email/sms template apis. --- .../server/email/template/v2/EmailApi.java | 8 ++-- .../email/template/v2/EmailApiService.java | 4 +- .../ApplicationEmailTemplatesService.java | 13 +++-- .../template/v2/impl/EmailApiServiceImpl.java | 17 ++++--- .../src/main/resources/email-template.yml | 10 ++++ .../template/v1/NotificationApi.java | 32 ++++++------- .../template/v1/NotificationApiService.java | 16 +++---- .../template/v1/core/TemplatesService.java | 47 ++++++++++++------- .../v1/impl/NotificationApiServiceImpl.java | 32 ++++++------- .../main/resources/notification-template.yml | 16 +++++++ pom.xml | 4 +- 11 files changed, 123 insertions(+), 76 deletions(-) diff --git a/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.rest.api.server.email.template.v2/src/gen/java/org/wso2/carbon/identity/rest/api/server/email/template/v2/EmailApi.java b/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.rest.api.server.email.template.v2/src/gen/java/org/wso2/carbon/identity/rest/api/server/email/template/v2/EmailApi.java index a45f9ac026..479479d70e 100644 --- a/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.rest.api.server.email.template.v2/src/gen/java/org/wso2/carbon/identity/rest/api/server/email/template/v2/EmailApi.java +++ b/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.rest.api.server.email.template.v2/src/gen/java/org/wso2/carbon/identity/rest/api/server/email/template/v2/EmailApi.java @@ -233,9 +233,9 @@ public Response getAllEmailTemplateTypes( @Valid @Min(0)@ApiParam(value = "Ma @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response getAppEmailTemplate(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale, @Valid @Min(0)@ApiParam(value = "Maximum number of records to return. _This option is not yet supported._") @QueryParam("limit") Integer limit, @Valid @Min(0)@ApiParam(value = "Number of records to skip for pagination. _This option is not yet supported._") @QueryParam("offset") Integer offset, @Valid@ApiParam(value = "Define the order in which the retrieved records should be sorted. _This option is not yet supported._", allowableValues="asc, desc") @QueryParam("sortOrder") String sortOrder, @Valid@ApiParam(value = "Attribute by which the retrieved records should be sorted. _This option is not yet supported._") @QueryParam("sortBy") String sortBy) { + public Response getAppEmailTemplate(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale, @Valid@ApiParam(value = "Specifies whether to return resolved template/s throughout the ancestor organization hierarchy.", defaultValue="false") @DefaultValue("false") @QueryParam("resolve") Boolean resolve, @Valid @Min(0)@ApiParam(value = "Maximum number of records to return. _This option is not yet supported._") @QueryParam("limit") Integer limit, @Valid @Min(0)@ApiParam(value = "Number of records to skip for pagination. _This option is not yet supported._") @QueryParam("offset") Integer offset, @Valid@ApiParam(value = "Define the order in which the retrieved records should be sorted. _This option is not yet supported._", allowableValues="asc, desc") @QueryParam("sortOrder") String sortOrder, @Valid@ApiParam(value = "Attribute by which the retrieved records should be sorted. _This option is not yet supported._") @QueryParam("sortBy") String sortBy) { - return delegate.getAppEmailTemplate(templateTypeId, appUuid, locale, limit, offset, sortOrder, sortBy ); + return delegate.getAppEmailTemplate(templateTypeId, appUuid, locale, resolve, limit, offset, sortOrder, sortBy ); } @Valid @@ -257,9 +257,9 @@ public Response getAppEmailTemplate(@ApiParam(value = "Email Template Type ID.", @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response getAppTemplatesListOfEmailTemplateType(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid, @Valid @Min(0)@ApiParam(value = "Maximum number of records to return. _This option is not yet supported._") @QueryParam("limit") Integer limit, @Valid @Min(0)@ApiParam(value = "Number of records to skip for pagination. _This option is not yet supported._") @QueryParam("offset") Integer offset, @Valid@ApiParam(value = "Define the order in which the retrieved records should be sorted. _This option is not yet supported._", allowableValues="asc, desc") @QueryParam("sortOrder") String sortOrder, @Valid@ApiParam(value = "Attribute by which the retrieved records should be sorted. _This option is not yet supported._") @QueryParam("sortBy") String sortBy) { + public Response getAppTemplatesListOfEmailTemplateType(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid, @Valid@ApiParam(value = "Specifies whether to return resolved template/s throughout the ancestor organization hierarchy.", defaultValue="false") @DefaultValue("false") @QueryParam("resolve") Boolean resolve, @Valid @Min(0)@ApiParam(value = "Maximum number of records to return. _This option is not yet supported._") @QueryParam("limit") Integer limit, @Valid @Min(0)@ApiParam(value = "Number of records to skip for pagination. _This option is not yet supported._") @QueryParam("offset") Integer offset, @Valid@ApiParam(value = "Define the order in which the retrieved records should be sorted. _This option is not yet supported._", allowableValues="asc, desc") @QueryParam("sortOrder") String sortOrder, @Valid@ApiParam(value = "Attribute by which the retrieved records should be sorted. _This option is not yet supported._") @QueryParam("sortBy") String sortBy) { - return delegate.getAppTemplatesListOfEmailTemplateType(templateTypeId, appUuid, limit, offset, sortOrder, sortBy ); + return delegate.getAppTemplatesListOfEmailTemplateType(templateTypeId, appUuid, resolve, limit, offset, sortOrder, sortBy ); } @Valid diff --git a/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.rest.api.server.email.template.v2/src/gen/java/org/wso2/carbon/identity/rest/api/server/email/template/v2/EmailApiService.java b/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.rest.api.server.email.template.v2/src/gen/java/org/wso2/carbon/identity/rest/api/server/email/template/v2/EmailApiService.java index d4ee3c4bf9..6bf416c7ce 100644 --- a/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.rest.api.server.email.template.v2/src/gen/java/org/wso2/carbon/identity/rest/api/server/email/template/v2/EmailApiService.java +++ b/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.rest.api.server.email.template.v2/src/gen/java/org/wso2/carbon/identity/rest/api/server/email/template/v2/EmailApiService.java @@ -49,9 +49,9 @@ public interface EmailApiService { public Response getAllEmailTemplateTypes(Integer limit, Integer offset, String sortOrder, String sortBy); - public Response getAppEmailTemplate(String templateTypeId, String appUuid, String locale, Integer limit, Integer offset, String sortOrder, String sortBy); + public Response getAppEmailTemplate(String templateTypeId, String appUuid, String locale, Boolean resolve, Integer limit, Integer offset, String sortOrder, String sortBy); - public Response getAppTemplatesListOfEmailTemplateType(String templateTypeId, String appUuid, Integer limit, Integer offset, String sortOrder, String sortBy); + public Response getAppTemplatesListOfEmailTemplateType(String templateTypeId, String appUuid, Boolean resolve, Integer limit, Integer offset, String sortOrder, String sortBy); public Response getEmailTemplateType(String templateTypeId); diff --git a/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.rest.api.server.email.template.v2/src/main/java/org/wso2/carbon/identity/rest/api/server/email/template/v2/core/ApplicationEmailTemplatesService.java b/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.rest.api.server.email.template.v2/src/main/java/org/wso2/carbon/identity/rest/api/server/email/template/v2/core/ApplicationEmailTemplatesService.java index 05ad5fc07d..2a6fbe2065 100644 --- a/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.rest.api.server.email.template.v2/src/main/java/org/wso2/carbon/identity/rest/api/server/email/template/v2/core/ApplicationEmailTemplatesService.java +++ b/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.rest.api.server.email.template.v2/src/main/java/org/wso2/carbon/identity/rest/api/server/email/template/v2/core/ApplicationEmailTemplatesService.java @@ -62,6 +62,7 @@ public class ApplicationEmailTemplatesService { * @param templateTypeId Email template type id. * @param templateId Email template id. * @param applicationUuid Application UUID. + * @param resolve Whether to retrieve the template resolved through the ancestor organization hierarchy. * @param limit Limit the number of email template types in the response. **Not supported at the moment** * @param offset Offset to be used with the limit parameter. **Not supported at the moment** * @param sortOrder Sort the response in ascending order or descending order. **Not supported at the moment** @@ -69,7 +70,7 @@ public class ApplicationEmailTemplatesService { * @return Email template identified by the given template-type-id and the template-id, 404 if not found. */ public EmailTemplateWithID getEmailTemplate(String templateTypeId, String templateId, String applicationUuid, - Integer limit, Integer offset, + boolean resolve, Integer limit, Integer offset, String sortOrder, String sortBy) { handleNotSupportedParameters(limit, offset, sortOrder, sortBy); @@ -79,7 +80,7 @@ public EmailTemplateWithID getEmailTemplate(String templateTypeId, String templa templateId = I18nEmailUtil.normalizeLocaleFormat(templateId); EmailTemplate internalEmailTemplate = EmailTemplatesServiceHolder.getEmailTemplateManager(). getEmailTemplate(templateTypeDisplayName, templateId, - getTenantDomainFromContext(), applicationUuid); + getTenantDomainFromContext(), applicationUuid, resolve); // EmailTemplateManager sends the default template if no matching template found. We need to check for // the locale specifically. if (!internalEmailTemplate.getLocale().equals(templateId)) { @@ -97,6 +98,8 @@ public EmailTemplateWithID getEmailTemplate(String templateTypeId, String templa * * @param templateTypeId Email template type id. * @param applicationUuid Application UUID. + * @param resolve Whether to retrieve templates resolved through the ancestor organization hierarchy, + * returning templates that are applicable across the tenant's organizational structure. * @param limit Limit the number of email template types in the response. **Not supported at the moment** * @param offset Offset to be used with the limit parameter. **Not supported at the moment** * @param sortOrder Sort the response in ascending order or descending order. **Not supported at the moment** @@ -104,6 +107,7 @@ public EmailTemplateWithID getEmailTemplate(String templateTypeId, String templa * @return List of SimpleEmailTemplate objects in the template type identified by the given id, 404 if not found. */ public List getTemplatesListOfEmailTemplateType(String templateTypeId, String applicationUuid, + boolean resolve, Integer limit, Integer offset, String sortOrder, String sortBy) { @@ -111,8 +115,9 @@ public List getTemplatesListOfEmailTemplateType(String temp String templateTypeDisplayName = decodeTemplateTypeId(templateTypeId); try { - List internalEmailTemplates = EmailTemplatesServiceHolder.getEmailTemplateManager(). - getEmailTemplateType(templateTypeDisplayName, getTenantDomainFromContext(), applicationUuid); + List internalEmailTemplates = + EmailTemplatesServiceHolder.getEmailTemplateManager().getEmailTemplateType( + templateTypeDisplayName, getTenantDomainFromContext(), applicationUuid, resolve); return buildSimpleEmailTemplatesList(internalEmailTemplates, templateTypeId, applicationUuid); } catch (I18nEmailMgtException e) { if (StringUtils.equals(I18nMgtConstants.ErrorCodes.EMAIL_TEMPLATE_TYPE_NOT_FOUND, e.getErrorCode())) { diff --git a/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.rest.api.server.email.template.v2/src/main/java/org/wso2/carbon/identity/rest/api/server/email/template/v2/impl/EmailApiServiceImpl.java b/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.rest.api.server.email.template.v2/src/main/java/org/wso2/carbon/identity/rest/api/server/email/template/v2/impl/EmailApiServiceImpl.java index 46f0788109..587346fb23 100644 --- a/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.rest.api.server.email.template.v2/src/main/java/org/wso2/carbon/identity/rest/api/server/email/template/v2/impl/EmailApiServiceImpl.java +++ b/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.rest.api.server.email.template.v2/src/main/java/org/wso2/carbon/identity/rest/api/server/email/template/v2/impl/EmailApiServiceImpl.java @@ -113,19 +113,22 @@ public Response getAllEmailTemplateTypes(Integer limit, Integer offset, String s } @Override - public Response getAppEmailTemplate(String templateTypeId, String appUuid, String locale, + public Response getAppEmailTemplate(String templateTypeId, String appUuid, String locale, Boolean resolve, Integer limit, Integer offset, String sortOrder, String sortBy) { - return Response.ok().entity(applicationEmailTemplatesService. - getEmailTemplate(templateTypeId, locale, appUuid, limit, offset, sortOrder, sortBy)).build(); + return Response.ok() + .entity(applicationEmailTemplatesService.getEmailTemplate(templateTypeId, locale, appUuid, resolve, + limit, offset, sortOrder, sortBy)).build(); } @Override - public Response getAppTemplatesListOfEmailTemplateType( - String templateTypeId, String appUuid, Integer limit, Integer offset, String sortOrder, String sortBy) { + public Response getAppTemplatesListOfEmailTemplateType(String templateTypeId, String appUuid, Boolean resolve, + Integer limit, Integer offset, String sortOrder, + String sortBy) { - return Response.ok().entity(applicationEmailTemplatesService. - getTemplatesListOfEmailTemplateType(templateTypeId, appUuid, limit, offset, sortOrder, sortBy)).build(); + return Response.ok() + .entity(applicationEmailTemplatesService.getTemplatesListOfEmailTemplateType(templateTypeId, appUuid, + resolve, limit, offset, sortOrder, sortBy)).build(); } @Override diff --git a/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.rest.api.server.email.template.v2/src/main/resources/email-template.yml b/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.rest.api.server.email.template.v2/src/main/resources/email-template.yml index 0a22ce4e28..bc5907cd3a 100644 --- a/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.rest.api.server.email.template.v2/src/main/resources/email-template.yml +++ b/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.rest.api.server.email.template.v2/src/main/resources/email-template.yml @@ -260,6 +260,7 @@ paths: parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' - $ref: '#/components/parameters/appUuidPathParam' + - $ref: '#/components/parameters/resolveQueryParam' - $ref: '#/components/parameters/limitQueryParam' - $ref: '#/components/parameters/offsetQueryParam' - $ref: '#/components/parameters/sortOrderQueryParam' @@ -442,6 +443,7 @@ paths: - $ref: '#/components/parameters/templateTypeIdPathParam' - $ref: '#/components/parameters/appUuidPathParam' - $ref: '#/components/parameters/localePathParam' + - $ref: '#/components/parameters/resolveQueryParam' - $ref: '#/components/parameters/limitQueryParam' - $ref: '#/components/parameters/offsetQueryParam' - $ref: '#/components/parameters/sortOrderQueryParam' @@ -556,6 +558,14 @@ components: description: Application UUID. schema: type: string + resolveQueryParam: + in: query + name: resolve + required: false + description: Specifies whether to return resolved template/s throughout the ancestor organization hierarchy. + schema: + type: boolean + default: false offsetQueryParam: in: query name: offset diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApi.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApi.java index 59c6729372..ae8915b0f9 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApi.java +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApi.java @@ -361,9 +361,9 @@ public Response deleteSMSTemplateType(@ApiParam(value = "Template Type ID.",requ @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response getAllAppTemplatesOfEmailTemplateType(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid) { + public Response getAllAppTemplatesOfEmailTemplateType(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid, @Valid@ApiParam(value = "Specifies whether to return resolved template/s throughout the ancestor organization hierarchy.", defaultValue="false") @DefaultValue("false") @QueryParam("resolve") Boolean resolve) { - return delegate.getAllAppTemplatesOfEmailTemplateType(templateTypeId, appUuid ); + return delegate.getAllAppTemplatesOfEmailTemplateType(templateTypeId, appUuid, resolve ); } @Valid @@ -385,9 +385,9 @@ public Response getAllAppTemplatesOfEmailTemplateType(@ApiParam(value = "Templat @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response getAllAppTemplatesOfSMSTemplateType(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid) { + public Response getAllAppTemplatesOfSMSTemplateType(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid, @Valid@ApiParam(value = "Specifies whether to return resolved template/s throughout the ancestor organization hierarchy.", defaultValue="false") @DefaultValue("false") @QueryParam("resolve") Boolean resolve) { - return delegate.getAllAppTemplatesOfSMSTemplateType(templateTypeId, appUuid ); + return delegate.getAllAppTemplatesOfSMSTemplateType(templateTypeId, appUuid, resolve ); } @Valid @@ -432,9 +432,9 @@ public Response getAllEmailTemplateTypes() { @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response getAllOrgTemplatesOfEmailTemplateType(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId) { + public Response getAllOrgTemplatesOfEmailTemplateType(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @Valid@ApiParam(value = "Specifies whether to return resolved template/s throughout the ancestor organization hierarchy.", defaultValue="false") @DefaultValue("false") @QueryParam("resolve") Boolean resolve) { - return delegate.getAllOrgTemplatesOfEmailTemplateType(templateTypeId ); + return delegate.getAllOrgTemplatesOfEmailTemplateType(templateTypeId, resolve ); } @Valid @@ -456,9 +456,9 @@ public Response getAllOrgTemplatesOfEmailTemplateType(@ApiParam(value = "Templat @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response getAllOrgTemplatesOfSMSTemplateType(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId) { + public Response getAllOrgTemplatesOfSMSTemplateType(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @Valid@ApiParam(value = "Specifies whether to return resolved template/s throughout the ancestor organization hierarchy.", defaultValue="false") @DefaultValue("false") @QueryParam("resolve") Boolean resolve) { - return delegate.getAllOrgTemplatesOfSMSTemplateType(templateTypeId ); + return delegate.getAllOrgTemplatesOfSMSTemplateType(templateTypeId, resolve ); } @Valid @@ -551,9 +551,9 @@ public Response getAllSystemTemplatesOfSMSTemplateType(@ApiParam(value = "Templa @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response getAppEmailTemplate(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { + public Response getAppEmailTemplate(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale, @Valid@ApiParam(value = "Specifies whether to return resolved template/s throughout the ancestor organization hierarchy.", defaultValue="false") @DefaultValue("false") @QueryParam("resolve") Boolean resolve) { - return delegate.getAppEmailTemplate(templateTypeId, appUuid, locale ); + return delegate.getAppEmailTemplate(templateTypeId, appUuid, locale, resolve ); } @Valid @@ -575,9 +575,9 @@ public Response getAppEmailTemplate(@ApiParam(value = "Template Type ID.",requir @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response getAppSMSTemplate(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { + public Response getAppSMSTemplate(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale, @Valid@ApiParam(value = "Specifies whether to return resolved template/s throughout the ancestor organization hierarchy.", defaultValue="false") @DefaultValue("false") @QueryParam("resolve") Boolean resolve) { - return delegate.getAppSMSTemplate(templateTypeId, appUuid, locale ); + return delegate.getAppSMSTemplate(templateTypeId, appUuid, locale, resolve ); } @Valid @@ -623,9 +623,9 @@ public Response getEmailTemplateType(@ApiParam(value = "Template Type ID.",requi @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response getOrgEmailTemplate(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { + public Response getOrgEmailTemplate(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale, @Valid@ApiParam(value = "Specifies whether to return resolved template/s throughout the ancestor organization hierarchy.", defaultValue="false") @DefaultValue("false") @QueryParam("resolve") Boolean resolve) { - return delegate.getOrgEmailTemplate(templateTypeId, locale ); + return delegate.getOrgEmailTemplate(templateTypeId, locale, resolve ); } @Valid @@ -647,9 +647,9 @@ public Response getOrgEmailTemplate(@ApiParam(value = "Template Type ID.",requir @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) }) - public Response getOrgSMSTemplate(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { + public Response getOrgSMSTemplate(@ApiParam(value = "Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale, @Valid@ApiParam(value = "Specifies whether to return resolved template/s throughout the ancestor organization hierarchy.", defaultValue="false") @DefaultValue("false") @QueryParam("resolve") Boolean resolve) { - return delegate.getOrgSMSTemplate(templateTypeId, locale ); + return delegate.getOrgSMSTemplate(templateTypeId, locale, resolve ); } @Valid diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApiService.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApiService.java index feb3334c4d..76b0b20420 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApiService.java +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApiService.java @@ -62,15 +62,15 @@ public interface NotificationApiService { public Response deleteSMSTemplateType(String templateTypeId); - public Response getAllAppTemplatesOfEmailTemplateType(String templateTypeId, String appUuid); + public Response getAllAppTemplatesOfEmailTemplateType(String templateTypeId, String appUuid, Boolean resolve); - public Response getAllAppTemplatesOfSMSTemplateType(String templateTypeId, String appUuid); + public Response getAllAppTemplatesOfSMSTemplateType(String templateTypeId, String appUuid, Boolean resolve); public Response getAllEmailTemplateTypes(); - public Response getAllOrgTemplatesOfEmailTemplateType(String templateTypeId); + public Response getAllOrgTemplatesOfEmailTemplateType(String templateTypeId, Boolean resolve); - public Response getAllOrgTemplatesOfSMSTemplateType(String templateTypeId); + public Response getAllOrgTemplatesOfSMSTemplateType(String templateTypeId, Boolean resolve); public Response getAllSMSTemplateTypes(); @@ -78,15 +78,15 @@ public interface NotificationApiService { public Response getAllSystemTemplatesOfSMSTemplateType(String templateTypeId); - public Response getAppEmailTemplate(String templateTypeId, String appUuid, String locale); + public Response getAppEmailTemplate(String templateTypeId, String appUuid, String locale, Boolean resolve); - public Response getAppSMSTemplate(String templateTypeId, String appUuid, String locale); + public Response getAppSMSTemplate(String templateTypeId, String appUuid, String locale, Boolean resolve); public Response getEmailTemplateType(String templateTypeId); - public Response getOrgEmailTemplate(String templateTypeId, String locale); + public Response getOrgEmailTemplate(String templateTypeId, String locale, Boolean resolve); - public Response getOrgSMSTemplate(String templateTypeId, String locale); + public Response getOrgSMSTemplate(String templateTypeId, String locale, Boolean resolve); public Response getSMSTemplateType(String templateTypeId); diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/TemplatesService.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/TemplatesService.java index 22a5b8d575..bb0097c73c 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/TemplatesService.java +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/TemplatesService.java @@ -134,29 +134,36 @@ public SimpleTemplate addSMSTemplate(String templateTypeId, SMSTemplateWithID sm /** * Retrieves the list of organization email templates of the given template type. * - * @param templateTypeId Template type ID. + * @param templateTypeId Template type ID. + * @param notificationChannel Notification channel. + * @param resolve Whether to retrieve templates resolved through the ancestor organization hierarchy, + * returning templates that are applicable across the tenant's organizational structure. * @return List of email templates. */ - public List getAllTemplatesOfTemplateType(String templateTypeId, String notificationChannel) { + public List getAllTemplatesOfTemplateType(String templateTypeId, String notificationChannel, + boolean resolve) { - return getAllTemplatesOfTemplateType(templateTypeId, null, notificationChannel); + return getAllTemplatesOfTemplateType(templateTypeId, null, notificationChannel, resolve); } /** * Retrieves the list of application email templates of the given template type. * - * @param templateTypeId Template type ID. - * @param applicationUuid Application UUID. + * @param templateTypeId Template type ID. + * @param applicationUuid Application UUID. + * @param notificationChannel Notification channel. + * @param resolve Whether to retrieve templates resolved through the ancestor organization hierarchy, + * returning templates that are applicable across the tenant's organizational structure. * @return List of email templates. */ public List getAllTemplatesOfTemplateType(String templateTypeId, String applicationUuid, - String notificationChannel) { + String notificationChannel, boolean resolve) { String templateTypeDisplayName = Util.decodeTemplateTypeId(templateTypeId); try { List templates = TemplatesServiceHolder.getNotificationTemplateManager() .getNotificationTemplatesOfType(notificationChannel, templateTypeDisplayName, - getTenantDomainFromContext(), applicationUuid); + getTenantDomainFromContext(), applicationUuid, resolve); String templateOwner = StringUtils.isNotBlank(applicationUuid) ? Constants.NOTIFICATION_TEMPLATE_OWNER_APP : Constants.NOTIFICATION_TEMPLATE_OWNER_ORG; return Util.buildSimpleTemplateList(templates, applicationUuid, templateOwner, notificationChannel); @@ -192,11 +199,12 @@ public List getAllSystemTemplatesOfTemplateType(String templateT * * @param templateTypeId Template type ID. * @param templateId Template ID. + * @param resolve Whether to retrieve the template resolved through the ancestor organization hierarchy. * @return Email template. */ - public EmailTemplateWithID getEmailTemplate(String templateTypeId, String templateId) { + public EmailTemplateWithID getEmailTemplate(String templateTypeId, String templateId, boolean resolve) { - return getEmailTemplate(templateTypeId, templateId, null); + return getEmailTemplate(templateTypeId, templateId, null, resolve); } /** @@ -205,15 +213,17 @@ public EmailTemplateWithID getEmailTemplate(String templateTypeId, String templa * @param templateTypeId Template type ID. * @param templateId Template ID. * @param applicationUuid Application UUID. + * @param resolve Whether to retrieve the template resolved through the ancestor organization hierarchy. * @return Email template. */ - public EmailTemplateWithID getEmailTemplate(String templateTypeId, String templateId, String applicationUuid) { + public EmailTemplateWithID getEmailTemplate(String templateTypeId, String templateId, String applicationUuid, + boolean resolve) { try { String templateTypeDisplayName = Util.decodeTemplateTypeId(templateTypeId); NotificationTemplate internalEmailTemplate = TemplatesServiceHolder.getNotificationTemplateManager(). getNotificationTemplate(Constants.NOTIFICATION_CHANNEL_EMAIL, templateTypeDisplayName, templateId, - getTenantDomainFromContext(), applicationUuid); + getTenantDomainFromContext(), applicationUuid, resolve); // NotificationTemplateManager sends the default template if no matching template found. // We need to check for the locale specifically. if (!internalEmailTemplate.getLocale().equals(templateId)) { @@ -230,13 +240,14 @@ public EmailTemplateWithID getEmailTemplate(String templateTypeId, String templa /** * Retrieves the organization SMS template of the given template type and locale. * - * @param templateTypeId Template type ID. - * @param templateId Template ID. + * @param templateTypeId Template type ID. + * @param templateId Template ID. + * @param resolve Whether to retrieve the template resolved through the ancestor organization hierarchy. * @return SMS template. */ - public SMSTemplateWithID getSMSTemplate(String templateTypeId, String templateId) { + public SMSTemplateWithID getSMSTemplate(String templateTypeId, String templateId, boolean resolve) { - return getSMSTemplate(templateTypeId, templateId, null); + return getSMSTemplate(templateTypeId, templateId, null, resolve); } /** @@ -245,15 +256,17 @@ public SMSTemplateWithID getSMSTemplate(String templateTypeId, String templateId * @param templateTypeId Template type ID. * @param templateId Template ID. * @param applicationUuid Application UUID. + * @param resolve Whether to retrieve the template resolved through the ancestor organization hierarchy. * @return SMS template. */ - public SMSTemplateWithID getSMSTemplate(String templateTypeId, String templateId, String applicationUuid) { + public SMSTemplateWithID getSMSTemplate(String templateTypeId, String templateId, String applicationUuid, + boolean resolve) { try { String templateTypeDisplayName = Util.decodeTemplateTypeId(templateTypeId); NotificationTemplate internalEmailTemplate = TemplatesServiceHolder.getNotificationTemplateManager(). getNotificationTemplate(Constants.NOTIFICATION_CHANNEL_SMS, templateTypeDisplayName, templateId, - getTenantDomainFromContext(), applicationUuid); + getTenantDomainFromContext(), applicationUuid, resolve); // NotificationTemplateManager sends the default template if no matching template found. // We need to check for the locale specifically. if (!internalEmailTemplate.getLocale().equals(templateId)) { diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/impl/NotificationApiServiceImpl.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/impl/NotificationApiServiceImpl.java index e83134c6a7..c60b08778f 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/impl/NotificationApiServiceImpl.java +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/impl/NotificationApiServiceImpl.java @@ -174,19 +174,19 @@ public Response deleteSMSTemplateType(String templateTypeId) { } @Override - public Response getAllAppTemplatesOfEmailTemplateType(String templateTypeId, String appUuid) { + public Response getAllAppTemplatesOfEmailTemplateType(String templateTypeId, String appUuid, Boolean resolve) { return Response.ok().entity( templatesService.getAllTemplatesOfTemplateType(templateTypeId, appUuid, - Constants.NOTIFICATION_CHANNEL_EMAIL)).build(); + Constants.NOTIFICATION_CHANNEL_EMAIL, resolve)).build(); } @Override - public Response getAllAppTemplatesOfSMSTemplateType(String templateTypeId, String appUuid) { + public Response getAllAppTemplatesOfSMSTemplateType(String templateTypeId, String appUuid, Boolean resolve) { return Response.ok().entity( templatesService.getAllTemplatesOfTemplateType(templateTypeId, appUuid, - Constants.NOTIFICATION_CHANNEL_SMS)).build(); + Constants.NOTIFICATION_CHANNEL_SMS, resolve)).build(); } @Override @@ -197,17 +197,17 @@ public Response getAllEmailTemplateTypes() { } @Override - public Response getAllOrgTemplatesOfEmailTemplateType(String templateTypeId) { + public Response getAllOrgTemplatesOfEmailTemplateType(String templateTypeId, Boolean resolve) { return Response.ok().entity(templatesService.getAllTemplatesOfTemplateType(templateTypeId, - Constants.NOTIFICATION_CHANNEL_EMAIL)).build(); + Constants.NOTIFICATION_CHANNEL_EMAIL, resolve)).build(); } @Override - public Response getAllOrgTemplatesOfSMSTemplateType(String templateTypeId) { + public Response getAllOrgTemplatesOfSMSTemplateType(String templateTypeId, Boolean resolve) { return Response.ok().entity(templatesService.getAllTemplatesOfTemplateType(templateTypeId, - Constants.NOTIFICATION_CHANNEL_SMS)).build(); + Constants.NOTIFICATION_CHANNEL_SMS, resolve)).build(); } @Override @@ -232,16 +232,16 @@ public Response getAllSystemTemplatesOfSMSTemplateType(String templateTypeId) { } @Override - public Response getAppEmailTemplate(String templateTypeId, String appUuid, String locale) { + public Response getAppEmailTemplate(String templateTypeId, String appUuid, String locale, Boolean resolve) { - return Response.ok().entity(templatesService.getEmailTemplate(templateTypeId, locale, appUuid)) + return Response.ok().entity(templatesService.getEmailTemplate(templateTypeId, locale, appUuid, resolve)) .build(); } @Override - public Response getAppSMSTemplate(String templateTypeId, String appUuid, String locale) { + public Response getAppSMSTemplate(String templateTypeId, String appUuid, String locale, Boolean resolve) { - return Response.ok().entity(templatesService.getSMSTemplate(templateTypeId, locale, appUuid)) + return Response.ok().entity(templatesService.getSMSTemplate(templateTypeId, locale, appUuid, resolve)) .build(); } @@ -253,15 +253,15 @@ public Response getEmailTemplateType(String templateTypeId) { } @Override - public Response getOrgEmailTemplate(String templateTypeId, String locale) { + public Response getOrgEmailTemplate(String templateTypeId, String locale, Boolean resolve) { - return Response.ok().entity(templatesService.getEmailTemplate(templateTypeId, locale)).build(); + return Response.ok().entity(templatesService.getEmailTemplate(templateTypeId, locale, resolve)).build(); } @Override - public Response getOrgSMSTemplate(String templateTypeId, String locale) { + public Response getOrgSMSTemplate(String templateTypeId, String locale, Boolean resolve) { - return Response.ok().entity(templatesService.getSMSTemplate(templateTypeId, locale)).build(); + return Response.ok().entity(templatesService.getSMSTemplate(templateTypeId, locale, resolve)).build(); } @Override diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/resources/notification-template.yml b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/resources/notification-template.yml index 0e05a947bb..f0704c7b57 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/resources/notification-template.yml +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/resources/notification-template.yml @@ -194,6 +194,7 @@ paths: * internal_email_mgt_view / internal_template_mgt_view
parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' + - $ref: '#/components/parameters/resolveQueryParam' responses: '200': description: Search results matching the given criteria. @@ -270,6 +271,7 @@ paths: parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' - $ref: '#/components/parameters/appUuidPathParam' + - $ref: '#/components/parameters/resolveQueryParam' responses: '200': description: Search results matching the given criteria. @@ -347,6 +349,7 @@ paths: parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' - $ref: '#/components/parameters/localePathParam' + - $ref: '#/components/parameters/resolveQueryParam' responses: '200': description: Search results matching the given criteria. @@ -500,6 +503,7 @@ paths: - $ref: '#/components/parameters/templateTypeIdPathParam' - $ref: '#/components/parameters/appUuidPathParam' - $ref: '#/components/parameters/localePathParam' + - $ref: '#/components/parameters/resolveQueryParam' responses: '200': description: Search results matching the given criteria. @@ -718,6 +722,7 @@ paths: parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' - $ref: '#/components/parameters/appUuidPathParam' + - $ref: '#/components/parameters/resolveQueryParam' responses: '200': description: Search results matching the given criteria. @@ -796,6 +801,7 @@ paths: - $ref: '#/components/parameters/templateTypeIdPathParam' - $ref: '#/components/parameters/appUuidPathParam' - $ref: '#/components/parameters/localePathParam' + - $ref: '#/components/parameters/resolveQueryParam' responses: '200': description: Search results matching the given criteria. @@ -886,6 +892,7 @@ paths: * internal_template_mgt_view
parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' + - $ref: '#/components/parameters/resolveQueryParam' responses: '200': description: Search results matching the given criteria. @@ -962,6 +969,7 @@ paths: parameters: - $ref: '#/components/parameters/templateTypeIdPathParam' - $ref: '#/components/parameters/localePathParam' + - $ref: '#/components/parameters/resolveQueryParam' responses: '200': description: Search results matching the given criteria. @@ -1131,6 +1139,14 @@ components: description: Application UUID. schema: type: string + resolveQueryParam: + in: query + name: resolve + required: false + description: Specifies whether to return resolved template/s throughout the ancestor organization hierarchy. + schema: + type: boolean + default: false responses: NotFound: description: The specified resource is not found. diff --git a/pom.xml b/pom.xml index f8fce6b37e..4fffa157d2 100644 --- a/pom.xml +++ b/pom.xml @@ -808,12 +808,12 @@ 2.3.1.wso2v1 1.4 1.2.4 - 1.11.11 + 1.11.18 7.6.9 3.0.5 1.12.0 **/gen/**/* - 1.9.12 + 1.9.24 7.0.169 5.11.44 1.9.4 From 6f30346f7d946ea79510fa26dc8d9432979dee7d Mon Sep 17 00:00:00 2001 From: dhaura Date: Tue, 10 Dec 2024 15:09:11 +0530 Subject: [PATCH 2/5] Update template existence check with resolve param. --- .../v2/core/ApplicationEmailTemplatesService.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.rest.api.server.email.template.v2/src/main/java/org/wso2/carbon/identity/rest/api/server/email/template/v2/core/ApplicationEmailTemplatesService.java b/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.rest.api.server.email.template.v2/src/main/java/org/wso2/carbon/identity/rest/api/server/email/template/v2/core/ApplicationEmailTemplatesService.java index 2a6fbe2065..7692fdd9c3 100644 --- a/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.rest.api.server.email.template.v2/src/main/java/org/wso2/carbon/identity/rest/api/server/email/template/v2/core/ApplicationEmailTemplatesService.java +++ b/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.rest.api.server.email.template.v2/src/main/java/org/wso2/carbon/identity/rest/api/server/email/template/v2/core/ApplicationEmailTemplatesService.java @@ -142,7 +142,7 @@ public SimpleEmailTemplate addEmailTemplate( try { boolean isTemplateExists = EmailTemplatesServiceHolder.getEmailTemplateManager() .isEmailTemplateExists(templateTypeDisplayName, emailTemplateWithID.getLocale(), - getTenantDomainFromContext(), applicationUuid); + getTenantDomainFromContext(), applicationUuid, false); if (!isTemplateExists) { // Email template is new, hence add to the system. addEmailTemplateToTheSystem(templateTypeDisplayName, emailTemplateWithID, applicationUuid); @@ -179,7 +179,7 @@ public void deleteEmailTemplate(String templateTypeId, String templateId, String } try { boolean isTemplateExists = EmailTemplatesServiceHolder.getEmailTemplateManager().isEmailTemplateExists( - templateTypeDisplayName, templateId, getTenantDomainFromContext(), applicationUuid); + templateTypeDisplayName, templateId, getTenantDomainFromContext(), applicationUuid, false); if (isTemplateExists) { EmailTemplatesServiceHolder.getEmailTemplateManager().deleteEmailTemplate(templateTypeDisplayName, templateId, getTenantDomainFromContext(), applicationUuid); @@ -229,9 +229,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(), applicationUuid); + templateTypeDisplayName, templateId, getTenantDomainFromContext(), applicationUuid, true); if (isTemplateExists) { addEmailTemplateToTheSystem(templateTypeDisplayName, emailTemplateWithID, applicationUuid); } else { From 6d4675c3dfa2519ead38020dd79865ab1138f2b3 Mon Sep 17 00:00:00 2001 From: dhaura Date: Tue, 10 Dec 2024 17:38:02 +0530 Subject: [PATCH 3/5] Bump governance and notification template handler versions --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index b4252f3f07..0b61c1ba2d 100644 --- a/pom.xml +++ b/pom.xml @@ -820,12 +820,12 @@ 2.3.1.wso2v1 1.4 1.2.4 - 1.11.18 + 1.11.21 7.7.24 3.0.5 1.12.0 **/gen/**/* - 1.9.24 + 1.9.28 7.0.169 5.11.44 1.9.4 From eb70b91806390d53242a0c28f49d388af966ea76 Mon Sep 17 00:00:00 2001 From: dhaura Date: Tue, 10 Dec 2024 17:40:28 +0530 Subject: [PATCH 4/5] Update template existence check with resolve param in org templates. --- .../template/v1/core/ServerEmailTemplatesService.java | 10 ++++++---- .../template/v2/core/ServerEmailTemplatesService.java | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.rest.api.server.email.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/email/template/v1/core/ServerEmailTemplatesService.java b/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.rest.api.server.email.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/email/template/v1/core/ServerEmailTemplatesService.java index 9f1961bfa7..a90f456de3 100644 --- a/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.rest.api.server.email.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/email/template/v1/core/ServerEmailTemplatesService.java +++ b/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.rest.api.server.email.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/email/template/v1/core/ServerEmailTemplatesService.java @@ -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); @@ -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()); @@ -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 { diff --git a/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.rest.api.server.email.template.v2/src/main/java/org/wso2/carbon/identity/rest/api/server/email/template/v2/core/ServerEmailTemplatesService.java b/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.rest.api.server.email.template.v2/src/main/java/org/wso2/carbon/identity/rest/api/server/email/template/v2/core/ServerEmailTemplatesService.java index 5b91d4dfc1..cb47321fc3 100644 --- a/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.rest.api.server.email.template.v2/src/main/java/org/wso2/carbon/identity/rest/api/server/email/template/v2/core/ServerEmailTemplatesService.java +++ b/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.rest.api.server.email.template.v2/src/main/java/org/wso2/carbon/identity/rest/api/server/email/template/v2/core/ServerEmailTemplatesService.java @@ -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); @@ -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()); @@ -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 { From 52cc594de56b057eaf39ae2c87e65ceb06051da5 Mon Sep 17 00:00:00 2001 From: dhaura Date: Tue, 10 Dec 2024 17:44:28 +0530 Subject: [PATCH 5/5] Revert "Update template existence check with resolve param in org templates." This reverts commit eb70b91806390d53242a0c28f49d388af966ea76. --- .../template/v1/core/ServerEmailTemplatesService.java | 10 ++++------ .../template/v2/core/ServerEmailTemplatesService.java | 10 ++++------ 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.rest.api.server.email.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/email/template/v1/core/ServerEmailTemplatesService.java b/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.rest.api.server.email.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/email/template/v1/core/ServerEmailTemplatesService.java index a90f456de3..9f1961bfa7 100644 --- a/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.rest.api.server.email.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/email/template/v1/core/ServerEmailTemplatesService.java +++ b/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.rest.api.server.email.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/email/template/v1/core/ServerEmailTemplatesService.java @@ -246,7 +246,7 @@ public SimpleEmailTemplate addEmailTemplate(String templateTypeId, EmailTemplate try { boolean isTemplateExists = EmailTemplatesServiceHolder.getEmailTemplateManager() .isEmailTemplateExists(templateTypeDisplayName, emailTemplateWithID.getId(), - getTenantDomainFromContext(), null, false); + getTenantDomainFromContext()); if (!isTemplateExists) { // Email template is new, hence add to the system. addEmailTemplateToTheSystem(templateTypeDisplayName, emailTemplateWithID); @@ -308,7 +308,7 @@ public void deleteEmailTemplate(String templateTypeId, String templateId) { } try { boolean isTemplateExists = EmailTemplatesServiceHolder.getEmailTemplateManager().isEmailTemplateExists( - templateTypeDisplayName, templateId, getTenantDomainFromContext(), null, false); + templateTypeDisplayName, templateId, getTenantDomainFromContext()); if (isTemplateExists) { EmailTemplatesServiceHolder.getEmailTemplateManager().deleteEmailTemplate(templateTypeDisplayName, templateId, getTenantDomainFromContext()); @@ -329,11 +329,9 @@ public void updateEmailTemplate(String templateTypeId, String templateId, EmailT String templateTypeDisplayName = decodeTemplateTypeId(templateTypeId); try { - /* 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. */ + // Check whether the email template exists, first. boolean isTemplateExists = EmailTemplatesServiceHolder.getEmailTemplateManager().isEmailTemplateExists( - templateTypeDisplayName, templateId, getTenantDomainFromContext(), null, true); + templateTypeDisplayName, templateId, getTenantDomainFromContext()); if (isTemplateExists) { addEmailTemplateToTheSystem(templateTypeDisplayName, emailTemplateWithID); } else { diff --git a/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.rest.api.server.email.template.v2/src/main/java/org/wso2/carbon/identity/rest/api/server/email/template/v2/core/ServerEmailTemplatesService.java b/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.rest.api.server.email.template.v2/src/main/java/org/wso2/carbon/identity/rest/api/server/email/template/v2/core/ServerEmailTemplatesService.java index cb47321fc3..5b91d4dfc1 100644 --- a/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.rest.api.server.email.template.v2/src/main/java/org/wso2/carbon/identity/rest/api/server/email/template/v2/core/ServerEmailTemplatesService.java +++ b/components/org.wso2.carbon.identity.api.server.email.template/org.wso2.carbon.identity.rest.api.server.email.template.v2/src/main/java/org/wso2/carbon/identity/rest/api/server/email/template/v2/core/ServerEmailTemplatesService.java @@ -243,7 +243,7 @@ public SimpleEmailTemplate addEmailTemplate(String templateTypeId, EmailTemplate try { boolean isTemplateExists = EmailTemplatesServiceHolder.getEmailTemplateManager() .isEmailTemplateExists(templateTypeDisplayName, emailTemplateWithID.getLocale(), - getTenantDomainFromContext(), null, false); + getTenantDomainFromContext()); if (!isTemplateExists) { // Email template is new, hence add to the system. addEmailTemplateToTheSystem(templateTypeDisplayName, emailTemplateWithID); @@ -332,7 +332,7 @@ public void deleteEmailTemplate(String templateTypeId, String templateId) { } try { boolean isTemplateExists = EmailTemplatesServiceHolder.getEmailTemplateManager().isEmailTemplateExists( - templateTypeDisplayName, templateId, getTenantDomainFromContext(), null, false); + templateTypeDisplayName, templateId, getTenantDomainFromContext()); if (isTemplateExists) { EmailTemplatesServiceHolder.getEmailTemplateManager().deleteEmailTemplate(templateTypeDisplayName, templateId, getTenantDomainFromContext()); @@ -353,11 +353,9 @@ public void updateEmailTemplate(String templateTypeId, String templateId, EmailT String templateTypeDisplayName = decodeTemplateTypeId(templateTypeId); try { - /* 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. */ + // Check whether the email template exists, first. boolean isTemplateExists = EmailTemplatesServiceHolder.getEmailTemplateManager().isEmailTemplateExists( - templateTypeDisplayName, templateId, getTenantDomainFromContext(), null, true); + templateTypeDisplayName, templateId, getTenantDomainFromContext()); if (isTemplateExists) { addEmailTemplateToTheSystem(templateTypeDisplayName, emailTemplateWithID); } else {