Example usage for org.springframework.http MediaType TEXT_PLAIN

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

Introduction

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

Prototype

MediaType TEXT_PLAIN

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

Click Source Link

Document

Public constant media type for text/plain .

Usage

From source file:com.thinkbiganalytics.feedmgr.service.EncryptionService.java

public String decrypt(String str) {
    if (!StringUtils.startsWith(str, encryptedPrefix)) {
        str = encryptedPrefix + str;/*from  w  w w .j av  a  2 s.c  o  m*/
    }
    return encryptionController.decrypt(str, MediaType.TEXT_PLAIN);
}

From source file:com.thinkbiganalytics.metadata.rest.client.MetadataClient.java

/**
 * Update the named high water mar, for the feed given by feedId, with the given value
 *
 * @param feedId        the id of the feed
 * @param waterMarkName the name of the water mark
 * @param value         the new value for the high water mark
 *///from  w  w  w. j  a  v a2s  .  co  m
public void updateHighWaterMarkValue(String feedId, String waterMarkName, String value) {
    put(path("feed", feedId, "watermark", waterMarkName), value, MediaType.TEXT_PLAIN);
}

From source file:com.vmware.appfactory.application.controller.AppApiController.java

/**
 * This method responds with a string response containing json data. If success is set, it means the request
 * was successful, else a failure. For IE8, IE9 compatibility, the contentType=text/plain is set explicitly.
 *
 * @param message//w  ww .j  a v a  2  s.c  o  m
 * @param success
 * @param request
 * @return
 */
private ResponseEntity<String> respondUploadMessage(String message, boolean success,
        HttpServletRequest request) {
    // wrap json in a textarea only if the request did not come from xhr
    /* Only required for json or script response types for jquery.form.js uploads.
    _log.trace("X-Requested-With: " + request.getHeader("X-Requested-With"));
    boolean isXhr = "XMLHttpRequest".equalsIgnoreCase(request.getHeader("X-Requested-With"));
    if (!isXhr) {
       message = String.format("<textarea>%s</textarea>", message);
    } */

    HttpHeaders responseHeaders = new HttpHeaders();
    responseHeaders.setContentType(MediaType.TEXT_PLAIN);
    SimpleResponse simpleResponse = new SimpleResponse(success, message);
    String response = StringUtils.EMPTY;
    try {
        response = AfJson.ObjectMapper().writeValueAsString(simpleResponse);
    } catch (JsonMappingException e) {
        // This should not occur, the object is simple enough with boolean, string.
        _log.error("Json convertion error: ", e);
        response = message;
    } catch (IOException e) {
        // This should not occur under normal circumstances.
        _log.error("Json convertion error: ", e);
        response = message;
    }
    return new ResponseEntity<String>(response, responseHeaders, HttpStatus.OK);
}

From source file:com.wonders.bud.freshmommy.web.content.controller.ContentController.java

/**
 * <p>// w w w .jav  a2 s. c om
 * Description:[]
 * </p>
 * Created by [HYH] [20141128] Midified by [] []
 * 
 * @param request
 * @param response
 * @param session
 * @return
 * @throws Exception
 * @throws IOException
 */
@RequestMapping(value = "/video", method = RequestMethod.POST)
@ResponseBody
public ResponseEntity<RestMsg<String>> video(HttpServletRequest request, HttpServletResponse response,
        HttpSession session) throws Exception, IOException {

    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(MediaType.TEXT_PLAIN);
    // MultipartHttpRequest
    MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
    // 
    MultipartFile file = multipartRequest.getFile("videofile");
    RestMsg<String> rm = new RestMsg<String>();
    String fileType = file.getContentType();
    if (fileType.toLowerCase().indexOf("video") < 0) {
        rm = rm.errorMsg();
        rm.setMsg("??");
        return new ResponseEntity<RestMsg<String>>(rm, headers, HttpStatus.OK);
    }
    // ??
    String filename = file.getOriginalFilename();
    String[] temp1 = filename.split("\\.");
    String extenName = temp1[temp1.length - 1];
    StringBuffer fileNameBuffer = new StringBuffer();
    fileNameBuffer.append(UUID.randomUUID()).append(".").append(extenName);

    InputStream input = file.getInputStream();
    String actionPath = request.getSession().getServletContext().getRealPath("");
    String path = actionPath + File.separator + CONTENT_TEMP_FILE;
    File savePath = new File(path);
    if (!savePath.exists()) { // 
        savePath.mkdir();
    }
    FileUtil.SaveFileFromInputStream(input, savePath.toString(), fileNameBuffer.toString());
    String filePath = "temps/" + fileNameBuffer;
    rm = rm.successMsg();
    rm.setResult(filePath);
    return new ResponseEntity<RestMsg<String>>(rm, headers, HttpStatus.OK);
}

From source file:com.wonders.bud.freshmommy.web.content.controller.ContentController.java

/**
 * audiofile//from ww  w. ja v  a 2 s .c  o  m
 * <p>
 * Description:[]
 * </p>
 * Created by [HYH] [20141128] Midified by [] []
 * 
 * @param request
 * @param response
 * @param session
 * @return
 * @throws Exception
 * @throws IOException
 */
