Package com.box.restclientv2

Examples of com.box.restclientv2.BoxBasicRestClient


        keepConnectionOpen = connectionOpen;
    }

    @Override
    public IBoxResponse execute(final IBoxRequest boxRequest) throws BoxRestException, AuthFatalFailureException {
        IBoxRequestAuth auth = boxRequest.getAuth();
        return execute(boxRequest, auth instanceof OAuthAuthorization);
    }
View Full Code Here


    @Override
    public void setAuth(IBoxRequest request) throws BoxRestException, AuthFatalFailureException {
        super.setAuth(request);

        DefaultBoxRequest defaultRequest = ((DefaultBoxRequest) request);
        defaultRequest.addQueryParam(PASSWORD, getPassword());
        defaultRequest.addQueryParam(LOGIN, getUserName());
        defaultRequest.addQueryParam(ACTION, AUTH_ACTION);
    }
View Full Code Here

    @Test
    public void testRequestIsWellFormed() throws BoxRestException, IllegalStateException, IOException, AuthFatalFailureException {
        String folderId = "testfolderid123";

        GetFolderCollaborationsRequest request = new GetFolderCollaborationsRequest(CONFIG, JSON_PARSER, folderId, new BoxDefaultRequestObject());
        testRequestIsWellFormed(request, TestUtils.getConfig().getApiUrlAuthority(),
            TestUtils.getConfig().getApiUrlPath().concat(GetFolderCollaborationsRequest.getUri(folderId)), HttpStatus.SC_OK, RestMethod.GET);
    }
View Full Code Here

    @Test
    public void testRequestIsWellFormed() throws BoxRestException, AuthFatalFailureException {
        String id = "testid123";
        String sha1 = "testsha1456";
        BoxDefaultRequestObject obj = new BoxDefaultRequestObject();
        obj.getRequestExtras().setIfMatch(sha1);
        DeleteFileRequest request = new DeleteFileRequest(CONFIG, JSON_PARSER, id, obj);
        testRequestIsWellFormed(request, TestUtils.getConfig().getApiUrlAuthority(),
            TestUtils.getConfig().getApiUrlPath().concat(DeleteFileRequest.getUri(id)), HttpStatus.SC_NO_CONTENT, RestMethod.DELETE);

        Header header = request.getRawRequest().getFirstHeader(Constants.IF_MATCH);
View Full Code Here

    public void testRequestIsWellFormed() throws BoxRestException, IllegalStateException, IOException, AuthFatalFailureException {
        int limit = 100;
        int offset = 200;
        String filterTerm = "testfilterterm";
        GetAllUsersInEnterpriseRequest request = new GetAllUsersInEnterpriseRequest(CONFIG, JSON_PARSER,
            (new BoxDefaultRequestObject()).setPage(limit, offset), filterTerm);

        testRequestIsWellFormed(request, TestUtils.getConfig().getApiUrlAuthority(),
            TestUtils.getConfig().getApiUrlPath().concat(GetAllUsersInEnterpriseRequest.getUri()), HttpStatus.SC_OK, RestMethod.GET);
        Assert.assertEquals(Integer.toString(limit), request.getQueryParams().get("limit"));
        Assert.assertEquals(Integer.toString(offset), request.getQueryParams().get("offset"));
View Full Code Here

        Assert.assertEquals(filterTerm, request.getQueryParams().get("filter_term"));
    }

    @Test
    public void testRequestDoesNotHaveFilterTermIfNotSupplied() throws BoxRestException {
        GetAllUsersInEnterpriseRequest request = new GetAllUsersInEnterpriseRequest(CONFIG, JSON_PARSER, (new BoxDefaultRequestObject()).setPage(1, 2), null);
        Assert.assertFalse(request.getQueryParams().containsKey("filter_term"));

    }
View Full Code Here

        LOG.debug("updateFileInfo: " + result);
    }

    public BoxFile uploadFile() throws Exception {
        // using com.box.restclientv2.requestsbase.BoxFileUploadRequestObject message body for single parameter "fileUploadRequest"
        final BoxFileUploadRequestObject requestObject =
                BoxFileUploadRequestObject.uploadFileRequestObject("0", CAMEL_TEST_FILE,
                        getClass().getResourceAsStream(TEST_UPLOAD_FILE));
        final FileTransferListener fileTransferListener = new FileTransferListener();
        requestObject.setListener(fileTransferListener);

        BoxFile result = requestBody("direct://UPLOADFILE", requestObject);

        assertTransferSuccess(fileTransferListener);
        assertNotNull("uploadFile result", result);
View Full Code Here

        try {
            final Map<String, Object> headers = new HashMap<String, Object>();
            // parameter type is String
            headers.put("CamelBox.fileId", boxFile.getId());
            // parameter type is com.box.restclientv2.requestsbase.BoxFileUploadRequestObject
            final BoxFileUploadRequestObject requestObject =
                    BoxFileUploadRequestObject.uploadNewVersionRequestObject(CAMEL_TEST_FILE,
                            getClass().getResourceAsStream(TEST_UPLOAD_FILE));
            final FileTransferListener fileTransferListener = new FileTransferListener();
            requestObject.setListener(fileTransferListener);

            headers.put("CamelBox.fileUploadRequest", requestObject);
            BoxFile result = requestBodyAndHeaders("direct://UPLOADNEWVERSION", null, headers);

            assertTransferSuccess(fileTransferListener);
View Full Code Here

        File f = null;

        f = TestUtils.createTempFile(content);

        String fileName = "testfilename998";
        BoxFileUploadRequestObject obj = BoxFileUploadRequestObject.uploadNewVersionRequestObject(fileName, f);
        obj.getRequestExtras().setIfMatch(sha1);
        UploadNewVersionFileRequest request = new UploadNewVersionFileRequest(CONFIG, JSON_PARSER, fileId, obj);
        testRequestIsWellFormed(request, TestUtils.getConfig().getUploadUrlAuthority(),
            TestUtils.getConfig().getUploadUrlPath().concat(UploadNewVersionFileRequest.getUri(fileId)), HttpStatus.SC_CREATED, RestMethod.POST);

        Header header = request.getRawRequest().getFirstHeader(Constants.IF_MATCH);
View Full Code Here

    private static final String CLIENT_SECRET = "testClientSecret324324";

    @Test
    public void testRevokeRequestObject() throws BoxRestException {
        String token = "testtoken1212";
        BoxOAuthRequestObject obj = BoxOAuthRequestObject.revokeOAuthRequestObject(token, CLIENT_ID, CLIENT_SECRET);

        Assert.assertEquals(CLIENT_ID, obj.getFromEntity("client_id"));
        Assert.assertEquals(CLIENT_SECRET, obj.getFromEntity("client_secret"));
        Assert.assertEquals(token, obj.getFromEntity("token"));
    }
View Full Code Here

TOP

Related Classes of com.box.restclientv2.BoxBasicRestClient

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.