Search in sources :

Example 21 with CerberusException

use of org.cerberus.exception.CerberusException in project cerberus-source by cerberustesting.

the class CreateBuildRevisionInvariant method processRequest.

/**
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
 * methods.
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 * @throws org.cerberus.exception.CerberusException
 * @throws org.json.JSONException
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, CerberusException, JSONException {
    JSONObject jsonResponse = new JSONObject();
    Answer ans = new Answer();
    MessageEvent msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);
    msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", ""));
    ans.setResultMessage(msg);
    PolicyFactory policy = Sanitizers.FORMATTING.and(Sanitizers.LINKS);
    String charset = request.getCharacterEncoding();
    response.setContentType("application/json");
    // Calling Servlet Transversal Util.
    ServletUtil.servletStart(request);
    /**
     * Parsing and securing all required parameters.
     */
    // Parameter that are already controled by GUI (no need to decode) --> We SECURE them
    Integer seq = -1;
    boolean seq_error = false;
    try {
        if (request.getParameter("seq") != null && !request.getParameter("seq").equals("")) {
            seq = Integer.valueOf(policy.sanitize(request.getParameter("seq")));
        }
    } catch (Exception ex) {
        seq_error = true;
    }
    Integer level = -1;
    boolean level_error = false;
    try {
        if (request.getParameter("level") != null && !request.getParameter("level").equals("")) {
            level = Integer.valueOf(policy.sanitize(request.getParameter("level")));
        }
    } catch (Exception ex) {
        level_error = true;
    }
    // Parameter that needs to be secured --> We SECURE+DECODE them
    String system = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("system"), "", charset);
    String versionName = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("versionname"), "", charset);
    /**
     * Checking all constrains before calling the services.
     */
    if (StringUtil.isNullOrEmpty(system)) {
        msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_EXPECTED);
        msg.setDescription(msg.getDescription().replace("%ITEM%", "BuildRevisionInvariant").replace("%OPERATION%", "Create").replace("%REASON%", "System name is missing!"));
        ans.setResultMessage(msg);
    } else if (level_error) {
        msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_EXPECTED);
        msg.setDescription(msg.getDescription().replace("%ITEM%", "BuildRevisionInvariant").replace("%OPERATION%", "Create").replace("%REASON%", "Could not manage to convert level to an integer value!"));
        ans.setResultMessage(msg);
    } else if (seq_error) {
        msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_EXPECTED);
        msg.setDescription(msg.getDescription().replace("%ITEM%", "BuildRevisionInvariant").replace("%OPERATION%", "Create").replace("%REASON%", "Could not manage to convert sequence to an integer value!"));
        ans.setResultMessage(msg);
    } else {
        /**
         * All data seems cleans so we can call the services.
         */
        ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
        IBuildRevisionInvariantService buildRevisionInvariantService = appContext.getBean(IBuildRevisionInvariantService.class);
        IFactoryBuildRevisionInvariant factoryBuildRevisionInvariant = appContext.getBean(IFactoryBuildRevisionInvariant.class);
        BuildRevisionInvariant buildRevisionInvariantData = factoryBuildRevisionInvariant.create(system, level, seq, versionName);
        ans = buildRevisionInvariantService.create(buildRevisionInvariantData);
        if (ans.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode())) {
            /**
             * Object created. Adding Log entry.
             */
            ILogEventService logEventService = appContext.getBean(LogEventService.class);
            logEventService.createForPrivateCalls("/CreateBuildRevisionInvariant", "CREATE", "Create BuildRevisionInvariant : ['" + system + "'|'" + level + "'|'" + seq + "']", request);
        }
    }
    /**
     * Formating and returning the json result.
     */
    jsonResponse.put("messageType", ans.getResultMessage().getMessage().getCodeString());
    jsonResponse.put("message", ans.getResultMessage().getDescription());
    response.getWriter().print(jsonResponse);
    response.getWriter().flush();
}
Also used : PolicyFactory(org.owasp.html.PolicyFactory) MessageEvent(org.cerberus.engine.entity.MessageEvent) IFactoryBuildRevisionInvariant(org.cerberus.crud.factory.IFactoryBuildRevisionInvariant) ServletException(javax.servlet.ServletException) JSONException(org.json.JSONException) IOException(java.io.IOException) CerberusException(org.cerberus.exception.CerberusException) IBuildRevisionInvariantService(org.cerberus.crud.service.IBuildRevisionInvariantService) Answer(org.cerberus.util.answer.Answer) ApplicationContext(org.springframework.context.ApplicationContext) JSONObject(org.json.JSONObject) IFactoryBuildRevisionInvariant(org.cerberus.crud.factory.IFactoryBuildRevisionInvariant) BuildRevisionInvariant(org.cerberus.crud.entity.BuildRevisionInvariant) ILogEventService(org.cerberus.crud.service.ILogEventService)

