Package com.box.restclientv2.exceptions

Examples of com.box.restclientv2.exceptions.BoxRestException


                // TODO Auto-generated method stub
                return 0;
            }

        };
        responseParser = new IBoxResponseParser() {

            @Override
            public Object parse(IBoxResponse response) throws BoxRestException {
                return parsedResponse;
            }
View Full Code Here


            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

        }
        catch (BoxUnexpectedHttpStatusException e) {
            handleException(e, sequenceId);
        }

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

     * @throws AuthFatalFailureException
     *             exception indicating authenticating totally failed
     */
    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 {
                throw new BoxServerException(error);
            }
        }
View Full Code Here

     *             exception indicating authenticating totally failed
     */
    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

     */
    public InputStream execute(final IBoxRequestAuth auth, ObjectMapper objectMapper, BoxDefaultRequestObject requestObject) throws BoxRestException,
        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

     */
    public BoxPreview getPreview(final String fileId, final String extension, final BoxImageRequestObject requestObject) throws BoxRestException,
        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

     */
    public InputStream downloadThumbnail(final String fileId, final String extension, final BoxImageRequestObject requestObject) throws BoxRestException,
        BoxServerException, AuthFatalFailureException {
        ThumbnailRequest request = new ThumbnailRequest(getConfig(), getObjectMapper(), fileId, extension, requestObject);
        request.setAuth(getAuth());
        DefaultBoxResponse response = (DefaultBoxResponse) getRestClient().execute(request);
        return (InputStream) (new DefaultFileResponseParser()).parse(response);
    }
View Full Code Here

            response = getRawHttpClient().execute(httpRequest);
        }
        catch (IOException e) {
            throw new BoxRestException(e);
        }
        DefaultBoxResponse boxResponse = new DefaultBoxResponse(response);
        boxResponse.setExpectedResponseCode(boxRequest.getExpectedResponseCode());
        return boxResponse;
    }
View Full Code Here

    /**
     * Execute a request and expect no response body.
     */
    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 {
                    throw new BoxServerException(error);
                }
            }
        }
        finally {
            Utils.consumeHttpEntityQuietly(response.getHttpResponse().getEntity());
        }
    }
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.