Search in sources :

Example 1 with EventLog

use of com.box.sdk.EventLog in project camel by apache.

the class BoxEventLogsManager method getEnterpriseEvents.

/**
     * Create an event stream with optional starting initial position and add
     * listener that will be notified when an event is received.
     * 
     * @param position
     *            - the starting position of the event stream. May be
     *            <code>null</code> in which case all events within bounds
     *            returned.
     * @param after
     *            - the lower bound on the timestamp of the events returned.
     * @param after
     *            - the upper bound on the timestamp of the events returned.
     * @param types
     *            - an optional list of event types to filter by.
     * 
     * @return A list of all the events that met the given criteria.
     */
public List<BoxEvent> getEnterpriseEvents(String position, Date after, Date before, BoxEvent.Type... types) {
    try {
        LOG.debug("Getting all enterprise events occuring between " + (after == null ? after : SimpleDateFormat.getDateTimeInstance().format(after)) + " and " + (before == null ? before : SimpleDateFormat.getDateTimeInstance().format(before)) + (position == null ? position : (" starting at " + position)));
        if (after == null) {
            throw new IllegalArgumentException("Parameter 'after' can not be null");
        }
        if (before == null) {
            throw new IllegalArgumentException("Parameter 'before' can not be null");
        }
        if (types == null) {
            types = new BoxEvent.Type[0];
        }
        EventLog eventLog = EventLog.getEnterpriseEvents(boxConnection, position, after, before, types);
        List<BoxEvent> results = new ArrayList<BoxEvent>();
        for (BoxEvent event : eventLog) {
            results.add(event);
        }
        return results;
    } catch (BoxAPIException e) {
        throw new RuntimeException(String.format("Box API returned the error code %d\n\n%s", e.getResponseCode(), e.getResponse()), e);
    }
}
Also used : BoxEvent(com.box.sdk.BoxEvent) EventLog(com.box.sdk.EventLog) ArrayList(java.util.ArrayList) BoxAPIException(com.box.sdk.BoxAPIException)

Aggregations

BoxAPIException (com.box.sdk.BoxAPIException)1 BoxEvent (com.box.sdk.BoxEvent)1 EventLog (com.box.sdk.EventLog)1 ArrayList (java.util.ArrayList)1