From c4d738296deb0a0c105c951fc434d4e7a922fdb9 Mon Sep 17 00:00:00 2001 From: dewniMW Date: Sat, 21 Oct 2023 19:26:04 +0530 Subject: [PATCH] Include org name in list discovery attributes of organizations API --- .../model/OrganizationDiscoveryResponse.java | 26 ++++++++++++++++++- .../OrganizationManagementService.java | 14 +++++----- ...rbon.identity.organization.management.yaml | 5 ++++ pom.xml | 2 +- 4 files changed, 38 insertions(+), 9 deletions(-) diff --git a/components/org.wso2.carbon.identity.api.server.organization.management/org.wso2.carbon.identity.api.server.organization.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/organization/management/v1/model/OrganizationDiscoveryResponse.java b/components/org.wso2.carbon.identity.api.server.organization.management/org.wso2.carbon.identity.api.server.organization.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/organization/management/v1/model/OrganizationDiscoveryResponse.java index 6bc74dd741..195c76c9dd 100644 --- a/components/org.wso2.carbon.identity.api.server.organization.management/org.wso2.carbon.identity.api.server.organization.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/organization/management/v1/model/OrganizationDiscoveryResponse.java +++ b/components/org.wso2.carbon.identity.api.server.organization.management/org.wso2.carbon.identity.api.server.organization.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/organization/management/v1/model/OrganizationDiscoveryResponse.java @@ -36,6 +36,7 @@ public class OrganizationDiscoveryResponse { private String organizationId; + private String organizationName; private List attributes = new ArrayList<>(); @@ -60,6 +61,27 @@ public void setOrganizationId(String organizationId) { this.organizationId = organizationId; } + /** + * The name of the organization. + **/ + public OrganizationDiscoveryResponse organizationName(String organizationName) { + + this.organizationName = organizationName; + return this; + } + + @ApiModelProperty(example = "ABC Builders", required = true, value = "The name of the organization.") + @JsonProperty("organizationName") + @Valid + @NotNull(message = "Property organizationName cannot be null.") + + public String getOrganizationName() { + return organizationName; + } + public void setOrganizationName(String organizationName) { + this.organizationName = organizationName; + } + /** **/ public OrganizationDiscoveryResponse attributes(List attributes) { @@ -98,12 +120,13 @@ public boolean equals(java.lang.Object o) { } OrganizationDiscoveryResponse organizationDiscoveryResponse = (OrganizationDiscoveryResponse) o; return Objects.equals(this.organizationId, organizationDiscoveryResponse.organizationId) && + Objects.equals(this.organizationName, organizationDiscoveryResponse.organizationName) && Objects.equals(this.attributes, organizationDiscoveryResponse.attributes); } @Override public int hashCode() { - return Objects.hash(organizationId, attributes); + return Objects.hash(organizationId, organizationName, attributes); } @Override @@ -113,6 +136,7 @@ public String toString() { sb.append("class OrganizationDiscoveryResponse {\n"); sb.append(" organizationId: ").append(toIndentedString(organizationId)).append("\n"); + sb.append(" organizationName: ").append(toIndentedString(organizationName)).append("\n"); sb.append(" attributes: ").append(toIndentedString(attributes)).append("\n"); sb.append("}"); return sb.toString(); diff --git a/components/org.wso2.carbon.identity.api.server.organization.management/org.wso2.carbon.identity.api.server.organization.management.v1/src/main/java/org/wso2/carbon/identity/api/server/organization/management/v1/service/OrganizationManagementService.java b/components/org.wso2.carbon.identity.api.server.organization.management/org.wso2.carbon.identity.api.server.organization.management.v1/src/main/java/org/wso2/carbon/identity/api/server/organization/management/v1/service/OrganizationManagementService.java index 5f8e1f62cc..4fa6b5298e 100644 --- a/components/org.wso2.carbon.identity.api.server.organization.management/org.wso2.carbon.identity.api.server.organization.management.v1/src/main/java/org/wso2/carbon/identity/api/server/organization/management/v1/service/OrganizationManagementService.java +++ b/components/org.wso2.carbon.identity.api.server.organization.management/org.wso2.carbon.identity.api.server.organization.management.v1/src/main/java/org/wso2/carbon/identity/api/server/organization/management/v1/service/OrganizationManagementService.java @@ -53,6 +53,7 @@ import org.wso2.carbon.identity.core.util.IdentityUtil; import org.wso2.carbon.identity.organization.discovery.service.OrganizationDiscoveryManager; import org.wso2.carbon.identity.organization.discovery.service.model.OrgDiscoveryAttribute; +import org.wso2.carbon.identity.organization.discovery.service.model.OrganizationDiscovery; import org.wso2.carbon.identity.organization.management.application.OrgApplicationManager; import org.wso2.carbon.identity.organization.management.application.model.SharedApplication; import org.wso2.carbon.identity.organization.management.service.OrganizationManager; @@ -75,7 +76,6 @@ import java.util.Base64; import java.util.Collections; import java.util.List; -import java.util.Map; import java.util.Optional; import java.util.stream.Collectors; @@ -483,21 +483,21 @@ public Response getOrganizationsDiscoveryAttributes(String filter, Integer offse handleNotImplementedCapabilities(filter, offset, limit); try { - Map> organizationsDiscoveryAttributes = + List organizationsDiscoveryAttributes = getOrganizationDiscoveryManager().getOrganizationsDiscoveryAttributes(); OrganizationsDiscoveryResponse response = new OrganizationsDiscoveryResponse(); - organizationsDiscoveryAttributes.forEach((key, value) -> { + for (OrganizationDiscovery organizationDiscovery : organizationsDiscoveryAttributes) { OrganizationDiscoveryResponse organizationDiscoveryResponse = new OrganizationDiscoveryResponse(); - organizationDiscoveryResponse.setOrganizationId(key); - value.forEach(orgDiscoveryAttribute -> { + organizationDiscoveryResponse.setOrganizationId(organizationDiscovery.getOrganizationId()); + organizationDiscoveryResponse.setOrganizationName(organizationDiscovery.getOrganizationName()); + organizationDiscovery.getDiscoveryAttributes().forEach(orgDiscoveryAttribute -> { DiscoveryAttribute organizationDiscoveryAttributeResponse = new DiscoveryAttribute(); organizationDiscoveryAttributeResponse.setType(orgDiscoveryAttribute.getType()); organizationDiscoveryAttributeResponse.setValues(orgDiscoveryAttribute.getValues()); organizationDiscoveryResponse.addAttributesItem(organizationDiscoveryAttributeResponse); - }); response.addOrganizationsItem(organizationDiscoveryResponse); - }); + } return Response.ok(response).build(); } catch (OrganizationManagementClientException e) { return OrganizationManagementEndpointUtil.handleClientErrorResponse(e, LOG); diff --git a/components/org.wso2.carbon.identity.api.server.organization.management/org.wso2.carbon.identity.api.server.organization.management.v1/src/main/resources/org.wso2.carbon.identity.organization.management.yaml b/components/org.wso2.carbon.identity.api.server.organization.management/org.wso2.carbon.identity.api.server.organization.management.v1/src/main/resources/org.wso2.carbon.identity.organization.management.yaml index eed3f8c660..22750759b6 100644 --- a/components/org.wso2.carbon.identity.api.server.organization.management/org.wso2.carbon.identity.api.server.organization.management.v1/src/main/resources/org.wso2.carbon.identity.organization.management.yaml +++ b/components/org.wso2.carbon.identity.api.server.organization.management/org.wso2.carbon.identity.api.server.organization.management.v1/src/main/resources/org.wso2.carbon.identity.organization.management.yaml @@ -1229,12 +1229,17 @@ components: type: object required: - organizationId + - organizationName - attributes properties: organizationId: type: string description: The ID of the organization. example: '06c1f4e2-3339-44e4-a825-96585e3653b1' + organizationName: + type: string + description: The name of the organization. + example: 'ABC Builders' attributes: type: array items: diff --git a/pom.xml b/pom.xml index ffa8394c3b..f8ecb9eb4d 100644 --- a/pom.xml +++ b/pom.xml @@ -789,7 +789,7 @@ - 1.3.73 + 1.3.85