Package com.box.boxjavalibv2.dao

Examples of com.box.boxjavalibv2.dao.BoxPreview


        }
    }

    @Test
    public void testUpdateMembership() throws Exception {
        final BoxGroup group = createGroup();

        try {
            final BoxGroupMembership membership = createMembership(group.getId());

            final Map<String, Object> headers = new HashMap<String, Object>();
            // parameter type is String
            headers.put("CamelBox.membershipId", membership.getId());
            // parameter type is com.box.boxjavalibv2.requests.requestobjects.BoxGroupMembershipRequestObject
            final BoxGroupMembershipRequestObject requestObject =
                    BoxGroupMembershipRequestObject.updateMembershipRequestObject(BoxGroupMembership.ROLE_ADMIN);
            headers.put("CamelBox.groupMembershipRequest", requestObject);

            BoxGroupMembership result = requestBodyAndHeaders("direct://UPDATEMEMBERSHIP", null, headers);

            assertNotNull("updateMembership result", result);
            LOG.debug("updateMembership: " + result);
        } finally {
            deleteGroup(group.getId());
        }
    }
View Full Code Here


    private static final String PATH_PREFIX = BoxApiCollection.getCollection().getApiName(IBoxSharedItemsManagerApiMethod.class).getName();

    @Test
    public void testGetSharedItem() throws Exception {
        // using com.box.restclientv2.requestsbase.BoxDefaultRequestObject message body for single parameter "defaultRequest"
        BoxItem result = requestBody("direct://GETSHAREDITEM", null);

        assertNotNull("getSharedItem result", result);
        LOG.debug("getSharedItem: " + result);
    }
View Full Code Here

                // get authorization code
                final String authorizationCode = params.get("code");

                // get OAuth token
                final IBoxOAuthManager oAuthManager = boxClient.getOAuthManager();
                final BoxOAuthToken oAuthToken = oAuthManager.createOAuth(authorizationCode,
                    configuration.getClientId(), configuration.getClientSecret(), null);

                // send initial token to BoxClient and this.listener
                final OAuthDataMessage authDataMessage = new OAuthDataMessage(oAuthToken,
                    boxClient.getJSONParser(), boxClient.getResourceHub());
View Full Code Here

                if (ObjectHelper.isEmpty(refreshToken)) {
                    return null;
                } else {
                    Map<String, Object> values = new HashMap<String, Object>();
                    values.put(BoxOAuthToken.FIELD_REFRESH_TOKEN, refreshToken);
                    return new BoxOAuthToken(values);
                }
            }
        });
        configuration.setRefreshListener(new OAuthRefreshListener() {
            @Override
View Full Code Here

                // get authorization code
                final String authorizationCode = params.get("code");

                // get OAuth token
                final IBoxOAuthManager oAuthManager = boxClient.getOAuthManager();
                final BoxOAuthToken oAuthToken = oAuthManager.createOAuth(authorizationCode,
                    configuration.getClientId(), configuration.getClientSecret(), null);

                // send initial token to BoxClient and this.listener
                final OAuthDataMessage authDataMessage = new OAuthDataMessage(oAuthToken,
                    boxClient.getJSONParser(), boxClient.getResourceHub());
View Full Code Here

            boolean ignore = false;
            if (e.getCause().getCause() instanceof BoxServerException) {
                BoxServerException exception = (BoxServerException) e.getCause().getCause();
                if (PREVIEW_UNAVAILABLE.equals(exception.getMessage())) {
                    // ignore unavailable preview errors
                    result = new BoxPreview();
                    ignore = true;
                }
            }
            if (!ignore) {
                throw e;
View Full Code Here

    private static final String REL = "rel";
    private static final String PAGE = "page";

    @Override
    public BoxPreview parse(IBoxResponse response) throws BoxRestException {
        BoxPreview preview = new BoxPreview();
        preview.setContent((InputStream) super.parse(response));
        extraParses(preview, (DefaultBoxResponse) response);
        return preview;
    }
View Full Code Here

    private InputStream inputStream;
    private Header header;

    @Before
    public void setUp() {
        preview = new BoxPreview();
        preview.setFirstPage(firstPage);
        preview.setLastPage(lastPage);
        boxResponse = EasyMock.createMock(DefaultBoxResponse.class);
        response = EasyMock.createMock(BasicHttpResponse.class);
        entity = EasyMock.createMock(StringEntity.class);
View Full Code Here

        EasyMock.replay(boxResponse, response, entity);
        PreviewResponseParser parser = new PreviewResponseParser();
        Object object = parser.parse(boxResponse);
        Assert.assertEquals(BoxPreview.class, object.getClass());

        BoxPreview parsed = (BoxPreview) object;
        Assert.assertEquals(length, parsed.getContentLength(), 0.001);
        Assert.assertEquals(firstPage, parsed.getFirstPage().intValue());
        Assert.assertEquals(lastPage, parsed.getLastPage().intValue());
        Assert.assertEquals(PREVIEW_MOCK_CONTENT, IOUtils.toString(parsed.getContent()));
        EasyMock.verify(boxResponse, response, entity);

    }
View Full Code Here

    private static final String PAGE = "page";

    @Override
    public BoxPreview parse(IBoxResponse response) throws BoxRestException {
        InputStream is = (InputStream) super.parse(response);
        BoxPreview preview = new BoxPreview();
        preview.setContent(is);
        preview.setContentLength(response.getContentLength());
        parseLinks(preview, (DefaultBoxResponse) response);
        return preview;
    }
View Full Code Here

TOP

Related Classes of com.box.boxjavalibv2.dao.BoxPreview

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.