Package com.box.boxjavalibv2.javafxoauth.sample

Examples of com.box.boxjavalibv2.javafxoauth.sample.SampleOAuthCaller


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


    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

    }

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

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

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

    @Test
    public void testGetEmailAliases() throws Exception {
        final BoxUser enterpriseUser = createEnterpriseUser();

        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.restclientv2.requestsbase.BoxDefaultRequestObject
//            headers.put("CamelBox.defaultRequest", null);

            List result = requestBodyAndHeaders("direct://GETEMAILALIASES", null, headers);

            assertNotNull("getEmailAliases result", result);
            LOG.debug("getEmailAliases: " + result);
        } finally {
            deleteEnterpriseUser(enterpriseUser.getId());
        }
    }
View Full Code Here

    }

    @Ignore("Developer account errors out with 'This does not currently support moving content into non-root folders'")
    @Test
    public void testMoveFolderToAnotherUser() throws Exception {
        final BoxUser enterpriseUser = createEnterpriseUser();

        try {
            final String toUserId = enterpriseUser.getId();
            moveTestFolder(testUserId, toUserId);
            moveTestFolder(toUserId, testUserId);
        } finally {
            deleteEnterpriseUser(enterpriseUser.getId());
        }
    }
View Full Code Here

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

    @Test
    public void testUpdateUserInformaiton() throws Exception {
        final BoxUser enterpriseUser = createEnterpriseUser();

        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);
            assertEquals("updateUserInformaiton job title", CAMEL_JOB_TITLE, result.getJobTitle());
            LOG.debug("updateUserInformaiton: " + result);
        } finally {
            deleteEnterpriseUser(enterpriseUser.getId());
        }
    }
View Full Code Here

    }

    @Ignore("Requires multiple confirmed email aliases, do disabled by default")
    @Test
    public void testUpdateUserPrimaryLogin() throws Exception {
        final BoxUser enterpriseUser = createEnterpriseUser();

        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);

            assertNotNull("updateUserPrimaryLogin result", result);
            assertEquals("updateUserPrimaryLogin primary login", UPDATED_EMAIL_ALIAS, result.getLogin());
            LOG.debug("updateUserPrimaryLogin: " + result);
        } finally {
            deleteEnterpriseUser(enterpriseUser.getId());
        }
    }
View Full Code Here

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

    private BoxCollaboration createCollaboration() throws InterruptedException {
        final Map<String, Object> headers = new HashMap<String, Object>();
        // parameter type is String
        headers.put("CamelBox.folderId", testFolderId);
        // parameter type is com.box.boxjavalibv2.requests.requestobjects.BoxCollabRequestObject
        final BoxCollabRequestObject collabObject = BoxCollabRequestObject.createCollabObject(testFolderId, null,
                "camel.test@localhost.com", BoxCollaborationRole.VIEWER);
        headers.put("CamelBox.collabRequest", collabObject);

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

        try {
            final Map<String, Object> headers = new HashMap<String, Object>();
            // parameter type is String
            headers.put("CamelBox.collabId", collaboration.getId());
            // parameter type is com.box.boxjavalibv2.requests.requestobjects.BoxCollabRequestObject
            final BoxCollabRequestObject requestObject = BoxCollabRequestObject.updateCollabObjects(
                    BoxCollaborationRole.EDITOR);
            headers.put("CamelBox.collabRequest", requestObject);

            BoxCollaboration result = requestBodyAndHeaders("direct://UPDATECOLLABORATION", null, headers);
            assertNotNull("updateCollaboration result", result);
View Full Code Here

TOP

Related Classes of com.box.boxjavalibv2.javafxoauth.sample.SampleOAuthCaller

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.