Skip to content

Commit

Permalink
Add minor changes
Browse files Browse the repository at this point in the history
Remove unused methods
Fix API total in GET key manager API usage response
Refactor code
  • Loading branch information
SavinduDimal committed Mar 22, 2024
1 parent 083fb16 commit 41ef483
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -519,10 +519,12 @@ Map<String, Object> 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<KeyManagerConfigurationDTO> getGlobalKeyManagerConfigurations(String organization) throws APIManagementException;
List<KeyManagerConfigurationDTO> getGlobalKeyManagerConfigurations(String organization)
throws APIManagementException;

/**
* This method used to retrieve global key manager with Id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -679,12 +679,6 @@ public KeyManagerApplicationUsages getApplicationsOfKeyManager(String keyManager
return keyManagerApplicationUsages;
}

public List<ApplicationInfoKeyManager> 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())) {
Expand Down Expand Up @@ -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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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<Topic> getTopics(String apiId) throws APIManagementException {

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

0 comments on commit 41ef483

Please sign in to comment.