Hi all,
I'm trying to use the Plain Java Client to get change set information from a work item. I've got to the point where I have a List of IItemHandles for all the change sets linked with the work item. Now I need to use these handles to get a List of IChangeSets.
public static void getChangeSets(ITeamRepository repository, IWorkItem workItem, IProgressMonitor monitor) {
//Get an IReference to the work item.
ILinkManager linkManager = (ILinkManager) repository.getClientLibrary(ILinkManager.class);
IReferenceFactory referenceFactory = linkManager.referenceFactory();
IReference workItemReference = referenceFactory.createReferenceToItem(workItem.getItemHandle());
//Find all ILinks which attach a change set to the work item.
ILinkQueryPage linkQueryPage = linkManager.findLinksByTarget("com.ibm.team.filesystem.workitems.change_set", workItemReference, monitor);
ILinkCollection linkCollection = linkQueryPage.getAllLinksFromHereOn();
//Put the ILinks in a list.
List<ILink> changeSetLinks = (List<ILink>)linkCollection.getLinksById("com.ibm.team.filesystem.workitems.change_set");
//Convert each ILink to an IReference to the change set.
List<IReference> changeSetReferences = new ArrayList<IReference>();
for (ILink link : changeSetLinks) {
changeSetReferences.add(link.getSourceRef());
}
//Convert each IReference to an IItemHandle.
List<IItemHandle> itemHandles = new ArrayList<IItemHandle>();
for (IReference reference : changeSetReferences) {
itemHandles.add((IItemHandle)reference.resolve());
}
//Convert each IItemHandle to an IChangeSet.
List<IChangeSet> changeSets = new ArrayList<IChangeSet>();
for (IItemHandle itemHandle : itemHandles) {
changeSets.add((IChangeSet)repository.itemManager().fetchCompleteItem(itemHandle, 0, monitor)); //ERROR HERE.
}
return;
}
When I run this I get the following PermissionDeniedException error.
Exception in thread "main" java.lang.RuntimeException: com.ibm.team.repository.common.PermissionDeniedException: CRJAZ1319E Illegal read access: User "tom.foyle@uk.ibm.com" attempted to read item(s) having the following type(s): ChangeSet
at snippets.RtcAccess.getChangeSets(RtcAccess.java:231)
at snippets.RtcAccess.main(RtcAccess.java:87)
Caused by: com.ibm.team.repository.common.PermissionDeniedException: CRJAZ1319E Illegal read access: User "tom.foyle@uk.ibm.com" attempted to read item(s) having the following type(s): ChangeSet
at com.ibm.team.repository.client.internal.ItemManager.internalFetchItem(ItemManager.java:1579)
at com.ibm.team.repository.client.internal.ItemManager.access$0(ItemManager.java:1538)
at com.ibm.team.repository.client.internal.ItemManager$AbstractStore.retrieveItem(ItemManager.java:186)
at com.ibm.team.repository.client.internal.ItemManager$CurrentStore.fetchItem(ItemManager.java:311)
at com.ibm.team.repository.client.internal.ItemManager.fetchCompleteItem(ItemManager.java:824)
at snippets.RtcAccess.getChangeSets(RtcAccess.java:226)
Is there some way I can get the required permission to access change sets? Or is there something else I'm doing wrong? Thanks for any help or suggestions.
Tom