diff --git a/components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/APIAdmin.java b/components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/APIAdmin.java index e1fcad758af1..4e8ab9666be1 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/APIAdmin.java +++ b/components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/APIAdmin.java @@ -519,10 +519,12 @@ Map searchPaginatedApis(String searchQuery, String organization, /** * This method used to retrieve global key manager configurations with usage check + * @param organization organization * @return KeyManagerConfigurationDTO list * @throws APIManagementException if error occurred */ - List getGlobalKeyManagerConfigurations(String organization) throws APIManagementException; + List getGlobalKeyManagerConfigurations(String organization) + throws APIManagementException; /** * This method used to retrieve global key manager with Id diff --git a/components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/APIConsumer.java b/components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/APIConsumer.java index 2e04e0a5df5c..9a7b53622d3f 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/APIConsumer.java +++ b/components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/APIConsumer.java @@ -721,17 +721,6 @@ ResourceFile getWSDL(API api, String environmentName, String environmentType, St */ String getRequestedTenant(); - /** - * Get consumer key and key manager name by application id and key mapping id - * @param applicationId application id - * @param keyMappingId key mapping id - * @return KeyManagerApplicationInfo - */ - KeyManagerApplicationInfo getKeyManagerNameAndConsumerKeyByAppIDAndKeyMapping(int applicationId, - String keyMappingId) - throws APIManagementException; - - /** * * @param apiId API UUID 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 e9fc8c2e4b44..e60c3782c32e 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 @@ -679,12 +679,6 @@ public KeyManagerApplicationUsages getApplicationsOfKeyManager(String keyManager return keyManagerApplicationUsages; } - public List getAllApplicationsOfKeyManager(String keyManagerId) - throws APIManagementException { - ApiMgtDAO apiMgtDAO = ApiMgtDAO.getInstance(); - return apiMgtDAO.getAllApplicationsOfKeyManager(keyManagerId); - } - private void validateKeyManagerEndpointConfiguration(KeyManagerConfigurationDTO keyManagerConfigurationDTO) throws APIManagementException { if (!APIConstants.KeyManager.DEFAULT_KEY_MANAGER.equals(keyManagerConfigurationDTO.getName())) { @@ -984,7 +978,7 @@ public void deleteKeyManagerConfigurationById(String organization, KeyManagerCon ExceptionCodes.KEY_MANAGER_DELETE_FAILED); } } else { - throw new APIManagementException("Key Manager is already used by an API or and Application.", + throw new APIManagementException("Key Manager is already used by an API or an Application.", ExceptionCodes.KEY_MANAGER_DELETE_FAILED); } } 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 e7f9a892e49a..228c96718d2a 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 @@ -3602,6 +3602,7 @@ public void cleanUpApplicationRegistrationByApplicationIdAndKeyMappingId(int app public boolean removalKeys(Application application, String keyMappingId, String xWSO2Tenant) throws APIManagementException { + try { APIConsumer apiConsumer = APIManagerFactory.getInstance().getAPIConsumer(this.username); @@ -3679,14 +3680,6 @@ public APIKey getApplicationKeyByAppIDAndKeyMapping(int applicationId, String ke return apiKey; } - @Override - public KeyManagerApplicationInfo getKeyManagerNameAndConsumerKeyByAppIDAndKeyMapping(int applicationId, String keyMappingId) - throws APIManagementException { - return apiMgtDAO - .getKeyManagerNameAndConsumerKeyByAppIdAndKeyMappingId(applicationId, keyMappingId); - } - - @Override public Set getTopics(String apiId) throws APIManagementException { 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/KeyManagersApiServiceImpl.java b/components/apimgt/org.wso2.carbon.apimgt.rest.api.admin.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/admin/v1/impl/KeyManagersApiServiceImpl.java index 2be4c28da890..0d69dc4f8148 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.rest.api.admin.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/admin/v1/impl/KeyManagersApiServiceImpl.java +++ b/components/apimgt/org.wso2.carbon.apimgt.rest.api.admin.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/admin/v1/impl/KeyManagersApiServiceImpl.java @@ -192,7 +192,7 @@ public Response keyManagersKeyManagerIdAppUsagesGet(String keyManagerId, Integer throw new APIManagementException("Requested KeyManager not found", ExceptionCodes.KEY_MANAGER_NOT_FOUND); } KeyManagerApplicationUsages result = apiAdmin.getApplicationsOfKeyManager(keyManagerId, offset, limit); - return Response.ok().entity(result).build(); + return Response.ok().entity(KeyManagerMappingUtil.toKeyManagerAppUsagesDTO(result)).build(); } public Response keyManagersPost(KeyManagerDTO body, MessageContext messageContext) throws APIManagementException { diff --git a/components/apimgt/org.wso2.carbon.apimgt.rest.api.admin.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/admin/v1/utils/mappings/KeyManagerMappingUtil.java b/components/apimgt/org.wso2.carbon.apimgt.rest.api.admin.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/admin/v1/utils/mappings/KeyManagerMappingUtil.java index ffa7527d8d49..42ec4fb3673c 100755 --- a/components/apimgt/org.wso2.carbon.apimgt.rest.api.admin.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/admin/v1/utils/mappings/KeyManagerMappingUtil.java +++ b/components/apimgt/org.wso2.carbon.apimgt.rest.api.admin.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/admin/v1/utils/mappings/KeyManagerMappingUtil.java @@ -398,7 +398,7 @@ public static KeyManagerAPIUsagesDTO toKeyManagerAPIUsagesDTO(AdminContentSearch apis.add(apiInfoKeyManagerDTO); } } - keyManagerAPIUsagesDTO.setApiCount(result.getApiCount()); + keyManagerAPIUsagesDTO.setApiCount(result.getApiTotal()); keyManagerAPIUsagesDTO.setApis(apis); } return keyManagerAPIUsagesDTO; @@ -444,7 +444,7 @@ public static ApplicationInfoKeyManagerDTO toApplicationInfoKeyManagerDTO( ApplicationInfoKeyManager applicationInfoKeyManager) { ApplicationInfoKeyManagerDTO applicationInfoKeyManagerDTO = new ApplicationInfoKeyManagerDTO(); - applicationInfoKeyManagerDTO.setName(applicationInfoKeyManager.getUuid()); + applicationInfoKeyManagerDTO.setName(applicationInfoKeyManager.getName()); applicationInfoKeyManagerDTO.setUuid(applicationInfoKeyManager.getUuid()); applicationInfoKeyManagerDTO.setOrganization(applicationInfoKeyManager.getOrganization()); applicationInfoKeyManagerDTO.setOrganizationId(applicationInfoKeyManager.getOrganizationId());