Package javax.ws.rs.core.Response

Examples of javax.ws.rs.core.Response.ResponseBuilder.entity()


                // nothing we can do really
            }
        } else {
            try {
                InputStream stream = mStream == null ? conn.getInputStream() : mStream;
                currentResponseBuilder.entity(stream);
            } catch (Exception ex) {
                // it may that the successful response has no response body
            }
        }
        ResponseBuilder rb = currentResponseBuilder.clone();
View Full Code Here


                    }
                }
            }
        }
        InputStream mStream = responseMessage.getContent(InputStream.class);
        currentResponseBuilder.entity(mStream);
       
        return currentResponseBuilder;
    }
   
    protected <T> void writeBody(T o, Message outMessage, Class<?> cls, Type type, Annotation[] anns,
View Full Code Here

            ResponseBuilder rb = setResponseBuilder(conn, outMessage.getExchange()).clone();
            Response currentResponse = rb.clone().build();
           
            Object entity = readBody(currentResponse, conn, outMessage, responseClass, genericType,
                                     new Annotation[]{});
            rb.entity(entity);
           
            return rb.build();
        } catch (Throwable ex) {
            throw new WebApplicationException(ex);
        }
View Full Code Here

   
    private static WebApplicationException newErrorException(Status statusCode, String message, String mimeType) {
        ResponseBuilder responseBuilder = Response.status(statusCode);
        if (mimeType != null)
            responseBuilder.type(mimeType);
        responseBuilder.entity(message);
        Response response = responseBuilder.build();
        WebApplicationException webAPPEx = new WebApplicationException(response);
        return webAPPEx;
    }
View Full Code Here

     * @param obj
     * @return
     */
    public static Response buildOkResponse(Object obj, String mimeType) {
        ResponseBuilder responseBuilder = Response.status(Status.OK);
        responseBuilder.entity(obj);
        if (mimeType != null)
            responseBuilder.type(mimeType);
        return responseBuilder.build();
    }
   
View Full Code Here

     * @param msg
     * @return
     */
    public static Response buildResponse(Status statusCode, Object msg) {
        ResponseBuilder responseBuilder = Response.status(statusCode);
        responseBuilder.entity(msg);
        if (String.class.isAssignableFrom(msg.getClass())) {
            responseBuilder.type(MediaType.TEXT_PLAIN);
        }
        return responseBuilder.build();
    }
View Full Code Here

            mStream = inMessage.getContent(InputStream.class);
        }
        if (status >= 400) {
            try {
                InputStream errorStream = mStream == null ? conn.getErrorStream() : mStream;
                currentResponseBuilder.entity(errorStream);
            } catch (Exception ex) {
                // nothing we can do really
            }
        } else {
            try {
View Full Code Here

                // nothing we can do really
            }
        } else {
            try {
                InputStream stream = mStream == null ? conn.getInputStream() : mStream;
                currentResponseBuilder.entity(stream);
            } catch (Exception ex) {
                // it may that the successful response has no response body
            }
        }
        ResponseBuilder rb = currentResponseBuilder.clone();
View Full Code Here

                int status = currentResponse.getStatus();
                if (status >= 400) {
                    entity = currentResponse.getEntity();
                }
            }
            rb.entity(entity instanceof Response
                      ? ((Response)entity).getEntity() : entity);
           
            return rb.build();
        } catch (Throwable ex) {
            throw (ex instanceof ClientWebApplicationException) ? (ClientWebApplicationException)ex
View Full Code Here

                    entity = currentResponse.getEntity();
                }
            }
            rb = Response.fromResponse(currentResponse);
           
            rb.entity(entity instanceof Response
                      ? ((Response)entity).getEntity() : entity);
           
            Response r = rb.build();
            ((ResponseImpl)r).setMessage(outMessage);
           
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.