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

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

Source:ReadBuildRevisionInvariant.java Github

copy

Full Screen

...69 * @throws ServletException if a servlet-specific error occurs70 * @throws IOException if an I/O error occurs71 * @throws org.cerberus.exception.CerberusException72 */73 protected void processRequest(HttpServletRequest request, HttpServletResponse response)74 throws ServletException, IOException, CerberusException {75 String echo = request.getParameter("sEcho");76 ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());77 PolicyFactory policy = Sanitizers.FORMATTING.and(Sanitizers.LINKS);78 response.setContentType("application/json");79 response.setCharacterEncoding("utf8");80 // Calling Servlet Transversal Util.81 ServletUtil.servletStart(request);82 83 // Default message to unexpected error.84 MessageEvent msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);85 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", ""));86 /**87 * Parsing and securing all required parameters.88 */89 Integer lvlid = -1;90 boolean lvlid_error = true;91 try {92 if (request.getParameter("level") != null && !request.getParameter("level").equals("")) {93 lvlid = Integer.valueOf(policy.sanitize(request.getParameter("level")));94 lvlid_error = false;95 }96 } catch (Exception ex) {97 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_EXPECTED);98 msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME));99 msg.setDescription(msg.getDescription().replace("%OPERATION%", "Read"));100 msg.setDescription(msg.getDescription().replace("%REASON%", "level must be an integer value."));101 lvlid_error = true;102 }103 Integer seqid = -1;104 boolean seqid_error = true;105 try {106 if (request.getParameter("seq") != null && !request.getParameter("seq").equals("")) {107 seqid = Integer.valueOf(policy.sanitize(request.getParameter("seq")));108 seqid_error = false;109 }110 } catch (Exception ex) {111 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_EXPECTED);112 msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME));113 msg.setDescription(msg.getDescription().replace("%OPERATION%", "Read"));114 msg.setDescription(msg.getDescription().replace("%REASON%", "id must be an integer value."));115 seqid_error = true;116 }117 String system = policy.sanitize(request.getParameter("system"));118 String columnName = ParameterParserUtil.parseStringParam(request.getParameter("columnName"), "");119 // Global boolean on the servlet that define if the user has permition to edit and delete object.120 boolean userHasPermissions = request.isUserInRole("Integrator");121 // Init Answer with potencial error from Parsing parameter.122 AnswerItem answer = new AnswerItem(msg);123 try {124 JSONObject jsonResponse = new JSONObject();125 if ((request.getParameter("system") != null) && (request.getParameter("level") != null) && !(lvlid_error) && (request.getParameter("seq") != null) && !(seqid_error)) { // ID parameter is specified so we return the unique record of object.126 answer = findBuildRevisionInvariantByKey(system, lvlid, seqid, appContext, userHasPermissions);127 jsonResponse = (JSONObject) answer.getItem();128 } else if (!Strings.isNullOrEmpty(columnName)) {129 answer = findDistinctValuesOfColumn(system, appContext, request, columnName);130 jsonResponse = (JSONObject) answer.getItem();131 } else { // Default behaviour, we return the list of objects.132 answer = findBuildRevisionInvariantList(system, lvlid, appContext, userHasPermissions, request);133 jsonResponse = (JSONObject) answer.getItem();134 }135 jsonResponse.put("messageType", answer.getResultMessage().getMessage().getCodeString());136 jsonResponse.put("message", answer.getResultMessage().getDescription());137 jsonResponse.put("sEcho", echo);138 response.getWriter().print(jsonResponse.toString());139 } catch (JSONException e) {140 LOG.warn(e);141 //returns a default error message with the json format that is able to be parsed by the client-side142 response.getWriter().print(AnswerUtil.createGenericErrorAnswer());143 }144 }145 // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">146 /**147 * Handles the HTTP <code>GET</code> method.148 *149 * @param request servlet request150 * @param response servlet response151 * @throws ServletException if a servlet-specific error occurs152 * @throws IOException if an I/O error occurs153 */154 @Override155 protected void doGet(HttpServletRequest request, HttpServletResponse response)156 throws ServletException, IOException {157 try {158 processRequest(request, response);159 } catch (CerberusException 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 }179 }180 /**181 * Returns a short description of the servlet.182 *183 * @return a String containing servlet description184 */185 @Override186 public String getServletInfo() {187 return "Short description";188 }// </editor-fold>189 private AnswerItem findBuildRevisionInvariantList(String system, Integer level, ApplicationContext appContext, boolean userHasPermissions, HttpServletRequest request) throws JSONException {...

Full Screen

Full Screen

processRequest

Using AI Code Generation

copy

Full Screen

