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.jutge.joc.porra.controller.base.BetController.java

@EntityStashManaged(entities = EntityStashEntityModule.ALL, views = EntityStashViewModule.NONE)
@RequestMapping(value = "/usuari/bloquejar-finalistes/{jugador1}/{jugador2}/{jugador3}/{jugador4}", method = RequestMethod.GET, produces = MediaType.TEXT_HTML_VALUE)
public String lockPlayers(@PathVariable final String jugador1, @PathVariable final String jugador2,
        @PathVariable final String jugador3, @PathVariable final String jugador4, final EntityStash entityStash,
        final HttpServletRequest request, final Locale locale) {
    this.logger.info("BetController.lockPlayers");
    final List<String> playerNames = this.validate4PlayerFinalAcion(jugador1, jugador2, jugador3, jugador4,
            entityStash, locale);//from www . j  a v  a2  s.  co  m
    this.playerService.lockPlayers(playerNames, entityStash);
    return "/desktop/update";
}

From source file:org.jutge.joc.porra.controller.base.BetController.java

@EntityStashManaged(entities = EntityStashEntityModule.ALL, views = EntityStashViewModule.NONE)
@RequestMapping(value = "/usuari/desbloquejar-finalistes/{jugador1}/{jugador2}/{jugador3}/{jugador4}", method = RequestMethod.GET, produces = MediaType.TEXT_HTML_VALUE)
public String unlockPlayers(@PathVariable final String jugador1, @PathVariable final String jugador2,
        @PathVariable final String jugador3, @PathVariable final String jugador4, final EntityStash entityStash,
        final HttpServletRequest request, final Locale locale) {
    this.logger.info("BetController.lockPlayers");
    final List<String> playerNames = this.validate4PlayerFinalAcion(jugador1, jugador2, jugador3, jugador4,
            entityStash, locale);//from   w  w w.ja v  a2s  . c o m
    this.playerService.unlockPlayers(playerNames, entityStash);
    return "/desktop/update";
}

From source file:org.jutge.joc.porra.controller.desktop.DesktopSignupController.java

@EntityStashManaged
@RequestMapping(value = "/apuntar-se/activar/{activationToken}", method = RequestMethod.POST, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces = MediaType.TEXT_HTML_VALUE)
public String activatePost(@PathVariable final String activationToken,
        @RequestBody final MultiValueMap<String, String> dataMap, final HttpServletRequest request,
        final Locale locale) {
    this.logger.info("DesktopSignupController.activatePost");
    final Account account = this.validateAccountToken(activationToken, locale);
    request.setAttribute("userName", account.getName());
    request.setAttribute("activationToken", activationToken);
    // validate params
    final String password = dataMap.getFirst("pwd");
    final String passwordConfirm = dataMap.getFirst("pwd-con");
    account.setHashedPass(password);/*from  w  ww . j  av a 2  s  .co  m*/
    this.validatePassword(account, passwordConfirm, locale);
    this.accountService.approveAccount(account);
    return "/desktop/signup/activate-done";
}

From source file:org.jutge.joc.porra.controller.desktop.DesktopSignupController.java

@EntityStashManaged
@RequestMapping(value = "nova-clau", method = RequestMethod.GET, produces = MediaType.TEXT_HTML_VALUE)
public String resetPassGet() {
    this.logger.info("DesktopSignupController.resetPassGet");
    return "/desktop/signup/reset";
}

From source file:org.jutge.joc.porra.controller.desktop.DesktopSignupController.java

@ReCaptchaConsumer
@EntityStashManaged/* w  w  w .j  ava 2s.  com*/
@RequestMapping(value = "/nova-clau", method = RequestMethod.POST, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces = MediaType.TEXT_HTML_VALUE)
public String resetPassPost(@RequestBody final MultiValueMap<String, String> dataMap, final Model model,
        final HttpServletRequest request, final Locale locale) {
    this.logger.info("DesktopSignupController.resetPassPost");
    // validation first
    final String name = dataMap.getFirst("usr");
    final String email = dataMap.getFirst("mil");
    request.setAttribute("usr", name);
    request.setAttribute("mil", email);
    final Boolean recaptchaIsValid = (Boolean) request.getAttribute(ReCaptchaUtils.RECAPTCHA_IS_VALID);
    final Account account = validateResetPassParams(name, email, recaptchaIsValid, locale);
    // Do actual reset
    this.accountService.resetAccount(account);
    this.emailService.sendPasswordResetMail(account);
    return "/desktop/signup/reset-done";
}

From source file:de.otto.mongodb.profiler.web.OpProfileController.java

