@Test public final void testProcessOther() { try { HttpServletRequest aReq = new MockHttpServletRequest(); SiteManager siteManager = new MockSiteManagerImpl(testFile); testInstance.setSiteManager(siteManager); Site site = siteManager.getSite(9000L, true); List<Annotation> list = createAnnotationList(); assertFalse(checkSortedList(list)); site.setAnnotations(list); SiteEditorContext ctx = new SiteEditorContext(site); aReq.getSession().setAttribute(SiteController.EDITOR_CONTEXT, ctx); HttpServletResponse aResp = new MockHttpServletResponse(); SiteCommand aCmd = new SiteCommand(); TabbedController tc = new SiteController(); TabConfig tabConfig = new TabConfig(); tabConfig.setViewName("site"); List<Tab> tabs = getTabList(siteManager); tabConfig.setTabs(tabs); tc.setTabConfig(tabConfig); Tab currentTab = tabs.get(0); aCmd.setCmdAction(SiteCommand.ACTION_ADD_NOTE); aCmd.setAnnotation("A note"); BindException aErrors = new BindException(aCmd, aCmd.getCmdAction()); int numAnnotations = site.getAnnotations().size(); ModelAndView mav = testInstance.processOther(tc, currentTab, aReq, aResp, aCmd, aErrors); assertTrue(mav != null); assertTrue(mav.getViewName().equals("site")); assertTrue(((TabStatus)mav.getModel().get("tabStatus")).getCurrentTab().getPageId().equals("GENERAL")); int listSize = site.getAnnotations().size(); assertTrue(listSize > 0); int noteIndex = 0; assertTrue(site.getAnnotations().size() == (numAnnotations+1)); assertTrue(site.getAnnotations().get(noteIndex).getNote().equals("A note")); assertTrue(checkSortedList(site.getAnnotations())); currentTab = tabs.get(0); aCmd.setCmdAction(SiteCommand.ACTION_MODIFY_NOTE); aCmd.setAnnotation("A new note"); aCmd.setAnnotationIndex(noteIndex); aErrors = new BindException(aCmd, aCmd.getCmdAction()); mav = testInstance.processOther(tc, currentTab, aReq, aResp, aCmd, aErrors); assertTrue(mav != null); assertTrue(mav.getViewName().equals("site")); assertTrue(((TabStatus)mav.getModel().get("tabStatus")).getCurrentTab().getPageId().equals("GENERAL")); listSize = site.getAnnotations().size(); assertTrue(listSize > 0); int newNoteIndex = 0; assertTrue(newNoteIndex == noteIndex); assertTrue(site.getAnnotations().size() == (numAnnotations+1)); assertFalse(site.getAnnotations().get(noteIndex).getNote().equals("A note")); assertTrue(site.getAnnotations().get(noteIndex).getNote().equals("A new note")); assertTrue(checkSortedList(site.getAnnotations())); currentTab = tabs.get(0); aCmd.setCmdAction(SiteCommand.ACTION_DELETE_NOTE); aCmd.setAnnotationIndex(noteIndex); aErrors = new BindException(aCmd, aCmd.getCmdAction()); mav = testInstance.processOther(tc, currentTab, aReq, aResp, aCmd, aErrors); assertTrue(mav != null); assertTrue(mav.getViewName().equals("site")); assertTrue(((TabStatus)mav.getModel().get("tabStatus")).getCurrentTab().getPageId().equals("GENERAL")); int newListSize = site.getAnnotations().size(); assertTrue(newListSize == (listSize-1)); assertTrue(site.getAnnotations().size() == numAnnotations); assertTrue(checkSortedList(site.getAnnotations())); } catch(Exception e) { fail(e.getMessage()); } }
public ModelAndView processOther(TabbedController tc, Tab currentTab, HttpServletRequest req, HttpServletResponse res, Object comm, BindException errors) { SiteCommand sc = (SiteCommand) comm; SiteEditorContext ctx = getEditorContext(req); if(errors.hasErrors()) { Tab tab = tc.getTabConfig().getTabByID("GENERAL"); TabbedModelAndView tmav = tab.getTabHandler().preProcessNextTab(tc, tab, req, res, comm ,errors); tmav.getTabStatus().setCurrentTab(tab); tmav.addObject(Constants.GBL_ERRORS, errors); return tmav; } processTab(tc, currentTab, req, res, comm, errors); Site site = ctx.getSite(); if(sc.isAction(SiteCommand.ACTION_MODIFY_NOTE)) { Annotation annotation = site.getAnnotation(sc.getAnnotationIndex()); if(annotation != null && annotation.getUser().equals(AuthUtil.getRemoteUserObject())) { annotation.setDate(new Date()); annotation.setNote(sc.getAnnotation()); } } else if(sc.isAction(SiteCommand.ACTION_DELETE_NOTE)) { Annotation annotation = site.getAnnotation(sc.getAnnotationIndex()); if(annotation != null && annotation.getUser().equals(AuthUtil.getRemoteUserObject())) { site.deleteAnnotation(sc.getAnnotationIndex()); } } bindEditorContext(req, ctx); TabbedModelAndView tmav = preProcessNextTab(tc, tc.getTabConfig().getTabByID("GENERAL"), req, res, comm, errors); tmav.getTabStatus().setCurrentTab(tc.getTabConfig().getTabByID("GENERAL")); return tmav; }
SiteGeneralHandler extends AbstractSiteHandler { public ModelAndView processOther(TabbedController tc, Tab currentTab, HttpServletRequest req, HttpServletResponse res, Object comm, BindException errors) { SiteCommand sc = (SiteCommand) comm; SiteEditorContext ctx = getEditorContext(req); if(errors.hasErrors()) { Tab tab = tc.getTabConfig().getTabByID("GENERAL"); TabbedModelAndView tmav = tab.getTabHandler().preProcessNextTab(tc, tab, req, res, comm ,errors); tmav.getTabStatus().setCurrentTab(tab); tmav.addObject(Constants.GBL_ERRORS, errors); return tmav; } processTab(tc, currentTab, req, res, comm, errors); Site site = ctx.getSite(); if(sc.isAction(SiteCommand.ACTION_MODIFY_NOTE)) { Annotation annotation = site.getAnnotation(sc.getAnnotationIndex()); if(annotation != null && annotation.getUser().equals(AuthUtil.getRemoteUserObject())) { annotation.setDate(new Date()); annotation.setNote(sc.getAnnotation()); } } else if(sc.isAction(SiteCommand.ACTION_DELETE_NOTE)) { Annotation annotation = site.getAnnotation(sc.getAnnotationIndex()); if(annotation != null && annotation.getUser().equals(AuthUtil.getRemoteUserObject())) { site.deleteAnnotation(sc.getAnnotationIndex()); } } bindEditorContext(req, ctx); TabbedModelAndView tmav = preProcessNextTab(tc, tc.getTabConfig().getTabByID("GENERAL"), req, res, comm, errors); tmav.getTabStatus().setCurrentTab(tc.getTabConfig().getTabByID("GENERAL")); return tmav; } }
SiteGeneralHandler extends AbstractSiteHandler { public ModelAndView processOther(TabbedController tc, Tab currentTab, HttpServletRequest req, HttpServletResponse res, Object comm, BindException errors) { SiteCommand sc = (SiteCommand) comm; SiteEditorContext ctx = getEditorContext(req); if(errors.hasErrors()) { Tab tab = tc.getTabConfig().getTabByID("GENERAL"); TabbedModelAndView tmav = tab.getTabHandler().preProcessNextTab(tc, tab, req, res, comm ,errors); tmav.getTabStatus().setCurrentTab(tab); tmav.addObject(Constants.GBL_ERRORS, errors); return tmav; } processTab(tc, currentTab, req, res, comm, errors); Site site = ctx.getSite(); if(sc.isAction(SiteCommand.ACTION_MODIFY_NOTE)) { Annotation annotation = site.getAnnotation(sc.getAnnotationIndex()); if(annotation != null && annotation.getUser().equals(AuthUtil.getRemoteUserObject())) { annotation.setDate(new Date()); annotation.setNote(sc.getAnnotation()); } } else if(sc.isAction(SiteCommand.ACTION_DELETE_NOTE)) { Annotation annotation = site.getAnnotation(sc.getAnnotationIndex()); if(annotation != null && annotation.getUser().equals(AuthUtil.getRemoteUserObject())) { site.deleteAnnotation(sc.getAnnotationIndex()); } } bindEditorContext(req, ctx); TabbedModelAndView tmav = preProcessNextTab(tc, tc.getTabConfig().getTabByID("GENERAL"), req, res, comm, errors); tmav.getTabStatus().setCurrentTab(tc.getTabConfig().getTabByID("GENERAL")); return tmav; }  }
SiteGeneralHandler extends AbstractSiteHandler { public ModelAndView processOther(TabbedController tc, Tab currentTab, HttpServletRequest req, HttpServletResponse res, Object comm, BindException errors) { SiteCommand sc = (SiteCommand) comm; SiteEditorContext ctx = getEditorContext(req); if(errors.hasErrors()) { Tab tab = tc.getTabConfig().getTabByID("GENERAL"); TabbedModelAndView tmav = tab.getTabHandler().preProcessNextTab(tc, tab, req, res, comm ,errors); tmav.getTabStatus().setCurrentTab(tab); tmav.addObject(Constants.GBL_ERRORS, errors); return tmav; } processTab(tc, currentTab, req, res, comm, errors); Site site = ctx.getSite(); if(sc.isAction(SiteCommand.ACTION_MODIFY_NOTE)) { Annotation annotation = site.getAnnotation(sc.getAnnotationIndex()); if(annotation != null && annotation.getUser().equals(AuthUtil.getRemoteUserObject())) { annotation.setDate(new Date()); annotation.setNote(sc.getAnnotation()); } } else if(sc.isAction(SiteCommand.ACTION_DELETE_NOTE)) { Annotation annotation = site.getAnnotation(sc.getAnnotationIndex()); if(annotation != null && annotation.getUser().equals(AuthUtil.getRemoteUserObject())) { site.deleteAnnotation(sc.getAnnotationIndex()); } } bindEditorContext(req, ctx); TabbedModelAndView tmav = preProcessNextTab(tc, tc.getTabConfig().getTabByID("GENERAL"), req, res, comm, errors); tmav.getTabStatus().setCurrentTab(tc.getTabConfig().getTabByID("GENERAL")); return tmav; }  void processTab(TabbedController tc, Tab currentTab, HttpServletRequest req,
			HttpServletResponse res, Object comm, BindException errors); TabbedModelAndView preProcessNextTab(TabbedController tc, Tab nextTab,
			HttpServletRequest req, HttpServletResponse res, Object comm,
			BindException errors); ModelAndView processOther(TabbedController tc, Tab currentTab, HttpServletRequest req,
			HttpServletResponse res, Object comm, BindException errors); void bindEditorContext(HttpServletRequest req, SiteEditorContext context); void setSiteManager(SiteManager siteManager); }
