@Test public void testDisplayAdminPage() { setUpMockRoleDataService(); setUpMockUserDataService(false, false, false); setUpMockAuthenticationContext(); assertEquals(ADMIN_VIEW_NAME, instance.displayAdminPage( new MockHttpServletRequest(), new MockHttpServletResponse(), new ExtendedModelMap())); }
@RequestMapping(value = TgolKeyStore.ADMIN_URL, method = RequestMethod.GET) @Secured(TgolKeyStore.ROLE_ADMIN_KEY) public String displayAdminPage( HttpServletRequest request, HttpServletResponse response, Model model) { model.addAttribute(TgolKeyStore.USER_LIST_KEY, userDataService.findAll()); if (request.getSession().getAttribute(TgolKeyStore.DELETED_USER_NAME_KEY) != null) { model.addAttribute(TgolKeyStore.DELETED_USER_NAME_KEY, request.getSession().getAttribute(TgolKeyStore.DELETED_USER_NAME_KEY)); request.getSession().removeAttribute(TgolKeyStore.DELETED_USER_NAME_KEY); } if (request.getSession().getAttribute(TgolKeyStore.DELETED_USER_AUDITS_KEY) != null) { model.addAttribute(TgolKeyStore.DELETED_USER_AUDITS_KEY, request.getSession().getAttribute(TgolKeyStore.DELETED_USER_AUDITS_KEY)); request.getSession().removeAttribute(TgolKeyStore.DELETED_USER_AUDITS_KEY); } if (request.getSession().getAttribute(TgolKeyStore.UPDATED_USER_NAME_KEY) != null) { model.addAttribute(TgolKeyStore.UPDATED_USER_NAME_KEY, request.getSession().getAttribute(TgolKeyStore.UPDATED_USER_NAME_KEY)); request.getSession().removeAttribute(TgolKeyStore.UPDATED_USER_NAME_KEY); } if (request.getSession().getAttribute(TgolKeyStore.ADDED_USER_NAME_KEY) != null) { model.addAttribute(TgolKeyStore.ADDED_USER_NAME_KEY, request.getSession().getAttribute(TgolKeyStore.ADDED_USER_NAME_KEY)); request.getSession().removeAttribute(TgolKeyStore.UPDATED_USER_NAME_KEY); } if (request.getSession().getAttribute(TgolKeyStore.ADDED_CONTRACT_NAME_KEY) != null && request.getSession().getAttribute(TgolKeyStore.ADDED_CONTRACT_USERS_NAME_KEY) != null) { model.addAttribute(TgolKeyStore.ADDED_CONTRACT_NAME_KEY, request.getSession().getAttribute(TgolKeyStore.ADDED_CONTRACT_NAME_KEY)); model.addAttribute(TgolKeyStore.ADDED_CONTRACT_USERS_NAME_KEY, request.getSession().getAttribute(TgolKeyStore.ADDED_CONTRACT_USERS_NAME_KEY)); request.getSession().removeAttribute(TgolKeyStore.ADDED_CONTRACT_USERS_NAME_KEY); request.getSession().removeAttribute(TgolKeyStore.ADDED_CONTRACT_NAME_KEY); } return TgolKeyStore.ADMIN_VIEW_NAME; }
UserManagementController extends AbstractUserAndContractsController { @RequestMapping(value = TgolKeyStore.ADMIN_URL, method = RequestMethod.GET) @Secured(TgolKeyStore.ROLE_ADMIN_KEY) public String displayAdminPage( HttpServletRequest request, HttpServletResponse response, Model model) { model.addAttribute(TgolKeyStore.USER_LIST_KEY, userDataService.findAll()); if (request.getSession().getAttribute(TgolKeyStore.DELETED_USER_NAME_KEY) != null) { model.addAttribute(TgolKeyStore.DELETED_USER_NAME_KEY, request.getSession().getAttribute(TgolKeyStore.DELETED_USER_NAME_KEY)); request.getSession().removeAttribute(TgolKeyStore.DELETED_USER_NAME_KEY); } if (request.getSession().getAttribute(TgolKeyStore.DELETED_USER_AUDITS_KEY) != null) { model.addAttribute(TgolKeyStore.DELETED_USER_AUDITS_KEY, request.getSession().getAttribute(TgolKeyStore.DELETED_USER_AUDITS_KEY)); request.getSession().removeAttribute(TgolKeyStore.DELETED_USER_AUDITS_KEY); } if (request.getSession().getAttribute(TgolKeyStore.UPDATED_USER_NAME_KEY) != null) { model.addAttribute(TgolKeyStore.UPDATED_USER_NAME_KEY, request.getSession().getAttribute(TgolKeyStore.UPDATED_USER_NAME_KEY)); request.getSession().removeAttribute(TgolKeyStore.UPDATED_USER_NAME_KEY); } if (request.getSession().getAttribute(TgolKeyStore.ADDED_USER_NAME_KEY) != null) { model.addAttribute(TgolKeyStore.ADDED_USER_NAME_KEY, request.getSession().getAttribute(TgolKeyStore.ADDED_USER_NAME_KEY)); request.getSession().removeAttribute(TgolKeyStore.UPDATED_USER_NAME_KEY); } if (request.getSession().getAttribute(TgolKeyStore.ADDED_CONTRACT_NAME_KEY) != null && request.getSession().getAttribute(TgolKeyStore.ADDED_CONTRACT_USERS_NAME_KEY) != null) { model.addAttribute(TgolKeyStore.ADDED_CONTRACT_NAME_KEY, request.getSession().getAttribute(TgolKeyStore.ADDED_CONTRACT_NAME_KEY)); model.addAttribute(TgolKeyStore.ADDED_CONTRACT_USERS_NAME_KEY, request.getSession().getAttribute(TgolKeyStore.ADDED_CONTRACT_USERS_NAME_KEY)); request.getSession().removeAttribute(TgolKeyStore.ADDED_CONTRACT_USERS_NAME_KEY); request.getSession().removeAttribute(TgolKeyStore.ADDED_CONTRACT_NAME_KEY); } return TgolKeyStore.ADMIN_VIEW_NAME; } }
UserManagementController extends AbstractUserAndContractsController { @RequestMapping(value = TgolKeyStore.ADMIN_URL, method = RequestMethod.GET) @Secured(TgolKeyStore.ROLE_ADMIN_KEY) public String displayAdminPage( HttpServletRequest request, HttpServletResponse response, Model model) { model.addAttribute(TgolKeyStore.USER_LIST_KEY, userDataService.findAll()); if (request.getSession().getAttribute(TgolKeyStore.DELETED_USER_NAME_KEY) != null) { model.addAttribute(TgolKeyStore.DELETED_USER_NAME_KEY, request.getSession().getAttribute(TgolKeyStore.DELETED_USER_NAME_KEY)); request.getSession().removeAttribute(TgolKeyStore.DELETED_USER_NAME_KEY); } if (request.getSession().getAttribute(TgolKeyStore.DELETED_USER_AUDITS_KEY) != null) { model.addAttribute(TgolKeyStore.DELETED_USER_AUDITS_KEY, request.getSession().getAttribute(TgolKeyStore.DELETED_USER_AUDITS_KEY)); request.getSession().removeAttribute(TgolKeyStore.DELETED_USER_AUDITS_KEY); } if (request.getSession().getAttribute(TgolKeyStore.UPDATED_USER_NAME_KEY) != null) { model.addAttribute(TgolKeyStore.UPDATED_USER_NAME_KEY, request.getSession().getAttribute(TgolKeyStore.UPDATED_USER_NAME_KEY)); request.getSession().removeAttribute(TgolKeyStore.UPDATED_USER_NAME_KEY); } if (request.getSession().getAttribute(TgolKeyStore.ADDED_USER_NAME_KEY) != null) { model.addAttribute(TgolKeyStore.ADDED_USER_NAME_KEY, request.getSession().getAttribute(TgolKeyStore.ADDED_USER_NAME_KEY)); request.getSession().removeAttribute(TgolKeyStore.UPDATED_USER_NAME_KEY); } if (request.getSession().getAttribute(TgolKeyStore.ADDED_CONTRACT_NAME_KEY) != null && request.getSession().getAttribute(TgolKeyStore.ADDED_CONTRACT_USERS_NAME_KEY) != null) { model.addAttribute(TgolKeyStore.ADDED_CONTRACT_NAME_KEY, request.getSession().getAttribute(TgolKeyStore.ADDED_CONTRACT_NAME_KEY)); model.addAttribute(TgolKeyStore.ADDED_CONTRACT_USERS_NAME_KEY, request.getSession().getAttribute(TgolKeyStore.ADDED_CONTRACT_USERS_NAME_KEY)); request.getSession().removeAttribute(TgolKeyStore.ADDED_CONTRACT_USERS_NAME_KEY); request.getSession().removeAttribute(TgolKeyStore.ADDED_CONTRACT_NAME_KEY); } return TgolKeyStore.ADMIN_VIEW_NAME; } UserManagementController(ContractDataService contractDataService,
                                    CreateUserCommandFactory createUserCommandFactory); }
UserManagementController extends AbstractUserAndContractsController { @RequestMapping(value = TgolKeyStore.ADMIN_URL, method = RequestMethod.GET) @Secured(TgolKeyStore.ROLE_ADMIN_KEY) public String displayAdminPage( HttpServletRequest request, HttpServletResponse response, Model model) { model.addAttribute(TgolKeyStore.USER_LIST_KEY, userDataService.findAll()); if (request.getSession().getAttribute(TgolKeyStore.DELETED_USER_NAME_KEY) != null) { model.addAttribute(TgolKeyStore.DELETED_USER_NAME_KEY, request.getSession().getAttribute(TgolKeyStore.DELETED_USER_NAME_KEY)); request.getSession().removeAttribute(TgolKeyStore.DELETED_USER_NAME_KEY); } if (request.getSession().getAttribute(TgolKeyStore.DELETED_USER_AUDITS_KEY) != null) { model.addAttribute(TgolKeyStore.DELETED_USER_AUDITS_KEY, request.getSession().getAttribute(TgolKeyStore.DELETED_USER_AUDITS_KEY)); request.getSession().removeAttribute(TgolKeyStore.DELETED_USER_AUDITS_KEY); } if (request.getSession().getAttribute(TgolKeyStore.UPDATED_USER_NAME_KEY) != null) { model.addAttribute(TgolKeyStore.UPDATED_USER_NAME_KEY, request.getSession().getAttribute(TgolKeyStore.UPDATED_USER_NAME_KEY)); request.getSession().removeAttribute(TgolKeyStore.UPDATED_USER_NAME_KEY); } if (request.getSession().getAttribute(TgolKeyStore.ADDED_USER_NAME_KEY) != null) { model.addAttribute(TgolKeyStore.ADDED_USER_NAME_KEY, request.getSession().getAttribute(TgolKeyStore.ADDED_USER_NAME_KEY)); request.getSession().removeAttribute(TgolKeyStore.UPDATED_USER_NAME_KEY); } if (request.getSession().getAttribute(TgolKeyStore.ADDED_CONTRACT_NAME_KEY) != null && request.getSession().getAttribute(TgolKeyStore.ADDED_CONTRACT_USERS_NAME_KEY) != null) { model.addAttribute(TgolKeyStore.ADDED_CONTRACT_NAME_KEY, request.getSession().getAttribute(TgolKeyStore.ADDED_CONTRACT_NAME_KEY)); model.addAttribute(TgolKeyStore.ADDED_CONTRACT_USERS_NAME_KEY, request.getSession().getAttribute(TgolKeyStore.ADDED_CONTRACT_USERS_NAME_KEY)); request.getSession().removeAttribute(TgolKeyStore.ADDED_CONTRACT_USERS_NAME_KEY); request.getSession().removeAttribute(TgolKeyStore.ADDED_CONTRACT_NAME_KEY); } return TgolKeyStore.ADMIN_VIEW_NAME; } UserManagementController(ContractDataService contractDataService,
                                    CreateUserCommandFactory createUserCommandFactory); @RequestMapping(value = TgolKeyStore.ADMIN_URL, method = RequestMethod.GET) @Secured(TgolKeyStore.ROLE_ADMIN_KEY) String displayAdminPage(
            HttpServletRequest request,
            HttpServletResponse response,
            Model model); @RequestMapping(value = TgolKeyStore.EDIT_USER_URL, method = RequestMethod.GET) @Secured(TgolKeyStore.ROLE_ADMIN_KEY) String displayEditUserAdminPage(
            @RequestParam(TgolKeyStore.USER_ID_KEY) String userId,
            HttpServletRequest request,
            HttpServletResponse response,
            Model model); @RequestMapping(value = TgolKeyStore.ADD_USER_URL, method = RequestMethod.GET) @Secured(TgolKeyStore.ROLE_ADMIN_KEY) String displayAddUserAdminPage(
            HttpServletRequest request,
            HttpServletResponse response,
            Model model); @RequestMapping(value = TgolKeyStore.DELETE_USER_URL, method = RequestMethod.GET) @Secured(TgolKeyStore.ROLE_ADMIN_KEY) String displayDeleteUserPage(
            @RequestParam(TgolKeyStore.USER_ID_KEY) String userId,
            HttpServletRequest request,
            HttpServletResponse response,
            Model model); @RequestMapping(value = TgolKeyStore.DELETE_USER_URL, method = RequestMethod.POST) @Secured(TgolKeyStore.ROLE_ADMIN_KEY) String displayDeleteUserConfirmation(
            HttpServletRequest request,
            HttpServletResponse response,
            Model model); @RequestMapping(value = TgolKeyStore.DELETE_USER_AUDITS_URL, method = RequestMethod.GET) @Secured(TgolKeyStore.ROLE_ADMIN_KEY) String displayDeleteUserAuditsPage(
            @RequestParam(TgolKeyStore.USER_ID_KEY) String userId,
            HttpServletRequest request,
            HttpServletResponse response,
            Model model); @RequestMapping(value = TgolKeyStore.DELETE_USER_AUDITS_URL, method = RequestMethod.POST) @Secured(TgolKeyStore.ROLE_ADMIN_KEY) String displayDeleteUserAuditsConfirmationPage(
            HttpServletRequest request,
            HttpServletResponse response,
            Model model); @RequestMapping(value = TgolKeyStore.ADD_CONTRACT_URL, method = RequestMethod.GET) @Secured(TgolKeyStore.ROLE_ADMIN_KEY) String displayAddContractAdminPage(
            HttpServletRequest request,
            HttpServletResponse response,
            Model model); @RequestMapping(value = TgolKeyStore.ADD_CONTRACT_URL, method = RequestMethod.POST) @Secured(TgolKeyStore.ROLE_ADMIN_KEY) String submitAddContractAdminPage(
            @ModelAttribute(TgolKeyStore.CREATE_CONTRACT_COMMAND_KEY) CreateContractCommand ccc,
            BindingResult result,
            HttpServletRequest request,
            HttpServletResponse response,
            Model model); }
