How to use processRequest method of org.cerberus.servlet.zzpublic.DisableEnvironmentV000 class

Best Cerberus-source code snippet using org.cerberus.servlet.zzpublic.DisableEnvironmentV000.processRequest

Source:DisableEnvironmentV000.java Github

copy

Full Screen

...60 * @param response servlet response61 * @throws ServletException if a servlet-specific error occurs62 * @throws IOException if an I/O error occurs63 */64 protected void processRequest(HttpServletRequest request, HttpServletResponse response)65 throws ServletException, IOException {66 PrintWriter out = response.getWriter();67 String charset = request.getCharacterEncoding();68 // Loading Services.69 ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());70 ICountryEnvParamService countryEnvParamService = appContext.getBean(ICountryEnvParamService.class);71 IInvariantService invariantService = appContext.getBean(IInvariantService.class);72 IBuildRevisionInvariantService buildRevisionInvariantService = appContext.getBean(IBuildRevisionInvariantService.class);73 IEmailService emailService = appContext.getBean(IEmailService.class);74 ICountryEnvParam_logService countryEnvParam_logService = appContext.getBean(ICountryEnvParam_logService.class);75 IParameterService parameterService = appContext.getBean(IParameterService.class);76 // Calling Servlet Transversal Util.77 ServletUtil.servletStart(request);78 /**79 * Adding Log entry.80 */81 ILogEventService logEventService = appContext.getBean(ILogEventService.class);82 logEventService.createForPublicCalls("/DisableEnvironmentV000", "CALL", "DisableEnvironmentV000 called : " + request.getRequestURL(), request);83 // Parsing all parameters.84 String system = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("system"), "", charset);85 String country = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("country"), "", charset);86 String environment = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("environment"), "", charset);87 // Defining help message.88 String helpMessage = "\nThis servlet is used to inform Cerberus that a system is disabled. For example when a Revision is beeing deployed.\n\nParameter list :\n"89 + "- system [mandatory] : the system where the Build Revision has been deployed. [" + system + "]\n"90 + "- country [mandatory] : the country where the Build Revision has been deployed. You can use ALL if you want to perform the action for all countries that exist for the given system and environement. [" + country + "]\n"91 + "- environment [mandatory] : the environment where the Build Revision has been deployed. [" + environment + "]\n";92 // Checking the parameter validity.93 boolean error = false;94 if (system.equalsIgnoreCase("")) {95 out.println("Error - Parameter system is mandatory.");96 error = true;97 }98 if (!system.equalsIgnoreCase("") && !invariantService.isInvariantExist("SYSTEM", system)) {99 out.println("Error - System does not exist : " + system);100 error = true;101 }102 if (environment.equalsIgnoreCase("")) {103 out.println("Error - Parameter environment is mandatory.");104 error = true;105 }106 if (!environment.equalsIgnoreCase("") && !invariantService.isInvariantExist("ENVIRONMENT", environment)) {107 out.println("Error - Environment does not exist : " + environment);108 error = true;109 }110 if (country.equalsIgnoreCase("")) {111 out.println("Error - Parameter country is mandatory.");112 error = true;113 } else if (!country.equalsIgnoreCase(PARAMETERALL)) {114 if (!invariantService.isInvariantExist("COUNTRY", country)) {115 out.println("Error - Country does not exist : " + country);116 error = true;117 }118 if (!error) {119 if (!countryEnvParamService.exist(system, country, environment)) {120 out.println("Error - System/Country/Environment does not exist : " + system + "/" + country + "/" + environment);121 error = true;122 }123 }124 }125 // Starting the database update only when no blocking error has been detected.126 if (error == false) {127 /**128 * Getting the list of objects to treat.129 */130 MessageEvent msg = new MessageEvent(MessageEventEnum.GENERIC_OK);131 Answer finalAnswer = new Answer(msg);132 AnswerList answerList = new AnswerList();133 if (country.equalsIgnoreCase(PARAMETERALL)) {134 country = null;135 }136 answerList = countryEnvParamService.readByVarious(system, country, environment, null, null, null);137 finalAnswer = AnswerUtil.agregateAnswer(finalAnswer, (Answer) answerList);138 for (CountryEnvParam cepData : (List<CountryEnvParam>) answerList.getDataList()) {139 /**140 * For each object, we can update it.141 */142 cepData.setActive(false);143 Answer answerUpdate = countryEnvParamService.update(cepData);144 if (!(answerUpdate.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode()))) {145 /**146 * Object could not be updated. We stop here and report the147 * error.148 */149 finalAnswer = AnswerUtil.agregateAnswer(finalAnswer, answerUpdate);150 } else {151 /**152 * Update was successful.153 */154 // Adding Log entry.155 logEventService.createForPrivateCalls("/DisableEnvironmentV000", "UPDATE", "Updated CountryEnvParam : ['" + cepData.getSystem() + "','" + cepData.getCountry() + "','" + cepData.getEnvironment() + "']", request);156 // Adding CountryEnvParam Log entry.157 countryEnvParam_logService.createLogEntry(cepData.getSystem(), cepData.getCountry(), cepData.getEnvironment(), "", "", "Disabled.", "PublicCall");158 /**159 * Email notification.160 */161 // Email Calculation.162 String eMailContent;163 String OutputMessage = "";164 MessageEvent me = emailService.generateAndSendDisableEnvEmail(cepData.getSystem(), cepData.getCountry(), cepData.getEnvironment());165 if (!"OK".equals(me.getMessage().getCodeString())) {166 LOG.warn(Infos.getInstance().getProjectNameAndVersion() + " - Exception catched." + me.getMessage().getDescription());167 logEventService.createForPrivateCalls("/DisableEnvironmentV000", "DISABLE", "Warning on Disable environment : ['" + cepData.getSystem() + "','" + cepData.getCountry() + "','" + cepData.getEnvironment() + "'] " + me.getMessage().getDescription(), request);168 OutputMessage = me.getMessage().getDescription();169 }170 if (OutputMessage.equals("")) {171 msg = new MessageEvent(MessageEventEnum.GENERIC_OK);172 Answer answerSMTP = new AnswerList(msg);173 finalAnswer = AnswerUtil.agregateAnswer(finalAnswer, answerSMTP);174 } else {175 msg = new MessageEvent(MessageEventEnum.GENERIC_WARNING);176 msg.setDescription(msg.getDescription().replace("%REASON%", OutputMessage + " when sending email for " + cepData.getSystem() + "/" + cepData.getCountry() + "/" + cepData.getEnvironment()));177 Answer answerSMTP = new AnswerList(msg);178 finalAnswer = AnswerUtil.agregateAnswer(finalAnswer, answerSMTP);179 }180 }181 }182 /**183 * Formating and returning the result.184 */185 out.println(finalAnswer.getResultMessage().getMessage().getCodeString() + " - " + finalAnswer.getResultMessage().getDescription());186 } else {187 // In case of errors, we display the help message.188 out.println(helpMessage);189 }190 }191 // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">192 /**193 * Handles the HTTP <code>GET</code> method.194 *195 * @param request servlet request196 * @param response servlet response197 * @throws ServletException if a servlet-specific error occurs198 * @throws IOException if an I/O error occurs199 */200 @Override201 protected void doGet(HttpServletRequest request, HttpServletResponse response)202 throws ServletException, IOException {203 processRequest(request, response);204 }205 /**206 * Handles the HTTP <code>POST</code> method.207 *208 * @param request servlet request209 * @param response servlet response210 * @throws ServletException if a servlet-specific error occurs211 * @throws IOException if an I/O error occurs212 */213 @Override214 protected void doPost(HttpServletRequest request, HttpServletResponse response)215 throws ServletException, IOException {216 processRequest(request, response);217 }218 /**219 * Returns a short description of the servlet.220 *221 * @return a String containing servlet description222 */223 @Override224 public String getServletInfo() {225 return "Short description";226 }// </editor-fold>227}...

Full Screen

Full Screen

processRequest

Using AI Code Generation

copy

Full Screen

1import org.cerberus.servlet.zzpublic.DisableEnvironmentV000;2DisableEnvironmentV000 disableEnvironment = new DisableEnvironmentV000();3disableEnvironment.processRequest(request, response);4import org.cerberus.servlet.zzpublic.DisableEnvironmentV000;5DisableEnvironmentV000 disableEnvironment = new DisableEnvironmentV000();6disableEnvironment.processRequest(request, response);7import org.cerberus.servlet.zzpublic.DisableEnvironmentV000;8DisableEnvironmentV000 disableEnvironment = new DisableEnvironmentV000();9disableEnvironment.processRequest(request, response);10import org.cerberus.servlet.zzpublic.DisableEnvironmentV000;11DisableEnvironmentV000 disableEnvironment = new DisableEnvironmentV000();12disableEnvironment.processRequest(request, response);13import org.cerberus.servlet.zzpublic.DisableEnvironmentV000;14DisableEnvironmentV000 disableEnvironment = new DisableEnvironmentV000();15disableEnvironment.processRequest(request, response);16import org.cerberus.servlet.zzpublic.DisableEnvironmentV000;17DisableEnvironmentV000 disableEnvironment = new DisableEnvironmentV000();18disableEnvironment.processRequest(request, response);19import org.cerberus.servlet.zzpublic.DisableEnvironmentV000;20DisableEnvironmentV000 disableEnvironment = new DisableEnvironmentV000();21disableEnvironment.processRequest(request, response);22import org.cerberus.servlet.zzpublic.DisableEnvironmentV000;23DisableEnvironmentV000 disableEnvironment = new DisableEnvironmentV000();24disableEnvironment.processRequest(request, response);25import org.cerberus.servlet.zzpublic.DisableEnvironmentV000;

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Cerberus-source automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in DisableEnvironmentV000

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful