Package javax.ws.rs.core.Response

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


                    }
                }
            }
        }
        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(outMessage, outMessage.getExchange());
            Response currentResponse = rb.clone().build();
           
            Object entity = readBody(currentResponse, outMessage, responseClass, genericType,
                                     new Annotation[]{});
            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

                    }
                }
            }
        }
        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());
            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

            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

        final PathSegment lastPathSegm = pathSegents.get(0);
        final MultivaluedMap<String, String> mp = lastPathSegm
                .getMatrixParameters();
        if (mp.isEmpty()) {
            final ResponseBuilder rb = Response.status(Status.NOT_FOUND);
            rb.entity("matrix parameters are empty");
            throw new WebApplicationException(rb.build());
        }
        return firstname + " " + lastname;
    }
}
View Full Code Here

        if (resp != null) {
            return resp.build();
        }
        // Build new Response
        final ResponseBuilder responseBuilder = Response.status(200);
        responseBuilder.entity("This is the Entity from " + modificDate);
        responseBuilder.lastModified(modificDate);
        responseBuilder.tag(entityTag);
        return responseBuilder.build();
    }
View Full Code Here

    @Produces("text/plain")
    public String isSecure(@Context UriInfo uriInfo) {
        if (!this.securityContext.isSecure()) {
            final ResponseBuilder rb = Response
                    .status(Status.MOVED_PERMANENTLY);
            rb.entity("You must use a secure connection");
            rb.location(uriInfo.getRequestUriBuilder().scheme("https").build());
            throw new WebApplicationException(rb.build());
        }
        return "wonderful! It's a secure request.";
    }
View Full Code Here

            entity = "<html><head><title>invalid argument</title></head>"
                    + "<boy><h1>Sorry</h1><p>" + entity + "</p></body></html>";
        } else {
            rb.type(MediaType.TEXT_PLAIN_TYPE);
        }
        return rb.entity(entity).build();
    }
}
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.