@Override public ApplicationStatus handle(final Response response) throws ResponseException { return response.isSuccessful() || (response.getStatusCode() == HttpStatus.SC_FORBIDDEN) || (response.getStatusCode() == HttpStatus.SC_UNAUTHORIZED) ? ApplicationStatus.AVAILABLE : ApplicationStatus.UNAVAILABLE; }
@Override public void handle(final Response response) throws ResponseException { successful = response.getStatusCode() >= 200 && response.getStatusCode() < 300; responseBody = Optional.of(response.getResponseBodyAsString()); LOGGER.debug("Status: " + response.getStatusCode()); LOGGER.debug(responseBody.get()); }
public void handle(final Response createLinkBackResponse) throws ResponseException { if (createLinkBackResponse.getStatusCode() == 201) { // cool! created reciprocal link, continue } else { throw new ResponseException(String.format("Received %s - %s", createLinkBackResponse.getStatusCode(), createLinkBackResponse.getStatusText() )); } } });
public Boolean handle(final Response response) throws ResponseException { if (response.getStatusCode() == 200) { // deleted reciprocal link, continue return false; } else { throw new ResponseException(String.format("Received %s - %s", response.getStatusCode(), response.getStatusText() )); } }
@Override public void handle(Response response) throws ResponseException { assertEquals(200, response.getStatusCode()); } });
@Nonnull public static Response fail(@Nonnull Response response) throws ResponseStatusException { throw new ResponseStatusException("Unexpected status: " + response.getStatusCode(), response); } }
private boolean hasLocation(final Response response) { final String location = response.getHeader("location"); if (isBlank(location)) { log.warn("HTTP response returned redirect code {} but did not provide a location header", response.getStatusCode()); } return isNotBlank(location); }
public void handle(final Response response) throws ResponseException { if (response.getStatusCode() == 200) { // deleted reciprocal link, continue } else { throw new ResponseException(String.format("Received %s - %s", response.getStatusCode(), response.getStatusText() )); } } });
private boolean hasLocation(final Response response) { final String location = response.getHeader("location"); if (isBlank(location)) { log.warn("HTTP response returned redirect code " + response.getStatusCode() + " but did not provide a location header"); } return isNotBlank(location); }
@Override public RestResponse handle(Response response) throws ResponseException { if (response.getStatusCode() == HttpStatus.SC_FORBIDDEN || response.getStatusCode() == HttpStatus.SC_UNAUTHORIZED) { return credentialsRequired(response); } return new RestResponse(response); }
@Override public Response handle(com.atlassian.sal.api.net.Response response) throws ResponseException { final Response.ResponseBuilder responseBuilder = Response.status(response.getStatusCode()).entity(response.getResponseBodyAsString()); for (Map.Entry<String, String> h : filter(response.getHeaders().entrySet(), not(BLACKLISTED_HEADERS))) { logger.debug("adding header {}:{}", h.getKey(), h.getValue()); responseBuilder.header(h.getKey(), h.getValue()); } return responseBuilder.build(); } }
public void handle(Response response) throws ResponseException { if (response.getStatusCode() == HttpServletResponse.SC_OK) { instance.getProperties().setProperty(TRUST, Boolean.TRUE.toString()); log.debug("Synchronisation SUCCESS"); } else { log.warn("Synchronisation FAILURE " + instance.getUrl() + ". Response: " + response.getStatusCode() + " " + response.getResponseBodyAsString()); } } });
public void handle(Response response) throws ResponseException { if (log.isTraceEnabled()) { log.trace("Server response is: {}", response.getResponseBodyAsString()); } requestReturned404.setValue(response.getStatusCode() == 404); } });
@Override public ApplinkOAuthStatus handle(Response response) throws ResponseException { checkStatus(response, Status.OK, Status.NOT_FOUND); return response.getStatusCode() == Status.OK.getStatusCode() ? getStatusFrom(response) : null; }
public void handle(final Response response) throws ResponseException { if (response.getStatusCode() == 200) { Iterables.addAll(entities, response.getEntity(ReferenceEntityList.class).getEntities(typeAccessor)); } else { throw new ResponseException(String.format("Failed to retrieve entity list, received %s response: %s", response.getStatusCode(), response.getStatusText())); } } });
@SuppressWarnings("ConstantConditions") public AbstractResponseApplinkError(@Nonnull Response response) { this.statusCode = response.getStatusCode(); this.body = Strings.emptyToNull(getTruncatedBody(response)); this.contentType = this.body != null ? getContentType(response).getMimeType() : null; }
public void handle(Response response) throws ResponseException { assertEquals(HttpServletResponse.SC_UNAUTHORIZED, response.getStatusCode()); assertTrue(response.getResponseBodyAsString().contains("This resource requires WebSudo")); } });
public String handle(final Response response) throws ResponseException { if (!response.isSuccessful()) { throw new ResponseStatusException("Unexpected response received. Status code: " + response.getStatusCode(), response); } return response.getResponseBodyAsString(); } }
public void handle(Response response) throws ResponseException { assertEquals(HttpServletResponse.SC_OK, response.getStatusCode()); assertEquals(expectedText, response.getResponseBodyAsString()); } });
public void handle(final Response response) throws ResponseException { if (response.isSuccessful()) { success.set(true); } else { errorMessage.set(String.format("Response code: %d: %s", response.getStatusCode(), response.getResponseBodyAsString())); } } });