Package com.box.restclientv2.authorization.oauthmultithread

Examples of com.box.restclientv2.authorization.oauthmultithread.OAuthMultithreadTest$StatusCodeException


     * Make a rest api request, get response, and then parse the response.
     */
    public Object getResponseAndParse(final DefaultBoxRequest request, final IBoxType type, final IBoxJSONParser parser) throws BoxRestException,
        AuthFatalFailureException {
        request.setAuth(getAuth());
        DefaultBoxResponse response = (DefaultBoxResponse) getRestClient().execute(request);
        BoxObjectResponseParser responseParser = new BoxObjectResponseParser(getClassFromType(type), parser);
        ErrorResponseParser errorParser = new ErrorResponseParser(getJSONParser());
        return response.parseResponse(responseParser, errorParser);
    }
View Full Code Here


    @Override
    public BoxPreview getPreview(final String fileId, final String extension, final BoxImageRequestObject requestObject) throws BoxRestException,
        BoxServerException, AuthFatalFailureException {
        GetPreviewRequest request = new GetPreviewRequest(getConfig(), getJSONParser(), fileId, extension, requestObject);
        request.setAuth(getAuth());
        DefaultBoxResponse response = (DefaultBoxResponse) getRestClient().execute(request);
        PreviewResponseParser parser = new PreviewResponseParser();
        ErrorResponseParser errorParser = new ErrorResponseParser(getJSONParser());
        Object result = response.parseResponse(parser, errorParser);

        return (BoxPreview) tryCastObject(BoxResourceType.PREVIEW, result);
    }
View Full Code Here

    @Override
    public BoxThumbnail getThumbnail(final String fileId, final String extension, final BoxImageRequestObject requestObject) throws BoxRestException,
        BoxServerException, AuthFatalFailureException {
        ThumbnailRequest request = new ThumbnailRequest(getConfig(), getJSONParser(), fileId, extension, requestObject);
        request.setAuth(getAuth());
        DefaultBoxResponse response = (DefaultBoxResponse) getRestClient().execute(request);
        ThumbnailResponseParser parser = new ThumbnailResponseParser();
        ErrorResponseParser errorParser = new ErrorResponseParser(getJSONParser());
        Object result = response.parseResponse(parser, errorParser);
        return (BoxThumbnail) tryCastObject(BoxResourceType.THUMBNAIL, result);
    }
View Full Code Here

    @Deprecated
    public InputStream downloadThumbnail(final String fileId, final String extension, final BoxImageRequestObject requestObject) throws BoxRestException,
        BoxServerException, AuthFatalFailureException {
        ThumbnailRequest request = new ThumbnailRequest(getConfig(), getJSONParser(), fileId, extension, requestObject);
        request.setAuth(getAuth());
        DefaultBoxResponse response = (DefaultBoxResponse) getRestClient().execute(request);
        if (response.getResponseStatusCode() != request.getExpectedResponseCode()) {
            ErrorResponseParser errorParser = new ErrorResponseParser(getJSONParser());
            Object o = errorParser.parse(response);
            if (o instanceof BoxServerError) {
                if (o instanceof BoxUnexpectedStatus) {
                    throw new BoxUnexpectedHttpStatusException((BoxUnexpectedStatus) o);
View Full Code Here

                Utils.consumeHttpEntityQuietly(response.getEntity());
            }
            throw e;
        }

        DefaultBoxResponse boxResponse = new DefaultBoxResponse(response);
        boxResponse.setExpectedResponseCode(boxRequest.getExpectedResponseCode());
        return boxResponse;
    }
View Full Code Here

            request = new DownloadPartialFileRequest(mConfig, parser, mFileId, requestObject);
        } else {
            request = new DownloadFileRequest(mConfig, parser, mFileId, requestObject);
        }
        request.setAuth(auth);
        DefaultBoxResponse response = (DefaultBoxResponse) mRestClient.execute(request);
        DefaultFileResponseParser responseParser = new DefaultFileResponseParser();
        ErrorResponseParser errorParser = new ErrorResponseParser(parser);
        Object result = response.parseResponse(responseParser, errorParser);
        if (result instanceof BoxServerError) {
            throw new BoxServerException((BoxServerError) result);
        }
        return (InputStream) result;
    }
View Full Code Here

    private int makeRequestAndGetStatusCode() throws BoxRestException, AuthFatalFailureException {
        MockRequest request = new MockRequest();
        request.setAuth(new OAuthAuthorization(client.getOAuthDataController()));
        MockRestClient client = new MockRestClient();
        DefaultBoxResponse response = (DefaultBoxResponse) client.execute(request);
        return response.getResponseStatusCode();
    }
View Full Code Here

                // TODO Auto-generated method stub

            }

        };
        response = new IBoxResponse() {

            @Override
            public Object parseResponse(IBoxResponseParser responseParser, IBoxResponseParser errorParser) throws BoxRestException {
                return parsedResponse;
            }
View Full Code Here

        };
    }

    @Test
    public void testInterfacesE2E() throws AuthFatalFailureException {
        IBoxResponse theResponse = null;
        try {
            theResponse = client.execute(request);
        }
        catch (BoxRestException e) {
            Assert.fail();
View Full Code Here

TOP

Related Classes of com.box.restclientv2.authorization.oauthmultithread.OAuthMultithreadTest$StatusCodeException

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.