Examples of ErrorResponseParser


Examples of com.box.boxjavalibv2.responseparsers.ErrorResponseParser

     */
    protected void executeRequestWithNoResponseBody(final DefaultBoxRequest request) throws BoxServerException, BoxRestException, AuthFatalFailureException {
        request.setAuth(getAuth());
        DefaultBoxResponse response = (DefaultBoxResponse) getRestClient().execute(request);
        if (response.getExpectedResponseCode() != response.getResponseStatusCode()) {
            ErrorResponseParser errorParser = new ErrorResponseParser(getObjectMapper());
            BoxServerError error = (BoxServerError) errorParser.parse(response);
            if (error == null) {
                throw new BoxServerException("Unexpected response code:" + response.getResponseStatusCode() + ", expecting:"
                                             + response.getExpectedResponseCode(), response.getResponseStatusCode());
            }
            else {
View Full Code Here

Examples of com.box.boxjavalibv2.responseparsers.ErrorResponseParser

    public Object getResponseAndParse(final DefaultBoxRequest request, final BoxResourceType type, final ObjectMapper objectMapper) throws BoxRestException,
        AuthFatalFailureException {
        request.setAuth(getAuth());
        DefaultBoxResponse response = (DefaultBoxResponse) getRestClient().execute(request);
        BoxObjectResponseParser parser = new BoxObjectResponseParser(getResourceHub().getClass(type), objectMapper);
        ErrorResponseParser errorParser = new ErrorResponseParser(getObjectMapper());
        return response.parseResponse(parser, errorParser);
    }
View Full Code Here

Examples of com.box.boxjavalibv2.responseparsers.ErrorResponseParser

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

Examples of com.box.boxjavalibv2.responseparsers.ErrorResponseParser

        BoxServerException, AuthFatalFailureException {
        PreviewRequest request = new PreviewRequest(getConfig(), getObjectMapper(), fileId, extension, requestObject);
        request.setAuth(getAuth());
        DefaultBoxResponse response = (DefaultBoxResponse) getRestClient().execute(request);
        PreviewResponseParser parser = new PreviewResponseParser();
        ErrorResponseParser errorParser = new ErrorResponseParser(getObjectMapper());
        Object result = response.parseResponse(parser, errorParser);

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

Examples of com.box.boxjavalibv2.responseparsers.ErrorResponseParser

    protected void executeRequestWithNoResponseBody(final DefaultBoxRequest request) throws BoxServerException, BoxRestException, AuthFatalFailureException {
        request.setAuth(getAuth());
        DefaultBoxResponse response = (DefaultBoxResponse) getRestClient().execute(request);
        try {
            if (response.getExpectedResponseCode() != response.getResponseStatusCode()) {
                ErrorResponseParser errorParser = new ErrorResponseParser(getJSONParser());
                BoxServerError error = (BoxServerError) errorParser.parse(response);
                if (error == null) {
                    throw new BoxServerException("Unexpected response code:" + response.getResponseStatusCode() + ", expecting:"
                                                 + response.getExpectedResponseCode(), response.getResponseStatusCode());
                }
                else {
View Full Code Here

Examples of com.box.boxjavalibv2.responseparsers.ErrorResponseParser

    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

Examples of com.box.boxjavalibv2.responseparsers.ErrorResponseParser

        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

Examples of com.box.boxjavalibv2.responseparsers.ErrorResponseParser

        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

Examples of com.box.boxjavalibv2.responseparsers.ErrorResponseParser

        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);
                }
                else {
View Full Code Here

Examples of com.box.boxjavalibv2.responseparsers.ErrorResponseParser

            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
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.