Package com.box.restclientv2.httpclientsupport

Examples of com.box.restclientv2.httpclientsupport.HttpClientURLEncodedUtils


     */
    public static BoxFileUploadRequestObject uploadNewVersionRequestObject(final String name, final InputStream inputStream) throws BoxRestException {
        try {
            return (new BoxFileUploadRequestObject()).setMultipartMIME(getNewVersionMultipartEntity(name, inputStream));
        } catch (UnsupportedEncodingException e) {
            throw new BoxRestException(e);
        }
    }
View Full Code Here


    }

    @Override
    public Object parse(IBoxResponse response) throws BoxRestException {
        if (!(response instanceof DefaultBoxResponse)) {
            throw new BoxRestException("class mismatch, expected:" + DefaultBoxResponse.class.getName() + ";current:" + response.getClass().getName());
        }

        HttpResponse httpResponse = ((DefaultBoxResponse) response).getHttpResponse();
        if (httpResponse == null) {
            return null;
View Full Code Here

        if (requestObject != null) {
            try {
                setEntity(requestObject.getEntity(parser));
            } catch (BoxJSONException e) {
                throw new BoxRestException(e, "Cannot parse entity of the request object.");
            } catch (UnsupportedEncodingException e) {
                throw new BoxRestException(e, "UnsupportedEncodingException in the request object.");
            }

            BoxRequestExtras mutator = requestObject.getRequestExtras();
            setRequestFields(mutator.getFields());
            getQueryParams().putAll(mutator.getQueryParams());
View Full Code Here

                ub.addParameter(entry.getKey(), StringUtils.defaultIfEmpty(entry.getValue(), ""));
            }

            rawRequest.setURI(ub.build());
        } catch (URISyntaxException e) {
            throw new BoxRestException("URISyntaxException:" + e.getMessage());
        }

        if (getAuth() != null) {
            getAuth().setAuth(this);
        }
View Full Code Here

            case DELETE:
                return new HttpDelete();
            case OPTIONS:
                return new HttpOptions();
            default:
                throw new BoxRestException("Method Not Implemented");
        }
    }
View Full Code Here

public class DefaultFileResponseParser implements IBoxResponseParser {

    @Override
    public Object parse(IBoxResponse response) throws BoxRestException {
        if (!(response instanceof DefaultBoxResponse)) {
            throw new BoxRestException("class mismatch, expected:" + DefaultBoxResponse.class.getName() + ";current:" + response.getClass().getCanonicalName());
        }
        HttpResponse httpResponse = ((DefaultBoxResponse) response).getHttpResponse();
        try {
            return httpResponse.getEntity().getContent();
        }
        catch (Exception e) {
            throw new BoxRestException(e, "Failed to parse response.");
        }
    }
View Full Code Here

     * @throws BoxRestException
     */
    @Override
    public Object parse(IBoxResponse response) throws BoxRestException {
        if (!(response instanceof DefaultBoxResponse)) {
            throw new BoxRestException("class mismatch, expected:" + DefaultBoxResponse.class.getName() + ";current:" + response.getClass().getName());
        }
        HttpResponse httpResponse = ((DefaultBoxResponse) response).getHttpResponse();

        InputStream in = null;
        try {
            in = httpResponse.getEntity().getContent();
            if (in == null) {
                return null;
            }
            else {
                return parseInputStream(in);
            }
        }
        catch (Exception e) {
            throw new BoxRestException(e, "Failed to parse response.");
        }
        finally {
            IOUtils.closeQuietly(in);
        }
    }
View Full Code Here

    public static final String AUTH_HEADER_NAME = "Authorization";

    @Override
    public void setAuth(final IBoxRequest request) throws BoxRestException, AuthFatalFailureException {
        if (!(request instanceof DefaultBoxRequest)) {
            throw new BoxRestException("class does not match, expected:" + DefaultBoxRequest.class.getCanonicalName() + ";current:"
                                       + request.getClass().getCanonicalName());
        }
    }
View Full Code Here

        }
        try {
            return new StringEntity(en.toJSONString(parser), CharEncoding.UTF_8);
        }
        catch (UnsupportedEncodingException e) {
            throw new BoxRestException(e);
        }
    }
View Full Code Here

        try {
            return new UrlEncodedFormEntity(pairs, CharEncoding.UTF_8);
        }
        catch (UnsupportedEncodingException e) {
            throw new BoxRestException(e);
        }
    }
View Full Code Here

TOP

Related Classes of com.box.restclientv2.httpclientsupport.HttpClientURLEncodedUtils

Copyright © 2018 www.massapicom. 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.