Java API extending - IVersionableManager unable to fetchCompleteState
Hi,
I want to download a file from a change set that is linked to a work item. I am using RTC 4.0.3. I find the work item by it's id and am able to populate an IChange List with the change set contents, but I am unable to call fetchCompleteState without an exception. ivhandle.hasFullState always returns false although it appears to have an itemId and stateId. Any ideas what I am doing wrong?
IWorkItemClient workItemClient = (IWorkItemClient) repo.getClientLibrary(IWorkItemClient.class);
IWorkItem workItem = workItemClient.findWorkItemById(id, IWorkItem.FULL_PROFILE, monitor);
IWorkItemCommon common = (IWorkItemCommon) ((ITeamRepository) workItem.getOrigin()).getClientLibrary(IWorkItemCommon.class);
IWorkItemReferences references = common.resolveWorkItemReferences(workItem, monitor);
List<IEndPointDescriptor> types = references.getTypes();
IVersionableManager vmgr = (IVersionableManager) repo.getClientLibrary(IVersionableManager.class);
for (IEndPointDescriptor endpointDescriptor : types) {
List<IReference> refList = references.getReferences(endpointDescriptor);
for (IReference iref : refList) {
URI uri = iref.createURI();
Location location = Location.location(uri);
IAuditableClient auditableClient = (IAuditableClient) repo.getClientLibrary(IAuditableClient.class);
IChangeSet cs = (IChangeSet) auditableClient.resolveAuditableByLocation(location, ItemProfile.createFullProfile(location.getItemType()), monitor);
List<IChange> changes = cs.changes();
for (IChange change : changes) {
System.out.println("change tostring = " + change.toString());
IVersionableHandle ivhandle = change.afterState();
if (ivhandle.hasFullState() == true) {
IVersionable iv = vmgr.fetchCompleteState(ivhandle, monitor);
System.out.println("iv name = " + iv.getName());
}
else {
System.out.println("ivhandle does not have a full state");
}
}
}
}
TIA for any assistance anyone can provide.
Peter
showing 5 of 6
show 1 more comments
|
One answer
this means that A change record might not have an 'after' state.
Comments
Peter Moraza
commented Jun 17 '14, 5:54 p.m.
That is interesting. In my case the change is an addition of a new set of files to the repository. When I print change.toString() I see the following:
change tostring = com.ibm.team.scm.common.internal.impl.ChangeImpl@7ee87ee8 (internalId: [UUID _sN5jtOpzEeO_MsKtwSaYJA]) (kind: 1, before: null, after: [UUID _sM7TU-pzEeO_MsKtwSaYJA])
My IVersionableHandle object has populated itemId ad stateId attributes, but some others like origin are null.
My requirement is to download a copy of one of the change set files to the local file system. As far as you know, do all properties of the IVersionableHandle object need to be non-null?
its unlikely that any object MUST be completely non-null.
|
Your answer
Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.
Comments
what is the reported exception ?
I get a java.lang.NullPointerException
here?
> if (ivhandle.hasFullState() == true) {
or which line of above
Forget to mention there is no additional detail at all in the exception to help in troubleshooting. I see that IChangeSet.changes should not return null, so am wondering if I'm somehow missing a prerequisite step before the call to changes().
The exception is thrown at the following line:
The exception is thrown at the following line: