Package com.box.boxjavalibv2.filetransfer

Examples of com.box.boxjavalibv2.filetransfer.IFileTransferListener


        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());
View Full Code Here


    public void testPoll() throws Exception {

        // generate file copy event
        final Map<String, Object> headers = new HashMap<String, Object>();
        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);
View Full Code Here

        // parameter type is String
        headers.put("CamelBox.userId", fromUserId);
        // parameter type is String
        headers.put("CamelBox.folderId", testFolderId);
        // 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);
View Full Code Here

    public void deleteEnterpriseUser(String userId) throws Exception {
        final Map<String, Object> headers = new HashMap<String, Object>();
        // parameter type is String
        headers.put("CamelBox.userId", userId);
        // parameter type is com.box.boxjavalibv2.requests.requestobjects.BoxUserDeleteRequestObject
        final BoxUserDeleteRequestObject requestObject =
                BoxUserDeleteRequestObject.deleteEnterpriseUserRequestObject(false, true);
        headers.put("CamelBox.userDeleteRequest", requestObject);

        requestBodyAndHeaders("direct://DELETEENTERPRISEUSER", null, headers);
        // pause for user to be deleted completely
View Full Code Here

        deleteEmailAlias();
    }

    public BoxUser createEnterpriseUser() throws Exception {
        // using com.box.boxjavalibv2.requests.requestobjects.BoxUserRequestObject message body for single parameter "userRequest"
        final BoxUserRequestObject enterpriseUserRequestObject =
                BoxUserRequestObject.createEnterpriseUserRequestObject(CAMEL_EMAIL_ALIAS, CAMEL_USER_NAME);
        BoxUser result = requestBody("direct://CREATEENTERPRISEUSER", enterpriseUserRequestObject);

        assertNotNull("createEnterpriseUser result", result);
        return result;
View Full Code Here

        try {
            final Map<String, Object> headers = new HashMap<String, Object>();
            // parameter type is String
            headers.put("CamelBox.userId", enterpriseUser.getId());
            // parameter type is com.box.boxjavalibv2.requests.requestobjects.BoxUserRequestObject
            final BoxUserRequestObject requestObject =
                    BoxUserRequestObject.updateUserInfoRequestObject(false);
            requestObject.setJobTitle(CAMEL_JOB_TITLE);
            headers.put("CamelBox.userRequest", requestObject);

            BoxUser result = requestBodyAndHeaders("direct://UPDATEUSERINFORMAITON", null, headers);

            assertNotNull("updateUserInformaiton result", result);
View Full Code Here

        try {
            final Map<String, Object> headers = new HashMap<String, Object>();
            // parameter type is String
            headers.put("CamelBox.userId", enterpriseUser.getId());
            // parameter type is com.box.boxjavalibv2.requests.requestobjects.BoxUserUpdateLoginRequestObject
            final BoxUserUpdateLoginRequestObject requestObject =
                    BoxUserUpdateLoginRequestObject.updateUserPrimaryLoginRequestObject(UPDATED_EMAIL_ALIAS);
            headers.put("CamelBox.userUpdateLoginRequest", requestObject);

            BoxUser result = requestBodyAndHeaders("direct://UPDATEUSERPRIMARYLOGIN", null, headers);
View Full Code Here

    public void poll(long streamPosition, final String streamType, final int limit, final EventCallback callback)
        throws BoxServerException, AuthFatalFailureException, BoxRestException {

        // get BoxClient Event Manager
        final IBoxEventsManager eventsManager = cachedBoxClient.getBoxClient().getEventsManager();

        // get current stream position if requested
        if (BoxEventRequestObject.STREAM_POSITION_NOW == streamPosition) {
            streamPosition = getCurrentStreamPosition(eventsManager, streamPosition);
        }

        // validate parameters
        ObjectHelper.notNull(streamPosition, "streamPosition");
        ObjectHelper.notEmpty(streamType, "streamType");
        ObjectHelper.notNull(callback, "eventCallback");

        httpClient = new DefaultHttpClient(cachedBoxClient.getClientConnectionManager(), httpParams);

        // start polling thread
        LOG.info("Started event polling thread for " + cachedBoxClient);

        final long startStreamPosition = streamPosition;
        pollFuture = executorService.submit(new Runnable() {
            @Override
            public void run() {

                final ObjectMapper mapper = new ObjectMapper();

                long currentStreamPosition = startStreamPosition;
                BoxRealTimeServer realTimeServer = null;

                boolean retry = false;
                int retries = 0;
                int maxRetries = 1;

                while (!done) {
                    try {
                        // set to true if no exceptions thrown
                        retry = false;

                        if (realTimeServer == null) {

                            // get RTS URL
                            realTimeServer = getBoxRealTimeServer(currentStreamPosition, eventsManager);

                            // update HTTP timeout
                            final int requestTimeout = Integer.parseInt(
                                realTimeServer.getExtraData(RETRY_TIMEOUT).toString());
                            final HttpParams params = httpClient.getParams();
                            HttpConnectionParams.setSoTimeout(params, requestTimeout * 1000);

                            // update maxRetries
                            maxRetries = Integer.parseInt(realTimeServer.getExtraData(MAX_RETRIES).toString());
                        }

                        // create HTTP request for RTS
                        httpGet = getPollRequest(realTimeServer.getUrl(), currentStreamPosition);

                        // execute RTS poll
                        HttpResponse httpResponse = null;
                        try {
                            httpResponse = httpClient.execute(httpGet, (HttpContext) null);
                        } catch (SocketTimeoutException e) {
                            LOG.debug("Poll timed out, retrying for " + cachedBoxClient);
                        }

                        if (httpResponse != null) {

                            // parse response
                            final StatusLine statusLine = httpResponse.getStatusLine();
                            if (statusLine != null && statusLine.getStatusCode() == HttpStatus.SC_OK) {
                                final HttpEntity entity = httpResponse.getEntity();
                                @SuppressWarnings("unchecked")
                                Map<String, String> rtsResponse = mapper.readValue(entity.getContent(), Map.class);

                                final String message = rtsResponse.get(MESSAGE);
                                if (NEW_CHANGE.equals(message)) {

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

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

TOP

Related Classes of com.box.boxjavalibv2.filetransfer.IFileTransferListener

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.