isis-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dan Haywood <...@haywood-associates.co.uk>
Subject Re: Questions for the Rest Interface for DomainService
Date Tue, 10 Feb 2015 08:14:05 GMT
On 10 February 2015 at 07:33, Lechner Andreas <alechner@at.focusmr.com>
wrote:

> hi,
>
> thank you Dan, and Martin also.
>
> The hint with the reference of DeliGroup was useful.
>
>
Glad you have it sorted.



> I had to add "I_" before the ObjectID to get it working with my
> postgresql database.
>
>
That "I_" prefix is the way in which the RO viewer encodes an integer.  For
a long it would be "L_" etc.

That said, strictly speaking you should consider the URL as opaque  The
value to provide is that of the "links[self].href" in the representation of
the entity you want to reference.

Cheers
Dan



> Here my working result:
>
> {
>     "deliverableName": {"value": "NAME_ABC5"},
>     "deliverableDescription": {"value": "DESC_ABC5"},
>     "deliGroup": {"value": {"href": "
> http://localhost:8080/restful/objects/DeliGroup/I_3"}}
> }
>
> br
> Andreas
>
> ----- Urspr√ľngliche Mail -----
> Von: "Dan Haywood" <dan@haywood-associates.co.uk>
> An: "users" <users@isis.apache.org>
> Gesendet: Sonntag, 8. Februar 2015 12:52:07
> Betreff: Re: Questions for the Rest Interface for DomainService
>
> On 5 February 2015 at 14:22, Lechner Andreas <alechner@at.focusmr.com>
> wrote:
>
> > public class DeliverableService {
> >
> >
> >         @NotContributed
> >         @MemberOrder(sequence = "2")
> >         @Named("Create New Deliverable")
> >         public Deliverable createNew(final @Named("DeliverableName")
> > String deliverableName,
> >                         final @Named("DeliverableDescription") String
> > deliverableDescription,
> >                         final @Named("DeliGroup") DeliGroup deliGroup
> >                 ) {
> >
> >          }
> > -------------------------------------
> >
> >
> > now I want to call this service over the rest interface.
> > I think the URL should be
> >
> >
> http://localhost:8080/restful/services/DeliverableService/actions/createNew/invoke
> >
> >
> > I tried to test it over the "RESTClient" Plugin for Firefox with
> following
> > JSON String
> >
> > JSON String:
> > {
> >     "deliverableName": {"value": "NAME_ABC"},
> >     "deliverableDescription": {"value": "DESC_ABC"},
> >     "deliGroup": {
> >         "historyId": { "value": "1"},
> >         "deliGroupName": { "value": "Factored" }
> >     }
> > }
> >
> > After removing the "deliGroup" part in DomainService class, and in the
> > JSON String, it was working.
> > {
> >     "deliverableName": {"value": "NAME_ABC"},
> >     "deliverableDescription": {"value": "DESC_ABC"}
> > }
> >
> > How has the JSON String to look?
> >
> >
>
> The Restful Objects spec [1] explains how to submit arguments that are
> references to entity types (such as "DeliGroup"); basically you send a
> "value.href" pointing to the object; see section 2.9.2.1
>
> Something like:
>
> {
>     "deliverableName": {"value": "NAME_ABC"},
>     "deliverableDescription": {"value": "DESC_ABC"},
>     "deliGroup": { "value": { "href": "
> http://localhost:8080/restful/objects/DeliGroup/1" } }
> }
>
> As for submitting this JSON, it is described in section 2.10; basically:
> * if the action has "safe" semantics, ie invoked via HTTP GET, then this
> string is URL encoded and appended to the end of the URL (after the ?).
> * if the action has "Idempotent" semantics (invoked via HTTP PUT) or
> non-idempotent semantics (invoked via HTTP POST) then the JSON string is
> simply the body of the request.
>
> HTH
> Dan
>
> [1] http://restfulobjects.org/download/
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message