Example usage for org.springframework.http MediaType TEXT_HTML_VALUE

List of usage examples for org.springframework.http MediaType TEXT_HTML_VALUE

Introduction

In this page you can find the example usage for org.springframework.http MediaType TEXT_HTML_VALUE.

Prototype

String TEXT_HTML_VALUE

To view the source code for org.springframework.http MediaType TEXT_HTML_VALUE.

Click Source Link

Document

A String equivalent of MediaType#TEXT_HTML .

Usage

From source file:org.geoserver.rest.catalog.MBStyleControllerTest.java

@Test
public void getAsHTML() throws Exception {
    MockHttpServletResponse response = getAsServletResponse("/rest/styles/teststyle.html");
    assertEquals(200, response.getStatus());
    assertEquals(MediaType.TEXT_HTML_VALUE, response.getContentType());
    String content = response.getContentAsString();
    assertTrue(content.contains("<a href=\"http://localhost:8080/geoserver/rest/styles/teststyle"));
}

From source file:org.geoserver.status.monitoring.rest.MonitorRest.java

@GetMapping(value = "", produces = { MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE,
        MediaType.TEXT_HTML_VALUE })
@ResponseStatus(HttpStatus.OK)//w  w w . j a  v a  2 s .  co  m
public RestWrapper<Metrics> getData(HttpServletRequest request, HttpServletResponse response) {
    Metrics si = systemInfoCollector.retrieveAllSystemInfo();
    return wrapObject(si, Metrics.class);
}

From source file:org.geowebcache.util.ResponseUtils.java

/**
 * Wrapper method for writing an error back to the client, and logging it at the same time.
 * /* ww  w. ja  va 2  s.c  om*/
 * @param response
 *            where to write to
 * @param httpCode
 *            the HTTP code to provide
 * @param errorMsg
 *            the actual error message, human readable
 */
public static void writeErrorPage(HttpServletResponse response, int httpCode, String errorMsg,
        RuntimeStats runtimeStats) {
    log.debug(errorMsg);
    errorMsg = "<html>\n" + ServletUtils.gwcHtmlHeader("../", "GWC Error") + "<body>\n"
            + ServletUtils.gwcHtmlLogoLink("../") + "<h4>" + httpCode + ": "
            + ServletUtils.disableHTMLTags(errorMsg) + "</h4>" + "</body></html>\n";
    writePage(response, httpCode, errorMsg, runtimeStats, MediaType.TEXT_HTML_VALUE);
}

From source file:org.jasig.ssp.util.security.lti.LtiLaunchErrorHandler.java

private void respondLive(HttpServletRequest request, HttpServletResponse response, ErrorResponse errorResponse)
        throws IOException {
    final String returnUrl = request.getParameter(LTI_LAUNCH_PRESENTATION_RETURN_URL);
    if (StringUtils.isNotBlank(returnUrl)) {
        final StringBuilder sb = new StringBuilder(returnUrl).append("?").append(LTI_ERROR_MSG).append("=")
                .append(URLEncoder.encode(errorResponse.endUserMessage, "UTF-8"));
        response.sendRedirect(sb.toString());
    } else {//from  w  w w .  ja  va 2  s.co  m
        response.setStatus(errorResponse.statusCode);
        response.setContentType(MediaType.TEXT_HTML_VALUE);
        final PrintWriter out = response.getWriter();
        final StringBuilder sb = new StringBuilder("<html><body><p>").append(errorResponse.endUserMessage)
                .append("</p></body></html>");
        out.println(sb.toString());
    }
}

From source file:org.opentestsystem.shared.rest.ApiController.java

@RequestMapping(value = "/api", produces = MediaType.TEXT_HTML_VALUE)
public ModelAndView apidoc() {
    parseExamples();/*from  ww  w  .  j  av a  2  s . c  o m*/
    LOGGER.info("GET /api/");
    return new ModelAndView("api/index", "apiRequestsByURI", apiRequestsByURI);
}

From source file:org.opentestsystem.shared.rest.ApiController.java

@RequestMapping(value = "/api/{context}", produces = MediaType.TEXT_HTML_VALUE)
public ModelAndView apispecific(@PathVariable("context") final String context) {
    parseExamples();/*from  w  w w .j  ava 2 s.com*/
    LOGGER.info("GET /api/context" + context);
    return new ModelAndView("api/api_context", "examples", apiRequestsByURI.get("/" + context));
}

From source file:org.orcid.frontend.web.controllers.NotificationController.java

@RequestMapping(value = "/CUSTOM/{id}/notification.html", produces = MediaType.TEXT_HTML_VALUE)
public @ResponseBody String getCustomNotificationHtml(@PathVariable("id") String id) {
    Notification notification = notificationManager.findByOrcidAndId(getCurrentUserOrcid(), Long.valueOf(id));
    if (notification instanceof NotificationCustom) {
        return ((NotificationCustom) notification).getBodyHtml();
    } else {//from w  w  w .  ja va2s.c om
        return "Notification is of wrong type";
    }
}

From source file:org.orcid.frontend.web.controllers.NotificationController.java

@RequestMapping(value = "/PERMISSION/{id}/notification.html", produces = MediaType.TEXT_HTML_VALUE)
public ModelAndView getPermissionNotificationHtml(@PathVariable("id") String id) {
    ModelAndView mav = new ModelAndView();
    Notification notification = notificationManager.findByOrcidAndId(getCurrentUserOrcid(), Long.valueOf(id));
    addSourceDescription(notification);//  www.  jav a2s  .co m
    mav.addObject("notification", notification);
    mav.setViewName("notification/add_activities_notification");
    return mav;
}

From source file:org.orcid.frontend.web.controllers.NotificationController.java

@RequestMapping(value = "/AMENDED/{id}/notification.html", produces = MediaType.TEXT_HTML_VALUE)
public ModelAndView getAmendedNotificationHtml(@PathVariable("id") String id) {
    ModelAndView mav = new ModelAndView();
    Notification notification = notificationManager.findByOrcidAndId(getCurrentUserOrcid(), Long.valueOf(id));
    addSourceDescription(notification);/*from  w  ww .j a  va 2  s .c o  m*/
    mav.addObject("notification", notification);
    mav.addObject("emailName", notificationManager.deriveEmailFriendlyName(getEffectiveProfile()));
    mav.setViewName("notification/amended_notification");
    return mav;
}