Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

How to create Child Of link to another artifact?

Hi,

I'm currently working with the IBM OSLC API to update artifact attributes. I've developed a sample REST API that successfully updates the content of an artifact. However, when I try to update the child link of an artifact in a similar way, it doesn't work. Kindly assist me with this.

Here content is XML data:

<rdf:RDF          .          .          .      
<rdf:Description rdf:about="">                  .  
       <oslc_rm:implementedBy rdf:ID="n0" rdf:resource="http://www.google.com"/>   
       <oslc_rm:validatedBy rdf:ID="n1" rdf:resource="http://www.something.com"/>                  .           
        </rdf:Description>        <rdf:Description rdf:about="#n0">          
  <dc:title rdf:parseType="Literal">Link1</dc:title>
       </rdf:Description>     
  <rdf:Description rdf:about="#n1">           
 <dc:title rdf:parseType="Literal">Link2</dc:title>  
     </rdf:Description> 
   </rdf:RDF>



        

HttpPut put = new HttpPut(artifactURI);

put.addHeader("Accept", "application/rdf+xml");

put.addHeader("Content-Type", "application/rdf+xml");

put.addHeader("If-Match",etag);

put.setEntity(new StringEntity(content, HTTP.UTF_8));

HttpResponse response = requestManager.put(put);




        

1

0 votes

Comments

"doesn't work": what happens?


How are you specifying the configuration?

You should probably be using header OSLC-Core-Version: 2.0 on your GET and PUT.

I edited the title of your question to make it clearer what the question is - title used to be "

How to update child of attribute of an artifact

"



7 answers

Permanent link

"doesn't work" is completely useless if you really want help solving your problem then provide the response/behaviour you get and what you expected.


But based on what limited information you put in your question I don't think you're using the OSLC API - to do this you must provide header OSLC-Core-Version: 2.0 with the GET/PUT/POST.

There's  simple example of creating a link in this article https://jazz.net/library/article/1197 see section 6. Adding and removing links - EXCEPT beware these days with configuration management enabled the link is always stored only at the source end - so for the Validated By and Implemented By these are stored in ETM and EWM respectively, i.e. no point trying to create them by PUT to RM. But you can create RM->RM links in (using a suitable link type) the same way as shown in the article.

Unless your project is not configuration management enabled you must provide the configuration with every PUT/GET/POST, either using header Configuration-Context or query parameter oslc_config.context (with the configuration url-encoded).

0 votes


Permanent link

Hi Barnard, I have modified my header as you suggested, but I am still unable to update the child of a link. I have a question: can we update the child links of an artifact in DOORS NG?

HttpPut put = new HttpPut(artifactURI);

put.addHeader("Accept", "application/rdf+xml"); put.addHeader("OSLC-Core-Version", "2.0");

put.addHeader("Content-Type", "application/rdf+xml");

put.addHeader("Configuration-Context", configurationUrl);

put.addHeader("If-Match",etag);

0 votes

Comments

"unable to update" - You still haven't answered my question: what result/error code do you get?


And what data is in the body of your PUT?

Are you certain you're authenticated?

Answer all three questions.


Permanent link
Hi Barnard,
  I am trying to modify the child link of an artifact using the steps below, but my new child link is not replacing with old one. I am not seeing any error messages in fact, I am getting a success message(200).
I have a question Is it possible to update the child links of an artifact in DOORS NG?

When I use the GET API, I am able to retrieve all the content of an artifact such as the artifact ID, content (primary text), child links, artifact type, etc. However, I am only attaching a specific XML related to the child link

Xml of an GET API (Actual child link of an artifact):

<rdf:Description rdf:nodeID="A0">
    <rdf:predicate rdf:resource="http://www.ibm.com/xmlns/rdm/types/Decomposition"/>
    <dcterms:title>389001</dcterms:title>
</rdf:Description>

Modified child of link XML for PUT request:

<rdf:Description rdf:nodeID="A0">
    <rdf:predicate rdf:resource="http://www.ibm.com/xmlns/rdm/types/Decomposition"/>
    <dcterms:title>389001</dcterms:title>
</rdf:Description>

content: modified XML data along with other content of an artifact

HttpPut put = new HttpPut(artifactURI);
put.addHeader("Accept", "application/rdf+xml");
put.addHeader("Content-Type", "application/rdf+xml");
put.addHeader("OSLC-Core-Version", "2.0");
put.addHeader("Configuration-Context", configurationURl);
put.addHeader("If-Match",etag);
put.setEntity(new StringEntity(content, HTTP.UTF_8));

