org.drupal.project.computing
Class DUtils.Drush

java.lang.Object
  extended by org.drupal.project.computing.DUtils.Drush
Enclosing class:
DUtils

public static class DUtils.Drush
extends java.lang.Object

This is the utility class to run drush command.


Constructor Summary
DUtils.Drush()
           
DUtils.Drush(DConfig config)
           
DUtils.Drush(java.lang.String drushExec)
           
 
Method Summary
 boolean checkComputing()
          Check if the "computing" module drush command is available.
 java.lang.String computingCall(java.lang.String[] params)
          Call any Drupal functions and returns results in json.
 java.lang.String computingEval(java.lang.String phpCode)
          Run any drupal code and get returns results in json.
 java.lang.String execute(java.lang.String[] command)
           
 java.lang.String execute(java.lang.String[] command, java.lang.String input)
          Execute Drush command, and returns STDOUT results.
 java.util.Properties getCoreStatus()
          Get Drupal core-status info.
 java.lang.String getDrushExec()
           
 java.lang.String getVersion()
          Get Drush version.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DUtils.Drush

public DUtils.Drush(java.lang.String drushExec)

DUtils.Drush

public DUtils.Drush(DConfig config)

DUtils.Drush

public DUtils.Drush()
Method Detail

execute

public java.lang.String execute(java.lang.String[] command)
                         throws DConnectionException
Throws:
DConnectionException

execute

public java.lang.String execute(java.lang.String[] command,
                                java.lang.String input)
                         throws DConnectionException
Execute Drush command, and returns STDOUT results. attention: here we use shell stdout to output results, which is problematic. possible problems are: 1) security concerns, where confidential info might get printed 2) encoding/decoding characters to byte streams, especially with non-english languages and serializd strings. 3) escaping problems 4) output might get messed up with other sub-processes. some other IPC approaches: 1) Apache Camel, 2) /tmp files, 3) message queue however, STDOUT is the simplest approach for now.

Parameters:
command - The drush command to execute.
input - Input stream, could be null.
Returns:
STDOUT results.
Throws:
DConnectionException

getVersion

public java.lang.String getVersion()
                            throws DConnectionException
Get Drush version.

Returns:
Throws:
DConnectionException

getDrushExec

public java.lang.String getDrushExec()

getCoreStatus

public java.util.Properties getCoreStatus()
                                   throws DConnectionException
Get Drupal core-status info.

Returns:
Throws:
DConnectionException
See Also:
"drush core-status"

computingEval

public java.lang.String computingEval(java.lang.String phpCode)
                               throws DConnectionException
Run any drupal code and get returns results in json.

Parameters:
phpCode - Should not use ""
Returns:
execution results in JSON.
Throws:
DConnectionException

computingCall

public java.lang.String computingCall(java.lang.String[] params)
                               throws DConnectionException
Call any Drupal functions and returns results in json.

Parameters:
params - First param is the function name; the rest are parameters in json. Callers are responsible to wrap the params in json, but not responsible to escape them as command line args.
Returns:
Execution results in JSON.
Throws:
DConnectionException

checkComputing

public boolean checkComputing()
Check if the "computing" module drush command is available. It doesn't check if the module itself is enabled or not.

Returns:
true if computing* drush command is available, or false if not.