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

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

Source:UpdateCountryEnvParam.java Github

copy

Full Screen

...64/**65 *66 * @author bcivel67 */68@WebServlet(name = "UpdateCountryEnvParam", urlPatterns = {"/UpdateCountryEnvParam"})69public class UpdateCountryEnvParam extends HttpServlet {70 private static final Logger LOG = LogManager.getLogger(UpdateCountryEnvParam.class);71 private final String OBJECT_NAME = "CountryEnvParam";72 @Autowired73 private ICountryEnvironmentParametersService countryEnvironmentParametersService;74 /**75 * Processes requests for both HTTP <code>GET</code> and <code>POST</code>76 * methods.77 *78 * @param request servlet request79 * @param response servlet response80 * @throws ServletException if a servlet-specific error occurs81 * @throws IOException if an I/O error occurs82 */83 protected void processRequest(HttpServletRequest request, HttpServletResponse response)84 throws ServletException, IOException, CerberusException, JSONException {85 JSONObject jsonResponse = new JSONObject();86 ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());87 Answer ans = new Answer();88 MessageEvent msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);89 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", ""));90 ans.setResultMessage(msg);91 PolicyFactory policy = Sanitizers.FORMATTING.and(Sanitizers.LINKS);92 String charset = request.getCharacterEncoding();93 ICountryEnvironmentDatabaseService cebService = appContext.getBean(ICountryEnvironmentDatabaseService.class);94 ICountryEnvironmentParametersService ceaService = appContext.getBean(ICountryEnvironmentParametersService.class);95 ICountryEnvDeployTypeService cedService = appContext.getBean(ICountryEnvDeployTypeService.class);96 ICountryEnvLinkService celService = appContext.getBean(ICountryEnvLinkService.class);97 response.setContentType("application/json");98 // Calling Servlet Transversal Util.99 ServletUtil.servletStart(request);100 /**101 * Parsing and securing all required parameters.102 */103 // Parameter that are already controled by GUI (no need to decode) --> We SECURE them104 String system = policy.sanitize(request.getParameter("system"));105 String country = policy.sanitize(request.getParameter("country"));106 String environment = policy.sanitize(request.getParameter("environment"));107 String type = policy.sanitize(request.getParameter("type"));108 String chain = policy.sanitize(request.getParameter("chain"));109 boolean maintenanceAct = ParameterParserUtil.parseBooleanParam(request.getParameter("maintenanceAct"), true);110 // Parameter that needs to be secured --> We SECURE+DECODE them111 String description = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("description"), "", charset);112 String maintenanceStr = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("maintenanceStr"), "01:00:00", charset);113 String maintenanceEnd = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("maintenanceEnd"), "01:00:00", charset);114 // Parameter that we cannot secure as we need the html --> We DECODE them115 String distribList = ParameterParserUtil.parseStringParamAndDecode(request.getParameter("distribList"), "", charset);116 String eMailBodyRevision = ParameterParserUtil.parseStringParamAndDecode(request.getParameter("eMailBodyRevision"), "", charset);117 String eMailBodyChain = ParameterParserUtil.parseStringParamAndDecode(request.getParameter("eMailBodyChain"), "", charset);118 String eMailBodyDisableEnvironment = ParameterParserUtil.parseStringParamAndDecode(request.getParameter("eMailBodyDisableEnvironment"), "", charset);119 // Getting list of database from JSON Call120 JSONArray objDatabaseArray = new JSONArray(request.getParameter("database"));121 List<CountryEnvironmentDatabase> cebList;122 cebList = getCountryEnvironmentDatabaseFromParameter(request, appContext, system, country, environment, objDatabaseArray);123 // Getting list of application from JSON Call124 JSONArray objApplicationArray = new JSONArray(request.getParameter("application"));125 List<CountryEnvironmentParameters> ceaList;126 ceaList = getCountryEnvironmentApplicationFromParameter(request, appContext, system, country, environment, objApplicationArray);127 // Getting list of database from JSON Call128 JSONArray objDeployTypeArray = new JSONArray(request.getParameter("deployType"));129 List<CountryEnvDeployType> cedList;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 }...

Full Screen

Full Screen

UpdateCountryEnvParam

Using AI Code Generation

copy

Full Screen

