List of usage examples for org.springframework.http ResponseEntity ResponseEntity
public ResponseEntity(MultiValueMap<String, String> headers, HttpStatus status)
From source file:com.chevres.rss.restapi.controller.LoginController.java
@CrossOrigin @RequestMapping(path = "/login", method = RequestMethod.POST) @ResponseBody/*from w w w .j a va 2s .c o m*/ public ResponseEntity<String> login(@RequestBody User user, BindingResult bindingResult) { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring.xml"); userValidator.validate(user, bindingResult); if (bindingResult.hasErrors()) { context.close(); return new ResponseEntity(new ErrorMessageResponse("bad_params"), HttpStatus.BAD_REQUEST); } UserDAO userDAO = context.getBean(UserDAO.class); UserAuthDAO userAuthDAO = context.getBean(UserAuthDAO.class); User foundUser = userDAO.findByUsernameAndPassword(user.getUsername(), user.getPassword()); if (foundUser == null) { context.close(); return new ResponseEntity(new ErrorMessageResponse("bad_credentials"), HttpStatus.BAD_REQUEST); } TokenGenerator tg = new TokenGenerator(); Date date = new Date(); Timestamp timestamp = new Timestamp(date.getTime()); UserAuth userAuth = new UserAuth(); userAuth.setIdUser(foundUser.getId()); userAuth.setToken(tg.getToken()); userAuth.setCreateDate(timestamp); userAuthDAO.create(userAuth); context.close(); return new ResponseEntity(new SuccessLoginResponse(userAuth.getToken()), HttpStatus.OK); }
From source file:edu.sjsu.cmpe275.project.controller.OrderController.java
@RequestMapping(value = "/{id}", method = RequestMethod.GET) public ResponseEntity<?> get(@PathVariable(value = "id") Long id) { return new ResponseEntity<Object>(orderService.get(id), HttpStatus.OK); }
From source file:cr.ac.siua.tec.controllers.FormController.java
/** * In charge of receiving mobile requests (forms) and validating them. No captcha response required. *//*from w w w . j a v a 2 s. com*/ @RequestMapping(value = "/mobileRequest", method = RequestMethod.POST) public ResponseEntity<HashMap<String, String>> createMobileTicket(@RequestBody HashMap<String, String> map) { return new ResponseEntity<>(getRequestResponseMap(map), HttpStatus.OK); }
From source file:edu.sjsu.cmpe275.project.controller.ReportController.java
@RequestMapping(value = "/daily") public ResponseEntity<?> roomDailyReport(@RequestParam(value = "date", required = true) Date date) { RoomReportData result = null;/*from ww w . ja va 2 s. c om*/ Date today = new Date(); int i = DateTool.compare(date, today); if (i == 0) { result = reportService.currentReport(date); } else if (i < 0) { result = reportService.postRport(date); } else { result = reportService.futureReprot(date); } return new ResponseEntity(result, HttpStatus.OK); }
From source file:edu.eci.cosw.restcontrollers.RestControladorRegistrarReserva.java
@RequestMapping(value = "/registrors", method = RequestMethod.POST) public ResponseEntity<?> registrarReserva(@RequestBody Reservacion r) { HttpStatus hs;/*from w w w . j av a 2 s.c o m*/ String mens = ""; try { mens = logica.registrarReserva(r.getSala().getEstablecimiento().getIdEstablecimiento(), r.getSala().getIdSala(), r.getFecha(), r.getHora(), r.getTiempo()); hs = HttpStatus.CREATED; } catch (Exception ex) { mens = ex.getMessage(); hs = HttpStatus.ALREADY_REPORTED; } //retorna el estado 201 en caso de que la operacin haya sido exitosa return new ResponseEntity<>(mens, hs); }
From source file:com.pw.ism.controllers.CommunicationController.java
@RequestMapping(value = "/newmessage", method = RequestMethod.POST, headers = { "Content-type=application/json" }) public ResponseEntity<String> newReport(@Valid @RequestBody AsiNetworkReport report, BindingResult bindingResults) {/*from w w w . ja v a2s. co m*/ if (bindingResults.hasErrors()) { LOGGER.info("JSON not correct, BADREQUEST! Count: {}", bindingResults.getFieldErrorCount()); return new ResponseEntity<>("NOK!", HttpStatus.BAD_REQUEST); } else { LOGGER.info("new post for message, customer: {}, network: {}, text: {}, sensor: {}", new Object[] { report.getCustomer(), report.getNetwork(), report.getText(), report.getSensor() }); Message message = new Message(report.getCustomer(), report.getNetwork(), "Sensor ID: " + report.getSensor() + " Message: " + report.getText()); messageRepository.save(message); return new ResponseEntity<>("OK", HttpStatus.OK); } }
From source file:fi.hsl.parkandride.front.SchemaController.java
@RequestMapping(method = GET, value = PRICING_METHODS) public ResponseEntity<List<PricingMethod>> pricingMethods() { return new ResponseEntity<>(asList(PricingMethod.values()), OK); }
From source file:net.thewaffleshop.nimbus.web.WebJarsController.java
@ResponseBody @RequestMapping("/webjarslocator/{webjar}/**") public ResponseEntity locateWebjarAsset(@PathVariable String webjar, HttpServletRequest request) { try {/*from w w w.j a va 2 s. c o m*/ String mvcPrefix = "/webjarslocator/" + webjar + "/"; String mvcPath = (String) request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE); String fullPath = assetLocator.getFullPath(webjar, mvcPath.substring(mvcPrefix.length())); return new ResponseEntity(new ClassPathResource(fullPath), HttpStatus.OK); } catch (Exception e) { return new ResponseEntity<>(HttpStatus.NOT_FOUND); } }
From source file:com.coinblesk.server.controller.FeeController.java
@RequestMapping(value = "/fee", method = GET, produces = APPLICATION_JSON_UTF8_VALUE) @ResponseBody//from www .j a v a 2s . c om public ResponseEntity<FeeTO> fee() { FeeTO output = new FeeTO(); try { output.fee(feeService.fee()); return new ResponseEntity<>(output, OK); } catch (Exception e) { LOG.error("{fee} - SERVER_ERROR - exception: ", e); output.type(SERVER_ERROR); output.message(e.getMessage()); return new ResponseEntity<>(output, BAD_REQUEST); } }
From source file:com.itn.webservices.AdminControllerWebservice.java
@RequestMapping("/foods") public ResponseEntity<List<FoodInventory>> findAllList() { List<FoodInventory> allFoodList = foodInventoryService.findAll(); logger.info("size is {}", allFoodList.size()); return new ResponseEntity<List<FoodInventory>>(allFoodList, HttpStatus.OK); }