Example 22 with CerberusException

use of org.cerberus.exception.CerberusException in project cerberus-source by cerberustesting.

the class ReadBuildRevisionInvariant method processRequest.

/**
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
 * methods.
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 * @throws org.cerberus.exception.CerberusException
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, CerberusException {
    String echo = request.getParameter("sEcho");
    ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
    PolicyFactory policy = Sanitizers.FORMATTING.and(Sanitizers.LINKS);
    response.setContentType("application/json");
    response.setCharacterEncoding("utf8");
    // Calling Servlet Transversal Util.
    ServletUtil.servletStart(request);
    // Default message to unexpected error.
    MessageEvent msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);
    msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", ""));
    /**
     * Parsing and securing all required parameters.
     */
    Integer lvlid = -1;
    boolean lvlid_error = true;
    try {
        if (request.getParameter("level") != null && !request.getParameter("level").equals("")) {
            lvlid = Integer.valueOf(policy.sanitize(request.getParameter("level")));
            lvlid_error = false;
        }
    } catch (Exception ex) {
        msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_EXPECTED);
        msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME));
        msg.setDescription(msg.getDescription().replace("%OPERATION%", "Read"));
        msg.setDescription(msg.getDescription().replace("%REASON%", "level must be an integer value."));
        lvlid_error = true;
    }
    Integer seqid = -1;
    boolean seqid_error = true;
    try {
        if (request.getParameter("seq") != null && !request.getParameter("seq").equals("")) {
            seqid = Integer.valueOf(policy.sanitize(request.getParameter("seq")));
            seqid_error = false;
        }
    } catch (Exception ex) {
        msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_EXPECTED);
        msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME));
        msg.setDescription(msg.getDescription().replace("%OPERATION%", "Read"));
        msg.setDescription(msg.getDescription().replace("%REASON%", "id must be an integer value."));
        seqid_error = true;
    }
    String system = policy.sanitize(request.getParameter("system"));
    String columnName = ParameterParserUtil.parseStringParam(request.getParameter("columnName"), "");
    // Global boolean on the servlet that define if the user has permition to edit and delete object.
    boolean userHasPermissions = request.isUserInRole("Integrator");
    // Init Answer with potencial error from Parsing parameter.
    AnswerItem answer = new AnswerItem(msg);
    try {
        JSONObject jsonResponse = new JSONObject();
        if ((request.getParameter("system") != null) && (request.getParameter("level") != null) && !(lvlid_error) && (request.getParameter("seq") != null) && !(seqid_error)) {
            // ID parameter is specified so we return the unique record of object.
            answer = findBuildRevisionInvariantByKey(system, lvlid, seqid, appContext, userHasPermissions);
            jsonResponse = (JSONObject) answer.getItem();
        } else if (!Strings.isNullOrEmpty(columnName)) {
            answer = findDistinctValuesOfColumn(system, appContext, request, columnName);
            jsonResponse = (JSONObject) answer.getItem();
        } else {
            // Default behaviour, we return the list of objects.
            answer = findBuildRevisionInvariantList(system, lvlid, appContext, userHasPermissions, request);
            jsonResponse = (JSONObject) answer.getItem();
        }
        jsonResponse.put("messageType", answer.getResultMessage().getMessage().getCodeString());
        jsonResponse.put("message", answer.getResultMessage().getDescription());
        jsonResponse.put("sEcho", echo);
        response.getWriter().print(jsonResponse.toString());
    } catch (JSONException e) {
        LOG.warn(e);
        // returns a default error message with the json format that is able to be parsed by the client-side
        response.getWriter().print(AnswerUtil.createGenericErrorAnswer());
    }
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) PolicyFactory(org.owasp.html.PolicyFactory) JSONObject(org.json.JSONObject) MessageEvent(org.cerberus.engine.entity.MessageEvent) JSONException(org.json.JSONException) AnswerItem(org.cerberus.util.answer.AnswerItem) ServletException(javax.servlet.ServletException) JSONException(org.json.JSONException) IOException(java.io.IOException) CerberusException(org.cerberus.exception.CerberusException)

