Skip to content

Commit 41ef483

Browse files
committed
Add minor changes
Remove unused methods Fix API total in GET key manager API usage response Refactor code
1 parent 083fb16 commit 41ef483

File tree

6 files changed

+8
-30
lines changed

6 files changed

+8
-30
lines changed

components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/APIAdmin.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -519,10 +519,12 @@ Map<String, Object> searchPaginatedApis(String searchQuery, String organization,
519519

520520
/**
521521
* This method used to retrieve global key manager configurations with usage check
522+
* @param organization organization
522523
* @return KeyManagerConfigurationDTO list
523524
* @throws APIManagementException if error occurred
524525
*/
525-
List<KeyManagerConfigurationDTO> getGlobalKeyManagerConfigurations(String organization) throws APIManagementException;
526+
List<KeyManagerConfigurationDTO> getGlobalKeyManagerConfigurations(String organization)
527+
throws APIManagementException;
526528

527529
/**
528530
* This method used to retrieve global key manager with Id

components/apimgt/org.wso2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/APIConsumer.java

-11
Original file line numberDiff line numberDiff line change
@@ -721,17 +721,6 @@ ResourceFile getWSDL(API api, String environmentName, String environmentType, St
721721
*/
722722
String getRequestedTenant();
723723

724-
/**
725-
* Get consumer key and key manager name by application id and key mapping id
726-
* @param applicationId application id
727-
* @param keyMappingId key mapping id
728-
* @return KeyManagerApplicationInfo
729-
*/
730-
KeyManagerApplicationInfo getKeyManagerNameAndConsumerKeyByAppIDAndKeyMapping(int applicationId,
731-
String keyMappingId)
732-
throws APIManagementException;
733-
734-
735724
/**
736725
*
737726
* @param apiId API UUID

components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/APIAdminImpl.java

+1-7
Original file line numberDiff line numberDiff line change
@@ -679,12 +679,6 @@ public KeyManagerApplicationUsages getApplicationsOfKeyManager(String keyManager
679679
return keyManagerApplicationUsages;
680680
}
681681

682-
public List<ApplicationInfoKeyManager> getAllApplicationsOfKeyManager(String keyManagerId)
683-
throws APIManagementException {
684-
ApiMgtDAO apiMgtDAO = ApiMgtDAO.getInstance();
685-
return apiMgtDAO.getAllApplicationsOfKeyManager(keyManagerId);
686-
}
687-
688682
private void validateKeyManagerEndpointConfiguration(KeyManagerConfigurationDTO keyManagerConfigurationDTO)
689683
throws APIManagementException {
690684
if (!APIConstants.KeyManager.DEFAULT_KEY_MANAGER.equals(keyManagerConfigurationDTO.getName())) {
@@ -984,7 +978,7 @@ public void deleteKeyManagerConfigurationById(String organization, KeyManagerCon
984978
ExceptionCodes.KEY_MANAGER_DELETE_FAILED);
985979
}
986980
} else {
987-
throw new APIManagementException("Key Manager is already used by an API or and Application.",
981+
throw new APIManagementException("Key Manager is already used by an API or an Application.",
988982
ExceptionCodes.KEY_MANAGER_DELETE_FAILED);
989983
}
990984
}

components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/APIConsumerImpl.java

+1-8
Original file line numberDiff line numberDiff line change
@@ -3602,6 +3602,7 @@ public void cleanUpApplicationRegistrationByApplicationIdAndKeyMappingId(int app
36023602

36033603
public boolean removalKeys(Application application, String keyMappingId, String xWSO2Tenant)
36043604
throws APIManagementException {
3605+
36053606
try {
36063607
APIConsumer apiConsumer = APIManagerFactory.getInstance().getAPIConsumer(this.username);
36073608

@@ -3679,14 +3680,6 @@ public APIKey getApplicationKeyByAppIDAndKeyMapping(int applicationId, String ke
36793680
return apiKey;
36803681
}
36813682

3682-
@Override
3683-
public KeyManagerApplicationInfo getKeyManagerNameAndConsumerKeyByAppIDAndKeyMapping(int applicationId, String keyMappingId)
3684-
throws APIManagementException {
3685-
return apiMgtDAO
3686-
.getKeyManagerNameAndConsumerKeyByAppIdAndKeyMappingId(applicationId, keyMappingId);
3687-
}
3688-
3689-
36903683
@Override
36913684
public Set<Topic> getTopics(String apiId) throws APIManagementException {
36923685

components/apimgt/org.wso2.carbon.apimgt.rest.api.admin.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/admin/v1/impl/KeyManagersApiServiceImpl.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ public Response keyManagersKeyManagerIdAppUsagesGet(String keyManagerId, Integer
192192
throw new APIManagementException("Requested KeyManager not found", ExceptionCodes.KEY_MANAGER_NOT_FOUND);
193193
}
194194
KeyManagerApplicationUsages result = apiAdmin.getApplicationsOfKeyManager(keyManagerId, offset, limit);
195-
return Response.ok().entity(result).build();
195+
return Response.ok().entity(KeyManagerMappingUtil.toKeyManagerAppUsagesDTO(result)).build();
196196
}
197197

198198
public Response keyManagersPost(KeyManagerDTO body, MessageContext messageContext) throws APIManagementException {

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ public static KeyManagerAPIUsagesDTO toKeyManagerAPIUsagesDTO(AdminContentSearch
398398
apis.add(apiInfoKeyManagerDTO);
399399
}
400400
}
401-
keyManagerAPIUsagesDTO.setApiCount(result.getApiCount());
401+
keyManagerAPIUsagesDTO.setApiCount(result.getApiTotal());
402402
keyManagerAPIUsagesDTO.setApis(apis);
403403
}
404404
return keyManagerAPIUsagesDTO;
@@ -444,7 +444,7 @@ public static ApplicationInfoKeyManagerDTO toApplicationInfoKeyManagerDTO(
444444
ApplicationInfoKeyManager applicationInfoKeyManager) {
445445

446446
ApplicationInfoKeyManagerDTO applicationInfoKeyManagerDTO = new ApplicationInfoKeyManagerDTO();
447-
applicationInfoKeyManagerDTO.setName(applicationInfoKeyManager.getUuid());
447+
applicationInfoKeyManagerDTO.setName(applicationInfoKeyManager.getName());
448448
applicationInfoKeyManagerDTO.setUuid(applicationInfoKeyManager.getUuid());
449449
applicationInfoKeyManagerDTO.setOrganization(applicationInfoKeyManager.getOrganization());
450450
applicationInfoKeyManagerDTO.setOrganizationId(applicationInfoKeyManager.getOrganizationId());

0 commit comments

Comments
 (0)