Package javax.ws.rs.client

Examples of javax.ws.rs.client.WebTarget.request()


        return RestResponse.getRestResponse(cr);
    }

    public static RestResponse options(String address, String responseType) {
        WebTarget target = getJerseyClient().target(address);
        Response cr = target
                .request(responseType)
                .cookie(new Cookie(REST_TOKEN_COOKIE, getRestToken()))
                .options(Response.class);
        return RestResponse.getRestResponse(cr);
    }
View Full Code Here


    public static void postRestRequestFromServlet(HttpServletRequest request, String endpoint, Map<String, Object> attrs, boolean quiet, boolean throwException) {
        String token = (String) request.getSession().getAttribute(AdminConsoleAuthModule.REST_TOKEN);
        WebTarget target = JERSEY_CLIENT.target(endpoint);
        MultivaluedMap formData = buildMultivalueMap(attrs);
        Response cr = target
                .request(RESPONSE_TYPE)
                .cookie(new Cookie(REST_TOKEN_COOKIE, token))
                .post(Entity.entity(formData, MediaType.APPLICATION_FORM_URLENCODED), Response.class);
        RestResponse rr = RestResponse.getRestResponse(cr);
        parseResponse(rr, null, endpoint, attrs, quiet, throwException);
View Full Code Here

        WebTarget target = client2.target(restURL);
        target.register(new HttpBasicAuthFilter(username, password));
        MultivaluedMap payLoad = new MultivaluedHashMap();
        payLoad.putSingle("remoteHostName", request.getRemoteHost());

        Response resp = target.request(RESPONSE_TYPE).post(Entity.entity(payLoad, MediaType.APPLICATION_FORM_URLENCODED), Response.class);
        RestResponse restResp = RestResponse.getRestResponse(resp);

        // Check to see if successful..
        if (restResp.isSuccess()) {
            // Username and Password sent in... validate them!
View Full Code Here

      WebTarget target = client.target(
          APICommons.POSTMON_HOST + APICommons.POSTMON_VER
              + tipoConsulta).path(cep);

      Invocation.Builder invocationBuilder = target
          .request(MediaType.APPLICATION_JSON);

      Response response = invocationBuilder.get();
      if (response.getStatus() == 200) {
        Gson gson = new Gson();
View Full Code Here

      if (entidadeRastreio.equals(Consultas.Entidade.ECT)) {
        WebTarget target = client.target(
            APICommons.POSTMON_HOST + APICommons.POSTMON_VER
                + tipoConsulta + entidadeRastreio).path(codigo);

        Invocation.Builder invocationBuilder = target
            .request(MediaType.APPLICATION_JSON);

        Response response = invocationBuilder.get();
        if (response.getStatus() == 200) {
          Gson gson = new Gson();
View Full Code Here

        try {
            // Jersey does not allow for null entity on put.
            Entity entity = Entity.entity("", MediaType.WILDCARD_TYPE);

            WebTarget webTarget = newWebTarget(databaseName);
            Response response = webTarget.request(MediaType.APPLICATION_JSON_TYPE)
                .put(entity);

            CouchStatusCode statusCode = CouchStatusCode.findByCode(response.getStatus());
            String eTag = getETag(response);
            byte[] content = response.readEntity(byte[].class);
View Full Code Here

    @Override
    public CouchHttpResponse head(HttpHeadRequest request) {
        try {
            WebTarget webTarget = newWebTarget(request);
            Response headResponse = webTarget.request().head();

            URI uri = webTarget.getUri();
            if (log.isDebugEnabled()) {
                log.debug("Head url: " + uri.toString());
            }
View Full Code Here

    public CouchHttpResponse get(HttpGetRequest request) {

        try {
            WebTarget webTarget = newWebTarget(request);
            MediaType acceptType = (request.getAcceptType() != null) ? MediaType.valueOf(request.getAcceptType().getMediaString()) : null;
            Response getResponse = webTarget.request(acceptType).get();

            URI uri = webTarget.getUri();
            if (log.isDebugEnabled()) {
                log.debug("Get url: " + uri.toString());
            }
View Full Code Here

            URI uri = webTarget.getUri();
            if (log.isDebugEnabled()) {
                log.debug("Put url: " + uri.toString());
            }

            Response putResponse = webTarget.request(MediaType.APPLICATION_JSON_TYPE)
                .header("Content-Type", contentType)
                .put(entity);

            return buildCouchResponse(request, uri, putResponse, request.getDocumentId());
        } catch (Throwable ex) {
View Full Code Here

            WebTarget webTarget = newWebTarget(request.getPath());
            for (HttpQueryParam queryParam : request.getQueryParameters()) {
                webTarget = webTarget.queryParam(queryParam.getName(), queryParam.getValue());
            }

            Response postResponse = webTarget.request(MediaType.APPLICATION_JSON_TYPE)
                .post(entity);

            URI uri = webTarget.getUri();
            if (log.isDebugEnabled()) {
                log.debug("POST url: " + uri.toString());
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.