TargetGeneralHandler extends AbstractTargetTabHandler { public void processTab(TabbedController tc, Tab currentTab, HttpServletRequest req, HttpServletResponse res, Object comm, BindException errors) { TargetGeneralCommand command = (TargetGeneralCommand) comm; TargetEditorContext ctx = getEditorContext(req); Target target = ctx.getTarget(); if(ctx.isEditMode()) { if( authorityManager.hasAtLeastOnePrivilege(target, Privilege.MODIFY_TARGET, Privilege.CREATE_TARGET)) { String previousName = target.getName(); target.setName(command.getName()); target.setDescription(command.getDescription()); target.setReferenceNumber(command.getReference()); target.setRunOnApproval(command.isRunOnApproval()); target.setUseAQA(command.isUseAQA()); target.setAutoPrune(command.isAutoPrune()); target.setAutoDenoteReferenceCrawl(command.isAutoDenoteReferenceCrawl()); target.setRequestToArchivists(command.getRequestToArchivists()); if(previousName == null || !previousName.equals(target.getName())) { DublinCore dc = target.getDublinCoreMetaData(); if(dc == null) { dc = new DublinCore(); dc.setType(target.getOwner().getAgency().getDefaultDescriptionType()); target.setDublinCoreMetaData(dc); } String title = dc.getTitle(); if(title == null || title.isEmpty() || title.equals(previousName)) { dc.setTitle(target.getName()); } } } if( authorityManager.hasAtLeastOnePrivilege(target, Privilege.APPROVE_TARGET, Privilege.CREATE_TARGET, Privilege.MODIFY_TARGET, Privilege.CANCEL_TARGET, Privilege.REINSTATE_TARGET) && targetManager.allowStateChange(target, command.getState())) { target.changeState(command.getState()); if (command.getState()==Target.STATE_REJECTED) { RejReason rejReason = agencyUserManager.getRejReasonByOid(command.getReasonOid()); target.setRejReason(rejReason); } } if(authorityManager.hasPrivilege(target, Privilege.TAKE_OWNERSHIP)) { User newOwner = userRoleDao.getUserByOid(command.getOwnerOid()); if(agencyUserManager.canGiveTo(target, newOwner)) { target.setOwner(newOwner); } } } }  void setUserRoleDao(UserRoleDAO aUserRoleDao); void processTab(TabbedController tc, Tab currentTab,
			HttpServletRequest req, HttpServletResponse res, Object comm,
			BindException errors); TabbedModelAndView preProcessNextTab(TabbedController tc,
			Tab nextTabID, HttpServletRequest req, HttpServletResponse res,
			Object comm, BindException errors); ModelAndView processOther(TabbedController tc, Tab currentTab,
			HttpServletRequest req, HttpServletResponse res, Object comm,
			BindException errors); void setTargetManager(TargetManager targetManager); void setAgencyUserManager(AgencyUserManager agencyUserManager); void setAuthorityManager(AuthorityManager authorityManager); void setAutoQAUrl(String autoQAUrl); String getAutoQAUrl();  }
@Test public final void testProcessTab() { HttpServletRequest aReq = new MockHttpServletRequest(); TargetManager targetManager = new MockTargetManager(testFile); testInstance.setAuthorityManager(new AuthorityManagerImpl()); testInstance.setTargetManager(targetManager); testInstance.setAgencyUserManager(new MockAgencyUserManagerImpl(testFile)); testInstance.setUserRoleDao(new MockUserRoleDAO(testFile)); Target target = targetManager.load(4000L); TargetEditorContext targetEditorContext = new TargetEditorContext(targetManager,target,true); aReq.getSession().setAttribute(TabbedTargetController.EDITOR_CONTEXT, targetEditorContext); HttpServletResponse aResp = new MockHttpServletResponse(); TargetGeneralCommand aCmd = TargetGeneralCommand.buildFromModel(target); TabbedController tc = new TabbedTargetController(); TabConfig tabConfig = new TabConfig(); tabConfig.setViewName("target"); List<Tab> tabs = getTabList(targetManager); tabConfig.setTabs(tabs); tc.setTabConfig(tabConfig); tc.setDefaultCommandClass(org.webcurator.ui.target.command.TargetDefaultCommand.class); Tab currentTab = tabs.get(0); aCmd.setName("TestName"); BindException aErrors = new BindException(aCmd, "TargetGeneralCommand"); assertTrue(target.getDublinCoreMetaData() != null); assertTrue(target.getDublinCoreMetaData().getTitle().isEmpty()); testInstance.processTab(tc, currentTab, aReq, aResp, aCmd, aErrors); assertTrue(target.getName().equals("TestName")); assertTrue(target.getDublinCoreMetaData() != null); assertEquals(target.getDublinCoreMetaData().getTitle(),"TestName"); aCmd.setName("TestName2"); testInstance.processTab(tc, currentTab, aReq, aResp, aCmd, aErrors); assertTrue(target.getName().equals("TestName2")); assertTrue(target.getDublinCoreMetaData() != null); assertEquals(target.getDublinCoreMetaData().getTitle(),"TestName2"); target.getDublinCoreMetaData().setTitle("TestName4"); aCmd.setName("TestName3"); testInstance.processTab(tc, currentTab, aReq, aResp, aCmd, aErrors); assertTrue(target.getName().equals("TestName3")); assertTrue(target.getDublinCoreMetaData() != null); assertEquals(target.getDublinCoreMetaData().getTitle(),"TestName4"); }