response.bufferEntity(); final int statusCode = response.getStatus(); final Response.Status status = Response.Status.fromStatusCode(statusCode); final Response.Status.Family statusFamily = response.getStatusInfo().getFamily(); webAppException = createExceptionForFamily(response, statusFamily); } else { break; default: final Response.Status.Family statusFamily = response.getStatusInfo().getFamily(); webAppException = createExceptionForFamily(response, statusFamily); return new ResponseProcessingException(response, webAppException); } catch (final Throwable t) { return new ResponseProcessingException(response, LocalizationMessages.RESPONSE_TO_EXCEPTION_CONVERSION_FAILED(), t);
response = ((ResponseProcessingException) cause).getResponse(); } else if (cause instanceof WebApplicationException) { response = ((WebApplicationException) cause).getResponse(); throw new DockerRequestException(method, resource.getUri(), response.getStatus(), message(response), cause); } else if ((cause instanceof SocketTimeoutException)
: client.getProjectQualifiedName(project); } catch (ResponseProcessingException rpe) { if (rpe.getResponse().getStatus() == 404) { log.error("Project {} not found", project); return; client.downloadFile(fileType, transLang, qualifiedName); } catch (ResponseProcessingException e) { if (e.getResponse().getStatus() == 404) { log.info("No glossary file in server"); return; InputStream glossaryFile = response.readEntity(InputStream.class); if (glossaryFile == null) { log.info("No glossary file in server");
int status = response.getStatus(); if (status >= 200 && status < 300) if (response.getMediaType() == null) T rtn = response.readEntity(responseType, annotations); if (InputStream.class.isInstance(rtn) || Reader.class.isInstance(rtn) || EventInput.class.isInstance(rtn)) throw new ResponseProcessingException(response, throwable);
.getProjectVersion(), locale.getId(), fileExtension, qualifiedDocName, getOpts().getApprovedOnly()); InputStream transDoc = response.readEntity(InputStream.class); if (transDoc != null) { try { String fileName = ClientUtil.getFileNameFromHeader( response.getStringHeaders()); String targetFileExt = FilenameUtils .getExtension(fileName); if (e.getResponse().getStatus() == 404) { log.info( "No translation document file found in locale {} for document [{}]",
qualifiedDocName); InputStream srcDoc = response .readEntity(InputStream.class); if (srcDoc != null) { try { if (e.getResponse().getStatus() == 404) { log.warn( "No source document file is available for [{}]. Skipping.",
sb.append(Base64Utility.encode(data.getBytes(StandardCharsets.UTF_8))); } catch (Exception ex) { throw new ProcessingException(ex); Map<String, String> map = null; try { map = new OAuthJSONProvider().readJSONResponse((InputStream)response.getEntity()); } catch (IOException ex) { throw new ResponseProcessingException(response, ex); if (200 == response.getStatus()) { ClientAccessToken token = fromMapToClientToken(map, defaultTokenType); if (token == null) { } else if (response.getStatus() >= 400 && map.containsKey(OAuthConstants.ERROR_KEY)) { OAuthError error = new OAuthError(map.get(OAuthConstants.ERROR_KEY), map.get(OAuthConstants.ERROR_DESCRIPTION_KEY));
if (candiate.handles(response.getStatus(), response.getHeaders())) response.bufferEntity(); if (prioritised.isPresent()) throw new ResponseProcessingException(response, t);
public String putResource(String docId, Resource resource, Set<String> extensions, boolean copyTrans) { Client client = factory.getClient(); WebTarget webResource = getBaseServiceResource(client).path("resource") .queryParam("docId", docId) .queryParam("ext", extensions.toArray()) .queryParam("copyTrans", String.valueOf(copyTrans)); try { Response response = webResource.request(MediaType.APPLICATION_XML_TYPE) .put(Entity.entity(resource, MediaType.APPLICATION_XML_TYPE)); response.bufferEntity(); return response.readEntity(String.class); } catch (ResponseProcessingException e) { if (RestUtil.isNotFound(e.getResponse())) { // fallback to old endpoint String idNoSlash = RestUtil.convertToDocumentURIId(docId); webResource = getBaseServiceResource(client) .path("r") .path(idNoSlash) .queryParam("ext", extensions.toArray()) .queryParam("copyTrans", String.valueOf(copyTrans)); Response response = webResource.request(MediaType.APPLICATION_XML_TYPE) .put(Entity.entity(resource, MediaType.APPLICATION_XML_TYPE)); response.bufferEntity(); return response.readEntity(String.class); } throw e; } }
if (response.getStatusInfo().getFamily() == Response.Status.Family.SUCCESSFUL) InputStream inputStream = response.readEntity(InputStream.class); try throw new ResponseProcessingException(response, e); response.close();
public static void printErrorMessage(Throwable throwable) { final Throwable cause = throwable.getCause(); if (cause == null) { System.out.println("cause = " + cause); //noinspection Duplicates } else if (cause instanceof ResponseProcessingException) { final ResponseProcessingException responseProcessingException = (ResponseProcessingException) cause; final Response response = responseProcessingException.getResponse(); final String s1 = response.readEntity(String.class); java.lang.System.out.println("s1 = " + s1); } else { throwable.printStackTrace(); } }
public @Nullable Account get(String username) { try { return webResource(username) .get(Account.class); } catch (ResponseProcessingException e) { if (e.getResponse().getStatusInfo().equals(Response.Status.NOT_FOUND)) { return null; } else { throw e; } } }
protected Object interceptorChainCompleted() throws Exception { try { return method.invoke(target, args); } catch (InvocationTargetException e) { if (e.getCause() instanceof ResponseProcessingException) { ResponseProcessingException rpe = (ResponseProcessingException) e.getCause(); // Note that the default client engine leverages a single connection // MP FT: we need to close the response otherwise we would not be able to retry if the method returns javax.ws.rs.core.Response rpe.getResponse().close(); Throwable cause = rpe.getCause(); if (cause instanceof RuntimeException) { throw (RuntimeException) cause; } } throw e; } }
@Override public ClientResponse invoke() { Providers current = pushProvidersContext(); try { ClientRequestContextImpl requestContext = new ClientRequestContextImpl(this); ClientResponse aborted = filterRequest(requestContext); // spec requires that aborted response go through filter/interceptor chains. ClientResponse response = (aborted != null) ? aborted : (ClientResponse)client.httpEngine().invoke(this); return filterResponse(requestContext, response); } catch (ResponseProcessingException e) { if (e.getResponse() != null) { e.getResponse().close(); } throw e; } finally { popProvidersContext(current); } }
private static RuntimeException clientException(Throwable ex, Response clientResponse) { RuntimeException ret; if (ex == null) { ret = new ProcessingException(new NullPointerException()); } else if (ex instanceof WebApplicationException) { ret = (WebApplicationException) ex; } else if (ex instanceof ProcessingException) { ret = (ProcessingException) ex; } else if (clientResponse != null) { ret = new ResponseProcessingException(clientResponse, ex); } else { ret = new ProcessingException(ex); } return ret; }
private <T> T translate(final ClientResponse response, final RequestScope scope, final Class<T> responseType) throws ProcessingException { if (responseType == Response.class) { return responseType.cast(new InboundJaxrsResponse(response, scope)); } if (response.getStatusInfo().getFamily() == Response.Status.Family.SUCCESSFUL) { try { return response.readEntity(responseType); } catch (final ProcessingException ex) { if (ex.getClass() == ProcessingException.class) { throw new ResponseProcessingException(new InboundJaxrsResponse(response, scope), ex.getCause()); } throw new ResponseProcessingException(new InboundJaxrsResponse(response, scope), ex); } catch (final WebApplicationException ex) { throw new ResponseProcessingException(new InboundJaxrsResponse(response, scope), ex); } catch (final Exception ex) { throw new ResponseProcessingException(new InboundJaxrsResponse(response, scope), LocalizationMessages.UNEXPECTED_ERROR_RESPONSE_PROCESSING(), ex); } } else { throw convertToException(new InboundJaxrsResponse(response, scope)); } }
@Override public Continuation<ClientResponse> apply(ClientResponse responseContext) { try { for (ClientResponseFilter filter : filters) { filter.filter(responseContext.getRequestContext(), responseContext); } } catch (IOException ex) { InboundJaxrsResponse response = new InboundJaxrsResponse(responseContext, null); throw new ResponseProcessingException(response, ex); } return Continuation.of(responseContext, getDefaultNext()); } }
.get(ContainerTranslationStatistics.class); } catch (ResponseProcessingException e) { if (RestUtil.isNotFound(e.getResponse())) {
protected ClientResponse filterResponse(ClientRequestContextImpl requestContext, ClientResponse response) { response.setProperties(configuration.getMutableProperties()); ClientResponseFilter[] responseFilters = getResponseFilters(); if (responseFilters != null && responseFilters.length > 0) { ClientResponseContextImpl responseContext = new ClientResponseContextImpl(response); for (ClientResponseFilter filter : responseFilters) { try { filter.filter(requestContext, responseContext); } catch (ResponseProcessingException e) { throw e; } catch (Throwable e) { throw new ResponseProcessingException(response, e); } } } return response; }
Throwable cause = rpe.getCause(); if (cause instanceof RuntimeException)