How to use processRequest method of org.cerberus.servlet.crud.buildrevisionchange.CreateBuildRevisionParameters class

Best Cerberus-source code snippet using org.cerberus.servlet.crud.buildrevisionchange.CreateBuildRevisionParameters.processRequest

Source:CreateBuildRevisionParameters.java Github

copy

Full Screen

...61 * @throws IOException if an I/O error occurs62 * @throws org.cerberus.exception.CerberusException63 * @throws org.json.JSONException64 */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 String charset = request.getCharacterEncoding();74 response.setContentType("application/json");75 // Calling Servlet Transversal Util.76 ServletUtil.servletStart(request);77 78 /**79 * Parsing and securing all required parameters.80 */81 // Parameter that are already controled by GUI (no need to decode) --> We SECURE them82 // Parameter that needs to be secured --> We SECURE+DECODE them83 String build = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("build"), "", charset);84 String revision = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("revision"), "", charset);85 String release = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("release"), "", charset);86 String application = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("application"), "", charset);87 String project = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("project"), "", charset);88 String ticketidfixed = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("ticketidfixed"), "", charset);89 String bugidfixed = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("bugidfixed"), "", charset);90 String releaseowner = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("releaseowner"), "", charset);91 String subject = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("subject"), "", charset);92 String jenkinsbuildid = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("jenkinsbuildid"), "", charset);93 String mavenGroupID = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("mavengroupid"), "", charset);94 String mavenArtifactID = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("mavenartifactid"), "", charset);95 String mavenVersion = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("mavenversion"), "", charset);96 // Parameter that we cannot secure as we need the html --> We DECODE them97 String link = ParameterParserUtil.parseStringParamAndDecode(request.getParameter("link"), "", charset);98 String repositoryUrl = ParameterParserUtil.parseStringParamAndDecode(request.getParameter("repositoryurl"), "", charset);99 /**100 * Checking all constrains before calling the services.101 */102 if (false) {103 // No constrain on that Create operation.104 } else {105 /**106 * All data seems cleans so we can call the services.107 */108 ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());109 IBuildRevisionParametersService buildRevisionParametersService = appContext.getBean(IBuildRevisionParametersService.class);110 IFactoryBuildRevisionParameters buildRevisionParametersFactory = appContext.getBean(IFactoryBuildRevisionParameters.class);111 BuildRevisionParameters brpData = buildRevisionParametersFactory.create(0, build, revision, release, application, project, ticketidfixed, bugidfixed, link, releaseowner, subject, null, jenkinsbuildid, mavenGroupID, mavenArtifactID, mavenVersion, repositoryUrl);112 ans = buildRevisionParametersService.create(brpData);113 if (ans.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode())) {114 /**115 * Object created. Adding Log entry.116 */117 ILogEventService logEventService = appContext.getBean(LogEventService.class);118 logEventService.createForPrivateCalls("/CreateBuildRevisionParameters", "CREATE", "Create BuildRevisionParameters : ['" + build + "']", request);119 }120 }121 /**122 * Formating and returning the json result.123 */124 jsonResponse.put("messageType", ans.getResultMessage().getMessage().getCodeString());125 jsonResponse.put("message", ans.getResultMessage().getDescription());126 response.getWriter().print(jsonResponse);127 response.getWriter().flush();128 }129 // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">130 /**131 * Handles the HTTP <code>GET</code> method.132 *133 * @param request servlet request134 * @param response servlet response135 * @throws ServletException if a servlet-specific error occurs136 * @throws IOException if an I/O error occurs137 */138 @Override139 protected void doGet(HttpServletRequest request, HttpServletResponse response)140 throws ServletException, IOException {141 try {142 processRequest(request, response);143 } catch (CerberusException ex) {144 LOG.warn(ex);145 } catch (JSONException ex) {146 LOG.warn(ex);147 }148 }149 /**150 * Handles the HTTP <code>POST</code> method.151 *152 * @param request servlet request153 * @param response servlet response154 * @throws ServletException if a servlet-specific error occurs155 * @throws IOException if an I/O error occurs156 */157 @Override158 protected void doPost(HttpServletRequest request, HttpServletResponse response)159 throws ServletException, IOException {160 try {161 processRequest(request, response);162 } catch (CerberusException ex) {163 LOG.warn(ex);164 } catch (JSONException ex) {165 LOG.warn(ex);166 }167 }168 /**169 * Returns a short description of the servlet.170 *171 * @return a String containing servlet description172 */173 @Override174 public String getServletInfo() {175 return "Short description";...

Full Screen

Full Screen

processRequest

Using AI Code Generation

copy

Full Screen

1skinparam class {2}3skinparam interface {4}5skinparam package {6}7skinparam node {8}9skinparam node {

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 CreateBuildRevisionParameters

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful