@Test public final void testEditButtonVisiblity2() { try { MockHttpServletRequest request = new MockHttpServletRequest(); MockHttpServletResponse response = new MockHttpServletResponse(); DefaultCommand comm = new DefaultCommand(); comm.setMode(DefaultCommand.MODE_VIEW); comm.setTargetGroupOid(15000L); TargetGroup aTargetGroup = manager.loadGroup(comm .getTargetGroupOid(), true); removeCurrentUserPrivilege(Privilege.SCOPE_AGENCY, Privilege.CREATE_GROUP); assertFalse(authorityManager.hasPrivilege(aTargetGroup, Privilege.CREATE_GROUP)); addCurrentUserPrivilege(Privilege.SCOPE_ALL, Privilege.CREATE_GROUP); assertTrue(authorityManager.hasPrivilege(aTargetGroup, Privilege.CREATE_GROUP)); BindException aError = new BindException(new DefaultSiteCommand(), null); ModelAndView mav = testInstance.showForm(request, response, comm, aError); assertTrue((Boolean) request.getSession().getAttribute( Constants.GBL_SESS_CAN_EDIT)); } catch (Exception e) { String message = e.getClass().toString() + " - " + e.getMessage(); log.debug(message); fail(message); } }
@Override protected ModelAndView showForm(HttpServletRequest req, HttpServletResponse res, Object comm, BindException errors) throws Exception { DefaultCommand command = (DefaultCommand) comm; if( command != null && command.getTargetGroupOid() != null) { TargetGroup aTargetGroup = targetManager.loadGroup(command.getTargetGroupOid(), true); if(command.isCopyMode()) { TargetGroup newGroup = targetManager.copy(aTargetGroup); GroupsEditorContext ctx = new GroupsEditorContext(newGroup, true); bindEditorContext(req, ctx); } else { GroupsEditorContext ctx = new GroupsEditorContext(aTargetGroup, command.isEditMode()); ctx.setCanEdit(false); if (!command.isEditMode()) { if (authorityManager.hasPrivilege(aTargetGroup,Privilege.CREATE_GROUP)) { ctx.setCanEdit(true); } } bindEditorContext(req, ctx); } } else { TargetGroup aTargetGroup = businessObjectFactory.newTargetGroup(); GroupsEditorContext ctx = new GroupsEditorContext(aTargetGroup, true); bindEditorContext(req, ctx); } Tab general = getTabConfig().getTabByID("GENERAL"); TabbedModelAndView tmav = general.getTabHandler().preProcessNextTab(this, general, req, res, null, errors); tmav.getTabStatus().setCurrentTab(general); return tmav; }
TabbedGroupController extends TabbedController { @Override protected ModelAndView showForm(HttpServletRequest req, HttpServletResponse res, Object comm, BindException errors) throws Exception { DefaultCommand command = (DefaultCommand) comm; if( command != null && command.getTargetGroupOid() != null) { TargetGroup aTargetGroup = targetManager.loadGroup(command.getTargetGroupOid(), true); if(command.isCopyMode()) { TargetGroup newGroup = targetManager.copy(aTargetGroup); GroupsEditorContext ctx = new GroupsEditorContext(newGroup, true); bindEditorContext(req, ctx); } else { GroupsEditorContext ctx = new GroupsEditorContext(aTargetGroup, command.isEditMode()); ctx.setCanEdit(false); if (!command.isEditMode()) { if (authorityManager.hasPrivilege(aTargetGroup,Privilege.CREATE_GROUP)) { ctx.setCanEdit(true); } } bindEditorContext(req, ctx); } } else { TargetGroup aTargetGroup = businessObjectFactory.newTargetGroup(); GroupsEditorContext ctx = new GroupsEditorContext(aTargetGroup, true); bindEditorContext(req, ctx); } Tab general = getTabConfig().getTabByID("GENERAL"); TabbedModelAndView tmav = general.getTabHandler().preProcessNextTab(this, general, req, res, null, errors); tmav.getTabStatus().setCurrentTab(general); return tmav; } }
TabbedGroupController extends TabbedController { @Override protected ModelAndView showForm(HttpServletRequest req, HttpServletResponse res, Object comm, BindException errors) throws Exception { DefaultCommand command = (DefaultCommand) comm; if( command != null && command.getTargetGroupOid() != null) { TargetGroup aTargetGroup = targetManager.loadGroup(command.getTargetGroupOid(), true); if(command.isCopyMode()) { TargetGroup newGroup = targetManager.copy(aTargetGroup); GroupsEditorContext ctx = new GroupsEditorContext(newGroup, true); bindEditorContext(req, ctx); } else { GroupsEditorContext ctx = new GroupsEditorContext(aTargetGroup, command.isEditMode()); ctx.setCanEdit(false); if (!command.isEditMode()) { if (authorityManager.hasPrivilege(aTargetGroup,Privilege.CREATE_GROUP)) { ctx.setCanEdit(true); } } bindEditorContext(req, ctx); } } else { TargetGroup aTargetGroup = businessObjectFactory.newTargetGroup(); GroupsEditorContext ctx = new GroupsEditorContext(aTargetGroup, true); bindEditorContext(req, ctx); } Tab general = getTabConfig().getTabByID("GENERAL"); TabbedModelAndView tmav = general.getTabHandler().preProcessNextTab(this, general, req, res, null, errors); tmav.getTabStatus().setCurrentTab(general); return tmav; }  }
TabbedGroupController extends TabbedController { @Override protected ModelAndView showForm(HttpServletRequest req, HttpServletResponse res, Object comm, BindException errors) throws Exception { DefaultCommand command = (DefaultCommand) comm; if( command != null && command.getTargetGroupOid() != null) { TargetGroup aTargetGroup = targetManager.loadGroup(command.getTargetGroupOid(), true); if(command.isCopyMode()) { TargetGroup newGroup = targetManager.copy(aTargetGroup); GroupsEditorContext ctx = new GroupsEditorContext(newGroup, true); bindEditorContext(req, ctx); } else { GroupsEditorContext ctx = new GroupsEditorContext(aTargetGroup, command.isEditMode()); ctx.setCanEdit(false); if (!command.isEditMode()) { if (authorityManager.hasPrivilege(aTargetGroup,Privilege.CREATE_GROUP)) { ctx.setCanEdit(true); } } bindEditorContext(req, ctx); } } else { TargetGroup aTargetGroup = businessObjectFactory.newTargetGroup(); GroupsEditorContext ctx = new GroupsEditorContext(aTargetGroup, true); bindEditorContext(req, ctx); } Tab general = getTabConfig().getTabByID("GENERAL"); TabbedModelAndView tmav = general.getTabHandler().preProcessNextTab(this, general, req, res, null, errors); tmav.getTabStatus().setCurrentTab(general); return tmav; }  void bindEditorContext(HttpServletRequest req, GroupsEditorContext context); void unbindEditorContext(HttpServletRequest req); GroupsEditorContext getEditorContext(HttpServletRequest req); void setTargetManager(TargetManager targetManager); void setBusinessObjectFactory(BusinessObjectFactory businessObjectFactory); void setSearchController(GroupSearchController searchController); void setMessageSource(MessageSource messageSource); void setAuthorityManager(AuthorityManager authorityManager); }
TabbedGroupController extends TabbedController { @Override protected ModelAndView showForm(HttpServletRequest req, HttpServletResponse res, Object comm, BindException errors) throws Exception { DefaultCommand command = (DefaultCommand) comm; if( command != null && command.getTargetGroupOid() != null) { TargetGroup aTargetGroup = targetManager.loadGroup(command.getTargetGroupOid(), true); if(command.isCopyMode()) { TargetGroup newGroup = targetManager.copy(aTargetGroup); GroupsEditorContext ctx = new GroupsEditorContext(newGroup, true); bindEditorContext(req, ctx); } else { GroupsEditorContext ctx = new GroupsEditorContext(aTargetGroup, command.isEditMode()); ctx.setCanEdit(false); if (!command.isEditMode()) { if (authorityManager.hasPrivilege(aTargetGroup,Privilege.CREATE_GROUP)) { ctx.setCanEdit(true); } } bindEditorContext(req, ctx); } } else { TargetGroup aTargetGroup = businessObjectFactory.newTargetGroup(); GroupsEditorContext ctx = new GroupsEditorContext(aTargetGroup, true); bindEditorContext(req, ctx); } Tab general = getTabConfig().getTabByID("GENERAL"); TabbedModelAndView tmav = general.getTabHandler().preProcessNextTab(this, general, req, res, null, errors); tmav.getTabStatus().setCurrentTab(general); return tmav; }  void bindEditorContext(HttpServletRequest req, GroupsEditorContext context); void unbindEditorContext(HttpServletRequest req); GroupsEditorContext getEditorContext(HttpServletRequest req); void setTargetManager(TargetManager targetManager); void setBusinessObjectFactory(BusinessObjectFactory businessObjectFactory); void setSearchController(GroupSearchController searchController); void setMessageSource(MessageSource messageSource); void setAuthorityManager(AuthorityManager authorityManager); static final String EDITOR_CONTEXT; }