1response.setContentType("application/json;charset=UTF-8");2org.cerberus.servlet.crud.buildrevisionchange.ReadBuildRevisionInvariant readBuildRevisionInvariant = new org.cerberus.servlet.crud.buildrevisionchange.ReadBuildRevisionInvariant();3readBuildRevisionInvariant.processRequest(request, response);4response.getWriter().write(readBuildRevisionInvariant.getJsonResponse().toString());5response.setContentType("application/json;charset=UTF-8");6org.cerberus.servlet.crud.buildrevisionchange.ReadBuildRevisionInvariant readBuildRevisionInvariant = new org.cerberus.servlet.crud.buildrevisionchange.ReadBuildRevisionInvariant();7readBuildRevisionInvariant.processRequest(request, response);8response.getWriter().write(readBuildRevisionInvariant.getJsonResponse().toString());9response.setContentType("application/json;charset=UTF-8");10org.cerberus.servlet.crud.buildrevisionchange.ReadBuildRevisionInvariant readBuildRevisionInvariant = new org.cerberus.servlet.crud.buildrevisionchange.ReadBuildRevisionInvariant();11readBuildRevisionInvariant.processRequest(request, response);12response.getWriter().write(readBuildRevisionInvariant.getJsonResponse().toString());13response.setContentType("application/json;charset=UTF-8");14org.cerberus.servlet.crud.buildrevisionchange.ReadBuildRevisionInvariant readBuildRevisionInvariant = new org.cerberus.servlet.crud.buildrevisionchange.ReadBuildRevisionInvariant();15readBuildRevisionInvariant.processRequest(request, response);16response.getWriter().write(readBuildRevisionInvariant.getJsonResponse().toString());17response.setContentType("application/json;charset=UTF-8");

Full Screen

Full Screen

processRequest

Using AI Code Generation

copy

Full Screen

1package org.cerberus.servlet.crud.buildrevisionchange;2import java.io.IOException;3import java.sql.Connection;4import java.sql.ResultSet;5import java.sql.SQLException;6import java.sql.Statement;7import java.util.ArrayList;8import java.util.List;9import javax.servlet.ServletException;10import javax.servlet.http.HttpServlet;11import javax.servlet.http.HttpServletRequest;12import javax.servlet.http.HttpServletResponse;13import org.cerberus.database.DatabaseSpring;14import org.cerberus.entity.BuildRevisionInvariant;15import org.cerberus.exception.CerberusException;16import org.cerberus.factory.IFactoryBuildRevisionInvariant;17import org.cerberus.log.MyLogger;18import org.cerberus.service.IBuildRevisionInvariantService;19import org.cerberus.servlet.api.GetApplicationList;20import org.json.JSONArray;21import org.json.JSONException;22import org.json.JSONObject;23import org.springframework.context.ApplicationContext;24import org.springframework.context.support.ClassPathXmlApplicationContext;25public class ReadBuildRevisionInvariant extends HttpServlet {26 private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(ReadBuildRevisionInvariant.class);27 protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {28 String answer = processRequest(request, response);29 response.setContentType("text/html");30 response.getWriter().print(answer);31 }32 protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {33 String answer = processRequest(request, response);34 response.setContentType("text/html");35 response.getWriter().print(answer);36 }37 private String processRequest(HttpServletRequest request, HttpServletResponse response) {38 JSONObject jsonResponse = new JSONObject();39 ApplicationContext appContext = new ClassPathXmlApplicationContext("classpath:/org/cerberus/applicationContext.xml");40 IBuildRevisionInvariantService buildRevisionInvariantService = appContext.getBean(IBuildRevisionInvariantService.class);

Full Screen

Full Screen

processRequest

Using AI Code Generation

copy

Full Screen

1processRequest(2 request.getParameter("build"),3 request.getParameter("revision"),4 request.getParameter("country"),5 request.getParameter("environment"),6 request.getParameter("system")7 );8public void processRequest(9 ) throws IOException {10 response.setContentType("application/json");11 response.setCharacterEncoding("utf-8");12 List<BuildRevisionInvariant> buildRevisionInvariantList = buildRevisionInvariantService.findBuildRevisionInvariantByCriteria(build, revision, country, environment, system);13 String json = new Gson().toJson(buildRevisionInvariantList);14 response.getWriter().write(json);15}16public List<BuildRevisionInvariant> findBuildRevisionInvariantByCriteria(17 ) throws CerberusException {18 List<BuildRevisionInvariant> buildRevisionInvariantList;19 if (!StringUtil.isNullOrEmpty(build)) {20 if (!StringUtil.isNullOrEmpty(revision)) {

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.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful