How to check if the saving of updated WI is successful?
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 workingCopy.save(null)? 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.
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 workingCopy.save(null)? 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));
comments.append(comment);
workingCopy.save(null);
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!");
workingCopyManager.disconnect(workItem);
teamRepository.logout();
return 6;}