Package javax.ws.rs.core.Response

Examples of javax.ws.rs.core.Response.ResponseBuilder.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;
            try {
View Full Code Here


        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;
            try {
                body = JsonMapper.instance().write(ExceptionPojo.create(cause));
            } catch (final Exception e) {
View Full Code Here

            } 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) {
            builder.header(RestfulResponse.Header.WARNING.getName(), RestfulResponse.Header.WARNING.render(message));
View Full Code Here

                }
            }
        }
        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;
View Full Code Here

            if (!allowedMethods.contains("HEAD") && allowedMethods.contains("GET")) {
                rb.header("Allow", "HEAD");
            }
        }
        if (msg != null && MessageUtils.isTrue(msg.getContextualProperty(REPORT_FAULT_MESSAGE_PROPERTY))) {
            rb.type(MediaType.TEXT_PLAIN_TYPE).entity(responseMessage);
        }
        return rb.build();
    }
   
    private static boolean matchHttpMethod(String expectedMethod, String httpMethod) {
View Full Code Here

            if (!allowedMethods.contains("HEAD") && allowedMethods.contains("GET")) {
                rb.header("Allow", "HEAD");
            }
        }
        if (msg != null && MessageUtils.isTrue(msg.getContextualProperty(REPORT_FAULT_MESSAGE_PROPERTY))) {
            rb.type(MediaType.TEXT_PLAIN_TYPE).entity(responseMessage);
        }
        return rb.build();
    }
   
    private static boolean matchHttpMethod(String expectedMethod, String httpMethod) {
View Full Code Here

    }
   
    protected void reportInvalidClient(OAuthError error) {
        ResponseBuilder rb = JAXRSUtils.toResponseBuilder(401);
        throw ExceptionUtils.toNotAuthorizedException(null,
            rb.type(MediaType.APPLICATION_JSON_TYPE).entity(error).build());
    }
   
    public void setCanSupportPublicClients(boolean support) {
        this.canSupportPublicClients = support;
    }
View Full Code Here

    }
   
    protected void reportInvalidRequestError(OAuthError entity, MediaType mt) {
        ResponseBuilder rb = JAXRSUtils.toResponseBuilder(400);
        if (mt != null) {
            rb.type(mt);
        }
        throw ExceptionUtils.toBadRequestException(null, rb.entity(entity).build());
    }

    /**
 
View Full Code Here

            }
            String msg = "No Book with id " + id + " is available";
            ResponseBuilder builder = Response.status(returnCode).header("BOOK-HEADER", msg);
           
            if (returnCode == 404) {
                builder.type("text/plain").entity(msg);
            }
            throw new WebApplicationException(builder.build());
        }
    
        if (!ignoreJaxrsClient) {
View Full Code Here

        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;
            try {
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.