[MGNLGROOVY-137] RemoteClientConsole doesn't work on M5 Created: 11/May/15  Updated: 25/Mar/22

Status: Open
Project: Magnolia Groovy Module
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Federico Grilli Assignee: Unassigned
Resolution: Unresolved Votes: 3
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Relates
causality
dependency
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Date of First Response:

 Description   

Remote client console no longer works with M5.

Goal
Allows a remote java client application to run Groovy scripts against a Magnolia server.

How To
In order to run the remote client, you can either use the internal Main class provided with the groovy module

*java -jar magnolia-module-groovy-1.2.jar *info.magnolia.module.groovy.remote.RemoteClientConsoleMain -user superuser -pass superuser ....
Command line arguments usage

usage: RemoteClientConsoleMain [-cmd <arg>] [-file <arg>] [-help] [-pass
       <arg>] [-uri <arg>] [-user <arg>]
 -cmd,--cmd <arg>         Groovy command line to be executed. Can have one
                          to n cmd arguments like
                              "name='World1'; println \"Hello $name!\"; println \"Hello $name1!\" ;"
 -file,--file <arg>       Groovy File to execute. Can have one to n file
                          arguments
 -help,--help             Print this usage information
 -pass,--password <arg>   Enter password
 -uri,--uri <arg>         Enter Magnolia Uri like
                          http://localhost:8080/contextpath
 -user,--user <arg>       Enter user

or write your own Main class:

Create a java project.
Refer the magnolia-module-groovy (either the jar or the Java Project).
Create a Main Class referring the MgnlGroovyRemoteClientConsole.class

...
import info.magnolia.module.groovy.util.MgnlGroovyRemoteClientConsole;
import java.io.File;
/**
 * ...
public class MainGroovyClient {
    /**
     * @param args
     */
    public static void main(String[] args) throws Exception {
       //Get incomming parameter from the args[]
        String userName = args[0];
        ...
        //Connect to Magnolia app
        MgnlGroovyRemoteClientConsole groovyClient = new MgnlGroovyRemoteClientConsole(magnoliaUri, userName, password);
        if(groovyClient.isConnected()){
            for(int i=3;i<args.length;i++) {
            .....
            String groovyScriptInArg = args[i];
            Object toExecute = null;
            //Check if the groovyScriptInArg is a File or a command line
            ...
            System.out.println(" "+groovyClient.execute(toExecute));
            ...
            groovyClient.disconnect();

Notes
Once MgnlGroovyRemoteClientConsole instance is connected, you can send 1 to n files. The connection will remain the same for the whole file list.

Variable/context defined in a script will not be accessible to the other scripts.



 Comments   
Comment by Vitor Costa [ 10/Oct/17 ]

This issue seems to be open still... What are the plans to fix this up? I'm running Magnolia 5.5, and I am unable to remotely start my groovy scripts...

Is there some kind of workaround for this? The problem seems to be the POST request to "/.magnolia/pages/groovyInteractiveConsole.html", which seems to be returning HTTP 400 (Bad Request)

Comment by Federico Grilli [ 10/Oct/17 ]

Hi Vitor, thanks for pointing this issue out again and sorry about the inconvenience. So far it's been very low priority. I will ask PM about plans to fix this. At the moment, as far as I know, there's no workaround.

As of Magnolia 5 the groovyInteractiveConsole.html page no longer exists, as the UI implementation underwent a complete rewrite.

Hope this helps,

Federico

Comment by Vitor Costa [ 10/Oct/17 ]

Hi Frederico, thank you for your feedback. That was my suspicion. It seems I'll have to see another way to go with this.

I'm quite new to Magnolia, and I'm trying to find a way to automate an export and import process. My first thought was to use groovy scripts for this, hence this need for the remote client. However, I just found that there is a scheduler module, which seems to fit my needs. I know this is beyond the scope of this ticket, but do you know where can I have a look into some examples of scheduled jobs? If there is an example for export / import pages and assets, it would be perfect.

Thank you!

Comment by Federico Grilli [ 10/Oct/17 ]

Nice that you found a solution to your problem An example of a scheduled job implemented as a Groovy script/class and how to configure it in Magnolia can be found on our documentation at
https://documentation.magnolia-cms.com/display/DOCS/Groovy+module#Groovymodule-UseGroovyclassesinsteadofJavaclasses

Hope this helps!

Comment by Vitor Costa [ 11/Oct/17 ]

Federico, thank you very much for that documentation! That was exactly what I was looking for, and it's working like a charm!

Best regards!

Generated at Mon Feb 12 05:55:57 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.