UserManagementController extends AbstractUserAndContractsController { @RequestMapping(value = TgolKeyStore.ADMIN_URL, method = RequestMethod.GET) @Secured(TgolKeyStore.ROLE_ADMIN_KEY) public String displayAdminPage( HttpServletRequest request, HttpServletResponse response, Model model) { model.addAttribute(TgolKeyStore.USER_LIST_KEY, userDataService.findAll()); if (request.getSession().getAttribute(TgolKeyStore.DELETED_USER_NAME_KEY) != null) { model.addAttribute(TgolKeyStore.DELETED_USER_NAME_KEY, request.getSession().getAttribute(TgolKeyStore.DELETED_USER_NAME_KEY)); request.getSession().removeAttribute(TgolKeyStore.DELETED_USER_NAME_KEY); } if (request.getSession().getAttribute(TgolKeyStore.DELETED_USER_AUDITS_KEY) != null) { model.addAttribute(TgolKeyStore.DELETED_USER_AUDITS_KEY, request.getSession().getAttribute(TgolKeyStore.DELETED_USER_AUDITS_KEY)); request.getSession().removeAttribute(TgolKeyStore.DELETED_USER_AUDITS_KEY); } if (request.getSession().getAttribute(TgolKeyStore.UPDATED_USER_NAME_KEY) != null) { model.addAttribute(TgolKeyStore.UPDATED_USER_NAME_KEY, request.getSession().getAttribute(TgolKeyStore.UPDATED_USER_NAME_KEY)); request.getSession().removeAttribute(TgolKeyStore.UPDATED_USER_NAME_KEY); } if (request.getSession().getAttribute(TgolKeyStore.ADDED_USER_NAME_KEY) != null) { model.addAttribute(TgolKeyStore.ADDED_USER_NAME_KEY, request.getSession().getAttribute(TgolKeyStore.ADDED_USER_NAME_KEY)); request.getSession().removeAttribute(TgolKeyStore.UPDATED_USER_NAME_KEY); } if (request.getSession().getAttribute(TgolKeyStore.ADDED_CONTRACT_NAME_KEY) != null && request.getSession().getAttribute(TgolKeyStore.ADDED_CONTRACT_USERS_NAME_KEY) != null) { model.addAttribute(TgolKeyStore.ADDED_CONTRACT_NAME_KEY, request.getSession().getAttribute(TgolKeyStore.ADDED_CONTRACT_NAME_KEY)); model.addAttribute(TgolKeyStore.ADDED_CONTRACT_USERS_NAME_KEY, request.getSession().getAttribute(TgolKeyStore.ADDED_CONTRACT_USERS_NAME_KEY)); request.getSession().removeAttribute(TgolKeyStore.ADDED_CONTRACT_USERS_NAME_KEY); request.getSession().removeAttribute(TgolKeyStore.ADDED_CONTRACT_NAME_KEY); } return TgolKeyStore.ADMIN_VIEW_NAME; } UserManagementController(ContractDataService contractDataService,
                                    CreateUserCommandFactory createUserCommandFactory); @RequestMapping(value = TgolKeyStore.ADMIN_URL, method = RequestMethod.GET) @Secured(TgolKeyStore.ROLE_ADMIN_KEY) String displayAdminPage(
            HttpServletRequest request,
            HttpServletResponse response,
            Model model); @RequestMapping(value = TgolKeyStore.EDIT_USER_URL, method = RequestMethod.GET) @Secured(TgolKeyStore.ROLE_ADMIN_KEY) String displayEditUserAdminPage(
            @RequestParam(TgolKeyStore.USER_ID_KEY) String userId,
            HttpServletRequest request,
            HttpServletResponse response,
            Model model); @RequestMapping(value = TgolKeyStore.ADD_USER_URL, method = RequestMethod.GET) @Secured(TgolKeyStore.ROLE_ADMIN_KEY) String displayAddUserAdminPage(
            HttpServletRequest request,
            HttpServletResponse response,
            Model model); @RequestMapping(value = TgolKeyStore.DELETE_USER_URL, method = RequestMethod.GET) @Secured(TgolKeyStore.ROLE_ADMIN_KEY) String displayDeleteUserPage(
            @RequestParam(TgolKeyStore.USER_ID_KEY) String userId,
            HttpServletRequest request,
            HttpServletResponse response,
            Model model); @RequestMapping(value = TgolKeyStore.DELETE_USER_URL, method = RequestMethod.POST) @Secured(TgolKeyStore.ROLE_ADMIN_KEY) String displayDeleteUserConfirmation(
            HttpServletRequest request,
            HttpServletResponse response,
            Model model); @RequestMapping(value = TgolKeyStore.DELETE_USER_AUDITS_URL, method = RequestMethod.GET) @Secured(TgolKeyStore.ROLE_ADMIN_KEY) String displayDeleteUserAuditsPage(
            @RequestParam(TgolKeyStore.USER_ID_KEY) String userId,
            HttpServletRequest request,
            HttpServletResponse response,
            Model model); @RequestMapping(value = TgolKeyStore.DELETE_USER_AUDITS_URL, method = RequestMethod.POST) @Secured(TgolKeyStore.ROLE_ADMIN_KEY) String displayDeleteUserAuditsConfirmationPage(
            HttpServletRequest request,
            HttpServletResponse response,
            Model model); @RequestMapping(value = TgolKeyStore.ADD_CONTRACT_URL, method = RequestMethod.GET) @Secured(TgolKeyStore.ROLE_ADMIN_KEY) String displayAddContractAdminPage(
            HttpServletRequest request,
            HttpServletResponse response,
            Model model); @RequestMapping(value = TgolKeyStore.ADD_CONTRACT_URL, method = RequestMethod.POST) @Secured(TgolKeyStore.ROLE_ADMIN_KEY) String submitAddContractAdminPage(
            @ModelAttribute(TgolKeyStore.CREATE_CONTRACT_COMMAND_KEY) CreateContractCommand ccc,
            BindingResult result,
            HttpServletRequest request,
            HttpServletResponse response,
            Model model);  }