List of usage examples for org.springframework.web.servlet ModelAndView getModel
public Map<String, Object> getModel()
From source file:com.zb.app.web.controller.account.AccountCustomerController.java
@RequestMapping(value = "/loglist.htm") public ModelAndView loglist(ModelAndView mav, TravelOperationLogQuery query, Integer page) { query.setNowPageIndex(Argument.isNotPositive(page) ? 0 : page - 1); query.setPageSize(20);/*from w w w .j av a 2s . c o m*/ query.setcId(WebUserTools.getCid()); PaginationList<TravelOperationLogFullDO> list = operationLogService.listPagination(query, new DefaultIpageUrl()); List<TravelOperationLogFullDO> lists = BeanUtils.convert(TravelOperationLogFullDO.class, list); mav.getModel().put(CustomVelocityLayoutView.USE_LAYOUT, "false"); mav.addObject("logList", lists); mav.addObject("pagination", list.getQuery()); mav.setViewName("/account/log/indexlist"); return mav; }
From source file:com.thoughtworks.go.server.controller.GoConfigAdministrationControllerIntegrationTest.java
@Test public void shouldReturnXmlAndErrorMessageWhenInvalidPostOfTemplateAsPartialXml() throws Exception { configHelper.addPipeline("pipeline", "stage", "build1", "build2"); String newXml = "<job name=\"build3\" />"; String md5 = goConfigFileDao.md5OfConfigFile(); ModelAndView mav = controller.postBuildAsXmlPartial("pipeline", "stage", 4, newXml, md5, response); assertThat(response.getStatus(), is(SC_NOT_FOUND)); assertThat(response.getContentType(), is(RESPONSE_CHARSET_JSON)); Json json = (Json) mav.getModel().get("json"); new JsonTester(json).shouldContain( "{ 'result' : 'Build does not exist.'," + " 'originalContent' : '" + newXml + "' }"); }
From source file:com.thoughtworks.go.server.controller.GoConfigAdministrationControllerIntegrationTest.java
@Test public void shouldReturnErrorMessageIfConfigFileChangesBeforePostBuildAsPartialXml() throws Exception { String md5 = goConfigFileDao.md5OfConfigFile(); configHelper.addPipeline("pipeline", "stage", "build1", "build2"); String newXml = "<job name=\"build3\" />"; ModelAndView mav = controller.postBuildAsXmlPartial("pipeline", "stage", 0, newXml, md5, response); assertThat(response.getStatus(), is(SC_CONFLICT)); assertThat(response.getContentType(), is(RESPONSE_CHARSET_JSON)); Json json = (Json) mav.getModel().get("json"); new JsonTester(json) .shouldContain("{ 'result' : '" + ConfigFileHasChangedException.CONFIG_CHANGED_PLEASE_REFRESH + "'," + " 'originalContent' : '" + newXml + "' }"); }
From source file:com.thoughtworks.go.server.controller.GoConfigAdministrationControllerIntegrationTest.java
@Test public void shouldReturnXmlAndErrorMessageWhenInvalidPostOfBuildAsPartialXml() throws Exception { configHelper.addPipeline("pipeline", "stage", "build1", "build2"); String newXml = "<job name=\"build3\" />"; String md5 = goConfigFileDao.md5OfConfigFile(); ModelAndView mav = controller.postBuildAsXmlPartial("pipeline", "stage", 4, newXml, md5, response); assertThat(response.getStatus(), is(SC_NOT_FOUND)); assertThat(response.getContentType(), is(RESPONSE_CHARSET_JSON)); Json json = (Json) mav.getModel().get("json"); new JsonTester(json).shouldContain( "{ 'result' : 'Build does not exist.'," + " 'originalContent' : '" + newXml + "' }"); }
From source file:com.thoughtworks.go.server.controller.GoConfigAdministrationControllerIntegrationTest.java
@Test public void shouldReturnXmlAndErrorMessageWhenPostOfBuildAsInvalidPartialXml() throws Exception { configHelper.addPipeline("pipeline", "stage", "build1", "build2"); String badXml = "<;askldjfa;dsklfja;sdjas;lkdfjob name=\"build3\" />"; String md5 = goConfigFileDao.md5OfConfigFile(); ModelAndView mav = controller.postBuildAsXmlPartial("pipeline", "stage", 0, badXml, md5, response); assertThat(response.getStatus(), is(SC_CONFLICT)); assertThat(response.getContentType(), is(RESPONSE_CHARSET_JSON)); Json json = (Json) mav.getModel().get("json"); new JsonTester(json).shouldContain( "{ 'result' : 'Error on line 1 of document : The markup in the document preceding the root element must be well-formed. Nested exception: The markup in the document preceding the root element must be well-formed.'," + " 'originalContent' : '" + badXml + "' }"); }
From source file:com.thoughtworks.go.server.controller.GoConfigAdministrationControllerIntegrationTest.java
@Test public void shouldReturnErrorMessageWhenPostOfJobContainsDotForExecWorkingDir() throws Exception { configHelper.addPipeline("pipeline", "stage", "build1", "build2"); String badXml = "<job name=\"build3\" >" + "<tasks>" + "<exec command=\"ant\" workingdir=\".\"/>" + "</tasks>" + "</job>"; String md5 = goConfigFileDao.md5OfConfigFile(); ModelAndView mav = controller.postBuildAsXmlPartial("pipeline", "stage", 0, badXml, md5, response); assertThat(response.getStatus(), is(SC_CONFLICT)); assertThat(response.getContentType(), is(RESPONSE_CHARSET_JSON)); Json json = (Json) mav.getModel().get("json"); JsonValue jsonValue = JsonUtils.from(json); assertThat(unescapeJavaScript(jsonValue.getString("originalContent")), is(badXml)); assertThat(unescapeJavaScript(jsonValue.getString("result")), containsString("File path is invalid")); }
From source file:com.thoughtworks.go.server.controller.GoConfigAdministrationControllerIntegrationTest.java
@Test public void shouldReturnXmlAndErrorMessageWhenInvalidPostOfPipelineAsPartialXml() throws Exception { groupName = BasicPipelineConfigs.DEFAULT_GROUP; configHelper.addPipeline("pipeline", "stage", "build1", "build2"); String md5 = goConfigFileDao.md5OfConfigFile(); ModelAndView mav = controller.postPipelineAsXmlPartial(4, groupName, NEW_PIPELINE, md5, response); assertThat(response.getStatus(), is(SC_NOT_FOUND)); assertThat(response.getContentType(), is(RESPONSE_CHARSET_JSON)); Json json = (Json) mav.getModel().get("json"); JsonMap jsonMap = new JsonMap(); jsonMap.put("result", "Pipeline does not exist."); jsonMap.put("originalContent", NEW_PIPELINE); assertThat(json, is((Json) jsonMap)); }
From source file:com.thoughtworks.go.server.controller.GoConfigAdministrationControllerIntegrationTest.java
@Test public void shouldReturnXmlAndErrorMessageWhenPostOfBuildWithDuplicatedNameAsPartialXml() throws Exception { configHelper.addPipeline("pipeline", "stage", "build1", "build2"); String newXml = "<job name=\"build2\" />"; String md5 = goConfigFileDao.md5OfConfigFile(); ModelAndView mav = controller.postBuildAsXmlPartial("pipeline", "stage", 0, newXml, md5, response); assertThat(response.getStatus(), is(SC_CONFLICT)); assertThat(response.getContentType(), is(RESPONSE_CHARSET_JSON)); Json json = (Json) mav.getModel().get("json"); JsonMap expected = new JsonMap(); expected.put("result", "Duplicate unique value [build2] declared for identity constraint \"uniqueJob\" of element \"jobs\"."); expected.put("originalContent", newXml); assertThat(json, is((Json) expected)); }
From source file:com.thoughtworks.go.server.controller.GoConfigAdministrationControllerIntegrationTest.java
@Test public void shouldReturnXmlAndErrorMessageWhenPostOfPipelineAsInvalidPartialXml() throws Exception { groupName = BasicPipelineConfigs.DEFAULT_GROUP; configHelper.addPipeline("pipeline", "stage", "build1", "build2"); String badXml = "<pipeline name=\"cruise\" labeltemplate=\"invalid\">\n" + " <materials>\n" + " <svn url=\"file:///tmp/foo\" checkexternals=\"true\" />\n" + " </materials>\n" + " <stage name=\"dev\">\n" + " <jobs>\n" + " <job name=\"linux\" />\n" + " <job name=\"windows\" />\n" + " </jobs>\n" + " </stage>\n" + "</pipeline>"; String md5 = goConfigFileDao.md5OfConfigFile(); ModelAndView mav = controller.postPipelineAsXmlPartial(0, groupName, badXml, md5, response); assertThat(response.getStatus(), is(SC_CONFLICT)); assertThat(response.getContentType(), is(RESPONSE_CHARSET_JSON)); JsonMap json = (JsonMap) mav.getModel().get("json"); assertThat(json.get("result").toString(), containsString("Label is invalid")); assertThat(json.get("originalContent"), is((Json) new JsonString(badXml))); }
From source file:ch.silviowangler.dox.web.DocumentController.java
@RequestMapping(method = POST, value = "/document/edit/{id}") public ModelAndView editDocument(@PathVariable("id") Long id, HttpServletRequest request) { ModelAndView modelAndView = new ModelAndView("import.successful"); try {/* ww w .j a v a 2 s . c om*/ DocumentReference documentReference = documentService.findDocumentReference(id); boolean didChangeValue = false; for (TranslatableKey key : documentReference.getIndices().keySet()) { final String paramValue = request.getParameter(key.getKey()); if (paramValue != null) { didChangeValue = true; documentReference.getIndices().put(key, new DescriptiveIndex(new String(paramValue.getBytes("iso-8859-1"), "utf-8"))); } } if (didChangeValue) { documentReference = documentService.updateIndices(documentReference); } modelAndView.getModel().put("doc", documentReference); } catch (DocumentNotFoundException | UnsupportedEncodingException e) { modelAndView.setViewName("modification.doc.failed"); logger.error("Cannot update document", e); } return modelAndView; }