How to use processRequest method of org.cerberus.servlet.crud.scheduleentry.UpdateScheduleEntry class

Best Cerberus-source code snippet using org.cerberus.servlet.crud.scheduleentry.UpdateScheduleEntry.processRequest

Source:UpdateScheduleEntry.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, JSONException {68 JSONObject jsonResponse = new JSONObject();69 Answer ans = new AnswerItem<>();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 response.setContentType("application/json");75 // Calling Servlet Transversal Util.76 ServletUtil.servletStart(request);77 /**78 * Parsing and securing all required parameters.79 */80 ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());81 IFactoryScheduleEntry factoryScheduleEntry = appContext.getBean(IFactoryScheduleEntry.class);82 IScheduleEntryService scheduleEntryService = appContext.getBean(IScheduleEntryService.class);83 Integer id = ParameterParserUtil.parseIntegerParam(request.getParameter("id"), 0);84 ScheduleEntry oldScheduleEntry = new ScheduleEntry();85 oldScheduleEntry = scheduleEntryService.readbykey(id).getItem();86 String oldName = oldScheduleEntry.getName();87 String name = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter("name"), oldName);88 String cronDefinition = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter("cronDefinition"), "");89 String type = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter("type"), "CAMPAIGN");90 String active = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter("active"), "Y");91 String userModif = request.getUserPrincipal().getName();92 Boolean validCron = org.quartz.CronExpression.isValidExpression(cronDefinition);93 /**94 * Checking all constrains before calling the services.95 */96 if (name.isEmpty() || cronDefinition.isEmpty() || !validCron) {97 msg = new MessageEvent(MessageEventEnum.SCHEDULER_ERROR_EXPECTED);98 msg.setDescription(msg.getDescription().replace("%ITEM%", "campaign")99 .replace("%OPERATION%", "Update")100 .replace("%REASON%", "Some mendatory fields are missing!"));101 ans.setResultMessage(msg);102 } else {103 /**104 * All data seems cleans so we can call the services.105 */106 107 ScheduleEntry scheduleEntry = scheduleEntryService.readbykey(id).getItem();108 scheduleEntry.setName(name);109 scheduleEntry.setType(type);110 scheduleEntry.setCronDefinition(cronDefinition);111 scheduleEntry.setActive(active);112 scheduleEntry.setUsrModif(userModif);113 ans = scheduleEntryService.update(scheduleEntry);114 if (ans.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode())) {115 /**116 * Object created. Updating scheduler entry.117 */118 IMyVersionService myVersionService = appContext.getBean(IMyVersionService.class);119 myVersionService.updateMyVersionString("scheduler_version", String.valueOf(new Date()));120 /**121 * Object created. Adding Log entry.122 */123 ILogEventService logEventService = appContext.getBean(LogEventService.class);124 IFactoryLogEvent factoryLogEvent = appContext.getBean(FactoryLogEvent.class);125 logEventService.createForPrivateCalls("/UpdateScheduleEntry", "Update", "Update schedule entry : ['" + scheduleEntry.getName() + "']", request);126 }127 }128 /**129 * Formating and returning the json result.130 */131 jsonResponse.put("messageType", ans.getResultMessage().getMessage().getCodeString());132 jsonResponse.put("message", ans.getResultMessage().getDescription());133 response.getWriter().print(jsonResponse);134 response.getWriter().flush();135 }136 // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">137 /**138 * Handles the HTTP <code>GET</code> method.139 *140 * @param request servlet request141 * @param response servlet response142 * @throws ServletException if a servlet-specific error occurs143 * @throws IOException if an I/O error occurs144 */145 @Override146 protected void doGet(HttpServletRequest request, HttpServletResponse response)147 throws ServletException, IOException {148 try {149 processRequest(request, response);150 } catch (JSONException ex) {151 LOG.warn(ex);152 }153 }154 /**155 * Handles the HTTP <code>POST</code> method.156 *157 * @param request servlet request158 * @param response servlet response159 * @throws ServletException if a servlet-specific error occurs160 * @throws IOException if an I/O error occurs161 */162 @Override163 protected void doPost(HttpServletRequest request, HttpServletResponse response)164 throws ServletException, IOException {165 try {166 processRequest(request, response);167 } catch (JSONException ex) {168 LOG.warn(ex);169 }170 }171 /**172 * Returns a short description of the servlet.173 *174 * @return a String containing servlet description175 */176 @Override177 public String getServletInfo() {178 return "Short description";179 }// </editor-fold>180}...

Full Screen

Full Screen

processRequest

Using AI Code Generation

copy

Full Screen

1 public void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {2 response.setContentType("text/html;charset=UTF-8");3 JSONObject jsonResponse = new JSONObject();4 PrintWriter out = response.getWriter();5 boolean hasPermissions = false;6 MessageEvent msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);7 AnswerItem resp = new AnswerItem<>(msg);8 try {9 JSONObject object = this.parseRequest(request);10 String system = ParameterParserUtil.parseStringParam(object.get("system"), "");11 String country = ParameterParserUtil.parseStringParam(object.get("country"), "");12 String env = ParameterParserUtil.parseStringParam(object.get("environment"), "");13 String app = ParameterParserUtil.parseStringParam(object.get("application"), "");14 String tag = ParameterParserUtil.parseStringParam(object.get("tag"), "");15 String build = ParameterParserUtil.parseStringParam(object.get("build"), "");16 String revision = ParameterParserUtil.parseStringParam(object.get("revision"), "");17 String active = ParameterParserUtil.parseStringParam(object.get("active"), "");18 String crontab = ParameterParserUtil.parseStringParam(object.get("crontab"), "");19 String description = ParameterParserUtil.parseStringParam(object.get("description"), "");20 String type = ParameterParserUtil.parseStringParam(object.get("type"), "");21 String id = ParameterParserUtil.parseStringParam(object.get("id"), "");22 String usr = ParameterParserUtil.parseStringParam(object.get("usr"), "");23 String pwd = ParameterParserUtil.parseStringParam(object.get("pwd"), "");24 String proxyHost = ParameterParserUtil.parseStringParam(object.get("proxyHost"), "");25 String proxyPort = ParameterParserUtil.parseStringParam(object.get("proxyPort"), "");26 String proxyUsr = ParameterParserUtil.parseStringParam(object.get("proxyUsr"), "");27 String proxyPwd = ParameterParserUtil.parseStringParam(object.get("proxyPwd"), "");28 String emailBody = ParameterParserUtil.parseStringParam(object.get("emailBody"), "");29 String emailBodyHTML = ParameterParserUtil.parseStringParam(object.get("emailBodyHTML"), "");30 String emailSubject = ParameterParserUtil.parseStringParam(object.get("emailSubject"), "");31 String emailTo = ParameterParserUtil.parseStringParam(object.get("emailTo"), "");32 String emailFrom = ParameterParserUtil.parseStringParam(object.get("emailFrom"), "");33 String emailCC = ParameterParserUtil.parseStringParam(object.get("emailCC"), "");

Full Screen

Full Screen

processRequest

Using AI Code Generation

copy

Full Screen

1[{2 {3 },4 {5 },6 {7 },8 {9 },10 {11 },12 {13 },14 {15 },16 {17 },18 {19 },20 {21 },22 {23 },24 {25 },26 {27 },28 {29 },30 {

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 UpdateScheduleEntry

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful