1

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

Is it possible to get it.

Thanks in advance.

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

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

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:

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!

Echo
  • 2,959
  • 15
  • 52
  • 65
  • "I couldn't make it"? I would help if you edited your question with the exact code you tried and the error message you got :) – VonC Feb 22 '13 at 06:48
  • Sure .. I've updated my question above. – Echo Feb 22 '13 at 09:57
  • Can you replace "`UUID.valueOf(uuid)`" by `_iibA0GlNEeKd76sMjPDLRA`, and see if that work? – VonC Feb 22 '13 at 10:18
  • I have replaced it with IWorkspaceHandle workspace = (IWorkspaceHandle) IWorkspace.ITEM_TYPE.createItemHandle(UUID.valueOf("_iibA0GlNEeKd76sMjPDLRA"), null); – Echo Feb 22 '13 at 11:46
  • It didn't throw exception at creation of IWorkspaceHandle but it throws an exception at creating workspaceconnection:com.ibm.team.repository.common.ItemNotFoundException: CRJAZ0215I The following record was not found in the database: com.ibm.team.scm.common.internal.impl.WorkspaceHandleImpl@70c970c9 (stateId: null, itemId: [UUID _iibA0GlNEeKd76sMjPDLRA], origin: , immutable: ) at com.ibm.team.scm.client.internal.WorkspaceManager.getWorkspaceConnection(WorkspaceManager.java:865) – Echo Feb 22 '13 at 11:48

1 Answers1

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()); 
Echo
  • 2,959
  • 15
  • 52
  • 65