HttpUtils.sendPutForSecureDocument(server, put, login, password, httpclient, JTS_Server);
 
Here validation has been done before doing put

HttpResponse documentResponse = httpClient.execute(put);


Required: The new link should replace the old one after the update

0 votes


Permanent link

Finally some usable details of what the problem is.


1. You can't "modify" a link. You can remove an existing link, or you can add a new link. So you need to remove the existing link and add a new link. These can be done in one PUT.

2. Ignore the tags in the rdf like:
  <rdf:Description rdf:nodeID="A1">
These are entirely managed by DOORS Next. You can use them to perhaps see more detail about the link, that's all.

3. The rdf which specifies an outgoing link is a tag looking like:
    <rm_property:LT_7oqH57C1Ee-Oi4_TXlWUGQ rdf:resource="https://jazz.ibm.com:9443/rm/resources/TX_7lDaILC1Ee-Oi4_TXlWUGQ"/>
In this the LT_7oqH57C1Ee-Oi4_TXlWUGQ is the unique id of the link type and the rdf:resource is the object of the link - the artifact it's going to.
If you "modify" this to point at a different object, what DOORS Next will do internally is delete the existing link and create the new link you specified.
There will be multiple tags with the same rm_property:LT_7oqH57C1Ee-Oi4_TXlWUGQ if there are multiple outgoing links of that type from the artifact.
You should only have one link of a specific type between two specific artifacts. I've not tried breaking this rule to see what happens - caveat emptor. Aside: one aspect of using the APIs which needs careful management by the API user (i.e. you) is that, while the UI prevents many user actions which don't make sense, the APIs don't have so many guardrails - e.g. you could try and put megabytes of data in an attribute and the API will try to do it for you, even though that will be impossible for someone to look at in the UI and impossible to include in a report.

You can create links between any mix of bindings and core artifacts - you should probably be consistent i.e. only link core->core or binding->binding and not a mixture, but that's not a hard rule it just makes it much easier for users to figure out where to look for links, and to report on links.

With configuration management enabled links are only stored at the source (subject) artifact. All the inter-application OSLC link types are only incoming to DOORS Next so these have to be created in ETM/EWM/RMM.

0 votes


Permanent link

Hi Barnard,


After removing the link, this is how my XML is parsed to the REST PUT API, but the link is still not removed, also seeing success (200) and I continue to see the old child of the link in the DOORS NG UI. I have a question: Do we need to enable any permissions on the DOORS NG side for this to take effect?

Xml content to PUT :
<rdf:object rdf:resource="">


content: modified XML data along with other content of an artifact

HttpPut put = new HttpPut(artifactURI);
put.addHeader("Accept", "application/rdf+xml");
put.addHeader("Content-Type", "application/rdf+xml");
put.addHeader("OSLC-Core-Version", "2.0");
put.addHeader("Configuration-Context", configurationURl);
put.addHeader("If-Match",etag);
put.setEntity(new StringEntity(content, HTTP.UTF_8));

HttpUtils.sendPutForSecureDocument(serverputloginpasswordhttpclientJTS_Server);
 
Here validation has been done before doing put

HttpResponse documentResponse = httpClient.execute(put);

0 votes


Permanent link

Messing around with fragments just isn't working - you aren't giving enough detail to diagnose what's going on.


Here's a log of:
1. GET an artifact with two links
2. Remove one of the links and PUT to update the artifact - it now only has one link
3. GET the artifact, shows it only has one artifact.

Look at what is PUT at step 2 - all that's changed is one of the outgoing links has been removed, so there's only one link tag (in bold). Nothing else is modified.

The outgoing links look like:
    <rm_property:LT_7oqH57C1Ee-Oi4_TXlWUGQ rdf:resource="https://jazz.ibm.com:9443/rm/resources/TX_7lffALC1Ee-Oi4_TXlWUGQ"/>

The rdf:resource attribute value is the URL of the object artifact - that's where the link goes to. It must be in the same config as this source artifact.

Ignore the tags like <rdf:Description rdf:nodeID="A0"> AND everything below them - don't modify, don't remove, just leave them alone.

I removed unneeded headers and namespaces in the XML, just showing headers that are needed/useful.

1. GET an artifact with two outgoing Satisfies links (in bold)

Accept: application/rdf+xml
OSLC-Core-Version: 2.0