@RequestMapping(value = "/audio", method = RequestMethod.POST)
@ResponseBody
public ResponseEntity<RestMsg<String>> audio(HttpServletRequest request, HttpServletResponse response,
        HttpSession session) throws Exception, IOException {

    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(MediaType.TEXT_PLAIN);
    // MultipartHttpRequest
    MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
    // 
    MultipartFile file = multipartRequest.getFile("audiofile");
    RestMsg<String> rm = new RestMsg<String>();
    String fileType = file.getContentType();
    if ((fileType.toLowerCase().indexOf("audio") < 0)) {
        rm = rm.errorMsg();
        rm.setMsg("??");
        return new ResponseEntity<RestMsg<String>>(rm, headers, HttpStatus.OK);
    }
    // ??
    String filename = file.getOriginalFilename();
    String[] temp1 = filename.split("\\.");
    String extenName = temp1[temp1.length - 1];
    StringBuffer fileNameBuffer = new StringBuffer();
    fileNameBuffer.append(UUID.randomUUID()).append(".").append(extenName);

    InputStream input = file.getInputStream();
    String actionPath = request.getSession().getServletContext().getRealPath("");
    String path = actionPath + File.separator + CONTENT_TEMP_FILE;
    File savePath = new File(path);
    if (!savePath.exists()) { // 
        savePath.mkdir();
    }
    FileUtil.SaveFileFromInputStream(input, savePath.toString(), fileNameBuffer.toString());
    String filePath = "temps/" + fileNameBuffer;
    rm = rm.successMsg();
    rm.setResult(filePath);
    return new ResponseEntity<RestMsg<String>>(rm, headers, HttpStatus.OK);
}

From source file:io.spring.initializr.web.project.MainControllerIntegrationTests.java

private void validateCurlHelpContent(ResponseEntity<String> response) {
    validateContentType(response, MediaType.TEXT_PLAIN);
    assertThat(response.getHeaders().getFirst(HttpHeaders.ETAG), not(nullValue()));
    assertThat(response.getBody(),/*from   ww w.  j a va2  s.c om*/
            allOf(containsString("Spring Initializr"), containsString("Examples:"), containsString("curl")));
}

From source file:io.spring.initializr.web.project.MainControllerIntegrationTests.java

private void validateHttpIeHelpContent(ResponseEntity<String> response) {
    validateContentType(response, MediaType.TEXT_PLAIN);
    assertThat(response.getHeaders().getFirst(HttpHeaders.ETAG), not(nullValue()));
    assertThat(response.getBody(), allOf(containsString("Spring Initializr"), containsString("Examples:"),
            not(containsString("curl")), containsString("http")));
}

From source file:io.spring.initializr.web.project.MainControllerIntegrationTests.java

private void validateGenericHelpContent(ResponseEntity<String> response) {
    validateContentType(response, MediaType.TEXT_PLAIN);
    assertThat(response.getHeaders().getFirst(HttpHeaders.ETAG), not(nullValue()));
    assertThat(response.getBody(), allOf(containsString("Spring Initializr"), not(containsString("Examples:")),
            not(containsString("curl"))));
}

From source file:io.spring.initializr.web.project.MainControllerIntegrationTests.java

private void validateSpringBootHelpContent(ResponseEntity<String> response) {
    validateContentType(response, MediaType.TEXT_PLAIN);
    assertThat(response.getHeaders().getFirst(HttpHeaders.ETAG), not(nullValue()));
    assertThat(response.getBody(),//  w w w  .  j av a 2 s  .  co m
            allOf(containsString("Service capabilities"), containsString("Supported dependencies"),
                    not(containsString("Examples:")), not(containsString("curl"))));
}

From source file:org.artifactory.webapp.servlet.TraceLoggingResponse.java

/**
 * Writes the request info and messages to the response
 *
 * @param requestId   Request trace context ID
 * @param methodName  HTTP method name//from   w ww. ja va2  s  . c o m
 * @param username    Authenticated user name
 * @param requestPath Request repo path id
 * @throws IOException
 */
public void sendResponse(String requestId, String methodName, String username, String requestPath)
        throws IOException {
    Writer writer = null;
    try {
        artifactoryResponse.setContentType(MediaType.TEXT_PLAIN.toString());
        writer = artifactoryResponse.getWriter();
        writer.append("Request ID: ").append(requestId).append("\n");
        writer.append("Repo Path ID: ").append(requestPath).append("\n");
        writer.append("Method Name: ").append(methodName).append("\n");
        writer.append("User: ").append(username).append("\n");
        writer.append("Time: ").append(time).append("\n");
        writer.append("Thread: ").append(threadName).append("\n");
        writer.flush();
        writer.append("Steps: ").append("\n");
        IOUtils.writeLines(logAggregator, null, writer);
        writer.flush();
        artifactoryResponse.sendSuccess();
    } finally {
        if (writer != null) {
            writer.close();
        }
    }
}