@Override @SuppressWarnings("ThrowableResultOfMethodCallIgnored") public boolean execute(@Nonnull final ApplicationLink applicationLink, @Nonnull final ApplicationId applicationId, @Nonnull final ApplicationLinkRequestFactory factory) throws IOException, CredentialsRequiredException, ResponseException, AuthenticationConfigurationException { try { configurator.enable(incoming, outgoing, applicationLink, factory); return true; } catch (AuthenticationConfigurationException ex) { ResponseStatusException cause = findCauseOfType(ex, ResponseStatusException.class); if (cause != null) { if (equalsStatus(cause.getResponse(), FORBIDDEN) || equalsStatus(cause.getResponse(), UNAUTHORIZED)) { return false; } } throw ex; } }
int statusCode = ex.getResponse().getStatusCode(); if (statusCode == 401)
@Override @SuppressWarnings("ConstantConditions") public ApplinkStatusException createMatchingError(String message, Throwable original) { ResponseStatusException statusException = findCauseOfType(original, ResponseStatusException.class); Response response = statusException.getResponse(); // response should generally always be available, but it's subject to well-behaved response handlers which // is sometimes outside of our control, so let's fall back to an "unknown" status in case there's no // response to figure it out from return response != null ? new ResponseApplinkStatusException(new UnexpectedResponseStatusError(response), statusException) : new SimpleApplinkStatusException(ApplinkErrorType.UNEXPECTED_RESPONSE_STATUS, "<UNKNOWN STATUS>", statusException); } }
int statusCode = ex.getResponse().getStatusCode(); if (statusCode == 401)