Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/RegisterAction.java =================================================================== diff -u -r5e7a73abd66a04cf44dfac630322dcfa958a396f -ra6a4ed61ecf23c10bc18e4c1435dfe6f8b8855f6 --- lams_admin/src/java/org/lamsfoundation/lams/admin/web/RegisterAction.java (.../RegisterAction.java) (revision 5e7a73abd66a04cf44dfac630322dcfa958a396f) +++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/RegisterAction.java (.../RegisterAction.java) (revision a6a4ed61ecf23c10bc18e4c1435dfe6f8b8855f6) @@ -48,72 +48,72 @@ /** * ConfigAction - * + * * @author Mitchell Seaton */ /** * struts doclets * - * @struts.action path="/register" parameter="method" name="RegisterForm" input=".register" scope="request" validate="false" + * @struts.action path="/register" parameter="method" name="RegisterForm" + * input=".register" scope="request" validate="false" * @struts.action-forward name="register" path=".register" * @struts.action-forward name="sysadmin" path="/sysadminstart.do" - * @struts.action-forward name="success" path="http://lamscommunity.org/registration" + * @struts.action-forward name="success" + * path="http://lamscommunity.org/registration" * @struts.action-forward name="error" path=".error" */ public class RegisterAction extends LamsDispatchAction { + private static final Logger log = Logger.getLogger(RegisterAction.class); + private static IUserManagementService service; - private static final Logger log = Logger.getLogger(RegisterAction.class); - private static IUserManagementService service; - - public ActionForward unspecified(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws Exception{ - - // check permission - if(!request.isUserInRole(Role.SYSADMIN)){ - request.setAttribute("errorName","RegisterAction"); - request.setAttribute("errorMessage",AdminServiceProxy.getMessageService(getServlet().getServletContext()) - .getMessage("error.authorisation")); - return mapping.findForward("error"); - } - - service = AdminServiceProxy.getService(getServlet().getServletContext()); - - DynaActionForm registerForm = (DynaActionForm) form; - - /** Set Server Configuration details in dyna form */ - registerForm.set("serverurl", Configuration.get(ConfigurationKeys.SERVER_URL)); - registerForm.set("serverversion", Configuration.get(ConfigurationKeys.VERSION)); - registerForm.set("serverbuild", Configuration.get(ConfigurationKeys.SERVER_VERSION_NUMBER)); - registerForm.set("serverlocale", Configuration.get(ConfigurationKeys.SERVER_LANGUAGE)); - registerForm.set("langdate", Configuration.get(ConfigurationKeys.DICTIONARY_DATE_CREATED)); - - /** Set user details for registration */ - UserDTO sysadmin = (UserDTO) SessionManager.getSession().getAttribute(AttributeNames.USER); - - registerForm.set("rname", sysadmin.getFirstName() + " " + sysadmin.getLastName()); - registerForm.set("remail", sysadmin.getEmail()); - - /** Get Server statistics for registration */ - List groups = service.findByProperty(Organisation.class,"organisationType.organisationTypeId",OrganisationType.COURSE_TYPE); - List subgroups = service.findByProperty(Organisation.class,"organisationType.organisationTypeId",OrganisationType.CLASS_TYPE); - - /** Set statistics in dyna form */ - registerForm.set("groupno", Integer.valueOf(groups.size())); - registerForm.set("subgroupno", Integer.valueOf(subgroups.size())); - registerForm.set("sysadminno", service.getCountRoleForSystem(Role.ROLE_SYSADMIN)); - registerForm.set("adminno", service.getCountRoleForSystem(Role.ROLE_GROUP_ADMIN)); - registerForm.set("authorno", service.getCountRoleForSystem(Role.ROLE_AUTHOR)); - registerForm.set("monitorno", service.getCountRoleForSystem(Role.ROLE_MONITOR)); - registerForm.set("managerno", service.getCountRoleForSystem(Role.ROLE_GROUP_MANAGER)); - registerForm.set("learnerno", service.getCountRoleForSystem(Role.ROLE_LEARNER)); - registerForm.set("authoradminno", service.getCountRoleForSystem(Role.ROLE_AUTHOR_ADMIN)); - registerForm.set("userno", Integer.valueOf(service.findAll(User.class).size())); - - - return mapping.findForward("register"); + public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws Exception { + + // check permission + if (!request.isUserInRole(Role.SYSADMIN)) { + request.setAttribute("errorName", "RegisterAction"); + request.setAttribute("errorMessage", AdminServiceProxy.getMessageService(getServlet().getServletContext()) + .getMessage("error.authorisation")); + return mapping.findForward("error"); } - + + service = AdminServiceProxy.getService(getServlet().getServletContext()); + + DynaActionForm registerForm = (DynaActionForm) form; + + /** Set Server Configuration details in dyna form */ + registerForm.set("serverurl", Configuration.get(ConfigurationKeys.SERVER_URL)); + registerForm.set("serverversion", Configuration.get(ConfigurationKeys.VERSION)); + registerForm.set("serverbuild", Configuration.get(ConfigurationKeys.SERVER_VERSION_NUMBER)); + registerForm.set("serverlocale", Configuration.get(ConfigurationKeys.SERVER_LANGUAGE)); + registerForm.set("langdate", Configuration.get(ConfigurationKeys.DICTIONARY_DATE_CREATED)); + + /** Set user details for registration */ + UserDTO sysadmin = (UserDTO) SessionManager.getSession().getAttribute(AttributeNames.USER); + + registerForm.set("rname", sysadmin.getFirstName() + " " + sysadmin.getLastName()); + registerForm.set("remail", sysadmin.getEmail()); + + /** Get Server statistics for registration */ + List groups = service.findByProperty(Organisation.class, "organisationType.organisationTypeId", + OrganisationType.COURSE_TYPE); + List subgroups = service.findByProperty(Organisation.class, "organisationType.organisationTypeId", + OrganisationType.CLASS_TYPE); + + /** Set statistics in dyna form */ + registerForm.set("groupno", Integer.valueOf(groups.size())); + registerForm.set("subgroupno", Integer.valueOf(subgroups.size())); + registerForm.set("sysadminno", service.getCountRoleForSystem(Role.ROLE_SYSADMIN)); + registerForm.set("adminno", service.getCountRoleForSystem(Role.ROLE_GROUP_ADMIN)); + registerForm.set("authorno", service.getCountRoleForSystem(Role.ROLE_AUTHOR)); + registerForm.set("monitorno", service.getCountRoleForSystem(Role.ROLE_MONITOR)); + registerForm.set("managerno", service.getCountRoleForSystem(Role.ROLE_GROUP_MANAGER)); + registerForm.set("learnerno", service.getCountRoleForSystem(Role.ROLE_LEARNER)); + registerForm.set("authoradminno", service.getCountRoleForSystem(Role.ROLE_AUTHOR_ADMIN)); + registerForm.set("userno", Integer.valueOf(service.findAll(User.class).size())); + + return mapping.findForward("register"); + } + }