|
49 | 49 | import javax.ws.rs.WebApplicationException; |
50 | 50 | import javax.ws.rs.client.Client; |
51 | 51 | import javax.ws.rs.client.ClientBuilder; |
| 52 | +import javax.ws.rs.client.Invocation; |
52 | 53 | import javax.ws.rs.client.WebTarget; |
53 | 54 | import javax.ws.rs.core.MediaType; |
54 | 55 | import javax.ws.rs.core.Response; |
@@ -85,7 +86,18 @@ public Properties proxyRequest(UriInfo sourceUriInfo, Client client, ServiceLoca |
85 | 86 | URI forwardURI = forwardUriBuilder.scheme("https").host(forwardInstance.getAdminHost()).port(forwardInstance.getAdminPort()).build(); //Host and Port are replaced to that of forwardInstanceName |
86 | 87 | client = addAuthenticationInfo(client, forwardInstance, habitat); |
87 | 88 | WebTarget resourceBuilder = client.target(forwardURI); |
88 | | - Response response = resourceBuilder.request(MediaType.APPLICATION_JSON).get(Response.class); //TODO if the target server is down, we get ClientResponseException. Need to handle it |
| 89 | + SecureAdmin secureAdmin = habitat.getService(SecureAdmin.class); |
| 90 | + final String indicatorValue = SecureAdmin.Util.configuredAdminIndicator(secureAdmin); |
| 91 | + Invocation.Builder builder; |
| 92 | + Response response; |
| 93 | + if (indicatorValue != null) { |
| 94 | + builder = resourceBuilder.request(MediaType.APPLICATION_JSON).header( |
| 95 | + SecureAdmin.Util.ADMIN_INDICATOR_HEADER_NAME, |
| 96 | + indicatorValue); |
| 97 | + response = builder.get(Response.class); |
| 98 | + } else { |
| 99 | + response = resourceBuilder.request(MediaType.APPLICATION_JSON).get(Response.class); |
| 100 | + } |
89 | 101 | Response.Status status = Response.Status.fromStatusCode(response.getStatus()); |
90 | 102 | if (status.getFamily() == javax.ws.rs.core.Response.Status.Family.SUCCESSFUL) { |
91 | 103 | String jsonDoc = response.readEntity(String.class); |
|
0 commit comments