It's all about the answers!

Ask a question

RTC SCM API : Identify Streams which doesnt belong to folder

vinitha dsouza (1211259) | asked Jan 20, 7:40 a.m.
Dear Team,

rtc version:

we are using RTC Feature of Folders to group our Streams to avoid crowding of streams.
this is currently working well for us and colleagues directly to their folders to see relevant streams for Project.

This permission is not given to users, as this has to be at project area level.
as there will be lot of streams created and we would like to help users to add this relevant folder without coming to us.

But problem here, we do not have option to really check which streams are added to folder and not. For this we  have manually check.

Could you please provide some examples or options, how i can get such information.

for example :
Stream name, Folder name
Stream x, ab14
Stream y,  no folder assigned.

We would like to use such a report and do for ones which are not under any folder.

vinitha dsouza commented Feb 10, 4:09 a.m. | edited Feb 10, 4:09 a.m.
Dear team,

can any one of you update on this?


Accepted answer

permanent link
David Lafreniere (4.6k7) | answered Feb 11, 10:38 a.m.
edited Feb 11, 10:45 a.m.
You will have to write your own plain-Java code to go fetch all the 'folders' in a given Project Area, and then to the fetch the items in those folders (ex: to see if they contain the stream you are interested in). As you traverse the folder hierarchy, you can build up your own data structure in what ever form is easiest to address your use cases.
Note: A stream could exist in multiple folders.

Here is some sample client-side code to do this (server-side code can be seen in IItemContainerService):

IItemContainerHandle rootNode; // Note: All Project Areas have an invisible 'rootNode'
IItemContainerService folderService = SCMPlatform.getWorkspaceManager(getRepository()).getItemContainerService();
        rootNode= folderService.getRootContainer(IWorkspaceManager.ROOT_FOLDER_ID, getProjectAreaHandle(), IItemContainerService.FLAG_NONE);

IItemContainerQueryResult queryResult = runContainerQuery(rootNode, monitor);
// queryResult.getItems() gives a list of IItemHandle (you can safely cast them to this)... if you know the stream itemId then you can just check if it exists in this returned list
// some of the items in this list could be streams (IWorkspaceHandle) or folders (ItemContainerHandle), and potentially other types...

    private IItemContainerQueryResult runContainerQuery(IItemContainerHandle parent, IProgressMonitor monitor) throws TeamRepositoryException {
        SubMonitor progress = SubMonitor.convert(monitor, 100);
        ItemContainerQueryParams queryParams = DtoFactory.eINSTANCE.createItemContainerQueryParams();
        IItemContainerService folderService = SCMPlatform.getWorkspaceManager(getRepository()).getItemContainerService();
        IItemContainerQueryResult result = folderService.getChildren(queryParams);
        return result;

vinitha dsouza selected this answer as the correct answer

vinitha dsouza commented Feb 15, 7:49 a.m.
let us give a try and come back :)
thank you

Your answer

Register or to post your answer.