<commit_before>package com.eae

import org.codehaus.groovy.grails.web.json.JSONObject

class EAEManagementController {

    def mongoService
    def openLavaService

    static allowedMethods = [authenticate: ['POST'], retrieveClusters: ['GET']]

    def mongoParams(){
        final String MONGO_URL = grailsApplication.config.com.eae.mongoURL;
        final String MONGO_USER = grailsApplication.config.com.eae.mongoUser;
        final String MONGO_USER_DB_IDENTIFICATION = grailsApplication.config.com.eae.mongoUserdatabse;
        final char[] MONGO_PASSWORD = grailsApplication.config.com.eae.mongoPassword;

        return [MONGO_URL, MONGO_USER, MONGO_USER_DB_IDENTIFICATION, MONGO_PASSWORD];
    }

    /**
     * Method that allows to register a new node.
     *
     * @return {str}: Sends if the node has been registered or not.
     */
    def registerNewNode = {
        def myParams =  request.reader.text
        def jsonParams = new JSONObject(myParams)
        String workflow = jsonParams.workflow


    }

    /**
     *   Authenticate the admin and go to eAE management page if the authentication is successful
     */
    def authenticate = {
        String username = params.username
        String password = <PASSWORD>

        final def (MONGO_URL, MONGO_USER, MONGO_USER_DB_IDENTIFICATION, MONGO_PASSWORD) = mongoParams();
        def url = MONGO_URL.split(':');
        String eaeDatabase= "eae";
        String collection = "users";
        def res = mongoService.checkUser((String)url[0], (String)url[1], (String)MONGO_USER, (String)MONGO_USER_DB_IDENTIFICATION, (char[])MONGO_PASSWORD, eaeDatabase, collection, username, password);

        if( res == "OK"){
            render template: '/eAEManagement/management'
        }else {
            render res
        }
    }

    /**
     *  Retrieve clusters and the associated nodes
     */
    def retrieveClusters = {
        final String scriptDir = getWebAppFolder() + '/Scripts/'
        def clusters = openLavaService.retrieveClusters(scriptDir)

        JSONObject answer = new JSONObject();
        answer.put("clusters", clusters);

        render answer
    }

    /**
     *   Gets the directory where all the bash scripts are located
     *
     *   @return {str}: path to the script folder
     */
    private def getWebAppFolder() {
        return  grailsApplication.mainContext.servletContext.getRealPath('web-app');
    }
}<commit_msg>fix for home script<commit_after>package com.eae

import org.codehaus.groovy.grails.web.json.JSONObject

class EAEManagementController {

    def mongoService
    def openLavaService

    static allowedMethods = [authenticate: ['POST'], retrieveClusters: ['GET']]

    def mongoParams(){
        final String MONGO_URL = grailsApplication.config.com.eae.mongoURL;
        final String MONGO_USER = grailsApplication.config.com.eae.mongoUser;
        final String MONGO_USER_DB_IDENTIFICATION = grailsApplication.config.com.eae.mongoUserdatabse;
        final char[] MONGO_PASSWORD = grailsApplication.config.com.eae.mongoPassword;

        return [MONGO_URL, MONGO_USER, MONGO_USER_DB_IDENTIFICATION, MONGO_PASSWORD];
    }

    /**
     * Method that allows to register a new node.
     *
     * @return {str}: Sends if the node has been registered or not.
     */
    def registerNewNode = {
        def myParams =  request.reader.text
        def jsonParams = new JSONObject(myParams)
        String workflow = jsonParams.workflow


    }

    /**
     *   Authenticate the admin and go to eAE management page if the authentication is successful
     */
    def authenticate = {
        String username = params.username
        String password = <PASSWORD>

        final def (MONGO_URL, MONGO_USER, MONGO_USER_DB_IDENTIFICATION, MONGO_PASSWORD) = mongoParams();
        def url = MONGO_URL.split(':');
        String eaeDatabase= "eae";
        String collection = "users";
        def res = mongoService.checkUser((String)url[0], (String)url[1], (String)MONGO_USER, (String)MONGO_USER_DB_IDENTIFICATION, (char[])MONGO_PASSWORD, eaeDatabase, collection, username, password);

        if( res == "OK"){
            render template: '/eAEManagement/management'
        }else {
            render res
        }
    }

    /**
     *  Retrieve clusters and the associated nodes
     */
    def retrieveClusters = {
        final String scriptDir = getScriptsFolder();
        def clusters = openLavaService.retrieveClusters(scriptDir);

        JSONObject answer = new JSONObject();
        answer.put("clusters", clusters);

        render answer
    }

    /**
     *   Gets the directory where all the bash scripts are located
     *
     *   @return {str}: path to the home folder
     */
    private def getScriptsFolder() {
        return  grailsApplication.mainContext.servletContext.getRealPath("") + '/Scripts/';
    }
}
{'fraction_non_alphanumeric': 0.09364066680386911, 'fraction_numerical': 0.0008232146532208273, 'mean_word_length': 2.7762237762237763, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4625709', 'n_tokens_mistral': 1462, 'n_tokens_neox': 1394, 'n_words': 351}