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:edu.infsci2560.services.FriendService.java
@RequestMapping(value = "/{id}", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Friend> list(@PathVariable("id") Long id) { HttpHeaders headers = new HttpHeaders(); return new ResponseEntity<>(repository.findOne(id), headers, HttpStatus.OK); }
From source file:edu.infsci2560.services.DvdsService.java
@RequestMapping(value = "/{id}", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Dvd> list(@PathVariable("id") Long id) { HttpHeaders headers = new HttpHeaders(); return new ResponseEntity<>(repository.findOne(id), headers, HttpStatus.OK); }
From source file:edu.infsci2560.services.BookService.java
@RequestMapping(value = "/{id}", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Book> list(@PathVariable("id") Long id) { HttpHeaders headers = new HttpHeaders(); return new ResponseEntity<>(repository.findOne(id), headers, HttpStatus.OK); }
From source file:edu.infsci2560.services.LocationsService.java
@RequestMapping(value = "/{id}", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Location> list(@PathVariable("id") Long id) { HttpHeaders headers = new HttpHeaders(); return new ResponseEntity<>(repository.findOne(id), headers, HttpStatus.OK); }
From source file:io.sevenluck.chat.controller.ChatMemberController.java
@ExceptionHandler @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) public ResponseEntity<?> handleException(MemberAlreadyExistsException e) { logger.error("validate:", e.getMessage()); return new ResponseEntity<>(ExceptionDTO.newConflictInstance(e.getMessage()), new HttpHeaders(), HttpStatus.CONFLICT);//from w w w . j a va 2 s.co m }
From source file:io.sevenluck.chat.controller.LoginController.java
@ExceptionHandler @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) public ResponseEntity<?> handleException(LoginException e) { logger.error("login failed:", e.getMessage()); return new ResponseEntity<>(ExceptionDTO.newUnauthorizedInstance(e.getMessage()), new HttpHeaders(), HttpStatus.UNAUTHORIZED);//ww w . j av a 2s . c om }
From source file:org.openmrs.module.patientimage.rest.controller.PatientImageController.java
/** * @param patientid int/*from w ww . ja v a 2 s . com*/ * @param pageid int * @return ResponseEntity<byte[]> containing image binary data with JPEG * image header. * @throws ResponseException * @throws IOException */ @RequestMapping(value = "/{patientid}/{pageid}", method = RequestMethod.GET) public ResponseEntity<byte[]> retrieve(@PathVariable("patientid") String patientIdStr, @PathVariable("pageid") String pageIdStr, HttpServletRequest request) throws IOException { //RequestContext context = RestUtil.getRequestContext(request); int patientId = Integer.parseInt(patientIdStr); int pageId = Integer.parseInt(pageIdStr); final HttpHeaders headers = new HttpHeaders(); byte[] imageData = null; HttpStatus status = null; headers.setContentType(MediaType.IMAGE_JPEG); status = HttpStatus.OK; return new ResponseEntity<byte[]>(imageData, headers, status); }
From source file:com.healthcit.cacure.web.controller.FormElementBatchDeleteController.java
@RequestMapping(value = "/questionList.delete", method = RequestMethod.POST) public ResponseEntity<String> batchDelete(@RequestParam(value = "feIds[]", required = false) Long[] feIds) { HashSet<Long> uniqueIds = new HashSet<Long>(Arrays.asList(feIds)); Set<Long> deleted = new HashSet<Long>(); for (Long id : uniqueIds) { try {//from w ww. j av a 2 s. c o m qaManager.deleteFormElementByID(id); deleted.add(id); } catch (Exception e) { e.printStackTrace(); } } JSONArray jsonArray = new JSONArray(); for (Long id : deleted) { jsonArray.add(id); } HttpHeaders headers = new HttpHeaders(); headers.add("Content-Type", "application/json"); return new ResponseEntity<String>(jsonArray.toString(), headers, HttpStatus.OK); }
From source file:com.fabionoth.rest.RobotRest.java
/** * * @param command//from w w w .j a v a2 s . c o m * @return */ @RequestMapping(value = { "rest/mars/", "/rest/mars/{command}" }, method = { RequestMethod.GET, RequestMethod.POST }) public ResponseEntity<String> sendCommand(@PathVariable Optional<String> command) { Robot robot; robot = new Robot(new Long(1), 0, 0, CardinalPoints.N); HttpHeaders responseHeaders = new HttpHeaders(); responseHeaders.setContentType(MediaType.TEXT_HTML); if (command.isPresent()) { try { robot = new RobotController(robot, command.get()).getRobot(); } catch (Exception ex) { Logger.getLogger(RobotRest.class.getName()).log(Level.SEVERE, null, ex); return new ResponseEntity<>("Erro", responseHeaders, HttpStatus.BAD_REQUEST); } } String response = "(" + robot.getX() + ", " + robot.getY() + ", " + robot.getC().toString() + ")"; return new ResponseEntity<>(response, responseHeaders, HttpStatus.OK); }
From source file:org.busko.routemanager.web.RoutePlotterController.java
@RequestMapping(method = RequestMethod.GET) public ResponseEntity<byte[]> handheldApk(Model uiModel, HttpServletRequest httpServletRequest) throws Exception { InputStream input = getClass().getClassLoader().getResourceAsStream("BuskoPlotter.apk"); int fileSize = input.available(); byte[] bytes = new byte[fileSize]; input.read(bytes);/*from w ww . j a v a2 s . com*/ input.close(); HttpHeaders responseHeaders = new HttpHeaders(); responseHeaders.set("Content-Disposition", "attachment;filename=BuskoPlotter.apk"); responseHeaders.set("Content-Length", Integer.toString(fileSize)); responseHeaders.set("Content-Type", "application/vnd.android.package-archive"); return new ResponseEntity<byte[]>(bytes, responseHeaders, HttpStatus.OK); }