Package com.sun.jersey.api.client

Examples of com.sun.jersey.api.client.WebResource.header()


        WebResource resource = context.service.path("api/entities/update/"
                + entity.getEntityType().name().toLowerCase() + "/" + entity.getName());
        if (endTime != null) {
            resource = resource.queryParam("effective", SchemaHelper.formatDateUTC(endTime));
        }
        ClientResponse response = resource
                .header("Cookie", context.getAuthenticationToken())
                .accept(MediaType.TEXT_XML)
                .post(ClientResponse.class, context.getServletInputStream(tmpFile.getAbsolutePath()));
        context.assertSuccessful(response);
    }
View Full Code Here


    WebResource resource = client.resource(url);

    // Provide filter that will rebuild exception that is sent from server
    resource.addFilter(serverExceptionFilter);

    return resource
      // Provide name of user executing request.
      .header(SqoopProtocolConstants.HEADER_SQOOP_USERNAME, System.getProperty("user.name"))
      // Sqoop is using JSON for data transfers
      .accept(MediaType.APPLICATION_JSON_TYPE)
      // Transfer client locale to return client specific data
View Full Code Here

            contentType = MediaType.APPLICATION_JSON;
        }
        if (payload instanceof Map) {
            payload = buildMultivalueMap((Map<String, Object>)payload);
        }
        ClientResponse cr = webResource.header("Content-Type", contentType)
                .cookie(new Cookie(REST_TOKEN_COOKIE, getRestToken()))
//                .header("Content-type", MediaType.APPLICATION_FORM_URLENCODED)
                .accept(RESPONSE_TYPE).post(ClientResponse.class, payload);
        RestResponse rr = RestResponse.getRestResponse(cr);
        return rr;
View Full Code Here

    assertThat(response.getStatus(), is(201));
    assertThat(response.getLocation(), is(r.getURI()));
   
    assertThat(r.get(String.class), is("[Widget name:dingo, description:awesome]"));
   
    assertThat(r.header("Accept-Encoding", "gzip").get(String.class), is(not("[Widget name:dingo, description:awesome]")));
   
    client.addFilter(new GZIPContentEncodingFilter());
   
    assertThat(r.header("Accept-Encoding", "gzip").get(String.class), is("[Widget name:dingo, description:awesome]"));
  }
View Full Code Here

   
    assertThat(r.header("Accept-Encoding", "gzip").get(String.class), is(not("[Widget name:dingo, description:awesome]")));
   
    client.addFilter(new GZIPContentEncodingFilter());
   
    assertThat(r.header("Accept-Encoding", "gzip").get(String.class), is("[Widget name:dingo, description:awesome]"));
  }
 
  @AfterClass
  public static void teardownThread() throws Exception {
    executor.shutdown();
View Full Code Here

        logger.info("GET " + eventUrl);

        WebResource wr = restClient.client.resource(UriBuilder.fromPath(eventUrl).build());
        wr.addFilter(new BearerTokenFilter(accessToken));
        try{
            wr.header("Authorization", createBearerAuthorizationHeader(accessToken));
            ClientResponse cr = wr.get(ClientResponse.class);
            if(cr.getStatus() >= 300){
                String error = String.format("EvenApi.readEvent() returned HTTP status: %s, message: %s",cr.getStatus(), cr.toString());
                logger.error(error);
                throw new EventApiException(error);
View Full Code Here

    public  List<Event> query(String evenQueryUrl) throws EventApiException {
        logger.info("Query: "+evenQueryUrl);
        WebResource wr = restClient.client.resource(evenQueryUrl);
        wr.addFilter(new BearerTokenFilter(accessToken));
        try{
            wr.header("Authorization", createBearerAuthorizationHeader(accessToken));
            ClientResponse cr = wr.get(ClientResponse.class);
            if(cr.getStatus() >= 300){
                String error = String.format("EvenApi.query() returned HTTP status: %s, message: %s",cr.getStatus(), cr.toString());
                logger.error(error);
                throw new EventApiException(error);
View Full Code Here

        WebResource wr = restClient.client.resource(UriBuilder.fromPath(eventUrl).build());
        wr.addFilter(new BearerTokenFilter(accessToken));

        try {
            wr.header("Authorization", createBearerAuthorizationHeader(accessToken));
        } catch (UnsupportedEncodingException e) {
            throw new EventApiException(e.getMessage(), e);
        }
        ClientResponse cr = wr.delete(ClientResponse.class);
        if(cr.getStatus() >= 300){
View Full Code Here

        logger.info("GET " + eventUrl);

        WebResource wr = restClient.client.resource(UriBuilder.fromPath(eventUrl).build());
        wr.addFilter(new BearerTokenFilter(accessToken));
        try{
            wr.header("Authorization", createBearerAuthorizationHeader(accessToken));
            ClientResponse cr = wr.get(ClientResponse.class);
            return restClient.objectMapper.readValue(cr.getEntityInputStream(), Event.class);
        }catch(IOException e){
            throw new EventApiException(e.getMessage(), e);
        }
View Full Code Here

    public  List<Event> query(String evenQueryUrl) throws EventApiException {
        logger.info("Query: "+evenQueryUrl);
        WebResource wr = restClient.client.resource(evenQueryUrl);
        wr.addFilter(new BearerTokenFilter(accessToken));
        try{
            wr.header("Authorization", createBearerAuthorizationHeader(accessToken));
            ClientResponse cr = wr.get(ClientResponse.class);
            return restClient.objectMapper.readValue(cr.getEntityInputStream(), new TypeReference<List<Event>>() {});
        }catch(IOException e){
            throw new EventApiException(e.getMessage(), e);
        }
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.