Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCU-1967

Commands: wrong example of execution through groovy

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Neutral
    • None
    • None
    • None
    • None

    Description

      The piece of code shown in Executing a command in the Groovy console section leads to errors since the context object used within groovy scope, which is actually a info.magnolia.module.groovy.console.MgnlGroovyContextDecorator object, doesn't work for certain cases like publish. See PUBLISHING-66.

      There are some tickets where customers reported wrong behaviour after executing commands this way so we should correct our docs in order to avoid its usage.

      The way the should be executed is either calling info.magnolia.commands.CommandsManager.executeCommand() or passing a SimpleContext object to execute() method instead of groovy ctx object. 

      Option1
      map  = new java.util.LinkedHashMap<String, String>()
      map.put("path", "/PATH-TO-PAGE")
      map.put("repository", "website")
      cm = info.magnolia.commands.CommandsManager.getInstance()
      cm.executeCommand('default','publish',map)  
      
      option2
      cm = info.magnolia.commands.CommandsManager.getInstance()
      command = cm.getCommand('activate')
      command.setRepository('website')
      command.setPath('/PATH-TO-PAGE')
      command.setRecursive(true)
      command.execute(new info.magnolia.context.SimpleContext())
      

      Checklists

        Acceptance criteria

        Attachments

          Issue Links

            Activity

              People

                mdrapela Martin Drápela
                jayala Jonathan Ayala
                Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved:

                  Checklists

                    Bug DoR