Atomic link manipulation on workItem
2 answers
public String myAtomicOperation() throws TeamRepositoryException { ITransactionService transactionService = getService(ITransactionService.class); String runInTransactionResult = transactionService.runInTransaction(false, new ITransactionRunnable<String>() { @Override public String run() throws TeamRepositoryException { // CRITICAL CODE GOES HERE // Example: createLinks, deleteLinks.
return "The result"; } }); return runInTransactionResult; }
See https://rsjazz.wordpress.com/ for examples about the link API.
Comments
Hi Ralph
Hi Martin,
that is above my level of knowledge. My experience is that in an advisor, if you prevent a save, the element is rolled back to the prior state on cancel.
I had a discussion with some developers two day ago where we found that you should not do manipulations in an advisor. See this post. I was not really aware of that also - I did not read the API documentation good enough I guess.
For work items, I think if you do your modifications e.g. in a workitem operation and exit with an exception or you and don't do the save of the workingcopy, you should end up with the previous state of the work item. However, I am not really sure if this is guarded by a transaction and is really atomic. I will pass this on to someone who could probably tell.