From 6223a562d6e7a033eebbb180fb7df12fb461e863 Mon Sep 17 00:00:00 2001 From: dewniMW Date: Thu, 5 Oct 2023 15:48:27 +0530 Subject: [PATCH] Address review comments --- .../OrganizationManagementService.java | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) 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 48bf4e0bff..6b94b0ab0b 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 @@ -101,6 +101,8 @@ public class OrganizationManagementService { private static final Log LOG = LogFactory.getLog(OrganizationManagementService.class); + private static final OrganizationDiscoveryManager organizationDiscoveryManager = + OrganizationManagementServiceHolder.getInstance().getOrganizationDiscoveryManager(); /** * Retrieve organization IDs. @@ -399,7 +401,7 @@ public Response addOrganizationDiscoveryAttributes(OrganizationDiscoveryPostRequ organizationDiscoveryPostRequest) { try { - List orgDiscoveryAttributeList = getOrganizationDiscoveryManager() + List orgDiscoveryAttributeList = organizationDiscoveryManager .addOrganizationDiscoveryAttributes(organizationDiscoveryPostRequest.getOrganizationId(), getOrgDiscoveryAttributesFromPostRequest(organizationDiscoveryPostRequest), true); String organizationId = organizationDiscoveryPostRequest.getOrganizationId(); @@ -421,7 +423,7 @@ public Response addOrganizationDiscoveryAttributes(OrganizationDiscoveryPostRequ public Response getOrganizationDiscoveryAttributes(String organizationId) { try { - List orgDiscoveryAttributeList = getOrganizationDiscoveryManager() + List orgDiscoveryAttributeList = organizationDiscoveryManager .getOrganizationDiscoveryAttributes(organizationId, true); return Response.ok().entity(getOrganizationDiscoveryAttributesResponse(orgDiscoveryAttributeList)).build(); } catch (OrganizationManagementClientException e) { @@ -443,7 +445,7 @@ public Response updateOrganizationDiscoveryAttributes(String organizationId, Org organizationDiscoveryAttributes) { try { - List orgDiscoveryAttributeList = getOrganizationDiscoveryManager() + List orgDiscoveryAttributeList = organizationDiscoveryManager .updateOrganizationDiscoveryAttributes(organizationId, getOrgDiscoveryAttributesFromPutRequest(organizationDiscoveryAttributes), true); return Response.ok().entity(getOrganizationDiscoveryAttributesResponse(orgDiscoveryAttributeList)).build(); @@ -463,7 +465,7 @@ public Response updateOrganizationDiscoveryAttributes(String organizationId, Org public Response deleteOrganizationDiscoveryAttributes(String organizationId) { try { - getOrganizationDiscoveryManager().deleteOrganizationDiscoveryAttributes(organizationId, true); + organizationDiscoveryManager.deleteOrganizationDiscoveryAttributes(organizationId, true); return Response.noContent().build(); } catch (OrganizationManagementClientException e) { return OrganizationManagementEndpointUtil.handleClientErrorResponse(e, LOG); @@ -485,7 +487,7 @@ public Response getOrganizationsDiscoveryAttributes(String filter, Integer offse handleNotImplementedCapabilities(filter, offset, limit); try { Map> organizationsDiscoveryAttributes = - getOrganizationDiscoveryManager().getOrganizationsDiscoveryAttributes(); + organizationDiscoveryManager.getOrganizationsDiscoveryAttributes(); OrganizationsDiscoveryResponse response = new OrganizationsDiscoveryResponse(); organizationsDiscoveryAttributes.forEach((key, value) -> { OrganizationDiscoveryResponse organizationDiscoveryResponse = new OrganizationDiscoveryResponse(); @@ -517,7 +519,7 @@ public Response isDiscoveryAttributeAvailable(OrganizationDiscoveryCheckPOSTRequ organizationDiscoveryCheckPOSTRequest) { try { - boolean discoveryAttributeValueAvailable = getOrganizationDiscoveryManager() + boolean discoveryAttributeValueAvailable = organizationDiscoveryManager .isDiscoveryAttributeValueAvailable(organizationDiscoveryCheckPOSTRequest.getType(), organizationDiscoveryCheckPOSTRequest.getValue()); OrganizationDiscoveryCheckPOSTResponse organizationDiscoveryCheckPOSTResponse = @@ -540,7 +542,7 @@ public Response getOrganizationMetadata() { try { Organization organization = getOrganizationManager().getOrganization(getOrganizationId(), false, true); - List organizationDiscoveryAttributes = getOrganizationDiscoveryManager() + List organizationDiscoveryAttributes = organizationDiscoveryManager .getOrganizationDiscoveryAttributes(getOrganizationId(), false); return Response.ok().entity(getOrganizationMetadataResponse(organization, organizationDiscoveryAttributes)) .build(); @@ -946,9 +948,4 @@ private OrgApplicationManager getOrgApplicationManager() { return OrganizationManagementServiceHolder.getInstance().getOrgApplicationManager(); } - - private OrganizationDiscoveryManager getOrganizationDiscoveryManager() { - - return OrganizationManagementServiceHolder.getInstance().getOrganizationDiscoveryManager(); - } }