How to use getCountryEnvironmentLinkFromParameter method of org.cerberus.servlet.crud.countryenvironment.UpdateCountryEnvParam class

Best Cerberus-source code snippet using org.cerberus.servlet.crud.countryenvironment.UpdateCountryEnvParam.getCountryEnvironmentLinkFromParameter

Source:UpdateCountryEnvParam.java Github

copy

Full Screen

...130 cedList = getCountryEnvironmentDeployTypeFromParameter(request, appContext, system, country, environment, objDeployTypeArray);131 // Getting list of database from JSON Call132 JSONArray objDepArray = new JSONArray(request.getParameter("dependencies"));133 List<CountryEnvLink> celList;134 celList = getCountryEnvironmentLinkFromParameter(request, appContext, system, country, environment, objDepArray);135 // Prepare the final answer.136 MessageEvent msg1 = new MessageEvent(MessageEventEnum.GENERIC_OK);137 Answer finalAnswer = new Answer(msg1);138 /**139 * Checking all constrains before calling the services.140 */141 if (StringUtil.isNullOrEmpty(system)) {142 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_EXPECTED);143 msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME)144 .replace("%OPERATION%", "Update")145 .replace("%REASON%", "System is missing"));146 ans.setResultMessage(msg);147 finalAnswer = AnswerUtil.agregateAnswer(finalAnswer, (Answer) ans);148 } else if (StringUtil.isNullOrEmpty(country)) {149 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_EXPECTED);150 msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME)151 .replace("%OPERATION%", "Update")152 .replace("%REASON%", "Country is missing"));153 ans.setResultMessage(msg);154 finalAnswer = AnswerUtil.agregateAnswer(finalAnswer, (Answer) ans);155 } else if (StringUtil.isNullOrEmpty(environment)) {156 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_EXPECTED);157 msg.setDescription(msg.getDescription().replace("%ITEM%", OBJECT_NAME)158 .replace("%OPERATION%", "Update")159 .replace("%REASON%", "Environment is missing"));160 ans.setResultMessage(msg);161 finalAnswer = AnswerUtil.agregateAnswer(finalAnswer, (Answer) ans);162 } else {163 /**164 * All data seems cleans so we can call the services.165 */166 ICountryEnvParamService cepService = appContext.getBean(ICountryEnvParamService.class);167 AnswerItem resp = cepService.readByKey(system, country, environment);168 if (!(resp.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode()) && resp.getItem()!=null)) {169 /**170 * Object could not be found. We stop here and report the error.171 */172 finalAnswer = AnswerUtil.agregateAnswer(finalAnswer, (Answer) resp);173 } else {174 /**175 * The service was able to perform the query and confirm the176 * object exist, then we can update it.177 */178 CountryEnvParam cepData = (CountryEnvParam) resp.getItem();179 cepData.setDescription(description);180 cepData.setDistribList(distribList);181 cepData.seteMailBodyRevision(eMailBodyRevision);182 cepData.setType(type);183 cepData.seteMailBodyChain(eMailBodyChain);184 cepData.seteMailBodyDisableEnvironment(eMailBodyDisableEnvironment);185 if (request.getParameter("maintenanceAct") != null) {186 cepData.setMaintenanceAct(maintenanceAct);187 }188 cepData.setMaintenanceStr(maintenanceStr);189 cepData.setMaintenanceEnd(maintenanceEnd);190 cepData.setChain(chain);191 ans = cepService.update(cepData);192 finalAnswer = AnswerUtil.agregateAnswer(finalAnswer, (Answer) ans);193 if (ans.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode())) {194 /**195 * Update was successful. Adding Log entry.196 */197 ILogEventService logEventService = appContext.getBean(LogEventService.class);198 logEventService.createForPrivateCalls("/UpdateCountryEnvParam", "UPDATE", "Updated CountryEnvParam : ['" + system + "','" + country + "','" + environment + "']", request);199 }200 // Update the Database with the new list.201 ans = cebService.compareListAndUpdateInsertDeleteElements(system, country, environment, cebList);202 finalAnswer = AnswerUtil.agregateAnswer(finalAnswer, (Answer) ans);203 // Update the Database with the new list.204 ans = ceaService.compareListAndUpdateInsertDeleteElements(system, country, environment, ceaList);205 finalAnswer = AnswerUtil.agregateAnswer(finalAnswer, (Answer) ans);206 // Update the Database with the new list.207 ans = cedService.compareListAndUpdateInsertDeleteElements(system, country, environment, cedList);208 finalAnswer = AnswerUtil.agregateAnswer(finalAnswer, (Answer) ans);209 // Update the Database with the new list.210 ans = celService.compareListAndUpdateInsertDeleteElements(system, country, environment, celList);211 finalAnswer = AnswerUtil.agregateAnswer(finalAnswer, (Answer) ans);212 }213 }214 /**215 * Formating and returning the json result.216 */217 jsonResponse.put("messageType", finalAnswer.getResultMessage().getMessage().getCodeString());218 jsonResponse.put("message", finalAnswer.getResultMessage().getDescription());219 response.getWriter().print(jsonResponse);220 response.getWriter().flush();221 }222 private List<CountryEnvironmentDatabase> getCountryEnvironmentDatabaseFromParameter(HttpServletRequest request, ApplicationContext appContext, String system, String country, String environment, JSONArray json) throws JSONException {223 List<CountryEnvironmentDatabase> cebList = new ArrayList();224 IFactoryCountryEnvironmentDatabase cebFactory = appContext.getBean(IFactoryCountryEnvironmentDatabase.class);225 for (int i = 0; i < json.length(); i++) {226 JSONObject tcsaJson = json.getJSONObject(i);227 boolean delete = tcsaJson.getBoolean("toDelete");228 String database = tcsaJson.getString("database");229 String connectionPool = tcsaJson.getString("connectionPoolName");230 String soapUrl = tcsaJson.getString("soapUrl");231 String csvUrl = tcsaJson.getString("csvUrl");232 if (!delete) {233 CountryEnvironmentDatabase ceb = cebFactory.create(system, country, environment, database, connectionPool, soapUrl, csvUrl);234 cebList.add(ceb);235 }236 }237 return cebList;238 }239 private List<CountryEnvironmentParameters> getCountryEnvironmentApplicationFromParameter(HttpServletRequest request, ApplicationContext appContext, String system, String country, String environment, JSONArray json) throws JSONException {240 List<CountryEnvironmentParameters> ceaList = new ArrayList();241 ICountryEnvironmentParametersService ceaService = appContext.getBean(ICountryEnvironmentParametersService.class);242 IFactoryCountryEnvironmentParameters ceaFactory = appContext.getBean(IFactoryCountryEnvironmentParameters.class);243 for (int i = 0; i < json.length(); i++) {244 JSONObject tcsaJson = json.getJSONObject(i);245 boolean delete = tcsaJson.getBoolean("toDelete");246 String application = tcsaJson.getString("application");247 String ip = tcsaJson.getString("ip");248 String domain = tcsaJson.getString("domain");249 String url = tcsaJson.getString("url");250 String urlLogin = tcsaJson.getString("urlLogin");251 String var1 = tcsaJson.getString("var1");252 String var2 = tcsaJson.getString("var2");253 String var3 = tcsaJson.getString("var3");254 String var4 = tcsaJson.getString("var4");255 String strPoolSize = tcsaJson.getString("poolSize");256 int poolSize;257 if (strPoolSize.isEmpty()) {258 poolSize = CountryEnvironmentParameters.DEFAULT_POOLSIZE;259 }260 else {261 try {262 poolSize = Integer.parseInt(strPoolSize);263 } catch (NumberFormatException e) {264 LOG.warn("Unable to parse pool size: " + strPoolSize + ". Applying default value");265 poolSize = CountryEnvironmentParameters.DEFAULT_POOLSIZE;266 }267 }268 if (!delete) {269 CountryEnvironmentParameters cea = ceaFactory.create(system, country, environment, application, ip, domain, url, urlLogin, var1, var2, var3, var4, poolSize);270 ceaList.add(cea);271 }272 }273 return ceaList;274 }275 private List<CountryEnvDeployType> getCountryEnvironmentDeployTypeFromParameter(HttpServletRequest request, ApplicationContext appContext, String system, String country, String environment, JSONArray json) throws JSONException {276 List<CountryEnvDeployType> cedList = new ArrayList();277 IFactoryCountryEnvDeployType cedFactory = appContext.getBean(IFactoryCountryEnvDeployType.class);278 for (int i = 0; i < json.length(); i++) {279 JSONObject tcsaJson = json.getJSONObject(i);280 boolean delete = tcsaJson.getBoolean("toDelete");281 String deployType = tcsaJson.getString("deployType");282 String jenkinsAgent = tcsaJson.getString("jenkinsAgent");283 if (!delete) {284 CountryEnvDeployType ced = cedFactory.create(system, country, environment, deployType, jenkinsAgent);285 cedList.add(ced);286 }287 }288 return cedList;289 }290 private List<CountryEnvLink> getCountryEnvironmentLinkFromParameter(HttpServletRequest request, ApplicationContext appContext, String system, String country, String environment, JSONArray json) throws JSONException {291 List<CountryEnvLink> ceiList = new ArrayList();292 IFactoryCountryEnvLink ceiFactory = appContext.getBean(IFactoryCountryEnvLink.class);293 for (int i = 0; i < json.length(); i++) {294 JSONObject tcsaJson = json.getJSONObject(i);295 boolean delete = tcsaJson.getBoolean("toDelete");296 String systemLink = tcsaJson.getString("systemLink");297 String countryLink = tcsaJson.getString("countryLink");298 String environmentLink = tcsaJson.getString("environmentLink");299 if (!delete) {300 CountryEnvLink cei = ceiFactory.create(system, country, environment, systemLink, countryLink, environmentLink);301 ceiList.add(cei);302 }303 }304 return ceiList;...

