It's all about the answers!

Ask a question

How to check if the saving of updated WI is successful?

Guowei Jim Hu (1.0k810353) | asked May 25 '11, 3:05 p.m.
I created a little java application using JazzPlainJava API to add comments to existing work item.

It works well when the updated WI is saved successfully.

But if for some reason the work item doesn't get saved, I have trouble with my logic to check if the new added comment is the same as the string I want to add. As it seems it doesn't matter if the save is good or not, the check will always be true due to the fact I am still in the same workingcopy of the WI I am handling.

So I guess this forces me to check the return of the WI's save operation through WorkItemWorkingCopy How do I do that?

It seems the commen.append is fine, so I can check much on that.

Is there other ways to check and get the new saved comment back?

Here are the related code pieces.

Any help is appreciated.

workingCopyManager.connect(workItem,IWorkItem.FULL_PROFILE,null );
WorkItemWorkingCopy workingCopy = workingCopyManager.getWorkingCopy(workItem);

// modify work item
IWorkItem myworkItem= workingCopy.getWorkItem();

IComments comments= myworkItem.getComments();
IComment comment= comments.createComment(teamRepository.loggedInContributor(), XMLString.createFromPlainText(sciComments));

XMLString newComment = comment.getHTMLContent();
String newCommentStr = newComment.toString();
System.out.println("New Comment: " + newCommentStr);
if (!newCommentStr.equals(sciComments))
System.out.println("work item has not been updated properly!");
return 6;}

One answer

permanent link
Guowei Jim Hu (1.0k810353) | answered May 26 '11, 11:11 a.m.
Never mind.

I guess I should have checked if the is successful or not instead of comparing the new added comment.

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.