@Test public final void testPreProcessNextTab() { HttpServletRequest aReq = new MockHttpServletRequest(); TargetInstanceManager targetInstanceManager = new MockTargetInstanceManager(testFile); testInstance.setTargetInstanceManager(targetInstanceManager); TargetInstance targetInstance = targetInstanceManager.getTargetInstance(5001L); testInstance.setHarvestCoordinator(new MockHarvestCoordinator()); aReq.getSession().setAttribute(TargetInstanceCommand.SESSION_TI, targetInstance); aReq.getSession().setAttribute(TargetInstanceCommand.SESSION_MODE, true); HttpServletResponse aResp = new MockHttpServletResponse(); TargetInstanceCommand aCmd = new TargetInstanceCommand(); aCmd.setCmd(TargetInstanceCommand.ACTION_EDIT); TabbedController tc = new TabbedTargetInstanceController(); TabConfig tabConfig = new TabConfig(); tabConfig.setViewName("targetInstance"); List<Tab> tabs = getTabList(targetInstanceManager); tabConfig.setTabs(tabs); tc.setTabConfig(tabConfig); tc.setDefaultCommandClass(org.webcurator.ui.target.command.TargetInstanceCommand.class); Tab currentTab = tabs.get(1); BindException aErrors = new BindException(aCmd, aCmd.getCmd()); ModelAndView mav = testInstance.preProcessNextTab(tc, currentTab, aReq, aResp, aCmd, aErrors); assertTrue(mav != null); assertNotNull((List<LogFilePropertiesDTO>)mav.getModel().get(TargetInstanceCommand.MDL_LOG_LIST)); List<LogFilePropertiesDTO> logFiles = (List<LogFilePropertiesDTO>)mav.getModel().get(TargetInstanceCommand.MDL_LOG_LIST); assertEquals(3, logFiles.size()); Iterator<LogFilePropertiesDTO> it = logFiles.iterator(); while(it.hasNext()) { LogFilePropertiesDTO logFile = it.next(); if(logFile.getName().startsWith("aqa-report")) { assertEquals("aqa-viewer.html", logFile.getViewer()); } else { assertEquals("log-viewer.html", logFile.getViewer()); } } }
public TabbedModelAndView preProcessNextTab(TabbedController tc, Tab nextTabID, HttpServletRequest req, HttpServletResponse res, Object comm, BindException errors) { TabbedModelAndView tmav = tc.new TabbedModelAndView(); Boolean editMode = false; TargetInstanceCommand cmd = null; TargetInstance ti = null; if (comm instanceof TargetInstanceCommand) { cmd = (TargetInstanceCommand) comm; if (cmd.getCmd().equals(TargetInstanceCommand.ACTION_EDIT)) { editMode = true; } } if (req.getSession().getAttribute(TargetInstanceCommand.SESSION_TI) == null) { ti = targetInstanceManager.getTargetInstance(cmd.getTargetInstanceId(), true); req.getSession().setAttribute(TargetInstanceCommand.SESSION_TI, ti); req.getSession().setAttribute(TargetInstanceCommand.SESSION_MODE, editMode); } else { if (WebUtils.hasSubmitParameter(req, "targetInstanceOid")) { String targetInstanceOid = req.getParameter("targetInstanceOid"); Long targetInstanceId = Long.parseLong(targetInstanceOid); if (!((TargetInstance)req.getSession().getAttribute(TargetInstanceCommand.SESSION_TI)).getOid().equals(targetInstanceId)){ ti = targetInstanceManager.getTargetInstance(targetInstanceId, true); req.getSession().setAttribute(TargetInstanceCommand.SESSION_TI, ti); } } ti = (TargetInstance) req.getSession().getAttribute(TargetInstanceCommand.SESSION_TI); editMode = (Boolean) req.getSession().getAttribute(TargetInstanceCommand.SESSION_MODE); } TargetInstanceCommand populatedCommand = new TargetInstanceCommand(ti); if (editMode) { populatedCommand.setCmd(TargetInstanceCommand.ACTION_EDIT); } LogFilePropertiesDTO[] arrLogs = harvestCoordinator.listLogFileAttributes(ti); List<LogFilePropertiesDTO> logs = new ArrayList<LogFilePropertiesDTO>(); for(int i = 0; i < arrLogs.length; i++) { logs.add(arrLogs[i]); } tmav.addObject(TargetInstanceCommand.MDL_LOG_LIST, logs); tmav.addObject(Constants.GBL_CMD_DATA, populatedCommand); tmav.addObject(TargetInstanceCommand.MDL_INSTANCE, ti); return tmav; }
TargetInstanceLogsHandler extends TabHandler { public TabbedModelAndView preProcessNextTab(TabbedController tc, Tab nextTabID, HttpServletRequest req, HttpServletResponse res, Object comm, BindException errors) { TabbedModelAndView tmav = tc.new TabbedModelAndView(); Boolean editMode = false; TargetInstanceCommand cmd = null; TargetInstance ti = null; if (comm instanceof TargetInstanceCommand) { cmd = (TargetInstanceCommand) comm; if (cmd.getCmd().equals(TargetInstanceCommand.ACTION_EDIT)) { editMode = true; } } if (req.getSession().getAttribute(TargetInstanceCommand.SESSION_TI) == null) { ti = targetInstanceManager.getTargetInstance(cmd.getTargetInstanceId(), true); req.getSession().setAttribute(TargetInstanceCommand.SESSION_TI, ti); req.getSession().setAttribute(TargetInstanceCommand.SESSION_MODE, editMode); } else { if (WebUtils.hasSubmitParameter(req, "targetInstanceOid")) { String targetInstanceOid = req.getParameter("targetInstanceOid"); Long targetInstanceId = Long.parseLong(targetInstanceOid); if (!((TargetInstance)req.getSession().getAttribute(TargetInstanceCommand.SESSION_TI)).getOid().equals(targetInstanceId)){ ti = targetInstanceManager.getTargetInstance(targetInstanceId, true); req.getSession().setAttribute(TargetInstanceCommand.SESSION_TI, ti); } } ti = (TargetInstance) req.getSession().getAttribute(TargetInstanceCommand.SESSION_TI); editMode = (Boolean) req.getSession().getAttribute(TargetInstanceCommand.SESSION_MODE); } TargetInstanceCommand populatedCommand = new TargetInstanceCommand(ti); if (editMode) { populatedCommand.setCmd(TargetInstanceCommand.ACTION_EDIT); } LogFilePropertiesDTO[] arrLogs = harvestCoordinator.listLogFileAttributes(ti); List<LogFilePropertiesDTO> logs = new ArrayList<LogFilePropertiesDTO>(); for(int i = 0; i < arrLogs.length; i++) { logs.add(arrLogs[i]); } tmav.addObject(TargetInstanceCommand.MDL_LOG_LIST, logs); tmav.addObject(Constants.GBL_CMD_DATA, populatedCommand); tmav.addObject(TargetInstanceCommand.MDL_INSTANCE, ti); return tmav; } }
TargetInstanceLogsHandler extends TabHandler { public TabbedModelAndView preProcessNextTab(TabbedController tc, Tab nextTabID, HttpServletRequest req, HttpServletResponse res, Object comm, BindException errors) { TabbedModelAndView tmav = tc.new TabbedModelAndView(); Boolean editMode = false; TargetInstanceCommand cmd = null; TargetInstance ti = null; if (comm instanceof TargetInstanceCommand) { cmd = (TargetInstanceCommand) comm; if (cmd.getCmd().equals(TargetInstanceCommand.ACTION_EDIT)) { editMode = true; } } if (req.getSession().getAttribute(TargetInstanceCommand.SESSION_TI) == null) { ti = targetInstanceManager.getTargetInstance(cmd.getTargetInstanceId(), true); req.getSession().setAttribute(TargetInstanceCommand.SESSION_TI, ti); req.getSession().setAttribute(TargetInstanceCommand.SESSION_MODE, editMode); } else { if (WebUtils.hasSubmitParameter(req, "targetInstanceOid")) { String targetInstanceOid = req.getParameter("targetInstanceOid"); Long targetInstanceId = Long.parseLong(targetInstanceOid); if (!((TargetInstance)req.getSession().getAttribute(TargetInstanceCommand.SESSION_TI)).getOid().equals(targetInstanceId)){ ti = targetInstanceManager.getTargetInstance(targetInstanceId, true); req.getSession().setAttribute(TargetInstanceCommand.SESSION_TI, ti); } } ti = (TargetInstance) req.getSession().getAttribute(TargetInstanceCommand.SESSION_TI); editMode = (Boolean) req.getSession().getAttribute(TargetInstanceCommand.SESSION_MODE); } TargetInstanceCommand populatedCommand = new TargetInstanceCommand(ti); if (editMode) { populatedCommand.setCmd(TargetInstanceCommand.ACTION_EDIT); } LogFilePropertiesDTO[] arrLogs = harvestCoordinator.listLogFileAttributes(ti); List<LogFilePropertiesDTO> logs = new ArrayList<LogFilePropertiesDTO>(); for(int i = 0; i < arrLogs.length; i++) { logs.add(arrLogs[i]); } tmav.addObject(TargetInstanceCommand.MDL_LOG_LIST, logs); tmav.addObject(Constants.GBL_CMD_DATA, populatedCommand); tmav.addObject(TargetInstanceCommand.MDL_INSTANCE, ti); return tmav; }  }
TargetInstanceLogsHandler extends TabHandler { public TabbedModelAndView preProcessNextTab(TabbedController tc, Tab nextTabID, HttpServletRequest req, HttpServletResponse res, Object comm, BindException errors) { TabbedModelAndView tmav = tc.new TabbedModelAndView(); Boolean editMode = false; TargetInstanceCommand cmd = null; TargetInstance ti = null; if (comm instanceof TargetInstanceCommand) { cmd = (TargetInstanceCommand) comm; if (cmd.getCmd().equals(TargetInstanceCommand.ACTION_EDIT)) { editMode = true; } } if (req.getSession().getAttribute(TargetInstanceCommand.SESSION_TI) == null) { ti = targetInstanceManager.getTargetInstance(cmd.getTargetInstanceId(), true); req.getSession().setAttribute(TargetInstanceCommand.SESSION_TI, ti); req.getSession().setAttribute(TargetInstanceCommand.SESSION_MODE, editMode); } else { if (WebUtils.hasSubmitParameter(req, "targetInstanceOid")) { String targetInstanceOid = req.getParameter("targetInstanceOid"); Long targetInstanceId = Long.parseLong(targetInstanceOid); if (!((TargetInstance)req.getSession().getAttribute(TargetInstanceCommand.SESSION_TI)).getOid().equals(targetInstanceId)){ ti = targetInstanceManager.getTargetInstance(targetInstanceId, true); req.getSession().setAttribute(TargetInstanceCommand.SESSION_TI, ti); } } ti = (TargetInstance) req.getSession().getAttribute(TargetInstanceCommand.SESSION_TI); editMode = (Boolean) req.getSession().getAttribute(TargetInstanceCommand.SESSION_MODE); } TargetInstanceCommand populatedCommand = new TargetInstanceCommand(ti); if (editMode) { populatedCommand.setCmd(TargetInstanceCommand.ACTION_EDIT); } LogFilePropertiesDTO[] arrLogs = harvestCoordinator.listLogFileAttributes(ti); List<LogFilePropertiesDTO> logs = new ArrayList<LogFilePropertiesDTO>(); for(int i = 0; i < arrLogs.length; i++) { logs.add(arrLogs[i]); } tmav.addObject(TargetInstanceCommand.MDL_LOG_LIST, logs); tmav.addObject(Constants.GBL_CMD_DATA, populatedCommand); tmav.addObject(TargetInstanceCommand.MDL_INSTANCE, ti); return tmav; }  void initBinder(HttpServletRequest request, ServletRequestDataBinder binder); 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 setHarvestCoordinator(HarvestCoordinator harvestCoordinator); void setTargetInstanceManager(TargetInstanceManager targetInstanceManager); }
TargetInstanceLogsHandler extends TabHandler { public TabbedModelAndView preProcessNextTab(TabbedController tc, Tab nextTabID, HttpServletRequest req, HttpServletResponse res, Object comm, BindException errors) { TabbedModelAndView tmav = tc.new TabbedModelAndView(); Boolean editMode = false; TargetInstanceCommand cmd = null; TargetInstance ti = null; if (comm instanceof TargetInstanceCommand) { cmd = (TargetInstanceCommand) comm; if (cmd.getCmd().equals(TargetInstanceCommand.ACTION_EDIT)) { editMode = true; } } if (req.getSession().getAttribute(TargetInstanceCommand.SESSION_TI) == null) { ti = targetInstanceManager.getTargetInstance(cmd.getTargetInstanceId(), true); req.getSession().setAttribute(TargetInstanceCommand.SESSION_TI, ti); req.getSession().setAttribute(TargetInstanceCommand.SESSION_MODE, editMode); } else { if (WebUtils.hasSubmitParameter(req, "targetInstanceOid")) { String targetInstanceOid = req.getParameter("targetInstanceOid"); Long targetInstanceId = Long.parseLong(targetInstanceOid); if (!((TargetInstance)req.getSession().getAttribute(TargetInstanceCommand.SESSION_TI)).getOid().equals(targetInstanceId)){ ti = targetInstanceManager.getTargetInstance(targetInstanceId, true); req.getSession().setAttribute(TargetInstanceCommand.SESSION_TI, ti); } } ti = (TargetInstance) req.getSession().getAttribute(TargetInstanceCommand.SESSION_TI); editMode = (Boolean) req.getSession().getAttribute(TargetInstanceCommand.SESSION_MODE); } TargetInstanceCommand populatedCommand = new TargetInstanceCommand(ti); if (editMode) { populatedCommand.setCmd(TargetInstanceCommand.ACTION_EDIT); } LogFilePropertiesDTO[] arrLogs = harvestCoordinator.listLogFileAttributes(ti); List<LogFilePropertiesDTO> logs = new ArrayList<LogFilePropertiesDTO>(); for(int i = 0; i < arrLogs.length; i++) { logs.add(arrLogs[i]); } tmav.addObject(TargetInstanceCommand.MDL_LOG_LIST, logs); tmav.addObject(Constants.GBL_CMD_DATA, populatedCommand); tmav.addObject(TargetInstanceCommand.MDL_INSTANCE, ti); return tmav; }  void initBinder(HttpServletRequest request, ServletRequestDataBinder binder); 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 setHarvestCoordinator(HarvestCoordinator harvestCoordinator); void setTargetInstanceManager(TargetInstanceManager targetInstanceManager);  }