Full Screen

Full Screen

getCountryEnvironmentLinkFromParameter

Using AI Code Generation

copy

Full Screen

1import org.cerberus.servlet.crud.countryenvironment.UpdateCountryEnvParam;2import org.cerberus.servlet.crud.countryenvironment.UpdateCountryEnvParam;3String country = request.getParameter("country");4String environment = request.getParameter("environment");5String link = UpdateCountryEnvParam.getCountryEnvironmentLinkFromParameter(country, environment, "param");6response.sendRedirect(link);7package org.cerberus.servlet.crud.countryenvironment;8import java.io.IOException;9import java.io.PrintWriter;10import java.sql.Connection;11import java.sql.ResultSet;12import java.sql.SQLException;13import java.sql.Statement;14import java.util.logging.Level;15import java.util.logging.Logger;16import javax.servlet.ServletException;17import javax.servlet.http.HttpServlet;18import javax.servlet.http.HttpServletRequest;19import javax.servlet.http.HttpServletResponse;20import org.cerberus.database.DatabaseSpring;21import org.cerberus.engine.entity.MessageEvent;22import org.cerberus.engine.entity.MessageGeneral;23import org.cerberus.exception.CerberusException;24import org.cerberus.factory.IFactoryMessage;25import org.cerberus.factory.impl.FactoryMessage;26import org.cerberus.log.MyLogger;27import org.cerberus.service.datalib.IDataLibService;28import org.cerberus.service.datalib.impl.DataLibService;29import org.cerberus.service.database.IDatabaseService;30import org.cerberus.service.database.impl.DatabaseService;31import org.cerberus.util.ParameterParserUtil;32import org.cerberus.version.Infos;33import org.springframework.context.ApplicationContext;34import org.springframework.context.support.ClassPathXmlApplicationContext;35public class UpdateCountryEnvParam extends HttpServlet {36 private static final long serialVersionUID = 1L;

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