How to use processRequest method of org.cerberus.servlet.zzpublic.NewRelease class

Best Cerberus-source code snippet using org.cerberus.servlet.zzpublic.NewRelease.processRequest

Source:NewRelease.java Github

copy

Full Screen

...63 * @param response servlet response64 * @throws ServletException if a servlet-specific error occurs65 * @throws IOException if an I/O error occurs66 */67 protected void processRequest(HttpServletRequest request, HttpServletResponse response)68 throws ServletException, IOException {69 PrintWriter out = response.getWriter();70 String charset = request.getCharacterEncoding();71 ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());72 /**73 * Adding Log entry.74 */75 ILogEventService logEventService = appContext.getBean(LogEventService.class);76 logEventService.createForPublicCalls("/NewRelease", "CALL", "NewRelease called : " + request.getRequestURL(), request);77 IApplicationService MyApplicationService = appContext.getBean(ApplicationService.class);78 IUserService MyUserService = appContext.getBean(UserService.class);79 IProjectService MyProjectService = appContext.getBean(ProjectService.class);80 IBuildRevisionParametersService buildRevisionParametersService = appContext.getBean(IBuildRevisionParametersService.class);81 IFactoryBuildRevisionParameters factoryBuildRevisionParameters = appContext.getBean(IFactoryBuildRevisionParameters.class);82 // Parsing all parameters.83 String application = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("application"), "", charset);84 String release = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("release"), "", charset);85 String project = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("project"), "", charset);86 String ticket = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("ticket"), "", charset);87 String bug = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("bug"), "", charset);88 String subject = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("subject"), "", charset);89 String owner = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("owner"), "", charset);90 String link = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("link"), "", charset);91 // Those Parameters could be used later when Cerberus send the deploy request to Jenkins. 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 String repositoryurl = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("repositoryurl"), "", charset);97 String helpMessage = "\nThis servlet is used to create or update a release entry in a 'NONE' build and 'NONE' revision.\n\nParameter list :\n"98 + "- application [mandatory] : the application that produced the release. This parameter must match the application list in Cerberus. [" + application + "]\n"99 + "- release : release number or svn number. This should be unique at the application level. 2 calls on the same application and release will update the other parameters on the same entry. [" + release + "]\n"100 + "- project : Project reference. [" + project + "]\n"101 + "- ticket : Ticket Reference. [" + ticket + "]\n"102 + "- bug : Bug reference. [" + bug + "]\n"103 + "- subject : A short description of the change. [" + subject + "]\n"104 + "- owner : User name of the developper/ person who did the commit. [" + owner + "]\n"105 + "- link : URL Link on detail documentation on the release. [" + link + "]\n\n"106 + "The following optional parameters could be used later when Cerberus send the deploy request to Jenkins.\n"107 + "- jenkinsbuildid : Jenkins Build ID. [" + jenkinsbuildid + "]\n"108 + "- mavengroupid : Maven Group ID. [" + mavengroupid + "]\n"109 + "- mavenartifactid : Maven Artifact ID. [" + mavenartifactid + "]\n"110 + "- repositoryurl : Repository URL. [" + repositoryurl + "]\n"111 + "- mavenversion : Maven Version. [" + mavenversion + "]\n";112 DatabaseSpring database = appContext.getBean(DatabaseSpring.class);113 Connection connection = database.connect();114 try {115 boolean error = false;116 // Checking the parameter validity. If application has been entered, does it exist ?117 if (!application.equalsIgnoreCase("") && !MyApplicationService.exist(application)) {118 out.println("Error - Application does not exist : " + application);119 error = true;120 }121 if (application.equalsIgnoreCase("")) {122 out.println("Error - Parameter application is mandatory.");123 error = true;124 }125 // Checking the parameter validity. If owner has been entered, does it exist ?126 if (!owner.equalsIgnoreCase("")) {127 if (MyUserService.isUserExist(owner)) {128 owner = MyUserService.findUserByKey(owner).getLogin(); // We get the exact name from Cerberus.129 } else {130 out.println("Warning - User does not exist : " + owner);131 }132 }133 // Checking the parameter validity. If project has been entered, does it exist ?134 if (!project.equalsIgnoreCase("") && !MyProjectService.exist(project)) {135 out.println("Warning - Project does not exist : " + project);136 }137 // Starting the database update only when no blocking error has been detected.138 if (error == false) {139 // In case the bugID is not defined, we try to guess it from the subject. should be between # and a space or CR.140 if (StringUtil.isNullOrEmpty(bug)) {141 String[] columns = subject.split("#");142 if (columns.length >= 2) {143 for (int i = 1; i < columns.length; i++) {144 String[] columnsbis = columns[i].split(" ");145 if (columnsbis.length >= 1) {146 if (!columnsbis[0].contains(";")) { // Bug number should not include ;147 bug = columnsbis[0];148 }149 }150 }151 }152 }153 // Transaction and database update.154 // Duplicate entry Verification. On the build/relivion not yet assigned (NONE/NONE),155 // we verify that the application + release has not been submitted yet.156 // if it exist, we update it in stead of inserting a new row.157 // That correspond in the cases where the Jenkins pipe is executed several times 158 // on a single svn commit.159 /**160 * Verify if the entry already exists if already exists, update161 * it else create it162 */163 AnswerItem answer = buildRevisionParametersService.readByVarious2("NONE", "NONE", release, application);164 BuildRevisionParameters buildRevisionParameters = (BuildRevisionParameters) answer.getItem();165 if (answer.getResultMessage().getCode() == new MessageEvent(MessageEventEnum.DATA_OPERATION_OK).getCode() && buildRevisionParameters != null) {166 out.println("Warning - Release entry already exist. Updating the existing entry : " + buildRevisionParameters.getId());167 if (!project.isEmpty()) {168 buildRevisionParameters.setProject(project);169 }170 if (!ticket.isEmpty()) {171 buildRevisionParameters.setTicketIdFixed(ticket);172 }173 if (!bug.isEmpty()) {174 buildRevisionParameters.setBugIdFixed(bug);175 }176 if (!subject.isEmpty()) {177 buildRevisionParameters.setSubject(subject);178 }179 if (!owner.isEmpty()) {180 buildRevisionParameters.setReleaseOwner(owner);181 }182 if (!link.isEmpty()) {183 buildRevisionParameters.setLink(link);184 }185 if (!jenkinsbuildid.isEmpty()) {186 buildRevisionParameters.setJenkinsBuildId(jenkinsbuildid);187 }188 if (!mavengroupid.isEmpty()) {189 buildRevisionParameters.setMavenGroupId(mavengroupid);190 }191 if (!mavenartifactid.isEmpty()) {192 buildRevisionParameters.setMavenArtifactId(mavenartifactid);193 }194 if (!mavenversion.isEmpty()) {195 buildRevisionParameters.setMavenVersion(mavenversion);196 }197 if (!repositoryurl.isEmpty()) {198 buildRevisionParameters.setRepositoryUrl(repositoryurl);199 }200 buildRevisionParametersService.update(buildRevisionParameters);201 } else if (answer.getResultMessage().getCode() == new MessageEvent(MessageEventEnum.DATA_OPERATION_NO_DATA_FOUND).getCode()) {202 buildRevisionParametersService.create(factoryBuildRevisionParameters.create(0, "NONE", "NONE", release, application, project, ticket, bug, link, owner, subject, null, jenkinsbuildid, mavengroupid, mavenartifactid, mavenversion, repositoryurl));203 out.println("Release Inserted : '" + release + "' on '" + application + "' for user '" + owner + "'");204 } else {205 out.println("A problem occured : '" + answer.getResultMessage().getDescription());206 }207 } else {208 // In case of errors, we display the help message.209 out.println(helpMessage);210 }211 } catch (Exception e) {212 LOG.warn(Infos.getInstance().getProjectNameAndVersion() + " - Exception catched.", e);213 out.print("Error while inserting the release : ");214 out.println(e.toString());215 } finally {216 out.close();217 try {218 if (connection != null) {219 connection.close();220 }221 } catch (SQLException e) {222 LOG.warn(e.toString());223 }224 }225 }226 // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">227 /**228 * Handles the HTTP <code>GET</code> method.229 *230 * @param request servlet request231 * @param response servlet response232 * @throws ServletException if a servlet-specific error occurs233 * @throws IOException if an I/O error occurs234 */235 @Override236 protected void doGet(HttpServletRequest request, HttpServletResponse response)237 throws ServletException, IOException {238 processRequest(request, response);239 }240 /**241 * Handles the HTTP <code>POST</code> method.242 *243 * @param request servlet request244 * @param response servlet response245 * @throws ServletException if a servlet-specific error occurs246 * @throws IOException if an I/O error occurs247 */248 @Override249 protected void doPost(HttpServletRequest request, HttpServletResponse response)250 throws ServletException, IOException {251 processRequest(request, response);252 }253 /**254 * Returns a short description of the servlet.255 *256 * @return a String containing servlet description257 */258 @Override259 public String getServletInfo() {260 return "Short description";261 }// </editor-fold>262}...

