Folder support added to RRC 4.0 OSLC-RM API implementation

There is now folder support in RRC 4.0 with the OSLC-RM API.  This was a highly requested feature for those trying to integrate with RRC via the OSLC-RM API.  In version 3.0.1, it was only possible to create a requirement in the root folder with the Requirement Creation Factory OSLC API.  With version 4.0, you can now create a requirement in any folder along with these other use cases:

  • Create Folder
  • Discover and navigate the folder structure
  • Move a requirement from one folder to another

Here is a preview on how to get started.  The examples below will cover how to discover the root folder and navigate the folder structure of a RM project, create a folder and how to create a requirement in that new folder.  At the end, I will mention briefly how to move a requirement from one folder to another.  This information will be incorporated into an updated version of the OSLC workshop on Jazz.net, so stay tuned for that for some sample code.  Note that in all the examples below, I do not discuss the request header.  The request header must contain OSLC-Core-Version=2.0 and Accept=application/xml (where applicable).

Discover the ‘root’ folder of the RM project

If you have played around with OSLC-CM or OSLC-RM and the IBM Rational implementation provided by RTC or RRC, you know you need to start with a GET of the rootservices document:

GET https://clm.jkebanking.net:9443/rm/rootservices

Next, look for the catalog of Requirements Management Service providers which looks like this in the rootservices document:

<!-- Catalog of Requirements Management Service Providers on this server -->
<oslc_rm:rmServiceProviders rdf:resource="https://clm.jkebanking.net:9443/rm/discovery/RMCatalog" />

Next, proceed with a GET on the catalog URL which results in a list of service provider URLs, one per RM project in the RM server:

GET https://clm.jkebanking.net:9443/rm/discovery/RMCatalog

Response Body (Partial):
...<oslc:ServiceProvider rdf:about="https://clm.jkebanking.net:9443/rm/discovery/_a0x-oLVyEeG3pOZm5lwEBA/services.xml">...

A GET on the service provider URL for a project yields a number of services, one of which is the query capability.  With RRC v4.0, there are now 2 entries returned for query capability.  One of them is the Folder Query Capability URL.
GET https://clm.jkebanking.net:9443/rm/discovery/_a0x-oLVyEeG3pOZm5lwEBA/services.xml

Response Body (Partial):

<oslc:QueryCapability>
<dcterms:title rdf:parseType="Literal">Folder Query Capability</dcterms:title>
<oslc:queryBase rdf:resource="https://clm.jkebanking.net:9443/rm/folders?oslc.where=public_rm:parent=https://clm.jkebanking.net:9443/rm/folders/_a0x-oLVyEeG3pOZm5lwEBA"/>
</oslc:QueryCapability>

The folder query capability URL is the way to discover the ‘root’ folder of the RM project.

An alternate way of retrieving the Folder Query Capability URL is by constructing a URL using the project ID and sending a GET request using this URL:  https://<server:port>/rm/folders/<project-id&gt;.  In our example, the project id is _a0x-oLVyEeG3pOZm5lwEBA.  NOTE:  We will need this later when creating a folder.  The project ID can be found in the service provider URI of the RM project.  Here is the alternate way of retrieving the folder query capability URL:

GET https://clm.jkebanking.net:9443/rm/folders/_a0x-oLVyEeG3pOZm5lwEBA

In the response body, look for the nav:subfolders element and the rdf:resource attribute:

...<nav:subfolders rdf:resource="https://clm.jkebanking.net:9443/rm/folders?oslc.where=public_rm:parent=https://clm.jkebanking.net:9443/rm/folders/_a0x-oLVyEeG3pOZm5lwEBA"/>...

In our example, the folder query capability URI of the ‘root’ folder is
https://clm.jkebanking.net:9443/rm/folders?oslc.where=public_rm:parent=https://clm.jkebanking.net:9443/rm/folders/_a0x-oLVyEeG3pOZm5lwEBA

The above folder query capability URI allows you to retrieve information about the root folder and discover attributes that will allow top down navigation of the folder structure.

GET https://clm.jkebanking.net:9443/rm/folders?oslc.where=public_rm:parent=https://clm.jkebanking.net:9443/rm/folders/_a0x-oLVyEeG3pOZm5lwEBA

Response Body

