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

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

Source:UpdateParameter.java Github

copy

Full Screen

...58 * @param response servlet response59 * @throws ServletException if a servlet-specific error occurs60 * @throws IOException if an I/O error occurs61 */62 protected void processRequest(HttpServletRequest request, HttpServletResponse response)63 throws ServletException, IOException, CerberusException, JSONException {64 JSONObject jsonResponse = new JSONObject();65 Answer ans = new Answer();66 MessageEvent msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);67 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", ""));68 ans.setResultMessage(msg);69 PolicyFactory policy = Sanitizers.FORMATTING.and(Sanitizers.LINKS);70 String charset = request.getCharacterEncoding() == null ? "UTF-8" : request.getCharacterEncoding();71 ILogEventService logEventService;72 String id = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("id"), "", charset);73 String value = ParameterParserUtil.parseStringParam(request.getParameter("value"), "");74 String system = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("system"), "", charset);75 String system1value = ParameterParserUtil.parseStringParam(request.getParameter("system1Value"), null);76 String system1 = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("system1"), null, charset);77 boolean userHasPermissions = request.isUserInRole("Administrator");78 // Prepare the final answer.79 MessageEvent msg1 = new MessageEvent(MessageEventEnum.GENERIC_OK);80 Answer finalAnswer = new Answer(msg1);81 /**82 * Checking all constrains before calling the services.83 */84 if (StringUtil.isNullOrEmpty(id) || StringUtil.isNullOrEmpty(system1)) {85 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_EXPECTED);86 msg.setDescription(msg.getDescription().replace("%ITEM%", "Parameter")87 .replace("%OPERATION%", "Update")88 .replace("%REASON%", "Parameter id or system1 is missing!"));89 finalAnswer.setResultMessage(msg);90 } else if (!userHasPermissions) {91 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_EXPECTED);92 msg.setDescription(msg.getDescription().replace("%ITEM%", "Parameter")93 .replace("%OPERATION%", "Update")94 .replace("%REASON%", "You don't have the right to do that"));95 finalAnswer.setResultMessage(msg);96 } else {97 /**98 * All data seems cleans so we can call the services.99 */100 ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());101 IParameterService parameterService = appContext.getBean(IParameterService.class);102 FactoryParameter factoryparameter = appContext.getBean(FactoryParameter.class);103 Parameter para = factoryparameter.create(system, id, value, "");104 ans = parameterService.save(para, request);105 if (!ans.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode())106 && !ans.isCodeEquals(MessageEventEnum.DATA_OPERATION_ERROR_EXPECTED.getCode())) {107 /**108 * Object could not be found. We stop here and report the error.109 */110 finalAnswer = AnswerUtil.agregateAnswer(finalAnswer, ans);111 } else {112 /**113 * Object updated. Adding Log entry.114 */115 if (ans.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode())) {116 logEventService = appContext.getBean(LogEventService.class);117 logEventService.createForPrivateCalls("/UpdateParameter", "UPDATE", "Update Parameter : ['" + id + "'|'" + system + "']", request);118 }119 if (system1 != null && system1value != null) {120 Parameter para1 = factoryparameter.create(system1, id, system1value, "");121 ans = parameterService.save(para1, request);122 if (ans.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode())) {123 /**124 * Object updated. Adding Log entry.125 */126 logEventService = appContext.getBean(LogEventService.class);127 logEventService.createForPrivateCalls("/UpdateParameter", "UPDATE", "Update Parameter : ['" + id + "'|'" + system1 + "']", request);128 }129 }130 }131 }132 /**133 * Formating and returning the json result.134 */135 jsonResponse.put("messageType", finalAnswer.getResultMessage().getMessage().getCodeString());136 jsonResponse.put("message", finalAnswer.getResultMessage().getDescription());137 response.getWriter().print(jsonResponse);138 response.getWriter().flush();139 }140 // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">141 /**142 * Handles the HTTP <code>GET</code> method.143 *144 * @param request servlet request145 * @param response servlet response146 * @throws ServletException if a servlet-specific error occurs147 * @throws IOException if an I/O error occurs148 */149 @Override150 protected void doGet(HttpServletRequest request, HttpServletResponse response)151 throws ServletException, IOException {152 try {153 processRequest(request, response);154 } catch (CerberusException ex) {155 LOG.warn(ex);156 } catch (JSONException ex) {157 LOG.warn(ex);158 }159 }160 /**161 * Handles the HTTP <code>POST</code> method.162 *163 * @param request servlet request164 * @param response servlet response165 * @throws ServletException if a servlet-specific error occurs166 * @throws IOException if an I/O error occurs167 */168 @Override169 protected void doPost(HttpServletRequest request, HttpServletResponse response)170 throws ServletException, IOException {171 try {172 processRequest(request, response);173 } catch (CerberusException ex) {174 LOG.warn(ex);175 } catch (JSONException ex) {176 LOG.warn(ex);177 }178 }179 /**180 * Returns a short description of the servlet.181 *182 * @return a String containing servlet description183 */184 @Override185 public String getServletInfo() {186 return "Short description";...

Full Screen

Full Screen

processRequest

Using AI Code Generation

copy

Full Screen

1var value = document.getElementById("paramValue").value;2var parameter = document.getElementById("paramValue").name;3var servlet = document.getElementById("paramValue").getAttribute("servlet");4var value = document.getElementById("paramValue").value;5var parameter = document.getElementById("paramValue").name;6var servlet = document.getElementById("paramValue").getAttribute("servlet");7var value = document.getElementById("paramValue").value;8var parameter = document.getElementById("paramValue").name;9var servlet = document.getElementById("paramValue").getAttribute("servlet");10var value = document.getElementById("paramValue").value;11var parameter = document.getElementById("paramValue").name;12var servlet = document.getElementById("paramValue").getAttribute("servlet");13var value = document.getElementById("paramValue").value;14var parameter = document.getElementById("paramValue").name;15var servlet = document.getElementById("paramValue").getAttribute("servlet");16var value = document.getElementById("paramValue").value;17var parameter = document.getElementById("paramValue").name;18var servlet = document.getElementById("paramValue").getAttribute("servlet");19var value = document.getElementById("paramValue").value;20var parameter = document.getElementById("paramValue").name;21var servlet = document.getElementById("paramValue").getAttribute("servlet");

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 UpdateParameter

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful