List of usage examples for org.springframework.http ResponseEntity ResponseEntity
private ResponseEntity(@Nullable T body, @Nullable MultiValueMap<String, String> headers, Object status)
From source file:com.aspose.showcase.qrcodegen.web.api.controller.RestResponseEntityExceptionHandler.java
protected <T> ResponseEntity<T> response(T body, HttpStatus status) { return new ResponseEntity<T>(body, new HttpHeaders(), status); }
From source file:com.cocktail.controller.CocktailController.java
@RequestMapping(value = "/cocktails/cocktail", method = RequestMethod.POST) public ResponseEntity<?> addCocktail(@RequestBody CocktailResource cocktailDTO, UriComponentsBuilder ucBuilder) { Cocktail cocktail = cocktailService.addCocktail(cocktailDTO); HttpHeaders headers = new HttpHeaders(); headers.setLocation(ucBuilder.path("/Cocktails/Cocktail/{id}").buildAndExpand(cocktail.getId()).toUri()); return new ResponseEntity<>(null, headers, HttpStatus.CREATED); }
From source file:be.solidx.hot.web.deprecated.ScriptExecutorController.java
public ResponseEntity<String> handleScript(WebRequest webRequest, String scriptName) { try {/*from w ww .ja v a 2 s . co m*/ scriptName = scriptName + getScriptExtension(); Script<COMPILED_SCRIPT> script = buildScript(IOUtils.toByteArray(loadResource(scriptName)), scriptName); StringWriter stringWriter = new StringWriter(); PrintWriter printWriter = new PrintWriter(stringWriter); scriptExecutor.execute(script, webRequest, dbMap, printWriter); return new ResponseEntity<String>(stringWriter.toString(), httpHeaders, HttpStatus.ACCEPTED); } catch (Exception e) { StringWriter stringWriter = new StringWriter(); printErrorPage(e, stringWriter); return new ResponseEntity<String>(stringWriter.toString(), httpHeaders, HttpStatus.ACCEPTED); } }
From source file:controllers.ImageController.java
@RequestMapping("/") public ResponseEntity<byte[]> getImage(@RequestParam(value = "name", required = false) String name, @RequestParam(value = "id", required = false) String id) throws IOException { File file = new File("/usr/local/seller/preview/" + id + "/" + name); if (!file.exists()) { return null; }/* ww w . ja v a2 s . c o m*/ InputStream in = new FileInputStream(file); //new File("/usr/local/seller/preview/"+id+"/"+name).; //servletContext.getResourceAsStream("/usr/local/seller/preview/"+id+"/"+name); final HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.IMAGE_PNG); return new ResponseEntity<>(IOUtils.toByteArray(in), headers, HttpStatus.CREATED); }
From source file:org.sventon.web.ctrl.ConfigurationReloadController.java
@RequestMapping(method = GET) @ResponseBody//from www . j a va 2 s. c om public ResponseEntity<String> reloadConfigAndReinitializeApplication() { HttpHeaders responseHeaders = new HttpHeaders(); responseHeaders.setContentType(MediaType.TEXT_PLAIN); if (!application.isConfigurationReloadSupported()) { return new ResponseEntity<String>("Forbidden.", responseHeaders, FORBIDDEN); } try { application.reinit(); return new ResponseEntity<String>("Configuration reloaded.", responseHeaders, OK); } catch (Exception e) { logger.error("Failed to reload configuration files.", e); return new ResponseEntity<String>("Internal error.", responseHeaders, INTERNAL_SERVER_ERROR); } }