使用RTC API从ProjectArea获取流 [英] Get Stream from ProjectArea using RTC API 4

查看:176
本文介绍了使用RTC API从ProjectArea获取流的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我一直在尝试使用projectArea获取流名称。
我有以下参数:
存储库
IFileItem
WorkItem及其ChangeSets

Hello I have been trying to get the stream name using projectArea. I have the following parameter: Repository IFileItem WorkItem and its ChangeSets

是否可以获取它。

提前致谢。

请不要给我一个指向顾问示例的链接,因为我已经阅读过它和我无法做到。

Please don't give me a link to the advisor example as I already read it and I couldn't make it.

在这篇文章中,提到了以下内容:
https://jazz.net/forum/questions/49910/how-to-get-an-iconfiguration -from-ichangeset

At this post,it was mentioned the following : https://jazz.net/forum/questions/49910/how-to-get-an-iconfiguration-from-ichangeset


有一个提示通常很有用(但不一定总是
正确),隐藏在ILink中,用作
IChangeSetHandle(源)和IWorkItemHandle(目标)之间的绑定。源端的
IItemReference有一个String extraInfo字段,可以通过IItemReference#getExtraInfo()检索
。此字符串
的格式为IWorkspace =,表示原始
工作空间。您可以使用
IWorkspace.ITEM_TYPE.createItemHandle(suppliedUUID,null)创建IWorkspace的句柄。

There is a hint that is often useful (but not necessarily always correct), hidden in the ILink which serves as the binding between the IChangeSetHandle (source) and the IWorkItemHandle (target). The IItemReference for the source side has a String extraInfo field which can be retrieved via IItemReference#getExtraInfo(). This string will be of the format IWorkspace= which indicates the originating workspace. You can create a handle to the IWorkspace by using IWorkspace.ITEM_TYPE.createItemHandle(suppliedUUID, null).



public void testWorkspaceConnection(ITeamRepository repository, IWorkItem workItem) throws TeamRepositoryException, IOException{
       List<ILink> changeSetLinks = (List<ILink>)linkCollection.getLinksById("com.ibm.team.filesystem.workitems.change_set");
       List<IReference> changeSetReferences = new ArrayList<IReference>();

         for (ILink link : changeSetLinks) {
            changeSetReferences.add(link.getSourceRef());
         }

         List<IItemHandle> itemHandles = new ArrayList<IItemHandle>();

         for (IReference reference : changeSetReferences) {
             itemHandles.add((IItemHandle)reference.resolve());
         }

         if(itemHandles.isEmpty()){
             return;
         }

         IItemHandle itemHandle = itemHandles.get(itemHandles.size() - 1);
         IChangeSet changeSet = (IChangeSet)repository.itemManager().fetchCompleteItem(itemHandle, 0, monitor);
         List changes = changeSet.changes();         

         IFileItem fileItem = getLogidiagFile(changeSet, repository);
         // TILL HERE THAT WAS AN EXISTING CODE THAT WAS ALREADY THERE AND IT FETCHES THE REQUIRED FILE.
         //NEXT IS WHAT |'VE ADDED TO BE ABLE TO DETERMINE THE FULL PATH
         String uuid=changeSetReferences.get(changeSetReferences.size()-1).getExtraInfo(); //Here I need to get workspace uuid to be abble to create a connection over as the post said
         IWorkspaceHandle workspaceHandle = (IWorkspaceHandle)IWorkspace.ITEM_TYPE.createItemHandle(UUID.valueOf(uuid), null);

         IWorkspaceManager workspaceManager = SCMPlatform.getWorkspaceManager(repository);
         IWorkspaceConnection workspaceConnection = workspaceManager.getWorkspaceConnection(workspaceHandle,monitor);

我得到的例外情况如下:

Exception I get is the following:


线程main中的异常java.lang.IllegalArgumentException:
UUID [Workspace = _iibA0GlNEeKd76sMjPDLRA]
com.ibm.team.repository.common.UUID.valueOf( UUID.java:76)

Exception in thread "main" java.lang.IllegalArgumentException: invalid UUID [Workspace=_iibA0GlNEeKd76sMjPDLRA] at com.ibm.team.repository.common.UUID.valueOf(UUID.java:76)

我走在正确的路线上还是有更好的路线可以指导我完成!

So am I walking on the right course or there are a better one you can guide me through!

推荐答案

 IWorkspaceManager workspaceManager = SCMPlatform.getWorkspaceManager(repository);

IWorkspaceSearchCriteria wsSearchCriteria = WorkspaceSearchCriteria.FACTORY.newInstance();

wsSearchCriteria.setKind(IWorkspaceSearchCriteria.STREAMS);

wsSearchCriteria.setPartialOwnerNameIgnoreCase(projectAreaName);

List <IWorkspaceHandle> workspaceHandles = workspaceManager.findWorkspaces(wsSearchCriteria, Integer.MAX_VALUE, Application.getMonitor()); 

IWorkspaceConnection workspaceConnection = workspaceManager.getWorkspaceConnection(workspaceHandles.get(0),Application.getMonitor()); 

这篇关于使用RTC API从ProjectArea获取流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