How to use UpdateBuildRevisionParameters class of org.cerberus.servlet.crud.buildrevisionchange package

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

Source:UpdateBuildRevisionParameters.java Github

copy

Full Screen

...46/**47 *48 * @author bcivel49 */50@WebServlet(name = "UpdateBuildRevisionParameters", urlPatterns = {"/UpdateBuildRevisionParameters"})51public class UpdateBuildRevisionParameters extends HttpServlet {52 private static final Logger LOG = LogManager.getLogger(UpdateBuildRevisionParameters.class);53 private final String OBJECT_NAME = "BuildRevisionParameters";54 /**55 * Processes requests for both HTTP <code>GET</code> and <code>POST</code>56 * methods.57 *58 * @param request servlet request59 * @param response servlet response60 * @throws ServletException if a servlet-specific error occurs61 * @throws IOException if an I/O error occurs62 */63 protected void processRequest(HttpServletRequest request, HttpServletResponse response)64 throws ServletException, IOException, CerberusException, JSONException {65 JSONObject jsonResponse = new JSONObject();66 ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());67 ILogEventService logEventService = appContext.getBean(LogEventService.class);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 // Parameter that we cannot secure as we need the html --> We DECODE them87 88 Integer brpid = 0;89 String[] myId = request.getParameterValues("id");90 StringBuilder output_message = new StringBuilder();91 int massErrorCounter = 0;92 for (String myId1 : myId) {93 brpid = 0;94 boolean brpid_error = true;95 try {96 if (myId1 != null && !myId1.equals("")) {97 brpid = Integer.valueOf(policy.sanitize(myId1));98 brpid_error = false;99 }100 } catch (Exception ex) {101 brpid_error = true;102 }103 /**104 * Checking all constrains before calling the services.105 */106 if (brpid_error) {107 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_EXPECTED);108 msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME)109 .replace("%OPERATION%", "Update")110 .replace("%REASON%", "Could not manage to convert id to an integer value or id is missing."));111 ans.setResultMessage(msg);112 massErrorCounter++;113 output_message.append("<br>id : ").append(myId1).append(" - ").append(msg.getDescription());114 } else {115 /**116 * All data seems cleans so we can call the services.117 */118 IBuildRevisionParametersService brpService = appContext.getBean(IBuildRevisionParametersService.class);119 AnswerItem resp = brpService.readByKeyTech(brpid);120 if (!(resp.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode()) && resp.getItem()!=null)) {121 /**122 * Object could not be found. We stop here and report the123 * error.124 */125 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_EXPECTED);126 msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME)127 .replace("%OPERATION%", "Update")128 .replace("%REASON%", "BuildRevisionParameters does not exist."));129 ans.setResultMessage(msg);130 massErrorCounter++;131 output_message.append("<br>id : ").append(myId1).append(" - ").append(msg.getDescription());132 } else {133 /**134 * The service was able to perform the query and confirm the135 * object exist, then we can update it.136 */137 BuildRevisionParameters brpData = (BuildRevisionParameters) resp.getItem();138 /**139 * Before updating, we check that the old entry can be140 * modified. If old entry point to a build/revision that141 * already been deployed, we cannot update it.142 */143 if (brpService.check_buildRevisionAlreadyUsed(brpData.getApplication(), brpData.getBuild(), brpData.getRevision())) {144 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_EXPECTED);145 msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME)146 .replace("%OPERATION%", "Update")147 .replace("%REASON%", "Could not update this release as its original build " + brpData.getBuild() + " revision " + brpData.getRevision() + " has already been deployed in an environment."));148 ans.setResultMessage(msg);149 massErrorCounter++;150 output_message.append("<br>id : ").append(myId1).append(" - ").append(msg.getDescription());151 } else {152 brpData.setBuild(ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("build"), brpData.getBuild(), charset));153 brpData.setRevision(ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("revision"), brpData.getRevision(), charset));154 brpData.setRelease(ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("release"), brpData.getRelease(), charset));155 brpData.setApplication(ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("application"), brpData.getApplication(), charset));156 brpData.setProject(ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("project"), brpData.getProject(), charset));157 brpData.setTicketIdFixed(ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("ticketidfixed"), brpData.getTicketIdFixed(), charset));158 brpData.setBugIdFixed(ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("bugidfixed"), brpData.getBugIdFixed(), charset));159 brpData.setLink(ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("link"), brpData.getLink(), charset));160 brpData.setReleaseOwner(ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("releaseowner"), brpData.getReleaseOwner(), charset));161 brpData.setSubject(ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("subject"), brpData.getSubject(), charset));162 brpData.setJenkinsBuildId(ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("jenkinsbuildid"), brpData.getJenkinsBuildId(), charset));163 brpData.setMavenGroupId(ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("mavengroupid"), brpData.getMavenGroupId(), charset));164 brpData.setMavenArtifactId(ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("mavenartifactid"), brpData.getMavenArtifactId(), charset));165 brpData.setMavenVersion(ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("mavenversion"), brpData.getMavenVersion(), charset));166 brpData.setRepositoryUrl(ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("repositoryurl"), brpData.getRepositoryUrl(), charset));167 ans = brpService.update(brpData);168 if (ans.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode())) {169 /**170 * Update was successful. Adding Log entry.171 */172 logEventService.createForPrivateCalls("/UpdateBuildRevisionParameters", "UPDATE", "Updated BuildRevisionParameters : ['" + brpid + "'|'" + build + "'|'" + revision + "'|'" + release + "']", request);173 } else {174 massErrorCounter++;175 output_message.append("<br>id : ").append(myId1).append(" - ").append(ans.getResultMessage().getDescription());176 }177 }178 }179 }180 }181 if (myId.length > 1) {182 if (massErrorCounter == myId.length) { // All updates are in ERROR.183 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_EXPECTED);184 msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME)185 .replace("%OPERATION%", "Mass Update")186 .replace("%REASON%", massErrorCounter + " objects(s) out of " + myId.length + " failed to update due to an issue.<br>") + output_message.toString());187 ans.setResultMessage(msg);188 } else if (massErrorCounter > 0) { // At least 1 update in error189 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_WARNING);190 msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME)191 .replace("%OPERATION%", "Mass Update")192 .replace("%REASON%", massErrorCounter + " objects(s) out of " + myId.length + " failed to update due to an issue.<br>") + output_message.toString());193 ans.setResultMessage(msg);194 } else { // No error detected.195 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);196 msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME)197 .replace("%OPERATION%", "Mass Update") + "\n\nAll " + myId.length + " object(s) updated successfuly.");198 ans.setResultMessage(msg);199 }200 logEventService.createForPrivateCalls("/UpdateBuildRevisionParameters", "MASSUPDATE", msg.getDescription(), request);201 }202 /**203 * Formating and returning the json result.204 */205 jsonResponse.put("messageType", ans.getResultMessage().getMessage().getCodeString());206 jsonResponse.put("message", ans.getResultMessage().getDescription());207 response.getWriter().print(jsonResponse);208 response.getWriter().flush();209 }210 // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">211 /**212 * Handles the HTTP <code>GET</code> method.213 *214 * @param request servlet request...

Full Screen

Full Screen

UpdateBuildRevisionParameters

Using AI Code Generation

copy

Full Screen

1import org.cerberus.servlet.crud.buildrevisionchange.UpdateBuildRevisionParameters;2import org.cerberus.servlet.crud.buildrevisionchange.UpdateBuildRevisionParameters;3UpdateBuildRevisionParameters updateBuildRevisionParameters = new UpdateBuildRevisionParameters();4updateBuildRevisionParameters.setBuild("1.0.0");5updateBuildRevisionParameters.setRevision("1234");6updateBuildRevisionParameters.setChain("QA");7updateBuildRevisionParameters.setEnvironment("QA");8updateBuildRevisionParameters.setCountry("FR");9updateBuildRevisionParameters.setApplication("MyApplication");10updateBuildRevisionParameters.setRobot("MyRobot");11updateBuildRevisionParameters.setRobotDecli("MyRobotDecli");12updateBuildRevisionParameters.setRobotIP("

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 methods in UpdateBuildRevisionParameters

Test Your Web Or Mobile Apps On 3000+ Browsers

Signup for free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful