icfnext / 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.
Other
159 stars 94 forks source link

Request-agnostic script context #100

Closed markdaugherty closed 4 years ago

markdaugherty commented 4 years ago

@pun-ky let me know what you think about the updates in this latest commit

pun-ky commented 4 years ago

@lykorian from my side now it's good. Thank you very much.

pun-ky commented 4 years ago

GroovyConsoleService.saveScript could have 2 signatures. First request agnostic with parameters like file name and script content... second one accepting request as it is already which will pass file name and content retrieved from request to first method.

https://github.com/icfnext/aem-groovy-console/blob/feature/request-agnostic-script-context/src/main/groovy/com/icfolson/aem/groovy/console/GroovyConsoleService.groovy#L12

interface GroovyConsoleService {

    RunScriptResponse runScript(SlingHttpServletRequest request) // backward compatibility

    RunScriptResponse runScript(ScriptContext scriptContext)

    SaveScriptResponse saveScript(SlingHttpServletRequest request) // backward compatibility

    SaveScriptResponse saveScript(ScriptData scriptData) // another request agnostic
}

interface ScriptData {
    String getFileName()
    String getContent()
}