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

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

Source:CreateApplication.java Github

copy

Full Screen

...47/**48 *49 * @author bcivel50 */51@WebServlet(name = "CreateApplication", urlPatterns = {"/CreateApplication"})52public class CreateApplication extends HttpServlet {53 private static final Logger LOG = LogManager.getLogger(CreateApplication.class);54 55 /**56 * Processes requests for both HTTP <code>GET</code> and <code>POST</code>57 * methods.58 *59 * @param request servlet request60 * @param response servlet response61 * @throws ServletException if a servlet-specific error occurs62 * @throws IOException if an I/O error occurs63 * @throws org.cerberus.exception.CerberusException64 * @throws org.json.JSONException65 */66 protected void processRequest(HttpServletRequest request, HttpServletResponse response)67 throws ServletException, IOException, CerberusException, JSONException {68 JSONObject jsonResponse = new JSONObject();69 Answer ans = new Answer();70 MessageEvent msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);71 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", ""));72 ans.setResultMessage(msg);73 PolicyFactory policy = Sanitizers.FORMATTING.and(Sanitizers.LINKS);74 String charset = request.getCharacterEncoding();75 response.setContentType("application/json");76 // Calling Servlet Transversal Util.77 ServletUtil.servletStart(request);78 79 /**80 * Parsing and securing all required parameters.81 */82 // Parameter that are already controled by GUI (no need to decode) --> We SECURE them83 String system = policy.sanitize(request.getParameter("system"));84 String type = policy.sanitize(request.getParameter("type"));85 String deployType = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("deploytype"), "", charset);86 // Parameter that needs to be secured --> We SECURE+DECODE them87 String application = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("application"), null, charset);88 String subSystem = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("subsystem"), "", charset);89 String mavenGpID = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("mavengroupid"), "", charset);90 String description = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("description"), "", charset);91 // Parameter that we cannot secure as we need the html --> We DECODE them92 String svnURL = ParameterParserUtil.parseStringParamAndDecode(request.getParameter("svnurl"), "", charset);93 String bugTrackerURL = ParameterParserUtil.parseStringParamAndDecode(request.getParameter("bugtrackerurl"), "", charset);94 String newBugURL = ParameterParserUtil.parseStringParamAndDecode(request.getParameter("bugtrackernewurl"), "", charset);95 Integer sort = 10;96 boolean sort_error = false;97 try {98 if (request.getParameter("sort") != null && !request.getParameter("sort").equals("")) {99 sort = Integer.valueOf(policy.sanitize(request.getParameter("sort")));100 }101 } catch (Exception ex) {102 sort_error = true;103 }104 /**105 * Checking all constrains before calling the services.106 */107 if (StringUtil.isNullOrEmpty(application)) {108 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_EXPECTED);109 msg.setDescription(msg.getDescription().replace("%ITEM%", "Application")110 .replace("%OPERATION%", "Create")111 .replace("%REASON%", "Application name is missing!"));112 ans.setResultMessage(msg);113 } else if (StringUtil.isNullOrEmpty(system)) {114 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_EXPECTED);115 msg.setDescription(msg.getDescription().replace("%ITEM%", "Application")116 .replace("%OPERATION%", "Create")117 .replace("%REASON%", "System is missing!"));118 ans.setResultMessage(msg);119 } else if (sort_error) {120 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_EXPECTED);121 msg.setDescription(msg.getDescription().replace("%ITEM%", "Application")122 .replace("%OPERATION%", "Create")123 .replace("%REASON%", "Could not manage to convert sort to an integer value!"));124 ans.setResultMessage(msg);125 } else {126 /**127 * All data seems cleans so we can call the services.128 */129 ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());130 IApplicationService applicationService = appContext.getBean(IApplicationService.class);131 IFactoryApplication factoryApplication = appContext.getBean(IFactoryApplication.class);132 Application applicationData = factoryApplication.create(application, description, sort, type, system, 133 subSystem, svnURL, deployType, mavenGpID, bugTrackerURL, newBugURL, request.getRemoteUser(), null, null, null);134 ans = applicationService.create(applicationData);135 if (ans.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode())) {136 /**137 * Object created. Adding Log entry.138 */139 ILogEventService logEventService = appContext.getBean(LogEventService.class);140 logEventService.createForPrivateCalls("/CreateApplication", "CREATE", "Create Application : ['" + application + "']", request);141 }142 }143 /**144 * Formating and returning the json result.145 */146 jsonResponse.put("messageType", ans.getResultMessage().getMessage().getCodeString());147 jsonResponse.put("message", ans.getResultMessage().getDescription());148 response.getWriter().print(jsonResponse);149 response.getWriter().flush();150 }151 // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">152 /**153 * Handles the HTTP <code>GET</code> method.154 *...

Full Screen

Full Screen

CreateApplication

Using AI Code Generation

copy

Full Screen

1import org.cerberus.servlet.crud.countryenvironment.CreateApplication;2import org.cerberus.servlet.crud.countryenvironment.UpdateApplication;3import org.cerberus.servlet.crud.countryenvironment.DeleteApplication;4import org.cerberus.servlet.crud.countryenvironment.ReadApplication;5import org.cerberus.servlet.crud.countryenvironment.CreateCountry;6import org.cerberus.servlet.crud.countryenvironment.UpdateCountry;7import org.cerberus.servlet.crud.countryenvironment.DeleteCountry;8import org.cerberus.servlet.crud.countryenvironment.ReadCountry;9import org.cerberus.servlet.crud.countryenvironment.CreateEnvironment;10import org.cerberus.servlet.crud.countryenvironment.UpdateEnvironment;11import org.cerberus.servlet.crud.countryenvironment.DeleteEnvironment;12import org.cerberus.servlet.crud.countryenvironment.ReadEnvironment;13import org.cerberus.servlet.crud.countryenvironment.CreateCountryEnvironmentParameters;14import org.cerberus.servlet.crud.countryenvironment.UpdateCountryEnvironmentParameters;15import org.cerberus.servlet.crud.countryenvironment.DeleteCountryEnvironmentParameters;16import org.cerberus.servlet.crud.countryenvironment.ReadCountryEnvironmentParameters;17import org.cerberus.servlet.crud.system.CreateSystem;18import org.cerberus.servlet.crud.system.UpdateSystem;19import org.cerberus.servlet.crud.system.DeleteSystem;20import org.cerberus.servlet.crud.system.ReadSystem;21import org.cerberus.servlet.crud.system.CreateSystemDatabase;22import org.cerberus.servlet.crud.system.UpdateSystemDatabase;23import org.cerberus.servlet.crud.system.DeleteSystemDatabase;24import org.cerberus.servlet.crud.system.ReadSystemDatabase;25import org.cerberus.servlet.crud.system.CreateSystemCountry;26import org.cerberus.servlet.crud.system.UpdateSystemCountry;27import org.cerberus.servlet.crud

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 CreateApplication

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