Refine search
if (acceptors == null) { throw new NotAllowedException( Response.status(Status.METHOD_NOT_ALLOWED).allow(consumesProducesAcceptors.keySet()).build()); effectiveResponseType = MediaType.APPLICATION_OCTET_STREAM_TYPE; } else { throw new NotAcceptableException(); throw new NotAcceptableException();
ResponseBuilder resBuilder = Response.ok(allowHeaderValue.toString(), MediaType.TEXT_PLAIN_TYPE).header(HttpHeaderNames.ALLOW, allowHeaderValue.toString()); Response res = Response.status(HttpResponseCodes.SC_METHOD_NOT_ALLOWED).header(HttpHeaderNames.ALLOW, allowHeaderValue).build(); throw new NotAllowedException(Messages.MESSAGES.noResourceMethodFoundForHttpMethod(httpMethod), res); throw new NotAcceptableException(Messages.MESSAGES.noMatchForAcceptHeader());
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; case NOT_ACCEPTABLE: webAppException = new NotAcceptableException(response); break; case UNSUPPORTED_MEDIA_TYPE:
final int status = response.getStatus(); switch (status) throw new NotAllowedException(response); case 406 : throw new NotAcceptableException(response); case 415 : throw new NotSupportedException(response);
@Test public void testServerWebApplicationExceptionXMLWithProxy() throws Exception { BookStore proxy = JAXRSClientFactory.create("http://localhost:" + PORT, BookStore.class); try { proxy.throwExceptionXML(); fail("Exception expected"); } catch (NotAcceptableException ex) { assertEquals(406, ex.getResponse().getStatus()); Book exBook = ex.getResponse().readEntity(Book.class); assertEquals("Exception", exBook.getName()); assertEquals(999L, exBook.getId()); } }
Response response = convertResponseToRs(feignResponse); int statusCode = response.getStatus(); Response.Status status = Response.Status.fromStatusCode(statusCode); Response.Status.Family statusFamily = response.getStatusInfo().getFamily(); return createExceptionForFamily(response, statusFamily); } else { return new NotAllowedException(response); case NOT_ACCEPTABLE: return new NotAcceptableException(response); case UNSUPPORTED_MEDIA_TYPE: return new NotSupportedException(response); return new ServiceUnavailableException(response); default: Response.Status.Family statusFamily = response.getStatusInfo().getFamily(); return createExceptionForFamily(response, statusFamily);
throw new NotAcceptableException("Size is " + numBlocks + " blocks, which is larger than the maximum of " + blockService.getMaxGetBlocks() + " blocks"); throw new NotAcceptableException("Size is " + numBlocks + " blocks, which is larger than the maximum of " + blockService.getMaxUpdateBlocks() + " blocks"); return Response.created(new URI(null, null, op.getLink(), null)).entity(op).build();
@Test public void testNotAcceptableLdprs() { when(mockTrellisRequest.getAcceptableMediaTypes()).thenReturn(singletonList(APPLICATION_JSON_TYPE)); final GetHandler handler = new GetHandler(mockTrellisRequest, mockBundler, false, true, true, null, baseUrl); final Response res = assertThrows(NotAcceptableException.class, () -> unwrapAsyncError(handler.getRepresentation(handler.standardHeaders(handler.initialize(mockResource)))), "No error thrown when given an unaccepable media type!").getResponse(); assertEquals(NOT_ACCEPTABLE, res.getStatusInfo(), "Incorrect response code!"); }
} else { throw new NotAcceptableException();
/** * Construct a new "request not acceptable" exception. * * @param response error response. * @param cause the underlying cause of the exception. * @throws IllegalArgumentException in case the status code set in the response * is not HTTP {@code 406}. */ public NotAcceptableException(Response response, Throwable cause) { super(validate(response, Response.Status.NOT_ACCEPTABLE), cause); }
ResponseBuilder resBuilder = Response.ok(allowHeaderValue.toString(), MediaType.TEXT_PLAIN_TYPE).header(HttpHeaderNames.ALLOW, allowHeaderValue.toString()); Response res = Response.status(HttpResponseCodes.SC_METHOD_NOT_ALLOWED).header(HttpHeaderNames.ALLOW, allowHeaderValue).build(); throw new NotAllowedException(Messages.MESSAGES.noResourceMethodFoundForHttpMethod(httpMethod), res); throw new NotAcceptableException(Messages.MESSAGES.noMatchForAcceptHeader());
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; case NOT_ACCEPTABLE: webAppException = new NotAcceptableException(response); break; case UNSUPPORTED_MEDIA_TYPE:
private T handleErrorStatus(Response response) { final int status = response.getStatus(); throw new NotAllowedException(response); case 406: throw new NotAcceptableException(response); case 415: throw new NotSupportedException(response);
@Test public void testServerWebApplicationExceptionXML() throws Exception { WebClient wc = WebClient.create("http://localhost:" + PORT + "/bookstore/webappexceptionXML"); wc.accept("application/xml"); try { wc.get(Book.class); fail("Exception expected"); } catch (NotAcceptableException ex) { assertEquals(406, ex.getResponse().getStatus()); Book exBook = ex.getResponse().readEntity(Book.class); assertEquals("Exception", exBook.getName()); assertEquals(999L, exBook.getId()); } }
Response response = convertResponseToRs(feignResponse); int statusCode = response.getStatus(); Response.Status status = Response.Status.fromStatusCode(statusCode); Response.Status.Family statusFamily = response.getStatusInfo().getFamily(); return createExceptionForFamily(response, statusFamily); } else { return new NotAllowedException(response); case NOT_ACCEPTABLE: return new NotAcceptableException(response); case UNSUPPORTED_MEDIA_TYPE: return new NotSupportedException(response); return new ServiceUnavailableException(response); default: Response.Status.Family statusFamily = response.getStatusInfo().getFamily(); return createExceptionForFamily(response, statusFamily);
} else { throw new NotAcceptableException();
/** * Construct a new "request not acceptable" exception. * * @param message the detail message (which is saved for later retrieval * by the {@link #getMessage()} method). * @param response error response. * @throws IllegalArgumentException in case the status code set in the response * is not HTTP {@code 406}. */ public NotAcceptableException(String message, Response response) { super(message, validate(response, Response.Status.NOT_ACCEPTABLE)); }
ResponseBuilder resBuilder = Response.ok(allowHeaderValue.toString(), MediaType.TEXT_PLAIN_TYPE).header(HttpHeaderNames.ALLOW, allowHeaderValue.toString()); Response res = Response.status(HttpResponseCodes.SC_METHOD_NOT_ALLOWED).header(HttpHeaderNames.ALLOW, allowHeaderValue).build(); throw new NotAllowedException(Messages.MESSAGES.noResourceMethodFoundForHttpMethod(httpMethod), res); throw new NotAcceptableException(Messages.MESSAGES.noMatchForAcceptHeader());
if (acceptors == null) { throw new NotAllowedException( Response.status(Status.METHOD_NOT_ALLOWED).allow(consumesProducesAcceptors.keySet()).build()); effectiveResponseType = MediaType.APPLICATION_OCTET_STREAM_TYPE; } else { throw new NotAcceptableException(); throw new NotAcceptableException();
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; case NOT_ACCEPTABLE: webAppException = new NotAcceptableException(response); break; case UNSUPPORTED_MEDIA_TYPE: