/** * Construct a new listener defining the generic type of the response to * receive. * * @param genericType the generic type of the response. */ public TypeListener(GenericType<T> genericType) { this.type = genericType.getRawClass(); this.genericType = genericType; }
/** * Construct a new listener defining the generic type of the response to * receive. * * @param genericType the generic type of the response. */ public TypeListener(GenericType<T> genericType) { this.type = genericType.getRawClass(); this.genericType = genericType; }
protected T get(ClientResponse response) { if (gt.getRawClass() == ClientResponse.class) return gt.getRawClass().cast(response); if (response.getStatus() < 300) return response.getEntity(gt); throw new UniformInterfaceException(response, request.getPropertyAsFeature(ClientConfig.PROPERTY_BUFFER_RESPONSE_ENTITY_ON_EXCEPTION, true)); } };
protected T get(ClientResponse response) { if (gt.getRawClass() == ClientResponse.class) return gt.getRawClass().cast(response); if (response.getStatus() < 300) return response.getEntity(gt); throw new UniformInterfaceException(response, request.getPropertyAsFeature(ClientConfig.PROPERTY_BUFFER_RESPONSE_ENTITY_ON_EXCEPTION, true)); } };
/** * Get the entity of the response. * <p> * If the entity is not an instance of Closeable then this response * is closed (you cannot read it more than once, any subsequent * call will produce {@link ClientHandlerException}). * * @param <T> the type of the response. * @param gt the generic type of the entity. * @return an instance of the type represented by the generic type. * * @throws ClientHandlerException if there is an error processing the response. * @throws UniformInterfaceException if the response status is 204 (No Content). */ public <T> T getEntity(GenericType<T> gt) throws ClientHandlerException, UniformInterfaceException { return getEntity(gt.getRawClass(), gt.getType()); }
/** * Get the entity of the response. * <p> * If the entity is not an instance of Closeable then this response * is closed (you cannot read it more than once, any subsequent * call will produce {@link ClientHandlerException}). * * @param <T> the type of the response. * @param gt the generic type of the entity. * @return an instance of the type represented by the generic type. * * @throws ClientHandlerException if there is an error processing the response. * @throws UniformInterfaceException if the response status is 204 (No Content). */ public <T> T getEntity(GenericType<T> gt) throws ClientHandlerException, UniformInterfaceException { return getEntity(gt.getRawClass(), gt.getType()); }
private <T> T handle(GenericType<T> gt, ClientRequest ro) throws UniformInterfaceException, ClientHandlerException { setProperties(ro); ClientResponse r = getHeadHandler().handle(ro); if (gt.getRawClass() == ClientResponse.class) return gt.getRawClass().cast(r); if (r.getStatus() < 300) return r.getEntity(gt); throw new UniformInterfaceException(r, ro.getPropertyAsFeature(ClientConfig.PROPERTY_BUFFER_RESPONSE_ENTITY_ON_EXCEPTION, true)); }
private <T> T handle(GenericType<T> gt, ClientRequest ro) throws UniformInterfaceException, ClientHandlerException { setProperties(ro); ClientResponse r = getHeadHandler().handle(ro); if (gt.getRawClass() == ClientResponse.class) return gt.getRawClass().cast(r); if (r.getStatus() < 300) return r.getEntity(gt); throw new UniformInterfaceException(r, ro.getPropertyAsFeature(ClientConfig.PROPERTY_BUFFER_RESPONSE_ENTITY_ON_EXCEPTION, true)); }
if (responseType.getRawClass().equals(ObjectNode.class)) { String stringEntity = clientResponse.getEntity(String.class); try {
if(api.getProduces().equals(MediaType.APPLICATION_OCTET_STREAM)) { return (T) clientResponse.getEntityInputStream(); } else if (responseType.getRawClass().equals(ObjectNode.class)) { String stringEntity = clientResponse.getEntity(String.class); try {
if (responseType.getRawClass() == JSONObject.class) { String stringEntity = clientResponse.getEntity(String.class); try {