1
votes

I'm trying to figure out a way to add custom nodetypes using a CND file to my Sling WebApp. I downloaded the WAR file and got it running but since all the code is already compiled (as .class files), I can't add code to read the CND file and add the custom nodetypes.

On a separate note, I do have Jackrabbit running and with it, I can use the JackrabbitNodeTypeManager or other ways to code reading a CND file and adding nodetypes. This works on my local repository that is not running on a server.

I want to be able to add new nodetypes to the Sling Web Application in a similar way. So I'll boil my questions down to:

  1. Is there a way to code the addition of new nodetypes in the Sling WebApp?
  2. How can I connect my Jackrabbit repository (local) to the Sling Web Application (on server) so that I can possibly explore adding custom nodetypes this way (as I'm doing on my Jackrabbit repo locally at the moment)?

I understand that Sling is a framework that uses Jackrabbit as a repo and provides REST-like services to work with the repository, but I imagine there's a way to add these custom nodetypes just like Jackrabbit allows.

Thanks.

1
How do you currently connect to your Jackrabbit repository outside of Sling? It should be possible to do so with Sling as well.Robert Munteanu
The Sling WebApp comes with the Jackrabbit repository layered underneath out-of-box. As for my separate Jackrabbit project that's simply placed locally, something simple like: Repository repository = new TransientRepository(); Session session = repository.login(new SimpleCredentials("username", "password".toCharArray()));. I've been following the Jackrabbit First Hops tutorial for the latter.HikeTakerByRequest
I see. The simplest way to connect to the JCR repository is to deploy a bundle doing all the work to Sling.Robert Munteanu
I didn't know it was possible to connect to the repository by deploying an OSGi bundle. I'll investigate this a little more.HikeTakerByRequest

1 Answers

1
votes

Is there a way to code the addition of new nodetypes in the Sling WebApp?

This is documented at Declared Node Type Registration. What you need to do is

  • write the node type definition in CND format
  • place it in a bundle
  • reference the file in the manifest using the Sling-Nodetypes header
  • deploy the bundle to your Sling app