No experience with CQ/AEM but been thrown in the deep end.
I have an approach where we'd have a web front end (built using Ember.js/handlebars) making calls to a web service which would in turn join the data (e.g. how many movies you've watched) with the appropriate content (e.g. the web service knows to look up node X in the CMS; "Thanks for watching all those movies!") and return the copy, image and data in a single JSON document.
This works really well when I have a RESTful API to the CMS.
However I've now been asked to make Adobe Experience Manager/CQ5 the CMS, and need to know if the same thing exists.
I don't think it does; I know that CQ5 uses either JCR/CRX as its content repository but from what I can see these aren't exposed as a web service (only language level APIs available)
AEM 6.2 uses JCR OAK which promises a RESTful API.
So in short my question is: does JCR OAK provide a RESTful API to the content and if so can anyone provide any examples/pointers please?
AEM comes with Apache Sling, which allows you to access the contents of the JCR through HTTP requests.
The DefaultGetServlet
can allow you to render content in JSON format by using the json
extension.
For example:
http://localhost:4502/content/geometrixx-outdoors/en/men.infinity.json
Returns the following JSON (shortened for readability):
{
jcr:primaryType: "cq:Page",
jcr:createdBy: "admin",
jcr:created: "Mon Jan 09 2017 14:44:46 GMT+1100",
jcr:content: {
jcr:primaryType: "cq:PageContent",
jcr:mixinTypes: [
"cq:LiveSync"
],
jcr:createdBy: "admin",
jcr:title: "Men's"
}
As of AEM 6.1, there is also a more user-friendly API based on Siren; however it is not fully complete yet.
http://localhost:4502/api.json/content/geometrixx-outdoors/en/men.html
Returns the following JSON (shortened for readability):
{
links: [
{
rel: [
"self"
],
href: "http://localhost:4502/api.json"
},
{
rel: [
"assets"
],
href: "http://localhost:4502/api/assets.json"
}
],
class: [
"core/services"
],
properties: {
name: "api"
}
}
These are the OOTB features but you can always create your own Sling Servlet to expose content however you like.