Source:
public Map<String, String> retrieveAttributes(String apiName, String version, String tenantDomain) throws ArtifactSynchronizerException { CloseableHttpResponse httpResponse = null; try { String endcodedVersion= URLEncoder.encode(version, APIConstants.DigestAuthConstants.CHARSET); String path = APIConstants.GatewayArtifactSynchronizer.SYNAPSE_ATTRIBUTES + "?apiName=" + apiName + "&tenantDomain="+ tenantDomain + "&version=" + endcodedVersion; String endpoint = baseURL + path; httpResponse = invokeService(endpoint); String responseString; if (httpResponse.getEntity() != null ) { responseString = EntityUtils.toString(httpResponse.getEntity(), APIConstants.DigestAuthConstants.CHARSET); httpResponse.close(); } else { throw new ArtifactSynchronizerException("HTTP response is empty"); } Map <String, String> apiAttribute = new HashMap<>(); JSONObject artifactObject = new JSONObject(responseString); String label = null; String apiId = null; try { apiId = (String)artifactObject.get(APIConstants.GatewayArtifactSynchronizer.API_ID); String labelsStr = artifactObject.get(APIConstants.GatewayArtifactSynchronizer.LABELS).toString(); Set<String> labelsSet = new Gson().fromJson(labelsStr, new TypeToken<HashSet<String>>(){}.getType()); Set<String> gatewaySubscribedLabel = gatewayArtifactSynchronizerProperties.getGatewayLabels(); if (!labelsSet.isEmpty() || !gatewaySubscribedLabel.isEmpty()){ labelsSet.retainAll(gatewaySubscribedLabel); if (!labelsSet.isEmpty()){ label = labelsSet.iterator().next(); } } } catch (Exception e ){ log.error("Unexpected response received from the storage ", e); } apiAttribute.put(APIConstants.GatewayArtifactSynchronizer.API_ID, apiId); apiAttribute.put(APIConstants.GatewayArtifactSynchronizer.LABEL, label); return apiAttribute; } catch (IOException e) { String msg = "Error while executing the http client"; log.error(msg, e); throw new ArtifactSynchronizerException(msg, e); } }

Target:
public Map<String, String> retrieveAttributes(String apiName, String version, String tenantDomain) throws ArtifactSynchronizerException { CloseableHttpResponse httpResponse = null; try { String endcodedVersion= URLEncoder.encode(version, APIConstants.DigestAuthConstants.CHARSET); String path = APIConstants.GatewayArtifactSynchronizer.SYNAPSE_ATTRIBUTES + "?apiName=" + apiName + "&tenantDomain="+ tenantDomain + "&version=" + endcodedVersion; String endpoint = baseURL + path; httpResponse = invokeService(endpoint); String responseString; if (httpResponse.getEntity() != null ) { responseString = EntityUtils.toString(httpResponse.getEntity(), APIConstants.DigestAuthConstants.CHARSET); httpResponse.close(); } else { throw new ArtifactSynchronizerException("HTTP response is empty"); } Map <String, String> apiAttribute = new HashMap<>(); JSONObject artifactObject = new JSONObject(responseString); String label = null; String apiId = null; try { apiId = (String)artifactObject.get(APIConstants.GatewayArtifactSynchronizer.API_ID); String labelsStr = artifactObject.get(APIConstants.GatewayArtifactSynchronizer.LABELS).toString(); Set<String> labelsSet = new Gson().fromJson(labelsStr, new TypeToken<HashSet<String>>(){}.getType()); Set<String> gatewaySubscribedLabel = gatewayArtifactSynchronizerProperties.getGatewayLabels(); if (!labelsSet.isEmpty() || !gatewaySubscribedLabel.isEmpty()){ labelsSet.retainAll(gatewaySubscribedLabel); if (!labelsSet.isEmpty()){ label = labelsSet.iterator().next(); } } } catch (ClassCastException e){ log.error("Unexpected response received from the storage." + e.getMessage()); } apiAttribute.put(APIConstants.GatewayArtifactSynchronizer.API_ID, apiId); apiAttribute.put(APIConstants.GatewayArtifactSynchronizer.LABEL, label); return apiAttribute; } catch (IOException e) { String msg = "Error while executing the http client"; log.error(msg, e); throw new ArtifactSynchronizerException(msg, e); } }