@Override protected CopyInformationBean parseResponse(Response response) throws ResponseException, JSONException { return response.getEntity(CopyInformationBean.class); } });
@Override protected FieldPermissionsBean parseResponse(Response response) throws ResponseException, JSONException { return response.getEntity(FieldPermissionsBean.class); } });
public Object handle(Response response) throws ResponseException { return response.getEntity(resultClass); } }
public ErrorListEntity handle(final Response response) throws ResponseException { // 201 means we created a new application link. // 200 means there already is an application link and we just updated this one. return !response.isSuccessful() ? response.getEntity(ErrorListEntity.class) : null; } });
private Set<ApplinksCapabilities> getCapabilities(Response response) throws ResponseException { @SuppressWarnings("unchecked") Iterable<String> stringCapabilities = response.getEntity(List.class); Iterable<ApplinksCapabilities> enumCapabilities = transform(stringCapabilities, fromNameSafe(ApplinksCapabilities.class)); return Sets.newEnumSet(filter(enumCapabilities, Predicates.notNull()), ApplinksCapabilities.class); } }
@Override protected IssueCreationResultBean parseResponse(Response response) throws ResponseException, JSONException { if (response.isSuccessful()) { return response.getEntity(IssueCreationResultBean.class); } else { ErrorBean errorBean = response.getEntity(ErrorBean.class); return provideResponseStatus(NegativeResponseStatus.errorOccured(jiraLocation, errorBean)); } } });
private ApplinkOAuthStatus getStatusFrom(Response response) throws ResponseException { try { return response.getEntity(RestApplinkOAuthStatus.class).asDomain(); } catch (Exception e) { throw new ResponseContentException(response, e); } } }
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())); } } });
public void handle(final com.atlassian.sal.api.net.Response response) throws ResponseException { // 201 means we created a new application link. // 200 means there already is an application link and we just updated this one. if (!response.isSuccessful()) { try { final ErrorListEntity listEntity = response.getEntity(ErrorListEntity.class); warnings.addAll(listEntity.getErrors()); } catch (RuntimeException re) { LOG.warn("Could not parse the peer's response to " + "upgrade application link \"" + oldApplicationLink.getName() + "\" to a bi-directional link. Status code: " + response.getStatusCode() + "."); throw re; } } } });
@Override public void handle(final Response response) throws ResponseException { super.handle(response); if (isSuccessful()) { final AuthenticationProviderEntityListEntity listEntity = response.getEntity(AuthenticationProviderEntityListEntity.class); final List<AuthenticationProviderEntity> providers = listEntity.getAuthenticationProviders(); if (providers != null) { for (AuthenticationProviderEntity provider : providers) { if (BasicAuthenticationProvider.class.getName().equals(provider.getProvider())) { legacyConfig = legacyConfig.basic(true); } if (TrustedAppsAuthenticationProvider.class.getName().equals(provider.getProvider())) { legacyConfig = legacyConfig.trusted(true); } } } } } }
public PermissionCode handle(final com.atlassian.sal.api.net.Response response) throws ResponseException { if (response.getStatusCode() == 200) { try { return response.getEntity(PermissionCodeEntity.class).getCode(); } catch (Exception e) { throw new ResponseException( String.format("Permission check failed, exception " + "encountered processing response: %s", e)); } } else if (response.getStatusCode() == 401) { ApplicationLinkRequestFactory authenticatedRequestFactory = applicationLink.createImpersonatingAuthenticatedRequestFactory(); if (authenticatedRequestFactory == null) { authenticatedRequestFactory = applicationLink.createNonImpersonatingAuthenticatedRequestFactory(); } if (authenticatedRequestFactory != null) { LOG.warn("Authentication failed for application link " + applicationLink + ". Response headers: " + response.getHeaders().toString() + " body: " + response.getResponseBodyAsString()); } else if (LOG.isDebugEnabled()) { LOG.debug("Authentication failed for application link " + applicationLink + ". Response headers: " + response.getHeaders().toString() + " body: " + response.getResponseBodyAsString()); } return AUTHENTICATION_FAILED; } else { throw new ResponseException(String.format("Permission check failed, received %s", response.getStatusCode())); } } });
@Override public ApplinkOAuthStatus handle(Response response) throws ResponseException { if (response.getStatusCode() == NOT_FOUND.getStatusCode()) { return null; } else if (response.getStatusCode() == FORBIDDEN.getStatusCode() || response.getStatusCode() == UNAUTHORIZED.getStatusCode()) { throw new ApplinkStatusAccessException(ApplinkErrorType.INSUFFICIENT_REMOTE_PERMISSION, uriGenerator, INSUFFICIENT_PERMISSION_MESSAGE); } else { checkStatusOk(response); try { RestApplicationLinkAuthentication authenticationEntity = response.getEntity( RestApplicationLinkAuthentication.class); return new ApplinkOAuthStatus( getIncomingConfig(authenticationEntity), getOutgoingConfig(authenticationEntity) ); } catch (Exception e) { throw new ResponseContentException(response, e); } } }
public void handle(Response response) throws ResponseException { // this means the response indicates a redirection. if (response.getStatusCode() >= 300 && response.getStatusCode() < 400) { final String location = response.getHeader("Location"); if (location == null) { throw new ResponseException("manifest not found"); } LOG.info("Manifest request got redirected to '" + location + "'."); exception.set(new ManifestGotRedirectedException("manifest got redirected", location)); } else if (response.isSuccessful()) { try { manifestHolder.set(asManifest(response.getEntity(ManifestEntity.class))); } catch (Exception ex) { exception.set(ex); } } } });
public void handle(Response response) throws ResponseException { // this means the response indicates a redirection. if (response.getStatusCode() >= 300 && response.getStatusCode() < 400) { final String location = response.getHeader("Location"); if (location == null) { throw new ResponseException("manifest not found"); } LOG.info("Manifest request got redirected to '" + location + "'."); exception.set(new ManifestGotRedirectedException("manifest got redirected", location)); } else { checkStatusOk(response); try { manifestHolder.set(asManifest(response.getEntity(ManifestEntity.class))); } catch (Exception ex) { exception.set(new ResponseContentException(response, ex)); } } } });
public Either<NegativeResponseStatus, T> handle(final Response response) throws ResponseException { if (log.isDebugEnabled()) { log.debug("Response is: " + response.getResponseBodyAsString()); } if (response.getStatusCode() == 401) { return Either.left(NegativeResponseStatus.authenticationFailed(jiraLocation)); } if (response.getStatusCode() == 404) { return Either.left(NegativeResponseStatus.pluginNotInstalled(jiraLocation)); } if (!response.isSuccessful()) { try { ErrorBean error = response.getEntity(ErrorBean.class); return Either.left(NegativeResponseStatus.errorOccured(jiraLocation, error)); } catch (ResponseException e) { return Either.left(NegativeResponseStatus.communicationFailed(jiraLocation)); } } try { T parsedResponse = parseResponse(response); if (providedResponseStatus != null) { return Either.left(providedResponseStatus); } else { return Either.right(parsedResponse); } } catch (JSONException e) { log.error(String.format("Failed to parse JSON from Application Link: %s (%s)", jiraLocation.getId(), e.getMessage())); return Either.left(NegativeResponseStatus.communicationFailed(jiraLocation)); } }
respBuilder.errors(response.getEntity(Errors.class));