public static EventLog getEnterpriseEvents(BoxAPIConnection api, String position, Date after, Date before,
                                               int limit, BoxEvent.Type... types) {

        URL url = ENTERPRISE_EVENT_URL_TEMPLATE.build(api.getBaseURL());

        if (position != null || types.length > 0 || after != null
            || before != null || limit != ENTERPRISE_LIMIT) {
            QueryStringBuilder queryBuilder = new QueryStringBuilder(url.getQuery());

            if (after != null) {
                queryBuilder.appendParam("created_after",
                    BoxDateFormat.format(after));
            }

            if (before != null) {
                queryBuilder.appendParam("created_before",
                    BoxDateFormat.format(before));
            }

            if (position != null) {
                queryBuilder.appendParam("stream_position", position);
            }

            if (limit != ENTERPRISE_LIMIT) {
                queryBuilder.appendParam("limit", limit);
            }

            if (types.length > 0) {
                StringBuilder filterBuilder = new StringBuilder();
                for (BoxEvent.Type filterType : types) {
                    filterBuilder.append(filterType.name());
                    filterBuilder.append(',');
                }
                filterBuilder.deleteCharAt(filterBuilder.length() - 1);
                queryBuilder.appendParam("event_type", filterBuilder.toString());
            }

            try {
                url = queryBuilder.addToURL(url);
            } catch (MalformedURLException e) {
                throw new BoxAPIException("Couldn't append a query string to the provided URL.");
            }
        }

        BoxAPIRequest request = new BoxAPIRequest(api, url, "GET");
        BoxJSONResponse response = (BoxJSONResponse) request.send();
        JsonObject responseJSON = JsonObject.readFrom(response.getJSON());
        EventLog log = new EventLog(api, responseJSON, position, limit);
        log.setStartDate(after);
        log.setEndDate(before);
        return log;
    }
public static EventLog getEnterpriseEvents ( BoxAPIConnection api , String position , Date after , Date before , int limit , BoxEvent . Type ... types ) { URL url = ENTERPRISE_EVENT_URL_TEMPLATE . build ( api . getBaseURL ( ) ) ; if ( position != null || types . length > 0 || after != null || before != null || limit != ENTERPRISE_LIMIT ) { QueryStringBuilder queryBuilder = new QueryStringBuilder ( url . getQuery ( ) ) ; if ( after != null ) { queryBuilder . appendParam ( "created_after" , BoxDateFormat . format ( after ) ) ; } if ( before != null ) { queryBuilder . appendParam ( "created_before" , BoxDateFormat . format ( before ) ) ; } if ( position != null ) { queryBuilder . appendParam ( "stream_position" , position ) ; } if ( limit != ENTERPRISE_LIMIT ) { queryBuilder . appendParam ( "limit" , limit ) ; } if ( types . length > 0 ) { StringBuilder filterBuilder = new StringBuilder ( ) ; for ( BoxEvent . Type filterType : types ) { filterBuilder . append ( filterType . name ( ) ) ; filterBuilder . append ( ',' ) ; } filterBuilder . deleteCharAt ( filterBuilder . length ( ) - 1 ) ; queryBuilder . appendParam ( "event_type" , filterBuilder . toString ( ) ) ; } try { url = queryBuilder . addToURL ( url ) ; } catch ( MalformedURLException e ) { throw new BoxAPIException ( "Couldn't append a query string to the provided URL." ) ; } } BoxAPIRequest request = new BoxAPIRequest ( api , url , "GET" ) ; BoxJSONResponse response = ( BoxJSONResponse ) request . send ( ) ; JsonObject responseJSON = JsonObject . readFrom ( response . getJSON ( ) ) ; EventLog log = new EventLog ( api , responseJSON , position , limit ) ; log . setStartDate ( after ) ; log . setEndDate ( before ) ; return log ; }
Gets all the enterprise events that occurred within a specified date range, starting from a given position
within the event stream.
@param  api      the API connection to use.
@param  position the starting position of the event stream.
@param  after    the lower bound on the timestamp of the events returned.
@param  before   the upper bound on the timestamp of the events returned.
@param  limit    the number of entries to be returned in the response.
@param  types    an optional list of event types to filter by.
@return          a log of all the events that met the given criteria.