Source:
<code>private void deleteAPI(API api) throws APIManagementException { APIIdentifier apiIdentifier = api.getId(); int tenantId = APIUtil.getTenantId(APIUtil.replaceEmailDomainBack(apiIdentifier.getProviderName())); String tenantDomain = APIUtil.getTenantDomainFromTenantId(tenantId); Set<String> localScopeKeysToDelete = apiMgtDAO.getUnversionedLocalScopeKeysForAPI(apiIdentifier, tenantId); Set<URITemplate> uriTemplates = apiMgtDAO.getURITemplatesOfAPI(apiIdentifier); Map<String, KeyManagerDto> tenantKeyManagers = KeyManagerHolder.getTenantKeyManagers(tenantDomain); for (Map.Entry<String, KeyManagerDto> keyManagerDtoEntry : tenantKeyManagers.entrySet()) { KeyManager keyManager = keyManagerDtoEntry.getValue().getKeyManager(); if (keyManager != null) { <START> try{ <END> keyManager.detachResourceScopes(api, uriTemplates); if (log.isDebugEnabled()) { log.debug("Resource scopes are successfully detached for the API : " + apiIdentifier + " from KeyManager :" + keyManagerDtoEntry.getKey() + "."); } for (String localScope : localScopeKeysToDelete) { keyManager.deleteScope(localScope); } if (log.isDebugEnabled()) { log.debug("Local scopes are successfully deleted for the API : " + apiIdentifier + " from KeyManager : " + keyManagerDtoEntry.getKey() + "."); } }catch (APIManagementException e){ log.error("Error while Detach and Delete Scope from KeyManager "+ keyManagerDtoEntry.getKey()); } } } apiMgtDAO.deleteAPI(apiIdentifier); if (log.isDebugEnabled()) { log.debug("API : " + apiIdentifier + " is successfully deleted from the database and KeyManager."); } }</code><technical_language>formatting issue</technical_language>

Target:
private void deleteAPI(API api) throws APIManagementException { APIIdentifier apiIdentifier = api.getId(); int tenantId = APIUtil.getTenantId(APIUtil.replaceEmailDomainBack(apiIdentifier.getProviderName())); String tenantDomain = APIUtil.getTenantDomainFromTenantId(tenantId); Set<String> localScopeKeysToDelete = apiMgtDAO.getUnversionedLocalScopeKeysForAPI(apiIdentifier, tenantId); Set<URITemplate> uriTemplates = apiMgtDAO.getURITemplatesOfAPI(apiIdentifier); Map<String, KeyManagerDto> tenantKeyManagers = KeyManagerHolder.getTenantKeyManagers(tenantDomain); for (Map.Entry<String, KeyManagerDto> keyManagerDtoEntry : tenantKeyManagers.entrySet()) { KeyManager keyManager = keyManagerDtoEntry.getValue().getKeyManager(); if (keyManager != null) { try { keyManager.detachResourceScopes(api, uriTemplates); if (log.isDebugEnabled()) { log.debug("Resource scopes are successfully detached for the API : " + apiIdentifier + " from Key Manager :" + keyManagerDtoEntry.getKey() + "."); } for (String localScope : localScopeKeysToDelete) { keyManager.deleteScope(localScope); } if (log.isDebugEnabled()) { log.debug("Local scopes are successfully deleted for the API : " + apiIdentifier + " from Key Manager : " + keyManagerDtoEntry.getKey() + "."); } } catch (APIManagementException e) { log.error("Error while Detach and Delete Scope from Key Manager " + keyManagerDtoEntry.getKey()); } } } deleteScopes(localScopeKeysToDelete, tenantId); apiMgtDAO.deleteAPI(apiIdentifier); if (log.isDebugEnabled()) { log.debug("API : " + apiIdentifier + " is successfully deleted from the database and Key Manager."); } }