How to use create method of org.cerberus.crud.factory.impl.FactoryUserRole class

Best Cerberus-source code snippet using org.cerberus.crud.factory.impl.FactoryUserRole.create

Source:UpdateUser.java Github

copy

Full Screen

...66 }67 68 @Override69 protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, IndexOutOfBoundsException {70 //TODO create class Validator to validate all parameter from page71 JSONObject jsonResponse = new JSONObject();72 MessageEvent msg1 = new MessageEvent(MessageEventEnum.GENERIC_OK);73 Answer ans = new Answer();74 Answer finalAnswer = new Answer(msg1);75 MessageEvent msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);76 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", ""));77 ans.setResultMessage(msg);78 79 String id = request.getParameter("id");80 String login = request.getParameter("login");81 String name = request.getParameter("name");82 String email = request.getParameter("email");83 String team = request.getParameter("team");84 String systems = request.getParameter("systems");85 String requests = request.getParameter("request");86 String roles = request.getParameter("roles");87 String apiKey = request.getParameter("apiKey");88 String att01 = request.getParameter("attribute01");89 String att02 = request.getParameter("attribute02");90 String att03 = request.getParameter("attribute03");91 String att04 = request.getParameter("attribute04");92 String att05 = request.getParameter("attribute05");93 String comment = request.getParameter("comment");94 String defaultSystem = request.getParameter("defaultSystem");95 96 if (StringUtil.isNullOrEmpty(login) || StringUtil.isNullOrEmpty(id)) {97 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_EXPECTED);98 msg.setDescription(msg.getDescription().replace("%ITEM%", "User")99 .replace("%OPERATION%", "Update")100 .replace("%REASON%", "User login is missing."));101 ans.setResultMessage(msg);102 103 } else {104 LOG.info("Updating user " + login);105 106 ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());107 IUserService userService = appContext.getBean(UserService.class);108 IUserRoleService userRoleService = appContext.getBean(UserRoleService.class);109 IFactoryUserSystem userSystemFactory = appContext.getBean(IFactoryUserSystem.class);110 IUserSystemService userSystemService = appContext.getBean(IUserSystemService.class);111 112 IFactoryUserRole factoryRole = new FactoryUserRole();113 114 User myUser;115 List<UserRole> newRoles = null;116 List<UserSystem> newSystems = null;117 try {118 myUser = userService.findUserByKey(id);119 120 List<String> listRole = new ArrayList<>();121 JSONArray GroupArray = new JSONArray(request.getParameter("roles"));122 for (int i = 0; i < GroupArray.length(); i++) {123 listRole.add(GroupArray.getString(i));124 }125 126 newRoles = new ArrayList<>();127 for (String role : listRole) {128 newRoles.add(factoryRole.create(role));129 }130 131 myUser.setLogin(login);132 myUser.setName(name);133 myUser.setTeam(team);134 myUser.setAttribute01(att01);135 myUser.setAttribute02(att02);136 myUser.setAttribute03(att03);137 myUser.setAttribute04(att04);138 myUser.setAttribute05(att05);139 myUser.setApiKey(apiKey);140 myUser.setComment(comment);141 myUser.setUsrModif(request.getRemoteUser());142 newSystems = new ArrayList<>();143 144 JSONArray SystemArray = new JSONArray(request.getParameter("systems"));145 146 List<String> listSystem = new ArrayList<>();147 for (int i = 0; i < SystemArray.length(); i++) {148 listSystem.add(SystemArray.getString(i));149 }150 151 for (String system : listSystem) {152 newSystems.add(userSystemFactory.create(login, system));153 }154 155 myUser.setDefaultSystem(defaultSystem);156 myUser.setRequest(requests);157 myUser.setEmail(email);158 159 try {160 161 ans = userService.update(myUser);162 finalAnswer = AnswerUtil.agregateAnswer(finalAnswer, ans);163 164 if (ans.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode())) {165 /**166 * Update was successful. Adding Log entry.167 */168 ILogEventService logEventService = appContext.getBean(LogEventService.class);169 logEventService.createForPrivateCalls("/UpdateUser", "UPDATE", "Updated user : ['" + login + "']", request);170 171 if (!newRoles.isEmpty()) {172 userRoleService.updateUserRoles(myUser, newRoles);173 }174 175 if (!newSystems.isEmpty()) {176 request.getSession().setAttribute("MySystem", newSystems.get(0).getSystem());177 userSystemService.updateUserSystems(myUser, newSystems);178 }179 180 }181 /**182 * Adding Log entry.183 */...

Full Screen

Full Screen

create

Using AI Code Generation

copy

Full Screen

1import org.cerberus.crud.entity.UserRole;2import org.cerberus.crud.entity.Role;3import org.cerberus.crud.entity.System;4import org.cerberus.crud.entity.Country;5import org.cerberus.crud.entity.Application;6import org.cerberus.crud.entity.UserSystem;7import org.cerberus.crud.entity.User;8UserRole userRole = factoryUserRole.create("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "60", "61", "62", "63", "64", "65", "66", "67", "68", "69", "70", "71", "72", "73", "74", "75", "76", "77", "78", "79", "80", "81", "82", "83", "84", "85", "86", "87", "88", "89", "90", "91", "92", "93", "94", "95", "96", "97",

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 method in FactoryUserRole

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful