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

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

Source:NewBuildRevisionV000.java Github

copy

Full Screen

...61 * @param response servlet response62 * @throws ServletException if a servlet-specific error occurs63 * @throws IOException if an I/O error occurs64 */65 protected void processRequest(HttpServletRequest request, HttpServletResponse response)66 throws ServletException, IOException {67 PrintWriter out = response.getWriter();68 String charset = request.getCharacterEncoding();69 ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());70 /**71 * Adding Log entry.72 */73 ILogEventService logEventService = appContext.getBean(ILogEventService.class);74 logEventService.createForPublicCalls("/NewBuildRevisionV000", "CALL", "NewBuildRevisionV000 called : " + request.getRequestURL(), request);75 ICountryEnvParamService countryEnvParamService = appContext.getBean(ICountryEnvParamService.class);76 IInvariantService invariantService = appContext.getBean(IInvariantService.class);77 IBuildRevisionInvariantService buildRevisionInvariantService = appContext.getBean(IBuildRevisionInvariantService.class);78 IEmailService emailService = appContext.getBean(IEmailService.class);79 IEmailGenerationService emailGenerationService = appContext.getBean(IEmailGenerationService.class);80 ICountryEnvParam_logService countryEnvParam_logService = appContext.getBean(ICountryEnvParam_logService.class);81 IParameterService parameterService = appContext.getBean(IParameterService.class);82 // Parsing all parameters.83 String system = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("system"), "", charset);84 String country = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("country"), "", charset);85 String environment = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("environment"), "", charset);86 String build = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("build"), "", charset);87 String revision = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("revision"), "", charset);88 String helpMessage = "\nThis servlet is used to inform Cerberus that a new Build and Revision has been deployed on a system.\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 + "- build [mandatory] : the build that has been deployed. [" + build + "]\n"93 + "- revision [mandatory] : the revision that has been deployed. [" + revision + "]\n";94 boolean error = false;95 // Checking the parameter validity. If application has been entered, does it exist ?96 if (system.equalsIgnoreCase("")) {97 out.println("Error - Parameter system is mandatory.");98 error = true;99 }100 if (!system.equalsIgnoreCase("") && !invariantService.isInvariantExist("SYSTEM", system)) {101 out.println("Error - System does not exist : " + system);102 error = true;103 }104 if (environment.equalsIgnoreCase("")) {105 out.println("Error - Parameter environment is mandatory.");106 error = true;107 }108 if (!environment.equalsIgnoreCase("") && !invariantService.isInvariantExist("ENVIRONMENT", environment)) {109 out.println("Error - Environment does not exist : " + environment);110 error = true;111 }112 if (country.equalsIgnoreCase("")) {113 out.println("Error - Parameter country is mandatory.");114 error = true;115 } else if (!country.equalsIgnoreCase(PARAMETERALL)) {116 if (!invariantService.isInvariantExist("COUNTRY", country)) {117 out.println("Error - Country does not exist : " + country);118 error = true;119 }120 if (!error) {121 if (!countryEnvParamService.exist(system, country, environment)) {122 out.println("Error - System/Country/Environment does not exist : " + system + "/" + country + "/" + environment);123 error = true;124 }125 }126 }127 if (build.equalsIgnoreCase("")) {128 out.println("Error - Parameter build is mandatory.");129 error = true;130 }131 if (!build.equalsIgnoreCase("") && !buildRevisionInvariantService.exist(system, 1, build)) {132 out.println("Error - Build does not exist : " + build);133 error = true;134 }135 if (revision.equalsIgnoreCase("")) {136 out.println("Error - Parameter revision is mandatory.");137 error = true;138 }139 if (!revision.equalsIgnoreCase("") && !buildRevisionInvariantService.exist(system, 2, revision)) {140 out.println("Error - Revision does not exist : " + revision);141 error = true;142 }143 // Starting the database update only when no blocking error has been detected.144 if (error == false) {145 /**146 * Getting the list of objects to treat.147 */148 // We update the object.149 MessageEvent msg = new MessageEvent(MessageEventEnum.GENERIC_OK);150 Answer finalAnswer = new Answer(msg);151 AnswerList answerList = new AnswerList();152 if (country.equalsIgnoreCase(PARAMETERALL)) {153 country = null;154 }155 answerList = countryEnvParamService.readByVarious(system, country, environment, null, null, null);156 finalAnswer = AnswerUtil.agregateAnswer(finalAnswer, (Answer) answerList);157 for (CountryEnvParam cepData : (List<CountryEnvParam>) answerList.getDataList()) {158 // Email Calculation. Email must be calcuated before we update the Build and revision in order to have the old build revision still available in the mail.159 String OutputMessage = "";160 Email email = null;161 try {162 email = emailGenerationService.generateRevisionChangeEmail(cepData.getSystem(), cepData.getCountry(), cepData.getEnvironment(), build, revision);163 } catch (Exception ex) {164 LOG.warn(Infos.getInstance().getProjectNameAndVersion() + " - Exception catched.", ex);165 logEventService.createForPrivateCalls("/NewBuildRevisionV000", "NEWBUILDREV", "Warning on New Build/Revision environment : ['" + cepData.getSystem() + "','" + cepData.getCountry() + "','" + cepData.getEnvironment() + "'] " + ex.getMessage(), request);166 OutputMessage = ex.getMessage();167 }168 /**169 * For each object, we can update it.170 */171 cepData.setBuild(build);172 cepData.setRevision(revision);173 cepData.setActive(true);174 Answer answerUpdate = countryEnvParamService.update(cepData);175 if (!(answerUpdate.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode()))) {176 /**177 * Object could not be updated. We stop here and report the178 * error.179 */180 finalAnswer = AnswerUtil.agregateAnswer(finalAnswer, answerUpdate);181 } else {182 /**183 * Update was successful.184 */185 // Adding Log entry.186 logEventService.createForPrivateCalls("/NewBuildRevisionV000", "UPDATE", "Updated CountryEnvParam : ['" + cepData.getSystem() + "','" + cepData.getCountry() + "','" + cepData.getEnvironment() + "']", request);187 // Adding CountryEnvParam Log entry.188 countryEnvParam_logService.createLogEntry(cepData.getSystem(), cepData.getCountry(), cepData.getEnvironment(), build, revision, "New Build Revision.", "PublicCall");189 /**190 * Email notification.191 */192 try {193 //Sending the email194 emailService.sendHtmlMail(email);195 } catch (Exception e) {196 LOG.warn(Infos.getInstance().getProjectNameAndVersion() + " - Exception catched.", e);197 logEventService.createForPrivateCalls("/NewBuildRevisionV000", "NEWBUILDREV", "Warning on New Build/Revision environment : ['" + cepData.getSystem() + "','" + cepData.getCountry() + "','" + cepData.getEnvironment() + "'] " + e.getMessage(), request);198 OutputMessage = e.getMessage();199 }200 if (OutputMessage.equals("")) {201 msg = new MessageEvent(MessageEventEnum.GENERIC_OK);202 Answer answerSMTP = new AnswerList(msg);203 finalAnswer = AnswerUtil.agregateAnswer(finalAnswer, answerSMTP);204 } else {205 msg = new MessageEvent(MessageEventEnum.GENERIC_WARNING);206 msg.setDescription(msg.getDescription().replace("%REASON%", OutputMessage + " when sending email for " + cepData.getSystem() + "/" + cepData.getCountry() + "/" + cepData.getEnvironment()));207 Answer answerSMTP = new AnswerList(msg);208 finalAnswer = AnswerUtil.agregateAnswer(finalAnswer, answerSMTP);209 }210 }211 }212 /**213 * Formating and returning the result.214 */215 out.println(finalAnswer.getResultMessage().getMessage().getCodeString() + " - " + finalAnswer.getResultMessage().getDescription());216 } else {217 // In case of errors, we display the help message.218 out.println(helpMessage);219 }220 }221 // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">222 /**223 * Handles the HTTP <code>GET</code> method.224 *225 * @param request servlet request226 * @param response servlet response227 * @throws ServletException if a servlet-specific error occurs228 * @throws IOException if an I/O error occurs229 */230 @Override231 protected void doGet(HttpServletRequest request, HttpServletResponse response)232 throws ServletException, IOException {233 processRequest(request, response);234 }235 /**236 * Handles the HTTP <code>POST</code> method.237 *238 * @param request servlet request239 * @param response servlet response240 * @throws ServletException if a servlet-specific error occurs241 * @throws IOException if an I/O error occurs242 */243 @Override244 protected void doPost(HttpServletRequest request, HttpServletResponse response)245 throws ServletException, IOException {246 processRequest(request, response);247 }248 /**249 * Returns a short description of the servlet.250 *251 * @return a String containing servlet description252 */253 @Override254 public String getServletInfo() {255 return "Short description";256 }// </editor-fold>257}...

