Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: DOCU-1967

...

Use the Groovy console to execute command business logic manually, in ad hoc fashion. This is a quick way to test a custom command before you compile it as a Java class.

...

Both of the two options below publish the page /travel/about/careers . You can test it by making a small change on the careers page, executing the Groovy commands, and viewing the modified history page on the public instance. 

  • Open the Groovy app.
  • Issue the following commands in the console:

    • Option A - Calling the info.magnolia.commands.CommandsManager.executeCommand():

      Code Block
      java
      java
      map  = new java.util.LinkedHashMap<String, String>()
      map.put("path", "/travel/about/careers")
      map.put("repository", "website")
      cm = info.magnolia.commands.CommandsManager.getInstance()
      cm.executeCommand('default','publish',map)
      
    • Option B - Passing a SimpleContextobject to the execute() method:

      Code Block
      java
      java
      cm = info.magnolia.commands.CommandsManager.getInstance()
      command = cm.getCommand('activate')

...

    • 
      command.setRepository('website')

...

    • 
      command.setPath('/travel/about/careers')

...

    • 
      command.setRecursive(true)
      command.execute(

...

This example activates the page /travel/about/careers. You can test it by making a small change on the careers page, executing the Groovy commands, and viewing the modified history page on the public instance.

...

    • new info.magnolia.context.SimpleContext())
      

Executing a command as a Groovy script

...