The process to create an OSLC link on a Jira issue is the following:
This page provides guidance on how to add a unidirectional link from a Jira issue to a remote OSLC resource. The same process is to apply to create the reverse link in the remote OSLC resource to target the Jira issue.
To execute those REST requests, you are free to use the REST library of your choice. You may use the MDAccess for OSLC library to ease the execution of requests, as demonstrated in Running OSLC snippets on Jira section.
Here is the REST request to obtain the Jira issue as an OSLC resource:
GET
https://SERVER:PORT/rest/oslc/1.0/cm/issue/ISSUE
Authorization
: Jira user and password encoded as BASIC authenticationAccept
: application/rdf+xml
OSLC-Core-Version
: 2.0
ETag
: resource version identifier<rdf:RDF ... <rdf:Description rdf:about="https://SERVER:PORT/rest/oslc/1.0/cm/issue/ISSUE"> <dcterms:title rdf:parseType="Literal">Test</dcterms:title> <rdf:type rdf:resource="http://atlassian.com/ns/cm#Issue"/> <rdf:type rdf:resource="http://open-services.net/ns/cm#ChangeRequest"/> ... </rdf:Description> </rdf:RDF>
The intent is now to add a link targeting an OSLC remote resource in this XML content.
If for example the Jira issue is to implement a requirement, the link type to use is http://open-services.net/ns/cm#implementsRequirement
and the new resource content should be something like:
<rdf:RDF ... <rdf:Description rdf:about="https://SERVER:PORT/rest/oslc/1.0/cm/issue/ISSUE"> <dcterms:title rdf:parseType="Literal">Test</dcterms:title> <rdf:type rdf:resource="http://open-services.net/ns/cm#ChangeRequest"/> ... <oslc_cm:implementsRequirement rdf:resource="https://REMOTE-SERVER:REMOTE-PORT/myRemoteApp/myRequirement/IDENTIFIER"/> ... </rdf:Description> </rdf:RDF>
Refer to the Links across OSLC domains section for details on link types.
Here is the REST request to update the content of the Jira issue:
PUT
https://SERVER:PORT/rest/oslc/1.0/cm/issue/ISSUE
Authorization
: Jira user and password encoded as BASIC authenticationAccept
: application/rdf+xml
OSLC-Core-Version
: 2.0
If-Match
: The value of the ETag
header received in the GET response