How to use getCountryEnvironmentApplicationFromParameter method of org.cerberus.servlet.crud.countryenvironment.UpdateApplication class

Best Cerberus-source code snippet using org.cerberus.servlet.crud.countryenvironment.UpdateApplication.getCountryEnvironmentApplicationFromParameter

Source:UpdateApplication.java Github

copy

Full Screen

...110 }111 // Getting list of application from JSON Call112 JSONArray objApplicationArray = new JSONArray(request.getParameter("environmentList"));113 List<CountryEnvironmentParameters> ceaList = new ArrayList();114 ceaList = getCountryEnvironmentApplicationFromParameter(request, appContext, system, application, objApplicationArray);115 // Prepare the final answer.116 MessageEvent msg1 = new MessageEvent(MessageEventEnum.GENERIC_OK);117 Answer finalAnswer = new Answer(msg1);118 /**119 * Checking all constrains before calling the services.120 */121 if (StringUtil.isNullOrEmpty(application)) {122 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_EXPECTED);123 msg.setDescription(msg.getDescription().replace("%ITEM%", "Application")124 .replace("%OPERATION%", "Update")125 .replace("%REASON%", "Application ID (application) is missing."));126 ans.setResultMessage(msg);127 } else if (StringUtil.isNullOrEmpty(system)) {128 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_EXPECTED);129 msg.setDescription(msg.getDescription().replace("%ITEM%", "Application")130 .replace("%OPERATION%", "Update")131 .replace("%REASON%", "System is missing!"));132 ans.setResultMessage(msg);133 } else if (sort_error) {134 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_EXPECTED);135 msg.setDescription(msg.getDescription().replace("%ITEM%", "Application")136 .replace("%OPERATION%", "Update")137 .replace("%REASON%", "Could not manage to convert sort to an integer value."));138 ans.setResultMessage(msg);139 } else {140 /**141 * All data seems cleans so we can call the services.142 */143 IApplicationService applicationService = appContext.getBean(IApplicationService.class);144 AnswerItem resp = applicationService.readByKey(originalApplication);145 if (!(resp.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode()) && resp.getItem() != null)) {146 /**147 * Object could not be found. We stop here and report the error.148 */149 finalAnswer = AnswerUtil.agregateAnswer(finalAnswer, (Answer) resp);150 } else {151 /**152 * The service was able to perform the query and confirm the153 * object exist, then we can update it.154 */155 Application applicationData = (Application) resp.getItem();156 applicationData.setApplication(application);157 applicationData.setSystem(system);158 applicationData.setSubsystem(subSystem);159 applicationData.setType(type);160 applicationData.setMavengroupid(mavenGpID);161 applicationData.setDeploytype(deployType);162 applicationData.setSvnurl(svnURL);163 applicationData.setBugTrackerUrl(bugTrackerURL);164 applicationData.setBugTrackerNewUrl(newBugURL);165 applicationData.setDescription(description);166 applicationData.setSort(sort);167 applicationData.setUsrModif(request.getRemoteUser());168 ans = applicationService.update(originalApplication, applicationData);169 finalAnswer = AnswerUtil.agregateAnswer(finalAnswer, (Answer) ans);170 if (ans.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode())) {171 /**172 * Update was successful. Adding Log entry.173 */174 ILogEventService logEventService = appContext.getBean(LogEventService.class);175 logEventService.createForPrivateCalls("/UpdateApplication", "UPDATE", "Updated Application : ['" + originalApplication + "']", request);176 // Update the Database with the new list.177 ans = ceaService.compareListAndUpdateInsertDeleteElements(system, application, ceaList);178 finalAnswer = AnswerUtil.agregateAnswer(finalAnswer, (Answer) ans);179 }180 }181 }182 /**183 * Formating and returning the json result.184 */185 jsonResponse.put("messageType", finalAnswer.getResultMessage().getMessage().getCodeString());186 jsonResponse.put("message", finalAnswer.getResultMessage().getDescription());187 response.getWriter().print(jsonResponse);188 response.getWriter().flush();189 }190 private List<CountryEnvironmentParameters> getCountryEnvironmentApplicationFromParameter(HttpServletRequest request, ApplicationContext appContext, String system, String application, JSONArray json) throws JSONException {191 List<CountryEnvironmentParameters> cedList = new ArrayList();192 ICountryEnvironmentParametersService ceaService = appContext.getBean(ICountryEnvironmentParametersService.class);193 IFactoryCountryEnvironmentParameters cedFactory = appContext.getBean(IFactoryCountryEnvironmentParameters.class);194 PolicyFactory policy = Sanitizers.FORMATTING.and(Sanitizers.LINKS);195 String charset = request.getCharacterEncoding();196 for (int i = 0; i < json.length(); i++) {197 JSONObject tcsaJson = json.getJSONObject(i);198 // Parameter that are already controled by GUI (no need to decode) --> We SECURE them199 boolean delete = tcsaJson.getBoolean("toDelete");200 String country = policy.sanitize(tcsaJson.getString("country"));201 String environment = policy.sanitize(tcsaJson.getString("environment"));202 // Parameter that needs to be secured --> We SECURE+DECODE them203 // Parameter that we cannot secure as we need the html --> We DECODE them204 String ip = tcsaJson.getString("ip");...

Full Screen

Full Screen

getCountryEnvironmentApplicationFromParameter

Using AI Code Generation

copy

Full Screen

1String country = request.getParameter("Country");2String environment = request.getParameter("Environment");3String application = request.getParameter("Application");4User user = request.getUserPrincipal();5UpdateApplication.updateApplication(country, environment, application, user);6String page = request.getParameter("page");7response.sendRedirect(page);8public static void updateApplication(String country, String environment, String application, User user) {9 try {10 CountryEnvironmentApplication countryEnvironmentApplication = countryEnvironmentApplicationService.convert(countryEnvironmentApplicationService.readByKey(country, environment, application));11 if (countryEnvironmentApplicationService.hasPermissionsUpdate(countryEnvironmentApplication, user)) {12 countryEnvironmentApplicationService.update(countryEnvironmentApplication);13 }14 } catch (CerberusException e) {15 LOG.error(e.toString(), e);16 }17}

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