Example 23 with CerberusException

use of org.cerberus.exception.CerberusException in project cerberus-source by cerberustesting.

the class UpdateBuildRevisionInvariant method processRequest.

/**
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
 * methods.
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, CerberusException, JSONException {
    JSONObject jsonResponse = new JSONObject();
    Answer ans = new Answer();
    MessageEvent msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);
    msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", ""));
    ans.setResultMessage(msg);
    PolicyFactory policy = Sanitizers.FORMATTING.and(Sanitizers.LINKS);
    String charset = request.getCharacterEncoding();
    response.setContentType("application/json");
    // Calling Servlet Transversal Util.
    ServletUtil.servletStart(request);
    /**
     * Parsing and securing all required parameters.
     */
    // Parameter that are already controled by GUI (no need to decode) --> We SECURE them
    Integer seq = -1;
    boolean seq_error = false;
    try {
        if (request.getParameter("seq") != null && !request.getParameter("seq").equals("")) {
            seq = Integer.valueOf(policy.sanitize(request.getParameter("seq")));
        }
    } catch (Exception ex) {
        seq_error = true;
    }
    Integer level = -1;
    boolean level_error = false;
    try {
        if (request.getParameter("level") != null && !request.getParameter("level").equals("")) {
            level = Integer.valueOf(policy.sanitize(request.getParameter("level")));
        }
    } catch (Exception ex) {
        level_error = true;
    }
    // Parameter that needs to be secured --> We SECURE+DECODE them
    String system = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("system"), "", charset);
    String versionName = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("versionname"), "", charset);
    /**
     * Checking all constrains before calling the services.
     */
    if (StringUtil.isNullOrEmpty(system)) {
        msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_EXPECTED);
        msg.setDescription(msg.getDescription().replace("%ITEM%", "BuildRevisionInvariant").replace("%OPERATION%", "Update").replace("%REASON%", "System name is missing!"));
        ans.setResultMessage(msg);
    } else if (level_error) {
        msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_EXPECTED);
        msg.setDescription(msg.getDescription().replace("%ITEM%", "BuildRevisionInvariant").replace("%OPERATION%", "Update").replace("%REASON%", "Could not manage to convert level to an integer value!"));
        ans.setResultMessage(msg);
    } else if (seq_error) {
        msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_EXPECTED);
        msg.setDescription(msg.getDescription().replace("%ITEM%", "BuildRevisionInvariant").replace("%OPERATION%", "Update").replace("%REASON%", "Could not manage to convert sequence to an integer value!"));
        ans.setResultMessage(msg);
    } else {
        /**
         * All data seems cleans so we can call the services.
         */
        ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
        IBuildRevisionInvariantService buildRevisionInvariantService = appContext.getBean(IBuildRevisionInvariantService.class);
        AnswerItem resp = buildRevisionInvariantService.readByKey(system, level, seq);
        if (!(resp.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode()) && resp.getItem() != null)) {
            /**
             * Object could not be found. We stop here and report the error.
             */
            msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_EXPECTED);
            msg.setDescription(msg.getDescription().replace("%ITEM%", "BuildRevisionInvariant").replace("%OPERATION%", "Update").replace("%REASON%", "BuildRevisionInvariant does not exist."));
            ans.setResultMessage(msg);
        } else {
            /**
             * The service was able to perform the query and confirm the
             * object exist, then we can update it.
             */
            BuildRevisionInvariant buildRevisionInvariantData = (BuildRevisionInvariant) resp.getItem();
            buildRevisionInvariantData.setSystem(system);
            buildRevisionInvariantData.setLevel(level);
            buildRevisionInvariantData.setSeq(seq);
            buildRevisionInvariantData.setVersionName(versionName);
            ans = buildRevisionInvariantService.update(buildRevisionInvariantData.getSystem(), buildRevisionInvariantData.getLevel(), buildRevisionInvariantData.getSeq(), buildRevisionInvariantData);
            if (ans.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode())) {
                /**
                 * Update was successful. Adding Log entry.
                 */
                ILogEventService logEventService = appContext.getBean(LogEventService.class);
                logEventService.createForPrivateCalls("/UpdateBuildRevisionInvariant", "UPDATE", "Updated BuildRevisionInvariant : ['" + system + "'|'" + level + "'|'" + seq + "']", request);
            }
        }
    }
    /**
     * Formating and returning the json result.
     */
    jsonResponse.put("messageType", ans.getResultMessage().getMessage().getCodeString());
    jsonResponse.put("message", ans.getResultMessage().getDescription());
    response.getWriter().print(jsonResponse);
    response.getWriter().flush();
}
Also used : PolicyFactory(org.owasp.html.PolicyFactory) MessageEvent(org.cerberus.engine.entity.MessageEvent) AnswerItem(org.cerberus.util.answer.AnswerItem) ServletException(javax.servlet.ServletException) JSONException(org.json.JSONException) IOException(java.io.IOException) CerberusException(org.cerberus.exception.CerberusException) IBuildRevisionInvariantService(org.cerberus.crud.service.IBuildRevisionInvariantService) Answer(org.cerberus.util.answer.Answer) ApplicationContext(org.springframework.context.ApplicationContext) JSONObject(org.json.JSONObject) BuildRevisionInvariant(org.cerberus.crud.entity.BuildRevisionInvariant) ILogEventService(org.cerberus.crud.service.ILogEventService)

