org.springframework.http.MediaType#TEXT_PLAIN_VALUE源码实例Demo

下面列出了org.springframework.http.MediaType#TEXT_PLAIN_VALUE 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: lams   文件: MonitoringController.java
@RequestMapping(path = "/setSubmissionDeadline", method = RequestMethod.POST, produces = MediaType.TEXT_PLAIN_VALUE)
   @ResponseBody
   public String setSubmissionDeadline(HttpServletRequest request) {
Long contentID = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_CONTENT_ID);
VoteContent voteContent = voteService.getVoteContent(contentID);

Long dateParameter = WebUtil.readLongParam(request, VoteAppConstants.ATTR_SUBMISSION_DEADLINE, true);
Date tzSubmissionDeadline = null;
String formattedDate = "";
if (dateParameter != null) {
    Date submissionDeadline = new Date(dateParameter);
    HttpSession ss = SessionManager.getSession();
    org.lamsfoundation.lams.usermanagement.dto.UserDTO teacher = (org.lamsfoundation.lams.usermanagement.dto.UserDTO) ss
	    .getAttribute(AttributeNames.USER);
    TimeZone teacherTimeZone = teacher.getTimeZone();
    tzSubmissionDeadline = DateUtil.convertFromTimeZoneToDefault(teacherTimeZone, submissionDeadline);
    formattedDate = DateUtil.convertToStringForJSON(tzSubmissionDeadline, request.getLocale());
}
voteContent.setSubmissionDeadline(tzSubmissionDeadline);
voteService.updateVote(voteContent);

return formattedDate;
   }
 
源代码2 项目: lams   文件: MonitoringController.java
/**
    * Set Submission Deadline
    */
   @RequestMapping(path = "/setSubmissionDeadline", method = RequestMethod.POST, produces = MediaType.TEXT_PLAIN_VALUE)
   @ResponseBody
   public String setSubmissionDeadline(HttpServletRequest request) {
Long contentID = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_CONTENT_ID);
QaContent content = qaService.getQaContent(contentID);

Long dateParameter = WebUtil.readLongParam(request, QaAppConstants.ATTR_SUBMISSION_DEADLINE, true);
Date tzSubmissionDeadline = null;
String formattedDate = "";
if (dateParameter != null) {
    Date submissionDeadline = new Date(dateParameter);
    HttpSession ss = SessionManager.getSession();
    UserDTO teacher = (UserDTO) ss.getAttribute(AttributeNames.USER);
    TimeZone teacherTimeZone = teacher.getTimeZone();
    tzSubmissionDeadline = DateUtil.convertFromTimeZoneToDefault(teacherTimeZone, submissionDeadline);
    formattedDate = DateUtil.convertToStringForJSON(tzSubmissionDeadline, request.getLocale());
} else {
    //set showOtherAnswersAfterDeadline to false
    content.setShowOtherAnswersAfterDeadline(false);
}
content.setSubmissionDeadline(tzSubmissionDeadline);
qaService.saveOrUpdateQaContent(content);

return formattedDate;
   }
 
源代码3 项目: OpenIoE   文件: AccountResource.java
/**
 * POST   /account/reset_password/init : Send an e-mail to reset the password of the user
 *
 * @param mail the mail of the user
 * @param request the HTTP request
 * @return the ResponseEntity with status 200 (OK) if the e-mail was sent, or status 400 (Bad Request) if the e-mail address is not registred
 */
@RequestMapping(value = "/account/reset_password/init",
    method = RequestMethod.POST,
    produces = MediaType.TEXT_PLAIN_VALUE)
@Timed
public ResponseEntity<?> requestPasswordReset(@RequestBody String mail, HttpServletRequest request) {
    return userService.requestPasswordReset(mail)
        .map(user -> {
            String baseUrl = request.getScheme() +
                "://" +
                request.getServerName() +
                ":" +
                request.getServerPort() +
                request.getContextPath();
            mailService.sendPasswordResetMail(user, baseUrl);
            return new ResponseEntity<>("e-mail was sent", HttpStatus.OK);
        }).orElse(new ResponseEntity<>("e-mail address not registered", HttpStatus.BAD_REQUEST));
}
 
源代码4 项目: hesperides   文件: FilesController.java
@ApiOperation("Get a valued template file")
@GetMapping(produces = MediaType.TEXT_PLAIN_VALUE + ";charset=UTF-8", path =
        "applications/{application_name}/platforms/{platform_name}/{module_path}/{module_name}/{module_version}/instances/{instance_name}/files/{template_name}")
