diff --git a/integration-tests/it-packages/it-groovy_always/pom.xml b/integration-tests/it-packages/it-groovy_always/pom.xml index 995468f..be7cdc2 100644 --- a/integration-tests/it-packages/it-groovy_always/pom.xml +++ b/integration-tests/it-packages/it-groovy_always/pom.xml @@ -9,7 +9,7 @@ biz.netcentric.vlt.upgrade it-packages - 1.0.4-SNAPSHOT + 1.0.6-SNAPSHOT it-groovy_always diff --git a/integration-tests/it-packages/it-groovy_always/src/main/META-INF/vault/definition/.content.xml b/integration-tests/it-packages/it-groovy_always/src/main/META-INF/vault/definition/.content.xml new file mode 100644 index 0000000..9ba7a93 --- /dev/null +++ b/integration-tests/it-packages/it-groovy_always/src/main/META-INF/vault/definition/.content.xml @@ -0,0 +1,18 @@ + + + \ No newline at end of file diff --git a/integration-tests/it-packages/it-groovy_always/src/main/META-INF/vault/filter.xml b/integration-tests/it-packages/it-groovy_always/src/main/META-INF/vault/filter.xml old mode 100755 new mode 100644 index 54ac2b7..f96a0a1 --- a/integration-tests/it-packages/it-groovy_always/src/main/META-INF/vault/filter.xml +++ b/integration-tests/it-packages/it-groovy_always/src/main/META-INF/vault/filter.xml @@ -1,2 +1,4 @@ - + + + \ No newline at end of file diff --git a/integration-tests/it-packages/it-groovy_always/src/main/jcr_root/.content.xml b/integration-tests/it-packages/it-groovy_always/src/main/jcr_root/.content.xml deleted file mode 100755 index 8ea9f2a..0000000 --- a/integration-tests/it-packages/it-groovy_always/src/main/jcr_root/.content.xml +++ /dev/null @@ -1,6 +0,0 @@ - - diff --git a/integration-tests/it-packages/it-groovy_always/src/main/jcr_root/content/myapp/.content.xml b/integration-tests/it-packages/it-groovy_always/src/main/jcr_root/content/myapp/.content.xml new file mode 100755 index 0000000..93d2f5b --- /dev/null +++ b/integration-tests/it-packages/it-groovy_always/src/main/jcr_root/content/myapp/.content.xml @@ -0,0 +1,3 @@ + + diff --git a/integration-tests/it-packages/it-groovy_install_failed/pom.xml b/integration-tests/it-packages/it-groovy_install_failed/pom.xml index f75f0f1..ec3aec1 100644 --- a/integration-tests/it-packages/it-groovy_install_failed/pom.xml +++ b/integration-tests/it-packages/it-groovy_install_failed/pom.xml @@ -9,7 +9,7 @@ biz.netcentric.vlt.upgrade it-packages - 1.0.4-SNAPSHOT + 1.0.6-SNAPSHOT it-groovy_install_failed diff --git a/integration-tests/it-packages/it-groovy_install_failed/src/main/META-INF/vault/config.xml b/integration-tests/it-packages/it-groovy_install_failed/src/main/META-INF/vault/config.xml deleted file mode 100644 index b525f1c..0000000 --- a/integration-tests/it-packages/it-groovy_install_failed/src/main/META-INF/vault/config.xml +++ /dev/null @@ -1,93 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/integration-tests/it-packages/it-groovy_install_failed/src/main/META-INF/vault/definition/.content.xml b/integration-tests/it-packages/it-groovy_install_failed/src/main/META-INF/vault/definition/.content.xml new file mode 100644 index 0000000..9ba7a93 --- /dev/null +++ b/integration-tests/it-packages/it-groovy_install_failed/src/main/META-INF/vault/definition/.content.xml @@ -0,0 +1,18 @@ + + + \ No newline at end of file diff --git a/integration-tests/it-packages/it-groovy_install_failed/src/main/META-INF/vault/filter.xml b/integration-tests/it-packages/it-groovy_install_failed/src/main/META-INF/vault/filter.xml old mode 100755 new mode 100644 index 73d78ec..f96a0a1 --- a/integration-tests/it-packages/it-groovy_install_failed/src/main/META-INF/vault/filter.xml +++ b/integration-tests/it-packages/it-groovy_install_failed/src/main/META-INF/vault/filter.xml @@ -1,4 +1,4 @@ - - + + \ No newline at end of file diff --git a/integration-tests/it-packages/it-groovy_install_failed/src/main/META-INF/vault/nodetypes.cnd b/integration-tests/it-packages/it-groovy_install_failed/src/main/META-INF/vault/nodetypes.cnd deleted file mode 100644 index 60c8fa5..0000000 --- a/integration-tests/it-packages/it-groovy_install_failed/src/main/META-INF/vault/nodetypes.cnd +++ /dev/null @@ -1,25 +0,0 @@ -<'sling'='http://sling.apache.org/jcr/sling/1.0'> -<'nt'='http://www.jcp.org/jcr/nt/1.0'> -<'rep'='internal'> - -[sling:Resource] - mixin - - sling:resourceType (string) - -[sling:Redirect] > sling:Resource - mixin - - sling:target (undefined) - -[sling:OrderedFolder] > sling:Folder - orderable - + * (nt:base) = sling:OrderedFolder version - -[sling:Folder] > nt:folder - - * (undefined) multiple - - * (undefined) - + * (nt:base) = sling:Folder version - -[rep:RepoAccessControllable] - mixin - + rep:repoPolicy (rep:Policy) protected ignore - diff --git a/integration-tests/it-packages/it-groovy_install_failed/src/main/jcr_root/.content.xml b/integration-tests/it-packages/it-groovy_install_failed/src/main/jcr_root/.content.xml deleted file mode 100755 index 8ea9f2a..0000000 --- a/integration-tests/it-packages/it-groovy_install_failed/src/main/jcr_root/.content.xml +++ /dev/null @@ -1,6 +0,0 @@ - - diff --git a/integration-tests/it-packages/it-groovy_install_failed/src/main/jcr_root/content/.content.xml b/integration-tests/it-packages/it-groovy_install_failed/src/main/jcr_root/content/.content.xml deleted file mode 100644 index bf2b0a2..0000000 --- a/integration-tests/it-packages/it-groovy_install_failed/src/main/jcr_root/content/.content.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - diff --git a/integration-tests/it-packages/it-groovy_install_failed/src/main/jcr_root/content/myapp/.content.xml b/integration-tests/it-packages/it-groovy_install_failed/src/main/jcr_root/content/myapp/.content.xml new file mode 100755 index 0000000..93d2f5b --- /dev/null +++ b/integration-tests/it-packages/it-groovy_install_failed/src/main/jcr_root/content/myapp/.content.xml @@ -0,0 +1,3 @@ + + diff --git a/integration-tests/it-packages/it-groovy_install_failed/src/main/jcr_root/content/folder-with-ntunstructured-error/.content.xml b/integration-tests/it-packages/it-groovy_install_failed/src/main/jcr_root/content/myapp/folder-with-ntunstructured-error/.content.xml similarity index 100% rename from integration-tests/it-packages/it-groovy_install_failed/src/main/jcr_root/content/folder-with-ntunstructured-error/.content.xml rename to integration-tests/it-packages/it-groovy_install_failed/src/main/jcr_root/content/myapp/folder-with-ntunstructured-error/.content.xml diff --git a/integration-tests/it-packages/it-groovy_onchange/pom.xml b/integration-tests/it-packages/it-groovy_onchange/pom.xml index 578855d..839257e 100644 --- a/integration-tests/it-packages/it-groovy_onchange/pom.xml +++ b/integration-tests/it-packages/it-groovy_onchange/pom.xml @@ -9,7 +9,7 @@ biz.netcentric.vlt.upgrade it-packages - 1.0.4-SNAPSHOT + 1.0.6-SNAPSHOT it-groovy_onchange diff --git a/integration-tests/it-packages/it-groovy_onchange/src/main/META-INF/vault/definition/.content.xml b/integration-tests/it-packages/it-groovy_onchange/src/main/META-INF/vault/definition/.content.xml new file mode 100644 index 0000000..9ba7a93 --- /dev/null +++ b/integration-tests/it-packages/it-groovy_onchange/src/main/META-INF/vault/definition/.content.xml @@ -0,0 +1,18 @@ + + + \ No newline at end of file diff --git a/integration-tests/it-packages/it-groovy_onchange/src/main/META-INF/vault/filter.xml b/integration-tests/it-packages/it-groovy_onchange/src/main/META-INF/vault/filter.xml old mode 100755 new mode 100644 index 54ac2b7..f96a0a1 --- a/integration-tests/it-packages/it-groovy_onchange/src/main/META-INF/vault/filter.xml +++ b/integration-tests/it-packages/it-groovy_onchange/src/main/META-INF/vault/filter.xml @@ -1,2 +1,4 @@ - + + + \ No newline at end of file diff --git a/integration-tests/it-packages/it-groovy_onchange/src/main/jcr_root/.content.xml b/integration-tests/it-packages/it-groovy_onchange/src/main/jcr_root/.content.xml deleted file mode 100755 index 8ea9f2a..0000000 --- a/integration-tests/it-packages/it-groovy_onchange/src/main/jcr_root/.content.xml +++ /dev/null @@ -1,6 +0,0 @@ - - diff --git a/integration-tests/it-packages/it-groovy_onchange/src/main/jcr_root/content/myapp/.content.xml b/integration-tests/it-packages/it-groovy_onchange/src/main/jcr_root/content/myapp/.content.xml new file mode 100755 index 0000000..93d2f5b --- /dev/null +++ b/integration-tests/it-packages/it-groovy_onchange/src/main/jcr_root/content/myapp/.content.xml @@ -0,0 +1,3 @@ + + diff --git a/integration-tests/it-packages/it-groovy_prepare_failed/pom.xml b/integration-tests/it-packages/it-groovy_prepare_failed/pom.xml index f43cbe8..de01095 100644 --- a/integration-tests/it-packages/it-groovy_prepare_failed/pom.xml +++ b/integration-tests/it-packages/it-groovy_prepare_failed/pom.xml @@ -9,7 +9,7 @@ biz.netcentric.vlt.upgrade it-packages - 1.0.4-SNAPSHOT + 1.0.6-SNAPSHOT it-groovy_prepare_failed diff --git a/integration-tests/it-packages/it-groovy_prepare_failed/src/main/META-INF/vault/definition/.content.xml b/integration-tests/it-packages/it-groovy_prepare_failed/src/main/META-INF/vault/definition/.content.xml new file mode 100644 index 0000000..9ba7a93 --- /dev/null +++ b/integration-tests/it-packages/it-groovy_prepare_failed/src/main/META-INF/vault/definition/.content.xml @@ -0,0 +1,18 @@ + + + \ No newline at end of file diff --git a/integration-tests/it-packages/it-groovy_prepare_failed/src/main/META-INF/vault/filter.xml b/integration-tests/it-packages/it-groovy_prepare_failed/src/main/META-INF/vault/filter.xml old mode 100755 new mode 100644 index 54ac2b7..f96a0a1 --- a/integration-tests/it-packages/it-groovy_prepare_failed/src/main/META-INF/vault/filter.xml +++ b/integration-tests/it-packages/it-groovy_prepare_failed/src/main/META-INF/vault/filter.xml @@ -1,2 +1,4 @@ - + + + \ No newline at end of file diff --git a/integration-tests/it-packages/it-groovy_prepare_failed/src/main/jcr_root/.content.xml b/integration-tests/it-packages/it-groovy_prepare_failed/src/main/jcr_root/.content.xml deleted file mode 100755 index 8ea9f2a..0000000 --- a/integration-tests/it-packages/it-groovy_prepare_failed/src/main/jcr_root/.content.xml +++ /dev/null @@ -1,6 +0,0 @@ - - diff --git a/integration-tests/it-packages/it-groovy_prepare_failed/src/main/jcr_root/content/myapp/.content.xml b/integration-tests/it-packages/it-groovy_prepare_failed/src/main/jcr_root/content/myapp/.content.xml new file mode 100755 index 0000000..93d2f5b --- /dev/null +++ b/integration-tests/it-packages/it-groovy_prepare_failed/src/main/jcr_root/content/myapp/.content.xml @@ -0,0 +1,3 @@ + + diff --git a/integration-tests/it-packages/it-groovy_prepare_installed_end/pom.xml b/integration-tests/it-packages/it-groovy_prepare_installed_end/pom.xml index ec204b1..d794ab1 100644 --- a/integration-tests/it-packages/it-groovy_prepare_installed_end/pom.xml +++ b/integration-tests/it-packages/it-groovy_prepare_installed_end/pom.xml @@ -9,7 +9,7 @@ biz.netcentric.vlt.upgrade it-packages - 1.0.4-SNAPSHOT + 1.0.6-SNAPSHOT it-groovy_prepare_installed_end diff --git a/integration-tests/it-packages/it-groovy_prepare_installed_end/src/main/META-INF/vault/definition/.content.xml b/integration-tests/it-packages/it-groovy_prepare_installed_end/src/main/META-INF/vault/definition/.content.xml new file mode 100644 index 0000000..9ba7a93 --- /dev/null +++ b/integration-tests/it-packages/it-groovy_prepare_installed_end/src/main/META-INF/vault/definition/.content.xml @@ -0,0 +1,18 @@ + + + \ No newline at end of file diff --git a/integration-tests/it-packages/it-groovy_prepare_installed_end/src/main/META-INF/vault/filter.xml b/integration-tests/it-packages/it-groovy_prepare_installed_end/src/main/META-INF/vault/filter.xml old mode 100755 new mode 100644 index 54ac2b7..f96a0a1 --- a/integration-tests/it-packages/it-groovy_prepare_installed_end/src/main/META-INF/vault/filter.xml +++ b/integration-tests/it-packages/it-groovy_prepare_installed_end/src/main/META-INF/vault/filter.xml @@ -1,2 +1,4 @@ - + + + \ No newline at end of file diff --git a/integration-tests/it-packages/it-groovy_prepare_installed_end/src/main/jcr_root/.content.xml b/integration-tests/it-packages/it-groovy_prepare_installed_end/src/main/jcr_root/.content.xml deleted file mode 100755 index 8ea9f2a..0000000 --- a/integration-tests/it-packages/it-groovy_prepare_installed_end/src/main/jcr_root/.content.xml +++ /dev/null @@ -1,6 +0,0 @@ - - diff --git a/integration-tests/it-packages/it-groovy_prepare_installed_end/src/main/jcr_root/content/myapp/.content.xml b/integration-tests/it-packages/it-groovy_prepare_installed_end/src/main/jcr_root/content/myapp/.content.xml new file mode 100755 index 0000000..93d2f5b --- /dev/null +++ b/integration-tests/it-packages/it-groovy_prepare_installed_end/src/main/jcr_root/content/myapp/.content.xml @@ -0,0 +1,3 @@ + + diff --git a/integration-tests/it-packages/it-script_always/pom.xml b/integration-tests/it-packages/it-script_always/pom.xml index 0a09e61..703b450 100644 --- a/integration-tests/it-packages/it-script_always/pom.xml +++ b/integration-tests/it-packages/it-script_always/pom.xml @@ -9,7 +9,7 @@ biz.netcentric.vlt.upgrade it-packages - 1.0.4-SNAPSHOT + 1.0.6-SNAPSHOT it-script_always diff --git a/integration-tests/it-packages/it-script_always/src/main/META-INF/vault/definition/.content.xml b/integration-tests/it-packages/it-script_always/src/main/META-INF/vault/definition/.content.xml new file mode 100644 index 0000000..9ba7a93 --- /dev/null +++ b/integration-tests/it-packages/it-script_always/src/main/META-INF/vault/definition/.content.xml @@ -0,0 +1,18 @@ + + + \ No newline at end of file diff --git a/integration-tests/it-packages/it-script_always/src/main/META-INF/vault/filter.xml b/integration-tests/it-packages/it-script_always/src/main/META-INF/vault/filter.xml old mode 100755 new mode 100644 index 54ac2b7..f96a0a1 --- a/integration-tests/it-packages/it-script_always/src/main/META-INF/vault/filter.xml +++ b/integration-tests/it-packages/it-script_always/src/main/META-INF/vault/filter.xml @@ -1,2 +1,4 @@ - + + + \ No newline at end of file diff --git a/integration-tests/it-packages/it-script_always/src/main/jcr_root/.content.xml b/integration-tests/it-packages/it-script_always/src/main/jcr_root/.content.xml deleted file mode 100755 index 8ea9f2a..0000000 --- a/integration-tests/it-packages/it-script_always/src/main/jcr_root/.content.xml +++ /dev/null @@ -1,6 +0,0 @@ - - diff --git a/integration-tests/it-packages/it-script_always/src/main/jcr_root/content/myapp/.content.xml b/integration-tests/it-packages/it-script_always/src/main/jcr_root/content/myapp/.content.xml new file mode 100755 index 0000000..93d2f5b --- /dev/null +++ b/integration-tests/it-packages/it-script_always/src/main/jcr_root/content/myapp/.content.xml @@ -0,0 +1,3 @@ + + diff --git a/integration-tests/it-packages/it-slingpipes_always/pom.xml b/integration-tests/it-packages/it-slingpipes_always/pom.xml index baf9106..956c18a 100644 --- a/integration-tests/it-packages/it-slingpipes_always/pom.xml +++ b/integration-tests/it-packages/it-slingpipes_always/pom.xml @@ -9,7 +9,7 @@ biz.netcentric.vlt.upgrade it-packages - 1.0.4-SNAPSHOT + 1.0.6-SNAPSHOT it-slingpipes_always diff --git a/integration-tests/it-packages/it-slingpipes_always/src/main/META-INF/vault/definition/.content.xml b/integration-tests/it-packages/it-slingpipes_always/src/main/META-INF/vault/definition/.content.xml new file mode 100644 index 0000000..9ba7a93 --- /dev/null +++ b/integration-tests/it-packages/it-slingpipes_always/src/main/META-INF/vault/definition/.content.xml @@ -0,0 +1,18 @@ + + + \ No newline at end of file diff --git a/integration-tests/it-packages/it-slingpipes_always/src/main/META-INF/vault/filter.xml b/integration-tests/it-packages/it-slingpipes_always/src/main/META-INF/vault/filter.xml old mode 100755 new mode 100644 index 54ac2b7..f96a0a1 --- a/integration-tests/it-packages/it-slingpipes_always/src/main/META-INF/vault/filter.xml +++ b/integration-tests/it-packages/it-slingpipes_always/src/main/META-INF/vault/filter.xml @@ -1,2 +1,4 @@ - + + + \ No newline at end of file diff --git a/integration-tests/it-packages/it-slingpipes_always/src/main/jcr_root/.content.xml b/integration-tests/it-packages/it-slingpipes_always/src/main/jcr_root/.content.xml deleted file mode 100755 index 8ea9f2a..0000000 --- a/integration-tests/it-packages/it-slingpipes_always/src/main/jcr_root/.content.xml +++ /dev/null @@ -1,6 +0,0 @@ - - diff --git a/integration-tests/it-packages/it-slingpipes_always/src/main/jcr_root/content/myapp/.content.xml b/integration-tests/it-packages/it-slingpipes_always/src/main/jcr_root/content/myapp/.content.xml new file mode 100755 index 0000000..93d2f5b --- /dev/null +++ b/integration-tests/it-packages/it-slingpipes_always/src/main/jcr_root/content/myapp/.content.xml @@ -0,0 +1,3 @@ + + diff --git a/integration-tests/it-packages/it-userconfig_always/pom.xml b/integration-tests/it-packages/it-userconfig_always/pom.xml index a53bd1d..a532b17 100644 --- a/integration-tests/it-packages/it-userconfig_always/pom.xml +++ b/integration-tests/it-packages/it-userconfig_always/pom.xml @@ -9,7 +9,7 @@ biz.netcentric.vlt.upgrade it-packages - 1.0.4-SNAPSHOT + 1.0.6-SNAPSHOT it-userconfig_always diff --git a/integration-tests/it-packages/it-userconfig_always/src/main/META-INF/vault/definition/.content.xml b/integration-tests/it-packages/it-userconfig_always/src/main/META-INF/vault/definition/.content.xml new file mode 100644 index 0000000..9ba7a93 --- /dev/null +++ b/integration-tests/it-packages/it-userconfig_always/src/main/META-INF/vault/definition/.content.xml @@ -0,0 +1,18 @@ + + + \ No newline at end of file diff --git a/integration-tests/it-packages/it-userconfig_always/src/main/META-INF/vault/filter.xml b/integration-tests/it-packages/it-userconfig_always/src/main/META-INF/vault/filter.xml old mode 100755 new mode 100644 index 54ac2b7..f96a0a1 --- a/integration-tests/it-packages/it-userconfig_always/src/main/META-INF/vault/filter.xml +++ b/integration-tests/it-packages/it-userconfig_always/src/main/META-INF/vault/filter.xml @@ -1,2 +1,4 @@ - + + + \ No newline at end of file diff --git a/integration-tests/it-packages/it-userconfig_always/src/main/jcr_root/.content.xml b/integration-tests/it-packages/it-userconfig_always/src/main/jcr_root/.content.xml deleted file mode 100755 index 8ea9f2a..0000000 --- a/integration-tests/it-packages/it-userconfig_always/src/main/jcr_root/.content.xml +++ /dev/null @@ -1,6 +0,0 @@ - - diff --git a/integration-tests/it-packages/it-userconfig_always/src/main/jcr_root/content/myapp/.content.xml b/integration-tests/it-packages/it-userconfig_always/src/main/jcr_root/content/myapp/.content.xml new file mode 100755 index 0000000..93d2f5b --- /dev/null +++ b/integration-tests/it-packages/it-userconfig_always/src/main/jcr_root/content/myapp/.content.xml @@ -0,0 +1,3 @@ + + diff --git a/integration-tests/it-packages/pom.xml b/integration-tests/it-packages/pom.xml index 724c61e..882e643 100644 --- a/integration-tests/it-packages/pom.xml +++ b/integration-tests/it-packages/pom.xml @@ -8,8 +8,8 @@ biz.netcentric.vlt.upgrade - integration-tests - 1.0.4-SNAPSHOT + vault-upgrade-hook-samples + 1.0.6-SNAPSHOT it-packages @@ -30,77 +30,24 @@ - packaging-contentpackage + upload-content-packages ${basedir}/src/main/jcr_root - - - ${basedir}/src/main/jcr_root - ${project.build.directory}/package/jcr_root - - **/*.vlt - **/*.svn - **/*.gitignore - **/*.DS_Store - - - - ${basedir}/src/main/upgrader - ${project.build.directory}/vault-work/META-INF/vault/definition/upgrader - - - - org.apache.maven.plugins - maven-resources-plugin - - true - - - - org.apache.maven.plugins - maven-dependency-plugin - - - copy - prepare-package - - copy - - - - - ${project.groupId} - vault-upgrade-hook - ${project.version} - true - ${project.build.directory}/vault-work/META-INF/vault/hooks - - - - - - com.day.jcr.vault content-package-maven-plugin - ${vaultUpgradeHook.testpackage.group} - src/main/META-INF/vault/filter.xml - ${project.build.directory}/package/jcr_root - http://${crx.host}:${crx.port}/crx/packmgr/service.jsp - ${crx.username} - ${crx.password} false - install-content-package - install + install-package + integration-test install @@ -111,4 +58,5 @@ + diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml index 0d8f5d0..c69feee 100644 --- a/integration-tests/pom.xml +++ b/integration-tests/pom.xml @@ -9,7 +9,7 @@ biz.netcentric.vlt.upgrade vault-upgrade-hook-reactor - 1.0.4-SNAPSHOT + 1.0.6-SNAPSHOT integration-tests @@ -17,13 +17,6 @@ Vault Upgrade Hook :: Integration Tests - - - - - vault-upgrade-it-test - - it-packages tests diff --git a/integration-tests/tests/pom.xml b/integration-tests/tests/pom.xml index ad21b7e..ea1112d 100644 --- a/integration-tests/tests/pom.xml +++ b/integration-tests/tests/pom.xml @@ -9,7 +9,7 @@ biz.netcentric.vlt.upgrade integration-tests - 1.0.4-SNAPSHOT + 1.0.6-SNAPSHOT tests @@ -38,46 +38,7 @@ http://${crx.host}:${crx.port}/ - - - 2000 - 5 - ${vaultUpgradeHook.testpackage.group} ${project.version} - - - test-vault-hook - it-userconfig_always - testUserPreference - TestValue - - - /content/vault-upgrade-test-resource-name - testResourceValue - it-groovy_always - TestValue - it-groovy_prepare_installed_end - prepare_installed_end - it-groovy_prepare_failed - prepare_preparefailed_end - it-groovy_install_failed - installfailed_end - it-groovy_onchange - TestValue - test-groovy-script - script.groovy - - - /content/vault-upgrade-test-script-resource-name - testResourceValue - TestValue - it-script_always - - - /content/vault-upgrade-test-slingpipes-resource-name - testResourceValue - it-slingpipes_always - TestValue **/*IT.java diff --git a/integration-tests/tests/src/test/java/biz/netcentric/vlt/upgrade/groovy/GroovyAbstractIT.java b/integration-tests/tests/src/test/java/biz/netcentric/vlt/upgrade/groovy/GroovyAbstractIT.java index e95c68a..dc45b76 100644 --- a/integration-tests/tests/src/test/java/biz/netcentric/vlt/upgrade/groovy/GroovyAbstractIT.java +++ b/integration-tests/tests/src/test/java/biz/netcentric/vlt/upgrade/groovy/GroovyAbstractIT.java @@ -9,6 +9,7 @@ package biz.netcentric.vlt.upgrade.groovy; import org.apache.sling.testing.clients.ClientException; +import org.apache.sling.testing.clients.SlingHttpResponse; import org.junit.After; import org.junit.Before; import org.junit.BeforeClass; @@ -23,7 +24,7 @@ public abstract class GroovyAbstractIT extends AbstractIT { @BeforeClass public static void setUpClass() { AbstractIT.setUpClass(); - testPropertyName = System.getProperty("vaultUpgradeHook.testpackage.groovy.testProperty"); + testPropertyName = System.getProperty("vaultUpgradeHook.testpackage.groovy.testProperty", "testResourceValue"); } @Before @@ -43,6 +44,6 @@ public void tearDown() throws ClientException, InterruptedException { @Override protected String getTestResourcePath() { - return System.getProperty("vaultUpgradeHook.testpackage.groovy.resourcePath"); + return System.getProperty("vaultUpgradeHook.testpackage.groovy.resourcePath", "/content/vault-upgrade-test-resource-name"); } } diff --git a/integration-tests/tests/src/test/java/biz/netcentric/vlt/upgrade/groovy/GroovyAlwaysIT.java b/integration-tests/tests/src/test/java/biz/netcentric/vlt/upgrade/groovy/GroovyAlwaysIT.java index 231b393..f898c48 100644 --- a/integration-tests/tests/src/test/java/biz/netcentric/vlt/upgrade/groovy/GroovyAlwaysIT.java +++ b/integration-tests/tests/src/test/java/biz/netcentric/vlt/upgrade/groovy/GroovyAlwaysIT.java @@ -19,7 +19,7 @@ public class GroovyAlwaysIT extends GroovyAbstractIT { @Before public void setUp() throws Exception { super.setUp(); - testPropertyValue = System.getProperty("vaultUpgradeHook.testpackage.groovy.always.testPropertyValue"); + testPropertyValue = System.getProperty("vaultUpgradeHook.testpackage.groovy.always.testPropertyValue", "TestValue"); } @Test @@ -43,6 +43,6 @@ public void shouldExecuteActionOnSecondInstallation() throws ClientException, In } protected String getPackageName() { - return System.getProperty("vaultUpgradeHook.testpackage.groovy.always"); + return System.getProperty("vaultUpgradeHook.testpackage.groovy.always", "it-groovy_always"); } } diff --git a/integration-tests/tests/src/test/java/biz/netcentric/vlt/upgrade/groovy/GroovyInstallFailedIT.java b/integration-tests/tests/src/test/java/biz/netcentric/vlt/upgrade/groovy/GroovyInstallFailedIT.java index fb22c2f..5e36612 100644 --- a/integration-tests/tests/src/test/java/biz/netcentric/vlt/upgrade/groovy/GroovyInstallFailedIT.java +++ b/integration-tests/tests/src/test/java/biz/netcentric/vlt/upgrade/groovy/GroovyInstallFailedIT.java @@ -19,7 +19,7 @@ public class GroovyInstallFailedIT extends GroovyAbstractIT { @Before public void setUp() throws Exception { super.setUp(); - testPropertyValue = System.getProperty("vaultUpgradeHook.testpackage.groovy.installfailed.testPropertyValue"); + testPropertyValue = System.getProperty("vaultUpgradeHook.testpackage.groovy.installfailed.testPropertyValue", "installfailed_end"); } @Test @@ -28,6 +28,6 @@ public void shouldExecuteFailedScript() throws ClientException, InterruptedExcep } protected String getPackageName() { - return System.getProperty("vaultUpgradeHook.testpackage.groovy.installfailed"); + return System.getProperty("vaultUpgradeHook.testpackage.groovy.installfailed", "it-groovy_install_failed"); } } diff --git a/integration-tests/tests/src/test/java/biz/netcentric/vlt/upgrade/groovy/GroovyOnChangeIT.java b/integration-tests/tests/src/test/java/biz/netcentric/vlt/upgrade/groovy/GroovyOnChangeIT.java index c50829d..2027ae2 100644 --- a/integration-tests/tests/src/test/java/biz/netcentric/vlt/upgrade/groovy/GroovyOnChangeIT.java +++ b/integration-tests/tests/src/test/java/biz/netcentric/vlt/upgrade/groovy/GroovyOnChangeIT.java @@ -22,9 +22,9 @@ public class GroovyOnChangeIT extends GroovyAbstractIT { @Before public void setUp() throws Exception { super.setUp(); - testPropertyValue = System.getProperty("vaultUpgradeHook.testpackage.groovy.onchange.testPropertyValue"); - scriptName = System.getProperty("vaultUpgradeHook.testpackage.groovy.onchange.scriptName"); - actionFolder = System.getProperty("vaultUpgradeHook.testpackage.groovy.onchange.actionFolder"); + testPropertyValue = System.getProperty("vaultUpgradeHook.testpackage.groovy.onchange.testPropertyValue", "TestValue"); + scriptName = System.getProperty("vaultUpgradeHook.testpackage.groovy.onchange.scriptName", "script.groovy"); + actionFolder = System.getProperty("vaultUpgradeHook.testpackage.groovy.onchange.actionFolder", "test-groovy-script"); } @Test @@ -61,6 +61,6 @@ private void changeHashAndAssert() throws ClientException, InterruptedException } protected String getPackageName() { - return System.getProperty("vaultUpgradeHook.testpackage.groovy.onchange"); + return System.getProperty("vaultUpgradeHook.testpackage.groovy.onchange", "it-groovy_onchange"); } } diff --git a/integration-tests/tests/src/test/java/biz/netcentric/vlt/upgrade/groovy/GroovyPhasesIT.java b/integration-tests/tests/src/test/java/biz/netcentric/vlt/upgrade/groovy/GroovyPhasesIT.java index 51c4ffc..75a5f35 100644 --- a/integration-tests/tests/src/test/java/biz/netcentric/vlt/upgrade/groovy/GroovyPhasesIT.java +++ b/integration-tests/tests/src/test/java/biz/netcentric/vlt/upgrade/groovy/GroovyPhasesIT.java @@ -19,7 +19,7 @@ public class GroovyPhasesIT extends GroovyAbstractIT { @Before public void setUp() throws Exception { super.setUp(); - testPropertyValue = System.getProperty("vaultUpgradeHook.testpackage.groovy.prepareinstalledend.testPropertyValue"); + testPropertyValue = System.getProperty("vaultUpgradeHook.testpackage.groovy.prepareinstalledend.testPropertyValue", "prepare_installed_end"); } /* @@ -33,6 +33,6 @@ public void shouldExecuteActionsInCorrectOrder() throws ClientException, Interru } protected String getPackageName() { - return System.getProperty("vaultUpgradeHook.testpackage.groovy.prepareinstalledend"); + return System.getProperty("vaultUpgradeHook.testpackage.groovy.prepareinstalledend", "it-groovy_prepare_installed_end"); } } diff --git a/integration-tests/tests/src/test/java/biz/netcentric/vlt/upgrade/groovy/GroovyPrepareFailedIT.java b/integration-tests/tests/src/test/java/biz/netcentric/vlt/upgrade/groovy/GroovyPrepareFailedIT.java index a2cbe08..f7fb843 100644 --- a/integration-tests/tests/src/test/java/biz/netcentric/vlt/upgrade/groovy/GroovyPrepareFailedIT.java +++ b/integration-tests/tests/src/test/java/biz/netcentric/vlt/upgrade/groovy/GroovyPrepareFailedIT.java @@ -19,7 +19,7 @@ public class GroovyPrepareFailedIT extends GroovyAbstractIT { @Before public void setUp() throws Exception { super.setUp(); - testPropertyValue = System.getProperty("vaultUpgradeHook.testpackage.groovy.preparefailed.testPropertyValue"); + testPropertyValue = System.getProperty("vaultUpgradeHook.testpackage.groovy.preparefailed.testPropertyValue", "prepare_preparefailed_end"); } @Test @@ -29,6 +29,6 @@ public void shouldExecuteFailedScript() throws ClientException, InterruptedExcep } protected String getPackageName() { - return System.getProperty("vaultUpgradeHook.testpackage.groovy.preparefailed"); + return System.getProperty("vaultUpgradeHook.testpackage.groovy.preparefailed", "it-groovy_prepare_failed"); } } diff --git a/integration-tests/tests/src/test/java/biz/netcentric/vlt/upgrade/script/ScriptIT.java b/integration-tests/tests/src/test/java/biz/netcentric/vlt/upgrade/script/ScriptIT.java index 6620d09..cc56e0d 100644 --- a/integration-tests/tests/src/test/java/biz/netcentric/vlt/upgrade/script/ScriptIT.java +++ b/integration-tests/tests/src/test/java/biz/netcentric/vlt/upgrade/script/ScriptIT.java @@ -24,8 +24,8 @@ public class ScriptIT extends AbstractIT { @Before public void setUp() throws Exception { testResourcePath = getTestResourcePath(); - testPropertyName = System.getProperty("vaultUpgradeHook.testpackage.script.testProperty"); - testPropertyValue = System.getProperty("vaultUpgradeHook.testpackage.script.testPropertyValue"); + testPropertyName = System.getProperty("vaultUpgradeHook.testpackage.script.testProperty", "testResourceValue"); + testPropertyValue = System.getProperty("vaultUpgradeHook.testpackage.script.testPropertyValue", "TestValue"); super.setUp(); cleanUpBefore(); @@ -46,11 +46,11 @@ public void shouldExecuteAction() throws ClientException, InterruptedException { @Override protected String getPackageName() { - return System.getProperty("vaultUpgradeHook.testpackage.script.always"); + return System.getProperty("vaultUpgradeHook.testpackage.script.always", "it-script_always"); } @Override protected String getTestResourcePath() { - return System.getProperty("vaultUpgradeHook.testpackage.script.resourcePath"); + return System.getProperty("vaultUpgradeHook.testpackage.script.resourcePath", "/content/vault-upgrade-test-script-resource-name"); } } diff --git a/integration-tests/tests/src/test/java/biz/netcentric/vlt/upgrade/slingpipes/SlingPipesIT.java b/integration-tests/tests/src/test/java/biz/netcentric/vlt/upgrade/slingpipes/SlingPipesIT.java index eebb1ab..75f1e9a 100644 --- a/integration-tests/tests/src/test/java/biz/netcentric/vlt/upgrade/slingpipes/SlingPipesIT.java +++ b/integration-tests/tests/src/test/java/biz/netcentric/vlt/upgrade/slingpipes/SlingPipesIT.java @@ -18,23 +18,21 @@ public class SlingPipesIT extends AbstractIT { - private static String testResourcePath; private static String testPropertyName; private static String testPropertyValue; @BeforeClass public static void setUpClass() { AbstractIT.setUpClass(); - testResourcePath = System.getProperty("vaultUpgradeHook.testpackage.slingpipes.resourcePath"); - testPropertyName = System.getProperty("vaultUpgradeHook.testpackage.slingpipes.testProperty"); - testPropertyValue = System.getProperty("vaultUpgradeHook.testpackage.slingpipes.testPropertyValue"); + testPropertyName = System.getProperty("vaultUpgradeHook.testpackage.slingpipes.testProperty", "testResourceValue"); + testPropertyValue = System.getProperty("vaultUpgradeHook.testpackage.slingpipes.testPropertyValue", "TestValue"); } @Before public void setUp() throws Exception { super.setUp(); cleanUpBefore(); - createResource(testResourcePath); + createResource(getTestResourcePath()); installPackage(packageRelPath); } @@ -45,17 +43,17 @@ public void tearDown() throws Exception { @Test public void shouldExecuteAction() throws ClientException, InterruptedException { - assertTestPropertyValue(testResourcePath, testPropertyName, testPropertyValue); + assertTestPropertyValue(getTestResourcePath(), testPropertyName, testPropertyValue); assertSuccessStatus(); } @Override protected String getPackageName() { - return System.getProperty("vaultUpgradeHook.testpackage.slingpipes.always"); + return System.getProperty("vaultUpgradeHook.testpackage.slingpipes.always", "it-slingpipes_always"); } @Override protected String getTestResourcePath() { - return System.getProperty("vaultUpgradeHook.testpackage.slingpipes.resourcePath"); + return System.getProperty("vaultUpgradeHook.testpackage.slingpipes.resourcePath", "/content/vault-upgrade-test-slingpipes-resource-name"); } } diff --git a/integration-tests/tests/src/test/java/biz/netcentric/vlt/upgrade/userpreferences/UserPreferencesAbstract.java b/integration-tests/tests/src/test/java/biz/netcentric/vlt/upgrade/userpreferences/UserPreferencesAbstract.java index d4396de..3a9598e 100644 --- a/integration-tests/tests/src/test/java/biz/netcentric/vlt/upgrade/userpreferences/UserPreferencesAbstract.java +++ b/integration-tests/tests/src/test/java/biz/netcentric/vlt/upgrade/userpreferences/UserPreferencesAbstract.java @@ -37,9 +37,9 @@ public abstract class UserPreferencesAbstract extends AbstractIT { @BeforeClass public static void setUpClass() { AbstractIT.setUpClass(); - testUser = System.getProperty("vaultUpgradeHook.testpackage.userconfig.testUser"); - testPropertyName = System.getProperty("vaultUpgradeHook.testpackage.userconfig.testProperty"); - testPropertyValue = System.getProperty("vaultUpgradeHook.testpackage.userconfig.testPropertyValue"); + testUser = System.getProperty("vaultUpgradeHook.testpackage.userconfig.testUser", "test-vault-hook"); + testPropertyName = System.getProperty("vaultUpgradeHook.testpackage.userconfig.testProperty", "testUserPreference"); + testPropertyValue = System.getProperty("vaultUpgradeHook.testpackage.userconfig.testPropertyValue", "TestValue"); } @Before diff --git a/integration-tests/tests/src/test/java/biz/netcentric/vlt/upgrade/userpreferences/UserPreferencesAlwaysIT.java b/integration-tests/tests/src/test/java/biz/netcentric/vlt/upgrade/userpreferences/UserPreferencesAlwaysIT.java index 0ff8e73..c07b2c7 100644 --- a/integration-tests/tests/src/test/java/biz/netcentric/vlt/upgrade/userpreferences/UserPreferencesAlwaysIT.java +++ b/integration-tests/tests/src/test/java/biz/netcentric/vlt/upgrade/userpreferences/UserPreferencesAlwaysIT.java @@ -36,6 +36,6 @@ public void shouldAlwaysExecuteAction() throws ClientException, InterruptedExcep } protected String getPackageName() { - return System.getProperty("vaultUpgradeHook.testpackage.userconfig.always"); + return System.getProperty("vaultUpgradeHook.testpackage.userconfig.always", "it-userconfig_always"); } } diff --git a/integration-tests/tests/src/test/java/biz/netcentric/vlt/upgrade/util/AbstractIT.java b/integration-tests/tests/src/test/java/biz/netcentric/vlt/upgrade/util/AbstractIT.java index 50ffd99..fa6781d 100644 --- a/integration-tests/tests/src/test/java/biz/netcentric/vlt/upgrade/util/AbstractIT.java +++ b/integration-tests/tests/src/test/java/biz/netcentric/vlt/upgrade/util/AbstractIT.java @@ -43,7 +43,7 @@ public abstract class AbstractIT { @BeforeClass public static void setUpClass() { packageVersion = System.getProperty("vaultUpgradeHook.testpackage.version"); - packageGroup = System.getProperty("vaultUpgradeHook.testpackage.group"); + packageGroup = System.getProperty("vaultUpgradeHook.testpackage.group", "vault-upgrade-hook-samples"); } @Before diff --git a/integration-tests/tests/src/test/java/biz/netcentric/vlt/upgrade/util/ConfiguredAbstractPoller.java b/integration-tests/tests/src/test/java/biz/netcentric/vlt/upgrade/util/ConfiguredAbstractPoller.java index 7820c44..2972ccd 100644 --- a/integration-tests/tests/src/test/java/biz/netcentric/vlt/upgrade/util/ConfiguredAbstractPoller.java +++ b/integration-tests/tests/src/test/java/biz/netcentric/vlt/upgrade/util/ConfiguredAbstractPoller.java @@ -12,8 +12,8 @@ public abstract class ConfiguredAbstractPoller extends AbstractPoller { - private static final int WAIT = Integer.getInteger("vaultUpgradeHook.testsettings.request.wait", 0); - private static final int RETRIES = Integer.getInteger("vaultUpgradeHook.testsettings.request.retries", 0); + private static final int WAIT = Integer.getInteger("vaultUpgradeHook.testsettings.request.wait", 2000); + private static final int RETRIES = Integer.getInteger("vaultUpgradeHook.testsettings.request.retries", 5); public ConfiguredAbstractPoller() { super(WAIT, RETRIES); diff --git a/pom.xml b/pom.xml index b53a133..8fe6207 100644 --- a/pom.xml +++ b/pom.xml @@ -169,8 +169,11 @@ true ${project.build.directory}/package/jcr_root http://${crx.host}:${crx.port}/crx/packmgr/service.jsp + http://${crx.host}:${crx.port}/crx/packmgr/service/.json ${crx.username} ${crx.password} + false + true diff --git a/samples/groovy-package/src/main/META-INF/vault/definition/.content.xml b/samples/groovy-package/src/main/META-INF/vault/definition/.content.xml new file mode 100644 index 0000000..9ba7a93 --- /dev/null +++ b/samples/groovy-package/src/main/META-INF/vault/definition/.content.xml @@ -0,0 +1,18 @@ + + + \ No newline at end of file diff --git a/samples/groovy-package/src/main/jcr_root/content/myapp/.content.xml b/samples/groovy-package/src/main/jcr_root/content/myapp/.content.xml new file mode 100755 index 0000000..93d2f5b --- /dev/null +++ b/samples/groovy-package/src/main/jcr_root/content/myapp/.content.xml @@ -0,0 +1,3 @@ + + diff --git a/samples/pom.xml b/samples/pom.xml index ce0fa3e..81f69be 100644 --- a/samples/pom.xml +++ b/samples/pom.xml @@ -24,24 +24,6 @@ userpreferences-package - - - - ${basedir}/src/main/jcr_root - ${project.build.directory}/package/jcr_root - - **/*.vlt - **/*.svn - **/*.gitignore - **/*.DS_Store - - - - ${basedir}/src/main/upgrader - ${project.build.directory}/vault-work/META-INF/vault/definition/upgrader - - - packaging-contentpackage @@ -51,6 +33,22 @@ + + + ${basedir}/src/main/jcr_root + ${project.build.directory}/package/jcr_root + + **/*.vlt + **/*.svn + **/*.gitignore + **/*.DS_Store + + + + ${basedir}/src/main/upgrader + ${project.build.directory}/vault-work/META-INF/vault/definition/upgrader + + org.apache.maven.plugins diff --git a/samples/script-package/src/main/META-INF/vault/definition/.content.xml b/samples/script-package/src/main/META-INF/vault/definition/.content.xml new file mode 100644 index 0000000..9ba7a93 --- /dev/null +++ b/samples/script-package/src/main/META-INF/vault/definition/.content.xml @@ -0,0 +1,18 @@ + + + \ No newline at end of file diff --git a/samples/script-package/src/main/jcr_root/content/myapp/.content.xml b/samples/script-package/src/main/jcr_root/content/myapp/.content.xml new file mode 100755 index 0000000..93d2f5b --- /dev/null +++ b/samples/script-package/src/main/jcr_root/content/myapp/.content.xml @@ -0,0 +1,3 @@ + + diff --git a/samples/sling-pipes-package/src/main/META-INF/vault/definition/.content.xml b/samples/sling-pipes-package/src/main/META-INF/vault/definition/.content.xml new file mode 100644 index 0000000..9ba7a93 --- /dev/null +++ b/samples/sling-pipes-package/src/main/META-INF/vault/definition/.content.xml @@ -0,0 +1,18 @@ + + + \ No newline at end of file diff --git a/samples/sling-pipes-package/src/main/jcr_root/content/myapp/.content.xml b/samples/sling-pipes-package/src/main/jcr_root/content/myapp/.content.xml new file mode 100755 index 0000000..93d2f5b --- /dev/null +++ b/samples/sling-pipes-package/src/main/jcr_root/content/myapp/.content.xml @@ -0,0 +1,3 @@ + + diff --git a/samples/userpreferences-package/src/main/META-INF/vault/definition/.content.xml b/samples/userpreferences-package/src/main/META-INF/vault/definition/.content.xml new file mode 100644 index 0000000..9ba7a93 --- /dev/null +++ b/samples/userpreferences-package/src/main/META-INF/vault/definition/.content.xml @@ -0,0 +1,18 @@ + + + \ No newline at end of file diff --git a/samples/userpreferences-package/src/main/jcr_root/content/myapp/.content.xml b/samples/userpreferences-package/src/main/jcr_root/content/myapp/.content.xml new file mode 100755 index 0000000..93d2f5b --- /dev/null +++ b/samples/userpreferences-package/src/main/jcr_root/content/myapp/.content.xml @@ -0,0 +1,3 @@ + + diff --git a/vault-upgrade-hook/pom.xml b/vault-upgrade-hook/pom.xml index 7b051b1..5bed021 100644 --- a/vault-upgrade-hook/pom.xml +++ b/vault-upgrade-hook/pom.xml @@ -109,13 +109,13 @@ org.codehaus.groovy groovy-all - 2.4.10 + 2.4.15 true com.icfolson.aem.groovy.console aem-groovy-console - 9.0.0 + 15.1.0 true diff --git a/vault-upgrade-hook/src/main/java/biz/netcentric/vlt/upgrade/handler/groovy/FakeRequest.java b/vault-upgrade-hook/src/main/java/biz/netcentric/vlt/upgrade/handler/groovy/FakeRequest.java deleted file mode 100644 index eb8e290..0000000 --- a/vault-upgrade-hook/src/main/java/biz/netcentric/vlt/upgrade/handler/groovy/FakeRequest.java +++ /dev/null @@ -1,573 +0,0 @@ -/* - * (C) Copyright 2016 Netcentric AG. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package biz.netcentric.vlt.upgrade.handler.groovy; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.UnsupportedEncodingException; -import java.security.Principal; -import java.util.Collections; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.ResourceBundle; - -import javax.servlet.RequestDispatcher; -import javax.servlet.ServletContext; -import javax.servlet.ServletInputStream; -import javax.servlet.http.Cookie; -import javax.servlet.http.HttpSession; -import javax.servlet.http.HttpSessionContext; - -import org.apache.sling.api.SlingHttpServletRequest; -import org.apache.sling.api.request.RequestDispatcherOptions; -import org.apache.sling.api.request.RequestParameter; -import org.apache.sling.api.request.RequestParameterMap; -import org.apache.sling.api.request.RequestPathInfo; -import org.apache.sling.api.request.RequestProgressTracker; -import org.apache.sling.api.resource.Resource; -import org.apache.sling.api.resource.ResourceResolver; - -@SuppressWarnings({ "deprecation", "rawtypes", "unchecked" }) -public class FakeRequest implements SlingHttpServletRequest { - private final String method; - private final String path; - private final Map attributes; - private final Map parameters; - private final HttpSession session; - private final ResourceResolver resourceResolver; - - private static final class FakeHttpSession implements HttpSession { - @Override - public long getCreationTime() { - throw new UnsupportedOperationException(); - } - - @Override - public String getId() { - throw new UnsupportedOperationException(); - } - - @Override - public long getLastAccessedTime() { - throw new UnsupportedOperationException(); - } - - @Override - public ServletContext getServletContext() { - throw new UnsupportedOperationException(); - } - - @Override - public void setMaxInactiveInterval(int i) { - throw new UnsupportedOperationException(); - } - - @Override - public int getMaxInactiveInterval() { - throw new UnsupportedOperationException(); - } - - @Override - public HttpSessionContext getSessionContext() { - throw new UnsupportedOperationException(); - } - - @Override - public Object getAttribute(String s) { - throw new UnsupportedOperationException(); - } - - @Override - public Object getValue(String s) { - throw new UnsupportedOperationException(); - } - - @Override - public Enumeration getAttributeNames() { - throw new UnsupportedOperationException(); - } - - @Override - public String[] getValueNames() { - throw new UnsupportedOperationException(); - } - - @Override - public void setAttribute(String s, Object o) { - throw new UnsupportedOperationException(); - } - - @Override - public void putValue(String s, Object o) { - throw new UnsupportedOperationException(); - } - - @Override - public void removeAttribute(String s) { - throw new UnsupportedOperationException(); - } - - @Override - public void removeValue(String s) { - throw new UnsupportedOperationException(); - } - - @Override - public void invalidate() { - throw new UnsupportedOperationException(); - } - - @Override - public boolean isNew() { - throw new UnsupportedOperationException(); - } - } - - public FakeRequest(ResourceResolver resourceResolver, String method, String path, Map params) { - this.resourceResolver = resourceResolver; - this.method = method; - this.path = path; - attributes = new HashMap(); - parameters = new HashMap(); - session = new FakeHttpSession(); - - for (String key : params.keySet()) { - Object value = params.get(key); - - // internally, Sling seems to expect all parameter values to be - // String[] - if (params.get(key) instanceof String[]) { - parameters.put(key, (String[]) value); - } else { - parameters.put(key, new String[] { value.toString() }); - } - } - } - - @Override - public String getAuthType() { - return null; - } - - @Override - public String getContextPath() { - return ""; - } - - @Override - public Cookie[] getCookies() { - return new Cookie[0]; - } - - @Override - public long getDateHeader(String name) { - return -1; - } - - @Override - public String getHeader(String name) { - return null; - } - - @Override - public Enumeration getHeaderNames() { - return null; - } - - @Override - public Enumeration getHeaders(String name) { - return null; - } - - @Override - public int getIntHeader(String name) { - return -1; - } - - @Override - public String getMethod() { - return method; - } - - @Override - public String getPathInfo() { - return null; - } - - @Override - public String getPathTranslated() { - return null; - } - - @Override - public String getQueryString() { - return null; - } - - @Override - public String getRemoteUser() { - return null; - } - - @Override - public String getRequestURI() { - return path; - } - - @Override - public StringBuffer getRequestURL() { - return new StringBuffer("http://localhost:4502" + path); - } - - @Override - public String getRequestedSessionId() { - return null; - } - - @Override - public String getServletPath() { - return path; - } - - @Override - public HttpSession getSession() { - return session; - } - - @Override - public HttpSession getSession(boolean create) { - return session; - } - - @Override - public Principal getUserPrincipal() { - return null; - } - - @Override - public boolean isRequestedSessionIdFromCookie() { - return false; - } - - @Override - public boolean isRequestedSessionIdFromURL() { - return false; - } - - @Override - public boolean isRequestedSessionIdFromUrl() { - return false; - } - - @Override - public boolean isRequestedSessionIdValid() { - return false; - } - - @Override - public boolean isUserInRole(String role) { - return false; - } - - @Override - public Object getAttribute(String name) { - return attributes.get(name); - } - - @Override - public Enumeration getAttributeNames() { - return Collections.enumeration(attributes.keySet()); - } - - @Override - public String getCharacterEncoding() { - return "utf-8"; - } - - @Override - public int getContentLength() { - return 0; - } - - @Override - public String getContentType() { - return null; - } - - @Override - public ServletInputStream getInputStream() throws IOException { - return null; - } - - @Override - public String getLocalAddr() { - return null; - } - - @Override - public String getLocalName() { - return null; - } - - @Override - public int getLocalPort() { - return 0; - } - - @Override - public Locale getLocale() { - return null; - } - - @Override - public Enumeration getLocales() { - return null; - } - - @Override - public String getParameter(String name) { - try { - final Object value = parameters.get(name); - - if (value instanceof String[]) { - return ((String[]) value)[0]; - } - - return (String) value; - } catch (ClassCastException e) { - return null; - } - } - - @Override - public Map getParameterMap() { - return parameters; - } - - @Override - public Enumeration getParameterNames() { - return Collections.enumeration(parameters.keySet()); - } - - @Override - public String[] getParameterValues(String name) { - throw new UnsupportedOperationException(); - } - - @Override - public String getProtocol() { - return "HTTP/1.1"; - } - - @Override - public BufferedReader getReader() throws IOException { - return null; - } - - @Override - public String getRealPath(String path) { - return null; - } - - @Override - public String getRemoteAddr() { - return null; - } - - @Override - public String getRemoteHost() { - return null; - } - - @Override - public int getRemotePort() { - return 0; - } - - @Override - public RequestDispatcher getRequestDispatcher(String path) { - return null; - } - - @Override - public String getScheme() { - return "http"; - } - - @Override - public String getServerName() { - return null; - } - - @Override - public int getServerPort() { - return 0; - } - - @Override - public boolean isSecure() { - return false; - } - - @Override - public void removeAttribute(String name) { - attributes.remove(name); - } - - @Override - public void setAttribute(String name, Object o) { - attributes.put(name, o); - } - - @Override - public void setCharacterEncoding(String env) throws UnsupportedEncodingException { - } - - @Override - public Resource getResource() { - return null; - } - - @Override - public ResourceResolver getResourceResolver() { - return resourceResolver; - } - - @Override - public RequestPathInfo getRequestPathInfo() { - return null; - } - - @Override - public RequestParameter getRequestParameter(final String s) { - final String value = getParameter(s); - if (value != null) { - return new RequestParameter() { - @Override - public String getName() { - return s; - } - - @Override - public boolean isFormField() { - return false; - } - - @Override - public String getContentType() { - return null; - } - - @Override - public long getSize() { - return value.length(); - } - - @Override - public byte[] get() { - return value.getBytes(); - } - - @Override - public InputStream getInputStream() throws IOException { - return null; - } - - @Override - public String getFileName() { - return null; - } - - @Override - public String getString() { - return value; - } - - @Override - public String getString(String s) throws UnsupportedEncodingException { - return value; - } - }; - } - return null; - } - - @Override - public RequestParameter[] getRequestParameters(String s) { - return new RequestParameter[0]; - } - - @Override - public RequestParameterMap getRequestParameterMap() { - return null; - } - - @Override - public RequestDispatcher getRequestDispatcher(String s, RequestDispatcherOptions requestDispatcherOptions) { - return null; - } - - @Override - public RequestDispatcher getRequestDispatcher(Resource resource, - RequestDispatcherOptions requestDispatcherOptions) { - return null; - } - - @Override - public RequestDispatcher getRequestDispatcher(Resource resource) { - return null; - } - - @Override - public Cookie getCookie(String s) { - return null; - } - - @Override - public String getResponseContentType() { - return null; - } - - @Override - public Enumeration getResponseContentTypes() { - return null; - } - - @Override - public ResourceBundle getResourceBundle(Locale locale) { - return null; - } - - @Override - public ResourceBundle getResourceBundle(String s, Locale locale) { - return null; - } - - @Override - public RequestProgressTracker getRequestProgressTracker() { - return null; - } - - @Override - public AdapterType adaptTo(Class aClass) { - if (ResourceResolver.class.equals(aClass)) { - return (AdapterType) getResourceResolver(); - } - return null; - } - - @Override - public List getRequestParameterList() { - return null; - } -} diff --git a/vault-upgrade-hook/src/main/java/biz/netcentric/vlt/upgrade/handler/groovy/FakeResponse.java b/vault-upgrade-hook/src/main/java/biz/netcentric/vlt/upgrade/handler/groovy/FakeResponse.java deleted file mode 100644 index 8302029..0000000 --- a/vault-upgrade-hook/src/main/java/biz/netcentric/vlt/upgrade/handler/groovy/FakeResponse.java +++ /dev/null @@ -1,190 +0,0 @@ -/* - * (C) Copyright 2016 Netcentric AG. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package biz.netcentric.vlt.upgrade.handler.groovy; - -import org.apache.sling.api.SlingHttpServletResponse; - -import javax.servlet.ServletOutputStream; -import javax.servlet.http.Cookie; -import java.io.IOException; -import java.io.PrintWriter; -import java.util.Locale; - -public class FakeResponse implements SlingHttpServletResponse { - - static FakeResponse INSTANCE = new FakeResponse(); - - private FakeResponse() { - } - - @Override - public void addCookie(Cookie cookie) { - - } - - @Override - public boolean containsHeader(String name) { - return false; - } - - @Override - public String encodeURL(String url) { - return null; - } - - @Override - public String encodeRedirectURL(String url) { - return null; - } - - @Override - public String encodeUrl(String url) { - return null; - } - - @Override - public String encodeRedirectUrl(String url) { - return null; - } - - @Override - public void sendError(int sc, String msg) throws IOException { - - } - - @Override - public void sendError(int sc) throws IOException { - - } - - @Override - public void sendRedirect(String location) throws IOException { - - } - - @Override - public void setDateHeader(String name, long date) { - - } - - @Override - public void addDateHeader(String name, long date) { - - } - - @Override - public void setHeader(String name, String value) { - - } - - @Override - public void addHeader(String name, String value) { - - } - - @Override - public void setIntHeader(String name, int value) { - - } - - @Override - public void addIntHeader(String name, int value) { - - } - - @Override - public void setStatus(int sc) { - - } - - @Override - public void setStatus(int sc, String sm) { - - } - - @Override - public String getCharacterEncoding() { - return null; - } - - @Override - public String getContentType() { - return null; - } - - @Override - public ServletOutputStream getOutputStream() throws IOException { - return null; - } - - @Override - public PrintWriter getWriter() throws IOException { - return null; - } - - @Override - public void setCharacterEncoding(String charset) { - - } - - @Override - public void setContentLength(int len) { - - } - - @Override - public void setContentType(String type) { - - } - - @Override - public void setBufferSize(int size) { - - } - - @Override - public int getBufferSize() { - return 0; - } - - @Override - public void flushBuffer() throws IOException { - - } - - @Override - public void resetBuffer() { - - } - - @Override - public boolean isCommitted() { - return false; - } - - @Override - public void reset() { - - } - - @Override - public void setLocale(Locale loc) { - - } - - @Override - public Locale getLocale() { - return null; - } - - @Override - public AdapterType adaptTo(Class type) { - return null; - } -} diff --git a/vault-upgrade-hook/src/main/java/biz/netcentric/vlt/upgrade/handler/groovy/GroovyScript.java b/vault-upgrade-hook/src/main/java/biz/netcentric/vlt/upgrade/handler/groovy/GroovyScript.java index de0c337..43df621 100644 --- a/vault-upgrade-hook/src/main/java/biz/netcentric/vlt/upgrade/handler/groovy/GroovyScript.java +++ b/vault-upgrade-hook/src/main/java/biz/netcentric/vlt/upgrade/handler/groovy/GroovyScript.java @@ -8,26 +8,20 @@ */ package biz.netcentric.vlt.upgrade.handler.groovy; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.util.HashMap; -import java.util.Map; - import javax.jcr.Node; import javax.jcr.RepositoryException; import org.apache.jackrabbit.vault.packaging.InstallContext; import org.apache.jackrabbit.vault.packaging.InstallContext.Phase; -import org.apache.sling.api.SlingHttpServletRequest; import com.icfolson.aem.groovy.console.GroovyConsoleService; +import com.icfolson.aem.groovy.console.api.context.ScriptContext; import com.icfolson.aem.groovy.console.response.RunScriptResponse; import biz.netcentric.vlt.upgrade.UpgradeAction; import biz.netcentric.vlt.upgrade.handler.OsgiUtil.ServiceWrapper; import biz.netcentric.vlt.upgrade.handler.SlingUtils; import biz.netcentric.vlt.upgrade.util.PackageInstallLogger; -import org.apache.sling.api.SlingHttpServletResponse; public class GroovyScript extends UpgradeAction { @@ -43,61 +37,31 @@ public GroovyScript(final Node script, final Phase defaultPhase) throws Reposito @Override public void execute(final InstallContext ctx) throws RepositoryException { - final SlingHttpServletRequest request = getRequestForScript(); - if (request != null) { - LOG.debug(ctx, "Executing [{}]", getName()); - final RunScriptResponse scriptResponse = run(request); - LOG.debug(ctx, "Executed script [{}]: [{}]\n{}\n---\n", getName(), scriptResponse.getRunningTime(), - scriptResponse.getExceptionStackTrace()); - if (scriptResponse.getExceptionStackTrace() != null && scriptResponse.getExceptionStackTrace().trim().length() > 0) { - throw new RuntimeException( - "Error executing script " + getName() + "\n" + scriptResponse.getExceptionStackTrace()); - } else { - LOG.info(ctx, "Executed [{}]: [{}]\n{}\n---\n", getName(), scriptResponse.getRunningTime(), - scriptResponse.getOutput().trim()); - } + LOG.debug(ctx, "Executing [{}]", getName()); + final RunScriptResponse scriptResponse = run(); + LOG.debug(ctx, "Executed script [{}]: [{}]\n{}\n---\n", getName(), scriptResponse.getRunningTime(), + scriptResponse.getExceptionStackTrace()); + if (scriptResponse.getExceptionStackTrace() != null && scriptResponse.getExceptionStackTrace().trim().length() > 0) { + throw new RuntimeException( + "Error executing script " + getName() + "\n" + scriptResponse.getExceptionStackTrace()); + } else { + LOG.info(ctx, "Executed [{}]: [{}]\n{}\n---\n", getName(), scriptResponse.getRunningTime(), + scriptResponse.getOutput().trim()); } } - protected RunScriptResponse run(final SlingHttpServletRequest request) { + protected RunScriptResponse run() throws RepositoryException { try (ServiceWrapper serviceWrapper = sling.getService(GroovyConsoleService.class)) { - Class consoleServiceClass = GroovyConsoleService.class; - - try { - Method runScript = consoleServiceClass.getDeclaredMethod("runScript", SlingHttpServletRequest.class, SlingHttpServletResponse.class); - if (Modifier.isPublic(runScript.getModifiers()) && runScript.getReturnType().equals(RunScriptResponse.class)) { - return (RunScriptResponse) runScript.invoke(serviceWrapper.getService(), request, FakeResponse.INSTANCE); - } - } catch (NoSuchMethodException nsm) { - // do nothing, this is an expected case - } catch (Exception e) { - throw new RuntimeException(e); - } - - try { - Method runScript = consoleServiceClass.getDeclaredMethod("runScript", SlingHttpServletRequest.class); - if (Modifier.isPublic(runScript.getModifiers()) && runScript.getReturnType().equals(RunScriptResponse.class)) { - return (RunScriptResponse) runScript.invoke(serviceWrapper.getService(), request); - } - } catch (NoSuchMethodException nsm) { - // do nothing, this is an expected case - } catch (Exception e) { - throw new RuntimeException(e); - } - - return null; + ScriptContext context = new UpgradeHookScriptContext() // + .setResourceResolver(sling.getResourceResolver(script.getSession())) // + .setUserId(script.getSession().getUserID()) // + .setScript(getScriptContent(script)) // + .setData(getData()) // + ; + return serviceWrapper.getService().runScript(context); } } - protected SlingHttpServletRequest getRequestForScript() throws RepositoryException { - final Map parameters = new HashMap<>(); - parameters.put("script", getScriptContent(script)); - parameters.put("scriptPath", script.getPath()); - parameters.put("data", getData()); - return new FakeRequest(sling.getResourceResolver(script.getSession()), "GET", "/bin/groovyconsole/post.json", - parameters); - } - private String getData() throws RepositoryException { Node parent = script.getParent(); return parent.hasProperty("data") ? parent.getProperty("data").getString() : ""; diff --git a/vault-upgrade-hook/src/main/java/biz/netcentric/vlt/upgrade/handler/groovy/UpgradeHookScriptContext.java b/vault-upgrade-hook/src/main/java/biz/netcentric/vlt/upgrade/handler/groovy/UpgradeHookScriptContext.java new file mode 100644 index 0000000..46a5053 --- /dev/null +++ b/vault-upgrade-hook/src/main/java/biz/netcentric/vlt/upgrade/handler/groovy/UpgradeHookScriptContext.java @@ -0,0 +1,67 @@ +package biz.netcentric.vlt.upgrade.handler.groovy; + +import java.io.ByteArrayOutputStream; +import java.io.PrintStream; + +import org.apache.sling.api.resource.ResourceResolver; + +import com.icfolson.aem.groovy.console.api.context.ScriptContext; + +public class UpgradeHookScriptContext implements ScriptContext { + + private ResourceResolver resourceResolver; + private String userId; + private String script; + private String data; + private final ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + + public UpgradeHookScriptContext setData(String data) { + this.data = data; + return this; + } + + public UpgradeHookScriptContext setResourceResolver(ResourceResolver resourceResolver) { + this.resourceResolver = resourceResolver; + return this; + } + + public UpgradeHookScriptContext setUserId(String userId) { + this.userId = userId; + return this; + } + + public UpgradeHookScriptContext setScript(String script) { + this.script = script; + return this; + } + + @Override + public String getData() { + return data; + } + + @Override + public ByteArrayOutputStream getOutputStream() { + return outputStream ; + } + + @Override + public PrintStream getPrintStream() { + return new PrintStream(getOutputStream()); + } + + @Override + public ResourceResolver getResourceResolver() { + return resourceResolver; + } + + @Override + public String getScript() { + return script; + } + + @Override + public String getUserId() { + return userId; + } +}