orbinson / aem-groovy-console

The AEM Groovy Console provides an interface for running Groovy scripts in the AEM container. Scripts can be created to manipulate content in the JCR, call OSGi services, or execute arbitrary code using the CQ, Sling, or JCR APIs.
https://orbinson.github.io/aem-groovy-console/
Other
16 stars 4 forks source link

Improve documentation of binding variables and methods #46

Open kwin opened 1 year ago

kwin commented 1 year ago

All methods/objects which are provided by default in the script context should have an improved documentation. This includes e.g. methods added via any of the classes in https://github.com/orbinson/aem-groovy-console/tree/1100331993e8799f2d6c82223e9950e5d1945fed/bundle/src/main/groovy/be/orbinson/aem/groovy/console/extension/impl/scriptmetaclass or objects added via the classes in https://github.com/orbinson/aem-groovy-console/tree/1100331993e8799f2d6c82223e9950e5d1945fed/bundle/src/main/groovy/be/orbinson/aem/groovy/console/extension/impl/binding.

The documentation in http://localhost:4502/groovyconsole is not enough, as this does not expose any description on binding variables and no detailled description on parameters for methods.

kwin commented 1 year ago

Particularly interesting is whether the underlying resourceResolver/session is derived from the user session bound to the request or always an admin or service resource resolver/session.

royteeuwen commented 1 year ago

Good idea, I'll add some docs!

It isn't certain on what resource resolver is used, this depends on the ScriptContext used.

For example if you use the groovy console through the UI, it will be user bound because it uses the RequestScriptContext: https://github.com/orbinson/aem-groovy-console/blob/main/api/src/main/groovy/be/orbinson/aem/groovy/console/api/context/impl/RequestScriptContext.groovy#L29 https://github.com/orbinson/aem-groovy-console/blob/main/bundle/src/main/groovy/be/orbinson/aem/groovy/console/servlets/ScriptPostServlet.groovy#L73

But if you use the groovy console through AECU, it will be a service user:

https://github.com/valtech/aem-easy-content-upgrade/blob/develop/core/src/main/java/de/valtech/aecu/core/service/AecuServiceImpl.java#L180 https://github.com/valtech/aem-easy-content-upgrade/blob/develop/core/src/main/java/de/valtech/aecu/core/service/AecuServiceImpl.java#L213

kwin commented 1 year ago

@royteeuwen Thanks for picking it up, but then I am wondering, what this service user is used for in Groovy Console: https://github.com/orbinson/aem-groovy-console/blob/1100331993e8799f2d6c82223e9950e5d1945fed/ui.config/src/main/content/jcr_root/apps/groovyconsole-config/osgiconfig/config/org.apache.sling.jcr.repoinit.RepositoryInitializer-groovyconsole.config#L8

kwin commented 1 year ago

Compare with the related https://github.com/valtech/aem-easy-content-upgrade/issues/220

royteeuwen commented 1 year ago

@kwin interested in doing a review for the first changes? https://github.com/orbinson/aem-groovy-console/pull/49