Example 24 with CerberusException

use of org.cerberus.exception.CerberusException in project cerberus-source by cerberustesting.

the class ExecutionThreadPoolService method executeNextInQueue.

/**
 * {@inheritDoc}
 */
@Override
public void executeNextInQueue(boolean forceExecution) throws CerberusException {
    // Job can be desactivated by parameter.
    if (!(parameterService.getParameterBooleanByKey("cerberus_queueexecution_enable", "", true))) {
        LOG.debug("Queue_Processing_Job disabled by parameter : 'cerberus_queueexecution_enable'.");
        return;
    }
    // We first check that another thread of Cerberus already trigger the job. Only 1 instance of the job is necessary.
    if (!(myVersionService.getMyVersionStringByKey("queueprocessingjobrunning", "N").equals("Y")) || forceExecution) {
        if (forceExecution) {
            LOG.debug("Forcing Start of Queue_Processing_Job.");
        }
        int nbqueuedexe = 0;
        do {
            if (!(parameterService.getParameterBooleanByKey("cerberus_queueexecution_enable", "", true))) {
                LOG.debug("Queue_Processing_Job disabled by parameter : 'cerberus_queueexecution_enable'.");
                return;
            }
            nbqueuedexe = 0;
            // Job is not already running, we can trigger it.
            LOG.debug("Starting Queue_Processing_Job.");
            // Flag in database that job is already running.
            myVersionService.UpdateMyVersionString("queueprocessingjobrunning", "Y");
            myVersionService.UpdateMyVersionString("queueprocessingjobstart", String.valueOf(new Date()));
            String cerberus_url = parameterService.getParameterStringByKey("cerberus_url", "", "");
            // Getting all executions to be treated.
            AnswerList answer = new AnswerList();
            answer = tceiqService.readQueueToTreat();
            List<TestCaseExecutionQueueToTreat> executionsInQueue = (List<TestCaseExecutionQueueToTreat>) answer.getDataList();
            int poolSizeGeneral = parameterService.getParameterIntegerByKey("cerberus_queueexecution_global_threadpoolsize", "", 12);
            int poolSizeRobot = parameterService.getParameterIntegerByKey("cerberus_queueexecution_defaultrobothost_threadpoolsize", "", 10);
            int queueTimeout = parameterService.getParameterIntegerByKey("cerberus_queueexecution_timeout", "", 600000);
            // Init constrain counter.
            int const01_current = 0;
            int const02_current = 0;
            int const03_current = 0;
            HashMap<String, Integer> constrains_current = new HashMap<String, Integer>();
            constrains_current = getCurrentlyRunning();
            // Getting RobotHost PoolSize
            HashMap<String, Integer> robot_poolsize = new HashMap<String, Integer>();
            robot_poolsize = invariantService.readToHashMapGp1IntegerByIdname("ROBOTHOST", poolSizeRobot);
            // Analysing each execution in the database queue.
            for (TestCaseExecutionQueueToTreat exe : executionsInQueue) {
                // Robot PoolSize if retreived from hashmap.
                int robot_poolsize_final = 0;
                if (robot_poolsize.containsKey(exe.getRobotHost())) {
                    robot_poolsize_final = ParameterParserUtil.parseIntegerParam(robot_poolsize.get(exe.getRobotHost()), poolSizeRobot);
                } else {
                    robot_poolsize_final = 0;
                }
                LOG.debug("Analysing Queue : " + exe.getId() + " poolGen " + poolSizeGeneral + " poolApp " + exe.getPoolSizeApplication() + " poolRobot " + robot_poolsize_final);
                String const01_key = TestCaseExecutionQueueToTreat.CONSTRAIN1_GLOBAL;
                String const02_key = TestCaseExecutionQueueToTreat.CONSTRAIN2_APPLICATION + CONST_SEPARATOR + exe.getSystem() + CONST_SEPARATOR + exe.getEnvironment() + CONST_SEPARATOR + exe.getCountry() + CONST_SEPARATOR + exe.getApplication();
                String const03_key = TestCaseExecutionQueueToTreat.CONSTRAIN3_ROBOT + CONST_SEPARATOR + exe.getRobotHost();
                // Eval Constrain 1
                if (constrains_current.containsKey(const01_key)) {
                    const01_current = constrains_current.get(const01_key);
                } else {
                    const01_current = 0;
                }
                // Eval Constrain 1
                boolean constMatch01;
                if (poolSizeGeneral == 0) {
                    // if poolsize == 0, this means no constrain specified.
                    constMatch01 = false;
                } else {
                    constMatch01 = (const01_current >= poolSizeGeneral);
                }
                // Eval Constrain 2
                if (constrains_current.containsKey(const02_key)) {
                    const02_current = constrains_current.get(const02_key);
                } else {
                    const02_current = 0;
                }
                // Eval Constrain 2
                boolean constMatch02;
                if (exe.getPoolSizeApplication() == 0) {
                    // if poolsize == 0, this means no constrain specified.
                    constMatch02 = false;
                } else {
                    constMatch02 = (const02_current >= exe.getPoolSizeApplication());
                }
                // Eval Constrain 3
                if (constrains_current.containsKey(const03_key)) {
                    const03_current = constrains_current.get(const03_key);
                } else {
                    const03_current = 0;
                }
                // Eval Constrain 3
                boolean constMatch03;
                if (robot_poolsize_final == 0) {
                    // if poolsize == 0, this means no constrain specified.
                    constMatch03 = false;
                } else {
                    constMatch03 = (const03_current >= robot_poolsize_final);
                }
                String notTriggeredExeMessage = "";
                boolean triggerExe = false;
                if ((!constMatch01 && !constMatch02 && !constMatch03) || (!constMatch01 && exe.getManualExecution().equals("Y"))) {
                    // Adding execution to queue.
                    if (queueService.updateToWaiting(exe.getId())) {
                        try {
                            ExecutionQueueWorkerThread task = new ExecutionQueueWorkerThread();
                            task.setCerberusExecutionUrl(cerberus_url);
                            task.setQueueId(exe.getId());
                            task.setToExecuteTimeout(queueTimeout);
                            task.setQueueService(queueService);
                            task.setExecThreadPool(threadQueuePool);
                            Future<?> future = threadQueuePool.getExecutor().submit(task);
                            task.setFuture(future);
                            triggerExe = true;
                            nbqueuedexe++;
                            // Debug messages.
                            LOG.debug("result : " + triggerExe + " Const1 " + constMatch01 + " Const2 " + constMatch01 + " Const3 " + constMatch01 + " Manual " + exe.getManualExecution());
                            LOG.debug(" CurConst1 " + const01_current + " CurConst2 " + const02_current + " CurConst3 " + const03_current);
                            // Counter increase
                            constrains_current.put(const01_key, const01_current + 1);
                            if (!exe.getManualExecution().equals("Y")) {
                                // Specific increment only if automatic execution.
                                constrains_current.put(const02_key, const02_current + 1);
                                constrains_current.put(const03_key, const03_current + 1);
                            }
                        } catch (Exception e) {
                            LOG.error("Failed to add Queueid : " + exe.getId() + " into the queue : " + e.getMessage());
                        }
                    }
                } else {
                    if (constMatch03) {
                        notTriggeredExeMessage = "Robot contrain on '" + const03_key + "' reached. " + robot_poolsize_final + " Execution(s) already in pool.";
                    }
                    if (constMatch02) {
                        notTriggeredExeMessage = "Application Environment contrain on '" + const02_key + "' reached . " + exe.getPoolSizeApplication() + " Execution(s) already in pool.";
                    }
                    if (constMatch01) {
                        notTriggeredExeMessage = "Global contrain reached. " + poolSizeGeneral + " Execution(s) already in pool.";
                    }
                    if ((exe.getDebugFlag() != null) && (exe.getDebugFlag().equalsIgnoreCase("Y"))) {
                        queueService.updateComment(exe.getId(), notTriggeredExeMessage);
                    }
                    LOG.debug("result : " + triggerExe + " Const1 " + constMatch01 + " Const2 " + constMatch01 + " Const3 " + constMatch01 + " Manual " + exe.getManualExecution());
                    LOG.debug(" CurConst1 " + const01_current + " CurConst2 " + const02_current + " CurConst3 " + const03_current);
                    LOG.debug(" " + notTriggeredExeMessage);
                }
            }
            // Flag in database that job is finished.
            myVersionService.UpdateMyVersionString("queueprocessingjobrunning", "N");
            LOG.debug("Stoping Queue_Processing_Job - TOTAL Released execution(s) : " + nbqueuedexe);
        } while (nbqueuedexe > 0);
    } else {
        LOG.debug("Queue_Processing_Job not triggered (already running.)");
    }
}
Also used : AnswerList(org.cerberus.util.answer.AnswerList) HashMap(java.util.HashMap) Date(java.util.Date) CerberusException(org.cerberus.exception.CerberusException) AnswerList(org.cerberus.util.answer.AnswerList) List(java.util.List) TestCaseExecutionQueueToTreat(org.cerberus.engine.threadpool.entity.TestCaseExecutionQueueToTreat)

