You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@isis.apache.org by Kambiz Darabi <da...@m-creations.com> on 2015/07/14 18:50:48 UTC
POSTing to an /objects/{domainType} resource
Hello,
as a new user of Isis, I would first like to thank you for open-sourcing
the software. I am a developer from Germany who is interested in using
Isis (and RO) for a customer project.
Reading section 9 in the RO spec, I would have expected to be able to
POST the following to http://~/objects/simple.SimpleObject/ (in
SimpleApp-PROTOTYPE-with-fixtures):
{
"members": {
"name": {
"value": "Quux"
}
}
}
but this leads to a 400 with the following warning:
199 RestfulObjects Could not find properties list (no members[objectMemberType=property]); got {"members":{"name":{"value":"Quux"}}}
I then debugged the application and had the impression that members must
be an array and that each element must have the attribute
objectMemberType set to "property":
{
"members" : [ {
"name" : {
"value": "Quux"
},
"objectMemberType": "property"
} ]
}
With such a JSON, the response is a '500 Server Error' and the logs show
Caused by: org.hsqldb.HsqlException: integrity constraint violation: NOT
NULL check constraint; SYS_CT_10102 table: "SimpleObject" column: "name"
Debugging again shows that in ObjectAdapterUpdateHelper's
copyOverProperties, the following is called with the id "name":
propertiesList.getRepresentation(id)
which returns null, so the property name is not copied to the object
which is to be persisted, resulting in the NOT NULL exception.
I guess that I'm completely misunderstanding how I should use the
resource.
Would someone be so kind to put me on the right track?
Thank you
Kambiz Darabi
--
m-creations gmbh
Acker 2
55116 Mainz
Germany
W: http://www.m-creations.com
E: darabi@m-creations.com
--
Registered Office: Mainz, HRB Mainz 7382
Managing Directors: Frank Pacholak, Kambiz Darabi
AW: POSTing to an /objects/{domainType} resource
Posted by "Rade, Joerg / Kuehne + Nagel / Ham GI-PS" <Jo...@Kuehne-Nagel.com>.
Hi Kambiz,
> Replacing e.g. "value" by "string1" may be worth a try.
Sorry that was misleading. I meant the element above "value" (see arguments/parameters in my sample below).
For invoking http://localhost:9090/sdm-webapp/restful/services/cm.repofact.Endpoints/actions/checkApplicationVersion/invoke I pass in:
{ "string1" : {"value": "SALOG"},
"string2" : {"value": "3.2.0.0-SNAPSHOT"}
}
Chrome/Postman is really helpful.
-j
---- 8< sample >8 ----
{
"id": "checkApplicationVersion",
"memberType": "action",
"links": [
{
"rel": "self",
"href": "http://localhost:9090/sdm-webapp/restful/services/cm.repofact.Endpoints/actions/checkApplicationVersion",
"method": "GET",
"type": "application/json;profile=\"urn:org.restfulobjects:repr-types/object-action\""
},
{
"rel": "up",
"href": "http://localhost:9090/sdm-webapp/restful/services/cm.repofact.Endpoints",
"method": "GET",
"type": "application/json;profile=\"urn:org.restfulobjects:repr-types/object\"",
"title": "Services"
},
{
"rel": "urn:org.restfulobjects:rels/invoke;action=\"checkApplicationVersion\"",
"href": "http://localhost:9090/sdm-webapp/restful/services/cm.repofact.Endpoints/actions/checkApplicationVersion/invoke",
"method": "GET",
"type": "application/json;profile=\"urn:org.restfulobjects:repr-types/object-action\"",
"arguments": {
"string1": {
"value": null
},
"string2": {
"value": null
}
}
},
{
"rel": "describedby",
"href": "http://localhost:9090/sdm-webapp/restful/domain-types/cm.repofact.Endpoints/actions/checkApplicationVersion",
"method": "GET",
"type": "application/json;profile=\"urn:org.restfulobjects:repr-types/action-description\""
}
],
"extensions": {
"actionType": "user",
"actionSemantics": "safe"
},
"parameters": {
"string1": {
"num": 0,
"id": "string1",
"name": "String 1",
"description": ""
},
"string2": {
"num": 1,
"id": "string2",
"name": "String 2",
"description": ""
}
}
}
-----Ursprüngliche Nachricht-----
Von: Kambiz Darabi [mailto:darabi@m-creations.com]
Gesendet: Mittwoch, 15. Juli 2015 15:29
An: Rade, Joerg / Kuehne + Nagel / Ham GI-PS
Cc: users@isis.apache.org
Betreff: Re: POSTing to an /objects/{domainType} resource
Hello Jörg,
On 2015-07-15 09:07 CEST, "Rade, Joerg / Kuehne + Nagel / Ham GI-PS" <Jo...@Kuehne-Nagel.com> wrote:
> Hi Kambiz,
>
> welcome to the list!
>
> When you GET http://<yourhost>:<yourport>/<your>-webapp/restful/services you should see a list of available resources.
>
> If you drill down further, e.g. to:
>
> http://<yourhost>:<yourport>/<your>-webapp/restful/services/<your.package>.<YourObjects>/actions/<yourAction>/ you will notice that arguments are listed e.g. as "string1", "string2", etc.
>
> Replacing e.g. "value" by "string1" may be worth a try.
thank you for the hint, but unfortunately it doesn't make any difference.
Thanks
Kambiz
Kühne + Nagel (AG & Co.) KG
Rechtsform: Kommanditgesellschaft, Bremen HRA 21928, USt-IdNr.: DE 812773878.
Geschäftsleitung Kühne + Nagel (AG & Co.) KG: Reiner Heiken (Vors.), Dirk Blesius, Martin Brinkmann, Matthias Heimbach, Jan-Hendrik Köstergarten, Christian Solf, Lars Wedel, Jens Wollesen.
Persönlich haftende Gesellschafterin: Kühne & Nagel A.G., Rechtsform: Aktiengesellschaft nach luxemburgischem Recht, HR-Nr.: B 18745, Geschäftsführendes Verwaltungsratsmitglied: Karl Gernandt.
Geschäftsleitung Region Westeuropa: Yngve Ruud (Vors.), Richard Huhn, Björn Johansson, Jan Kunze, Bruno Mang, Stefan Paul, Holger Ketz, Dominic Edmonds.
Wir arbeiten ausschließlich auf Grundlage der Allgemeinen Deutschen Spediteursbedingungen (ADSp), jeweils neuester Fassung. Wir verweisen insbesondere auf die vom Gesetz abweichenden Haftungsbeschränkungen von Ziffer 23 und 24 ADSp. Den vollständigen Text der ADSp übersenden wir Ihnen gerne auf Anfrage und können Sie auch unter http://www.kuehne-nagel.com einsehen. Ergänzend wird vereinbart, dass (1) Ziffer 27 ADSp im Rahmen internationaler Übereinkommen weder unsere Haftung noch die Zurechnung des Verschuldens von Leuten und sonstigen Dritten zu Gunsten des Auftraggebers erweitert, und (2) wir in den im deutschen Seehandelsrecht aufgeführten Fällen des nautischen Verschuldens oder Feuer an Bord nur für eigenes Verschulden und (3) im Sinne der CMNI genannten Voraussetzungen nicht für nautisches Verschulden, Feuer an Bord oder Mängel des Schiffes haften.
Re: POSTing to an /objects/{domainType} resource
Posted by Kambiz Darabi <da...@m-creations.com>.
Hello Jörg,
On 2015-07-15 09:07 CEST, "Rade, Joerg / Kuehne + Nagel / Ham GI-PS" <Jo...@Kuehne-Nagel.com> wrote:
> Hi Kambiz,
>
> welcome to the list!
>
> When you GET http://<yourhost>:<yourport>/<your>-webapp/restful/services you should see a list of available resources.
>
> If you drill down further, e.g. to:
>
> http://<yourhost>:<yourport>/<your>-webapp/restful/services/<your.package>.<YourObjects>/actions/<yourAction>/ you will notice that arguments are listed e.g. as "string1", "string2", etc.
>
> Replacing e.g. "value" by "string1" may be worth a try.
thank you for the hint, but unfortunately it doesn't make any
difference.
Thanks
Kambiz
AW: POSTing to an /objects/{domainType} resource
Posted by "Rade, Joerg / Kuehne + Nagel / Ham GI-PS" <Jo...@Kuehne-Nagel.com>.
Hi Kambiz,
welcome to the list!
When you GET http://<yourhost>:<yourport>/<your>-webapp/restful/services you should see a list of available resources.
If you drill down further, e.g. to:
http://<yourhost>:<yourport>/<your>-webapp/restful/services/<your.package>.<YourObjects>/actions/<yourAction>/ you will notice that arguments are listed e.g. as "string1", "string2", etc.
Replacing e.g. "value" by "string1" may be worth a try.
HTH
Jörg
-----Ursprüngliche Nachricht-----
Von: Kambiz Darabi [mailto:darabi@m-creations.com]
Gesendet: Dienstag, 14. Juli 2015 18:51
An: Isis Users
Betreff: POSTing to an /objects/{domainType} resource
Hello,
as a new user of Isis, I would first like to thank you for open-sourcing the software. I am a developer from Germany who is interested in using Isis (and RO) for a customer project.
Reading section 9 in the RO spec, I would have expected to be able to POST the following to http://~/objects/simple.SimpleObject/ (in
SimpleApp-PROTOTYPE-with-fixtures):
{
"members": {
"name": {
"value": "Quux"
}
}
}
but this leads to a 400 with the following warning:
199 RestfulObjects Could not find properties list (no members[objectMemberType=property]); got {"members":{"name":{"value":"Quux"}}}
I then debugged the application and had the impression that members must be an array and that each element must have the attribute objectMemberType set to "property":
{
"members" : [ {
"name" : {
"value": "Quux"
},
"objectMemberType": "property"
} ]
}
With such a JSON, the response is a '500 Server Error' and the logs show
Caused by: org.hsqldb.HsqlException: integrity constraint violation: NOT NULL check constraint; SYS_CT_10102 table: "SimpleObject" column: "name"
Debugging again shows that in ObjectAdapterUpdateHelper's copyOverProperties, the following is called with the id "name":
propertiesList.getRepresentation(id)
which returns null, so the property name is not copied to the object which is to be persisted, resulting in the NOT NULL exception.
I guess that I'm completely misunderstanding how I should use the resource.
Would someone be so kind to put me on the right track?
Thank you
Kambiz Darabi
--
m-creations gmbh
Acker 2
55116 Mainz
Germany
W: http://www.m-creations.com
E: darabi@m-creations.com
--
Registered Office: Mainz, HRB Mainz 7382 Managing Directors: Frank Pacholak, Kambiz Darabi
Kühne + Nagel (AG & Co.) KG
Rechtsform: Kommanditgesellschaft, Bremen HRA 21928, USt-IdNr.: DE 812773878.
Geschäftsleitung Kühne + Nagel (AG & Co.) KG: Reiner Heiken (Vors.), Dirk Blesius, Martin Brinkmann, Matthias Heimbach, Jan-Hendrik Köstergarten, Christian Solf, Lars Wedel, Jens Wollesen.
Persönlich haftende Gesellschafterin: Kühne & Nagel A.G., Rechtsform: Aktiengesellschaft nach luxemburgischem Recht, HR-Nr.: B 18745, Geschäftsführendes Verwaltungsratsmitglied: Karl Gernandt.
Geschäftsleitung Region Westeuropa: Yngve Ruud (Vors.), Richard Huhn, Björn Johansson, Jan Kunze, Bruno Mang, Stefan Paul, Holger Ketz, Dominic Edmonds.
Wir arbeiten ausschließlich auf Grundlage der Allgemeinen Deutschen Spediteursbedingungen (ADSp), jeweils neuester Fassung. Wir verweisen insbesondere auf die vom Gesetz abweichenden Haftungsbeschränkungen von Ziffer 23 und 24 ADSp. Den vollständigen Text der ADSp übersenden wir Ihnen gerne auf Anfrage und können Sie auch unter http://www.kuehne-nagel.com einsehen. Ergänzend wird vereinbart, dass (1) Ziffer 27 ADSp im Rahmen internationaler Übereinkommen weder unsere Haftung noch die Zurechnung des Verschuldens von Leuten und sonstigen Dritten zu Gunsten des Auftraggebers erweitert, und (2) wir in den im deutschen Seehandelsrecht aufgeführten Fällen des nautischen Verschuldens oder Feuer an Bord nur für eigenes Verschulden und (3) im Sinne der CMNI genannten Voraussetzungen nicht für nautisches Verschulden, Feuer an Bord oder Mängel des Schiffes haften.
Re: POSTing to an /objects/{domainType} resource
Posted by Kambiz Darabi <da...@m-creations.com>.
Hi,
thank you for the quick fix and the screencast!
I agree with the reservation against an 'objects of type' resource from
the DDD perspective. However, people with prior experience with other
types of restful APIs will find it quite natural to have to POST to an
URL which represents a type to create a new persistent object.
I don't have any strong feelings about this (until I have more
experience with Isis and RO), but I think that alignment with what has
become mainstream in restful API development would help a lot for
spreading RO and Isis. Especially if the service is to be consumed by
front-end developers who hand-craft the client code.
Thanks again
Kambiz
On 2015-07-17 12:17 CEST, Dan Haywood <da...@haywood-associates.co.uk> wrote:
> Hi Kambiz,
>
> as Jorg says, welcome to the list. Nice to hear that you are looking to
> Apache Isis and RO for your project.
>
> I took a look at the code, and it turns out it's not suprising you were
> having difficulties ... that bit of the code was actually broken.
>
> I've raised a ticket [1] and just pushed a release, so it's now working in
> 1.9.0-SNAPSHOT.
>
> I've also recorded a quick screencast [2] (the second one in that section),
> so you can see it working. (Apologies for the slightly duff audio on it...
> I don't actually have a lisp!). You might also want to check out the other
> screencast on RO there, too.
>
> Of course, if you want to try this out then you'll need to build Isis from
> source; it's not difficult to do [3].
>
> ~~~
> Also, in the video I do make the remark that I may very well remove the
> "objects for type" resource; it breaks hypermedia, and - as Udi Dahan
> pointed out in this old blog post [4] - I don't actually think it's good
> domain modelling either. You might have your own opinions on that?
>
> Cheers
> Dan
>
>
> [1] https://issues.apache.org/jira/browse/ISIS-1174
> [2] http://localhost:4000/screencasts.html#_restful_objects_viewer
> [3] http://isis.apache.org/guides/cg.html#_cg_building-isis
> [4] http://www.udidahan.com/2009/06/29/dont-create-aggregate-roots/
>
>
>
> On 14 July 2015 at 17:50, Kambiz Darabi <da...@m-creations.com> wrote:
>
>> Hello,
>>
>> as a new user of Isis, I would first like to thank you for open-sourcing
>> the software. I am a developer from Germany who is interested in using
>> Isis (and RO) for a customer project.
>>
>> Reading section 9 in the RO spec, I would have expected to be able to
>> POST the following to http://~/objects/simple.SimpleObject/ (in
>> SimpleApp-PROTOTYPE-with-fixtures):
>>
>> {
>> "members": {
>> "name": {
>> "value": "Quux"
>> }
>> }
>> }
>>
>> but this leads to a 400 with the following warning:
>>
>> 199 RestfulObjects Could not find properties list (no
>> members[objectMemberType=property]); got
>> {"members":{"name":{"value":"Quux"}}}
>>
>> I then debugged the application and had the impression that members must
>> be an array and that each element must have the attribute
>> objectMemberType set to "property":
>>
>> {
>> "members" : [ {
>> "name" : {
>> "value": "Quux"
>> },
>> "objectMemberType": "property"
>> } ]
>> }
>>
>> With such a JSON, the response is a '500 Server Error' and the logs show
>>
>> Caused by: org.hsqldb.HsqlException: integrity constraint violation: NOT
>> NULL check constraint; SYS_CT_10102 table: "SimpleObject" column: "name"
>>
>> Debugging again shows that in ObjectAdapterUpdateHelper's
>> copyOverProperties, the following is called with the id "name":
>>
>> propertiesList.getRepresentation(id)
>>
>> which returns null, so the property name is not copied to the object
>> which is to be persisted, resulting in the NOT NULL exception.
>>
>>
>> I guess that I'm completely misunderstanding how I should use the
>> resource.
>>
>> Would someone be so kind to put me on the right track?
>>
>>
>> Thank you
>>
>>
>> Kambiz Darabi
>> --
>> m-creations gmbh
>> Acker 2
>> 55116 Mainz
>> Germany
>>
>> W: http://www.m-creations.com
>> E: darabi@m-creations.com
>> --
>> Registered Office: Mainz, HRB Mainz 7382
>> Managing Directors: Frank Pacholak, Kambiz Darabi
>>
Re: POSTing to an /objects/{domainType} resource
Posted by Dan Haywood <da...@haywood-associates.co.uk>.
On 17 July 2015 at 11:38, Martin Grigorov <mg...@apache.org> wrote:
> Hi Dan,
>
> >
> > [1] https://issues.apache.org/jira/browse/ISIS-1174
> > [2] http://localhost:4000/screencasts.html#_restful_objects_viewer
>
>
> It took me a bit to get access to your machine (localhost). To save some
> time to the others I'd suggest them to use
> https://www.youtube.com/watch?v=VmvhACyA2ZI instead ;)
>
>
Doh! that was dumb of me!
That should've been
http://isis.apache.org/screencasts.html#_restful_objects_viewer
Thanks for the catch!
Cheers
Dan
Re: POSTing to an /objects/{domainType} resource
Posted by Martin Grigorov <mg...@apache.org>.
Hi Dan,
On Fri, Jul 17, 2015 at 1:17 PM, Dan Haywood <da...@haywood-associates.co.uk>
wrote:
> Hi Kambiz,
>
> as Jorg says, welcome to the list. Nice to hear that you are looking to
> Apache Isis and RO for your project.
>
> I took a look at the code, and it turns out it's not suprising you were
> having difficulties ... that bit of the code was actually broken.
>
> I've raised a ticket [1] and just pushed a release, so it's now working in
> 1.9.0-SNAPSHOT.
>
> I've also recorded a quick screencast [2] (the second one in that section),
> so you can see it working. (Apologies for the slightly duff audio on it...
> I don't actually have a lisp!). You might also want to check out the other
> screencast on RO there, too.
>
> Of course, if you want to try this out then you'll need to build Isis from
> source; it's not difficult to do [3].
>
> ~~~
> Also, in the video I do make the remark that I may very well remove the
> "objects for type" resource; it breaks hypermedia, and - as Udi Dahan
> pointed out in this old blog post [4] - I don't actually think it's good
> domain modelling either. You might have your own opinions on that?
>
> Cheers
> Dan
>
>
> [1] https://issues.apache.org/jira/browse/ISIS-1174
> [2] http://localhost:4000/screencasts.html#_restful_objects_viewer
It took me a bit to get access to your machine (localhost). To save some
time to the others I'd suggest them to use
https://www.youtube.com/watch?v=VmvhACyA2ZI instead ;)
>
> [3] http://isis.apache.org/guides/cg.html#_cg_building-isis
> [4] http://www.udidahan.com/2009/06/29/dont-create-aggregate-roots/
>
>
>
> On 14 July 2015 at 17:50, Kambiz Darabi <da...@m-creations.com> wrote:
>
> > Hello,
> >
> > as a new user of Isis, I would first like to thank you for open-sourcing
> > the software. I am a developer from Germany who is interested in using
> > Isis (and RO) for a customer project.
> >
> > Reading section 9 in the RO spec, I would have expected to be able to
> > POST the following to http://~/objects/simple.SimpleObject/ (in
> > SimpleApp-PROTOTYPE-with-fixtures):
> >
> > {
> > "members": {
> > "name": {
> > "value": "Quux"
> > }
> > }
> > }
> >
> > but this leads to a 400 with the following warning:
> >
> > 199 RestfulObjects Could not find properties list (no
> > members[objectMemberType=property]); got
> > {"members":{"name":{"value":"Quux"}}}
> >
> > I then debugged the application and had the impression that members must
> > be an array and that each element must have the attribute
> > objectMemberType set to "property":
> >
> > {
> > "members" : [ {
> > "name" : {
> > "value": "Quux"
> > },
> > "objectMemberType": "property"
> > } ]
> > }
> >
> > With such a JSON, the response is a '500 Server Error' and the logs show
> >
> > Caused by: org.hsqldb.HsqlException: integrity constraint violation: NOT
> > NULL check constraint; SYS_CT_10102 table: "SimpleObject" column: "name"
> >
> > Debugging again shows that in ObjectAdapterUpdateHelper's
> > copyOverProperties, the following is called with the id "name":
> >
> > propertiesList.getRepresentation(id)
> >
> > which returns null, so the property name is not copied to the object
> > which is to be persisted, resulting in the NOT NULL exception.
> >
> >
> > I guess that I'm completely misunderstanding how I should use the
> > resource.
> >
> > Would someone be so kind to put me on the right track?
> >
> >
> > Thank you
> >
> >
> > Kambiz Darabi
> > --
> > m-creations gmbh
> > Acker 2
> > 55116 Mainz
> > Germany
> >
> > W: http://www.m-creations.com
> > E: darabi@m-creations.com
> > --
> > Registered Office: Mainz, HRB Mainz 7382
> > Managing Directors: Frank Pacholak, Kambiz Darabi
> >
>
Re: POSTing to an /objects/{domainType} resource
Posted by Dan Haywood <da...@haywood-associates.co.uk>.
Hi Kambiz,
as Jorg says, welcome to the list. Nice to hear that you are looking to
Apache Isis and RO for your project.
I took a look at the code, and it turns out it's not suprising you were
having difficulties ... that bit of the code was actually broken.
I've raised a ticket [1] and just pushed a release, so it's now working in
1.9.0-SNAPSHOT.
I've also recorded a quick screencast [2] (the second one in that section),
so you can see it working. (Apologies for the slightly duff audio on it...
I don't actually have a lisp!). You might also want to check out the other
screencast on RO there, too.
Of course, if you want to try this out then you'll need to build Isis from
source; it's not difficult to do [3].
~~~
Also, in the video I do make the remark that I may very well remove the
"objects for type" resource; it breaks hypermedia, and - as Udi Dahan
pointed out in this old blog post [4] - I don't actually think it's good
domain modelling either. You might have your own opinions on that?
Cheers
Dan
[1] https://issues.apache.org/jira/browse/ISIS-1174
[2] http://localhost:4000/screencasts.html#_restful_objects_viewer
[3] http://isis.apache.org/guides/cg.html#_cg_building-isis
[4] http://www.udidahan.com/2009/06/29/dont-create-aggregate-roots/
On 14 July 2015 at 17:50, Kambiz Darabi <da...@m-creations.com> wrote:
> Hello,
>
> as a new user of Isis, I would first like to thank you for open-sourcing
> the software. I am a developer from Germany who is interested in using
> Isis (and RO) for a customer project.
>
> Reading section 9 in the RO spec, I would have expected to be able to
> POST the following to http://~/objects/simple.SimpleObject/ (in
> SimpleApp-PROTOTYPE-with-fixtures):
>
> {
> "members": {
> "name": {
> "value": "Quux"
> }
> }
> }
>
> but this leads to a 400 with the following warning:
>
> 199 RestfulObjects Could not find properties list (no
> members[objectMemberType=property]); got
> {"members":{"name":{"value":"Quux"}}}
>
> I then debugged the application and had the impression that members must
> be an array and that each element must have the attribute
> objectMemberType set to "property":
>
> {
> "members" : [ {
> "name" : {
> "value": "Quux"
> },
> "objectMemberType": "property"
> } ]
> }
>
> With such a JSON, the response is a '500 Server Error' and the logs show
>
> Caused by: org.hsqldb.HsqlException: integrity constraint violation: NOT
> NULL check constraint; SYS_CT_10102 table: "SimpleObject" column: "name"
>
> Debugging again shows that in ObjectAdapterUpdateHelper's
> copyOverProperties, the following is called with the id "name":
>
> propertiesList.getRepresentation(id)
>
> which returns null, so the property name is not copied to the object
> which is to be persisted, resulting in the NOT NULL exception.
>
>
> I guess that I'm completely misunderstanding how I should use the
> resource.
>
> Would someone be so kind to put me on the right track?
>
>
> Thank you
>
>
> Kambiz Darabi
> --
> m-creations gmbh
> Acker 2
> 55116 Mainz
> Germany
>
> W: http://www.m-creations.com
> E: darabi@m-creations.com
> --
> Registered Office: Mainz, HRB Mainz 7382
> Managing Directors: Frank Pacholak, Kambiz Darabi
>