@Page
@RequestMapping(value = "/control", method = RequestMethod.GET, params = "action=changeOutlierConfiguration", produces = MediaType.TEXT_HTML_VALUE)
public ModelAndView showOutlierConfiguration(@PathVariable("connectionId") final String connectionId,
        @PathVariable("databaseName") final String databaseName) throws ResourceNotFoundException {

    final ProfiledDatabase database = requireDatabase(connectionId, databaseName);

    final OpProfile.OutlierConfiguration config = getProfilerService().getOpProfiler(database)
            .getOutlierConfiguration();//from w  w  w.ja  va  2 s  .c om

    final OpOutlierConfigurationFormModel model = new OpOutlierConfigurationFormModel();

    if (config != null) {
        model.setEnabled(true);
        model.setIgnoreOutliers(config.ignoreOutliers());
        model.setCaptureOutliers(config.captureOutliers());
    }

    return new ModelAndView("page.op-outlierconfig")
            .addObject("model", new OpOutlierConfigurationPageViewModel(database, config != null))
            .addObject("configuration", model);
}

From source file:de.otto.mongodb.profiler.web.OpProfileController.java

@Page
@RequestMapping(value = "/control", method = RequestMethod.POST, params = "action=changeOutlierConfiguration", produces = MediaType.TEXT_HTML_VALUE, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
public ModelAndView changeOutlierConfiguration(@PathVariable("connectionId") final String connectionId,
        @PathVariable("databaseName") final String databaseName,
        @Valid @ModelAttribute("configuration") final OpOutlierConfigurationFormModel model,
        final BindingResult bindingResult, final UriComponentsBuilder uriComponentsBuilder)
        throws ResourceNotFoundException {

    final ProfiledDatabase database = requireDatabase(connectionId, databaseName);

    final OpProfiler opProfiler = getProfilerService().getOpProfiler(database);

    if (bindingResult.hasErrors()) {

        final boolean outlierConfiEnabled = model.isEnabled()
                || getProfilerService().getOpProfiler(database).getOutlierConfiguration() != null;

        return new ModelAndView("page.op-outlierconfig")
                .addObject("model", new OpOutlierConfigurationPageViewModel(database, outlierConfiEnabled))
                .addObject("configuration", model);
    }/* w  w w .j a v  a 2s.c  o  m*/

    final OpProfile.OutlierConfiguration outlierConfig;

    if (model.isEnabled()) {
        outlierConfig = new OpProfile.OutlierConfiguration() {
            @Override
            public boolean ignoreOutliers() {
                return Boolean.TRUE.equals(model.getIgnoreOutliers());
            }

            @Override
            public boolean captureOutliers() {
                return Boolean.TRUE.equals(model.getCaptureOutliers());
            }

            @Override
            public AverageMeasure.OutlierStrategy createStrategy() {
                return model.getStrategy().createStrategy(model);
            }
        };
    } else {
        outlierConfig = null;
    }

    opProfiler.setOutlierConfiguration(outlierConfig);
    opProfiler.reset();

    return new ModelAndView(new RedirectView(
            uriComponentsBuilder.path("/connections/{connectionId}/databases/{databaseName}/ops")
                    .queryParam("action", "changeOutlierConfiguration")
                    .buildAndExpand(connectionId, databaseName).toUriString()));
}

From source file:eu.trentorise.smartcampus.mobility.service.SmartPlannerService.java

@Override
public void sendAlert(Alert alert) throws Exception {
    String req = mapper.writeValueAsString(alert);
    String param = null;//from   w w  w. ja v a  2  s .c  om
    if (alert instanceof AlertDelay) {
        param = "updateAD";
    } else if (alert instanceof AlertAccident) {
        param = "updateAE";
    } else if (alert instanceof AlertStrike) {
        param = "updateAS";
    } else if (alert instanceof AlertParking) {
        param = "updateAP";
    } else if (alert instanceof AlertRoad) {
        param = "updateAR";
    } else {
        throw new IllegalArgumentException("Unknown alert type " + alert.getClass().getName());
    }

    String result = HTTPConnector.doPost(otpURL + SMARTPLANNER + param, req, MediaType.TEXT_HTML_VALUE,
            MediaType.APPLICATION_JSON_VALUE);
    logger.info(result);
    processAlerResult(alert, result);
}

From source file:com.netflix.genie.web.controllers.JobRestControllerIntegrationTest.java

private void checkJobOutput(final int documentationId, final String id) throws Exception {
    // Check getting a directory as json
    final RestDocumentationFilter jsonResultFilter = RestAssuredRestDocumentation.document(
            "{class-name}/" + documentationId + "/getJobOutput/json/",
            Snippets.ID_PATH_PARAM.and(RequestDocumentation.parameterWithName("filePath")
                    .description("The path to the directory to get").optional()), // Path parameters
            HeaderDocumentation.requestHeaders(HeaderDocumentation.headerWithName(HttpHeaders.ACCEPT)
                    .description(MediaType.APPLICATION_JSON_VALUE).optional()), // Request header
            HeaderDocumentation.responseHeaders(HeaderDocumentation.headerWithName(HttpHeaders.CONTENT_TYPE)
                    .description(MediaType.APPLICATION_JSON_VALUE)), // Response Headers
            Snippets.OUTPUT_DIRECTORY_FIELDS);

    RestAssured.given(this.getRequestSpecification()).filter(jsonResultFilter)
            .accept(MediaType.APPLICATION_JSON_VALUE).when().port(this.port)
            .get(JOBS_API + "/{id}/output/{filePath}", id, "").then()
            .statusCode(Matchers.is(HttpStatus.OK.value()))
            .contentType(Matchers.equalToIgnoringCase(MediaType.APPLICATION_JSON_UTF8_VALUE))
            .body("parent", Matchers.isEmptyOrNullString()).body("directories[0].name", Matchers.is("genie/"))
            .body("files[0].name", Matchers.is("config1")).body("files[1].name", Matchers.is("dep1"))
            .body("files[2].name", Matchers.is("jobsetupfile")).body("files[3].name", Matchers.is("run"))
            .body("files[4].name", Matchers.is("stderr")).body("files[5].name", Matchers.is("stdout"));

    // Check getting a directory as HTML
    final RestDocumentationFilter htmlResultFilter = RestAssuredRestDocumentation.document(
            "{class-name}/" + documentationId + "/getJobOutput/html/",
            Snippets.ID_PATH_PARAM.and(RequestDocumentation.parameterWithName("filePath")
                    .description("The path to the directory to get").optional()), // Path parameters
            HeaderDocumentation.requestHeaders(
                    HeaderDocumentation.headerWithName(HttpHeaders.ACCEPT).description(MediaType.TEXT_HTML)), // Request header
            HeaderDocumentation.responseHeaders(HeaderDocumentation.headerWithName(HttpHeaders.CONTENT_TYPE)
                    .description(MediaType.TEXT_HTML)) // Response Headers
    );//w  w  w  .  ja v a 2  s  .  c  o  m

    RestAssured.given(this.getRequestSpecification()).filter(htmlResultFilter).accept(MediaType.TEXT_HTML_VALUE)
            .when().port(this.port).get(JOBS_API + "/{id}/output/{filePath}", id, "").then()
            .statusCode(Matchers.is(HttpStatus.OK.value()))
            .contentType(Matchers.containsString(MediaType.TEXT_HTML_VALUE));

    // Check getting a file
    final RestDocumentationFilter fileResultFilter = RestAssuredRestDocumentation.document(
            "{class-name}/" + documentationId + "/getJobOutput/file/",
            Snippets.ID_PATH_PARAM.and(RequestDocumentation.parameterWithName("filePath")
                    .description("The path to the file to get").optional()), // Path parameters
            HeaderDocumentation.requestHeaders(HeaderDocumentation.headerWithName(HttpHeaders.ACCEPT)
                    .description(MediaType.ALL_VALUE).optional()), // Request header
            HeaderDocumentation.responseHeaders(HeaderDocumentation.headerWithName(HttpHeaders.CONTENT_TYPE)
                    .description("The content type of the file being returned").optional()) // Response Headers
    );

    // check that the generated run file is correct
    final String runShFileName = SystemUtils.IS_OS_LINUX ? "linux-runsh.txt" : "non-linux-runsh.txt";

    final String runShFile = this.resourceLoader.getResource(BASE_DIR + runShFileName).getFile()
            .getAbsolutePath();
    final String runFileContents = new String(Files.readAllBytes(Paths.get(runShFile)), StandardCharsets.UTF_8);

    final String jobWorkingDir = this.jobDirResource.getFile().getCanonicalPath() + FILE_DELIMITER + id;
    final String expectedRunScriptContent = this.getExpectedRunContents(runFileContents, jobWorkingDir, id);

    RestAssured.given(this.getRequestSpecification()).filter(fileResultFilter).when().port(this.port)
            .get(JOBS_API + "/{id}/output/{filePath}", id, "run").then()
            .statusCode(Matchers.is(HttpStatus.OK.value())).body(Matchers.is(expectedRunScriptContent));
}