I have a java program that runs every morning from my CRM. It walks a folder tree and updates the security for the folders based on the users role in my CRM. It's a fluid environment so I am changing users from editors, to owners or the other way around..... I am trying to find a way to update an existing collaboration object instead of deleting it an recreating it as this sends an email to the user. I can't seem to figure out how to update an existing collaboration. Here is my code below...
// Loop through the property's sub-folders
for (final BoxFolder propertySubfolder : boxService.getSubFolders( propertyFolder ))
{
out.format( " %s%n", propertySubfolder.getInfo().getName() );
// Capture a list of all existing collaborators for later...
List listOfCollaborators = new ArrayList();
for( final BoxCollaboration.Info collaboration : propertySubfolder.getCollaborations() )
{
// Loop through existing collaborators and remove any groups so we can add them later with the appropriate access
if( collaboration.getAccessibleBy() != null )
{
String collabName = collaboration.getAccessibleBy().getName();
if( StringUtils.containsIgnoreCase( listOfGroupEditors.toString(), collabName ) )
{
out.println( " Removing: " + collabName );
collaboration.getResource().delete();
}
else
{
// Add all collaborators in this subfolder to a list for checking if we need to add collaborators later
listOfCollaborators.add( collaboration );
}
}
}
int index;
BoxCollaboration.Info aCollaboration;
// Add the regional directory as an editor
if( regionalDirector != null )
{
// Do we have the collaborator object in the list?
index = findCollaborator( regionalDirector, listOfCollaborators );
if( index == -1 )
{
out.println( " Adding regional director: " + regionalDirector.getInfo().getName() );
propertySubfolder.collaborate( regionalDirector, BoxCollaboration.Role.CO_OWNER );
}
else
{
// Found it so update it
aCollaboration = listOfCollaborators.get( index );
aCollaboration.setRole( BoxCollaboration.Role.CO_OWNER );
// how do I update the collaboration object?????
}
}