HTTP/1.1 200 OK
ETag: "%220%22&_8OtbS7C1Ee-Oi4_TXlWUGQ"

<rdf:RDF
    ...
    xmlns:oslc_auto="http://open-services.net/ns/auto#"
  <rdf:Description rdf:nodeID="A0">
  </rdf:Description>
  <rdf:Description rdf:nodeID="A1">
  </rdf:Description>
    <dcterms:creator rdf:resource="https://jazz.ibm.com:9443/jts/users/ibm"/>
    <rdf:type rdf:resource="http://jazz.net/ns/rm#Text"/>
    <dcterms:contributor rdf:resource="https://jazz.ibm.com:9443/jts/users/ibm"/>
    <dcterms:description rdf:parseType="Literal"></dcterms:description>
    <rdf:type rdf:resource="http://open-services.net/ns/rm#Requirement"/>
    <oslc:instanceShape rdf:resource="https://jazz.ibm.com:9443/rm/types/OT_7o8brLC1Ee-Oi4_TXlWUGQ"/>
    <rm_property:LT_7oqH57C1Ee-Oi4_TXlWUGQ rdf:resource="https://jazz.ibm.com:9443/rm/resources/TX_7lffALC1Ee-Oi4_TXlWUGQ"/>
    <dcterms:title rdf:parseType="Literal">ANSI 1252 Latin 1 for CSV Export</dcterms:title>
    <rm_property:LT_7oqH57C1Ee-Oi4_TXlWUGQ rdf:resource="https://jazz.ibm.com:9443/rm/resources/TX_7lDaILC1Ee-Oi4_TXlWUGQ"/>
    <jazz_rm:primaryText rdf:parseType="Literal"><div xmlns="http://www.w3.org/1999/xhtml">
<div> <p id="_1"> <span style="font-family: arial,sans-serif; font-size: 10.0pt; ">ANSI 1252 Latin 1 for CSV Export</span></p></div>
</div></jazz_rm:primaryText>
  </rdf:Description>
</rdf:RDF>


------------------------------------------------------------------

2. PUT with one of the links removed - nothing else is modified

OSLC-Core-Version: 2.0
Content-Type: application/rdf+xml
If-Match: "%220%22&_8OtbS7C1Ee-Oi4_TXlWUGQ"

  <rdf:Description rdf:nodeID="A0">
  </rdf:Description>
  <rdf:Description rdf:nodeID="A1">
  </rdf:Description>
    <dcterms:creator rdf:resource="https://jazz.ibm.com:9443/jts/users/ibm"/>
    <rdf:type rdf:resource="http://jazz.net/ns/rm#Text"/>
    <dcterms:contributor rdf:resource="https://jazz.ibm.com:9443/jts/users/ibm"/>
    <dcterms:description rdf:parseType="Literal"/>
    <rdf:type rdf:resource="http://open-services.net/ns/rm#Requirement"/>
    <oslc:instanceShape rdf:resource="https://jazz.ibm.com:9443/rm/types/OT_7o8brLC1Ee-Oi4_TXlWUGQ"/>
    <dcterms:title rdf:parseType="Literal">ANSI 1252 Latin 1 for CSV Export</dcterms:title>
    <rm_property:LT_7oqH57C1Ee-Oi4_TXlWUGQ rdf:resource="https://jazz.ibm.com:9443/rm/resources/TX_7lDaILC1Ee-Oi4_TXlWUGQ"/>
    <jazz_rm:primaryText rdf:parseType="Literal"><div xmlns="http://www.w3.org/1999/xhtml">
<div> <p id="_1"> <span style="font-family: arial,sans-serif; font-size: 10.0pt; ">ANSI 1252 Latin 1 for CSV Export</span></p></div>
</div></jazz_rm:primaryText>
  </rdf:Description>
</rdf:RDF>

HTTP/1.1 200 OK
ETag: "%220%22&_8OtbS7C1Ee-Oi4_TXlWUGQ"

------------------------------------------------------------------

3. GET of the artifact - now it only has one outgoing link

Accept: application/rdf+xml
OSLC-Core-Version: 2.0

HTTP/1.1 200 OK
Content-Type: application/rdf+xml
ETag: "%220%22&_8OtbS7C1Ee-Oi4_TXlWUGQ"

