Cloud 5 - REPOINIT

Getting started with REPOINIT – or the Sling Repository Initializer. Learn a few tricks to unlock the power of using this tool and some of its use cases.

Transcript
James, have you - ever heard the term REPOINIT used outside of the Sling/AEM world? You mean like a sweater knit. sure. No, no, no, no, no, no. What about repository initialization? Repository initialization? Hmm. Might be something. I can’t really think of anything - offhand, though. What about sling? Oh, yeah. That’s a very common word. In fact, I just got my arm out of a sling, - if you want the truth. Yeah. No, no, no, no. I mean, OK. What’s your favorite TV show? What is something - you wouldn’t miss an episode of? Oh, man, that’s easy. No hesitation at all. Peppa Pig. What does this have to do with REPOINIT? Nothing. I mean, I just wanted to get it on record - that your favorite show’s Peppa Pig. REPOINIT, or the sling repository - initializer has been available out of the box in AEM since several - versions of AEM 65 alongside the JCR API , REPOINIT has become a very powerful tool - for setting up and configuring repositories in our mutable, - immutable world that we now live in. It’s a pretty handy tool - to have in your kit for creating service users - and their associated ACLs as well as the required content - tree structures that your app requires.
There’s a number of ways to use REPOINIT, - but I’d like to focus on the way that the latest archetype - handles configuration as it really sets - that best practices precedent. Many of the AEM components - like site assets and so on, already use REPOINIT internally - to initialize their structures and system requirements within AEM system. Yeah. Darin this sounds particularly useful - for AEM as a cloud service. Talk to me - a little bit about some use cases. Why would I actually want to use this - in my AEM cloud service project? Well, not every project needs - something like this or something like creating site paths - and another things. You can still use the old school way - of hacking together VLT content XML files that ultimately turn into - installable packages. But if you want to create users - and assign permissions to those users REPOINIT is perfect for that scenario - since it executes early in the build image. As an elevated system user.
Yeah, that’s really fantastic. I can really think - of some great use cases for this. How would I get started using REPOINIT? So the adobe suggested format - for your REPOINIT configs are the OSGi dot CFG.JSON format. The latest archetype - will build one of those in that format. However, I’m not a big fan of this format - for longer and larger scripts. The JSON format won’t let you put multiple lines in the script, - so you end up with a really long lines with escape, you know, \n for new lines, - most other things. Here’s an example of that. I personally prefer the dot config format, - which will make the scripts much more readable since it respects - those new lines and formatting options. There are a few things - that need to be escaped with dot config files, - and we’re including those down below Here’s an example of that same config json reformatted to the same file format. The grammar for those script languages are the REPOINIT script - language is largely self explaining and we’ve included the Sling - appendix down below for reference. One thing you can do, James, is - you can generate a new project using the latest AEM archetype - and look at the config located in the UI config module - under the OSGi directory. That should really get you started.
Yeah, really appreciate you sharing the best practices here, - Darin Human readable is always the best. Do you have any other important considerations you want to tell me - and the audience about using REPOINIT? I have three. First is the scripts execute every time a system starts up every time, - so you don’t have to create it. So don’t have it create a bunch of items - that are transient or temporary. The good news is, - is that if item’s already been created, the system will just No-Op and move on - and not do anything. Number two, the same rules - apply about mutable and immutable paths, so don’t make REPOINIT Change application - level nodes as it’ll break the product - or make your cloud manager pipeline fail. And that’ll result - in all sorts of trouble. Number three REPOINIT is very granular - and prescriptive. Don’t have it. You can’t have it. Query statements that change - a lot of a large group of things. All the steps you want to happen - have to be listed in the order. All of them, one by one. OK, that makes sense. You know, - this is really great and really useful. It’s not quite as great - as an episode of Peppa Pig, but you don’t want it comes close. Thanks again.

Content covered in this video

Additional Resources

Watch related videos on the Cloud 5 season 2 page.

recommendation-more-help
4859a77c-7971-4ac9-8f5c-4260823c6f69