@GET @Produces({MediaType.APPLICATION_JSON}) @Path("/{nodeType}") public Response getClusterServers(@PathParam("nodeType") NodeType nodeType, @QueryParam("full") boolean full) { if (nodeType == null) { return Response.serverError() .status(Response.Status.BAD_REQUEST) .entity("Invalid nodeType of null. Valid node types are " + Arrays.toString(NodeType.values())) .build(); } else { return Response.status(Response.Status.OK).entity(getNodes(nodeType, full)).build(); } }
@Override public Response toResponse(final Throwable cause) { return Response.ok(ExceptionUtil.transform(cause), MediaType.TEXT_PLAIN).status(Response.Status.INTERNAL_SERVER_ERROR).build(); } }
@Override public Response toResponse(DRPCExecutionException ex) { ResponseBuilder builder = Response.status(500); switch (ex.get_type()) { case FAILED_REQUEST: builder.status(400); break; case SERVER_SHUTDOWN: builder.status(503); //Not available break; case SERVER_TIMEOUT: builder.status(504); //proxy timeout break; case INTERNAL_ERROR: //fall throw on purpose default: //Empty (Still 500) break; } Map<String, String> body = new HashMap<>(); //TODO I would love to standardize this... body.put("error", ex.is_set_type() ? ex.get_type().toString() : "Internal Error"); body.put("errorMessage", ex.get_msg()); return builder.entity(JSONValue.toJSONString(body)).type("application/json").build(); }
@PUT @Path("{taskId}/delegate") public Response delegateTask(@PathParam("taskId") String taskId, @QueryParam("delegatedActors") List<String> delegatedActors, @QueryParam("comment") String comment) { Framework.getService(DocumentRoutingService.class).delegateTask(getContext().getCoreSession(), taskId, delegatedActors, comment); return Response.ok().status(Status.OK).build(); }
/** * Create a new ResponseBuilder with the supplied status. * * @param status the response status. * @return a new response builder. * @throws IllegalArgumentException if status is {@code null}. */ public static ResponseBuilder status(StatusType status) { return ResponseBuilder.newInstance().status(status); }
/** * Set the status on the ResponseBuilder. * * @param status the response status. * @return the updated response builder. * @throws IllegalArgumentException if status is {@code null}. */ public ResponseBuilder status(Status status) { return status((StatusType) status); }
/** * Create a new ResponseBuilder with the supplied status. * * @param status the response status. * @return a new response builder. * @throws IllegalArgumentException if status is less than {@code 100} or greater * than {@code 599}. */ public static ResponseBuilder status(int status) { return ResponseBuilder.newInstance().status(status); }
public ResponseBuilder status(StatusType status) { if (status == null) { throw new IllegalArgumentException(); } return status(status.getStatusCode()); }
private Response executeProvider(Throwable exception, ExceptionMapper<Throwable> provider) { try { return provider.toResponse(exception); } catch (Throwable e) { logger.error(Messages.getMessage("exceptionOccurredDuringExceptionMapper", provider.getClass().getName()), e); //$NON-NLS-1$ return RUNTIME_DELEGATE.createResponseBuilder().status(500).build(); } }
/** * Create a new ResponseBuilder with the supplied status. * * @param status the response status. * @return a new response builder. * @throws IllegalArgumentException if status is less than {@code 100} or greater * than {@code 599}. */ public static ResponseBuilder status(int status) { return ResponseBuilder.newInstance().status(status); }
/** * Create a new ResponseBuilder with the supplied status. * * @param status the response status. * @return a new response builder. * @throws IllegalArgumentException if status is {@code null}. */ public static ResponseBuilder status(StatusType status) { return ResponseBuilder.newInstance().status(status); }
/** * Create a new ResponseBuilder with the supplied status. * * @param status the response status. * @return a new response builder. * @throws IllegalArgumentException if status is {@code null}. */ public static ResponseBuilder status(StatusType status) { return ResponseBuilder.newInstance().status(status); }
excludeDatanodes.getValue(), offset, length, bufferSize); if(!noredirectParam.getValue()) { return rb.status(Status.TEMPORARY_REDIRECT).location(uri) .type(MediaType.APPLICATION_OCTET_STREAM).build(); } else { final String js = JsonUtil.toJsonString("Location", uri); return rb.status(Status.OK).entity(js).type(MediaType.APPLICATION_JSON) .build();
if (validatedResponse != null) throw new NoLogWebApplicationException(validatedResponse.status(Response.Status.NOT_MODIFIED).cacheControl(cc).header(HttpHeaders.ETAG, etag).build());
/** * FIXME Comment this * * @param mediaType media type * @return image reader */ public static ImageReader getImageReaderByMediaType(MediaType mediaType) { Iterator<ImageReader> readers = ImageIO.getImageReadersByMIMEType(mediaType.toString()); ImageReader reader = null; while (readers.hasNext()) { reader = (ImageReader) readers.next(); } if (reader == null) { String[] availableTypes = ImageIO.getReaderMIMETypes(); LogMessages.LOGGER.readerNotFound(mediaType, availableTypes); List<Variant> variants = ProviderHelper.getAvailableVariants(availableTypes); Response response = Response.notAcceptable(variants).status(Status.NOT_ACCEPTABLE).build(); throw new WebApplicationException(response); } return reader; }
public void invoke() throws IllegalAccessException, InvocationTargetException { Object o = method.invoke(resource, params); if (o != null) { Response r = new ResponseBuilderImpl().entity(o).status(200).build(); context.getResponse().setResponse(r); } } });
/** * Returns a response builder with the specified status code, with a JSON serialized form of the causing exception, * and an appropriate HTTP header (Content-Type: application/json). */ public static Response.ResponseBuilder encodeExceptionResponse(Exception exception, int statusCode) { return Response.serverError() .entity(createSerializableError(exception)) .status(statusCode) .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON); }
public static ResponseBuilder status(int status) { ResponseBuilder b = ResponseBuilder.newInstance(); b.status(status); return b; }
@Override public void _dispatch(Object resource, HttpContext context) throws IllegalAccessException, InvocationTargetException { final Object[] params = getParams(context); final Object o = invoker.invoke(method, resource, params); if (o != null) { Response r = new ResponseBuilderImpl(). entityWithType(o, t).status(200).build(); context.getResponse().setResponse(r); } } }
public static ResponseBuilder status(Status status) { ResponseBuilder b = ResponseBuilder.newInstance(); b.status(status); return b; }