Home » Eclipse Projects » Lyo » Issues with creating a specific resource request body in OSLC4J(API requires a specific RDF/XML to be sent which I can not generate.)
|
Re: Issues with creating a specific resource request body in OSLC4J [message #1799806 is a reply to message #1799796] |
Thu, 13 December 2018 22:10 |
Jad El-khoury Messages: 61 Registered: August 2015 |
Member |
|
|
Hi Ralph
1.
I am looking at your annotation: @OslcResourceShape(title = "Changeset", describes = "http://open-services.net/ns/config#" + "Changeset")
The "describes" is telling OSLC4J marsheller that the rdf:type is "http://open-services.net/ns/config#Changeset". So, you should change that value, if you expect <rdf:type rdf:resource="http://open-services.net/ns/config#Configuration"/>
2.
Don't think this is really the source of problems, but I am looking at your
response = client.createResource(changeSetCreationFactory, this, OslcMediaType.APPLICATION_RDF_XML, OslcMediaType.APPLICATION_XML);
Is there a reason contentType (APPLICATION_RDF_XML) is different from the accept type (APPLICATION_XML)?
Do you know what you server is expecting?
3.
I think you should avoid setting the rdf:type property through the getters in the class, as you tried to do in the commented-out code.
Finally, can you give more details about the issues you have with the code generation?
If you can start a new thread on that, I can try to help out.
[Updated on: Thu, 13 December 2018 22:15] Report message to a moderator
|
|
|
Re: Issues with creating a specific resource request body in OSLC4J [message #1799824 is a reply to message #1799806] |
Fri, 14 December 2018 09:38 |
Ralph Schoon Messages: 9 Registered: November 2018 |
Junior Member |
|
|
Hi Jad,
I know it is kind of against intuition, but the inventor of this API has decided they want a Changeset to be created. So the outer part is supposed to be Changeset. However the inner type must be Configuration. Here the important pieces:
<rdf:RDF
xmlns:j.0="http://open-services.net/ns/config#"
<j.0:Changeset>
<rdf:type rdf:resource="http://open-services.net/ns/config#Configuration"/>
</j.0:Changeset>
</rdf:RDF>
So the outer (I don't know the language here) type has to be "ChangeSet", hence the
@OslcNamespace("http://open-services.net/ns/config#")
@OslcResourceShape(title = "Changeset", describes = "http://open-services.net/ns/config#" + "Changeset")
and the class is also "Changeset".
But the designer of the API also requires the inner type to be "Configuration".
<rdf:type rdf:resource="http://open-services.net/ns/config#Configuration"/>
Note, this is not supposed to be "Changeset". I seem to be unable to get this to be generated.
What I get generated is
<rdf:RDF
.....
<j.0:Changeset>
<j.0:stream rdf:resource="https://clm.example.com:9443/rm/cm/stream/_8HxiUPoZEei1heqPanuHaQ"/>
<j.0:component rdf:resource="https://clm.example.com:9443/rm/cm/component/_qQIn0PoYEei1heqPanuHaQ"/>
<dcterms:title rdf:parseType="Literal">Import-Type-System-CS-2018/12/14 10:15:46 MEZ</dcterms:title>
<dcterms:description>Created for automation.</dcterms:description>
</j.0:Changeset>
</rdf:RDF>
Which is fine. But I need also
<rdf:type rdf:resource="http://open-services.net/ns/config#Configuration"/>
to be generated. As soon as I try to do that with setting the type or adding a property as described above things start to go wrong.
What typically happens is that the generated body looks like
<rdf:RDF
.....
<j.0:Configuration>
.....
<rdf:type rdf:resource="http://open-services.net/ns/config#Changeset"/>
</j.0:Configuration>
</rdf:RDF>
So the other way round.
BTW, I changed the factory call to
response = client.createResource(changeSetCreationFactory, (Changeset)this, OslcMediaType.APPLICATION_RDF_XML, OSLCConstants.CT_RDF);
The result is the same. This is not the issue. I have accidentally been able to generate the correct body and then everything worked.
I was able to achieve that by using
// This is a work around.
this.addType(new URI("http://open-services.net/ns/config#Configuration"));
but for some reason unknown to me, this does not work anymore. If I do that, this is the result (only the important bits)
<rdf:RDF
...
<j.0:Configuration>
...
<rdf:type rdf:resource="http://open-services.net/ns/config#Changeset"/>
</j.0:Configuration>
</rdf:RDF>
and this is exactly the opposite of what I need. I am also concerned that it was working once and somehow it does not any more. How can I trust my code if some random stuff happens?
I hope I have explained this in enough details. As it stands I should probably duplicate the class, call it Configuration and use the trick in reverse. But I don't understand why the change from
<rdf:RDF
...
<j.0:Changeset>
...
</j.0:Changeset>
</rdf:RDF>
to
<rdf:RDF
...
<j.0:Configuration>
...
<rdf:type rdf:resource="http://open-services.net/ns/config#Changeset"/>
</j.0:Configuration>
</rdf:RDF>
actually happens and if this would change some time in the future for a random reason.
Any ideas you have are most welcome!
|
|
| | | | | |
Goto Forum:
Current Time: Sun Jan 12 22:18:08 GMT 2025
Powered by FUDForum. Page generated in 0.03711 seconds
|