0

Is there a way to connect JCR/CRX(AEM) remotely apart from RMI/WEBDAV/JNDI? WEBDAV & RMI are not recommended to be open in PROD environment so I don't want to take that route in spite of a working solution.

Options explored which doesn't seem to fit my use case:

  1. SLING API - sling.apache.org/documentation/development/repository-based-development.html
  2. OAK API - github.com/davidegiannella/adaptTo16
  3. REST/JSON - adapt.to/2016/en/schedule/remote-resources.html . Will work for a direct resource access but not for querying or CRUD operations.
  4. JCR API- http://experience-aem.blogspot.com/2015/05/aem-6-sp2-accessing-crx-remotely-using-jcr-remoting-davex.html or https://wiki.apache.org/jackrabbit/RemoteAccess

Any pointers?

  • what is your use-case? Why do you need remote access to AEM instance and that too prod environment? – Ameesh Trikha Oct 18 '16 at 08:38
  • AEM content will be used as a knowledge hub and other apps in the ecosystem will query the content. Unfortunately, we are not in a position to re-architect the infrastructure which hosts apps in both DMZ & non DMZ. – user7027991 Oct 19 '16 at 16:43
  • @user7027991 I wonder how you connect to an Oak server via JCR in the first place. Does work for Jackrabbit2, but not sure how it works for Oak. Added the question on SO here: http://stackoverflow.com/questions/40191705/jackrabbit-oak-getting-started-and-connect-to-a-standalone-repository-via-java Not sure if it's the same what you are looking for. It's not AEM/CQ5 related. – Mathias Conradt Oct 22 '16 at 13:19

1 Answers1

1

Given that Apache Sling is very good at exposing resources via HTTP, my first option would be to use the Sling Get Servlet to get resources as JSON.

For instance, accessing http://localhost:8080/content.json will get you a JSON rendering of the resource at /content.

If you want to get more data in you can specify the number of children to traverse down the hierarchy using a selector. http://localhost:8080/content.2.json will give you the properties of content and those of the children and grand-children.

If that is not enough for you, you can always create a custom servlet and perform the rendering there.

Robert Munteanu
  • 67,031
  • 36
  • 206
  • 278
  • Thanks Rob!, the use case is to utilize AEM as a knowledge bank/repository where other apps would "query" the content remotely using full text search. Had it been the case of plain content rendering, this example would work. Writing custom servlets/services inside AEM is one of the not so good solutions and is debatable based on use cases. There could be a couple custom solutions to tweak the architecture or write custom services at either ends but I wanted to explore OAK and AEM6.2 OOTB APIs to save the effort. Hope it makes sense. – user7027991 Dec 22 '16 at 11:39
  • Right, now I understand more. However, I'm not sure why "Writing custom servlets/services inside AEM is one of the not so good solutions and is debatable based on use cases." I am not aware of any AEM deployment without custom code :-) and this gives you the needed flexibility to achieve your goals. – Robert Munteanu Dec 30 '16 at 20:58
  • Agreed, the goal is not to write custom code inside AEM deployment and expose the content via placeholders in specific way for different apps rather vice versa. The app who wants to consume it should use the OOTB API, query it smartly and get the content format or do the content massaging. AEM will just be a dumb node with content and whosoever wants to access it, has to massage it because we don't want to re-architect existing AEM apps/sites/infrastructure. For this reason, one would need APIs for remote access. – user7027991 Jan 04 '17 at 10:50
  • @user7027991 - then you're severly restricting yourself . I would start with using the default Sling Get Servlet, but it that is not enough a custom servlet will get you very far with little effort. – Robert Munteanu Jan 04 '17 at 21:19