2011년 12월 30일 금요일

StaleDataException

Exception -> Status Code(https://jazz.net/wiki/bin/view/Main/JFSStorageAPI)
  • ItemNotFoundException -> 404 Not found 
  • IllegalArgumentException -> 400 Bad Request 
  • StaleDataException -> 409 Conflict 
  • TeamRepositoryException -> 500 Internal Server Error

Every time an item is saved, a new state is created. When you save an item, the newest state must be used, otherwise you get a StaleDataException.

When you save an item more than once, you will need to make sure that you always have the latest state by:

  • either use the item returned by the save call
  • fetch the item from the repository again


StaleDataException is being caused because the work item you are referencing has already been updated from a previous change and you are still referencing the old work item.

So let's say you are updating multiple attributes but each independently. The pseudo-code would be something like this ...

[begin of pseudo-code]

get work item handle
get working copy
edit attribute 1
save working copy

get fresh copy of work item
get working copy
edit attribute 2
save working copy

get fresh copy of work item
...

[end of pseudo-code]

// get fresh copy of work item
workItem = workItemServer.findWorkItemById(workItem.getId(), IWorkItem.FULL_PROFILE, monitor);

댓글 없음:

댓글 쓰기