Package javax.ws.rs.client

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


    }

    public static RestResponse post(String address, Map<String, Object> payload) {
        WebTarget target = getJerseyClient().target(address);
        MultivaluedMap formData = buildMultivalueMap(payload);
        Response cr = target
                //                .header("Content-type", MediaType.APPLICATION_FORM_URLENCODED)
                .request(RESPONSE_TYPE)
                .cookie(new Cookie(REST_TOKEN_COOKIE, getRestToken()))
                .post(Entity.entity(formData, MediaType.APPLICATION_FORM_URLENCODED), Response.class);
        RestResponse rr = RestResponse.getRestResponse(cr);
View Full Code Here


    }

    public static RestResponse put(String address, Map<String, Object> payload) {
        WebTarget target = getJerseyClient().target(address);
        MultivaluedMap formData = buildMultivalueMap(payload);
        Response cr = target
                //                .header("Content-type", MediaType.APPLICATION_FORM_URLENCODED)
                .request(RESPONSE_TYPE)
                .cookie(new Cookie(REST_TOKEN_COOKIE, getRestToken()))
                .put(Entity.entity(formData, MediaType.APPLICATION_FORM_URLENCODED), Response.class);
        RestResponse rr = RestResponse.getRestResponse(cr);
View Full Code Here

        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

        this.client = client;
    }

    public<R> R invoke(final String targetUrl, final String method, Object inputObject, Class<R> resultClass) throws WebApplicationException {
        final WebTarget target = client.target(targetUrl);
        final Invocation.Builder builder = target.request()
                .header("Authorization", new StringBuilder("Basic ")
                        .append(Base64.encodeBase64String(new StringBuilder(environmentKey)
                                        .append(":")
                                        .append(accessSecret).toString().getBytes())).toString());
        final Response response;
View Full Code Here

    }

    public static Response getRequestFromServlet(HttpServletRequest request, String endpoint, Map<String, Object> attrs) {
        String token = (String) request.getSession().getAttribute(AdminConsoleAuthModule.REST_TOKEN);
        WebTarget target = targetWithQueryParams(JERSEY_CLIENT.target(endpoint), attrs);
        Response cr = target
                .request().cookie(new Cookie(REST_TOKEN_COOKIE, token))
                .get(Response.class);

        return cr;
    }
View Full Code Here

    }

    public static void getRestRequestFromServlet(HttpServletRequest request, String endpoint, Map<String, Object> attrs, boolean quiet, boolean throwException) {
        String token = (String) request.getSession().getAttribute(AdminConsoleAuthModule.REST_TOKEN);
        WebTarget target = targetWithQueryParams(JERSEY_CLIENT.target(endpoint), attrs);
        Response cr = target
                .request(RESPONSE_TYPE)
                .cookie(new Cookie(REST_TOKEN_COOKIE, token))
                .get(Response.class);
        RestResponse rr = RestResponse.getRestResponse(cr);
        parseResponse(rr, null, endpoint, attrs, quiet, throwException);
View Full Code Here

    public static RestResponse get(String address, Map<String, Object> payload) {
        if (address.startsWith("/")) {
            address = FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("REST_URL") + address;
        }
        WebTarget target = targetWithQueryParams(getJerseyClient().target(address), payload);
        Response resp = target
                .request(RESPONSE_TYPE)
                .cookie(new Cookie(REST_TOKEN_COOKIE, getRestToken()))
                .get(Response.class);
        return RestResponse.getRestResponse(resp);
    }
View Full Code Here

            contentType = MediaType.APPLICATION_JSON;
        }
        if (payload instanceof Map) {
            payload = buildMultivalueMap((Map<String, Object>) payload);
        }
        Response cr = target.request(RESPONSE_TYPE).header("Content-Type", contentType)
                .cookie(new Cookie(REST_TOKEN_COOKIE, getRestToken()))
                //                .header("Content-type", MediaType.APPLICATION_FORM_URLENCODED)
                .post(Entity.entity(payload, contentType), Response.class);
        RestResponse rr = RestResponse.getRestResponse(cr);
        return rr;
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.