Hello Dan, Thank you very much for your response. Unfortunately I haven’t been involved in the development of the app thus far, my involvement now is to build a user interface. However a quick look in our “ContextAwareAbstractFactoryAndRepository” class shows that a BookmarkService is being utilised. It appears that some instance ID is being stored in the session.
On the upside, I have refactored our app to not utilise this class. While I’m sure I have broken some business logic, this has yielded success for the Rest API calls. The operations I was battling with earlier are now working properly. I will consult with my collages that were involved in the development of the app and I’m sure we will be abel to work around our implementation error. Thank you very much, you’ve been a tremendous help to me! Regards, Michael > On 07 Apr 2015, at 10:32 AM, Dan Haywood <[email protected]> > wrote: > > Hi Michael, > > some thoughts within... > > > On 7 April 2015 at 07:21, Michael Kyrilov <[email protected] > ><mailto:[email protected]>> wrote: > >> >> Lets look at a simple one first. >> >> The URL is: >> http://localhost:8080/restful/services/com.ecntelecoms.vbx.domain.contact.Users/actions/listAll >> >> <http://localhost:8080/restful/services/com.ecntelecoms.vbx.domain.contact.Users/actions/listAll> >> < >> http://localhost:8080/restful/services/com.ecntelecoms.vbx.domain.contact.Users/actions/listAll >> >> <http://localhost:8080/restful/services/com.ecntelecoms.vbx.domain.contact.Users/actions/listAll> >>> >> The following is what I see onscreen: >> { >> > ... > >> , { >> "rel" : "urn:org.restfulobjects:rels/invoke;action=\"listAll\"", >> "href" : " >> http://localhost:8080/restful/services/com.ecntelecoms.vbx.domain.contact.Users/actions/listAll/invoke >> >> <http://localhost:8080/restful/services/com.ecntelecoms.vbx.domain.contact.Users/actions/listAll/invoke> >> ", >> "method" : "GET", >> "type" : >> "application/json;profile=\"urn:org.restfulobjects:repr-types/object-action\"", >> "arguments" : { } >> }, >> > ... > >> } >> My understanding of this is that if I visit: >> http://localhost:8080/restful/services/com.ecntelecoms.vbx.domain.contact.Users/actions/listAll/invoke >> >> <http://localhost:8080/restful/services/com.ecntelecoms.vbx.domain.contact.Users/actions/listAll/invoke> >> < >> http://localhost:8080/restful/services/com.ecntelecoms.vbx.domain.contact.Users/actions/listAll/invoke >> >> <http://localhost:8080/restful/services/com.ecntelecoms.vbx.domain.contact.Users/actions/listAll/invoke> >>> >> with no arguments I should get a list of all my Users from the database. >> > > > yes, that's correct. > > > >> This is not the case, in fact I get an error message: >> { >> "message" : "There is no application attached to current thread >> 1501572129@qtp-836514715-3", >> "stackTrace" : [ > > > >> "org.apache.wicket.Application.get(Application.java:239)", > > > >> "org.apache.wicket.protocol.http.WebApplication.get(WebApplication.java:156)", >> > > > >> "org.apache.isis.viewer.wicket.viewer.IsisWicketApplication.get(IsisWicketApplication.java:134)", >> > > > >> "com.ecntelecoms.vbx.domain.ContextAwareAbstractFactoryAndRepository.contextVpbx(ContextAwareAbstractFactoryAndRepository.java:30)", >> > > > >> "com.ecntelecoms.vbx.domain.contact.Users.listAll(Users.java:37)", > > > ... > > >> "org.apache.isis.viewer.restfulobjects.server.resources.DomainServiceResourceServerside.invokeActionQueryOnly(DomainServiceResourceServerside.java:165)", >> > > > >> Here I am interested to know if this is an implementation problem in our >> app or if I am misusing the API? >> >> > A bit of both, I think. > > The stacktrace shows that in your class > ContextAwareAbstractFactoryAndRepository.contextVpbx(...) you are calling > the Wicket API. However, the Wicket application is only available when the > domain objects are interacted with through the Wicket viewer, which isn't > the case here, of course. > > Do you know why ContextAwareAbstractFactoryAndRepository needs Wicket > application? I think that will need to be refactored/abstracted somehow > such that your domain objects can also be used from the RO viewer. > > Also, if you want to do any integration testing of your classes, removing > that dependency on Wicket is probably a good idea. > > > > >> >> >> A more complicated scenario: >> The URL is: >> http://localhost:8080/restful/services/com.ecntelecoms.vbx.domain.contact.Users/actions/create >> >> <http://localhost:8080/restful/services/com.ecntelecoms.vbx.domain.contact.Users/actions/create> >> < >> http://localhost:8080/restful/services/com.ecntelecoms.vbx.domain.contact.Users/actions/create >> >> <http://localhost:8080/restful/services/com.ecntelecoms.vbx.domain.contact.Users/actions/create> >>> >> Again we are dealing with the Users object, but this time we’d like to >> create a new user. >> The following is what I see on screen: >> { >> > ... > >> }, { >> "rel" : "urn:org.restfulobjects:rels/invoke;action=\"create\"", >> "href" : " >> http://localhost:8080/restful/services/com.ecntelecoms.vbx.domain.contact.Users/actions/create/invoke >> >> <http://localhost:8080/restful/services/com.ecntelecoms.vbx.domain.contact.Users/actions/create/invoke> >> ", >> "method" : "POST", >> "type" : >> "application/json;profile=\"urn:org.restfulobjects:repr-types/object-action\"", >> "arguments" : { >> "firstName" : { >> "value" : null >> }, >> "lastName" : { >> "value" : null >> }, >> "pIN" : { >> "value" : null >> }, >> "type" : { >> "value" : null >> } >> } >> }, > > > >> ... >> "parameters" : { >> "firstName" : { >> "num" : 0, >> "id" : "firstName", >> "name" : "First Name", >> "description" : "" >> }, >> "lastName" : { >> "num" : 1, >> "id" : "lastName", >> "name" : "Last Name", >> "description" : "" >> }, >> "pIN" : { >> "num" : 2, >> "id" : "pIN", >> "name" : "PIN", >> "description" : "" >> }, >> "type" : { >> "num" : 3, >> "id" : "type", >> "name" : "Type", >> "description" : "", >> "choices" : [ "some_user_type", "another_user_type", "super_user" ] >> } >> } >> } >> So here I do a POST request to: >> http://localhost:8080/restful/services/com.ecntelecoms.vbx.domain.contact.Users/actions/create/invoke >> >> <http://localhost:8080/restful/services/com.ecntelecoms.vbx.domain.contact.Users/actions/create/invoke> >> >> with the following body as JSON: >> >> { >> "firstName": { >> "value": "REST" >> }, >> "lastName": { >> "value": "FUL" >> }, >> "pIN": { >> "value": "1234" >> }, >> "type": { >> "value": "super_user" >> } >> } >> >> > > This looks correct to me. > > > >> This is the response I get: >> { >> "httpStatusCode" : 0, >> "message" : "Unrecognized token 'firstName': was expecting \n at >> [Source: java.io.StringReader@38d5fe99; line: 1, column: 10]", >> > > seems like some sort of parsing issue. Given what you describe below, > perhaps depends on what you mean by "send as JSON"... > > reading on.... > > > >> >> I have also tried sending the POST request with a string body, in that >> case we get: >> { >> "message" : "There is no application attached to current thread >> 1501572129@qtp-836514715-3", >> "stackTrace" : [ > > > >> "org.apache.wicket.Application.get(Application.java:239)", > > > >> "org.apache.wicket.protocol.http.WebApplication.get(WebApplication.java:156)", >> > > > >> "org.apache.isis.viewer.wicket.viewer.IsisWicketApplication.get(IsisWicketApplication.java:134)", >> > > > >> "com.ecntelecoms.vbx.domain.ContextAwareAbstractFactoryAndRepository.contextVpbx(ContextAwareAbstractFactoryAndRepository.java:30)", >> > > > >> "com.ecntelecoms.vbx.domain.contact.Users.create(Users.java:66)", > > ... > >> "org.apache.isis.viewer.restfulobjects.server.resources.DomainServiceResourceServerside.invokeAction(DomainServiceResourceServerside.java:204)", >> > > > > However you submitted the request here ("as a string body") has worked; the > stack trace shows that the Users#create method has been called. And then > we have the same issue as before; there is no Wicket application available. > > > > >> I’d like to thank you for taking the time to read through my questions. >> > > No worries! > > >> I know I have provided a very specific example, however I feel that if a >> solution is found here, others can more easily adapt that to their own work. >> >> > Indeed. I don't know if there's anywhere that we have explicitly > documented that the Wicket API is not available if invoked via the RO > viewer. It's probably "obvious" if one knows how Isis works internally; > but that's hardly the point. > > Come back to us if you need help abstracting away that usage of the Wicket > API. > > Cheers > Dan > > > > >> Regards, >> Michael >> >>> On 02 Apr 2015, at 2:58 PM, Hiruni Madola <[email protected] >>> ><mailto:[email protected]>> >> wrote: >>> >>> Hi Dan, >>> >>> I got a related question about parameter passing when invoking ISIS Rest >>> API. >>> >>> In my sample service I have a method to echo the parameter I pass to it. >>> >>> public String echoParam(String param) >>> { >>> return "echo "+param ; >>> } >>> >>> I invoke this using curl as : >>> curl -X POST -u sven:pass >>> >> http://localhost:8080/restful/services/EchoService/actions/echoParam/invoke?param=hello >> >> <http://localhost:8080/restful/services/EchoService/actions/echoParam/invoke?param=hello> >>> >>> I cannot get the desire result and I get below as the response; >>> {"param":{"value":"hello"},"x-ro-invalidReason":"Argument 'param' found >> but >>> no such parameter"} >>> >>> Can you please advice on how to pass a parameter to the REST service when >>> invoking via a REST client? >>> >>> Regards, >>> Hiruni >>> >>> On Thu, Apr 2, 2015 at 5:21 PM, Dan Haywood < >> [email protected] <mailto:[email protected]>> >>> wrote: >>> >>>> Hi Michael, >>>> >>>> The Apache mailing lists don't accept documents, as you've discovered. >>>> >>>> Although you can mail me directly if you want [1], I'd rather you simply >>>> paste your questions here... that way your questions and hopefully some >>>> answers will be available to others in the community to discover/learn >>>> from. >>>> >>>> ~~~ >>>> Meanwhile, for some additional ideas on how to use the RO API, take a >> look >>>> at our (incomplete) TCK tests [2]. >>>> >>>> I'm also aware of this bespoke Angular app [3] that's being written as a >>>> front-end to this Isis back-end [4]; might give you some ideas. >>>> >>>> Another option, if the full RO representations are a built >> overwhelming, is >>>> either to configure Isis to provide a simplified representation [5] or >> you >>>> could even use custom representations [6]. >>>> >>>> HTH >>>> Dan >>>> >>>> >>>> >>>> >>>> [1] https://github.com/apache/isis/blob/master/core/pom.xml#L201 >>>> <https://github.com/apache/isis/blob/master/core/pom.xml#L201> >>>> [2] >>>> >>>> >> https://github.com/apache/isis/tree/master/tck/tck-viewer-restfulobjects/src/test/java/org/apache/isis/viewer/restfulobjects/tck >> >> <https://github.com/apache/isis/tree/master/tck/tck-viewer-restfulobjects/src/test/java/org/apache/isis/viewer/restfulobjects/tck> >>>> [3] https://github.com/edge-art/matchingfront >>>> <https://github.com/edge-art/matchingfront> >>>> [4] https://github.com/johandoornenbal/matching >>>> <https://github.com/johandoornenbal/matching> >>>> [5] >>>> >>>> >> http://isis.apache.org/components/viewers/restfulobjects/simplified-object-representation.html >> >> <http://isis.apache.org/components/viewers/restfulobjects/simplified-object-representation.html> >>>> [6] >>>> >>>> >> http://isis.apache.org/components/viewers/restfulobjects/custom-representations.html >> >> <http://isis.apache.org/components/viewers/restfulobjects/custom-representations.html> >>>> >>>> >>>> >>>> >>>> On 2 April 2015 at 12:15, Michael Kyrilov <[email protected]> wrote: >>>> >>>>> Hi Dan, >>>>> >>>>> I had looked at the Restful Objects document, unfortunately I am still >>>>> unsure of how to work with he API. >>>>> >>>>> I have prepared a short PDF highlighting what exactly my struggles are. >>>>> Unfortunately I don’t seem to be able to send it to you. Every time I >>>> try, >>>>> I get a failed notice from [email protected] <mailto: >>>>> [email protected]> >>>>> Is there any other way I say send you this document? >>>>> >>>>> Regards, >>>>> Michael >>>>> >>>>>> On 02 Apr 2015, at 9:46 AM, Dan Haywood <[email protected] >>> >>>>> wrote: >>>>>> >>>>>> Hi Michael, >>>>>> Have you taken a look at the Restful Objects spec? That should give >>>> you a >>>>>> good background so you can start to understand what Isis Rest API is >>>>>> surfacing for you. >>>>>> >>>>>> Cheers, Dan >>>>>> >>>>>> http://restfulobjects.org >>>>>> On 2 Apr 2015 08:35, "Michael Kyrilov" <[email protected]> wrote: >>>>>> >>>>>>> Hi there, >>>>>>> >>>>>>> My name is Michael. I have recently been tasked to develop a User >>>>>>> Interface on top of an Apache Isis application. >>>>>>> Isis was originally chosen due to time constrains for the project, >>>> this >>>>>>> way the team was able to get a functional UI but remain heavily >>>> focused >>>>> on >>>>>>> implementing the business logic. >>>>>>> >>>>>>> Our understanding is that Isis provides a REST API for interacting >>>> with >>>>>>> the domain model, which sounds ideal for building a User Interface. >>>>>>> I have managed to locate an API: http://host:port/restful/ >>>>>>> >>>>>>> I am having difficulties understanding how to interact with this API. >>>>>>> I do see that /services the models we have defined and /domain-types >>>>> does >>>>>>> much the same. >>>>>>> We do have data in the database and the difficulty I am having is >>>> that I >>>>>>> am unable to get data out of this API and I also don’t see how I can >>>>> POST >>>>>>> data via the API so that it would be saved in the database. >>>>>>> >>>>>>> >>>>>>> I am not sure if I am misunderstanding how this works or if I am >>>> trying >>>>> to >>>>>>> use it inappropriately. >>>>>>> >>>>>>> >>>>>>> Thank you >>>>>>> Regards, >>>>>>> Michael >>>>>>> >>>>>>> Michael Kyrilov >>>>>>> Mid-Level Developer >>>>>>> >>>>>>> >>>>>>> [http://static.ecntelecoms.za.net/images/ecn-logo.png] >>>>>>> >>>>>>> Unit 10 Growthpoint Business Park >>>>>>> 2 Tonnetti Street, Midrand, 1685 >>>>>>> Office: +27 10 590 0035 >>>>>>> Cell: +27 72 634 9687 >>>>>>> >>>>>>> [email protected] >>>>>>> www.ecn.co.za<http://www.ecn.co.za/> >>>>>>> >>>>>>> >>>>>>> This email is sent subject to the terms and conditions detailed in >> the >>>>>>> ECN Email Disclaimer< >>>>>>> >>>>> >> http://www.nashuacommunications.com/disclaimer-and-confidentiality-note/ >>>>> >>>>>>> >>>>>>> Disclaimer >>>>>>> >>>>>>> The information contained in this communication from the sender is >>>>>>> confidential. It is intended solely for use by the recipient and >>>> others >>>>>>> authorized to receive it. >>>>>>> If you are not the recipient, you are hereby notified that any >>>>> disclosure, >>>>>>> copying, distribution or taking action in relation of the contents of >>>>> this >>>>>>> information is strictly prohibited and may be unlawful. >>>>>>> >>>>>>> This email has been scanned for viruses and malware. >>>>> >>>>> Disclaimer >>>>> >>>>> The information contained in this communication from the sender is >>>>> confidential. It is intended solely for use by the recipient and others >>>>> authorized to receive it. >>>>> If you are not the recipient, you are hereby notified that any >>>> disclosure, >>>>> copying, distribution or taking action in relation of the contents of >>>> this >>>>> information is strictly prohibited and may be unlawful. >>>>> >>>>> This email has been scanned for viruses and malware. >>>>> >>>> >>> >>> >>> >>> -- >>> Hiru >> >> Disclaimer >> >> The information contained in this communication from the sender is >> confidential. It is intended solely for use by the recipient and others >> authorized to receive it. >> If you are not the recipient, you are hereby notified that any disclosure, >> copying, distribution or taking action in relation of the contents of this >> information is strictly prohibited and may be unlawful. >> >> This email has been scanned for viruses and malware. Disclaimer The information contained in this communication from the sender is confidential. It is intended solely for use by the recipient and others authorized to receive it. If you are not the recipient, you are hereby notified that any disclosure, copying, distribution or taking action in relation of the contents of this information is strictly prohibited and may be unlawful. This email has been scanned for viruses and malware.
