It's all about the answers!

Ask a question

[RTC] Is it possible to exclusively control work item updates by REST API(OSLC)?


HIROAKI JOSAKO (47430) | asked Oct 22 '19, 8:23 p.m.

I want to lock a Workitem when updating it using REST API.
Is it possible?


[APITool1]<---Get[RTC]<Lock>X<---PUT[APIToool2]

or

[APITool1]PUT(2nd)--->X<refuse>[RTC]<---PUT(1st)[APIToool2]

Accepted answer


permanent link
Ralph Schoon (63.3k33646) | answered Oct 29 '19, 3:20 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
edited Oct 29 '19, 3:27 a.m.

As far as I can tell, 

  1. There is no locking mechanism. 
  2. Regardless of how you implement it, REST or JAVA API, there are only limited options. You can detect a possible conflict e.g. based on the error when saving. In case there is an error, determine if this could be a stale data error. In case it is, refresh/reload the work item redo the modification and try to save again.
  3. A problem will be detected when saving - note that the Web UI has the same limitations, if a user works on a work item and another user saves this item while they do, there will be a save conflict.
  4. The Web UI check every now and then and shows a banner that says the work item has been changed - I don't know how that is implemented. I think it is irrelevant for automation, because the likely hood of a save conflict happening should be minimal and it would be possible to reload the item and retry.
  5. There is no other wonder API I am aware of. 



Ralph Schoon selected this answer as the correct answer

Comments
HIROAKI JOSAKO commented Oct 29 '19, 7:08 a.m.

Thanks Ralph.
However, I do not understand well.
What is “only limited options”?
Are there any articles I can learn?


Ralph Schoon commented Oct 29 '19, 7:54 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
In general locking is an even worse concept then not locking. If locks are not removed, they pose a higher risk of creating issues than having to redo an operation because of a racing condition.

There are many automation tools (and users) working against RTC servers. If it would be a problem I would have likely heard about it. 


Ralph Schoon commented Oct 29 '19, 7:56 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

 Summary, if you run into a racing condition, the tool detects the fact (based on some header information, I think [etag?]) and lets you know. Reread the work item, do the change again and try writing it again.


HIROAKI JOSAKO commented Oct 31 '19, 5:18 a.m.

ETag!!

I understood a little.
Thank you very much.
Acquire that ETag is not changed after the session information and confirm that it matches.

I don't want to lock it if I imagine it would be impossible to unlock.

Let's consider a mechanism to check for updates even a little by checking with ETag.
I learned a lot.

One other answer



permanent link
Ian Wark (79713553) | answered Oct 25 '19, 12:51 a.m.
It looks like you can lock work items from the WebUI. I am not sure if you would be able to perform a work item update via REST API with the lock on, but this is one way to lock the state of the relevant work items.


Does this help?

Comments
Ralph Schoon commented Oct 25 '19, 2:28 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

That is no lock, that is a pre-condition that prevents saving a work item under certain conditions.


As far as I am aware, there is no "locking" mechanism for work items. You can refresh before you do a change. If there is a conflict you get a stale data exception (in the java API) and you have to refetch and retry. 


HIROAKI JOSAKO commented Oct 28 '19, 3:29 a.m.

Thanks Wark!!
But,this is for the control to close the WI, and is a good match for the process that prevents overwriting exclusively.



HIROAKI JOSAKO commented Oct 28 '19, 3:46 a.m.

Thanks Ralph ,follow!!
Exactly,This is a conflict issue.

Can Java API detect conflicts?
I would like to do it with REST API, is it impossible?


Ralph Schoon commented Oct 28 '19, 6:18 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

As far as I can tell, there is no locking mechanism. Regardless of how you implement it, REST or JAVA API, there are only limited options. You can detect a possible conflict e.g. based on the error. In case there is an error, determine if this could be a stale data error. In case it is, refresh/reload the work item redo the modification and try to save again.


HIROAKI JOSAKO commented Oct 28 '19, 11:56 p.m.

limited options?
Is there a “conflict check” API?
or
get "modified Date" and diff?

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.