Java Code Examples for org.springframework.http.ResponseEntity#hasBody()
The following examples show how to use
org.springframework.http.ResponseEntity#hasBody() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ClientApplicationStatusUpdater.java From spring-batch-lightmin with Apache License 2.0 | 6 votes |
private LightminClientApplicationStatus getStatus(final LightminClientApplication lightminClientApplication) { LightminClientApplicationStatus lightminClientApplicationStatus; try { @SuppressWarnings("unchecked") final ResponseEntity<Map<String, Object>> response = this.restTemplate.getForEntity(lightminClientApplication.getHealthUrl(), (Class<Map<String, Object>>) (Class<?>) Map.class); if (response.hasBody() && response.getBody().get(STATUS_RESPONSE_KEY) instanceof String) { lightminClientApplicationStatus = LightminClientApplicationStatus.valueOf((String) response.getBody().get(STATUS_RESPONSE_KEY)); } else if (response.getStatusCode().is2xxSuccessful()) { lightminClientApplicationStatus = LightminClientApplicationStatus.ofUp(); } else { lightminClientApplicationStatus = LightminClientApplicationStatus.ofOffline(); } } catch (final Exception ex) { if (LightminClientApplicationStatus.ofOffline().getStatus().equals(lightminClientApplication .getLightminClientApplicationStatus().getStatus())) { log.debug("Error while getting status for {}", lightminClientApplication, ex); } else { log.warn("Error while getting status for {}", lightminClientApplication, ex); } lightminClientApplicationStatus = LightminClientApplicationStatus.ofOffline(); } return lightminClientApplicationStatus; }
Example 2
Source File: RestTemplateEurekaHttpClient.java From spring-cloud-netflix with Apache License 2.0 | 6 votes |
@Override public EurekaHttpResponse<InstanceInfo> sendHeartBeat(String appName, String id, InstanceInfo info, InstanceStatus overriddenStatus) { String urlPath = serviceUrl + "apps/" + appName + '/' + id + "?status=" + info.getStatus().toString() + "&lastDirtyTimestamp=" + info.getLastDirtyTimestamp().toString() + (overriddenStatus != null ? "&overriddenstatus=" + overriddenStatus.name() : ""); ResponseEntity<InstanceInfo> response = restTemplate.exchange(urlPath, HttpMethod.PUT, null, InstanceInfo.class); EurekaHttpResponseBuilder<InstanceInfo> eurekaResponseBuilder = anEurekaHttpResponse( response.getStatusCodeValue(), InstanceInfo.class) .headers(headersOf(response)); if (response.hasBody()) { eurekaResponseBuilder.entity(response.getBody()); } return eurekaResponseBuilder.build(); }
Example 3
Source File: UAAClient.java From multiapps-controller with Apache License 2.0 | 5 votes |
public Map<String, Object> readTokenKey() { String tokenKeyURL = uaaUrl.toString() + TOKEN_KEY_ENDPOINT; ResponseEntity<String> tokenKeyResponse = restTemplate.getForEntity(tokenKeyURL, String.class); if (!tokenKeyResponse.hasBody()) { throw new IllegalStateException(MessageFormat.format("Invalid response returned from /token_key: {0}", tokenKeyResponse.getBody())); } return JsonUtil.convertJsonToMap(tokenKeyResponse.getBody()); }
Example 4
Source File: HalActuatorEndpointsDiscoverer.java From microservices-dashboard with Apache License 2.0 | 5 votes |
private Links discoverLinks(ResponseEntity<String> response) { Links links = new Links(); if (!response.getStatusCode().isError() && response.hasBody() && !StringUtils.isEmpty(response.getBody())) { MediaType mediaType = Optional.ofNullable(response.getHeaders().getContentType()) .orElse(MediaTypes.HAL_JSON_UTF8); links = createLinksFrom(response.getBody(), mediaType); } return links; }
Example 5
Source File: StudioWorkspaceResourceHandler.java From bonita-ui-designer with GNU General Public License v2.0 | 5 votes |
@Override public LockStatus getLockStatus(final Path filePath) throws ResourceNotFoundException { try { ResponseEntity<String> lockStatusResponse = doGet(filePath, GET_LOCK_STATUS); if (lockStatusResponse.hasBody()) { return LockStatus.valueOf(lockStatusResponse.getBody()); } } catch (Exception e) { handleResourceException(filePath, e); } return LockStatus.UNLOCKED; }
Example 6
Source File: RestTemplateEurekaHttpClient.java From spring-cloud-netflix with Apache License 2.0 | 5 votes |
@Override public EurekaHttpResponse<Application> getApplication(String appName) { String urlPath = serviceUrl + "apps/" + appName; ResponseEntity<Application> response = restTemplate.exchange(urlPath, HttpMethod.GET, null, Application.class); Application application = response.getStatusCodeValue() == HttpStatus.OK.value() && response.hasBody() ? response.getBody() : null; return anEurekaHttpResponse(response.getStatusCodeValue(), application) .headers(headersOf(response)).build(); }