diff --git a/components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/APIManager.java b/components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/APIManager.java index 94ed069bbc9c..05544baf910c 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/APIManager.java +++ b/components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/APIManager.java @@ -519,8 +519,8 @@ List getResourcesOfAPIProduct(APIProductIdentifier productId * @return * @throws APIManagementException */ - Map searchPaginatedAPIs(String searchQuery, String organization, int start, int end, - String sortBy, String sortOrder) throws APIManagementException; + Map searchPaginatedAPIs(String searchQuery, String organization, int start, int end) + throws APIManagementException; /** * Search in content of apis, api products and documents and provide the results diff --git a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/APIAdminImpl.java b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/APIAdminImpl.java index 1027c4e2f59e..ca2d09019165 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/APIAdminImpl.java +++ b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/APIAdminImpl.java @@ -1216,7 +1216,7 @@ private int isCategoryAttached(APICategory category, String username) throws API //APIs and API categories String searchQuery = APIConstants.CATEGORY_SEARCH_TYPE_PREFIX + ":*" + category.getName() + "*"; String tenantDomain = MultitenantUtils.getTenantDomain(username); - Map result = apiProvider.searchPaginatedAPIs(searchQuery, tenantDomain, 0, Integer.MAX_VALUE, null, null); + Map result = apiProvider.searchPaginatedAPIs(searchQuery, tenantDomain, 0, Integer.MAX_VALUE); return (int) (Integer) result.get("length"); } diff --git a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/APIConsumerImpl.java b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/APIConsumerImpl.java index 7f212b1bd96f..8edc0129f3a1 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/APIConsumerImpl.java +++ b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/APIConsumerImpl.java @@ -3840,8 +3840,8 @@ public void changeUserPassword(String currentPassword, String newPassword) throw } @Override - public Map searchPaginatedAPIs(String searchQuery, String organization, int start, int end, - String sortBy, String sortOrder) throws APIManagementException { + public Map searchPaginatedAPIs(String searchQuery, String organization, int start, int end) + throws APIManagementException { Map result = new HashMap(); if (log.isDebugEnabled()) { diff --git a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/APIProviderImpl.java b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/APIProviderImpl.java index a06a898cf5c6..e34fa542b122 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/APIProviderImpl.java +++ b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/APIProviderImpl.java @@ -5407,7 +5407,7 @@ public APISearchResult searchPaginatedAPIsByFQDN(String endpoint, String tenantD try { PublisherAPISearchResult searchAPIs = apiPersistenceInstance.searchAPIsForPublisher(org, query, - offset, limit, userCtx, "createdTime", "desc"); + offset, limit, userCtx); if (log.isDebugEnabled()) { log.debug("Running Solr query : " + query); } @@ -5514,8 +5514,8 @@ public APIProduct getAPIProductbyUUID(String uuid, String organization) throws A } @Override - public Map searchPaginatedAPIs(String searchQuery, String organization, int start, int end, - String sortBy, String sortOrder) throws APIManagementException { + public Map searchPaginatedAPIs(String searchQuery, String organization, int start, int end) + throws APIManagementException { Map result = new HashMap(); if (log.isDebugEnabled()) { log.debug("Original search query received : " + searchQuery); @@ -5527,7 +5527,7 @@ public Map searchPaginatedAPIs(String searchQuery, String organi UserContext userCtx = new UserContext(userNameWithoutChange, org, properties, roles); try { PublisherAPISearchResult searchAPIs = apiPersistenceInstance.searchAPIsForPublisher(org, searchQuery, - start, end, userCtx, sortBy, sortOrder); + start, end, userCtx); if (log.isDebugEnabled()) { log.debug("searched APIs for query : " + searchQuery + " :-->: " + searchAPIs.toString()); } diff --git a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/AbstractAPIManager.java b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/AbstractAPIManager.java index 29d8c2decc12..08c31db1e05f 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/AbstractAPIManager.java +++ b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/AbstractAPIManager.java @@ -142,7 +142,7 @@ public List getAllAPIs() throws APIManagementException { UserContext userCtx = new UserContext(username, org, properties, roles); try { PublisherAPISearchResult searchAPIs = apiPersistenceInstance.searchAPIsForPublisher(org, "", 0, - Integer.MAX_VALUE, userCtx, null, null); + Integer.MAX_VALUE, userCtx); if (searchAPIs != null) { List list = searchAPIs.getPublisherAPIInfoList(); diff --git a/components/apimgt/org.wso2.carbon.apimgt.impl/src/test/java/org/wso2/carbon/apimgt/impl/APIProviderImplTest.java b/components/apimgt/org.wso2.carbon.apimgt.impl/src/test/java/org/wso2/carbon/apimgt/impl/APIProviderImplTest.java index 87b99d361bc0..e691ed9c62d3 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.impl/src/test/java/org/wso2/carbon/apimgt/impl/APIProviderImplTest.java +++ b/components/apimgt/org.wso2.carbon.apimgt.impl/src/test/java/org/wso2/carbon/apimgt/impl/APIProviderImplTest.java @@ -1657,9 +1657,7 @@ public void testSearchPaginatedAPIsByFQDNWithCorrectInputs() throws APIManagemen Mockito.anyString(), Mockito.anyInt(), Mockito.anyInt(), - Mockito.any(UserContext.class), - Mockito.anyString(), - Mockito.anyString())).thenReturn(returnSearchAPIs); + Mockito.any(UserContext.class))).thenReturn(returnSearchAPIs); APIProviderImplWrapper apiProvider = new APIProviderImplWrapper(apiPersistenceInstance, apimgtDAO, scopesDAO); @@ -1692,9 +1690,7 @@ public void testSearchPaginatedAPIsByFQDNWhenSearchResultIsNull() throws APIMana Mockito.anyString(), Mockito.anyInt(), Mockito.anyInt(), - Mockito.any(UserContext.class), - Mockito.anyString(), - Mockito.anyString())).thenReturn(null); + Mockito.any(UserContext.class))).thenReturn(null); APIProviderImplWrapper apiProvider = new APIProviderImplWrapper(apiPersistenceInstance, apimgtDAO, scopesDAO); diff --git a/components/apimgt/org.wso2.carbon.apimgt.impl/src/test/java/org/wso2/carbon/apimgt/impl/AbstractAPIManagerTestCase.java b/components/apimgt/org.wso2.carbon.apimgt.impl/src/test/java/org/wso2/carbon/apimgt/impl/AbstractAPIManagerTestCase.java index 90f43248de64..0a130d890348 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.impl/src/test/java/org/wso2/carbon/apimgt/impl/AbstractAPIManagerTestCase.java +++ b/components/apimgt/org.wso2.carbon.apimgt.impl/src/test/java/org/wso2/carbon/apimgt/impl/AbstractAPIManagerTestCase.java @@ -148,7 +148,7 @@ public void testGetAllApis() throws GovernanceException, APIManagementException, value.setPublisherAPIInfoList(publisherAPIInfoList); Mockito.when(apiPersistenceInstance.searchAPIsForPublisher(any(Organization.class), anyString(), - anyInt(), anyInt(), any(UserContext.class), isNull(), isNull())).thenReturn(value); + anyInt(), anyInt(), any(UserContext.class))).thenReturn(value); List apis = abstractAPIManager.getAllAPIs(); Assert.assertNotNull(apis); Assert.assertEquals(apis.size(), 1); diff --git a/components/apimgt/org.wso2.carbon.apimgt.impl/src/test/java/org/wso2/carbon/apimgt/impl/AbstractAPIManagerWrapper.java b/components/apimgt/org.wso2.carbon.apimgt.impl/src/test/java/org/wso2/carbon/apimgt/impl/AbstractAPIManagerWrapper.java index 23e3afba343d..54e714023bd5 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.impl/src/test/java/org/wso2/carbon/apimgt/impl/AbstractAPIManagerWrapper.java +++ b/components/apimgt/org.wso2.carbon.apimgt.impl/src/test/java/org/wso2/carbon/apimgt/impl/AbstractAPIManagerWrapper.java @@ -133,8 +133,8 @@ public API getLightweightAPIByUUID(String uuid, String organization) throws APIM } @Override - public Map searchPaginatedAPIs(String searchQuery, String organization, int start, int end, - String sortBy, String sortOrder) throws APIManagementException { + public Map searchPaginatedAPIs(String searchQuery, String organization, int start, int end) + throws APIManagementException { // TODO Auto-generated method stub return null; } diff --git a/components/apimgt/org.wso2.carbon.apimgt.persistence/src/main/java/org/wso2/carbon/apimgt/persistence/APIPersistence.java b/components/apimgt/org.wso2.carbon.apimgt.persistence/src/main/java/org/wso2/carbon/apimgt/persistence/APIPersistence.java index 63592cd946d8..9bb6851d7554 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.persistence/src/main/java/org/wso2/carbon/apimgt/persistence/APIPersistence.java +++ b/components/apimgt/org.wso2.carbon.apimgt.persistence/src/main/java/org/wso2/carbon/apimgt/persistence/APIPersistence.java @@ -170,13 +170,11 @@ void deleteAPIRevision(Organization org, String apiUUID, String revisionUUID, in * @param searchQuery search query * @param start starting index * @param offset offset to search - * @param sortBy sort criteria - * @param sortOrder sort order * @return Publisher API Search Result * @throws APIPersistenceException */ PublisherAPISearchResult searchAPIsForPublisher(Organization org, String searchQuery, int start, - int offset, UserContext ctx, String sortBy, String sortOrder) throws APIPersistenceException; + int offset, UserContext ctx) throws APIPersistenceException; /** * Search APIs to be displayed on Dev Portal API listing diff --git a/components/apimgt/org.wso2.carbon.apimgt.persistence/src/main/java/org/wso2/carbon/apimgt/persistence/RegistryPersistenceImpl.java b/components/apimgt/org.wso2.carbon.apimgt.persistence/src/main/java/org/wso2/carbon/apimgt/persistence/RegistryPersistenceImpl.java index 52f799f742f9..e3d88aac6b1f 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.persistence/src/main/java/org/wso2/carbon/apimgt/persistence/RegistryPersistenceImpl.java +++ b/components/apimgt/org.wso2.carbon.apimgt.persistence/src/main/java/org/wso2/carbon/apimgt/persistence/RegistryPersistenceImpl.java @@ -979,7 +979,7 @@ public void deleteAllAPIs(Organization org) throws APIPersistenceException { @Override public PublisherAPISearchResult searchAPIsForPublisher(Organization org, String searchQuery, int start, int offset, - UserContext ctx, String sortBy, String sortOrder) throws APIPersistenceException { + UserContext ctx) throws APIPersistenceException { String requestedTenantDomain = org.getName(); boolean isTenantFlowStarted = false; diff --git a/components/apimgt/org.wso2.carbon.apimgt.rest.api.admin.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/admin/v1/impl/ApisApiServiceImpl.java b/components/apimgt/org.wso2.carbon.apimgt.rest.api.admin.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/admin/v1/impl/ApisApiServiceImpl.java index 2d45e4bfc516..e0fb22302e7e 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.rest.api.admin.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/admin/v1/impl/ApisApiServiceImpl.java +++ b/components/apimgt/org.wso2.carbon.apimgt.rest.api.admin.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/admin/v1/impl/ApisApiServiceImpl.java @@ -66,8 +66,7 @@ public Response getAllAPIs(Integer limit, Integer offset, String query, String i query = query == null ? APIConstants.CHAR_ASTERIX : query; APIProvider apiProvider = RestApiCommonUtil.getLoggedInUserProvider(); String organization = RestApiUtil.getOrganization(messageContext); - Map result = apiProvider.searchPaginatedAPIs(query, organization, offset, limit, - RestApiConstants.DEFAULT_SORT_BY, RestApiConstants.DEFAULT_SORT_ORDER); + Map result = apiProvider.searchPaginatedAPIs(query, organization, offset, limit); List apis = SearchApiServiceImplUtil.getAPIListFromAPISearchResult(result); List allMatchedResults = getAllMatchedResults(apis); resultListDTO.setApis(allMatchedResults); diff --git a/components/apimgt/org.wso2.carbon.apimgt.rest.api.common/src/main/java/org/wso2/carbon/apimgt/rest/api/common/RestApiCommonUtil.java b/components/apimgt/org.wso2.carbon.apimgt.rest.api.common/src/main/java/org/wso2/carbon/apimgt/rest/api/common/RestApiCommonUtil.java index 8b073c9b4bdc..385311daa29c 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.rest.api.common/src/main/java/org/wso2/carbon/apimgt/rest/api/common/RestApiCommonUtil.java +++ b/components/apimgt/org.wso2.carbon.apimgt.rest.api.common/src/main/java/org/wso2/carbon/apimgt/rest/api/common/RestApiCommonUtil.java @@ -573,6 +573,24 @@ public static String getSubscriptionPaginatedURLForAPIId(Integer offset, Integer return paginatedURL; } + /** + * Returns the paginated url for subscriptions + * + * @param offset starting index + * @param limit max number of objects returned + * @param groupId groupId of the Application + * @return constructed paginated url + */ + public static String getSubscriptionPaginatedURL(Integer offset, Integer limit, String groupId) { + + groupId = groupId == null ? "" : groupId; + String paginatedURL = RestApiConstants.SUBSCRIPTIONS_GET_PAGINATION_URL_APIID; + paginatedURL = paginatedURL.replace(RestApiConstants.LIMIT_PARAM, String.valueOf(limit)); + paginatedURL = paginatedURL.replace(RestApiConstants.OFFSET_PARAM, String.valueOf(offset)); + paginatedURL = paginatedURL.replace(RestApiConstants.GROUPID_PARAM, groupId); + return paginatedURL; + } + /** * Returns the paginated url for subscriptions for a particular application * diff --git a/components/apimgt/org.wso2.carbon.apimgt.rest.api.common/src/main/resources/publisher-api.yaml b/components/apimgt/org.wso2.carbon.apimgt.rest.api.common/src/main/resources/publisher-api.yaml index 919a6d051230..e97ec391b818 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.rest.api.common/src/main/resources/publisher-api.yaml +++ b/components/apimgt/org.wso2.carbon.apimgt.rest.api.common/src/main/resources/publisher-api.yaml @@ -130,8 +130,6 @@ paths: parameters: - $ref: '#/components/parameters/limit' - $ref: '#/components/parameters/offset' - - $ref: '#/components/parameters/sortBy' - - $ref: '#/components/parameters/sortOrder' - $ref: '#/components/parameters/requestedTenant' - name: query in: query @@ -14195,30 +14193,6 @@ components: schema: type: integer default: 0 - sortBy: - name: sortBy - in: query - description: | - Criteria for sorting. - schema: - type: string - default: createdTime - enum: - - apiName - - version - - createdTime - - status - sortOrder: - name: sortOrder - in: query - description: | - Order of sorting(ascending/descending). - schema: - type: string - default: desc - enum: - - asc - - desc If-None-Match: name: If-None-Match in: header diff --git a/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1.common/src/main/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/common/mappings/SubscriptionMappingUtil.java b/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1.common/src/main/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/common/mappings/SubscriptionMappingUtil.java index 1302fe48b205..0b6e6fc4c0e9 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1.common/src/main/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/common/mappings/SubscriptionMappingUtil.java +++ b/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1.common/src/main/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/common/mappings/SubscriptionMappingUtil.java @@ -171,16 +171,31 @@ public static void setPaginationParams(SubscriptionListDTO subscriptionListDTO, Map paginatedParams = RestApiCommonUtil.getPaginationParams(offset, limit, size); if (paginatedParams.get(RestApiConstants.PAGINATION_PREVIOUS_OFFSET) != null) { - paginatedPrevious = RestApiCommonUtil - .getSubscriptionPaginatedURLForAPIId( - paginatedParams.get(RestApiConstants.PAGINATION_PREVIOUS_OFFSET), - paginatedParams.get(RestApiConstants.PAGINATION_PREVIOUS_LIMIT), apiId, groupId); + if (apiId != null) { + paginatedPrevious = RestApiCommonUtil + .getSubscriptionPaginatedURLForAPIId( + paginatedParams.get(RestApiConstants.PAGINATION_PREVIOUS_OFFSET), + paginatedParams.get(RestApiConstants.PAGINATION_PREVIOUS_LIMIT), apiId, groupId); + } else { + paginatedPrevious = RestApiCommonUtil + .getSubscriptionPaginatedURL( + paginatedParams.get(RestApiConstants.PAGINATION_PREVIOUS_OFFSET), + paginatedParams.get(RestApiConstants.PAGINATION_PREVIOUS_LIMIT), groupId); + } } if (paginatedParams.get(RestApiConstants.PAGINATION_NEXT_OFFSET) != null) { - paginatedNext = RestApiCommonUtil - .getSubscriptionPaginatedURLForAPIId(paginatedParams.get(RestApiConstants.PAGINATION_NEXT_OFFSET), - paginatedParams.get(RestApiConstants.PAGINATION_NEXT_LIMIT), apiId, groupId); + if (apiId != null) { + paginatedPrevious = RestApiCommonUtil + .getSubscriptionPaginatedURLForAPIId( + paginatedParams.get(RestApiConstants.PAGINATION_NEXT_OFFSET), + paginatedParams.get(RestApiConstants.PAGINATION_NEXT_LIMIT), apiId, groupId); + } else { + paginatedPrevious = RestApiCommonUtil + .getSubscriptionPaginatedURL( + paginatedParams.get(RestApiConstants.PAGINATION_NEXT_OFFSET), + paginatedParams.get(RestApiConstants.PAGINATION_NEXT_LIMIT), groupId); + } } PaginationDTO pagination = new PaginationDTO(); diff --git a/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1/src/gen/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/ApisApi.java b/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1/src/gen/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/ApisApi.java index 8b3458989a54..6eafedcdaadf 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1/src/gen/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/ApisApi.java +++ b/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1/src/gen/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/ApisApi.java @@ -1193,8 +1193,8 @@ public Response getAllAPISpecificOperationPolicies(@ApiParam(value = "**API ID** @ApiResponse(code = 200, message = "OK. List of qualifying APIs is returned. ", response = APIListDTO.class), @ApiResponse(code = 304, message = "Not Modified. Empty body because the client has already the latest version of the requested resource (Will be supported in future). ", response = Void.class), @ApiResponse(code = 406, message = "Not Acceptable. The requested media type is not supported.", response = ErrorDTO.class) }) - public Response getAllAPIs( @ApiParam(value = "Maximum size of resource array to return. ", defaultValue="25") @DefaultValue("25") @QueryParam("limit") Integer limit, @ApiParam(value = "Starting point within the complete list of items qualified. ", defaultValue="0") @DefaultValue("0") @QueryParam("offset") Integer offset, @ApiParam(value = "Criteria for sorting. ", allowableValues="apiName, version, createdTime, status", defaultValue="createdTime") @DefaultValue("createdTime") @QueryParam("sortBy") String sortBy, @ApiParam(value = "Order of sorting(ascending/descending). ", allowableValues="asc, desc", defaultValue="desc") @DefaultValue("desc") @QueryParam("sortOrder") String sortOrder, @ApiParam(value = "For cross-tenant invocations, this is used to specify the tenant domain, where the resource need to be retirieved from. " )@HeaderParam("X-WSO2-Tenant") String xWSO2Tenant, @ApiParam(value = "**Search condition**. You can search in attributes by using an **\":\"** modifier. Eg. \"provider:wso2\" will match an API if the provider of the API contains \"wso2\". \"provider:\"wso2\"\" will match an API if the provider of the API is exactly \"wso2\". \"status:PUBLISHED\" will match an API if the API is in PUBLISHED state. Also you can use combined modifiers Eg. name:pizzashack version:v1 will match an API if the name of the API is pizzashack and version is v1. Supported attribute modifiers are [**version, context, name, status, description, provider, api-category, tags, doc, contexttemplate, lcstate, content, type, label, enablestore, thirdparty**] If no advanced attribute modifier has been specified, the API names containing the search term will be returned as a result. Please note that you need to use encoded URL (URL encoding) if you are using a client which does not support URL encoding (such as curl) ") @QueryParam("query") String query, @ApiParam(value = "Validator for conditional requests; based on the ETag of the formerly retrieved variant of the resource. " )@HeaderParam("If-None-Match") String ifNoneMatch, @ApiParam(value = "Media types acceptable for the response. Default is application/json. " , defaultValue="application/json")@HeaderParam("Accept") String accept) throws APIManagementException{ - return delegate.getAllAPIs(limit, offset, sortBy, sortOrder, xWSO2Tenant, query, ifNoneMatch, accept, securityContext); + public Response getAllAPIs( @ApiParam(value = "Maximum size of resource array to return. ", defaultValue="25") @DefaultValue("25") @QueryParam("limit") Integer limit, @ApiParam(value = "Starting point within the complete list of items qualified. ", defaultValue="0") @DefaultValue("0") @QueryParam("offset") Integer offset, @ApiParam(value = "For cross-tenant invocations, this is used to specify the tenant domain, where the resource need to be retirieved from. " )@HeaderParam("X-WSO2-Tenant") String xWSO2Tenant, @ApiParam(value = "**Search condition**. You can search in attributes by using an **\":\"** modifier. Eg. \"provider:wso2\" will match an API if the provider of the API contains \"wso2\". \"provider:\"wso2\"\" will match an API if the provider of the API is exactly \"wso2\". \"status:PUBLISHED\" will match an API if the API is in PUBLISHED state. Also you can use combined modifiers Eg. name:pizzashack version:v1 will match an API if the name of the API is pizzashack and version is v1. Supported attribute modifiers are [**version, context, name, status, description, provider, api-category, tags, doc, contexttemplate, lcstate, content, type, label, enablestore, thirdparty**] If no advanced attribute modifier has been specified, the API names containing the search term will be returned as a result. Please note that you need to use encoded URL (URL encoding) if you are using a client which does not support URL encoding (such as curl) ") @QueryParam("query") String query, @ApiParam(value = "Validator for conditional requests; based on the ETag of the formerly retrieved variant of the resource. " )@HeaderParam("If-None-Match") String ifNoneMatch, @ApiParam(value = "Media types acceptable for the response. Default is application/json. " , defaultValue="application/json")@HeaderParam("Accept") String accept) throws APIManagementException{ + return delegate.getAllAPIs(limit, offset, xWSO2Tenant, query, ifNoneMatch, accept, securityContext); } @GET diff --git a/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1/src/gen/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/ApisApiService.java b/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1/src/gen/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/ApisApiService.java index 7caffe1a712f..8d7b71fe1339 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1/src/gen/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/ApisApiService.java +++ b/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1/src/gen/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/ApisApiService.java @@ -120,7 +120,7 @@ public interface ApisApiService { public Response getAPISwagger(String apiId, String ifNoneMatch, MessageContext messageContext) throws APIManagementException; public Response getAPIThumbnail(String apiId, String ifNoneMatch, MessageContext messageContext) throws APIManagementException; public Response getAllAPISpecificOperationPolicies(String apiId, Integer limit, Integer offset, String query, MessageContext messageContext) throws APIManagementException; - public Response getAllAPIs(Integer limit, Integer offset, String sortBy, String sortOrder, String xWSO2Tenant, String query, String ifNoneMatch, String accept, MessageContext messageContext) throws APIManagementException; + public Response getAllAPIs(Integer limit, Integer offset, String xWSO2Tenant, String query, String ifNoneMatch, String accept, MessageContext messageContext) throws APIManagementException; public Response getAllCommentsOfAPI(String apiId, String xWSO2Tenant, Integer limit, Integer offset, Boolean includeCommenterInfo, MessageContext messageContext) throws APIManagementException; public Response getAllPublishedExternalStoresByAPI(String apiId, String ifNoneMatch, MessageContext messageContext) throws APIManagementException; public Response getAmazonResourceNamesOfAPI(String apiId, MessageContext messageContext) throws APIManagementException; diff --git a/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/impl/ApisApiServiceImpl.java b/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/impl/ApisApiServiceImpl.java index da6a6d7ab74a..07e5400ddf53 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/impl/ApisApiServiceImpl.java +++ b/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/impl/ApisApiServiceImpl.java @@ -98,9 +98,8 @@ public class ApisApiServiceImpl implements ApisApiService { private static final String API_PRODUCT_TYPE = "APIPRODUCT"; @Override - public Response getAllAPIs(Integer limit, Integer offset, String sortBy, String sortOrder, String xWSO2Tenant, - String query, String ifNoneMatch, String accept, - MessageContext messageContext) { + public Response getAllAPIs(Integer limit, Integer offset, String xWSO2Tenant, String query, String ifNoneMatch, + String accept, MessageContext messageContext) { List allMatchedApis = new ArrayList<>(); Object apiListDTO; @@ -110,8 +109,6 @@ public Response getAllAPIs(Integer limit, Integer offset, String sortBy, String limit = limit != null ? limit : RestApiConstants.PAGINATION_LIMIT_DEFAULT; offset = offset != null ? offset : RestApiConstants.PAGINATION_OFFSET_DEFAULT; query = query == null ? "" : query; - sortBy = sortBy != null ? sortBy : RestApiConstants.DEFAULT_SORT_CRITERION; - sortOrder = sortOrder != null ? sortOrder : RestApiConstants.DESCENDING_SORT_ORDER; try { //revert content search back to normal search by name to avoid doc result complexity and to comply with REST api practices @@ -133,7 +130,7 @@ public Response getAllAPIs(Integer limit, Integer offset, String sortBy, String }*/ Map result; - result = apiProvider.searchPaginatedAPIs(query, organization, offset, limit, sortBy, sortOrder); + result = apiProvider.searchPaginatedAPIs(query, organization, offset, limit); Set apis = (Set) result.get("apis"); allMatchedApis.addAll(apis); diff --git a/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/impl/SearchApiServiceImpl.java b/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/impl/SearchApiServiceImpl.java index 6ab36696dc85..27034791bae5 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/impl/SearchApiServiceImpl.java +++ b/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/impl/SearchApiServiceImpl.java @@ -67,8 +67,7 @@ public Response search(Integer limit, Integer offset, String query, String ifNon if (query.startsWith(APIConstants.CONTENT_SEARCH_TYPE_PREFIX)) { result = apiProvider.searchPaginatedContent(query, organization, offset, limit); } else { - result = apiProvider.searchPaginatedAPIs(query, organization, offset, limit, - RestApiConstants.DEFAULT_SORT_CRITERION, RestApiConstants.DEFAULT_SORT_ORDER); + result = apiProvider.searchPaginatedAPIs(query, organization, offset, limit); } /* Above searchPaginatedAPIs method underneath calls searchPaginatedAPIsByContent method,searchPaginatedAPIs diff --git a/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/impl/WorkflowsApiServiceImpl.java b/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/impl/WorkflowsApiServiceImpl.java index 0c3f7427afee..3f1671124f24 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/impl/WorkflowsApiServiceImpl.java +++ b/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/impl/WorkflowsApiServiceImpl.java @@ -117,8 +117,7 @@ public Response workflowsGet(Integer limit, Integer offset, String accept, Strin return Response.ok().entity(workflowListDTO).build(); } while (start >= 0) { - result = apiProvider.searchPaginatedAPIs(query, tenantDomain, start, start + 100, - RestApiConstants.DEFAULT_SORT_CRITERION, RestApiConstants.DESCENDING_SORT_ORDER); + result = apiProvider.searchPaginatedAPIs(query, tenantDomain, start, start + 100); Set apis = (Set) result.get("apis"); for (API api : apis) { String organization = (RestApiUtil.getOrganization(messageContext) != null) ? diff --git a/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1/src/main/resources/publisher-api.yaml b/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1/src/main/resources/publisher-api.yaml index 919a6d051230..e97ec391b818 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1/src/main/resources/publisher-api.yaml +++ b/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1/src/main/resources/publisher-api.yaml @@ -130,8 +130,6 @@ paths: parameters: - $ref: '#/components/parameters/limit' - $ref: '#/components/parameters/offset' - - $ref: '#/components/parameters/sortBy' - - $ref: '#/components/parameters/sortOrder' - $ref: '#/components/parameters/requestedTenant' - name: query in: query @@ -14195,30 +14193,6 @@ components: schema: type: integer default: 0 - sortBy: - name: sortBy - in: query - description: | - Criteria for sorting. - schema: - type: string - default: createdTime - enum: - - apiName - - version - - createdTime - - status - sortOrder: - name: sortOrder - in: query - description: | - Order of sorting(ascending/descending). - schema: - type: string - default: desc - enum: - - asc - - desc If-None-Match: name: If-None-Match in: header diff --git a/components/apimgt/org.wso2.carbon.apimgt.rest.api.store.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/store/v1/impl/ApisApiServiceImpl.java b/components/apimgt/org.wso2.carbon.apimgt.rest.api.store.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/store/v1/impl/ApisApiServiceImpl.java index c22b2114da0f..d85adec7e250 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.rest.api.store.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/store/v1/impl/ApisApiServiceImpl.java +++ b/components/apimgt/org.wso2.carbon.apimgt.rest.api.store.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/store/v1/impl/ApisApiServiceImpl.java @@ -104,9 +104,7 @@ public Response apisGet(Integer limit, Integer offset, String xWSO2Tenant, Strin .replace(APIConstants.CONTENT_SEARCH_TYPE_PREFIX + ":", APIConstants.NAME_TYPE_PREFIX + ":"); } - Map allMatchedApisMap = apiConsumer.searchPaginatedAPIs(query, organization, offset, - limit, null, null); - + Map allMatchedApisMap = apiConsumer.searchPaginatedAPIs(query, organization, offset, limit); Set sortedSet = (Set) allMatchedApisMap.get("apis"); // This is a SortedSet ArrayList allMatchedApis = new ArrayList<>(sortedSet); diff --git a/components/apimgt/org.wso2.carbon.apimgt.rest.api.store.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/store/v1/impl/SearchApiServiceImpl.java b/components/apimgt/org.wso2.carbon.apimgt.rest.api.store.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/store/v1/impl/SearchApiServiceImpl.java index 8707ee31f411..b594da922bec 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.rest.api.store.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/store/v1/impl/SearchApiServiceImpl.java +++ b/components/apimgt/org.wso2.carbon.apimgt.rest.api.store.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/store/v1/impl/SearchApiServiceImpl.java @@ -70,7 +70,7 @@ public Response searchGet(Integer limit, Integer offset, String xWSO2Tenant, Str if (query.startsWith(APIConstants.CONTENT_SEARCH_TYPE_PREFIX)) { result = apiConsumer.searchPaginatedContent(query, organization, offset, limit); } else { - result = apiConsumer.searchPaginatedAPIs(query, organization, offset, limit, null, null); + result = apiConsumer.searchPaginatedAPIs(query, organization, offset, limit); } ArrayList apis;