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

Error programmatically getting approvals

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

0 votes



One answer

Permanent link
 Hello Susan,
this article https://jazz.net/library/article/1118
might help you here.

Thanks.
Eric.

0 votes

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,

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.

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

Question asked: Mar 19 '13, 6:53 a.m.

Question was seen: 4,408 times

Last updated: Mar 22 '13, 12:46 a.m.

Confirmation Cancel Confirm