diff --git a/components/org.wso2.carbon.identity.api.server.branding.preference.management/org.wso2.carbon.identity.api.server.branding.preference.management.common/src/main/java/org/wso2/carbon/identity/api/server/branding/preference/management/common/BrandingPreferenceManagementConstants.java b/components/org.wso2.carbon.identity.api.server.branding.preference.management/org.wso2.carbon.identity.api.server.branding.preference.management.common/src/main/java/org/wso2/carbon/identity/api/server/branding/preference/management/common/BrandingPreferenceManagementConstants.java index 524e51516b..332aa679ea 100644 --- a/components/org.wso2.carbon.identity.api.server.branding.preference.management/org.wso2.carbon.identity.api.server.branding.preference.management.common/src/main/java/org/wso2/carbon/identity/api/server/branding/preference/management/common/BrandingPreferenceManagementConstants.java +++ b/components/org.wso2.carbon.identity.api.server.branding.preference.management/org.wso2.carbon.identity.api.server.branding.preference.management.common/src/main/java/org/wso2/carbon/identity/api/server/branding/preference/management/common/BrandingPreferenceManagementConstants.java @@ -97,7 +97,10 @@ public enum ErrorMessage { "Error while retrieving branding preference generation result status for operation."), ERROR_CODE_ERROR_GETTING_BRANDING_RESULT("65010", "Error while getting branding preference generation result.", - "Error while retrieving branding preference generation result for operation."); + "Error while retrieving branding preference generation result for operation."), + ERROR_WHILE_CONVERTING_BRANDING_AI_SERVER_RESPONSE("65602", + "Error occurred while converting the AI server response.", + "Could not convert the AI server response to a valid response."); private final String code; 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 c127961558..8b0e23e5c7 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 @@ -159,11 +159,9 @@ public Response deleteCustomText( @Valid@ApiParam(value = "Type to filter the @ApiResponses(value = { @ApiResponse(code = 202, message = "Branding generation process started", response = BrandingGenerationResponseModel.class), @ApiResponse(code = 400, message = "Invalid input in the request.", response = Error.class), - @ApiResponse(code = 401, message = "Authentication information is missing or invalid.", response = Void.class), - @ApiResponse(code = 403, message = "Access forbidden.", response = Void.class), - @ApiResponse(code = 409, message = "Conflict.", response = Error.class), - @ApiResponse(code = 500, message = "Internal server error.", response = Error.class), - @ApiResponse(code = 501, message = "Not Implemented.", response = Error.class) + @ApiResponse(code = 401, message = "Unauthorized", response = Error.class), + @ApiResponse(code = 403, message = "Forbidden", response = Error.class), + @ApiResponse(code = 500, message = "Internal server error.", response = Error.class) }) public Response generateBrandingPreference(@ApiParam(value = "This represents the properties of the organization used to generate branding preferences, including the organization's website URL." ,required=true) @Valid BrandingGenerationRequestModel brandingGenerationRequestModel) { @@ -182,7 +180,12 @@ public Response generateBrandingPreference(@ApiParam(value = "This represents th }) }, tags={ "Branding Preference", }) @ApiResponses(value = { - @ApiResponse(code = 200, message = "OK", response = BrandingGenerationResultModel.class) + @ApiResponse(code = 200, message = "OK", response = BrandingGenerationResultModel.class), + @ApiResponse(code = 400, message = "Invalid input in the request.", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized", response = Error.class), + @ApiResponse(code = 403, message = "Forbidden", response = Error.class), + @ApiResponse(code = 404, message = "Requested resource is not found.", response = Error.class), + @ApiResponse(code = 500, message = "Internal server error.", response = Error.class) }) public Response getBrandingGenerationResult(@ApiParam(value = "The unique identifier for the branding generation operation.",required=true) @PathParam("operationId") String operationId) { @@ -203,8 +206,8 @@ public Response getBrandingGenerationResult(@ApiParam(value = "The unique identi @ApiResponses(value = { @ApiResponse(code = 200, message = "OK", response = BrandingGenerationStatusModel.class), @ApiResponse(code = 400, message = "Invalid input in the request.", response = Error.class), - @ApiResponse(code = 401, message = "Authentication information is missing or invalid.", response = Void.class), - @ApiResponse(code = 403, message = "Access forbidden.", response = Void.class), + @ApiResponse(code = 401, message = "Unauthorized", response = Error.class), + @ApiResponse(code = 403, message = "Forbidden", response = Error.class), @ApiResponse(code = 404, message = "Requested resource is not found.", response = Error.class), @ApiResponse(code = 500, message = "Internal server error.", response = Error.class) }) 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/model/BrandingGenerationRequestModel.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/model/BrandingGenerationRequestModel.java index cd9ccec85e..3de1b48f08 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/model/BrandingGenerationRequestModel.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/model/BrandingGenerationRequestModel.java @@ -35,7 +35,7 @@ public class BrandingGenerationRequestModel { private String websiteUrl; /** - * URL of the company's website. + * URL of the organization's website. **/ public BrandingGenerationRequestModel websiteUrl(String websiteUrl) { @@ -43,7 +43,7 @@ public BrandingGenerationRequestModel websiteUrl(String websiteUrl) { return this; } - @ApiModelProperty(value = "URL of the company's website.") + @ApiModelProperty(example = "https://wso2.com/", value = "URL of the organization's website.") @JsonProperty("websiteUrl") @Valid public String getWebsiteUrl() { 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/model/BrandingGenerationStatusModel.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/model/BrandingGenerationStatusModel.java index 17e72e9ffe..fb78329661 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/model/BrandingGenerationStatusModel.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/model/BrandingGenerationStatusModel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). + * Copyright (c) 2025, 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 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/model/BrandingPreferenceModel.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/model/BrandingPreferenceModel.java index 5fd6e030cf..e45593cfd2 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/model/BrandingPreferenceModel.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/model/BrandingPreferenceModel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). + * Copyright (c) 2025, 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 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/BrandingAIPreferenceManagementService.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/BrandingAIPreferenceManagementService.java index 415f731d64..920556c372 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/BrandingAIPreferenceManagementService.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/BrandingAIPreferenceManagementService.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). + * Copyright (c) 2025, 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 @@ -38,6 +38,7 @@ import static org.wso2.carbon.identity.api.server.branding.preference.management.common.BrandingPreferenceManagementConstants.ErrorMessage.ERROR_CODE_ERROR_GETTING_BRANDING_RESULT; import static org.wso2.carbon.identity.api.server.branding.preference.management.common.BrandingPreferenceManagementConstants.ErrorMessage.ERROR_CODE_ERROR_GETTING_BRANDING_RESULT_STATUS; +import static org.wso2.carbon.identity.api.server.branding.preference.management.common.BrandingPreferenceManagementConstants.ErrorMessage.ERROR_WHILE_CONVERTING_BRANDING_AI_SERVER_RESPONSE; /** * Service class for AI branding preference management. @@ -166,7 +167,7 @@ private APIError handleServerException(AIServerException error) { return new APIError(Response.Status.INTERNAL_SERVER_ERROR, errorResponseBuilder.build()); } - private static Map convertObjectToMap(Object object) { + private static Map convertObjectToMap(Object object) throws AIServerException { if (object instanceof Map) { Map map = new HashMap<>(); @@ -186,11 +187,11 @@ private static Map convertObjectToMap(Object object) { } return map; } - LOG.warn("Object is not an instance of Map. Returning an empty map."); - return new HashMap<>(); + throw new AIServerException(ERROR_WHILE_CONVERTING_BRANDING_AI_SERVER_RESPONSE.getMessage(), + ERROR_WHILE_CONVERTING_BRANDING_AI_SERVER_RESPONSE.getCode()); } - private static Object[] convertListToArray(List list) { + private static Object[] convertListToArray(List list) throws AIServerException { Object[] array = new Object[list.size()]; for (int i = 0; i < list.size(); i++) { @@ -208,6 +209,3 @@ private static Object[] convertListToArray(List list) { return array; } } - - - 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 d9362307ac..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 @@ -71,6 +71,7 @@ public class BrandingPreferenceManagementService { private static final Log log = LogFactory.getLog(BrandingPreferenceManagementService.class); + /** * Create a branding preference resource with a resource file. * 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 1517d8a210..73539a69e6 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 @@ -287,7 +287,18 @@ public Response updateBrandingPreference(BrandingPreferenceModel brandingPrefere @Override public Response updateCustomText(CustomTextModel customTextModel) { - // do some magic! - return Response.ok().entity("magic!").build(); + if (StringUtils.isBlank(customTextModel.getType().toString())) { + return Response.status(Response.Status.BAD_REQUEST).build(); + } + if (!ORGANIZATION_TYPE.equals(customTextModel.getType().toString())) { + return Response.status(Response.Status.NOT_FOUND).build(); + } + if (StringUtils.isBlank(customTextModel.getScreen())) { + return Response.status(Response.Status.BAD_REQUEST).build(); + } + + CustomTextModel updatedCustomTextModel = + brandingPreferenceManagementService.updateCustomTextPreference(customTextModel); + return Response.ok().entity(updatedCustomTextModel).build(); } } 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 e63ec101d7..651cfa6529 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 @@ -225,15 +225,19 @@ paths: '400': $ref: '#/components/responses/BadRequest' '401': - $ref: '#/components/responses/Unauthorized' + description: Unauthorized + content: + application/json: + schema: + $ref: '#/components/schemas/Error' '403': - $ref: '#/components/responses/Forbidden' - '409': - $ref: '#/components/responses/Conflict' + description: Forbidden + content: + application/json: + schema: + $ref: '#/components/schemas/Error' '500': $ref: '#/components/responses/ServerError' - '501': - $ref: '#/components/responses/NotImplemented' '/branding-preference/status/{operationId}': get: tags: @@ -254,9 +258,17 @@ paths: '400': $ref: '#/components/responses/BadRequest' '401': - $ref: '#/components/responses/Unauthorized' + description: Unauthorized + content: + application/json: + schema: + $ref: '#/components/schemas/Error' '403': - $ref: '#/components/responses/Forbidden' + description: Forbidden + content: + application/json: + schema: + $ref: '#/components/schemas/Error' '404': $ref: '#/components/responses/NotFound' '500': @@ -278,6 +290,24 @@ paths: 'application/json': schema: $ref: '#/components/schemas/BrandingGenerationResultModel' + '400': + $ref: '#/components/responses/BadRequest' + '401': + description: Unauthorized + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '403': + description: Forbidden + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '404': + $ref: '#/components/responses/NotFound' + '500': + $ref: '#/components/responses/ServerError' '/branding-preference/text': get: @@ -564,16 +594,13 @@ components: BrandingGenerationRequestModel: type: object properties: - # Define properties related to the organization that are used to generate branding preferences - # Example property: websiteUrl: type: string - description: URL of the company's website. + description: URL of the organization's website. + example: "https://wso2.com/" BrandingGenerationResponseModel: type: object properties: - # Define properties related to the organization that are used to generate branding preferences - # Example property: operationId: type: string description: Operation id of the initiated branding generation process.