Example usage for com.mongodb.gridfs GridFSFile toString

List of usage examples for com.mongodb.gridfs GridFSFile toString

Introduction

In this page you can find the example usage for com.mongodb.gridfs GridFSFile toString.

Prototype

@Override
    @SuppressWarnings("deprecation")
    public String toString() 

Source Link

Usage

From source file:org.opentestsystem.authoring.testauth.rest.FileGroupController.java

License:Open Source License

@ResponseStatus(HttpStatus.CREATED)
@RequestMapping(value = "/fileGroup/gridFsFile", method = RequestMethod.POST, consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.TEXT_PLAIN_VALUE)
@Secured({ "ROLE_Result Upload Modify" })
@ResponseBody//from   w w w. j  a v a2  s.com
public String uploadGridFsFile(@RequestParam("gridFsFile") final MultipartFile gridFsFile,
        final HttpServletRequest request, final HttpServletResponse response) throws IOException {
    String jsonAsStringForIE = null;
    try {
        final GridFSFile savedFile = this.fileGroupService.saveGridFsFile(gridFsFile.getOriginalFilename(),
                gridFsFile.getBytes(), gridFsFile.getContentType());
        jsonAsStringForIE = savedFile.toString();
    } catch (final LocalizedException e) {
        // return a 201 here -
        // IE9 and browsers which require iframe transport must receive an OK status to get the response result after file upload
        jsonAsStringForIE = this.objectMapper.writeValueAsString(super.handleException(e));
    } catch (final IOException e) {
        // return a 201 here -
        // IE9 and browsers which require iframe transport must receive an OK status to get the response result after file upload
        jsonAsStringForIE = this.objectMapper.writeValueAsString(super.handleException(e));
    }

    return jsonAsStringForIE;
}

From source file:org.opentestsystem.authoring.testauth.rest.ScoringRuleController.java

License:Open Source License

@ResponseStatus(HttpStatus.CREATED)
@RequestMapping(value = "/scoringRule/conversionTableFile/{type}", method = RequestMethod.POST, consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.TEXT_PLAIN_VALUE)
@Secured({ "ROLE_Scoring Rule Modify" })
// NOTE: there is intentionally no @PreAuthorize annotation...ability to modify scoring rule is all that is needed since scoring rule conversion table files are non-tenanted
@ResponseBody// w  ww . ja  v a2  s .c  om
public String uploadConversionTableFile(
        @RequestParam("conversionTableFile") final MultipartFile conversionTableFile,
        @PathVariable("type") final String type, final HttpServletRequest request,
        final HttpServletResponse response) throws IOException {
    String jsonAsStringForIE = null;
    try {
        final GridFSFile savedFile = this.scoringRuleService.saveConversionTableFile(type,
                conversionTableFile.getOriginalFilename(), conversionTableFile.getBytes(),
                conversionTableFile.getContentType());
        jsonAsStringForIE = savedFile.toString();
    } catch (final LocalizedException e) {
        // return a 201 here -
        // IE9 and browsers which require iframe transport must receive an OK status to get the response result after file upload
        jsonAsStringForIE = this.objectMapper.writeValueAsString(super.handleException(e));
    } catch (final IOException e) {
        // return a 201 here -
        // IE9 and browsers which require iframe transport must receive an OK status to get the response result after file upload
        jsonAsStringForIE = this.objectMapper.writeValueAsString(super.handleException(e));
    }

    return jsonAsStringForIE;
}