/*
 * LICENCE : CloudUnit is available under the GNU Affero General Public License : https://gnu.org/licenses/agpl.html
 * but CloudUnit is licensed too under a standard commercial license.
 * Please contact our sales team if you would like to discuss the specifics of our Enterprise license.
 * If you are not sure whether the AGPL is right for you,
 * you can always test our software under the AGPL and inspect the source code before you contact us
 * about purchasing a commercial license.
 *
 * LEGAL TERMS : "CloudUnit" is a registered trademark of Treeptik and can't be used to endorse
 * or promote products derived from this project without prior written permission from Treeptik.
 * Products or services derived from this software may not be called "CloudUnit"
 * nor may "Treeptik" or similar confusing terms appear in their names without prior written permission.
 * For any questions, contact us : contact@treeptik.fr
 */

package fr.treeptik.cloudunit.controller;

import fr.treeptik.cloudunit.aspects.CloudUnitSecurable;
import fr.treeptik.cloudunit.dto.*;
import fr.treeptik.cloudunit.enums.RemoteExecAction;
import fr.treeptik.cloudunit.exception.CheckException;
import fr.treeptik.cloudunit.exception.ServiceException;
import fr.treeptik.cloudunit.factory.EnvUnitFactory;
import fr.treeptik.cloudunit.manager.ApplicationManager;
import fr.treeptik.cloudunit.model.Application;
import fr.treeptik.cloudunit.model.Status;
import fr.treeptik.cloudunit.model.User;
import fr.treeptik.cloudunit.service.ApplicationService;
import fr.treeptik.cloudunit.service.DockerService;
import fr.treeptik.cloudunit.service.GitlabService;
import fr.treeptik.cloudunit.service.JenkinsService;
import fr.treeptik.cloudunit.utils.AuthentificationUtils;
import fr.treeptik.cloudunit.utils.CheckUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.inject.Inject;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.Serializable;
import java.util.List;
import java.util.Locale;

/**
 * Controler for Script execution coming from CLI Syntax
 */
@Controller
@RequestMapping("/scripting")
public class ScriptingController
        implements Serializable {

    private final Logger logger = LoggerFactory.getLogger(ScriptingController.class);

    @Inject
    private DockerService dockerService;

    @Inject
    private AuthentificationUtils authentificationUtils;

    @RequestMapping(value = "/execute",
            method = RequestMethod.POST)
    public void scriptingExecute(
            @RequestBody ScriptRequestBody scriptRequestBody,
            HttpServletRequest request, HttpServletResponse response)
            throws ServiceException, CheckException, IOException {
        System.out.println("########################################");
        System.out.println(scriptRequestBody);
        System.out.println("#################################");
        if (logger.isDebugEnabled()) {
            logger.debug("scriptRequestBody: " + scriptRequestBody);
        }
    }
}

@@ -2230,16 +2230,41 @@
 .Locale;
+%0Aimport java.util.Random;
 %0A%0A/**%0A *
@@ -2643,16 +2643,523 @@
 Utils;%0A%0A
+%0A    @RequestMapping(value = %22/execute%22,%0A            method = RequestMethod.GET)%0A    public JsonResponse scriptingExecute(%0A            HttpServletRequest request, HttpServletResponse response)%0A            throws ServiceException, CheckException, IOException, InterruptedException %7B%0A        Random random = new Random();%0A        int i = random.nextInt(5);%0A        Thread.sleep(2000);%0A        if((i %25 5 )== 0) %7B%0A            return new HttpOk();%0A        %7D%0A%0A        return new HttpErrorServer(%22erreur%22);%0A    %7D%0A%0A
     @Req
@@ -3453,34 +3453,85 @@
 ion, IOException
- %7B
+, InterruptedException %7B%0A        Thread.sleep(12000);
 %0A        System.

Add GET route in ScriptingController