1import org.cerberus.servlet.crud.countryenvironment.UpdateCountryEnvParam;2import org.cerberus.servlet.crud.countryenvironment.UpdateCountryEnvParam;3UpdateCountryEnvParam updateCountryEnvParam = new UpdateCountryEnvParam();4updateCountryEnvParam.doPost(request, response);5import org.cerberus.servlet.crud.countryenvironment.UpdateCountryEnvParam;6import org.cerberus.servlet.crud.countryenvironment.UpdateCountryEnvParam;7UpdateCountryEnvParam updateCountryEnvParam = new UpdateCountryEnvParam();8updateCountryEnvParam.doPost(request, response);9import org.cerberus.servlet.crud.countryenvironment.UpdateCountryEnvParam;10import org.cerberus.servlet.crud.countryenvironment.UpdateCountryEnvParam;11UpdateCountryEnvParam updateCountryEnvParam = new UpdateCountryEnvParam();12updateCountryEnvParam.doPost(request, response);13import org.cerberus.servlet.crud.countryenvironment.UpdateCountryEnvParam;14import org.cerberus.servlet.crud.countryenvironment.UpdateCountryEnvParam;15UpdateCountryEnvParam updateCountryEnvParam = new UpdateCountryEnvParam();16updateCountryEnvParam.doPost(request, response);17import org.cerberus.servlet.crud.countryenvironment.UpdateCountryEnvParam;18import org.cerberus.servlet.crud.countryenvironment.UpdateCountryEnvParam;19UpdateCountryEnvParam updateCountryEnvParam = new UpdateCountryEnvParam();20updateCountryEnvParam.doPost(request, response);21import org.cerberus.servlet.crud.countryenvironment.UpdateCountryEnvParam;22import org.cerberus.servlet.crud.countryenvironment.UpdateCountryEnvParam;23UpdateCountryEnvParam updateCountryEnvParam = new UpdateCountryEnvParam();24updateCountryEnvParam.doPost(request, response);25import org.cerberus.servlet.crud.countryenvironment.UpdateCountryEnvParam;26import org.cerberus.servlet.cr

Full Screen

Full Screen

UpdateCountryEnvParam

Using AI Code Generation

copy

Full Screen

1import org.cerberus.servlet.crud.countryenvironment.UpdateCountryEnvParam;2import org.cerberus.util.answer.AnswerItem;3AnswerItem answer = UpdateCountryEnvParam.readByKey("cerberus_countryenvironmentparameters_id");4if (answer.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode())) {5 CountryEnvParam cep = (CountryEnvParam) answer.getItem();6 cep.setValue("NewValue");7 answer = UpdateCountryEnvParam.update(cep);8}9if (answer.isCodeEquals(MessageEventEnum.DATA_OPERATION_NO_DATA.getCode())) {10 CountryEnvParam cep = new CountryEnvParam();11 cep.setSystem("cerberus");12 cep.setCountry("FR");13 cep.setEnvironment("QA");14 cep.setApplication("MyApplication");15 cep.setParam("cerberus_countryenvironmentparameters_id");16 cep.setValue("NewValue");17 answer = UpdateCountryEnvParam.create(cep);18}19if (answer.isCodeEquals(MessageEventEnum.DATA_OPERATION_ERROR.getCode())) {20 String message = answer.getResultMessage().getDescription();21}22if (answer.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode()) || answer.isCodeEquals(MessageEventEnum.DATA_OPERATION_CREATED.getCode())) {23 CountryEnvParam cep = (CountryEnvParam) answer.getItem();24 String value = cep.getValue();25}26if (answer.isCodeEquals(MessageEventEnum.DATA_OPERATION_NO_DATA.getCode()) || answer.isCodeEquals(MessageEventEnum.DATA_OPERATION_ERROR.getCode())) {27 String message = answer.getResultMessage().getDescription();28}

Full Screen

Full Screen

UpdateCountryEnvParam

Using AI Code Generation

copy

Full Screen

1import org.cerberus.servlet.crud.countryenvironment.UpdateCountryEnvParam;2import org.cerberus.crud.entity.CountryEnvironmentParameters;3import org.cerberus.crud.factory.IFactoryCountryEnvironmentParameters;4import org.cerberus.crud.service.ICountryEnvironmentParametersService;5import org.cerberus.crud.service.impl.CountryEnvironmentParametersService;6import org.cerberus.crud.service.impl.FactoryCountryEnvironmentParameters;7import org.cerberus.engine.entity.MessageEvent;8import org.cerberus.engine.entity.MessageGeneral;9import org.cerberus.engine.entity.MessageEventEnum;10import org.cerberus.exception.CerberusException;11import org.cerberus.util.answer.AnswerItem;12import org.cerberus.util.answer.AnswerList;13import org.cerberus.util.answer.AnswerUtil;14import org.springframework.context.ApplicationContext;15import org.springframework.context.support.ClassPathXmlApplicationContext;16ApplicationContext appContext;17ICountryEnvironmentParametersService countryEnvironmentParametersService;18IFactoryCountryEnvironmentParameters factoryCountryEnvironmentParameters;19appContext = new ClassPathXmlApplicationContext("applicationContext.xml");20countryEnvironmentParametersService = appContext.getBean(CountryEnvironmentParametersService.class);21factoryCountryEnvironmentParameters = appContext.getBean(FactoryCountryEnvironmentParameters.class);22String system;23String country;24String environment;25String parameter;26String value;27String type;28String description;29String database;30String active;31String usrCreated;32String usrModif;33String dateCreated;34String dateModif;35String application;36String applicationObject;37String environmentGroup;38String sort;39String dir;40String draw;41String length;42String start;43String column;44String search;45String searchColumn;46String searchOperator;47String searchValue;48String searchValue2;49String searchValue3;50String searchValue4;51String searchValue5;52String searchValue6;53String searchValue7;54String searchValue8;55String searchValue9;56String searchValue10;57String searchValue11;58String searchValue12;59String searchValue13;60String searchValue14;61String searchValue15;62String searchValue16;63String searchValue17;64String searchValue18;65String searchValue19;66String searchValue20;

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.

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