Full Screen

Full Screen

processRequest

Using AI Code Generation

copy

Full Screen

1import org.cerberus.servlet.zzpublic.NewRelease;2import org.cerberus.servlet.zzpublic.NewReleaseRequest;3NewReleaseRequest newReleaseRequest = new NewReleaseRequest();4newReleaseRequest.setRelease("1.0.0");5newReleaseRequest.setReleaseDate("2018-10-01");6newReleaseRequest.setRevision("123456789");7newReleaseRequest.setRevisionDate("2018-10-01");8newReleaseRequest.setRevisionDesc("This is a test");9NewRelease newRelease = new NewRelease();10newRelease.processRequest(newReleaseRequest);11import org.cerberus.servlet.zzpublic.NewRelease;12import org.cerberus.servlet.zzpublic.NewReleaseRequest;13NewReleaseRequest newReleaseRequest = new NewReleaseRequest();14newReleaseRequest.setRelease("1.0.0");15newReleaseRequest.setReleaseDate("2018-10-01");16newReleaseRequest.setRevision("123456789");17newReleaseRequest.setRevisionDate("2018-10-01");18newReleaseRequest.setRevisionDesc("This is a test");19NewRelease newRelease = new NewRelease();20newRelease.processRequest(newReleaseRequest);21import org.cerberus.servlet.zzpublic.NewRelease;22import org.cerberus.servlet.zzpublic.NewReleaseRequest;23NewReleaseRequest newReleaseRequest = new NewReleaseRequest();24newReleaseRequest.setRelease("1.0.0");25newReleaseRequest.setReleaseDate("2018-10-01");26newReleaseRequest.setRevision("123456789");27newReleaseRequest.setRevisionDate("2018-10-01");28newReleaseRequest.setRevisionDesc("This is a test");29NewRelease newRelease = new NewRelease();30newRelease.processRequest(newReleaseRequest);31import org.cerberus.servlet.zzpublic.NewRelease;32import org.cerberus.servlet.zzpublic.NewReleaseRequest;33NewReleaseRequest newReleaseRequest = new NewReleaseRequest();34newReleaseRequest.setRelease("1.0.0");

