Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add API Support to Resolve Branding Preferences only using Published Preferences #637

Merged
merged 2 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ paths:
- $ref: '#/components/parameters/typeQueryParam'
- $ref: '#/components/parameters/nameQueryParam'
- $ref: '#/components/parameters/localeQueryParam'
- $ref: '#/components/parameters/restrictToPublishedQueryParam'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we need to support this query param in branding-preference/text/resolve API as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix for text customizations is tracked by wso2/product-is#20858

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update the yaml in docs as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

responses:
'200':
description: OK
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -818,7 +818,7 @@
<org.wso2.carbon.identity.oauth2.token.handler.clientauth.jwt.version>2.5.15</org.wso2.carbon.identity.oauth2.token.handler.clientauth.jwt.version>
<org.wso2.carbon.logging.service.version>4.10.7</org.wso2.carbon.logging.service.version>
<org.wso2.carbon.event.publisher.version>5.2.15</org.wso2.carbon.event.publisher.version>
<identity.branding.preference.management.version>1.1.13</identity.branding.preference.management.version>
<identity.branding.preference.management.version>1.1.16</identity.branding.preference.management.version>
<apache.felix.scr.ds.annotations.version>1.2.4</apache.felix.scr.ds.annotations.version>

<!--<maven.checkstyleplugin.excludes>**/gen/**/*</maven.checkstyleplugin.excludes>-->
Expand Down
Loading