Full Screen

Full Screen

processRequest

Using AI Code Generation

copy

Full Screen

1[INFO] [talledLocalContainer] 2017-12-05 15:45:07,947 [http-nio-8080-exec-2] INFO o.c.s.zzpublic.NewBuildRevisionV000 - processRequest() - START2[INFO] [talledLocalContainer] 2017-12-05 15:45:08,001 [http-nio-8080-exec-2] INFO o.c.s.zzpublic.NewBuildRevisionV000 - processRequest() - END3[INFO] [talledLocalContainer] 2017-12-05 15:45:08,002 [http-nio-8080-exec-2] INFO o.c.s.zzpublic.NewBuildRevisionV000 - processRequest() - END4[INFO] [talledLocalContainer] 2017-12-05 15:45:08,002 [http-nio-8080-exec-2] INFO o.c.s.zzpublic.NewBuildRevisionV000 - processRequest() - END5[INFO] [talledLocalContainer] 2017-12-05 15:45:08,003 [http-nio-8080-exec-2] INFO o.c.s.zzpublic.NewBuildRevisionV000 - processRequest() - END6[INFO] [talledLocalContainer] 2017-12-05 15:45:08,005 [http-nio-8080-exec-2] INFO o.c.s.zzpublic.NewBuildRevisionV000 - processRequest() - END7[INFO] [talledLocalContainer] 2017-12-05 15:45:08,006 [http-nio-8080-exec-2] INFO o.c.s.zzpublic.NewBuildRevisionV000 - processRequest() - END8[INFO] [talledLocalContainer] 2017-12-05 15:45:08,006 [http-nio-8080-exec-2] INFO o.c.s.zzpublic.NewBuildRevisionV000 - processRequest() - END9[INFO] [talledLocalContainer] 2017-12-05 15:45:08,007 [http-nio-8080-exec-2] INFO o.c.s.zzpublic.NewBuildRevisionV000 - processRequest() - END

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 NewBuildRevisionV000

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful