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

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

Source:ReadCountryEnvDeployType.java Github

copy

Full Screen

...63 * @throws ServletException if a servlet-specific error occurs64 * @throws IOException if an I/O error occurs65 * @throws org.cerberus.exception.CerberusException66 */67 protected void processRequest(HttpServletRequest request, HttpServletResponse response)68 throws ServletException, IOException, CerberusException {69 String echo = request.getParameter("sEcho");70 ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());71 PolicyFactory policy = Sanitizers.FORMATTING.and(Sanitizers.LINKS);72 response.setContentType("application/json");73 response.setCharacterEncoding("utf8");74 // Calling Servlet Transversal Util.75 ServletUtil.servletStart(request);76 77 // Default message to unexpected error.78 MessageEvent msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);79 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", ""));80 /**81 * Parsing and securing all required parameters.82 */83 String system = policy.sanitize(request.getParameter("system"));84 String country = policy.sanitize(request.getParameter("country"));85 String environment = policy.sanitize(request.getParameter("environment"));86 // Global boolean on the servlet that define if the user has permition to edit and delete object.87 boolean userHasPermissions = request.isUserInRole("IntegratorRO");88 // Init Answer with potencial error from Parsing parameter.89 AnswerItem answer = new AnswerItem(msg);90 try {91 JSONObject jsonResponse = new JSONObject();92 if (1 == 1) {93 answer = findCountryEnvironmentDeployTypeList(request.getParameter("system"), request.getParameter("country"), request.getParameter("environment"), appContext, userHasPermissions, request);94 jsonResponse = (JSONObject) answer.getItem();95 }96 jsonResponse.put("messageType", answer.getResultMessage().getMessage().getCodeString());97 jsonResponse.put("message", answer.getResultMessage().getDescription());98 jsonResponse.put("sEcho", echo);99 response.getWriter().print(jsonResponse.toString());100 } catch (JSONException e) {101 LOG.warn(e);102 //returns a default error message with the json format that is able to be parsed by the client-side103 response.getWriter().print(AnswerUtil.createGenericErrorAnswer());104 }105 }106// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">107 /**108 * Handles the HTTP <code>GET</code> method.109 *110 * @param request servlet request111 * @param response servlet response112 * @throws ServletException if a servlet-specific error occurs113 * @throws IOException if an I/O error occurs114 */115 @Override116 protected void doGet(HttpServletRequest request, HttpServletResponse response)117 throws ServletException, IOException {118 try {119 processRequest(request, response);120 } catch (CerberusException ex) {121 LOG.warn(ex);122 }123 }124 /**125 * Handles the HTTP <code>POST</code> method.126 *127 * @param request servlet request128 * @param response servlet response129 * @throws ServletException if a servlet-specific error occurs130 * @throws IOException if an I/O error occurs131 */132 @Override133 protected void doPost(HttpServletRequest request, HttpServletResponse response)134 throws ServletException, IOException {135 try {136 processRequest(request, response);137 } catch (CerberusException ex) {138 LOG.warn(ex);139 }140 }141 /**142 * Returns a short description of the servlet.143 *144 * @return a String containing servlet description145 */146 @Override147 public String getServletInfo() {148 return "Short description";149 }// </editor-fold>150 private AnswerItem findCountryEnvironmentDeployTypeList(String system, String country, String environment, ApplicationContext appContext, boolean userHasPermissions, HttpServletRequest request) throws JSONException {...

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.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful