Skip to content

Commit

Permalink
Add review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
HasiniSama committed Jul 14, 2024
1 parent 80f0063 commit a0d0372
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public MetaAttributesResponse links(List<Link> links) {
return this;
}

@ApiModelProperty(example = "[{\"href\":\"/o/10084a8d-113f-4211-a0d5-efe36b082211/api/server/v1/organizations/meta-attributes?limit=10&filter=key+co+country&next=MjAyMS0xMi0yMSAwNToxODozMS4wMDQzNDg=\",\"rel\":\"next\"},{\"href\":\"/o/10084a8d-113f-4211-a0d5-efe36b082211/api/server/v1/organizations/meta-attributes?limit=10&filter=key+co+country&before=MjAyMS0xMi0yMSAwNToxODozMS4wMDQzNDg=\",\"rel\":\"previous\"}]", value = "")
@ApiModelProperty(example = "[{\"href\":\"/o/api/server/v1/organizations/meta-attributes?limit=10&recursive=false&filter=attributes+co+C&after=MjAyMS0xMi0yMSAwNToxODozMS4wMDQzNDg=\",\"rel\":\"next\"},{\"href\":\"/o/api/server/v1/organizations/meta-attributes?limit=10&recursive=false&filter=attributes+co+C&before=MjAyMS0xMi0yMSAwNToxODozMS4wMDQzNDg=\",\"rel\":\"previous\"}]", value = "")
@JsonProperty("links")
@Valid
public List<Link> getLinks() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,10 @@
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.identity.api.server.common.Util;
import org.wso2.carbon.identity.api.server.organization.management.common.OrganizationManagementServiceHolder;
import org.wso2.carbon.identity.api.server.organization.management.v1.exceptions.OrganizationManagementEndpointException;
import org.wso2.carbon.identity.api.server.organization.management.v1.model.ApplicationSharePOSTRequest;
import org.wso2.carbon.identity.api.server.organization.management.v1.model.Attribute;
import org.wso2.carbon.identity.api.server.organization.management.v1.model.BasicOrganizationResponse;
import org.wso2.carbon.identity.api.server.organization.management.v1.model.DiscoveryAttribute;
import org.wso2.carbon.identity.api.server.organization.management.v1.model.Error;
import org.wso2.carbon.identity.api.server.organization.management.v1.model.GetOrganizationResponse;
import org.wso2.carbon.identity.api.server.organization.management.v1.model.Link;
import org.wso2.carbon.identity.api.server.organization.management.v1.model.MetaAttributesResponse;
Expand Down Expand Up @@ -558,7 +556,7 @@ public Response getOrganizationsMetaAttributes(String filter, Integer limit, Str

try {
limit = validateLimit(limit);
String sortOrder = StringUtils.isNotBlank(before) ? ASC_SORT_ORDER : DESC_SORT_ORDER;
String sortOrder = StringUtils.isNotBlank(before) ? DESC_SORT_ORDER : ASC_SORT_ORDER;
List<String> metaAttributes = getOrganizationManager().getOrganizationsMetaAttributes(limit + 1, after,
before, sortOrder, filter, Boolean.TRUE.equals(recursive));
return Response.ok().entity(getMetaAttributesResponse(limit, after, before, filter, metaAttributes,
Expand Down Expand Up @@ -739,12 +737,10 @@ private OrganizationsResponse getOrganizationsResponse(Integer limit, String aft
try {
url += "&filter=" + URLEncoder.encode(filter, StandardCharsets.UTF_8.name());
} catch (UnsupportedEncodingException e) {
LOG.error("Server encountered an error while building pagination URL for the response.", e);
Error error = OrganizationManagementEndpointUtil.getError(
ERROR_CODE_ERROR_BUILDING_PAGINATED_RESPONSE_URL.getCode(),
throw new OrganizationManagementServerException(
ERROR_CODE_ERROR_BUILDING_PAGINATED_RESPONSE_URL.getMessage(),
ERROR_CODE_ERROR_BUILDING_PAGINATED_RESPONSE_URL.getDescription());
throw new OrganizationManagementEndpointException(Response.Status.INTERNAL_SERVER_ERROR, error);
ERROR_CODE_ERROR_BUILDING_PAGINATED_RESPONSE_URL.getDescription(),
ERROR_CODE_ERROR_BUILDING_PAGINATED_RESPONSE_URL.getCode(), e);
}
}

Expand Down Expand Up @@ -956,17 +952,15 @@ private MetaAttributesResponse getMetaAttributesResponse(Integer limit, String a
(StringUtils.isNotBlank(before) && !hasMoreItems);
boolean isLastPage = !hasMoreItems && (StringUtils.isNotBlank(after) || StringUtils.isBlank(before));

String url = "?limit=" + limit + "&recursive=" + recursive;
String url = "/meta-attributes" + "?limit=" + limit + "&recursive=" + recursive;
if (StringUtils.isNotBlank(filter)) {
try {
url += "&filter=" + URLEncoder.encode(filter, StandardCharsets.UTF_8.name());
} catch (UnsupportedEncodingException e) {
LOG.error("Server encountered an error while building pagination URL for the response.", e);
Error error = OrganizationManagementEndpointUtil.getError(
ERROR_CODE_ERROR_BUILDING_PAGINATED_RESPONSE_URL.getCode(),
throw new OrganizationManagementServerException(
ERROR_CODE_ERROR_BUILDING_PAGINATED_RESPONSE_URL.getMessage(),
ERROR_CODE_ERROR_BUILDING_PAGINATED_RESPONSE_URL.getDescription());
throw new OrganizationManagementEndpointException(Response.Status.INTERNAL_SERVER_ERROR, error);
ERROR_CODE_ERROR_BUILDING_PAGINATED_RESPONSE_URL.getDescription(),
ERROR_CODE_ERROR_BUILDING_PAGINATED_RESPONSE_URL.getCode(), e);
}
}
if (hasMoreItems) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1123,12 +1123,12 @@ components:
example:
[
{
"href": "/o/10084a8d-113f-4211-a0d5-efe36b082211/api/server/v1/organizations/meta-attributes?limit=10&filter=key+co+country&next=MjAyMS0xMi0yMSAwNToxODozMS4wMDQzNDg=",
"href": "/o/api/server/v1/organizations/meta-attributes?limit=10&recursive=false&filter=attributes+co+C&after=MjAyMS0xMi0yMSAwNToxODozMS4wMDQzNDg=",
"rel": "next",
}, {
"href": "/o/10084a8d-113f-4211-a0d5-efe36b082211/api/server/v1/organizations/meta-attributes?limit=10&filter=key+co+country&before=MjAyMS0xMi0yMSAwNToxODozMS4wMDQzNDg=",
"rel": "previous",
}
"href": "/o/api/server/v1/organizations/meta-attributes?limit=10&recursive=false&filter=attributes+co+C&before=MjAyMS0xMi0yMSAwNToxODozMS4wMDQzNDg=",
"rel": "previous",
}
]
attributes:
type: array
Expand Down Expand Up @@ -1273,9 +1273,9 @@ components:
"href": "/o/10084a8d-113f-4211-a0d5-efe36b082211/api/server/v1/organizations/discovery?filter=attributes.type+eq+emailDomain&limit=10&offset=50",
"rel": "next",
}, {
"href": "/o/10084a8d-113f-4211-a0d5-efe36b082211/api/server/v1/organizations/discovery?filter=attributes.type+eq+emailDomain&limit=10&offset=30",
"rel": "previous",
}
"href": "/o/10084a8d-113f-4211-a0d5-efe36b082211/api/server/v1/organizations/discovery?filter=attributes.type+eq+emailDomain&limit=10&offset=30",
"rel": "previous",
}
]
organizations:
type: array
Expand Down

0 comments on commit a0d0372

Please sign in to comment.