@Test public final void testHandleOther() { try { testSetAuthorityManager(); testSetTargetManager(); testSetGroupsController(); HttpServletRequest request = new MockHttpServletRequest(); HttpServletResponse response = new MockHttpServletResponse(); AddParentsCommand command = new AddParentsCommand(); BindException errors = new BindException(command, "AddMembersCommand"); bindEditorContext(request, 15002L); command.setActionCmd(null); ModelAndView mav = testInstance.handle(request, response, command, errors); assertNotNull(mav); assertEquals(mav.getViewName(), "group-add-parents"); } catch(Exception e) { fail(e.getMessage()); } }
@Override protected ModelAndView handle(HttpServletRequest request, HttpServletResponse response, Object comm, BindException errors) throws Exception { AddParentsCommand command = (AddParentsCommand) comm; TargetGroup target = getEditorContext(request).getTargetGroup(); if( AddParentsCommand.ACTION_ADD_PARENTS.equals(command.getActionCmd())) { List<GroupMemberDTO> parents = getParents(request); GroupMemberDTO newDTO = null; if(command.getParentOids() != null && command.getParentOids().length == 1) { newDTO = targetManager.createGroupMemberDTO(target, command.getParentOids()[0]); newDTO.setSaveState(SAVE_STATE.NEW); if(parents.contains(newDTO)) { String name = newDTO.getParentName(); errors.reject("target.error.duplicate_parent", new Object[] { name }, "This target is already in this group"); } } else { errors.reject("groups.errors.addparents.must_select", null, "You must select a parent group"); } if(errors.hasErrors()) { return doSearch(request, response, comm, errors); } else { Tab generalTab = groupsController.getTabConfig().getTabByID("GENERAL"); TabbedModelAndView tmav = generalTab.getTabHandler().preProcessNextTab(groupsController, generalTab, request, response, command, errors); tmav.getTabStatus().setCurrentTab(generalTab); return tmav; } } else if( AddParentsCommand.ACTION_CANCEL.equals(command.getActionCmd())) { Tab generalTab = groupsController.getTabConfig().getTabByID("GENERAL"); TabbedModelAndView tmav = generalTab.getTabHandler().preProcessNextTab(groupsController, generalTab, request, response, command, errors); tmav.getTabStatus().setCurrentTab(generalTab); return tmav; } else { return doSearch(request, response, comm, errors); } }
AddParentsController extends AbstractCommandController { @Override protected ModelAndView handle(HttpServletRequest request, HttpServletResponse response, Object comm, BindException errors) throws Exception { AddParentsCommand command = (AddParentsCommand) comm; TargetGroup target = getEditorContext(request).getTargetGroup(); if( AddParentsCommand.ACTION_ADD_PARENTS.equals(command.getActionCmd())) { List<GroupMemberDTO> parents = getParents(request); GroupMemberDTO newDTO = null; if(command.getParentOids() != null && command.getParentOids().length == 1) { newDTO = targetManager.createGroupMemberDTO(target, command.getParentOids()[0]); newDTO.setSaveState(SAVE_STATE.NEW); if(parents.contains(newDTO)) { String name = newDTO.getParentName(); errors.reject("target.error.duplicate_parent", new Object[] { name }, "This target is already in this group"); } } else { errors.reject("groups.errors.addparents.must_select", null, "You must select a parent group"); } if(errors.hasErrors()) { return doSearch(request, response, comm, errors); } else { Tab generalTab = groupsController.getTabConfig().getTabByID("GENERAL"); TabbedModelAndView tmav = generalTab.getTabHandler().preProcessNextTab(groupsController, generalTab, request, response, command, errors); tmav.getTabStatus().setCurrentTab(generalTab); return tmav; } } else if( AddParentsCommand.ACTION_CANCEL.equals(command.getActionCmd())) { Tab generalTab = groupsController.getTabConfig().getTabByID("GENERAL"); TabbedModelAndView tmav = generalTab.getTabHandler().preProcessNextTab(groupsController, generalTab, request, response, command, errors); tmav.getTabStatus().setCurrentTab(generalTab); return tmav; } else { return doSearch(request, response, comm, errors); } } }
AddParentsController extends AbstractCommandController { @Override protected ModelAndView handle(HttpServletRequest request, HttpServletResponse response, Object comm, BindException errors) throws Exception { AddParentsCommand command = (AddParentsCommand) comm; TargetGroup target = getEditorContext(request).getTargetGroup(); if( AddParentsCommand.ACTION_ADD_PARENTS.equals(command.getActionCmd())) { List<GroupMemberDTO> parents = getParents(request); GroupMemberDTO newDTO = null; if(command.getParentOids() != null && command.getParentOids().length == 1) { newDTO = targetManager.createGroupMemberDTO(target, command.getParentOids()[0]); newDTO.setSaveState(SAVE_STATE.NEW); if(parents.contains(newDTO)) { String name = newDTO.getParentName(); errors.reject("target.error.duplicate_parent", new Object[] { name }, "This target is already in this group"); } } else { errors.reject("groups.errors.addparents.must_select", null, "You must select a parent group"); } if(errors.hasErrors()) { return doSearch(request, response, comm, errors); } else { Tab generalTab = groupsController.getTabConfig().getTabByID("GENERAL"); TabbedModelAndView tmav = generalTab.getTabHandler().preProcessNextTab(groupsController, generalTab, request, response, command, errors); tmav.getTabStatus().setCurrentTab(generalTab); return tmav; } } else if( AddParentsCommand.ACTION_CANCEL.equals(command.getActionCmd())) { Tab generalTab = groupsController.getTabConfig().getTabByID("GENERAL"); TabbedModelAndView tmav = generalTab.getTabHandler().preProcessNextTab(groupsController, generalTab, request, response, command, errors); tmav.getTabStatus().setCurrentTab(generalTab); return tmav; } else { return doSearch(request, response, comm, errors); } } AddParentsController(); }
AddParentsController extends AbstractCommandController { @Override protected ModelAndView handle(HttpServletRequest request, HttpServletResponse response, Object comm, BindException errors) throws Exception { AddParentsCommand command = (AddParentsCommand) comm; TargetGroup target = getEditorContext(request).getTargetGroup(); if( AddParentsCommand.ACTION_ADD_PARENTS.equals(command.getActionCmd())) { List<GroupMemberDTO> parents = getParents(request); GroupMemberDTO newDTO = null; if(command.getParentOids() != null && command.getParentOids().length == 1) { newDTO = targetManager.createGroupMemberDTO(target, command.getParentOids()[0]); newDTO.setSaveState(SAVE_STATE.NEW); if(parents.contains(newDTO)) { String name = newDTO.getParentName(); errors.reject("target.error.duplicate_parent", new Object[] { name }, "This target is already in this group"); } } else { errors.reject("groups.errors.addparents.must_select", null, "You must select a parent group"); } if(errors.hasErrors()) { return doSearch(request, response, comm, errors); } else { Tab generalTab = groupsController.getTabConfig().getTabByID("GENERAL"); TabbedModelAndView tmav = generalTab.getTabHandler().preProcessNextTab(groupsController, generalTab, request, response, command, errors); tmav.getTabStatus().setCurrentTab(generalTab); return tmav; } } else if( AddParentsCommand.ACTION_CANCEL.equals(command.getActionCmd())) { Tab generalTab = groupsController.getTabConfig().getTabByID("GENERAL"); TabbedModelAndView tmav = generalTab.getTabHandler().preProcessNextTab(groupsController, generalTab, request, response, command, errors); tmav.getTabStatus().setCurrentTab(generalTab); return tmav; } else { return doSearch(request, response, comm, errors); } } AddParentsController(); GroupsEditorContext getEditorContext(HttpServletRequest req); void setGroupsController(TabbedGroupController groupsController); void setTargetManager(TargetManager targetManager); void setAuthorityManager(AuthorityManager authorityManager); }
AddParentsController extends AbstractCommandController { @Override protected ModelAndView handle(HttpServletRequest request, HttpServletResponse response, Object comm, BindException errors) throws Exception { AddParentsCommand command = (AddParentsCommand) comm; TargetGroup target = getEditorContext(request).getTargetGroup(); if( AddParentsCommand.ACTION_ADD_PARENTS.equals(command.getActionCmd())) { List<GroupMemberDTO> parents = getParents(request); GroupMemberDTO newDTO = null; if(command.getParentOids() != null && command.getParentOids().length == 1) { newDTO = targetManager.createGroupMemberDTO(target, command.getParentOids()[0]); newDTO.setSaveState(SAVE_STATE.NEW); if(parents.contains(newDTO)) { String name = newDTO.getParentName(); errors.reject("target.error.duplicate_parent", new Object[] { name }, "This target is already in this group"); } } else { errors.reject("groups.errors.addparents.must_select", null, "You must select a parent group"); } if(errors.hasErrors()) { return doSearch(request, response, comm, errors); } else { Tab generalTab = groupsController.getTabConfig().getTabByID("GENERAL"); TabbedModelAndView tmav = generalTab.getTabHandler().preProcessNextTab(groupsController, generalTab, request, response, command, errors); tmav.getTabStatus().setCurrentTab(generalTab); return tmav; } } else if( AddParentsCommand.ACTION_CANCEL.equals(command.getActionCmd())) { Tab generalTab = groupsController.getTabConfig().getTabByID("GENERAL"); TabbedModelAndView tmav = generalTab.getTabHandler().preProcessNextTab(groupsController, generalTab, request, response, command, errors); tmav.getTabStatus().setCurrentTab(generalTab); return tmav; } else { return doSearch(request, response, comm, errors); } } AddParentsController(); GroupsEditorContext getEditorContext(HttpServletRequest req); void setGroupsController(TabbedGroupController groupsController); void setTargetManager(TargetManager targetManager); void setAuthorityManager(AuthorityManager authorityManager);  }