Package com.box.boxjavalibv2.dao

Examples of com.box.boxjavalibv2.dao.BoxFile


                                    // 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.BoxItemCopyRequestObject
        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);

        return result;
View Full Code Here

        return result;
    }

    @Test
    public void testCreateSharedLink() throws Exception {
        final BoxFile boxFile = copyFile();

        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.boxjavalibv2.requests.requestobjects.BoxSharedLinkRequestObject
            final BoxSharedLinkRequestEntity sharedLink = new BoxSharedLinkRequestEntity(BoxSharedLinkAccess.OPEN);
            final BoxSharedLinkRequestObject requestObject =
                    BoxSharedLinkRequestObject.createSharedLinkRequestObject(sharedLink);
            headers.put("CamelBox.sharedLinkRequest", requestObject);

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

            assertNotNull("createSharedLink result", result);
            LOG.debug("createSharedLink: " + result);
        } finally {
            deleteFile(boxFile.getId());
View Full Code Here

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

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

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

        headers.put("CamelBox.fileId", testFileId);
        // parameter type is com.box.boxjavalibv2.requests.requestobjects.BoxFileRequestObject
        final BoxFileRequestObject requestObject = BoxFileRequestObject.getRequestObject();
        requestObject.setTags(new String[]{CAMEL_TEST_TAG});
        headers.put("CamelBox.fileRequest", requestObject);
        BoxFile result = requestBodyAndHeaders("direct://UPDATEFILEINFO", null, headers);

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

                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);
        LOG.debug("uploadFile: " + result);
View Full Code Here

TOP

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

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.