Full Screen

Full Screen

processRequest

Using AI Code Generation

copy

Full Screen

1String data = "action=processRequest&release=1.0.0";2String result = httpGet(url, data);3System.out.println(result);4String data = "action=processRequest&release=1.0.0";5String result = httpPost(url, data);6System.out.println(result);7String data = "action=processRequest&release=1.0.0";8String result = httpPut(url, data);9System.out.println(result);10String data = "action=processRequest&release=1.0.0";11String result = httpDelete(url, data);12System.out.println(result);13String data = "action=processRequest&release=1.0.0";14String result = httpPatch(url, data);15System.out.println(result);16String data = "action=processRequest&release=1.0.0";17String result = httpHead(url, data);18System.out.println(result);19String data = "action=processRequest&release=1.0.0";20String result = httpOptions(url, data);21System.out.println(result);

Full Screen

Full Screen

processRequest

Using AI Code Generation

copy

Full Screen

1String data = "release=1.0.0&application=MyApp&description=This is my first release";2String response = org.cerberus.util.http.HttpUtil.sendPost(url, data);3String data = "release=1.0.0&application=MyApp&description=This is my first release";4String response = org.cerberus.util.http.HttpUtil.sendPost(url, data);5String data = "release=1.0.0&application=MyApp&description=This is my first release";6String response = org.cerberus.util.http.HttpUtil.sendPost(url, data);7String data = "release=1.0.0&application=MyApp&description=This is my first release";

Full Screen

Full Screen

processRequest

Using AI Code Generation

copy

Full Screen

1package org.cerberus.servlet.zzpublic;2import java.io.BufferedReader;3import java.io.IOException;4import java.io.InputStreamReader;5import java.io.OutputStreamWriter;6import java.net.HttpURLConnection;7import java.net.URL;8import org.json.JSONArray;9import org.json.JSONException;10import org.json.JSONObject;11public class NewRelease {12 public static void main(String[] args) throws IOException, JSONException {13 String charset = "UTF-8";14 String param1 = "param1";15 String param2 = "param2";16 String query = String.format("param1=%s&param2=%s",17 param1, param2);18 HttpURLConnection connection = (HttpURLConnection) new URL(url + "?" + query).openConnection();19 connection.setRequestMethod("GET");20 connection.setRequestProperty("Accept-Charset", charset);21 connection.setRequestProperty("Content-Type", "application/json;charset=" + charset);22 connection.setDoOutput(true);23 try (OutputStreamWriter writer = new OutputStreamWriter(connection.getOutputStream())) {24 writer.write(query);25 }26 String response = "";27 try (BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream()))) {28 String line;29 while ((line = br.readLine()) != null) {30 response += line;31 }32 }33 JSONObject json = new JSONObject(response);34 JSONArray releases = json.getJSONArray("contentTable");35 for (int i = 0; i < releases.length(); i++) {36 JSONObject release = releases.getJSONObject(i);37 System.out.println(release.getString("release"));38 }39 }40}

Full Screen

Full Screen

processRequest

Using AI Code Generation

copy

Full Screen

1var releaseNote = servlets.zzpublic.NewRelease.processRequest(request, response, "3.8.1");2var modal = new Modal();3modal.setTitle("Release note 3.8.1");4modal.setBody(releaseNote);5modal.show();6var version = new Label("3.8.1");7version.setCssClass("version");8version.setTooltip("Click to display the release note");9version.setClick("modal.show()");10var modal = new Modal();11modal.setTitle("Release note 3.8.1");12modal.setBody("3.8.1\n"13 + "- [Issue 1417](

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 NewRelease

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful