public Response toResponse(TikaServerParseException e) { if (e.getMessage() != null && e.getMessage().equals(Response.Status.UNSUPPORTED_MEDIA_TYPE.toString())) { return buildResponse(e, 415); } Throwable cause = e.getCause(); if (cause == null) { return buildResponse(e, Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); } else { if (cause instanceof EncryptedDocumentException) { return buildResponse(cause, 422); } else if (cause instanceof TikaException) { //unsupported media type Throwable causeOfCause = cause.getCause(); if (causeOfCause instanceof WebApplicationException) { return ((WebApplicationException) causeOfCause).getResponse(); } return buildResponse(cause, 422); } else if (cause instanceof IllegalStateException) { return buildResponse(cause, 422); } else if (cause instanceof OldWordFileFormatException) { return buildResponse(cause, 422); } else if (cause instanceof WebApplicationException) { return ((WebApplicationException) e.getCause()).getResponse(); } else { return buildResponse(e, 500); } } }
@Override public Response toResponse(final U exception) { final Map<String, String> response = ImmutableMap.of("code", statusCode.toString(), "requestid", MoreObjects.firstNonNull(MDC.get("requestid"), ""), "message", MoreObjects.firstNonNull(exception.getMessage(), "(no message)")); return Response.status(statusCode) .entity(response) .type(MediaType.APPLICATION_JSON_TYPE) .build(); } }
private String getStatus(Response r) { Response.Status status = Response.Status.fromStatusCode(r.getStatus()); return new StringBuffer(Integer.toString(r.getStatus())) .append(" ").append(status.toString()) .append(" (").append(status.getFamily()).append(")") .toString(); }
/** * Get the reason phrase. * * @return the reason phrase. */ @Override public String getReasonPhrase() { return toString(); }
/** * Get the reason phrase. * * @return the reason phrase. */ @Override public String getReasonPhrase() { return toString(); }
/** * Get the reason phrase * @return the reason phrase */ public String getReasonPhrase() { return toString(); }
@Override public Response toResponse(final U exception) { final Map<String, String> response = ImmutableMap.of("code", statusCode.toString(), "trace", ObjectUtils.toString(MDC.get("track")), "message", ObjectUtils.toString(exception.getMessage(), "(no message)")); return Response.status(statusCode) .entity(response) .type(MediaType.APPLICATION_JSON_TYPE) .build(); } }
/** * Get the reason phrase. * * @return the reason phrase. */ @Override public String getReasonPhrase() { return toString(); }
/** * Get the reason phrase. * * @return the reason phrase. */ @Override public String getReasonPhrase() { return toString(); }
/** * Get the reason phrase. * * @return the reason phrase. */ @Override public String getReasonPhrase() { return toString(); }
public static UserException.Builder withStatus(UserException.Builder builder, Response.Status status) { return builder.addContext(RESPONSE_STATUS+":"+status.toString()); }
/** * Get the reason phrase. * * @return the reason phrase. */ @Override public String getReasonPhrase() { return toString(); }
/** * Get the reason phrase * @return the reason phrase */ public String getReasonPhrase() { return toString(); }
/** * Get the reason phrase. * * @return the reason phrase. */ @Override public String getReasonPhrase() { return toString(); }
/** * Get the reason phrase * @return the reason phrase */ public String getReasonPhrase() { return toString(); }
/** * Get the reason phrase * * @return the reason phrase */ public String getReasonPhrase() { return toString(); }
/** * Get the reason phrase. * * @return the reason phrase. */ @Override public String getReasonPhrase() { return toString(); }
/** * Get the reason phrase. * * @return the reason phrase. */ @Override public String getReasonPhrase() { return toString(); }
/** * Get the reason phrase. * * @return the reason phrase. */ @Override public String getReasonPhrase() { return toString(); }
/** * Convert the given HTTP response code to its corresponding status text or * response category. This is useful to avoid creating NPEs if this producer * is presented with an HTTP response code that the JAX-RS API doesn't know. * * @param responseCode the HTTP response code to be converted to status text * @return the status text for the code, or, if JAX-RS doesn't know the code, * the status category as text */ String statusTextFromResponseCode(int responseCode) { Response.Status status = Response.Status.fromStatusCode(responseCode); return status != null ? status.toString() : responseCategoryFromCode(responseCode); }