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.janrain.backplane.server.metrics.MetricsController.java
@RequestMapping(value = "/dump", method = RequestMethod.POST) public ResponseEntity<String> dump(@RequestBody MetricRequest metricRequest) throws SimpleDBException, BackplaneServerException, AuthException { bpConfig.checkMetricAuth(metricRequest.getUser(), metricRequest.getSecret()); try {/*from ww w . j av a 2 s .com*/ return new ResponseEntity<String>(retrieveAllMetrics(), new HttpHeaders() { { add("Content-Type", "application/json"); } }, HttpStatus.OK); } catch (Exception e) { logger.error(e); throw new BackplaneServerException(e.getMessage()); } }
From source file:edu.infsci2560.services.BookService.java
@RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public ResponseEntity<Book> create(@RequestBody Book book) { HttpHeaders headers = new HttpHeaders(); return new ResponseEntity<>(repository.save(book), headers, HttpStatus.OK); }
From source file:io.sevenluck.chat.controller.ChatChannelController.java
@ExceptionHandler @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) public ResponseEntity<?> handleException(EntityNotFoundException e) { logger.error("validate:", e.getMessage()); return new ResponseEntity<>(ExceptionDTO.newNotFoundInstance(e.getMessage()), new HttpHeaders(), HttpStatus.NOT_FOUND);//from www .j a va 2 s .c om }
From source file:guru.nidi.ramltester.spring.SpringMockRamlMessageTest.java
@RequestMapping(value = "path", produces = "text/dummy") @ResponseBody/* w w w . ja v a 2 s . c o m*/ public ResponseEntity<String> test() { final HttpHeaders headers = new HttpHeaders(); headers.add("head", "resValue"); return new ResponseEntity<>("respons", headers, HttpStatus.ACCEPTED); }
From source file:org.springsource.sinspctr.rest.SInspctrRootController.java
private ResponseEntity<String> getIndexHtml() { ResponseEntity<String> response; try {/*w ww.j a va 2s . c o m*/ HttpHeaders headers = new HttpHeaders(); headers.add("content-type", "text/html"); response = new ResponseEntity<String>( FileCopyUtils.copyToString( new FileReader(ResourceLocator.getClasspathRelativeFile("assets/index.html"))), headers, HttpStatus.OK); return response; } catch (Exception e) { return new ResponseEntity<String>(HttpStatus.NOT_FOUND); } }
From source file:edu.infsci2560.services.LocationsService.java
@RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public ResponseEntity<Location> create(@RequestBody Location locations) { HttpHeaders headers = new HttpHeaders(); return new ResponseEntity<>(repository.save(locations), headers, HttpStatus.OK); }
From source file:com.biz.report.controller.CustomerReportControler.java
@ResponseBody @RequestMapping(value = "customerreport/{year}/get", method = RequestMethod.POST, headers = { "Content-type=application/json" }) public ResponseEntity<ReportDataSet> readFTypes(@PathVariable("year") String year, @RequestBody Map data) { logger.info(year);//from ww w .jav a2 s. com logger.info(data); Assert.notNull(data, "Data is null."); Assert.notNull(year, "Year is null."); String items = data.get("customers").toString(); String months = data.get("months").toString(); ReportDataSet reportDataSet = customerService.getReports(items, months, year); HttpHeaders headers = new HttpHeaders(); headers.add("success", "Success"); return new ResponseEntity<ReportDataSet>(reportDataSet, headers, HttpStatus.OK); }
From source file:am.ik.categolj2.api.file.FileHelper.java
ResponseEntity<byte[]> creteHttpResponse(long ifModifiedSince, UploadFileSummary summary, HttpHeaders responseHeaders) {/*from w ww . ja va 2 s . c om*/ if (summary.getLastModifiedDate().isAfter(ifModifiedSince)) { UploadFile uploadFile = uploadFileService.findOne(summary.getFileId()); return new ResponseEntity<>(uploadFile.getFileContent(), responseHeaders, HttpStatus.OK); } else { return new ResponseEntity<>(responseHeaders, HttpStatus.NOT_MODIFIED); } }
From source file:com.biz.report.controller.ItemDashBoardController.java
@ResponseBody @RequestMapping(value = "itemreport/{year}/get", method = RequestMethod.POST, headers = { "Content-type=application/json" }) public ResponseEntity<ReportDataSet> readFTypes(@PathVariable("year") String year, @RequestBody Map data) { logger.info(year);//from w w w . jav a 2s.c o m logger.info(data); Assert.notNull(data, "Data is null."); Assert.notNull(year, "Year is null."); String items = data.get("items").toString(); String months = data.get("months").toString(); ReportDataSet reportDataSet = itemDashBoardService.getReports(items, months, year); HttpHeaders headers = new HttpHeaders(); headers.add("success", "Success"); return new ResponseEntity<ReportDataSet>(reportDataSet, headers, HttpStatus.OK); }
From source file:com.biz.report.controller.ReportController.java
@ResponseBody @RequestMapping(value = "report/{year}/get", method = RequestMethod.POST, headers = { "Content-type=application/json" }) public ResponseEntity<ReportDataSet> readFTypes(@PathVariable("year") String year, @RequestBody Map data) { logger.info(year);// w w w . j a v a 2s . c om logger.info(data); Assert.notNull(data, "Data is null."); Assert.notNull(year, "Year is null."); String types = data.get("types").toString(); String months = data.get("months").toString(); ReportDataSet reportDataSet = reportService.getReports(types, months, year); HttpHeaders headers = new HttpHeaders(); headers.add("success", "Success"); return new ResponseEntity<ReportDataSet>(reportDataSet, headers, HttpStatus.OK); }