Package com.box.boxjavalibv2.requests.requestobjects

Examples of com.box.boxjavalibv2.requests.requestobjects.BoxUserRequestObject


        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

        String key2 = "testkey2";
        String value2 = "testvalue2";
        LinkedHashMap<String, String> codes = new LinkedHashMap<String, String>();
        codes.put(key1, value1);
        codes.put(key2, value2);
        BoxUserRequestObject obj = getUserRequestObject(login, name, role, language, sync, title, phone, address, space, codes, seeManaged, status,
            exemptLimit, exemptLogin);
        CreateEnterpriseUserRequest request = new CreateEnterpriseUserRequest(CONFIG, JSON_PARSER, obj);
        testRequestIsWellFormed(request, TestUtils.getConfig().getApiUrlAuthority(),
            TestUtils.getConfig().getApiUrlPath().concat(CreateEnterpriseUserRequest.getUri()), HttpStatus.SC_CREATED, RestMethod.POST);
View Full Code Here

        assertEqualStringEntity(obj, entity);
    }

    private BoxUserRequestObject getUserRequestObject(String login, String name, String role, String language, boolean sync, String title, String phone,
        String address, double space, LinkedHashMap<String, String> codes, boolean seeManaged, String status, boolean exemptLimit, boolean exemptLogin) {
        BoxUserRequestObject obj = BoxUserRequestObject.createEnterpriseUserRequestObject(login, name);
        obj.setRole(role);
        obj.setLanguage(language);
        obj.setSyncEnabled(sync);
        obj.setJobTitle(title);
        obj.setPhone(phone);
        obj.setAddress(address);
        obj.setSpaceAmount(space);
        obj.setTrackingCodes(codes);
        obj.setCanSeeManagedUsers(seeManaged);
        obj.setStatus(status);
        obj.setExemptFromDeviceLimits(exemptLimit);
        obj.setExemptFromLoginVerification(exemptLogin);
        return obj;
    }
View Full Code Here

        String key2 = "testkey2";
        String value2 = "testvalue2";
        LinkedHashMap<String, String> codes = new LinkedHashMap<String, String>();
        codes.put(key1, value1);
        codes.put(key2, value2);
        BoxUserRequestObject obj = getUserRequestObject(notify, name, role, language, sync, title, phone, address, space, codes, seeManaged, exemptLimit,
            exemptLogin);
        if (removeEnterprise) {
            obj.setEnterprise(null);
        }
        obj.setMaxUploadSize(1000d);
        obj.setAvatarUrl("http://testboxavatarurl.com");
        obj.setMyTags("mytaga","mytagb");
        UpdateUserRequest request = new UpdateUserRequest(CONFIG, JSON_PARSER, userId, obj);
        testRequestIsWellFormed(request, TestUtils.getConfig().getApiUrlAuthority(),
            TestUtils.getConfig().getApiUrlPath().concat(UpdateUserRequest.getUri(userId)), HttpStatus.SC_OK, RestMethod.PUT);

        Assert.assertEquals(Boolean.toString(notify), request.getQueryParams().get("notify"));
View Full Code Here

        assertEqualStringEntity(obj, en);
    }

    private BoxUserRequestObject getUserRequestObject(boolean notify, String name, String role, String language, boolean sync, String title, String phone,
        String address, double space, LinkedHashMap<String, String> codes, boolean seeManaged, boolean exemptLimit, boolean exemptLogin) {
        BoxUserRequestObject obj = BoxUserRequestObject.updateUserInfoRequestObject(notify);
        obj.setRole(role);
        obj.setLanguage(language);
        obj.setSyncEnabled(sync);
        obj.setJobTitle(title);
        obj.setPhone(phone);
        obj.setAddress(address);
        obj.setSpaceAmount(space);
        obj.setTrackingCodes(codes);
        obj.setCanSeeManagedUsers(seeManaged);
        obj.setExemptFromDeviceLimits(exemptLimit);
        obj.setExemptFromLoginVerification(exemptLogin);
        return obj;
    }
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.requests.requestobjects.BoxUserRequestObject

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.