[DOCU-1967] Commands: wrong example of execution through groovy Created: 31/Oct/19 Updated: 06/Nov/19 Resolved: 06/Nov/19 |
|
| Status: | Closed |
| Project: | Documentation |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Neutral |
| Reporter: | Jonathan Ayala | Assignee: | Martin Drápela |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
||||||||
| Issue Links: |
|
||||||||
| Template: |
|
||||||||
| Acceptance criteria: |
Empty
|
||||||||
| Bug DoR: |
[ ]*
Steps to reproduce, expected, and actual results filled
[ ]*
Affected version filled
|
||||||||
| Date of First Response: | |||||||||
| Epic Link: | 2019 mgnl-staff requests | ||||||||
| 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 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()) |