From 64e2f48a072cb7de78ef955fcf66fa211d6768cd Mon Sep 17 00:00:00 2001 From: dewniMW Date: Sat, 21 Oct 2023 16:47:40 +0530 Subject: [PATCH] Improve list discovery attributes of organizations method --- .../service/dao/OrganizationDiscoveryDAOImpl.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/components/org.wso2.carbon.identity.organization.discovery.service/src/main/java/org/wso2/carbon/identity/organization/discovery/service/dao/OrganizationDiscoveryDAOImpl.java b/components/org.wso2.carbon.identity.organization.discovery.service/src/main/java/org/wso2/carbon/identity/organization/discovery/service/dao/OrganizationDiscoveryDAOImpl.java index 41e91021e..51367c689 100644 --- a/components/org.wso2.carbon.identity.organization.discovery.service/src/main/java/org/wso2/carbon/identity/organization/discovery/service/dao/OrganizationDiscoveryDAOImpl.java +++ b/components/org.wso2.carbon.identity.organization.discovery.service/src/main/java/org/wso2/carbon/identity/organization/discovery/service/dao/OrganizationDiscoveryDAOImpl.java @@ -305,14 +305,14 @@ private List buildOrganizationsDiscoveryFromRawData( } else { List discoveryAttributes = existingDiscovery.getDiscoveryAttributes(); boolean attributeExists = false; - List newAttributeValues = new ArrayList<>(); + String newAttributeValue = null; List existingAttributeValues = null; - List attributeValues = new ArrayList<>(); for (OrgDiscoveryAttribute attribute : discoveryAttributes) { if (StringUtils.equals(attribute.getType(), attributeType)) { existingAttributeValues = attribute.getValues(); - newAttributeValues.add(attributeValue); + newAttributeValue = attributeValue; attributeExists = true; + break; } } @@ -320,11 +320,11 @@ private List buildOrganizationsDiscoveryFromRawData( for (OrgDiscoveryAttribute attribute : discoveryAttributes) { if (StringUtils.equals(attribute.getType(), attributeType)) { if (existingAttributeValues == null) { - attribute.setValues(newAttributeValues); + attribute.setValues(Collections.singletonList(newAttributeValue)); break; } - attributeValues.addAll(existingAttributeValues); - attributeValues.addAll(newAttributeValues); + List attributeValues = new ArrayList<>(existingAttributeValues); + attributeValues.add(newAttributeValue); attribute.setValues(attributeValues); break; }