Apologies for the delayed response. I was out of town and unexpectedly wasn't able to connect to email.
We actually are using the :operation=import POST using json and it works quite well. But it doesn't seem like there is a modify/update operation that also takes in json. I believe using import for nodes that already exist gives an error (which makes sense to me), but I don't see a way to send json with the modify operation. This would mostly be useful for updating the entire DTO graph with one POST. We can absolutely write something to convert the DTO graph into properties and POST those out node by node, but it got me thinking maybe I was going down an untrodden path. Thanks for your help, Mike -----Original Message----- From: Julian Sedding [mailto:[email protected]] Sent: Friday, July 24, 2015 6:00 AM To: [email protected] Subject: Re: Best practices for java DTOs to/from Sling Documentation for JSON import via the SLing POST Servlet is available here: http://sling.apache.org/documentation/bundles/manipulating-content-the-slingpostservlet-servlets-post.html#importing-content-structures Regards Julian On Thu, Jul 23, 2015 at 2:35 PM, Jason Bailey <[email protected]> wrote: > The occasional problem with Sling is that the feature set moves faster than > the documentation. > > Support for modification of content via JSON has been implemented. Here's > some relevant links: > https://cwiki.apache.org/confluence/display/SLING/FAQ#FAQ-HowdoIcreateanodebypostingajsondocumenttoaURL? > https://issues.apache.org/jira/browse/SLING-1172 > > As you can tell, this was actually completed a while back. So the problem > you're experiencing is either a bug(new or regression) or there's a problem > with how you implemented > > Can you provide a simple use case of the problem you're having posting json? > > -Jason > > -----Original Message----- > From: Haefele, Michael [mailto:[email protected]] > Sent: Wednesday, July 22, 2015 4:36 PM > To: [email protected] > Subject: Best practices for java DTOs to/from Sling > > We have a Sling application that we're using basically as a database/file > manager for portions of a java Spring application. > > In java we have a bunch of DTOs that we import by converting to json using > Jackson and persisting to Sling using the import option on the Sling post > servlet. > We then read them using .tidy.infinity.json and convert back to DTOs using > Jackson again. > This is working really well. > > But we've reached point where we need to modify some of the data in Sling and > it seems like I've hit a bit of a conceptual wall. > I was thinking we'd keep the DTO pattern going. > Load the DTO, modify some value, push the updated DTO back to Sling. > > But it seems the POST servlet doesn't support json when doing a modify > operation. > I basically took that as a hint that I might be barking up the wrong tree > here. > > We could also do the updates by posting specific properties, but it seems > like that's opening the door to writing a lot of custom update code. > > > Does anyone have any suggestions for best practices for this sort of thing? > Am I trying too hard to apply RDBMS/hibernate style patterns? > > > Thanks for taking to the time to read a somewhat open ended question.
