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

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

Source:UpdateEventHook.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, CerberusException, JSONException {67 JSONObject jsonResponse = new JSONObject();68 Answer ans = new Answer();69 MessageEvent msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);70 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", ""));71 ans.setResultMessage(msg);72 PolicyFactory policy = Sanitizers.FORMATTING.and(Sanitizers.LINKS);73 ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());74 String charset = request.getCharacterEncoding() == null ? "UTF-8" : request.getCharacterEncoding();75 IEventHookService eventHookService = appContext.getBean(IEventHookService.class);76 IFactoryEventHook eventHookFactory = appContext.getBean(IFactoryEventHook.class);77 response.setContentType("application/json");78 // Calling Servlet Transversal Util.79 ServletUtil.servletStart(request);80 /**81 * Parsing and securing all required parameters.82 */83 // Parameter that are already controled by GUI (no need to decode) --> We SECURE them84 Integer id = Integer.valueOf(request.getParameter("id"));85 boolean isActive = (("true".equals(request.getParameter("isActive"))));86 String objectKey1 = ParameterParserUtil.parseStringParamAndDecode(policy.sanitize(request.getParameter("objectKey1")), "", charset);87 String objectKey2 = ParameterParserUtil.parseStringParamAndDecode(policy.sanitize(request.getParameter("objectKey2")), "", charset);88 // Parameter that needs to be secured --> We SECURE+DECODE them89 String eventReference = ParameterParserUtil.parseStringParamAndDecode(request.getParameter("eventReference"), "", charset);90 String description = ParameterParserUtil.parseStringParamAndDecode(request.getParameter("description"), "", charset);91 String hookChannel = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("hookChannel"), "", charset);92 String hookConnector = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("hookConnector"), "", charset);93 String hookRecipient = ParameterParserUtil.parseStringParamAndDecode(request.getParameter("hookRecipient"), "", charset);94 String usr = request.getUserPrincipal().getName();95 /**96 * Checking all constrains before calling the services.97 */98 if (id == 0) {99 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_EXPECTED);100 msg.setDescription(msg.getDescription().replace("%ITEM%", "Event Hook")101 .replace("%OPERATION%", "Update")102 .replace("%REASON%", "Event Hook ID is missing."));103 ans.setResultMessage(msg);104 } else {105 /**106 * All data seems cleans so we can call the services.107 */108 AnswerItem resp = eventHookService.readByKey(id);109 if (!(resp.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode()) && resp.getItem() != null)) {110 /**111 * Object could not be found. We stop here and report the error.112 */113 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_EXPECTED);114 msg.setDescription(msg.getDescription().replace("%ITEM%", "Event Hook")115 .replace("%OPERATION%", "Update")116 .replace("%REASON%", "Event Hook does not exist."));117 ans.setResultMessage(msg);118 } else {119 /**120 * The service was able to perform the query and confirm the121 * object exist, then we can delete it.122 */123 Timestamp updateDate = new Timestamp(new Date().getTime());124 EventHook eh = eventHookFactory.create(id, eventReference, objectKey1, objectKey2, isActive, hookConnector, hookRecipient, hookChannel, description, usr, updateDate, usr, updateDate);125 ans = eventHookService.update(eh);126 if (ans.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode())) {127 /**128 * Delete was successful. Adding Log entry.129 */130 ILogEventService logEventService = appContext.getBean(LogEventService.class);131 logEventService.createForPrivateCalls("/UpdateEventHook", "UPDATE", "Update EventHook : ['" + id + "']", request);132 }133 }134 }135 /**136 * Formating and returning the json result.137 */138 jsonResponse.put("messageType", ans.getResultMessage().getMessage().getCodeString());139 jsonResponse.put("message", ans.getResultMessage().getDescription());140 response.getWriter().print(jsonResponse);141 response.getWriter().flush();142 }143 // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">144 /**145 * Handles the HTTP <code>GET</code> method.146 *147 * @param request servlet request148 * @param response servlet response149 * @throws ServletException if a servlet-specific error occurs150 * @throws IOException if an I/O error occurs151 */152 @Override153 protected void doGet(HttpServletRequest request, HttpServletResponse response)154 throws ServletException, IOException {155 try {156 processRequest(request, response);157 } catch (CerberusException ex) {158 LOG.warn(ex);159 } catch (JSONException ex) {160 LOG.warn(ex);161 }162 }163 /**164 * Handles the HTTP <code>POST</code> method.165 *166 * @param request servlet request167 * @param response servlet response168 * @throws ServletException if a servlet-specific error occurs169 * @throws IOException if an I/O error occurs170 */171 @Override172 protected void doPost(HttpServletRequest request, HttpServletResponse response)173 throws ServletException, IOException {174 try {175 processRequest(request, response);176 } catch (CerberusException ex) {177 LOG.warn(ex);178 } catch (JSONException ex) {179 LOG.warn(ex);180 }181 }182 /**183 * Returns a short description of the servlet.184 *185 * @return a String containing servlet description186 */187 @Override188 public String getServletInfo() {189 return "Short description";...

Full Screen

Full Screen

processRequest

Using AI Code Generation

copy

Full Screen

1import org.cerberus.servlet.crud.transversaltables.UpdateEventHook;2String eventHook = request.getParameter("eventHook");3String eventHookDescription = request.getParameter("eventHookDescription");4String eventHookActive = request.getParameter("eventHookActive");5String eventHookURL = request.getParameter("eventHookURL");6String eventHookURLParameter = request.getParameter("eventHookURLParameter");7String eventHookURLParameterSeparator = request.getParameter("eventHookURLParameterSeparator");8String eventHookURLParameterSeparatorValue = request.getParameter("eventHookURLParameterSeparatorValue");9String eventHookURLParameterSeparatorValue2 = request.getParameter("eventHookURLParameterSeparatorValue2");10String eventHookURLParameterSeparatorValue3 = request.getParameter("eventHookURLParameterSeparatorValue3");11String eventHookURLParameterSeparatorValue4 = request.getParameter("eventHookURLParameterSeparatorValue4");12String eventHookURLParameterSeparatorValue5 = request.getParameter("eventHookURLParameterSeparatorValue5");13String eventHookURLParameterSeparatorValue6 = request.getParameter("eventHookURLParameterSeparatorValue6");14String eventHookURLParameterSeparatorValue7 = request.getParameter("eventHookURLParameterSeparatorValue7");15String eventHookURLParameterSeparatorValue8 = request.getParameter("eventHookURLParameterSeparatorValue8");16String eventHookURLParameterSeparatorValue9 = request.getParameter("eventHookURLParameterSeparatorValue9");17String eventHookURLParameterSeparatorValue10 = request.getParameter("eventHookURLParameterSeparatorValue10");18String eventHookURLParameterSeparatorValue11 = request.getParameter("eventHookURLParameterSeparatorValue11");19String eventHookURLParameterSeparatorValue12 = request.getParameter("eventHookURLParameterSeparatorValue12");20String eventHookURLParameterSeparatorValue13 = request.getParameter("eventHookURLParameterSeparatorValue13");21String eventHookURLParameterSeparatorValue14 = request.getParameter("eventHookURLParameterSeparatorValue14");22String eventHookURLParameterSeparatorValue15 = request.getParameter("eventHookURLParameterSeparatorValue15");23UpdateEventHook.updateEventHook(eventHook, eventHookDescription, eventHookActive, eventHookURL, event

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 UpdateEventHook

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful