Skip to content

Latest commit

 

History

History
106 lines (78 loc) · 3.9 KB

collaborations.md

File metadata and controls

106 lines (78 loc) · 3.9 KB

Collaborations

Collaborations are used to share folders between users or groups. They also define what permissions a user has for a folder.

Add a Collaboration

A collaboration can be added for an existing user or group with collaborate(BoxCollaborator, BoxCollaboration.Role). The role parameter determines what permissions the collaborator will have on the folder.

BoxCollaborator user = new BoxUser(api, "user-id")
BoxFolder folder = new BoxFile(api, "folder-id");
folder.collaborate(user, BoxCollaboration.Role.EDITOR);

You can also add a collaboration by providing an email address with collaborate(String, BoxCollaboration.Role). If the receipient doesn't have a Box account, they will be asked create one.

BoxFolder folder = new BoxFile(api, "id");
folder.collaborate("[email protected]", BoxCollaboration.Role.EDITOR);

Edit a Collaboration

A collaboration can be edited by creating a new BoxCollaboration.Info object or updating an existing one, and then calling updateInfo(BoxCollaboration.Info)

BoxCollaboration collaboration = new BoxCollaboration(api, "id");
BoxCollaboration.Info info = collaboration.new Info();
info.setStatus(BoxCollaboration.Status.ACCEPTED);
collaboration.updateInfo(info);

Remove a Collaboration

A collaboration can be removed by calling delete().

BoxCollaboration collaboration = new BoxCollaboration(api, "id");
collaboration.delete();

Get a Collaboration's Information

Calling getInfo() on a collaboration returns a snapshot of the collaboration's info.

BoxCollaboration collaboration = new BoxCollaboration(api, "id");
BoxCollaboration.Info info = collaboration.getInfo();

Get the Collaborations on a Folder

You can get all of the collaborations on a folder by calling getCollaborations() on the folder.

BoxFolder folder = new BoxFile(api, "id");
Collection<BoxCollaboration.Info> collaborations = folder.getCollaborations();

Get Pending Collaborations

A collection of all the user's pending collaborations can be retrieved with getPendingCollaborations(BoxAPIConnection).

Collection<BoxCollaboration.Info> pendingCollaborations =
    BoxCollaboration.getPendingCollaborations(api);