Error programmatically getting approvals
java.lang.IllegalArgumentException: itemHandle must not be null and must not have a null state id
com.ibm.team.repository.common.model.impl.ContributorHandleImpl@41104110 (stateId: <unset>, itemId: [UUID _4TNJsCxDEd-osPt1oXgcDw], origin: com.ibm.team.repository.client.internal.TeamRepository@4ed44ed4, immutable: true)
at com.ibm.team.repository.client.internal.ItemManager.fetchCompleteState(ItemManager.java:1014)
I've looked at the actual defect approvals on the Approvals tab (in Eclipse client) and I see nothing odd or unique. They have a person actually assigned as an approver and that person is a valid, unarchived person.
I'm not sure why these ones may be unique, so I thought I would ask.
Here is the code I am using.
for (IWorkItem item : items) {
IApprovals approvals = item.getApprovals(); //get the approvals
List<IApproval> individualApprovals = approvals.getContents(); //get each approval
for (IApproval approval : individualApprovals) {
IApprovalDescriptor descrip = approval.getDescriptor();
IContributorHandle owner = approval.getApprover();
String userid = "unableToRetrieve";
try {
IContributor ownerObject = rtcm.getContributorFromHandle(owner);
userid = ownerObject.getUserId();
} catch (Exception e) {
e.printStackTrace();
}
}
}
The getContributorFromHandle() method calls this:
itemManager().fetchCompleteState(handle, monitor);
One answer
Comments
I got a bit more on this ... so out of about 100 work items, I get this error on exactly 4 of them. These 4 I have verified the approval record WITH the actual approver exists (eclipse client). I also didn't find any pattern .. the approvers were different people, the approval record added by different people on different days.
I removed each one and added the approvers back on, and the error seems to have gone away. If it comes back, I'll try to get more investigation done.
Hello Susan,
A bit more info ..I hit a new error today, and asked for details on what the person used to actually create the approval record:
1) did you add this with web client or eclipse client?
Web client
2a) if web: what browser level and on what OS?
Windows 7 64 bit v1.04.00, Firefox 19.0.2
2b) if eclipse client: what client level (from Help->About) and what OS
n/a
My code calls:
IContributor ownerObject = rtcm.getContributorFromHandle(owner); //(RTCM is an RTC Manager which knows how to interact with RTC
The RTC Manager gets the itemManager and, passing in the "owner" handle from above, calls fetchCompleteState(), which is what throws the exception.
itemManager().fetchCompleteState(handle, monitor);