Search in sources :

Example 1 with BoxGroup

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

the class BoxGroupsManager method addGroupMembership.

/**
     * Add a member to group with the specified role.
     * 
     * @param groupId
     *            - the id of group.
     * @param userId
     *            - the id of user to be added to group.
     * @param role
     *            - the role of the user in this group. Can be <code>null</code>
     *            to assign the default role.
     * @return The group information.
     */
public BoxGroupMembership addGroupMembership(String groupId, String userId, BoxGroupMembership.Role role) {
    try {
        LOG.debug("Adding user(id=" + userId + ") as member to group(id=" + groupId + (role == null ? ")" : ") with role=" + role.name()));
        if (groupId == null) {
            throw new IllegalArgumentException("Parameter 'groupId' can not be null");
        }
        if (userId == null) {
            throw new IllegalArgumentException("Parameter 'userId' can not be null");
        }
        BoxGroup group = new BoxGroup(boxConnection, groupId);
        BoxUser user = new BoxUser(boxConnection, userId);
        return group.addMembership(user, role).getResource();
    } 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 : BoxGroup(com.box.sdk.BoxGroup) BoxAPIException(com.box.sdk.BoxAPIException) BoxUser(com.box.sdk.BoxUser)

Example 2 with BoxGroup

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

the class BoxGroupsManager method deleteGroup.

/**
     * Delete group.
     * 
     * @param groupId
     *            - the id of group to delete.
     */
public void deleteGroup(String groupId) {
    try {
        LOG.debug("Deleting group(" + groupId + ")");
        if (groupId == null) {
            throw new IllegalArgumentException("Parameter 'groupId' can not be null");
        }
        BoxGroup group = new BoxGroup(boxConnection, groupId);
        group.delete();
    } 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 : BoxGroup(com.box.sdk.BoxGroup) BoxAPIException(com.box.sdk.BoxAPIException)

Example 3 with BoxGroup

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

the class BoxGroupsManager method getGroupMemberships.

/**
     * Get information about all of the group memberships for this group.
     * 
     * @param groupId
     *            - the id of group.
     * @return The group information.
     */
public Collection<BoxGroupMembership.Info> getGroupMemberships(String groupId) {
    try {
        LOG.debug("Getting information about all memberships for group(id=" + groupId + ")");
        if (groupId == null) {
            throw new IllegalArgumentException("Parameter 'groupId' can not be null");
        }
        BoxGroup group = new BoxGroup(boxConnection, groupId);
        return group.getMemberships();
    } 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 : BoxGroup(com.box.sdk.BoxGroup) BoxAPIException(com.box.sdk.BoxAPIException)

Example 4 with BoxGroup

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

the class BoxGroupsManager method getGroupInfo.

/**
     * Get group information.
     * 
     * @param groupId
     *            - the id of group.
     * @return The group information.
     */
public BoxGroup.Info getGroupInfo(String groupId) {
    try {
        LOG.debug("Getting info for group(id=" + groupId + ")");
        if (groupId == null) {
            throw new IllegalArgumentException("Parameter 'groupId' can not be null");
        }
        BoxGroup group = new BoxGroup(boxConnection, groupId);
        return group.getInfo();
    } 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 : BoxGroup(com.box.sdk.BoxGroup) BoxAPIException(com.box.sdk.BoxAPIException)

Aggregations

BoxAPIException (com.box.sdk.BoxAPIException)4 BoxGroup (com.box.sdk.BoxGroup)4 BoxUser (com.box.sdk.BoxUser)1