adaptto 2016 vault install hooks with groovy console scripts and sling pipes

13
APACHE SLING & FRIENDS TECH MEETUP BERLIN, 26-28 SEPTEMBER 2016 Install Hooks with Groovy or Sling Pipes Conrad Wöltge, Netcentric

Upload: conrad-woeltge

Post on 11-Apr-2017

148 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: AdaptTo 2016 Vault Install Hooks with Groovy Console Scripts and Sling Pipes

APACHE SLING & FRIENDS TECH MEETUPBERLIN, 26-28 SEPTEMBER 2016

Install Hooks with Groovy or Sling PipesConrad Wöltge, Netcentric

Page 2: AdaptTo 2016 Vault Install Hooks with Groovy Console Scripts and Sling Pipes

adaptTo() 2016 2

Vault Install Hooks

Page 3: AdaptTo 2016 Vault Install Hooks with Groovy Console Scripts and Sling Pipes

Install Hooks

adaptTo() 2016 3

§ Execute Java class for each phase of a package install

§ Phases PREPARE/INSTALLED/END§ PREPARE(PREPARE_FAILED)§ INSTALLED(INSTALL_FAILED)§ END

InstallHook see https://jackrabbit.apache.org/filevault/apidocs/org/apache/jackrabbit/vault/packaging/class-use/InstallHook.html

Page 4: AdaptTo 2016 Vault Install Hooks with Groovy Console Scripts and Sling Pipes

Java Hooks are great

adaptTo() 2016 4

Java is great … you just have to write a Class that does the work, recompile the InstallHook package and execute it…... wait, but only once. Only for that single version.I can test that … maybe. What if it fails?

Page 5: AdaptTo 2016 Vault Install Hooks with Groovy Console Scripts and Sling Pipes

Java? Groovy! Scripts!

adaptTo() 2016 5

Ilove

my Groovy Console!https://github.com/OlsonDigital/cq-groovy-console

Page 6: AdaptTo 2016 Vault Install Hooks with Groovy Console Scripts and Sling Pipes

Java? Groovy!

adaptTo() 2016 6

How about running Groovy scripts in that? Actually Groovy scripts just as in console?

Page 7: AdaptTo 2016 Vault Install Hooks with Groovy Console Scripts and Sling Pipes

adaptTo() 2016 7

Demo

Page 8: AdaptTo 2016 Vault Install Hooks with Groovy Console Scripts and Sling Pipes

Java? Groovy!

adaptTo() 2016 8

How about running Groovy scripts in that? Actually Groovy scripts just as in console?

Page 9: AdaptTo 2016 Vault Install Hooks with Groovy Console Scripts and Sling Pipes

Groovy Handler

adaptTo() 2016 9

§ Groovy Handler

META-INF/vault/definition/upgrader/somejobname

...

jcr:primaryType="sling:Folder"jcr:title="Update via Custom Class."handler=”groovy"run=”always"version="0.0.1-SNAPSHOT”

...

prepare-script.groovy

script1.groovy

end-script.groovy

Page 10: AdaptTo 2016 Vault Install Hooks with Groovy Console Scripts and Sling Pipes

Custom Handler

adaptTo() 2016 10

§ Custom Handlerjcr:primaryType="sling:Folder"jcr:title="Update via Custom Class."handler="custom"handlerClass="com.netcentric.vlt.upgrade.MyCustomClass"run="once"version="0.0.1-SNAPSHOT"

Page 11: AdaptTo 2016 Vault Install Hooks with Groovy Console Scripts and Sling Pipes

Bonus: Sling Pipes

adaptTo() 2016 11

Let’s hook in Sling Pipes

https://sling.apache.org/documentation/bundles/sling-pipes.html

Page 12: AdaptTo 2016 Vault Install Hooks with Groovy Console Scripts and Sling Pipes

adaptTo() 2016 12

Demo

Page 13: AdaptTo 2016 Vault Install Hooks with Groovy Console Scripts and Sling Pipes

References

adaptTo() 2016 13

§ Vault Upgrade Hook§ https://github.com/Netcentric/vault-upgrade-hook

§ Sling Pipes§ https://sling.apache.org/documentation/bundles/sling-

pipes.html§ https://github.com/apache/sling/tree/trunk/contrib/extensions/s

ling-pipes§ https://github.com/npeltier/sling-pipes-client