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

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

Source:CreateScheduleEntry.java Github

copy

Full Screen

...65 * @param response servlet response66 * @throws ServletException if a servlet-specific error occurs67 * @throws IOException if an I/O error occurs68 */69 protected void processRequest(HttpServletRequest request, HttpServletResponse response)70 throws ServletException, IOException, JSONException {71 JSONObject jsonResponse = new JSONObject();72 Answer ans = new Answer();73 MessageEvent msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);74 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", ""));75 ans.setResultMessage(msg);76 PolicyFactory policy = Sanitizers.FORMATTING.and(Sanitizers.LINKS);77 response.setContentType("application/json");78 // Calling Servlet Transversal Util.79 ServletUtil.servletStart(request);80 /**81 * Parsing and securing all required parameters.82 */83 String name = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter("name"), "");84 String cronDefinition = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter("cronDefinition"), "");85 String type = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter("type"), "CAMPAIGN");86 String active = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter("active"), "Y");87 String desc = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter("description"), "Y");88 Boolean validCron = org.quartz.CronExpression.isValidExpression(cronDefinition);89 LOG.debug("validCron : " + validCron);90 /**91 * Checking all constrains before calling the services.92 */93 if (name.isEmpty() || cronDefinition.isEmpty() || !validCron) {94 msg = new MessageEvent(MessageEventEnum.SCHEDULER_ERROR_EXPECTED);95 msg.setDescription(msg.getDescription().replace("%ITEM%", "campaign")96 .replace("%OPERATION%", "Create")97 .replace("%REASON%", "Some mendatory fields are missing or iregular!"));98 ans.setResultMessage(msg);99 } else {100 /**101 * All data seems cleans so we can call the services.102 */103 ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());104 IFactoryScheduleEntry factoryScheduleEntry = appContext.getBean(IFactoryScheduleEntry.class);105 IScheduleEntryService scheduleEntryService = appContext.getBean(IScheduleEntryService.class);106 ScheduleEntry scheduleEntry = factoryScheduleEntry.create(0, type, name, cronDefinition, null, active, desc, request.getUserPrincipal().getName(), null, null, null);107 ans = scheduleEntryService.create(scheduleEntry);108 if (ans.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode())) {109 /**110 * Object created. Updating Scheduler Version.111 */112 IMyVersionService myVersionService = appContext.getBean(IMyVersionService.class);113 myVersionService.updateMyVersionString("scheduler_version", String.valueOf(new Date()));114 /**115 * Object created. Adding Log entry.116 */117 ILogEventService logEventService = appContext.getBean(LogEventService.class);118 IFactoryLogEvent factoryLogEvent = appContext.getBean(FactoryLogEvent.class);119 logEventService.createForPrivateCalls("/CreateScheduleEntry", "CREATE", "Create schedule entry : ['" + scheduleEntry.getName() + "']", request);120 }121 }122 /**123 * Formating and returning the json result.124 */125 jsonResponse.put("messageType", ans.getResultMessage().getMessage().getCodeString());126 jsonResponse.put("message", ans.getResultMessage().getDescription());127 response.getWriter().print(jsonResponse);128 response.getWriter().flush();129 }130 // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">131 /**132 * Handles the HTTP <code>GET</code> method.133 *134 * @param request servlet request135 * @param response servlet response136 * @throws ServletException if a servlet-specific error occurs137 * @throws IOException if an I/O error occurs138 */139 @Override140 protected void doGet(HttpServletRequest request, HttpServletResponse response)141 throws ServletException, IOException {142 try {143 processRequest(request, response);144 } catch (JSONException ex) {145 LOG.warn(ex);146 }147 }148 /**149 * Handles the HTTP <code>POST</code> method.150 *151 * @param request servlet request152 * @param response servlet response153 * @throws ServletException if a servlet-specific error occurs154 * @throws IOException if an I/O error occurs155 */156 @Override157 protected void doPost(HttpServletRequest request, HttpServletResponse response)158 throws ServletException, IOException {159 try {160 processRequest(request, response);161 } catch (JSONException ex) {162 LOG.warn(ex);163 }164 }165 /**166 * Returns a short description of the servlet.167 *168 * @return a String containing servlet description169 */170 @Override171 public String getServletInfo() {172 return "Short description";173 }// </editor-fold>174}...

Full Screen

Full Screen

processRequest

Using AI Code Generation

copy

Full Screen

1importClass(org.cerberus.servlet.crud.scheduleentry.CreateScheduleEntry);2importClass(java.util.HashMap);3importClass(java.util.ArrayList);4var cerberus = require("cerberus");5var scheduleEntry = new CreateScheduleEntry();6var scheduleEntryName = "scheduleEntryName";7var frequency = "DAILY";8var map = new HashMap();9var list = new ArrayList();10map.put("name", scheduleEntryName);11map.put("frequency", frequency);12map.put("active", "Y");13map.put("type", "COUNTRY");14map.put("value1", "FRA");15map.put("value2", "");16map.put("value3", "");17map.put("value4", "");18map.put("value5", "");19map.put("value6", "");20map.put("value7", "");21map.put("value8", "");22map.put("value9", "");23map.put("value10", "");24map.put("value11", "");25map.put("value12", "");26map.put("value13", "");27map.put("value14", "");28map.put("value15", "");29map.put("value16", "");30map.put("value17", "");31map.put("value18", "");32map.put("value19", "");33map.put("value20", "");34map.put("description", "");35map.put("mailTo", "");36map.put("mailSubject", "");37map.put("mailBody", "");38map.put("mailBodyHTML", "");39map.put("mailHeader", "");40map.put("mailFooter", "");41map.put("mailFooterHTML", "");42map.put("mailAttachment", "");43map.put("mailAttachmentFilename", "");44map.put("mailAttachmentInline", "");45map.put("mailAttachmentInlineFilename", "");46map.put("mailAttachmentInlineCID", "");47map.put("mailAttachmentInlineCIDFilename", "");48map.put("mailAttachmentInlineCIDFilename2", "");49map.put("mailAttachmentInlineCIDFilename3", "");50map.put("mailAttachmentInlineCIDFilename4", "");51map.put("mailAttachmentInlineCIDFilename5", "");52map.put("mailAttachmentInlineCIDFilename6", "");53map.put("mailAttachmentInlineCIDFilename7", "");54map.put("mailAttachmentInlineCIDFilename8", "");55map.put("mailAttachmentInlineCIDFilename9", "");56map.put("mailAttachmentInlineCIDFilename10", "");57map.put("mailAttachmentInlineCIDFilename11", "");58map.put("mailAttachmentInlineCIDFilename12",

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 CreateScheduleEntry

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful