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

Include org name in list discovery attributes of organizations API #512

Merged
merged 1 commit into from
Oct 21, 2023
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
Expand Up @@ -36,6 +36,7 @@
public class OrganizationDiscoveryResponse {

private String organizationId;
private String organizationName;
private List<DiscoveryAttribute> attributes = new ArrayList<>();


Expand All @@ -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<DiscoveryAttribute> attributes) {
Expand Down Expand Up @@ -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
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -483,21 +483,21 @@ public Response getOrganizationsDiscoveryAttributes(String filter, Integer offse

handleNotImplementedCapabilities(filter, offset, limit);
try {
Map<String, List<OrgDiscoveryAttribute>> organizationsDiscoveryAttributes =
List<OrganizationDiscovery> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@
</org.wso2.carbon.identity.organization.management.core.version.range>

<!-- Organization management service Version -->
<org.wso2.carbon.identity.organization.management.version>1.3.73
<org.wso2.carbon.identity.organization.management.version>1.3.85
</org.wso2.carbon.identity.organization.management.version>

<!-- Unit test versions -->
Expand Down
Loading