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

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.




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

0 votes



One answer

Permanent link
Never mind.

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

0 votes

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
× 10,927

Question asked: May 25 '11, 3:05 p.m.

Question was seen: 4,520 times

Last updated: May 25 '11, 3:05 p.m.

Confirmation Cancel Confirm