您好我一直在尝试使用projectArea获取流名称。 我有以下参数: 知识库 IFileItem WorkItem及其ChangeSet
是否有可能得到它。
提前致谢。
请不要给我一个指向顾问示例的链接,因为我已经阅读过了,但我无法做到。
在这篇文章中,提到了以下内容: https://jazz.net/forum/questions/49910/how-to-get-an-iconfiguration-from-ichangeset
有一个通常有用的提示(但不一定总是如此) 正确),隐藏在ILink中,作为之间的绑定 IChangeSetHandle(源代码)和IWorkItemHandle(目标)。该 源端的IItemReference有一个String extraInfo字段 可以通过IItemReference#getExtraInfo()检索。这个字符串会 格式为IWorkspace =表示原始格式 工作区。您可以使用创建IWorkspace的句柄 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);
我得到的例外情况如下:
线程“main”中的异常java.lang.IllegalArgumentException:无效 UUID [Workspace = _iibA0GlNEeKd76sMjPDLRA] at com.ibm.team.repository.common.UUID.valueOf(UUID.java:76)
我是走在正确的路线上还是有更好的方法可以指导我完成!
答案 0 :(得分:1)
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());