Lock/Unlock RRC artifacts using OSLC API
Samanwita Majumdar (50●3●39●40)
| asked Dec 16 '14, 11:23 p.m.
edited Dec 17 '14, 5:02 a.m. by Ralph Schoon (63.6k●3●36●46)
I had a mechanism to programatically lock/unlock artifacts using OSLC for RRC. This worked fine in version 4.0.3 however is not running in the upgraded version 5.0.1 and throwing an exception 400/Bad Request.
The code snippet for locking an artifact is as follows- https://inmbzp4102.in.dst.ibm.com:9443/rm/locks/"+artifactURI - the locking URI public String getLockUnlockResource(String uri) { HttpGet get = new HttpGet(uri); get.setHeader("Accept", "application/xml"); get.setHeader("OSLC-Core-Version", "2.0"); get.setHeader("X-Jazz-CSRF-Prevent","0000UfsWrlfdGf4tF6SMIpVjnly:-1"); String responseXML = getResourceForLock(get); return responseXML; } public String getResourceForLock(HttpGet get) { String resourceXML=""; System.out.println("\n=== " + get.getRequestLine()); HttpResponse jfsResponse; try { jfsResponse = HttpUtils.sendGetForSecureDocument( server, get, login, password, httpclient, JTS_Server); getResponseCode = jfsResponse.getStatusLine().getStatusCode(); if(getResponseCode==404) { jfsResponse.getEntity().consumeContent(); return "404"; } if(jfsResponse.getStatusLine().getStatusCode() != HttpStatus.SC_OK) { throw new Error("Bad status: " + jfsResponse.getStatusLine() + " for " + get.getRequestLine()); } HttpEntity responseEntity = jfsResponse.getEntity(); resourceXML = printEntity(responseEntity); jfsResponse.getEntity().consumeContent(); } catch (Throwable t) { // TODO Auto-generated catch block t.printStackTrace(); } return resourceXML; } |
One answer
The underlying structure of locks changed quite dramatically after 4.0.3. I'm not sure it was ever supported to be able to programatically lock/unlock artifacts via OSLC or if it would even be possible now given the new internal strucutre used by the locking mechanism.
|
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.