예제 #1
0
 private com.sun.jersey.api.client.WebResource makeResource(String path) {
   com.sun.jersey.api.client.WebResource resource = resource();
   UriBuilder b = resource.getUriBuilder();
   if (path.startsWith("/")) {
     b.replacePath(path);
   } else {
     b.path(path);
   }
   URI uri = b.build();
   return resource.uri(uri);
 }
예제 #2
0
  public <T> T get(
      URI uri, MultivaluedMap<String, String> queryParams, Class<T> clazz, String mediaType) {
    if (uri == null)
      throw new IllegalArgumentException(
          "The URI can't be null. This usually means that a previous "
              + "call to Mgmt REST api failed.");

    com.sun.jersey.api.client.WebResource resource = resource();
    if (queryParams != null) {
      resource = resource.queryParams(queryParams);
    }
    ClientResponse response =
        resource.uri(uri).type(mediaType).accept(mediaType).get(ClientResponse.class);
    if (response.getStatus() >= 300) {
      handleHttpError(response);
    }
    return response.getEntity(clazz);
  }