public ResponseEntity<String> getFile(Authentication authentication,
                                      @PathVariable("application_name") final String applicationName,
                                      @PathVariable("platform_name") final String platformName,
                                      @PathVariable("module_path") final String modulePath,
                                      @PathVariable("module_name") final String moduleName,
                                      @PathVariable("module_version") final String moduleVersion,
                                      @PathVariable("instance_name") final String instanceName,
                                      @PathVariable("template_name") final String templateName,
                                      @RequestParam("isWorkingCopy") final Boolean isWorkingCopy,
                                      @RequestParam("template_namespace") final String templateNamespace,
                                      @RequestParam(value = "simulate", required = false) final Boolean simulate) {

    String fileContent = filesUseCases.getFile(
            applicationName,
            platformName,
            modulePath,
            moduleName,
            moduleVersion,
            instanceName,
            templateName,
            Boolean.TRUE.equals(isWorkingCopy),
            templateNamespace,
            Boolean.TRUE.equals(simulate),
            new User(authentication));

    return ResponseEntity.ok(fileContent);
}
 
/**
 * GET  / : get the SSH public key
 */
@GetMapping(value = "/ssh/public_key", produces = MediaType.TEXT_PLAIN_VALUE)
@Timed
public ResponseEntity<String> eureka() {
    try {
        String publicKey = getPublicKey();
        if(publicKey != null) return new ResponseEntity<>(publicKey, HttpStatus.OK);
    } catch (IOException e) {
        log.warn("SSH public key could not be loaded: {}", e.getMessage());
    }
    return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
 
源代码6 项目: jhipster-registry   文件: SshResource.java
/**
 * GET  / : get the SSH public key
 */
@GetMapping(value = "/ssh/public_key", produces = MediaType.TEXT_PLAIN_VALUE)
public ResponseEntity<String> getSshPublicKey() {
    try {
        String publicKey = getPublicKey();
        if(publicKey != null) return new ResponseEntity<>(publicKey, HttpStatus.OK);
    } catch (IOException e) {
        log.warn("SSH public key could not be loaded: {}", e.getMessage());
    }
    return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
 
/**
 * POST   /account/reset_password/init : Send an email to reset the password of the user
 *
 * @param mail the mail of the user
 * @return the ResponseEntity with status 200 (OK) if the email was sent, or status 400 (Bad Request) if the email address is not registered
 */
@PostMapping(path = "/account/reset_password/init",
    produces = MediaType.TEXT_PLAIN_VALUE)
@Timed
public ResponseEntity requestPasswordReset(@RequestBody String mail) {
    return userService.requestPasswordReset(mail)
        .map(user -> {
            mailService.sendPasswordResetMail(user);
            return new ResponseEntity<>("email was sent", HttpStatus.OK);
        }).orElse(new ResponseEntity<>("email address not registered", HttpStatus.BAD_REQUEST));
}
 
/**
 * POST   /account/reset_password/finish : Finish to reset the password of the user
 *
 * @param keyAndPassword the generated key and the new password
 * @return the ResponseEntity with status 200 (OK) if the password has been reset,
 * or status 400 (Bad Request) or 500 (Internal Server Error) if the password could not be reset
 */
@PostMapping(path = "/account/reset_password/finish",
    produces = MediaType.TEXT_PLAIN_VALUE)
@Timed
public ResponseEntity<String> finishPasswordReset(@RequestBody KeyAndPasswordVM keyAndPassword) {
    if (!checkPasswordLength(keyAndPassword.getNewPassword())) {
        return new ResponseEntity<>("Incorrect password", HttpStatus.BAD_REQUEST);
    }
    return userService.completePasswordReset(keyAndPassword.getNewPassword(), keyAndPassword.getKey())
          .map(user -> new ResponseEntity<String>(HttpStatus.OK))
          .orElse(new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR));
}
 
源代码9 项目: flair-engine   文件: AccountResource.java
/**
 * POST   /account/reset_password/finish : Finish to reset the password of the user
 *
 * @param keyAndPassword the generated key and the new password
 * @return the ResponseEntity with status 200 (OK) if the password has been reset,
 * or status 400 (Bad Request) or 500 (Internal Server Error) if the password could not be reset
 */
@PostMapping(path = "/account/reset_password/finish",
    produces = MediaType.TEXT_PLAIN_VALUE)
@Timed
public ResponseEntity<String> finishPasswordReset(@RequestBody KeyAndPasswordVM keyAndPassword) {
    if (!checkPasswordLength(keyAndPassword.getNewPassword())) {
        return new ResponseEntity<>(CHECK_ERROR_MESSAGE, HttpStatus.BAD_REQUEST);
    }
    return userService.completePasswordReset(keyAndPassword.getNewPassword(), keyAndPassword.getKey())
          .map(user -> new ResponseEntity<String>(HttpStatus.OK))
          .orElse(new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR));
}
 