Example 25 with CerberusException

use of org.cerberus.exception.CerberusException in project cerberus-source by cerberustesting.

the class GetConnectionPoolName method processRequest.

/**
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
 * methods.
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");
    PrintWriter out = response.getWriter();
    try {
        String system = ParameterParserUtil.parseStringParam(request.getParameter("system"), "");
        String country = ParameterParserUtil.parseStringParam(request.getParameter("country"), "");
        String environment = ParameterParserUtil.parseStringParam(request.getParameter("environment"), "");
        String database = ParameterParserUtil.parseStringParam(request.getParameter("database"), "");
        ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
        ICountryEnvironmentDatabaseService cedService = appContext.getBean(ICountryEnvironmentDatabaseService.class);
        String result = "";
        try {
            result = cedService.convert(cedService.readByKey(system, country, environment, database)).getConnectionPoolName();
        } catch (CerberusException ex) {
            LOG.warn(ex);
        }
        out.print(result);
    } finally {
        out.close();
    }
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) CerberusException(org.cerberus.exception.CerberusException) ICountryEnvironmentDatabaseService(org.cerberus.crud.service.ICountryEnvironmentDatabaseService) PrintWriter(java.io.PrintWriter)

Aggregations

CerberusException (org.cerberus.exception.CerberusException)159 MessageEvent (org.cerberus.engine.entity.MessageEvent)64 MessageGeneral (org.cerberus.engine.entity.MessageGeneral)58 ApplicationContext (org.springframework.context.ApplicationContext)58 JSONObject (org.json.JSONObject)54 JSONException (org.json.JSONException)53 Connection (java.sql.Connection)48 SQLException (java.sql.SQLException)48 PreparedStatement (java.sql.PreparedStatement)47 AnswerItem (org.cerberus.util.answer.AnswerItem)41 ArrayList (java.util.ArrayList)37 IOException (java.io.IOException)35 PolicyFactory (org.owasp.html.PolicyFactory)35 ILogEventService (org.cerberus.crud.service.ILogEventService)34 Answer (org.cerberus.util.answer.Answer)34 ServletException (javax.servlet.ServletException)26 ResultSet (java.sql.ResultSet)18 TestCase (org.cerberus.crud.entity.TestCase)16 JSONArray (org.json.JSONArray)16 HashMap (java.util.HashMap)12