Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

How to programmatically get all streams that user has access to? (server side)

 Hi,

  I'm trying to build something that returns all streams that logged user has access to.

  I was unable to get proper services within IValueSetProvider (getPeer and requiredInterfaces doesn't works).

  So my idea is to build a RestService (based on https://jazz.net/library/LearnItem.jsp?href=content/docs/web-ui-programming/web-ui-todo-rest.html)

  I'm able to get the contributor with getAuthenticatedContributor(). But now, I want to find all streams that this user has access to.

  My first approach was to use IScmQueryService. Using findWorkspace() method requires IWorkspaceSearchCriteria, but this method doesn't give me option for a "access" criteria, only owner criteria (which can be ProjectArea or TeamArea or Contributor...)

  I'm afraid that I'll have to use IProcessService.findTeamAreas to find out all user's team areas, then loop those team areas using IScmQueryService.findWorkspace() passing ownerName = TeamArea Name...

   Is there an easier way to do it? Please say "yes" :)

  

    

0 votes



3 answers

Permanent link
You can use the getFilterByOwnerOptional() List in IWorkspaceSearchCriteria to append the project areas' and team areas' IProcessAreaHandles. When you ask the server for the workspaces, it will already filter out any streams that are owned by a team area that the currently logged in user is not a part of (assuming the visibility has been set as such).

That is, consider a stream X owned by team area Y whose visibility is set to be private to the team area. If I ask the server to return the list of streams owned by team area Y, it will not return stream X if I am not a member of team area Y.

1 vote


Permanent link
What does access mean? Read access? Write Access?

I don't think it would be that easy. I am not sure how to approach this. You would have to evaluate which roles in which team areas a user has and then, from the ownership and the visibility of a stream deduce if the user has access to it.

This is certainly going to be complex. If you are logged in as a user you could get all the streams and would only get the ones you have read access to, I believe. The permission aware API should only show these.


0 votes

Comments
Read access is fine.

There must to exist some internal function that does that. Because it is just what we see in IDE Client when we expand "Source Control" item, a list of streams that are visible to the user.


I'll investigate a little more. Thanks.

If your use case would be clearer, there might be ways. However, the API that shows the views works with a certain user being logged in and provided him with what he can see. If you want to do the same with a different user being logged in (to create a report) it is an entirely different approach that could be very hard. See http://rsjazz.wordpress.com/2013/09/24/managing-workspaces-streams-and-components-using-the-plain-java-client-libraries/ for some clues - however, this is client code.


Permanent link
 My use case would be something like:

   An workitem has an attribute for StreamName and another for ComponentName.

  1. The user creates an work item and choose a value for the attribute StreamName (String), using presentation "Value Set Picker". The values presented to user would be only the names of streams that user has at least read access.

  2. After that, the user choose a value  for the attribute ComponentName (String), using another presentation "Value Set Picker". The value presented to the user would be only components added to the stream previously choosed

Currently I have this solution:

  The StreamName attribute is choosed with a 'HTTP Filtered Value Set' that points to the URL: 
'https://jazzserver/ccm/rpt/repository/scm?size=600&fields=scm/workspace[stream=true]/name

  But this returns every existing streams. (note parameter 'size=600', soon I'll have to increase this value to return more results)

  And the 'ComponentName' attribute is choosed with another 'HTTP Filtered Value Set' that points to the URL: 
'https://jazzserver/ccm/rpt/repository/scm?size=900&fields=scm/component/*

  This also returns every component in repository.

  I tried to use Java Value Sets, but I was unable to instantiate needed services. Now, my approach is to create webservices that provides the corrects names. And use 'HTTP Filtered Value Set' to get it in workitem.



0 votes

Comments

I would be interested in the solution to that use case too. However, I don't have the time currently to look into it.

I would look into Java Value Provider https://rsjazz.wordpress.com/2013/06/26/attribute-customization-java-based-value-providers-conditions-and-validators/. The issue here is that you only have the IWorkItemCommon interface. This leads to AudibleCommon. As getPeer() is deprecated, I don't know how to get to the SCM service. Also, as this has to run in the server as well as in the client,it would have to run on common interfaces only.

Your answer

Register or log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,938
× 137
× 79
× 19

Question asked: Sep 10 '14, 12:34 p.m.

Question was seen: 6,150 times

Last updated: Sep 12 '14, 10:40 a.m.

Confirmation Cancel Confirm