Examples of entity()


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

                text = e.getMessage();
            }
            if (asHeader) {
                builder.header("oauth_problem", text);
            } else {
                builder.entity(e.getMessage());   
            }
        }
        return builder.build();
    }
View Full Code Here

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

    if (error.code == null) {
      error.code = e.getClass().getSimpleName();
    }

    ResponseBuilder response = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
    response.entity(error);
    return response.build();

    // VariantListBuilder variantListBuilder = VariantListBuilder.newInstance();
    // variantListBuilder.mediaTypes(MediaType.APPLICATION_JSON_TYPE, MediaType.APPLICATION_XML_TYPE);
    // List<Variant> variants = variantListBuilder.build();
View Full Code Here

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

            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

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

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

            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

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

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

        // body and content-type
        final JsonRepresentation bodyRepr = ex.getBody();
        final Throwable cause = ex.getCause();
        if (bodyRepr != null) {
            final String body = bodyRepr.toString();
            builder.entity(body);
            builder.type(MediaType.APPLICATION_JSON); // generic; the spec doesn't define what the media type should be
        } else if(cause == null) {
            builder.type(MediaType.APPLICATION_JSON); // generic; the spec doesn't define what the media type should be
        } else {
            String body;
View Full Code Here

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

                body = JsonMapper.instance().write(ExceptionPojo.create(cause));
            } catch (final Exception e) {
                // fallback
                body = "{ \"exception\": \"" + ExceptionUtils.getFullStackTrace(cause) + "\" }";
            }
            builder.entity(body);
            builder.type(RestfulMediaType.APPLICATION_JSON_ERROR);
        }

        final String message = ex.getMessage();
        if (message != null) {
View Full Code Here

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

        String ct = (String)responseMessage.get(Message.CONTENT_TYPE);
        if (ct != null) {
            currentResponseBuilder.type(ct);
        }
        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

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

                    entity = currentResponse.getEntity();
                }
            }
            rb = JAXRSUtils.fromResponse(currentResponse);
           
            rb.entity(entity instanceof Response
                      ? ((Response)entity).getEntity() : entity);
           
            Response r = rb.build();
            getState().setResponse(r);
            ((ResponseImpl)r).setOutMessage(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.