How to use processRequest method of org.cerberus.servlet.crud.transversaltables.DeleteEventHook class

Best Cerberus-source code snippet using org.cerberus.servlet.crud.transversaltables.DeleteEventHook.processRequest

Source:DeleteEventHook.java Github

copy

Full Screen

...62 * @param response servlet response63 * @throws ServletException if a servlet-specific error occurs64 * @throws IOException if an I/O error occurs65 */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 ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());75 String charset = request.getCharacterEncoding() == null ? "UTF-8" : request.getCharacterEncoding();76 77 IEventHookService eventHookService = appContext.getBean(IEventHookService.class);78 IFactoryEventHook eventHookFactory = appContext.getBean(IFactoryEventHook.class);79 80 response.setContentType("application/json");81 // Calling Servlet Transversal Util.82 ServletUtil.servletStart(request);83 /**84 * Parsing and securing all required parameters.85 */86 // Parameter that are already controled by GUI (no need to decode) --> We SECURE them87 Integer id = Integer.valueOf(request.getParameter("id"));88 LOG.debug(id);89 90 String usr = request.getUserPrincipal().getName();91 /**92 * Checking all constrains before calling the services.93 */94 /**95 * The service was able to perform the query and confirm the object96 * exist, then we can delete it.97 */98 Timestamp updateDate = new Timestamp(new Date().getTime());99 EventHook eh = eventHookFactory.create(id, null, null, null, true, null, null, null, null, usr, updateDate, usr, updateDate);100 ans = eventHookService.delete(eh);101 102 if (ans.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode())) {103 /**104 * Delete was successful. Adding Log entry.105 */106 ILogEventService logEventService = appContext.getBean(LogEventService.class);107 logEventService.createForPrivateCalls("/CreateEventHook", "CREATE", "Create EventHook : ['" + id + "']", request);108 }109 /**110 * Formatting and returning the json result.111 */112 jsonResponse.put("messageType", ans.getResultMessage().getMessage().getCodeString());113 jsonResponse.put("message", ans.getResultMessage().getDescription());114 115 response.getWriter().print(jsonResponse);116 response.getWriter().flush();117 }118 // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">119 /**120 * Handles the HTTP <code>GET</code> method.121 *122 * @param request servlet request123 * @param response servlet response124 * @throws ServletException if a servlet-specific error occurs125 * @throws IOException if an I/O error occurs126 */127 @Override128 protected void doGet(HttpServletRequest request, HttpServletResponse response)129 throws ServletException, IOException {130 try {131 processRequest(request, response);132 133 } catch (CerberusException ex) {134 LOG.warn(ex);135 } catch (JSONException ex) {136 LOG.warn(ex);137 }138 }139 /**140 * Handles the HTTP <code>POST</code> method.141 *142 * @param request servlet request143 * @param response servlet response144 * @throws ServletException if a servlet-specific error occurs145 * @throws IOException if an I/O error occurs146 */147 @Override148 protected void doPost(HttpServletRequest request, HttpServletResponse response)149 throws ServletException, IOException {150 try {151 processRequest(request, response);152 153 } catch (CerberusException ex) {154 LOG.warn(ex);155 } catch (JSONException ex) {156 LOG.warn(ex);157 }158 }159 /**160 * Returns a short description of the servlet.161 *162 * @return a String containing servlet description163 */164 @Override165 public String getServletInfo() {...

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 DeleteEventHook

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful