RTC SCM API : Identify Streams which doesnt belong to folder
Accepted answer
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();
queryParams.setContainer(parent);
queryParams.setFlags(IItemContainerService.QUERY_CHECK_ACCESSIBLE);
IItemContainerService folderService = SCMPlatform.getWorkspaceManager(getRepository()).getItemContainerService();
IItemContainerQueryResult result = folderService.getChildren(queryParams);
progress.done();
return result;
}
Comments
vinitha dsouza
Feb 10 '21, 4:09 a.m.