Package com.box.boxjavalibv2.filetransfer

Examples of com.box.boxjavalibv2.filetransfer.BoxFileDownloadTest$TestOutputStream


                                    // get events
                                    final BoxEventRequestObject requestObject =
                                        BoxEventRequestObject.getEventsRequestObject(currentStreamPosition);
                                    requestObject.setStreamType(streamType);
                                    requestObject.setLimit(limit);
                                    final BoxEventCollection events = eventsManager.getEvents(requestObject);

                                    // notify callback
                                    callback.onEvent(events);

                                    // update stream position
                                    currentStreamPosition = events.getNextStreamPosition();

                                } else if (RECONNECT.equals(message) || MAX_RETRIES.equals(message)) {
                                    LOG.debug("Long poll reconnect for " + cachedBoxClient);
                                    realTimeServer = null;
                                } else if (OUT_OF_DATE.equals(message)) {
View Full Code Here


    private long getCurrentStreamPosition(IBoxEventsManager eventsManager, long streamPosition)
        throws BoxRestException, BoxServerException, AuthFatalFailureException {

        final BoxEventRequestObject requestObject =
            BoxEventRequestObject.getEventsRequestObject(streamPosition);
        final BoxEventCollection events = eventsManager.getEvents(requestObject);
        streamPosition = events.getNextStreamPosition();
        return streamPosition;
    }
View Full Code Here

    }

    @Override
    public Object splitResult(Object result) {
        if (result instanceof BoxEventCollection && splitResult) {
            BoxEventCollection eventCollection = (BoxEventCollection) result;
            final ArrayList<BoxTypedObject> entries = eventCollection.getEntries();
            return entries.toArray(new BoxTypedObject[entries.size()]);
        }
        return result;
    }
View Full Code Here

    }

    @Override
    public void interceptResult(Object result, Exchange resultExchange) {
        if (result instanceof BoxEventCollection) {
            BoxEventCollection boxEventCollection = (BoxEventCollection) result;
            resultExchange.getIn().setHeader(BoxConstants.CHUNK_SIZE_PROPERTY,
                boxEventCollection.getChunkSize());
            resultExchange.getIn().setHeader(BoxConstants.NEXT_STREAM_POSITION_PROPERTY,
                boxEventCollection.getNextStreamPosition());
        }
    }
View Full Code Here

        headers.put("CamelBox.fileId", testFileId);
        final BoxItemCopyRequestObject requestObject = BoxItemCopyRequestObject.copyItemRequestObject("0");
        requestObject.setName(CAMEL_TEST_FILE);
        headers.put("CamelBox.itemCopyRequest", requestObject);

        BoxFile result = requestBodyAndHeaders("direct://COPYFILE", null, headers);

        assertNotNull("copyFile result", result);
        LOG.debug("copyFile: " + result);

        // generate file delete event
        headers.clear();
        headers.put("CamelBox.fileId", result.getId());
        headers.put("CamelBox.defaultRequest", null);
        requestBodyAndHeaders("direct://DELETEFILE", null, headers);

        MockEndpoint mockEndpoint = getMockEndpoint("mock:boxEvents");
        mockEndpoint.expectedMinimumMessageCount(2);
View Full Code Here

        // parameter type is com.box.boxjavalibv2.requests.requestobjects.BoxSimpleUserRequestObject
        final BoxSimpleUserRequestObject requestObject =
                BoxSimpleUserRequestObject.moveFolderToAnotherUserRequestEntity(toUserId, false);
        headers.put("CamelBox.simpleUserRequest", requestObject);

        BoxFolder result = requestBodyAndHeaders("direct://MOVEFOLDERTOANOTHERUSER", null, headers);

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

    @Test
    // also tests create folder, and delete folder
    public void testCopyFolder() throws Exception {
        // create a test folder to copy
        final BoxFolder testFolder = createFolder();

        try {
            final Map<String, Object> headers = new HashMap<String, Object>();
            // parameter type is String
            headers.put("CamelBox.folderId", testFolder.getId());
            // parameter type is com.box.boxjavalibv2.requests.requestobjects.BoxItemCopyRequestObject
            final BoxItemCopyRequestObject requestObject = BoxItemCopyRequestObject.copyItemRequestObject("0");
            requestObject.setName(CAMEL_TEST_COPY_FOLDER);
            headers.put("CamelBox.itemCopyRequest", requestObject);

            BoxFolder result = requestBodyAndHeaders("direct://COPYFOLDER", null, headers);
            assertNotNull("copyFolder result", result);
            assertEquals("copyFolder folder name", CAMEL_TEST_COPY_FOLDER, result.getName());
            LOG.debug("copyFolder: " + result);

            // delete the copy
            deleteFolder(result.getId());
        } finally {
            deleteFolder(testFolder.getId());
        }
    }
View Full Code Here

    private BoxFolder createFolder() {
        // using com.box.boxjavalibv2.requests.requestobjects.BoxFolderRequestObject message body for single parameter "folderRequest"
        final BoxFolderRequestObject camelTestFolder = BoxFolderRequestObject.createFolderRequestObject(CAMEL_TEST_FOLDER, "0");

        BoxFolder result = requestBody("direct://CREATEFOLDER", camelTestFolder);
        assertNotNull("createFolder result", result);
        assertNotNull("createFolder folder id", result.getId());
        return result;
    }
View Full Code Here

        return result;
    }

    @Test
    public void testCreateSharedLink() throws Exception {
        final BoxFolder testFolder = createFolder();

        try {
            final Map<String, Object> headers = new HashMap<String, Object>();
            // parameter type is String
            headers.put("CamelBox.folderId", testFolder.getId());
            // parameter type is com.box.boxjavalibv2.requests.requestobjects.BoxSharedLinkRequestObject
            final BoxSharedLinkRequestEntity sharedLink = new BoxSharedLinkRequestEntity(
                    BoxSharedLinkAccess.COLLABORATORS);
            headers.put("CamelBox.sharedLinkRequest",
                    BoxSharedLinkRequestObject.createSharedLinkRequestObject(sharedLink));

            BoxFolder result = requestBodyAndHeaders("direct://CREATESHAREDLINK", null, headers);
            assertNotNull("createSharedLink result", result);
            assertNotNull("createSharedLink result", result.getSharedLink());
            LOG.debug("createSharedLink: " + result);
        } finally {
            deleteFolder(testFolder.getId());
        }
    }
View Full Code Here

        // parameter type is String
        headers.put("CamelBox.folderId", "0");
        // parameter type is com.box.restclientv2.requestsbase.BoxDefaultRequestObject
//        headers.put("CamelBox.defaultRequest", null);

        final BoxFolder result = (BoxFolder) requestBodyAndHeaders("direct://GETFOLDER", null, headers);
        assertNotNull("getFolder result", result);
        assertEquals("getFolder folder id", "0", result.getId());
        LOG.debug("getFolder: " + result);
    }
View Full Code Here

TOP

Related Classes of com.box.boxjavalibv2.filetransfer.BoxFileDownloadTest$TestOutputStream

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.