源代码10 项目: api-layer   文件: MultipartControllerTest.java
@Test
public void shouldSubmitWithPutAndReturnString() {
    MockMultipartFile file = new MockMultipartFile("file", "hello.txt", MediaType.TEXT_PLAIN_VALUE, "Hello, World!".getBytes());
    UploadFileResponse uploadFileResponse = multipartController.uploadFileWithPut(file);

    assertEquals("hello.txt", uploadFileResponse.getFileName());
    assertEquals("text/plain", uploadFileResponse.getFileType());
    assertEquals(13, uploadFileResponse.getSize());
}
 
@DeleteMapping(path = "/addstring", produces = MediaType.TEXT_PLAIN_VALUE)
public String addString(@RequestParam(name = "s") List<String> s) {
  String result = "";
  for (String x : s) {
    result += x;
  }
  return result;
}
 
源代码12 项目: tutorials   文件: AccountResource.java
/**
 * POST   /account/reset_password/init : Send an e-mail to reset the password of the user
 *
 * @param mail the mail of the user
 * @return the ResponseEntity with status 200 (OK) if the e-mail was sent, or status 400 (Bad Request) if the e-mail address is not registered
 */
@PostMapping(path = "/account/reset_password/init",
    produces = MediaType.TEXT_PLAIN_VALUE)
@Timed
public ResponseEntity requestPasswordReset(@RequestBody String mail) {
    return userService.requestPasswordReset(mail)
        .map(user -> {
            mailService.sendPasswordResetMail(user);
            return new ResponseEntity<>("e-mail was sent", HttpStatus.OK);
        }).orElse(new ResponseEntity<>("e-mail address not registered", HttpStatus.BAD_REQUEST));
}
 
@GetMapping(value = "/ambiguous", produces = MediaType.TEXT_PLAIN_VALUE)
public String ambiguous1() {
	return "ambiguous";
}
 
@RequestMapping(method = RequestMethod.POST, path = "/multipartFilenames",
		consumes = MediaType.MULTIPART_FORM_DATA_VALUE,
		produces = MediaType.TEXT_PLAIN_VALUE)
String requestPartListOfMultipartFilesReturnsFileNames(
		@RequestPart("files") List<MultipartFile> files);
 
源代码15 项目: mutual-tls-ssl   文件: HelloWorldController.java
@LogClientType
@LogCertificate(detailed = true)
@GetMapping(value = "/api/hello", produces = MediaType.TEXT_PLAIN_VALUE)
public ResponseEntity<String> hello() {
    return ResponseEntity.ok("Hello");
}
 
@PostMapping(path = "/upload", produces = MediaType.TEXT_PLAIN_VALUE)
public String fileUpload(@RequestPart(name = "file1") MultipartFile file1,
    @RequestPart(name = "someFile") Part file2) {
  return _fileUpload(file1, file2);
}
 
@RequestMapping(path = "", method = RequestMethod.GET, produces = MediaType.TEXT_PLAIN_VALUE)
@ResponseBody
@Override
public String home() {
  return super.home();
}
 
@RequestMapping(method = RequestMethod.POST, path = "/singlePart",
		consumes = MediaType.MULTIPART_FORM_DATA_VALUE,
		produces = MediaType.TEXT_PLAIN_VALUE)
String singlePart(@RequestPart("hello") String hello) {
	return hello;
}
 
@RequestMapping(method = RequestMethod.POST, path = "/multipart",
		consumes = MediaType.MULTIPART_FORM_DATA_VALUE,
		produces = MediaType.TEXT_PLAIN_VALUE)
String multipart(@RequestPart("hello") String hello,
		@RequestPart("world") String world,
		@RequestPart("file") MultipartFile file);
 
/**
 * Gets the text.
 *
 * @return the text.
 */
@GetMapping(value = "/text", produces = MediaType.TEXT_PLAIN_VALUE)
public String getText() {
    return "TEST-TEXT";
}