Package com.box.restclientv2.exceptions

Examples of com.box.restclientv2.exceptions.BoxRestException


        final BoxConnectionManagerBuilder connectionManager = connectionManagerBuilder != null
            ? connectionManagerBuilder : new BoxConnectionManagerBuilder();

        // create REST client for BoxClient
        final ClientConnectionManager[] clientConnectionManager = new ClientConnectionManager[1];
        final IBoxRESTClient restClient = new BoxRESTClient(connectionManager.build()) {
            @Override
            public HttpClient getRawHttpClient() {
                final HttpClient httpClient = super.getRawHttpClient();
                clientConnectionManager[0] = httpClient.getConnectionManager();
                final SchemeRegistry schemeRegistry = clientConnectionManager[0].getSchemeRegistry();
View Full Code Here


        final BoxConnectionManagerBuilder connectionManager = connectionManagerBuilder != null
            ? connectionManagerBuilder : new BoxConnectionManagerBuilder();

        // create REST client for BoxClient
        final ClientConnectionManager[] clientConnectionManager = new ClientConnectionManager[1];
        final IBoxRESTClient restClient = new BoxRESTClient(connectionManager.build()) {
            @Override
            public HttpClient getRawHttpClient() {
                final HttpClient httpClient = super.getRawHttpClient();
                clientConnectionManager[0] = httpClient.getConnectionManager();
View Full Code Here

            @Override
            public void setCookie(IBoxRequest request) {
            }

        };
        client = new IBoxRESTClient() {

            @Override
            public IBoxResponse execute(IBoxRequest boxRequest) throws BoxRestException {
                return response;
            }
View Full Code Here

    @Override
    public void onAuthFlowEvent(IAuthEvent event, IAuthFlowMessage message) {
        OAuthEvent oe = (OAuthEvent) event;
        if (oe == OAuthEvent.OAUTH_CREATED) {
            IBoxRequestAuth auth = getAuth();
            // We currently only supports OAuth.
            if (auth instanceof IOAuthAuthorization) {
                ((IOAuthAuthorization) auth).setOAuthData(getOAuthTokenFromMessage(message));
            }
        }
View Full Code Here

        keepConnectionOpen = connectionOpen;
    }

    @Override
    public IBoxResponse execute(final IBoxRequest boxRequest) throws BoxRestException, AuthFatalFailureException {
        IBoxRequestAuth auth = boxRequest.getAuth();
        return execute(boxRequest, auth instanceof IOAuthAuthorization);
    }
View Full Code Here

    private final String parsedResponse = "parsed response";
    private ICookie cookie;

    @Before
    public void setUp() {
        auth = new IBoxRequestAuth() {

            @Override
            public void setAuth(IBoxRequest request) throws BoxRestException {
            }
        };
View Full Code Here

        try {
            response = getRawHttpClient().execute(httpRequest);
        }
        catch (Exception e) {
            throw new BoxRestException(e);
        }
        DefaultBoxResponse boxResponse = new DefaultBoxResponse(response);
        boxResponse.setExpectedResponseCode(boxRequest.getExpectedResponseCode());
        return boxResponse;
    }
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);
        }
    }
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.getMessage());
        }
        finally {
            IOUtils.closeQuietly(in);
        }
    }
View Full Code Here

        try {
            JsonParser jp = jsonFactory.createJsonParser(in);
            return mObjectMapper.readValue(jp, objectClass);
        }
        catch (Exception e) {
            throw new BoxRestException(e, e.getMessage());
        }
    }
View Full Code Here

TOP

Related Classes of com.box.restclientv2.exceptions.BoxRestException

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.