// Path: java/src/org/drupal/project/computing/exception/DSiteException.java
// public class DSiteException extends Exception {
//     public DSiteException() {
//         super();
//     }
// 
//     public DSiteException(String s) {
//         super(s);
//     }
// 
//     public DSiteException(String s, Throwable throwable) {
//         super(s, throwable);
//     }
// 
//     public DSiteException(Throwable throwable) {
//         super(throwable);
//     }
// 
//     /**
//      * The error code is arbitrary by the caller which sets it.
//      */
//     private int errorCode = 0;
// 
//     public int getErrorCode() {
//         return errorCode;
//     }
// 
//     public void setErrorCode(int errorCode) {
//         this.errorCode = errorCode;
//     }
// 
// }
// 
// Path: java/src/org/drupal/project/computing/exception/DSystemExecutionException.java
// public class DSystemExecutionException extends Exception {
//     public DSystemExecutionException() {
//     }
// 
//     public DSystemExecutionException(String s) {
//         super(s);
//     }
// 
//     public DSystemExecutionException(String s, Throwable throwable) {
//         super(s, throwable);
//     }
// 
//     public DSystemExecutionException(Throwable throwable) {
//         super(throwable);
//     }
// }


import org.apache.commons.exec.CommandLine;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.drupal.project.computing.exception.DSiteException;
import org.drupal.project.computing.exception.DSystemExecutionException;
import javax.script.Bindings;
import javax.script.SimpleBindings;
import java.util.logging.Logger;
            logger.severe("Error running drush core-status.");
            throw new DSiteException("Cannot run drush core-status.", e);
        }

        return coreStatus;
    }


    /**
     * <p>Run any drupal code and get returns results in json.</p>
     *
     * <p>You wouldn't want to eval any Drupal code here. For example, node_save($node) is very hard to eval because
     * it's hard to pass in the parameter $node.</p>
     *
     * <p>To do node_save(), you need a Drupal function as a proxy that takes into some primitive parameters,
     * and then prepares $node to do node_save(). In fact, the basic idea of the "computing" module is that
     * you have a mixed of Drupal/PHP code and non-PHP code, where the former focuses on Drupal-related
     * stuff, and the latter on non-PHP related stuff.</p>
     *
     * @param phpCode Should not use "<?php ... ?>"
     *
     * @return execution results in JSON.
     * @throws DSiteException
     */
    public String computingEval(String phpCode) throws DSiteException {
        String result;
        try {
            result = execute(new String[] {"computing-eval", "--pipe", "-"}, phpCode);
        } catch (Exception e) {
            logger.severe("Error executing PHP code through computing-eval: " + phpCode);
// Path: java/src/org/drupal/project/computing/exception/DSiteException.java
// public class DSiteException extends Exception {
//     public DSiteException() {
//         super();
//     }
// 
//     public DSiteException(String s) {
//         super(s);
//     }
// 
//     public DSiteException(String s, Throwable throwable) {
//         super(s, throwable);
//     }
// 
//     public DSiteException(Throwable throwable) {
//         super(throwable);
//     }
// 
//     /**
//      * The error code is arbitrary by the caller which sets it.
//      */
//     private int errorCode = 0;
// 
//     public int getErrorCode() {
//         return errorCode;
//     }
// 
//     public void setErrorCode(int errorCode) {
//         this.errorCode = errorCode;
//     }
// 
// }
// 
// Path: java/src/org/drupal/project/computing/exception/DSystemExecutionException.java
// public class DSystemExecutionException extends Exception {
//     public DSystemExecutionException() {
//     }
// 
//     public DSystemExecutionException(String s) {
//         super(s);
//     }
// 
//     public DSystemExecutionException(String s, Throwable throwable) {
//         super(s, throwable);
//     }
// 
//     public DSystemExecutionException(Throwable throwable) {
//         super(throwable);
//     }
// }


// Path: java/src/org/drupal/project/computing/DDrush.java
import org.apache.commons.exec.CommandLine;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.drupal.project.computing.exception.DSiteException;
import org.drupal.project.computing.exception.DSystemExecutionException;
import javax.script.Bindings;
import javax.script.SimpleBindings;
import java.util.logging.Logger;

            logger.severe("Error running drush core-status.");
            throw new DSiteException("Cannot run drush core-status.", e);
        }

        return coreStatus;
    }


    /**
     * <p>Run any drupal code and get returns results in json.</p>
     *
     * <p>You wouldn't want to eval any Drupal code here. For example, node_save($node) is very hard to eval because
     * it's hard to pass in the parameter $node.</p>
     *
     * <p>To do node_save(), you need a Drupal function as a proxy that takes into some primitive parameters,
     * and then prepares $node to do node_save(). In fact, the basic idea of the "computing" module is that
     * you have a mixed of Drupal/PHP code and non-PHP code, where the former focuses on Drupal-related
     * stuff, and the latter on non-PHP related stuff.</p>
     *
     * @param phpCode Should not use "<?php ... ?>"
     *
     * @return execution results in JSON.
     * @throws DSiteException
     */
    public String computingEval(String phpCode) throws DSiteException {
        String result;
        try {
            result = execute(new String[] {"computing-eval", "--pipe", "-"}, phpCode);
        } catch (Exception e) {
            logger.severe("Error executing PHP code through computing-eval: " + phpCode);
            throw new DSiteException("Cannot execute computing-eval.", e);