SiteGeneralHandler extends AbstractSiteHandler { public ModelAndView processOther(TabbedController tc, Tab currentTab, HttpServletRequest req, HttpServletResponse res, Object comm, BindException errors) { SiteCommand sc = (SiteCommand) comm; SiteEditorContext ctx = getEditorContext(req); if(errors.hasErrors()) { Tab tab = tc.getTabConfig().getTabByID("GENERAL"); TabbedModelAndView tmav = tab.getTabHandler().preProcessNextTab(tc, tab, req, res, comm ,errors); tmav.getTabStatus().setCurrentTab(tab); tmav.addObject(Constants.GBL_ERRORS, errors); return tmav; } processTab(tc, currentTab, req, res, comm, errors); Site site = ctx.getSite(); if(sc.isAction(SiteCommand.ACTION_MODIFY_NOTE)) { Annotation annotation = site.getAnnotation(sc.getAnnotationIndex()); if(annotation != null && annotation.getUser().equals(AuthUtil.getRemoteUserObject())) { annotation.setDate(new Date()); annotation.setNote(sc.getAnnotation()); } } else if(sc.isAction(SiteCommand.ACTION_DELETE_NOTE)) { Annotation annotation = site.getAnnotation(sc.getAnnotationIndex()); if(annotation != null && annotation.getUser().equals(AuthUtil.getRemoteUserObject())) { site.deleteAnnotation(sc.getAnnotationIndex()); } } bindEditorContext(req, ctx); TabbedModelAndView tmav = preProcessNextTab(tc, tc.getTabConfig().getTabByID("GENERAL"), req, res, comm, errors); tmav.getTabStatus().setCurrentTab(tc.getTabConfig().getTabByID("GENERAL")); return tmav; }  void processTab(TabbedController tc, Tab currentTab, HttpServletRequest req,
			HttpServletResponse res, Object comm, BindException errors); TabbedModelAndView preProcessNextTab(TabbedController tc, Tab nextTab,
			HttpServletRequest req, HttpServletResponse res, Object comm,
			BindException errors); ModelAndView processOther(TabbedController tc, Tab currentTab, HttpServletRequest req,
			HttpServletResponse res, Object comm, BindException errors); void bindEditorContext(HttpServletRequest req, SiteEditorContext context); void setSiteManager(SiteManager siteManager);  }