Error getting Contributor of an approval record
I opened this as a PMR but was told that PMR support does not include the Java APIs (which I really find hard to believe).
I have 2 Java programs using the java 4.0.0.1 client. One programmatically adds an approval record of type Verification and adds an approver, and one that generates reports that reads that information.
I am getting an exception randomly on the fetchCompleteState() call java.lang.IllegalArgumentException: itemHandle must not be null and must not have a null state id at com.ibm.team.repository.client.internal.ItemManager.fetchCompleteState(ItemManager.java:1014)
The ContributorHandle that I am attempting to fetch is:
com.ibm.team.repository.common.model.impl.ContributorHandleImpl@a330a33 (stateId: <unset>, itemId: [UUID _YVcmYL87Ed2iU6ePvw_uCw], origin: com.ibm.team.repository.client.internal.TeamRepository@5f775f77, immutable:true)
I can see that the stateId: is <unset> but I do not know why. If I look at the work item that I am getting this on in the 4001 RTC Eclipse client, I see the Verification record and the approver (her name is listed) with a state of Pending. I can also view her profile in the client and there is no error.
The approval record is added programmatically using this method:
private void addWASVerificationApproval(IWorkItem wasWorkItem) {
IApprovals approvals = wasWorkItem.getApprovals();
List<IApprovalDescriptor> adList = approvals.getDescriptors();
String suffix = adList.isEmpty() ? "" : " " + (adList.size() + 1);
IApprovalDescriptor descriptor = approvals.createDescriptor(WorkItemApprovals.VERIFICATION_TYPE.getIdentifier(),
"Verification - created by Bridge" + suffix);
// Create the approval
approvals.add(descriptor);
approvals.add(approvals.createApproval(descriptor, wasWorkItem.getCreator()));
}
You can see I pass in the work item "getCreator()" value, which should (I would think) never be invalid.
Please assist in determining how to resolve this issue.
I have 2 Java programs using the java 4.0.0.1 client. One programmatically adds an approval record of type Verification and adds an approver, and one that generates reports that reads that information.
I am getting an exception randomly on the fetchCompleteState() call java.lang.IllegalArgumentException: itemHandle must not be null and must not have a null state id at com.ibm.team.repository.client.internal.ItemManager.fetchCompleteState(ItemManager.java:1014)
The ContributorHandle that I am attempting to fetch is:
com.ibm.team.repository.common.model.impl.ContributorHandleImpl@a330a33 (stateId: <unset>, itemId: [UUID _YVcmYL87Ed2iU6ePvw_uCw], origin: com.ibm.team.repository.client.internal.TeamRepository@5f775f77, immutable:true)
I can see that the stateId: is <unset> but I do not know why. If I look at the work item that I am getting this on in the 4001 RTC Eclipse client, I see the Verification record and the approver (her name is listed) with a state of Pending. I can also view her profile in the client and there is no error.
The approval record is added programmatically using this method:
private void addWASVerificationApproval(IWorkItem wasWorkItem) {
IApprovals approvals = wasWorkItem.getApprovals();
List<IApprovalDescriptor> adList = approvals.getDescriptors();
String suffix = adList.isEmpty() ? "" : " " + (adList.size() + 1);
IApprovalDescriptor descriptor = approvals.createDescriptor(WorkItemApprovals.VERIFICATION_TYPE.getIdentifier(),
"Verification - created by Bridge" + suffix);
// Create the approval
approvals.add(descriptor);
approvals.add(approvals.createApproval(descriptor, wasWorkItem.getCreator()));
}
You can see I pass in the work item "getCreator()" value, which should (I would think) never be invalid.
Please assist in determining how to resolve this issue.
Accepted answer
there are lots of places in the product code that checks to see if there is a fullstate available (hasFulLState()) before doing the fetchfullState.
I assume they would get an exception just like you.
let me look for an example.
I assume they would get an exception just like you.
let me look for an example.
Comments
1 vote
2 other answers
The code that creates the data is not very helpful. The code that actually fails would be more interesting.
I agree with Sam and would suggest to wrap the code with a try/catch. That way you can find out the source work item and try to figure out what goes wrong. Without looking at the code that provides the data and fails, I can't say more.
I agree with Sam and would suggest to wrap the code with a try/catch. That way you can find out the source work item and try to figure out what goes wrong. Without looking at the code that provides the data and fails, I can't say more.
So the code that reads it looks like this:
List<IApproval> individualApprovals = approvals.getContents();
for (IApproval approval : individualApprovals) {
IApprovalDescriptor descrip = approval.getDescriptor();
if (descrip.getTypeIdentifier().equals("com.ibm.team.workitem.approvalType.verification")) {
if (approval.getStateIdentifier().equals("com.ibm.team.workitem.approvalState.pending")) {
IContributorHandle owner = approval.getApprover();
IContributor = myRepository.itemManager().fetchCompleteState(owner,null);
}
}
}
I am looking for pending verification records, and for each of those, I need to pull out the Contributors name and emailAddress.
I switched from itemManager to auditableClient and it seems to have resolved this issue on the one I was getting the error on. I am running through the entire report now just to confirm.
Thanks for the pointer/suggestion.
S
List<IApproval> individualApprovals = approvals.getContents();
for (IApproval approval : individualApprovals) {
IApprovalDescriptor descrip = approval.getDescriptor();
if (descrip.getTypeIdentifier().equals("com.ibm.team.workitem.approvalType.verification")) {
if (approval.getStateIdentifier().equals("com.ibm.team.workitem.approvalState.pending")) {
IContributorHandle owner = approval.getApprover();
IContributor = myRepository.itemManager().fetchCompleteState(owner,null);
}
}
}
I am looking for pending verification records, and for each of those, I need to pull out the Contributors name and emailAddress.
I switched from itemManager to auditableClient and it seems to have resolved this issue on the one I was getting the error on. I am running through the entire report now just to confirm.
Thanks for the pointer/suggestion.
S
Comments
1 vote