List of usage examples for org.springframework.http MediaType TEXT_HTML_VALUE
String TEXT_HTML_VALUE
To view the source code for org.springframework.http MediaType TEXT_HTML_VALUE.
Click Source Link
From source file:org.bozzo.ipplan.web.AddressController.java
@RequestMapping(value = "/{ip}", method = RequestMethod.GET, produces = { MediaType.TEXT_HTML_VALUE }) @ApiIgnore// w ww . j a v a2s . c o m public ModelAndView getAddressView(@PathVariable Integer infraId, @PathVariable Long subnetId, @PathVariable Long ip) { HttpEntity<AddressResource> address = this.getAddress(infraId, subnetId, ip); ModelAndView view = new ModelAndView("address"); view.addObject("id", ip); view.addObject("object", address.getBody()); return view; }
From source file:controller.SeatController.java
@RequestMapping(value = "/list/hide", method = RequestMethod.POST, produces = MediaType.TEXT_HTML_VALUE, consumes = MediaType.TEXT_HTML_VALUE) public @ResponseBody String hide() { return ""; }
From source file:edu.sjsu.cmpe275.lab2.controller.ManagePersonController.java
@RequestMapping(value = "/{id}", method = RequestMethod.GET, params = "format=html", produces = MediaType.TEXT_HTML_VALUE) public String getPersonHtml(@PathVariable("id") long id, Model model) { Person person = null;//w w w. j a v a 2 s.co m person = personDao.get(id); if (person == null) { return "error404"; } else { model.addAttribute("person", person); return "person"; } }
From source file:controller.PlayController.java
@RequestMapping(value = "/list/refresh", method = RequestMethod.POST, produces = MediaType.TEXT_HTML_VALUE, consumes = MediaType.TEXT_HTML_VALUE) public @ResponseBody String refresh() { List<Play> plays = null; if (currentPlay.getPlayName() != null && currentPlay.getStartTime() != null && currentPlay.getStartTime() != null && currentPlay.getEndTime() != null && currentPlay.getStartDate() != null && currentPlay.getTicketPrice() != 0) { Play play = userService.getPlay(currentPlay.getIdPlay()); currentPlay.setPlayName(play.getPlayName()); currentPlay.setStartTime(play.getStartTime()); currentPlay.setEndTime(play.getEndTime()); currentPlay.setStartDate(play.getStartDate()); currentPlay.setTicketPrice(play.getTicketPrice()); }/* w w w. ja v a 2 s .c o m*/ String response; try { plays = filterPlays(currentPlay, userService.loadPlays()); if (plays != null) { response = utils.convertPlaysToHtml(plays); } else { response = utils.convertPlaysToHtml(userService.loadPlays()); } } catch (AppException e) { response = "Exception:" + e.getMessage(); } return response; }
From source file:edu.mayo.trilliumbridge.webapp.TransformerController.java
protected void doTransform(HttpServletRequest request, HttpServletResponse response, String acceptHeader, String formatOverride, Transformer transformer) throws IOException { // default to XML if no Accept Header (it should at least be */*, but just in case). if (StringUtils.isBlank(acceptHeader)) { acceptHeader = MediaType.APPLICATION_ATOM_XML_VALUE; }/*from w w w. ja v a2 s. com*/ TrilliumBridgeTransformer.Format responseFormat = null; if (StringUtils.isNotBlank(formatOverride)) { responseFormat = TrilliumBridgeTransformer.Format.valueOf(formatOverride); } else { String[] accepts = StringUtils.split(acceptHeader, ','); for (String accept : accepts) { MediaType askedForType = MediaType.parseMediaType(accept); if (askedForType.isCompatibleWith(MediaType.TEXT_XML) || askedForType.isCompatibleWith(MediaType.APPLICATION_XML)) { responseFormat = TrilliumBridgeTransformer.Format.XML; } else if (askedForType.isCompatibleWith(MediaType.TEXT_HTML) || askedForType.isCompatibleWith(MediaType.APPLICATION_XHTML_XML)) { responseFormat = TrilliumBridgeTransformer.Format.HTML; } else if (askedForType.getType().equals("application") && askedForType.getSubtype().equals("pdf")) { responseFormat = TrilliumBridgeTransformer.Format.PDF; } if (responseFormat != null) { break; } } } if (responseFormat == null) { throw new UserInputException("Cannot return type: " + acceptHeader, HttpStatus.NOT_ACCEPTABLE); } String contentType; switch (responseFormat) { case XML: contentType = MediaType.APPLICATION_XML_VALUE; break; case HTML: contentType = MediaType.TEXT_HTML_VALUE.toString(); break; case PDF: contentType = "application/pdf"; break; default: throw new IllegalStateException("Illegal Response Format"); } InputStream inputStream; if (request instanceof MultipartHttpServletRequest) { MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; MultipartFile multipartFile = multipartRequest.getFile(INPUT_FILE_NAME); inputStream = multipartFile.getInputStream(); } else { inputStream = request.getInputStream(); } inputStream = this.checkForUtf8BOMAndDiscardIfAny(this.checkStreamIsNotEmpty(inputStream)); // create a buffer so we don't use the servlet's output stream unless // we get a successful transform, because if we do use it, // we can't use the error view anymore. ByteArrayOutputStream baos = new ByteArrayOutputStream(); transformer.transform(inputStream, baos, responseFormat); try { response.setContentType(contentType); response.getOutputStream().write(baos.toByteArray()); } finally { IOUtils.closeQuietly(baos); } }
From source file:org.cloudfoundry.identity.uaa.mock.audit.AuditCheckMvcMockTests.java
@Test public void userLoginTest() throws Exception { MockHttpServletRequestBuilder loginPost = post("/login.do").accept(MediaType.TEXT_HTML_VALUE) .param("username", testAccounts.getUserName()).param("password", testAccounts.getPassword()); //success means a 302 to / (failure is 302 to /login?error...) mockMvc.perform(loginPost).andExpect(status().is3xxRedirection()) .andExpect(header().string("Location", "/")); ArgumentCaptor<UserAuthenticationSuccessEvent> captor = ArgumentCaptor .forClass(UserAuthenticationSuccessEvent.class); verify(listener).onApplicationEvent(captor.capture()); UserAuthenticationSuccessEvent event = captor.getValue(); assertEquals(testAccounts.getUserName(), event.getUser().getUsername()); }
From source file:com.netflix.genie.web.resources.handlers.GenieResourceHttpRequestHandlerUnitTests.java
/** * Make sure if the resource is a directory as HTML it's handled properly. * * @throws Exception On any error//w w w .j a va 2 s .c om */ @Test public void canHandleRequestForDirectoryHtml() throws Exception { final HttpServletRequest request = Mockito.mock(HttpServletRequest.class); final HttpServletResponse response = Mockito.mock(HttpServletResponse.class); final String path = UUID.randomUUID().toString(); Mockito.when(request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE)).thenReturn(path); Mockito.when(request.getHeader(HttpHeaders.ACCEPT)).thenReturn(MediaType.TEXT_HTML_VALUE); final String forwardedUrl = UUID.randomUUID().toString(); Mockito.when(request.getHeader(JobConstants.GENIE_FORWARDED_FROM_HEADER)).thenReturn(forwardedUrl); final Resource resource = Mockito.mock(Resource.class); Mockito.when(this.location.createRelative(Mockito.eq(path))).thenReturn(resource); Mockito.when(resource.exists()).thenReturn(true); final File file = Mockito.mock(File.class); Mockito.when(resource.getFile()).thenReturn(file); Mockito.when(file.isDirectory()).thenReturn(true); final String html = UUID.randomUUID().toString(); Mockito.when(this.directoryWriter.toHtml(Mockito.eq(file), Mockito.eq(forwardedUrl), Mockito.eq(false))) .thenReturn(html); final ServletOutputStream os = Mockito.mock(ServletOutputStream.class); Mockito.when(response.getOutputStream()).thenReturn(os); this.handler.handleRequest(request, response); Mockito.verify(response, Mockito.times(1)).setContentType(MediaType.TEXT_HTML_VALUE); Mockito.verify(response, Mockito.times(1)).getOutputStream(); Mockito.verify(this.directoryWriter, Mockito.times(1)).toHtml(Mockito.eq(file), Mockito.eq(forwardedUrl), Mockito.eq(false)); Mockito.verify(os, Mockito.times(1)).write(html.getBytes(Charset.forName("UTF-8"))); }
From source file:org.jutge.joc.porra.controller.base.BetController.java
@EntityStashManaged(entities = EntityStashEntityModule.ALL, views = EntityStashViewModule.NONE) @RequestMapping(value = "/usuari/consumir-ronda-final/{guanyador}/{perdedor1}/{perdedor2}/{perdedor3}/{tipus}", method = RequestMethod.GET, produces = MediaType.TEXT_HTML_VALUE) public String consumeFinalRound(@PathVariable final String guanyador, @PathVariable final String perdedor1, @PathVariable final String perdedor2, @PathVariable final String perdedor3, @PathVariable final String tipus, final EntityStash entityStash, final HttpServletRequest request, final Locale locale) { this.logger.info("BetController.consumeFinalRound"); final List<String> playerNames = this.validate4PlayerFinalAcion(guanyador, perdedor1, perdedor2, perdedor3, entityStash, locale);// www. ja va 2 s . co m this.betService.consumeFinalRound(playerNames, entityStash, tipus); return "/desktop/update"; }
From source file:controller.PlayController.java
@RequestMapping(value = "/list/undo", method = RequestMethod.POST, produces = MediaType.TEXT_HTML_VALUE, consumes = MediaType.TEXT_HTML_VALUE) public @ResponseBody String undo() { List<Play> plays;/* w ww .ja v a2s . c o m*/ String response; try { if (!changes.isEmpty()) { currentPlay = changes.pop(); plays = filterPlays(currentPlay, userService.loadPlays()); } else { plays = userService.loadPlays(); } if (plays != null) { response = utils.convertPlaysToHtml(plays); } else { response = utils.convertPlaysToHtml(userService.loadPlays()); } } catch (AppException e) { response = "Exception:" + e.getMessage(); } return response; }
From source file:org.jutge.joc.porra.controller.desktop.DesktopSignupController.java
@EntityStashManaged @RequestMapping(value = "/apuntar-se/activar/{activationToken}", method = RequestMethod.GET, produces = MediaType.TEXT_HTML_VALUE) public String activateGet(@PathVariable final String activationToken, final Model model, final Locale locale) { this.logger.info("DesktopSignupController.activateGet"); final Account account = this.validateAccountToken(activationToken, locale); model.addAttribute("userName", account.getName()); model.addAttribute("activationToken", activationToken); return "/desktop/signup/activate"; }