Collaborations are used to share folders between users or groups. They also define what permissions a user has for a folder.
- Add a Collaboration
- Edit a Collaboration
- Remove a Collaboration
- Get a Collaboration's Information
- Get the Collaborations on a Folder
- Get Pending Collaborations
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);
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);
A collaboration can be removed by calling delete()
.
BoxCollaboration collaboration = new BoxCollaboration(api, "id");
collaboration.delete();
Calling getInfo()
on a collaboration returns a snapshot of the
collaboration's info.
BoxCollaboration collaboration = new BoxCollaboration(api, "id");
BoxCollaboration.Info info = collaboration.getInfo();
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();
A collection of all the user's pending collaborations can be retrieved with
getPendingCollaborations(BoxAPIConnection)
.
Collection<BoxCollaboration.Info> pendingCollaborations =
BoxCollaboration.getPendingCollaborations(api);