<rdf:RDF
    ...
    xmlns:oslc_auto="http://open-services.net/ns/auto#"
  <rdf:Description rdf:nodeID="A0">
  </rdf:Description>
    <dcterms:creator rdf:resource="https://jazz.ibm.com:9443/jts/users/ibm"/>
    <rdf:type rdf:resource="http://jazz.net/ns/rm#Text"/>
    <dcterms:contributor rdf:resource="https://jazz.ibm.com:9443/jts/users/ibm"/>
    <dcterms:description rdf:parseType="Literal"></dcterms:description>
    <rdf:type rdf:resource="http://open-services.net/ns/rm#Requirement"/>
    <oslc:instanceShape rdf:resource="https://jazz.ibm.com:9443/rm/types/OT_7o8brLC1Ee-Oi4_TXlWUGQ"/>
    <dcterms:title rdf:parseType="Literal">ANSI 1252 Latin 1 for CSV Export</dcterms:title>
    <rm_property:LT_7oqH57C1Ee-Oi4_TXlWUGQ rdf:resource="https://jazz.ibm.com:9443/rm/resources/TX_7lDaILC1Ee-Oi4_TXlWUGQ"/>
    <jazz_rm:primaryText rdf:parseType="Literal"><div xmlns="http://www.w3.org/1999/xhtml">
<div> <p id="_1"> <span style="font-family: arial,sans-serif; font-size: 10.0pt; ">ANSI 1252 Latin 1 for CSV Export</span></p></div>
</div></jazz_rm:primaryText>
  </rdf:Description>
</rdf:RDF>


0 votes


Permanent link

Hi Barnard,


This is the XML data I received when I used the GET REST API, but I don't see any <rm_property:LT_7oqH57C1Ee-Oi4_TXlWUGQ tag  in the XML. Is that why I'm unable to remove or update it?

<rdf:RDF
    ...
    xmlns:oslc_auto="http://open-services.net/ns/auto#" > 
        <rdf:type rdf:resource="http://open-services.net/ns/rm#Requirement"/>
        <acp:accessControl rdf:resource="https://localhost:9444/rm/accessControl/_3K4wkIOOEeu4rcLuUs_vzw"/>
        <dcterms:identifier rdf:datatype="http://www.w3.org/2001/XMLSchema#string">5231475</dcterms:identifier>
        <j.1:PVSubstitutionMarkers rdf:datatype="http://www.w3.org/2001/XMLSchema#string">open={
end=}
esc=$</j.1:PVSubstitutionMarkers>
        <dcterms:description rdf:parseType="Literal">Des1</dcterms:description>
        <rdf:type rdf:resource="http://jazz.net/ns/rm#Text"/>
        <oslc_config:component rdf:resource="https://localhost:9444/rm/cm/component/_hwHZ0AirEe-bCa7jHbxLPg"/>
        <j.0:Decomposition rdf:resource="https://localhost:9444/rm/resources/BI_LZOJM7CEEe-bLPm2dX65rw"/>
        <dcterms:creator rdf:resource="https://localhost:9444/jts/users/E520039"/>
        <dcterms:contributor rdf:resource="https://localhost:9444/jts/users/H583831"/>
        <oslc:instanceShape rdf:resource="https://localhost:9444/rm/types/OT_qQth8AirEe-bCa7jHbxLPg"/>
        <dcterms:title rdf:parseType="Literal">5231468</dcterms:title>
        <oslc:serviceProvider rdf:resource="https://localhost:9444/rm/oslc_rm/_3K4wkIOOEeu4rcLuUs_vzw/services.xml"/>
        <jazz_rm:primaryText rdf:parseType="Literal">
            <div xmlns="http://www.w3.org/1999/xhtml">
                <p dir="ltr" id="_1733126835239">Sample Testing Check</p>
            </div>
        </jazz_rm:primaryText>
    </rdf:Description>
    <rdf:Description rdf:nodeID="A0">
        <rdf:predicate rdf:resource="http://www.ibm.com/xmlns/rdm/types/Decomposition"/>
        <rdf:type rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#Statement"/>
        <dcterms:title>5231469</dcterms:title>
    </rdf:Description>
</rdf:RDF>

0 votes

Comments
You may note I said "look like:    <rm_property:LT_7oqH57..." - i.e. that's an example.

Your specific links will almost certainly have a different tag - in this case you have a Child Of link which is the tag:

If you define a custom link type it will look more like the <rm_property:LT_7oqH57... example I showed, but not exactly the same.

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 7,582
× 6,160
× 1,412

Question asked: Jul 22, 4:37 a.m.

Question was seen: 667 times

Last updated: Jul 30, 8:44 a.m.

Related questions
Confirmation Cancel Confirm