Using the SDK to get all share

 There has been a lot of pollution on our server with ChangeRequest being shared back and forth between views and sometimes in fdirfferent folders of the same view.

I am trying to do a cleanup routine that will identify all the CR shares starting from the CRs in a given view.

Using the viewmembercollection of the view I can easily get all the CRs.

Then from each CR I can get the Parent and Child Shares.

However, I know that there are many more complex shares involved (ex: Root was shared to two other views, then a share was created in a target view back to the root view, get the picture).

Is there a way to get the entire Share Tree of a CR or do I have to run a complex traverse algorithm that will cover all possible directions?


  • Verified Answer

    Hi Patrick,
    There's an SDK api for that.

    * Returns the shares for this view member.
    * @return All shares of this view member
    public Share[] ViewMember::getAllShares() {

    this returns the share tree for any viewmember, (in your case, a CR is a viewmember)

    you'll need to walk the share tree, and process the shares accordingly.

    from the data structure of the Share object, you can extract the cr's viewmemberid, viewid, projectid, etc, then resolve each share to its corresponding project/view.

    you'll find tests that process the share tree in the test suite, for examples of how to go about doing it...

    take care,
  • Ah, see, I didn't think of going to the viewmember object.