It's all about the answers!

Ask a question

Error programmatically getting approvals


Susan Hanson (1.6k2201194) | asked Mar 19 '13, 6:53 a.m.
I have some code that reads approvals programmatically.  Most of them I have issues with, but a couple I get an odd error:
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



permanent link
Eric Jodet (6.3k5111120) | answered Mar 19 '13, 11:41 a.m.
JAZZ DEVELOPER
 Hello Susan,
this article https://jazz.net/library/article/1118
might help you here.

Thanks.
Eric.

Comments
Susan Hanson commented Mar 20 '13, 10:05 p.m.

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.


Eric Jodet commented Mar 21 '13, 5:16 a.m.
JAZZ DEVELOPER

 Hello Susan,

as we only have the first line of the stack, not sure which line in your code is failing and causing the IllegalArgumentException

May you please point it out?

Thanks.
Eric.


Susan Hanson commented Mar 22 '13, 12:46 a.m.

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);

Your answer


Register or 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.