Examples of BoxRestException


Examples of com.box.restclientv2.exceptions.BoxRestException

        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

Examples of com.box.restclientv2.exceptions.BoxRestException

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

Examples of com.box.restclientv2.exceptions.BoxRestException

     * @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

Examples of com.box.restclientv2.exceptions.BoxRestException

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

Examples of com.box.restclientv2.exceptions.BoxRestException

    private void handleException(final Exception e, final int sequenceId) throws BoxRestException {
        for (IBoxRestVisitor v : visitors) {
            v.visitException(e, sequenceId);
        }
        throw new BoxRestException(e);
    }
View Full Code Here

Examples of com.box.restclientv2.exceptions.BoxRestException

            Class expectedClass = getResourceHub().getClass(expectedType);
            if (expectedClass.isInstance(obj)) {
                return obj;
            }
            else {
                throw new BoxRestException("Invalid class, expected:" + expectedClass.getCanonicalName() + ";current:" + obj.getClass().getCanonicalName());
            }
        }
    }
View Full Code Here

Examples of com.box.restclientv2.exceptions.BoxRestException

            }

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

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

Examples of com.box.restclientv2.exceptions.BoxRestException

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

Examples of com.box.restclientv2.exceptions.BoxRestException

    public static String convertIJSONStringEntitytoString(final Object object, ObjectMapper objectMapper) throws BoxRestException {
        try {
            return objectMapper.writeValueAsString(object);
        }
        catch (Exception e) {
            throw new BoxRestException(e);
        }
    }
View Full Code Here

Examples of com.box.restclientv2.exceptions.BoxRestException

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