How to use processRequest method of org.cerberus.servlet.crud.countryenvironment.CreateCountryEnvParam class

Best Cerberus-source code snippet using org.cerberus.servlet.crud.countryenvironment.CreateCountryEnvParam.processRequest

copy

Full Screen

...62 * @throws IOException if an I/​O error occurs63 * @throws org.cerberus.exception.CerberusException64 * @throws org.json.JSONException65 */​66 protected void processRequest(HttpServletRequest request, HttpServletResponse response)67 throws ServletException, IOException, CerberusException, JSONException {68 JSONObject jsonResponse = new JSONObject();69 Answer ans = new Answer();70 MessageEvent msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);71 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", ""));72 ans.setResultMessage(msg);73 PolicyFactory policy = Sanitizers.FORMATTING.and(Sanitizers.LINKS);74 String charset = request.getCharacterEncoding();75 response.setContentType("application/​json");76 /​/​ Calling Servlet Transversal Util.77 ServletUtil.servletStart(request);78 /​**79 * Parsing and securing all required parameters.80 */​81 /​/​ Parameter that are already controled by GUI (no need to decode) --> We SECURE them82 String system = policy.sanitize(request.getParameter("system"));83 String country = policy.sanitize(request.getParameter("country"));84 String environment = policy.sanitize(request.getParameter("environment"));85 String type = policy.sanitize(request.getParameter("type"));86 boolean active = (request.getParameter("active") != null);87 boolean maintenanceAct = "Y".equals(policy.sanitize(request.getParameter("maintenanceAct"))) ? true : false;88 /​/​ Parameter that needs to be secured --> We SECURE+DECODE them89 String description = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("description"), "", charset);90 String maintenanceStr = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("maintenanceStr"), "01:00:00", charset);91 String maintenanceEnd = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("maintenanceEnd"), "01:00:00", charset);92 maintenanceStr = maintenanceStr.isEmpty() ? "00:00:00" : maintenanceStr;93 maintenanceEnd = maintenanceEnd.isEmpty() ? "00:00:00" : maintenanceEnd;94 String build = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("build"), "", charset);95 if ("ALL".equalsIgnoreCase(build)) build="";96 String revision = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("revision"), "", charset);97 if ("ALL".equalsIgnoreCase(revision)) revision="";98 String chain = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("chain"), "", charset);99 /​/​ Parameter that we cannot secure as we need the html --> We DECODE them100 String distribList = ParameterParserUtil.parseStringParamAndDecode(request.getParameter("distribList"), "", charset);101 String emailBodyRevision = ParameterParserUtil.parseStringParamAndDecode(request.getParameter("eMailBodyRevision"), "", charset);102 String emailBodyChain = ParameterParserUtil.parseStringParamAndDecode(request.getParameter("eMailBodyChain"), "", charset);103 String emailBodyDisableEnvironment = ParameterParserUtil.parseStringParamAndDecode(request.getParameter("eMailBodyDisableEnvironment"), "", charset);104 /​**105 * Checking all constrains before calling the services.106 */​107 if (StringUtil.isNullOrEmpty(system)) {108 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_EXPECTED);109 msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME)110 .replace("%OPERATION%", "Create")111 .replace("%REASON%", "System is missing!"));112 ans.setResultMessage(msg);113 } else if (StringUtil.isNullOrEmpty(country)) {114 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_EXPECTED);115 msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME)116 .replace("%OPERATION%", "Create")117 .replace("%REASON%", "Country is missing!"));118 ans.setResultMessage(msg);119 } else if (StringUtil.isNullOrEmpty(environment)) {120 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_EXPECTED);121 msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME)122 .replace("%OPERATION%", "Create")123 .replace("%REASON%", "Environment is missing!"));124 ans.setResultMessage(msg);125 } else {126 /​**127 * All data seems cleans so we can call the services.128 */​129 ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());130 ICountryEnvParamService countryEnvParamService = appContext.getBean(ICountryEnvParamService.class);131 IFactoryCountryEnvParam factoryCountryEnvParam = appContext.getBean(IFactoryCountryEnvParam.class);132 CountryEnvParam countryEnvParamData = factoryCountryEnvParam.create(system, country, environment, description, build, revision, chain, distribList, emailBodyRevision, type, emailBodyChain, emailBodyDisableEnvironment, active, maintenanceAct, maintenanceStr, maintenanceEnd);133 ans = countryEnvParamService.create(countryEnvParamData);134 if (ans.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode())) {135 /​**136 * Object created. Adding Log entry.137 */​138 ILogEventService logEventService = appContext.getBean(LogEventService.class);139 logEventService.createForPrivateCalls("/​CreateCountryEnvParam", "CREATE", "Create CountryEnvParam : ['" + system + "'|'" + country + "'|'" + environment + "']", request);140 }141 }142 /​**143 * Formating and returning the json result.144 */​145 jsonResponse.put("messageType", ans.getResultMessage().getMessage().getCodeString());146 jsonResponse.put("message", ans.getResultMessage().getDescription());147 response.getWriter().print(jsonResponse);148 response.getWriter().flush();149 }150 /​/​ <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">151 /​**152 * Handles the HTTP <code>GET</​code> method.153 *154 * @param request servlet request155 * @param response servlet response156 * @throws ServletException if a servlet-specific error occurs157 * @throws IOException if an I/​O error occurs158 */​159 @Override160 protected void doGet(HttpServletRequest request, HttpServletResponse response)161 throws ServletException, IOException {162 try {163 processRequest(request, response);164 } catch (CerberusException ex) {165 LOG.warn(ex);166 } catch (JSONException ex) {167 LOG.warn(ex);168 }169 }170 /​**171 * Handles the HTTP <code>POST</​code> method.172 *173 * @param request servlet request174 * @param response servlet response175 * @throws ServletException if a servlet-specific error occurs176 * @throws IOException if an I/​O error occurs177 */​178 @Override179 protected void doPost(HttpServletRequest request, HttpServletResponse response)180 throws ServletException, IOException {181 try {182 processRequest(request, response);183 } catch (CerberusException ex) {184 LOG.warn(ex);185 } catch (JSONException ex) {186 LOG.warn(ex);187 }188 }189 /​**190 * Returns a short description of the servlet.191 *192 * @return a String containing servlet description193 */​194 @Override195 public String getServletInfo() {196 return "Short description";...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

Starting &#038; growing a QA Testing career

The QA testing career includes following an often long, winding road filled with fun, chaos, challenges, and complexity. Financially, the spectrum is broad and influenced by location, company type, company size, and the QA tester’s experience level. QA testing is a profitable, enjoyable, and thriving career choice.

Unveiling Samsung Galaxy Z Fold4 For Mobile App Testing

Hey LambdaTesters! We’ve got something special for you this week. ????

A Step-By-Step Guide To Cypress API Testing

API (Application Programming Interface) is a set of definitions and protocols for building and integrating applications. It’s occasionally referred to as a contract between an information provider and an information user establishing the content required from the consumer and the content needed by the producer.

Keeping Quality Transparency Throughout the organization

In general, software testers have a challenging job. Software testing is frequently the final significant activity undertaken prior to actually delivering a product. Since the terms “software” and “late” are nearly synonymous, it is the testers that frequently catch the ire of the whole business as they try to test the software at the end. It is the testers who are under pressure to finish faster and deem the product “release candidate” before they have had enough opportunity to be comfortable. To make matters worse, if bugs are discovered in the product after it has been released, everyone looks to the testers and says, “Why didn’t you spot those bugs?” The testers did not cause the bugs, but they must bear some of the guilt for the bugs that were disclosed.

Fault-Based Testing and the Pesticide Paradox

In some sense, testing can be more difficult than coding, as validating the efficiency of the test cases (i.e., the ‘goodness’ of your tests) can be much harder than validating code correctness. In practice, the tests are just executed without any validation beyond the pass/fail verdict. On the contrary, the code is (hopefully) always validated by testing. By designing and executing the test cases the result is that some tests have passed, and some others have failed. Testers do not know much about how many bugs remain in the code, nor about their bug-revealing efficiency.

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 CreateCountryEnvParam

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful