Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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

0 votes

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:


IVersionable iv = vmgr.fetchCompleteState(ivhandle, monitor);

That line was originally entered as follows, I had moved it within the "if" earlier to avoid the exception in debugging.

IVersionableHandle ivhandle = change.afterState();
IVersionable iv = vmgr.fetchCompleteState(ivhandle, monitor);
 

showing 5 of 6 show 1 more comments


One answer

Permanent link
this means that A change record might not have an 'after' state.


afterState()
Returns the "after" state of the versionable item, or null if the change is the deletion of a versionable item from the configuration.

1 vote

Comments

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.

that is also the 1st time you have attempted to use the vmgr object..

I do so like debugging  interactively thru these kinds of issues

Your answer

Register or log in to post 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,938
× 149
× 33

Question asked: Jun 17 '14, 4:23 p.m.

Question was seen: 5,450 times

Last updated: Jun 17 '14, 6:38 p.m.

Confirmation Cancel Confirm