View Javadoc
1 /* 2 * Demosys. 3 * 4 * Terms of license - http://opensource.org/licenses/apachepl.php 5 */ 6 package org.demosys.web.user.action; 7 import javax.servlet.http.HttpServletRequest; 8 import javax.servlet.http.HttpServletResponse; 9 import org.apache.struts.action.*; 10 import org.demosys.web.ServiceLocator; 11 import org.demosys.web.user.DuplicateUserException; 12 import org.demosys.web.user.InvalidUserException; 13 import org.demosys.web.user.UserService; 14 /*** 15 */ 16 public class NewUserAction extends Action { 17 public ActionForward execute(ActionMapping mapping, ActionForm objForm, 18 HttpServletRequest req, HttpServletResponse res) { 19 UserForm form = (UserForm)objForm; 20 try { 21 UserService userService = ServiceLocator.getServiceLocator().getUserService(); 22 userService.newUser(form.toUserView()); 23 } 24 catch (DuplicateUserException e) { 25 ActionErrors errors = new ActionErrors(); 26 errors.add("id", new ActionError("user.control.user.already.exist")); 27 saveErrors(req, errors); 28 return mapping.findForward("failure"); 29 } 30 catch (InvalidUserException e) { 31 saveErrors(req, e.getErrors()); 32 return mapping.findForward("failure"); 33 } 34 35 return mapping.findForward("success"); 36 } 37 }

This page was automatically generated by Maven