Java Code Examples for com.sun.jersey.api.client.ClientResponse#setEntityInputStream()

The following examples show how to use com.sun.jersey.api.client.ClientResponse#setEntityInputStream() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WebServicesVersionConversion.java    From Bats with Apache License 2.0 6 votes vote down vote up
@Override
public ClientResponse handle(ClientRequest cr) throws ClientHandlerException
{
  URIBuilder uriBuilder = new URIBuilder(cr.getURI());
  String path = uriBuilder.getPath();
  uriBuilder.setPath(converter.convertCommandPath(path));
  try {
    cr.setURI(uriBuilder.build());
    ClientResponse response = getNext().handle(cr);
    String newEntity = converter.convertResponse(path, response.getEntity(String.class));
    response.setEntityInputStream(new ByteArrayInputStream(newEntity.getBytes()));
    return response;
  } catch (Exception ex) {
    throw new ClientHandlerException(ex);
  }
}
 
Example 2
Source File: RawLoggingFilter.java    From phoebus with Eclipse Public License 1.0 6 votes vote down vote up
private void logResponse(long id, ClientResponse response) {
	StringBuilder b = new StringBuilder();

	printResponseLine(b, id, response);
	printResponseHeaders(b, id, response.getHeaders());

	ByteArrayOutputStream out = new ByteArrayOutputStream();
	InputStream in = response.getEntityInputStream();
	try {
		ReaderWriter.writeTo(in, out);

		byte[] requestEntity = out.toByteArray();
		printEntity(b, requestEntity);
		response.setEntityInputStream(new ByteArrayInputStream(
				requestEntity));
	} catch (IOException ex) {
		throw new ClientHandlerException(ex);
	}
	log(b);
}
 
Example 3
Source File: RawLoggingFilter.java    From phoebus with Eclipse Public License 1.0 6 votes vote down vote up
private void logResponse(long id, ClientResponse response) {
	StringBuilder b = new StringBuilder();

	printResponseLine(b, id, response);
	printResponseHeaders(b, id, response.getHeaders());

	ByteArrayOutputStream out = new ByteArrayOutputStream();
	InputStream in = response.getEntityInputStream();
	try {
		ReaderWriter.writeTo(in, out);

		byte[] requestEntity = out.toByteArray();
		printEntity(b, requestEntity);
		response.setEntityInputStream(new ByteArrayInputStream(
				requestEntity));
	} catch (IOException ex) {
		throw new ClientHandlerException(ex);
	}
	log(b);
}
 
Example 4
Source File: RawLoggingFilter.java    From phoebus with Eclipse Public License 1.0 6 votes vote down vote up
private void logResponse(long id, ClientResponse response) {
	StringBuilder b = new StringBuilder();

	printResponseLine(b, id, response);
	printResponseHeaders(b, id, response.getHeaders());

	ByteArrayOutputStream out = new ByteArrayOutputStream();
	InputStream in = response.getEntityInputStream();
	try {
		ReaderWriter.writeTo(in, out);

		byte[] requestEntity = out.toByteArray();
		printEntity(b, requestEntity);
		response.setEntityInputStream(new ByteArrayInputStream(
				requestEntity));
	} catch (IOException ex) {
		throw new ClientHandlerException(ex);
	}
	log(b);
}
 
Example 5
Source File: RequestLogger.java    From qaf with MIT License 6 votes vote down vote up
private StringBuilder logResponse(long id, ClientResponse response) {
	StringBuilder b = new StringBuilder();

	printResponseLine(b, id, response);
	printResponseHeaders(b, id, response.getHeaders());

	ByteArrayOutputStream out = new ByteArrayOutputStream();
	InputStream in = response.getEntityInputStream();
	try {
		ReaderWriter.writeTo(in, out);

		byte[] requestEntity = out.toByteArray();
		printEntity(b, requestEntity);
		response.setEntityInputStream(new ByteArrayInputStream(requestEntity));
	} catch (IOException ex) {
		throw new ClientHandlerException(ex);
	}
	log(b.toString());
	return b;
}
 
Example 6
Source File: WebServicesVersionConversion.java    From attic-apex-core with Apache License 2.0 6 votes vote down vote up
@Override
public ClientResponse handle(ClientRequest cr) throws ClientHandlerException
{
  URIBuilder uriBuilder = new URIBuilder(cr.getURI());
  String path = uriBuilder.getPath();
  uriBuilder.setPath(converter.convertCommandPath(path));
  try {
    cr.setURI(uriBuilder.build());
    ClientResponse response = getNext().handle(cr);
    String newEntity = converter.convertResponse(path, response.getEntity(String.class));
    response.setEntityInputStream(new ByteArrayInputStream(newEntity.getBytes()));
    return response;
  } catch (Exception ex) {
    throw new ClientHandlerException(ex);
  }
}