Examples of entity()


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

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

            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

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

   
    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

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

     * @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

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

     * @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

Examples of org.apache.olingo.odata2.api.processor.ODataResponse.ODataResponseBuilder.entity()

        stream = new ByteArrayInputStream(value.getBytes(DEFAULT_CHARSET));
      } catch (UnsupportedEncodingException e) {
        throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
            .getSimpleName()), e);
      }
      builder.entity(stream);
    }

    return builder.build();
  }
View Full Code Here

Examples of org.apache.olingo.odata2.api.processor.ODataResponse.ODataResponseBuilder.entity()

  public ODataResponse writeBinary(final String mimeType, final byte[] data) throws EntityProviderException {
    ODataResponseBuilder builder = ODataResponse.newBuilder();
    if (data != null) {
      ByteArrayInputStream bais = new ByteArrayInputStream(data);
      builder.contentHeader(mimeType);
      builder.entity(bais);
    } else {
      builder.status(HttpStatusCodes.NO_CONTENT);
    }
    return builder.build();
  }
View Full Code Here

Examples of org.apache.olingo.odata2.api.processor.ODataResponse.ODataResponseBuilder.entity()

          .getSimpleName()), e);
    } catch (FactoryConfigurationError e) {
      throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
          .getSimpleName()), e);
    }
    builder.entity(csb.getInputStream());
    builder.header(ODataHttpHeaders.DATASERVICEVERSION, dataServiceVersion);
    return builder.build();
  }

  /**
 
View Full Code Here

Examples of org.glassfish.jersey.server.RequestContextBuilder.entity()

    private void _test(ApplicationHandler app, String expected, String method, Object entity, String mediaType, String... accept)
            throws ExecutionException, InterruptedException {
        RequestContextBuilder requestContextBuilder = RequestContextBuilder.from("/", method);
        if (entity != null) {
            requestContextBuilder.entity(entity).type(mediaType);
        }
        ContainerRequest requestContext = requestContextBuilder.accept(accept).build();
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        app.apply(requestContext, baos);
        assertEquals(expected, baos.toString());
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.