Examples of RestResponse


Examples of com.denimgroup.threadfix.remote.response.RestResponse

            return true;
        }
    }

    private static boolean isValid(String url, String apiKey) {
        RestResponse response = RestUtils.test(url, apiKey);
        return !response.success &&
                response.responseCode == 200 &&
                response.message.startsWith(Constants.APP_LOOKUP_FAILURE_STRING);
    }
View Full Code Here

Examples of com.jcabi.http.response.RestResponse

    }

    @Override
    @NotNull(message = "iterable is never NULL")
    public Iterable<String> iterate() throws IOException {
        final RestResponse response = this.request.fetch()
            .as(RestResponse.class)
            .assertStatus(HttpURLConnection.HTTP_OK);
        final List<JsonString> list = response.as(JsonResponse.class)
            .json().readArray().getValuesAs(JsonString.class);
        final List<String> templates = new ArrayList<String>(list.size());
        for (final JsonString value : list) {
            templates.add(value.getString());
        }
View Full Code Here

Examples of com.jcabi.http.response.RestResponse

         * Fetch the next portion, if available.
         * @throws IOException If there is any I/O problem
         */
        @SuppressWarnings("unchecked")
        private void fetch() throws IOException {
            final RestResponse response = this.request.fetch()
                .as(RestResponse.class)
                .assertStatus(HttpURLConnection.HTTP_OK);
            final WebLinkingResponse.Link link = response
                .as(WebLinkingResponse.class)
                .links()
                .get("next");
            if (link == null) {
                this.more = false;
            } else {
                this.request = response.jump(link.uri());
            }
            final JsonArray arr = response.as(JsonResponse.class).json()
                .readArray();
            final Queue<P> list = new LinkedList<P>();
            for (final JsonValue value : arr) {
                list.add((P) value);
            }
View Full Code Here

Examples of com.jcabi.http.response.RestResponse

    }

    @Override
    public boolean exists(final String path, final String ref)
        throws IOException {
        final RestResponse response = this.request.method(Request.GET)
            .uri().path(path).queryParam("ref", ref).back()
            .fetch().as(RestResponse.class);
        return response.status() == HttpURLConnection.HTTP_OK;
    }
View Full Code Here

Examples of com.linkedin.r2.message.rest.RestResponse

            RestRequest request = rb.build();
            Future<RestResponse> f = client.restRequest(request);

            // This will block
            RestResponse response = f.get();
            final ByteString entity = response.getEntity();
            if(entity == null) {
                if(logger.isDebugEnabled()) {
                    logger.debug("Empty response !");
                }
            }
View Full Code Here

Examples of com.linkedin.r2.message.rest.RestResponse

                                                + base64Key));
            String timeoutStr = Long.toString(this.config.getTimeoutConfig()
                                                         .getOperationTimeout(VoldemortOpCode.GET_OP_CODE));
            rb.setHeader("Accept", MULTIPART_CONTENT_TYPE);

            RestResponse response = fetchGetResponse(rb, timeoutStr);
            final ByteString entity = response.getEntity();
            if(entity != null) {
                resultList = parseGetResponse(entity);
            } else {
                if(logger.isDebugEnabled()) {
                    logger.debug("Did not get any response!");
View Full Code Here

Examples of com.linkedin.r2.message.rest.RestResponse

            }
            if(this.zoneId != INVALID_ZONE_ID) {
                rb.setHeader(RestMessageHeaders.X_VOLD_ZONE_ID, String.valueOf(this.zoneId));
            }

            RestResponse response = fetchGetResponse(rb, FETCH_SCHEMA_TIMEOUT_MS);
            return response.getEntity().asString("UTF-8");
        } catch(ExecutionException e) {
            if(e.getCause() instanceof RestException) {
                RestException exception = (RestException) e.getCause();
                if(logger.isDebugEnabled()) {
                    logger.debug("REST EXCEPTION STATUS : " + exception.getResponse().getStatus());
View Full Code Here

Examples of com.linkedin.r2.message.rest.RestResponse

    }

    @Override
    public void put(ByteArray key, Versioned<byte[]> value, byte[] transform)
            throws VoldemortException {
        RestResponse response = null;

        try {
            byte[] payload = value.getValue();

            // Create the REST request with this byte array
            String base64Key = RestUtils.encodeVoldemortKey(key.get());
            RestRequestBuilder rb = new RestRequestBuilder(new URI(this.restBootstrapURL + "/"
                                                                   + getName() + "/" + base64Key));

            // Create a HTTP POST request
            rb.setMethod(POST);
            rb.setEntity(payload);
            rb.setHeader(CONTENT_TYPE, "binary");
            rb.setHeader(CONTENT_LENGTH, "" + payload.length);
            String timeoutStr = Long.toString(this.config.getTimeoutConfig()
                                                         .getOperationTimeout(VoldemortOpCode.PUT_OP_CODE));
            rb.setHeader(RestMessageHeaders.X_VOLD_REQUEST_TIMEOUT_MS, timeoutStr);
            rb.setHeader(RestMessageHeaders.X_VOLD_REQUEST_ORIGIN_TIME_MS,
                         String.valueOf(System.currentTimeMillis()));
            if(this.routingTypeCode != null) {
                rb.setHeader(RestMessageHeaders.X_VOLD_ROUTING_TYPE_CODE, this.routingTypeCode);
            }
            if(this.zoneId != INVALID_ZONE_ID) {
                rb.setHeader(RestMessageHeaders.X_VOLD_ZONE_ID, String.valueOf(this.zoneId));
            }

            // Serialize the Vector clock
            VectorClock vc = (VectorClock) value.getVersion();

            // If the given Vector clock is empty, we'll let the receiver of
            // this request fetch the existing vector clock and increment before
            // doing the put.
            if(vc != null) {
                String serializedVC = null;
                if(!vc.getEntries().isEmpty()) {
                    serializedVC = RestUtils.getSerializedVectorClock(vc);
                }

                if(serializedVC != null && serializedVC.length() > 0) {
                    rb.setHeader(RestMessageHeaders.X_VOLD_VECTOR_CLOCK, serializedVC);
                }
            }

            RestRequest request = rb.build();
            Future<RestResponse> f = client.restRequest(request);

            // This will block
            response = f.get();

            String serializedUpdatedVC = response.getHeader(RestMessageHeaders.X_VOLD_VECTOR_CLOCK);
            if(serializedUpdatedVC == null || serializedUpdatedVC.length() == 0) {
                if(logger.isDebugEnabled()) {
                    logger.debug("Received empty vector clock in the response");
                }
            } else {
                VectorClock updatedVC = RestUtils.deserializeVectorClock(serializedUpdatedVC);
                VectorClock originalVC = (VectorClock) value.getVersion();
                originalVC.copyFromVectorClock(updatedVC);
            }

            final ByteString entity = response.getEntity();
            if(entity == null) {
                if(logger.isDebugEnabled()) {
                    logger.debug("Empty response !");
                }
            }
View Full Code Here

Examples of com.linkedin.r2.message.rest.RestResponse

                RestRequest request = rb.build();
                Future<RestResponse> f = client.restRequest(request);

                // This will block
                RestResponse response = f.get();

                // Parse the response
                final ByteString entity = response.getEntity();

                String contentType = response.getHeader(CONTENT_TYPE);
                if(entity != null) {
                    if(contentType.equalsIgnoreCase(MULTIPART_CONTENT_TYPE)) {

                        resultMap = parseGetAllResults(entity);
                    } else {
View Full Code Here

Examples of com.linkedin.r2.message.rest.RestResponse

            String timeoutStr = Long.toString(this.config.getTimeoutConfig()
                                                         .getOperationTimeout(VoldemortOpCode.GET_VERSION_OP_CODE));

            rb.setHeader(RestMessageHeaders.X_VOLD_GET_VERSION, "true");

            RestResponse response = fetchGetResponse(rb, timeoutStr);
            final ByteString entity = response.getEntity();
            if(entity != null) {
                resultList = parseGetVersionResponse(entity);
            } else {
                if(logger.isDebugEnabled()) {
                    logger.debug("Did not get any response!");
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.