I must be missing some fundamental concept here.
I’m not sure exactly what you mean by “default json rendering of resources”. 
I’m after structure data here, not actual content rendering.
I just want to be able to obtain self & child references in json responses so 
the UI can create the appropriate tree structure to navigate the JCR data.
The actual representation of the leaf node data will be specific to that data 
type and handled by the client UI.

-Bruce

From: Sarwar Bhuiyan <[email protected]<mailto:[email protected]>>
Reply-To: "[email protected]<mailto:[email protected]>" 
<[email protected]<mailto:[email protected]>>
Date: Wednesday, November 12, 2014 at 11:20 AM
To: "[email protected]<mailto:[email protected]>" 
<[email protected]<mailto:[email protected]>>
Subject: Re: HATEOAS compliant json self/child references from sling?

Bruce, it's not the format that's the problem. It's the default json
rendering of resources that's the issue for things exposed to the public
side. Typically what we do for the web side of things is either write our
own servlets or component jsps where we can have more control of what to
output.

On Wednesday, November 12, 2014, Bruce Edge 
<[email protected]<mailto:[email protected]>>
wrote:

I can understand how exposing that level of structure may be a risk in
some circumstances but it allows for a huge leg up on the client side code.
Things like https://github.com/GonzaloAlvarez/restangular-hateoas provide
a superbly simple way to wrap a UI around the whole thing if you have
HATEOAS on the server side. It’s as close as you can get to a CRUD UI with
seriously minimal code.
Also, this is the data format provided by spring-data-rest, so it’s a
format that already has wide acceptance.

I suppose one could enable this only for specific paths if security was a
concern.

-Bruce

From: Jason Bailey <[email protected]<mailto:[email protected]> 
<javascript:;><mailto:
[email protected]<mailto:[email protected]> <javascript:;>>>
Reply-To: "[email protected]<mailto:[email protected]> 
<javascript:;><mailto:
[email protected]<mailto:[email protected]> <javascript:;>>" 
<[email protected]<mailto:[email protected]>
<javascript:;><mailto:[email protected] <javascript:;>>>
Date: Wednesday, November 12, 2014 at 11:05 AM
To: "[email protected]<mailto:[email protected]> 
<javascript:;><mailto:[email protected]
<javascript:;>>" <[email protected]<mailto:[email protected]> 
<javascript:;><mailto:
[email protected]<mailto:[email protected]> <javascript:;>>>
Subject: RE: HATEOAS compliant json self/child references from sling?

Not unless you add it yourself. As a note, you may not want to design your
application where you are relying on the default json renderer to supply
information to the front end client. It can reveal more information and
structure then a lot of people are comfortable with.

-----Original Message-----
From: Bruce Edge [mailto:[email protected] <javascript:;>]
Sent: Wednesday, November 12, 2014 1:49 PM
To: users
Subject: HATEOAS compliant json self/child references from sling?

Can one retrieve HATEOAS format responses form sling?

%> curl -qu admin:admin http://localhost:8090/var/content.tidy.json
{
   "jcr:createdBy": "admin",
   "jcr:mimeType": "application/octet-stream",
   "jcr:created": "Sat Nov 08 2014 16:17:51 GMT-0800",
   "jcr:lastModified": "Sat Nov 08 2014 16:17:51 GMT-0800",
   "jcr:primaryType": "sling:Folder"
}

Using a HATEOAS server I would expect something like this:
{
   "jcr:createdBy": "admin",
   "jcr:mimeType": "application/octet-stream",
   "jcr:created": "Sat Nov 08 2014 16:17:51 GMT-0800",
   "jcr:lastModified": "Sat Nov 08 2014 16:17:51 GMT-0800",
   "jcr:primaryType": ³sling:Folder"
"_links":{
     "self":{
       "href":"http://localhost:8090/var/content";
     }
   }
}

Is it possible to have sling insert both self and child references into
all json responses?

-Bruce




Reply via email to