Source:
<code>public String getApiRecommendations(String userName, String tenantDomain) { if (isRecommendationEnabled(tenantDomain)) { String recommendationEndpointURL = recommendationEnvironment.getRecommendationServerURL() + APIConstants.RECOMMENDATIONS_GET_RESOURCE; try { String userID = apiMgtDAO.getUserID(userName); URL serverURL = new URL(recommendationEndpointURL); int serverPort = serverURL.getPort(); String serverProtocol = serverURL.getProtocol(); HttpGet method = new HttpGet(recommendationEndpointURL); HttpClient httpClient = APIUtil.getHttpClient(serverPort, serverProtocol); if (recommendationEnvironment.getOauthURL() != null) { String accessToken = AccessTokenGeneratorImpl.getInstance().getAccessToken( recommendationEnvironment.getOauthURL(), recommendationEnvironment.getConsumerKey(), recommendationEnvironment.getConsumerSecret()); method.setHeader(APIConstants.AUTHORIZATION_HEADER_DEFAULT, "Bearer " + accessToken); } else { byte[] credentials = org.apache.commons.codec.binary.Base64.encodeBase64( (recommendationEnvironment.getUserName() + ":" + recommendationEnvironment.getPassword()) .getBytes(StandardCharsets.UTF_8)); <START> method.setHeader("Authorization", "Basic " + new String(credentials, StandardCharsets.UTF_8)); <END> } method.setHeader(APIConstants.RECOMMENDATIONS_USER_HEADER, userID); method.setHeader(APIConstants.RECOMMENDATIONS_ACCOUNT_HEADER, tenantDomain); HttpResponse httpResponse = httpClient.execute(method); if (httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { String contentString = EntityUtils.toString(httpResponse.getEntity()); if (log.isDebugEnabled()) { log.debug("Recommendations received for user " + userName + " is " + contentString); } return contentString; } else { log.warn("Error getting recommendations from server. Server responded with " + httpResponse.getStatusLine().getStatusCode()); } } catch (IOException e) { log.error("Connection failure for the recommendation engine", e); } catch (APIManagementException e) { log.error("Error while getting recommendations for user " + userName, e); } } return null; }</code><technical_language>please constants</technical_language>

Target:
public String getApiRecommendations(String userName, String tenantDomain) { if (isRecommendationEnabled(tenantDomain)) { String recommendationEndpointURL = recommendationEnvironment.getRecommendationServerURL() + APIConstants.RECOMMENDATIONS_GET_RESOURCE; try { String userID = apiMgtDAO.getUserID(userName); URL serverURL = new URL(recommendationEndpointURL); int serverPort = serverURL.getPort(); String serverProtocol = serverURL.getProtocol(); HttpGet method = new HttpGet(recommendationEndpointURL); HttpClient httpClient = APIUtil.getHttpClient(serverPort, serverProtocol); if (recommendationEnvironment.getOauthURL() != null) { String accessToken = ServiceReferenceHolder.getInstance().getAccessTokenGenerator() .getAccessToken(); method.setHeader(APIConstants.AUTHORIZATION_HEADER_DEFAULT, APIConstants.AUTHORIZATION_BEARER + accessToken); } else { byte[] credentials = org.apache.commons.codec.binary.Base64.encodeBase64( (recommendationEnvironment.getUserName() + ":" + recommendationEnvironment.getPassword()) .getBytes(StandardCharsets.UTF_8)); method.setHeader(APIConstants.AUTHORIZATION_HEADER_DEFAULT, APIConstants.AUTHORIZATION_BASIC + new String(credentials, StandardCharsets.UTF_8)); } method.setHeader(APIConstants.RECOMMENDATIONS_USER_HEADER, userID); method.setHeader(APIConstants.RECOMMENDATIONS_ACCOUNT_HEADER, tenantDomain); HttpResponse httpResponse = httpClient.execute(method); if (httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { String contentString = EntityUtils.toString(httpResponse.getEntity()); if (log.isDebugEnabled()) { log.debug("Recommendations received for user " + userName + " is " + contentString); } return contentString; } else { log.warn("Error getting recommendations from server. Server responded with " + httpResponse.getStatusLine().getStatusCode()); } } catch (IOException e) { log.error("Connection failure for the recommendation engine", e); } catch (APIManagementException e) { log.error("Error while getting recommendations for user " + userName, e); } } return null; }