This response body contains the top level folders of this RM Project:  JKE Private Banking and Securities Project , JKE Enterprise Project, and JKE Business Recovery Matters.  Each folder contains a nav:subfolders element which is that folder’s query URL.  Use that URL to discover any subfolders.  Each folder has its own unique identifier which is found in the rdf:about attribute of the nav:folder element.  It is this attribute that will be used in our next section to identify the parent folder of a new folder.

Create Folder

Now, let’s create a subfolder in the folder ‘JKE Business Recovery Matters Project’.  We just need to provide a nav:parent element to our POST request body to indicate where we want the folder created.  In our case, we need the nav:parent element to point to the folder URL of the ‘JKE Business Recovery Matters Project’ folder.   That was obtained at the end of the previous section using the rdf:about attribute of the nav:folder element for the ‘JKE Business Recovery Matters Project’ folder.

For example, here is a partial POST request body:

….<dcterms:title>My First OSLC folder</dcterms:title><nav:parent rdf:resource=”https://clm.jkebanking.net:9443/rm/folders/_u0xiMbVyEeG3pOZm5lwEBA">…

The POST request must be made to the folder Creation Factory URI.  The folder creation factory URI can be constructed as follows:  https://<server:port>/rm/folders?projectURL=https://<server:port>/jts/process/project-areas/<project-id&gt;.  For our example, the folder creation factory for the RM project is

https://clm.jkebanking.net:9443/rm/folders/?projectURL=https://clm.jkebanking.net:9443/jts/process/project-areas/_a0x-oLVyEeG3pOZm5lwEBA

The full request body for the POST would like as follows:

<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dcterms="http://purl.org/dc/terms/"
xmlns:oslc="http://open-services.net/ns/core"
xmlns:nav="http://jazz.net/ns/rm/navigation"
xmlns:calm="http://jazz.net/xmlns/prod/jazz/calm/1.0/">
<nav:folder rdf:about="">
<dcterms:title> My First OSLC folder </dcterms:title>
<dcterms:description>The description is optional.</dcterms:description>
<nav:parent rdf:resource="https://clm.jkebanking.net:9443/rm/folders/_u0xiMbVyEeG3pOZm5lwEBA"/>
</nav:folder>
</rdf:RDF>

After the POST, you can get the folder URL of the new folder from the location field of the response header.

You can also confirm via the RRC Web UI Artifacts page that there is a new folder, ‘My First OSLC folder’, created under the ‘JKE Business Recovery Matters Project’ folder.

Create Requirement in folder

Next, I want to create a requirement in this new folder.  Requirements can be created using the Requirement Creation Factory URL.  I can find that URL by doing a GET on the services provider URL for my RM project.  We did that earlier to locate the Query Capability URL.

GET https://clm.jkebanking.net:9443/rm/discovery/_a0x-oLVyEeG3pOZm5lwEBA/services.xml

Response Body (Partial):

