From 4ddc6a5fb342bcd296bd357901ca2ec7f12aa565 Mon Sep 17 00:00:00 2001 From: dhaura Date: Mon, 29 Jul 2024 15:32:07 +0530 Subject: [PATCH 1/2] Add API support to resolve branding preferences only using published preferences. --- .../management/v1/BrandingPreferenceApi.java | 6 +++--- .../v1/BrandingPreferenceApiService.java | 4 ++-- .../BrandingPreferenceManagementService.java | 19 +++++++++++++++++-- .../BrandingPreferenceApiServiceImpl.java | 8 ++++---- .../main/resources/branding-preference.yaml | 13 +++++++++++++ 5 files changed, 39 insertions(+), 11 deletions(-) diff --git a/components/org.wso2.carbon.identity.api.server.branding.preference.management/org.wso2.carbon.identity.api.server.branding.preference.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/branding/preference/management/v1/BrandingPreferenceApi.java b/components/org.wso2.carbon.identity.api.server.branding.preference.management/org.wso2.carbon.identity.api.server.branding.preference.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/branding/preference/management/v1/BrandingPreferenceApi.java index 252aa91312..f295f63617 100644 --- a/components/org.wso2.carbon.identity.api.server.branding.preference.management/org.wso2.carbon.identity.api.server.branding.preference.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/branding/preference/management/v1/BrandingPreferenceApi.java +++ b/components/org.wso2.carbon.identity.api.server.branding.preference.management/org.wso2.carbon.identity.api.server.branding.preference.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/branding/preference/management/v1/BrandingPreferenceApi.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023, WSO2 LLC. (http://www.wso2.com). + * Copyright (c) 2021-2024, WSO2 LLC. (http://www.wso2.com). * * WSO2 LLC. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except @@ -206,9 +206,9 @@ public Response getCustomText( @Valid@ApiParam(value = "Type to filter the re @ApiResponse(code = 404, message = "Requested resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal server error.", response = Error.class) }) - public Response resolveBrandingPreference( @Valid@ApiParam(value = "Type to filter the retrieval of customizations.", allowableValues="ORG, APP, CUSTOM") @QueryParam("type") String type, @Valid@ApiParam(value = "Tenant/Application name to filter the retrieval of customizations.") @QueryParam("name") String name, @Valid@ApiParam(value = "Locale to filter the retrieval of customizations.") @QueryParam("locale") String locale) { + public Response resolveBrandingPreference( @Valid@ApiParam(value = "Type to filter the retrieval of customizations.", allowableValues="ORG, APP, CUSTOM") @QueryParam("type") String type, @Valid@ApiParam(value = "Tenant/Application name to filter the retrieval of customizations.") @QueryParam("name") String name, @Valid@ApiParam(value = "Locale to filter the retrieval of customizations.") @QueryParam("locale") String locale, @Valid@ApiParam(value = "Specifies whether to use only published branding preferences for resolving. If set to true, branding preference will be resolved only using published branding preferences. If set to false, branding preference will be resolved using both published and unpublished branding preferences. ", defaultValue="false") @DefaultValue("false") @QueryParam("restrictToPublished") Boolean restrictToPublished) { - return delegate.resolveBrandingPreference(type, name, locale ); + return delegate.resolveBrandingPreference(type, name, locale, restrictToPublished ); } @Valid diff --git a/components/org.wso2.carbon.identity.api.server.branding.preference.management/org.wso2.carbon.identity.api.server.branding.preference.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/branding/preference/management/v1/BrandingPreferenceApiService.java b/components/org.wso2.carbon.identity.api.server.branding.preference.management/org.wso2.carbon.identity.api.server.branding.preference.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/branding/preference/management/v1/BrandingPreferenceApiService.java index 44f3b81aae..e2cfaf60ac 100644 --- a/components/org.wso2.carbon.identity.api.server.branding.preference.management/org.wso2.carbon.identity.api.server.branding.preference.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/branding/preference/management/v1/BrandingPreferenceApiService.java +++ b/components/org.wso2.carbon.identity.api.server.branding.preference.management/org.wso2.carbon.identity.api.server.branding.preference.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/branding/preference/management/v1/BrandingPreferenceApiService.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023, WSO2 LLC. (http://www.wso2.com). + * Copyright (c) 2021-2024, WSO2 LLC. (http://www.wso2.com). * * WSO2 LLC. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except @@ -44,7 +44,7 @@ public interface BrandingPreferenceApiService { public Response getCustomText(String type, String name, String locale, String screen); - public Response resolveBrandingPreference(String type, String name, String locale); + public Response resolveBrandingPreference(String type, String name, String locale, Boolean restrictToPublished); public Response resolveCustomText(String type, String name, String locale, String screen); diff --git a/components/org.wso2.carbon.identity.api.server.branding.preference.management/org.wso2.carbon.identity.api.server.branding.preference.management.v1/src/main/java/org/wso2/carbon/identity/api/server/branding/preference/management/v1/core/BrandingPreferenceManagementService.java b/components/org.wso2.carbon.identity.api.server.branding.preference.management/org.wso2.carbon.identity.api.server.branding.preference.management.v1/src/main/java/org/wso2/carbon/identity/api/server/branding/preference/management/v1/core/BrandingPreferenceManagementService.java index d264f62e09..133e1d240e 100644 --- a/components/org.wso2.carbon.identity.api.server.branding.preference.management/org.wso2.carbon.identity.api.server.branding.preference.management.v1/src/main/java/org/wso2/carbon/identity/api/server/branding/preference/management/v1/core/BrandingPreferenceManagementService.java +++ b/components/org.wso2.carbon.identity.api.server.branding.preference.management/org.wso2.carbon.identity.api.server.branding.preference.management.v1/src/main/java/org/wso2/carbon/identity/api/server/branding/preference/management/v1/core/BrandingPreferenceManagementService.java @@ -191,6 +191,21 @@ So always use locale as default locale(en-US). */ public BrandingPreferenceModel resolveBrandingPreference(String type, String name, String locale) { + return resolveBrandingPreference(type, name, locale, false); + } + + /** + * Retrieve the resolved branding preferences. + * + * @param type Resource Type. + * @param name Name. + * @param locale Language preference. + * @param restrictToPublished Whether to resolve using only published branding preferences. + * @return The resolved branding preference resource. If not exists return the default preferences. + */ + public BrandingPreferenceModel resolveBrandingPreference(String type, String name, String locale, + boolean restrictToPublished) { + /* Currently this API provides the support to only configure organization wise & application wise branding preference for 'en-US' locale. @@ -202,11 +217,11 @@ So always locale as default locale(en-US). if (APPLICATION_TYPE.equals(type)) { // Get application specific branding preference. responseDTO = BrandingPreferenceServiceHolder.getBrandingPreferenceManager(). - resolveBrandingPreference(APPLICATION_TYPE, name, DEFAULT_LOCALE); + resolveBrandingPreference(APPLICATION_TYPE, name, DEFAULT_LOCALE, restrictToPublished); } else { // Get default branding preference. responseDTO = BrandingPreferenceServiceHolder.getBrandingPreferenceManager(). - resolveBrandingPreference(ORGANIZATION_TYPE, tenantDomain, DEFAULT_LOCALE); + resolveBrandingPreference(ORGANIZATION_TYPE, tenantDomain, DEFAULT_LOCALE, restrictToPublished); } return buildBrandingResponseFromResponseDTO(responseDTO); diff --git a/components/org.wso2.carbon.identity.api.server.branding.preference.management/org.wso2.carbon.identity.api.server.branding.preference.management.v1/src/main/java/org/wso2/carbon/identity/api/server/branding/preference/management/v1/impl/BrandingPreferenceApiServiceImpl.java b/components/org.wso2.carbon.identity.api.server.branding.preference.management/org.wso2.carbon.identity.api.server.branding.preference.management.v1/src/main/java/org/wso2/carbon/identity/api/server/branding/preference/management/v1/impl/BrandingPreferenceApiServiceImpl.java index e91052374a..faee49b12b 100644 --- a/components/org.wso2.carbon.identity.api.server.branding.preference.management/org.wso2.carbon.identity.api.server.branding.preference.management.v1/src/main/java/org/wso2/carbon/identity/api/server/branding/preference/management/v1/impl/BrandingPreferenceApiServiceImpl.java +++ b/components/org.wso2.carbon.identity.api.server.branding.preference.management/org.wso2.carbon.identity.api.server.branding.preference.management.v1/src/main/java/org/wso2/carbon/identity/api/server/branding/preference/management/v1/impl/BrandingPreferenceApiServiceImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023, WSO2 LLC. (http://www.wso2.com). + * Copyright (c) 2021-2024, WSO2 LLC. (http://www.wso2.com). * * WSO2 LLC. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except @@ -203,15 +203,15 @@ public Response getCustomText(String type, String name, String locale, String sc } @Override - public Response resolveBrandingPreference(String type, String name, String locale) { + public Response resolveBrandingPreference(String type, String name, String locale, Boolean restrictToPublished) { if (type != null) { if (!(ORGANIZATION_TYPE.equals(type) || APPLICATION_TYPE.equals(type) || CUSTOM_TYPE.equals(type))) { return Response.status(Response.Status.BAD_REQUEST).build(); } } - return Response.ok() - .entity(brandingPreferenceManagementService.resolveBrandingPreference(type, name, locale)).build(); + return Response.ok().entity(brandingPreferenceManagementService + .resolveBrandingPreference(type, name, locale, restrictToPublished)).build(); } @Override diff --git a/components/org.wso2.carbon.identity.api.server.branding.preference.management/org.wso2.carbon.identity.api.server.branding.preference.management.v1/src/main/resources/branding-preference.yaml b/components/org.wso2.carbon.identity.api.server.branding.preference.management/org.wso2.carbon.identity.api.server.branding.preference.management.v1/src/main/resources/branding-preference.yaml index 4777810dc8..724caf7150 100644 --- a/components/org.wso2.carbon.identity.api.server.branding.preference.management/org.wso2.carbon.identity.api.server.branding.preference.management.v1/src/main/resources/branding-preference.yaml +++ b/components/org.wso2.carbon.identity.api.server.branding.preference.management/org.wso2.carbon.identity.api.server.branding.preference.management.v1/src/main/resources/branding-preference.yaml @@ -181,6 +181,7 @@ paths: - $ref: '#/components/parameters/typeQueryParam' - $ref: '#/components/parameters/nameQueryParam' - $ref: '#/components/parameters/localeQueryParam' + - $ref: '#/components/parameters/restrictToPublishedQueryParam' responses: '200': description: OK @@ -404,6 +405,18 @@ components: schema: type: string example: "login" + restrictToPublishedQueryParam: + in: query + name: restrictToPublished + required: false + description: | + Specifies whether to use only published branding preferences for resolving. + If set to true, branding preference will be resolved only using published branding preferences. + If set to false, branding preference will be resolved using both published and unpublished branding preferences. + schema: + type: boolean + default: false + example: true schemas: BrandingPreferenceModel: From 03bc0b888a6e887b93b731dc6ecdaa0e54de7271 Mon Sep 17 00:00:00 2001 From: dhaura Date: Mon, 12 Aug 2024 09:16:17 +0530 Subject: [PATCH 2/2] Bump branding preference mgt version. --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5bbc49615a..4da643f7e7 100644 --- a/pom.xml +++ b/pom.xml @@ -818,7 +818,7 @@ 2.5.15 4.10.7 5.2.15 - 1.1.13 + 1.1.16 1.2.4