List of usage examples for org.springframework.http ResponseEntity ResponseEntity
public ResponseEntity(MultiValueMap<String, String> headers, HttpStatus status)
From source file:edu.eci.arsw.pacm.controllers.PacmRESTController.java
@RequestMapping(path = "/{salanum}/atacantes", method = RequestMethod.PUT) public ResponseEntity<?> agregarAtacante(@PathVariable(name = "salanum") String salanum, @RequestBody Player p) {// w w w .j a va 2 s.c om synchronized (services) { try { if (services.getAtacantes(Integer.parseInt(salanum)).size() < 4) { services.registrarJugadorAtacante(Integer.parseInt(salanum), p); } } catch (ServicesException ex) { Logger.getLogger(PacmRESTController.class.getName()).log(Level.SEVERE, null, ex); return new ResponseEntity<>(ex.getLocalizedMessage(), HttpStatus.BAD_REQUEST); } return new ResponseEntity<>(HttpStatus.CREATED); } }
From source file:com.nebhale.buildmonitor.web.ControllerUtils.java
@ExceptionHandler(ConstraintViolationException.class) ResponseEntity<Set<String>> handleConstraintViolation(ConstraintViolationException e) { Set<ConstraintViolation<?>> constraintViolations = e.getConstraintViolations(); Set<String> messages = new HashSet<>(constraintViolations.size()); messages.addAll(constraintViolations.stream() .map(constraintViolation -> String.format("%s value '%s' %s", constraintViolation.getPropertyPath(), constraintViolation.getInvalidValue(), constraintViolation.getMessage())) .collect(Collectors.toList())); return new ResponseEntity<>(messages, HttpStatus.BAD_REQUEST); }
From source file:br.com.hyperclass.snackbar.restapi.OrderController.java
@RequestMapping(value = "/order/all", method = RequestMethod.GET) public ResponseEntity<ProductsWrapper> orderItemProducts() { return new ResponseEntity<ProductsWrapper>(new ProductsWrapper(order.getProductsOrder()), HttpStatus.OK); }
From source file:com.seguriboxltv.ws.HsmKeyRest.java
@RequestMapping(value = "/sdhsmkey", method = RequestMethod.GET, headers = "Accept=application/json") @ResponseBody//from w w w . j a va 2 s . c om public ResponseEntity<List<HSMKey>> getAllHsmKey() { List<HSMKey> list = null; try { list = hsmKeyService.SDGetAll(); } catch (Exception e) { } return new ResponseEntity<>(list, HttpStatus.OK); }
From source file:net.paulgray.lmsrest.grades.GradesController.java
@RequestMapping(method = RequestMethod.GET, produces = "application/json", value = CourseController.PATH + "/{course}/" + GradesController.PATH) public ResponseEntity getAnnouncements(@ContextUser User user, @PathVariable Course course) { return new ResponseEntity(gradesService.getGradesForUserAndCourse(user, course), HttpStatus.OK); }
From source file:edu.sjsu.cmpe275.project.controller.OrderController.java
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE) public ResponseEntity<?> checkOut(@PathVariable(value = "id") Long id) { return new ResponseEntity(orderService.checkOut(id), HttpStatus.OK); }
From source file:reconf.server.services.component.ReadComponentService.java
@RequestMapping(value = "/product/{prod}/component/{comp}", method = RequestMethod.GET) @Transactional(readOnly = true)// w w w . ja v a 2s . c om public ResponseEntity<ComponentResult> doIt(@PathVariable("prod") String productId, @PathVariable("comp") String componentId, HttpServletRequest request, Authentication auth) { ComponentKey key = new ComponentKey(productId, componentId); Component reqComponent = new Component(key); List<String> errors = DomainValidator.checkForErrors(key); if (!errors.isEmpty()) { return new ResponseEntity<ComponentResult>(new ComponentResult(reqComponent, errors), HttpStatus.BAD_REQUEST); } Component dbComponent = components.findOne(key); if (dbComponent == null) { return new ResponseEntity<ComponentResult>(new ComponentResult(reqComponent, Component.NOT_FOUND), HttpStatus.NOT_FOUND); } return new ResponseEntity<ComponentResult>( new ComponentResult(dbComponent, CrudServiceUtils.getBaseUrl(request)), HttpStatus.OK); }
From source file:br.com.avelar.bac.controllers.CarController.java
@CrossOrigin @RequestMapping("/all") public ResponseEntity<List<Car>> findAll() { return new ResponseEntity<List<Car>>(service.findAll(), HttpStatus.OK); }
From source file:com.sentinel.web.controllers.AdminController.java
@RequestMapping(value = "/users/{userId}/grant/role", method = RequestMethod.POST) @PreAuthorize(value = "hasRole('SUPER_ADMIN_PRIVILEGE')") @ResponseBody// www. j av a2 s . co m public ResponseEntity<String> grantSimpleRole(@PathVariable Long userId) { User user = userRepository.findOne(userId); LOG.debug("Allow user for Simle user permissions"); if (user == null) { return new ResponseEntity<String>("invalid user id", HttpStatus.UNPROCESSABLE_ENTITY); } Role role = roleRepository.findByName("ROLE_SIMPLE_USER"); userService.grantRole(user, role); user.setEnabled(true); userRepository.saveAndFlush(user); return new ResponseEntity<String>("role granted", HttpStatus.OK); }
From source file:org.oncoblocks.centromere.web.exceptions.RestExceptionHandler.java
/** * Catches a {@link org.oncoblocks.centromere.web.exceptions.RestException} thrown bt a web service * controller and returns an informative message. * //from w w w . ja v a 2 s .c om * @param ex {@link org.oncoblocks.centromere.web.exceptions.RestException} * @param request {@link WebRequest} * @return {@link org.oncoblocks.centromere.web.exceptions.RestError} */ @ExceptionHandler(value = { RestException.class }) public ResponseEntity<RestError> handleRestException(RestException ex, WebRequest request) { RestError restError = ex.getRestError(); return new ResponseEntity<>(restError, restError.getStatus()); }