<oslc:CreationFactory>
<dcterms:title rdf:parseType="Literal">Requirement Creation Factory</dcterms:title>
<oslc:creation rdf:resource="https://clm.jkebanking.net:9443/rm/requirementFactory?projectURL=https%3A%2F%2Fclm.jkebanking.net%3A9443%2Fjts%2Fprocess%2Fproject-areas%2F_a0x-oLVyEeG3pOZm5lwEBA"/>
<oslc:resourceType rdf:resource="http://open-services.net/ns/rm#Requirement"/>
<oslc:resourceShape rdf:resource="https://clm.jkebanking.net:9443/rm/types/_n-4BYbVyEeG3pOZm5lwEBA"/>
<oslc:resourceShape rdf:resource="https://clm.jkebanking.net:9443/rm/types/_n_S4IrVyEeG3pOZm5lwEBA"/>
<oslc:resourceShape rdf:resource="https://clm.jkebanking.net:9443/rm/types/_oAo79LVyEeG3pOZm5lwEBA"/>
<oslc:resourceShape rdf:resource="https://clm.jkebanking.net:9443/rm/types/_oA5aobVyEeG3pOZm5lwEBA"/>
<oslc:resourceShape rdf:resource="https://clm.jkebanking.net:9443/rm/types/_oDjGBbVyEeG3pOZm5lwEBA"/>
<oslc:resourceShape rdf:resource="https://clm.jkebanking.net:9443/rm/types/_oD5rUbVyEeG3pOZm5lwEBA"/>
<oslc:resourceShape rdf:resource="https://clm.jkebanking.net:9443/rm/types/_oEPCg7VyEeG3pOZm5lwEBA"/>
<oslc:resourceShape rdf:resource="https://clm.jkebanking.net:9443/rm/types/_oFQ9QrVyEeG3pOZm5lwEBA"/>
<oslc:resourceShape rdf:resource="https://clm.jkebanking.net:9443/rm/types/_oFql4rVyEeG3pOZm5lwEBA"/>
<oslc:resourceShape rdf:resource="https://clm.jkebanking.net:9443/rm/types/_oF85wbVyEeG3pOZm5lwEBA"/>
<oslc:resourceShape rdf:resource="https://clm.jkebanking.net:9443/rm/types/_oIepVLVyEeG3pOZm5lwEBA"/>
<oslc:resourceShape rdf:resource="https://clm.jkebanking.net:9443/rm/types/_oKvTIbVyEeG3pOZm5lwEBA"/>
<oslc:resourceShape rdf:resource="https://clm.jkebanking.net:9443/rm/types/_oMQ9IbVyEeG3pOZm5lwEBA"/>
<oslc:resourceShape rdf:resource="https://clm.jkebanking.net:9443/rm/types/_oMj4ELVyEeG3pOZm5lwEBA"/>
<oslc:resourceShape rdf:resource="https://clm.jkebanking.net:9443/rm/types/_oNGqobVyEeG3pOZm5lwEBA"/>
<oslc:usage rdf:resource="http://open-services.net/ns/core#default"/>
</oslc:CreationFactory>

Next, construct the requirement creation request.   Grab one of the resourceShape URLs and use it as the instanceShape rdf:resource.  To specify a folder  for this requirement, add the nav:parent element and provide the folder URL in the rdf: resource attribute.  How do you find the folder URL?  At the end of the previous section, it was part of the response header.  If it was not saved, then simply do a GET on its parent folder query URL, and parse for the name of the new folder in the query results.

Once the nav:parent element value has been located, use it to complete the content for the new requirement.  Here is the complete content to send in the POST request body.


<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF
xmlns:oslc_rm="http://open-services.net/ns/rm#"
xmlns:dc="http://purl.org/dc/terms/"
xmlns:oslc="http://open-services.net/ns/core#"
xmlns:rm_property="https://clm.jkebanking.net:9443/rm/types/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:nav=http://jazz.net/ns/rm/navigation#">
<oslc_rm:Requirement
rdf:about="">
<dc:title>MyDocument</dc:title>
<dc:description>This is a test document</dc:description>
<nav:parent rdf:resource="https://clm.jkebanking.net:9443/rm/folders/_EH_3wr8BEeGugPMVwOckzA"/>
<oslc:instanceShape rdf:resource="https://clm.jkebanking.net:9443/rm/types/_n-4BYbVyEeG3pOZm5lwEBA"/>
<rm_property:_bw8r8rVyEeG3pOZm5lwEBA rdf:parseType="Literal">
<div xmlns="http://www.w3.org/1999/xhtml" id="_Nf2cQJKNEd25PMUBGiN3Dw"><h1 id="_DwpWsMueEd28xKN9fhQheA">Test Document</h1></div></rm_property:_bw8r8rVyEeG3pOZm5lwEBA>
</oslc_rm:Requirement>
</rdf:RDF>

To create this requirement, do a POST to the requirement creation URL with the above POST body.  The location field of the response header will contain the URL of the newly created resource.

Move requirement from one folder to another

To move a requirement from one folder to another, you simply have to update the nav:parent element of the requirement using a PUT.  We cover updating a requirement in Example 4 of the OSLC workshop.

  1. Locate the folder URL of the new folder you want to move the requirement to.
  2. Update the  rdf:resource attribute of the nav:parent element.  The rdf: resource attribute of the nav:parent element is what contains the folder URL for a requirement resource .

Here is a the XML for a requirement resource.  Notice the highlighted nav:parent element.

Useful Tools

There are a few tools that are useful when working with the OSLC API.  Here are some links.

HTTPRequester Add-on for Firefox

RESTClient Add-on for Firefox