Java Code Examples for com.sun.jersey.api.client.ClientRequest#setURI()

The following examples show how to use com.sun.jersey.api.client.ClientRequest#setURI() . 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: 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);
  }
}
 
Example 3
Source File: RequestEncoder.java    From jersey-hmac-auth with Apache License 2.0 5 votes vote down vote up
private void addApiKey(ClientRequest request) {
    URI uriWithApiKey = UriBuilder.fromUri(request.getURI())
            .queryParam(this.requestConfiguration.getApiKeyQueryParamName(), apiKey)
            .build();

    request.setURI(uriWithApiKey);
}