Source:
public Response endPointsGet(String apiName, String version , String tenantDomain, MessageContext messageContext) { InMemoryAPIDeployer inMemoryApiDeployer = new InMemoryAPIDeployer(); if (tenantDomain == null){ tenantDomain =SUPER_TENAT_DOMAIN; } Map<String, String> apiAttributes = inMemoryApiDeployer.getGatewayAPIAttributes(apiName, version, tenantDomain); String apiId = apiAttributes.get(APIConstants.GatewayArtifactSynchronizer.API_ID); String label = apiAttributes.get(APIConstants.GatewayArtifactSynchronizer.LABEL); GatewayAPIDTO gatewayAPIDTO = inMemoryApiDeployer.getAPIArtifact(apiId, label); JSONObject responseObj = new JSONObject(); if (gatewayAPIDTO != null) { try { JSONArray endPointArray = new JSONArray(); JSONArray unDeployedEndPointArray = new JSONArray(); if (gatewayAPIDTO.getEndpointEntriesToBeAdd() != null) { EndpointAdminServiceProxy endpointAdminServiceProxy = new EndpointAdminServiceProxy (gatewayAPIDTO.getTenantDomain()); for (GatewayContentDTO gatewayEndpoint : gatewayAPIDTO.getEndpointEntriesToBeAdd()) { if (endpointAdminServiceProxy.isEndpointExist(gatewayEndpoint.getName())) { endPointArray.put(endpointAdminServiceProxy.getEndpoints(gatewayEndpoint.getName())); } else { log.error(gatewayEndpoint.getName() + " was not deployed in the gateway"); unDeployedEndPointArray.put(gatewayEndpoint.getContent()); } } } responseObj.put("Deployed Endpoints", endPointArray); responseObj.put("UnDeployed Endpoints", unDeployedEndPointArray); } catch (EndpointAdminException e) { String errorMessage = "Error in fetching deployed Endpoints from Synapse Configuration"; log.error(errorMessage, e); RestApiUtil.handleInternalServerError(errorMessage, e, log); } String responseStringObj = String.valueOf(responseObj); return Response.ok().entity(responseStringObj).build(); } else { responseObj.put("Message", "Error"); String responseStringObj = String.valueOf(responseObj); return Response.serverError().entity(responseStringObj).build(); } }

Target:
public Response endPointsGet(String apiName, String version , String tenantDomain, MessageContext messageContext) { InMemoryAPIDeployer inMemoryApiDeployer = new InMemoryAPIDeployer(); if (tenantDomain == null) { tenantDomain = APIConstants.SUPER_TENANT_DOMAIN; } Map<String, String> apiAttributes = inMemoryApiDeployer.getGatewayAPIAttributes(apiName, version, tenantDomain); String apiId = apiAttributes.get(APIConstants.GatewayArtifactSynchronizer.API_ID); String label = apiAttributes.get(APIConstants.GatewayArtifactSynchronizer.LABEL); GatewayAPIDTO gatewayAPIDTO = inMemoryApiDeployer.getAPIArtifact(apiId, label); JSONObject responseObj = new JSONObject(); if (gatewayAPIDTO != null) { try { JSONArray endPointArray = new JSONArray(); JSONArray unDeployedEndPointArray = new JSONArray(); if (gatewayAPIDTO.getEndpointEntriesToBeAdd() != null) { EndpointAdminServiceProxy endpointAdminServiceProxy = new EndpointAdminServiceProxy (gatewayAPIDTO.getTenantDomain()); for (GatewayContentDTO gatewayEndpoint : gatewayAPIDTO.getEndpointEntriesToBeAdd()) { if (endpointAdminServiceProxy.isEndpointExist(gatewayEndpoint.getName())) { endPointArray.put(endpointAdminServiceProxy.getEndpoints(gatewayEndpoint.getName())); } else { log.error(gatewayEndpoint.getName() + " was not deployed in the gateway"); unDeployedEndPointArray.put(gatewayEndpoint.getContent()); } } } responseObj.put("Deployed Endpoints", endPointArray); responseObj.put("UnDeployed Endpoints", unDeployedEndPointArray); } catch (EndpointAdminException e) { String errorMessage = "Error in fetching deployed Endpoints from Synapse Configuration"; log.error(errorMessage, e); RestApiUtil.handleInternalServerError(errorMessage, e, log); } String responseStringObj = String.valueOf(responseObj); return Response.ok().entity(responseStringObj).build(); } else { responseObj.put("Message", "Error"); String responseStringObj = String.valueOf(responseObj); return Response.serverError().entity(responseStringObj).build(); } }