Source:
public API getApi(String version, String context) { API api = null; try ( Connection conn = APIMgtDBUtil.getConnection(); PreparedStatement ps = conn.prepareStatement(SubscriptionValidationSQLConstants.GET_API_SQL + " UNION " + SubscriptionValidationSQLConstants.GET_API_PRODUCT_SQL)) { ps.setString(1, version); ps.setString(2, context); ps.setString(3, version); ps.setString(4, context); ResultSet resultSet = ps.executeQuery(); Map<Integer, API> temp = new ConcurrentHashMap<>(); while (resultSet.next()) { int apiId = resultSet.getInt("API_ID"); api = temp.get(apiId); if (api == null) { api = new API(); api.setApiId(apiId); api.setProvider(resultSet.getString("API_PROVIDER")); api.setName(resultSet.getString("API_NAME")); api.setPolicy(resultSet.getString("API_TIER")); api.setVersion(resultSet.getString("API_VERSION")); api.setContext(resultSet.getString("CONTEXT")); api.setIsDefaultVersion(resultSet.getBoolean("PUBLISHED_DEFAULT_API_VERSION")); temp.put(apiId, api); } String urlPattern = resultSet.getString("URL_PATTERN"); String httpMethod = resultSet.getString("HTTP_METHOD"); URLMapping urlMapping = api.getResource(urlPattern, httpMethod); if (urlMapping == null) { urlMapping = new URLMapping(); urlMapping.setThrottlingPolicy(resultSet.getString("RES_TIER")); urlMapping.setAuthScheme(resultSet.getString("AUTH_SCHEME")); urlMapping.setHttpMethod(httpMethod); urlMapping.setUrlPattern(urlPattern); api.addResource(urlMapping); } String scopeName = resultSet.getString("SCOPE_NAME"); if (StringUtils.isNotEmpty(scopeName)) { urlMapping.addScope(scopeName); } } } catch (SQLException e) { log.error("Error in loading API for api : " + context + " : " + version, e); } return api; }

Target:
public API getApi(String version, String context) { API api = null; try ( Connection conn = APIMgtDBUtil.getConnection(); PreparedStatement ps = conn.prepareStatement(SubscriptionValidationSQLConstants.GET_API_SQL + " UNION " + SubscriptionValidationSQLConstants.GET_API_PRODUCT_SQL)) { ps.setString(1, version); ps.setString(2, context); ps.setString(3, version); ps.setString(4, context); ResultSet resultSet = ps.executeQuery(); Map<Integer, API> temp = new ConcurrentHashMap<>(); while (resultSet.next()) { int apiId = resultSet.getInt("API_ID"); api = temp.get(apiId); if (api == null) { api = new API(); api.setApiId(apiId); api.setProvider(resultSet.getString("API_PROVIDER")); api.setName(resultSet.getString("API_NAME")); api.setPolicy(resultSet.getString("API_TIER")); String apiVersionFromDB = resultSet.getString("API_VERSION"); api.setVersion(apiVersionFromDB); api.setContext(resultSet.getString("CONTEXT")); String publishedDefaultVersion = resultSet.getString("PUBLISHED_DEFAULT_API_VERSION"); if (apiVersionFromDB != null) { api.setIsDefaultVersion(apiVersionFromDB.equals(publishedDefaultVersion)); } temp.put(apiId, api); } String urlPattern = resultSet.getString("URL_PATTERN"); String httpMethod = resultSet.getString("HTTP_METHOD"); URLMapping urlMapping = api.getResource(urlPattern, httpMethod); if (urlMapping == null) { urlMapping = new URLMapping(); urlMapping.setThrottlingPolicy(resultSet.getString("RES_TIER")); urlMapping.setAuthScheme(resultSet.getString("AUTH_SCHEME")); urlMapping.setHttpMethod(httpMethod); urlMapping.setUrlPattern(urlPattern); api.addResource(urlMapping); } String scopeName = resultSet.getString("SCOPE_NAME"); if (StringUtils.isNotEmpty(scopeName)) { urlMapping.addScope(scopeName); } } } catch (SQLException e) { log.error("Error in loading API for api : " + context + " : " + version, e); } return api; }