Collaboration Invites Create An Account

回答済み
新規投稿

コメント

12件のコメント

  • srieger

    The title of this should be Trying to Update Collaboration Object

    0
    コメントアクション パーマリンク
  • cbetta

     I think if you pass "notify=false" as a query parameter to the API call it should silent all notifications.

     

    https://github.com/box/box-java-sdk/blob/master/src/main/java/com/box/sdk/BoxCollaboration.java#L59

    0
    コメントアクション パーマリンク
  • srieger

    , I went through the java sdk and saw that parameter in the low level code but sadly the methods that I am using exclude those parameters as they pass null values to the underlying methods ugh.  

     

     

    public BoxCollaboration.Info collaborate(BoxCollaborator collaborator, BoxCollaboration.Role role) {
            JsonObject accessibleByField = new JsonObject();
            accessibleByField.add("id", collaborator.getID());
    
            if (collaborator instanceof BoxUser) {
                accessibleByField.add("type", "user");
            } else if (collaborator instanceof BoxGroup) {
                accessibleByField.add("type", "group");
            } else {
                throw new IllegalArgumentException("The given collaborator is of an unknown type.");
            }
    
            return this.collaborate(accessibleByField, role, null, null);

     

    0
    コメントアクション パーマリンク
  • cbetta

     ah, that's not right. I'd recommend opening an issue with the SDK team on GitHub to get that added. Clearly seems to be an omission that should be able to get fixed soon.

    0
    コメントアクション パーマリンク
  • srieger

    Good news bad news.  Turns out I can call that method myself.  Who knew.  However, it doesn't work. 😞

     

    My code looks like this now:

    propertySubfolder.collaborate( regionalDirector, BoxCollaboration.Role.CO_OWNER, false, null );
    Still notified the users.
    0
    コメントアクション パーマリンク
  • Jason

    Hey , I think the best thing might be to address your original question around updating a collab. From looking at our docs, we have this laid out:

     

    https://github.com/box/box-java-sdk/blob/master/doc/collaborations.md#edit-a-collaboration

     

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

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

    It looks like this might be what you need re:updating a collab?

     

    Otherwise, the behavior around emails and new collaborations are expected. Emails will always get sent out for those.

     

    From our docs at:

    https://developer.box.com/reference#suppressing-notifications

    User creationcommentcollaboration creationchange user's login, and task assignment notifications cannot be suppressed using this header.

     

    Let us know if you're able to make that collaboration update method work, or if you try something but it doesn't quite get you all the way there.

    0
    コメントアクション パーマリンク
  • srieger

    I agree and would much rather update an existing collaboration. The
    documentation is not clear to me anyhow, how to create a new collaboration.
    Specifically, the parameter "id". Surely I can't use that string "id". So
    how do I come up with the id for that call? In my code, I have the
    existing collaboration.info object . Is there anyway to use that?


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


    Here is my code...
    // Loop through the property's sub-folders
    for (final BoxFolder propertySubfolder : boxService.getSubFolders
    ( propertyFolder ))
    {
    // 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( collabName );
    }
    }
    }

    // Add the regional directory as an editor
    if( regionalDirector != null )
    {
    index = findCollaborator( regionalDirector,
    listOfCollaborators );
    if( index == -1 )
    {
    out.println( " Adding regional director: " +
    regionalDirector.getInfo().getName() );
    propertySubfolder.collaborate( regionalDirector,
    BoxCollaboration.Role.EDITOR, false, null );
    }
    else
    {
    aCollaboration = listOfCollaborators.get( index );
    aCollaboration.setRole( BoxCollaboration.Role.EDITOR );
    // now what?
    }
    }
    }

    0
    コメントアクション パーマリンク
  • Jason

    Good morning !

     

    To answer the question on creating a new collab, the "id" would be the ID of either the file or folder:

    https://github.com/box/box-java-sdk/blob/master/doc/collaborations.md#add-a-collaboration

     

    Those file/folder IDs should be returned when your code is "walking" through the folder structure, presumably here:

     

    //  Loop through the property's sub-folders
    for (final BoxFolder propertySubfolder : boxService.getSubFolders( propertyFolder ))
    {
    	out.format( "  %s%n", propertySubfolder.getInfo().getName() );

    And you'd probably want .getID()

    http://opensource.box.com/box-java-sdk/javadoc/com/box/sdk/BoxResource.Info.html#getID--

     

    However, since it sounds like you are trying to get a file/folder ID based on a collaboration, you can find information about the item in the "item" field on the collaboration:

    https://github.com/box/box-java-sdk/blob/master/doc/collaborations.md#get-a-collaborations-information

     

    An example JSON response from the API on the GET Collaboration Info call can be found at:

    https://developer.box.com/reference#get-collabs

     

    {
        "type": "collaboration",
        "id": "791293",
        "created_by": {
            "type": "user",
            "id": "17738362",
            "name": "sean rose",
            "login": "sean@box.com"
        },
        "created_at": "2012-12-12T10:54:37-08:00",
        "modified_at": "2012-12-12T11:30:43-08:00",
        "expires_at": null,
        "status": "accepted",
        "accessible_by": {
            "type": "user",
            "id": "18203124",
            "name": "sean",
            "login": "sean+test@box.com"
        },
        "role": "editor",
        "acknowledged_at": "2012-12-12T11:30:43-08:00",
        "item": {
            "type": "folder",
            "id": "11446500",
            "sequence_id": "0",
            "etag": "0",
            "name": "Shared Pictures"
        }

    Note the "item" field at the bottom. You would request that "ITEM" field and pull the "id" from there.

     

    0
    コメントアクション パーマリンク
  • srieger

    Thank you so much  for the help.  

     

    Just to provide the solution in case anyone else is looking for it as I was, here is my code....

     

     

    int index;
    BoxCollaboration aCollaboration;
    BoxCollaboration.Info collaborationInfo;
    // Add the regional directory as an editor
    if( regionalDirector != null ) 
    {
    	//  Find the collaboration.info object if we have it...
    	index = findCollaborator( regionalDirector, listOfCollaborators );
    	//  If not found
    	if( index == -1 )
    	{
    		//  Add the collaborator to the subFolder
    		out.println( "  Adding regional director: " + regionalDirector.getInfo().getName() );
    		propertySubfolder.collaborate( regionalDirector, BoxCollaboration.Role.EDITOR, false, null );
    	}
    	else
    	{
    		//  Fetch the collaboration.info object stored above
    		collaborationInfo = listOfCollaborators.get( index );
    		//  Create a new collaboration object using the collaboration.info id
    		aCollaboration = boxService.createBoxCollaboration( collaborationInfo.getID() );
    
    		//  Update the role as needed
    		collaborationInfo.setRole( BoxCollaboration.Role.EDITOR );
    // This doesn't work as it must be pending to accept it.
    // collaborationInfo.setStatus( Status.ACCEPTED );
    // Update the collaboration.
    aCollaboration.updateInfo( collaborationInfo ); } }

     

    0
    コメントアクション パーマリンク
  • holzru

    If it always sends emails for new collaborations then why have the boolean parameter notify that says "Determines if users should receive email notification for the action performed." I am trying to using node api and notify parameter is not being respected

    Here's the code:

     

     

    createCollaboration({ item, accessibleBy, role }, options = {}) {
      return this.request({
        ...options,
        body: {
          item,
          accessible_by: accessibleBy,
          role,
          notify: false,
        },
        method: 'POST',
        path: '/2.0/collaborations/',
      });
    }

     

     
    0
    コメントアクション パーマリンク
  • holzru

    Also side note, all of the box reference links formatted like https://developer.box.com/reference#suppressing-notifications are broken they all forward to the same generic page

     

    0
    コメントアクション パーマリンク
  • holzru

     wrote:

    If it always sends emails for new collaborations then why have the boolean parameter notify that says "Determines if users should receive email notification for the action performed." I am trying to using node api and notify parameter is not being respected

    Here's the code:

     

     

     

     

    createCollaboration({ item, accessibleBy, role }, options = {}) {
      return this.request({
        ...options,
        body: {
          item,
          accessible_by: accessibleBy,
          role,
          notify: false,
        },
        method: 'POST',
        path: '/2.0/collaborations/',
      });
    }

     

     

     

     

    SOLVED

    I was being a dumby, sticking it into the body rather than the query, ignore me 

     

    0
    コメントアクション パーマリンク

サインインしてコメントを残してください。