List of usage examples for org.springframework.http HttpStatus CONFLICT
HttpStatus CONFLICT
To view the source code for org.springframework.http HttpStatus CONFLICT.
Click Source Link
From source file:bg.vitkinov.edu.services.JokeCategoryService.java
@RequestMapping(method = { RequestMethod.POST, RequestMethod.PUT }) public ResponseEntity<?> insert(@RequestParam String name, @RequestParam String keywords) { Optional<Category> category = repository.findByName(name); if (category.isPresent()) { return new ResponseEntity<>(category.get(), HttpStatus.CONFLICT); }/*w w w . j a v a 2s.c om*/ Category newCateogry = new Category(); newCateogry.setName(name); newCateogry.setKeyWords(getKewWors(keywords)); return new ResponseEntity<>(repository.save(newCateogry), HttpStatus.CREATED); }
From source file:ca.qhrtech.controllers.GameController.java
@ApiMethod(description = "Create a new Game") @RequestMapping(value = "/game", method = RequestMethod.POST) public ResponseEntity<Game> createGame(@RequestBody Game game) { if (!gameService.doesGameExist(game)) { Game newGame = gameService.saveGame(game); return new ResponseEntity<>(newGame, HttpStatus.CREATED); }/*from w ww . j a va2s . c om*/ return new ResponseEntity<>(HttpStatus.CONFLICT); }
From source file:org.osiam.resources.exception.OsiamExceptionHandler.java
@ExceptionHandler(ResourceExistsException.class) @ResponseStatus(HttpStatus.CONFLICT) @ResponseBody/*from w w w . j a v a 2s .co m*/ public ErrorResponse handleResourceExists(ResourceExistsException e) { return produceErrorResponse(e.getMessage(), HttpStatus.CONFLICT); }
From source file:com.sambrannen.samples.events.web.RestEventController.java
@ResponseStatus(HttpStatus.CONFLICT) @ExceptionHandler(DataIntegrityViolationException.class) public void handleDatabaseConstraintViolation() { /* no-op */ }
From source file:it.reply.orchestrator.exception.GlobalControllerExceptionHandler.java
/** * Conflict exception handler.// ww w. j a v a 2s . c om * * @param ex * the exception * @return a {@code ResponseEntity} instance */ @ExceptionHandler @ResponseStatus(HttpStatus.CONFLICT) @ResponseBody public Error handleException(ConflictException ex) { return new Error().withCode(HttpStatus.CONFLICT.value()).withTitle(HttpStatus.CONFLICT.getReasonPhrase()) .withMessage(ex.getMessage()); }
From source file:ca.qhrtech.controllers.ResultController.java
@ApiMethod(description = "Create a new Game Result") @RequestMapping(value = "/result", method = RequestMethod.POST) public ResponseEntity<GameResult> createResult(@RequestBody GameResult result) { if (!resultService.doesResultExist(result)) { GameResult newResult = resultService.saveResult(result); return new ResponseEntity<>(newResult, HttpStatus.CREATED); }// w w w . j av a 2s . c o m return new ResponseEntity<>(HttpStatus.CONFLICT); }
From source file:rest.DependenciaRestController.java
@RequestMapping(value = "/dependencia/", method = RequestMethod.POST) public ResponseEntity<Void> createDependencia(@RequestBody DependenciaBean dependencia, UriComponentsBuilder ucBuilder) { System.out.println("Registrar una Dependencia"); if (dependenciaService.isDependenciaExist(dependencia)) { System.out.println("La dependencia con Nombre " + dependencia.getDesDep() + " ya existe."); return new ResponseEntity<Void>(HttpStatus.CONFLICT); }/* w w w . j av a2s . c o m*/ dependenciaService.save(dependencia); HttpHeaders headers = new HttpHeaders(); headers.setLocation( ucBuilder.path("/dependencia/{codDep}").buildAndExpand(dependencia.getCodDep()).toUri()); return new ResponseEntity<Void>(headers, HttpStatus.CREATED); }
From source file:cz.muni.fi.editor.webapp.controllers.ajax.AjaxOrganizationController.java
@RequestMapping(value = "/changeName/", method = RequestMethod.POST) public ResponseEntity<String> changeOrganizationName(@RequestParam Long organization, @RequestParam String name) { OrganizationDTO org = new OrganizationDTO(); org.setId(organization);// w w w .j a v a 2 s .com org.setOrganizationName(name); try { organizationService.rename(org); return OK; } catch (FieldException ex) { log.warn(ex); return new ResponseEntity<>(ex.getMessage(), HttpStatus.CONFLICT); } }
From source file:com.mycompany.springrest.controllers.UserController.java
@RequestMapping(value = "/user/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Void> createUser(@RequestBody User user, UriComponentsBuilder ucBuilder) { logger.info("Creating User " + user.getUserName()); if (userService.isUserExist(user)) { logger.info("A User with name " + user.getUserName() + " already exist"); return new ResponseEntity<Void>(HttpStatus.CONFLICT); }/*from ww w.j a v a2 s . com*/ userService.addUser(user); HttpHeaders headers = new HttpHeaders(); headers.setLocation(ucBuilder.path("/user/{id}").buildAndExpand(user.getId()).toUri()); return new ResponseEntity<Void>(headers, HttpStatus.CREATED); }
From source file:com._8x8.presentation.restController.UserRestController.java
@RequestMapping(value = "/user/", method = RequestMethod.POST) public ResponseEntity<Void> createUser(@RequestBody User user, UriComponentsBuilder ucBuilder) { System.out.println("Creating Username: " + user.getUsername()); if (_userService.isUserExist(user)) { System.out.println("A User with name " + user.getUsername() + " already exist"); return new ResponseEntity<Void>(HttpStatus.CONFLICT); }// w w w.j a v a 2 s .c o m _userService.InsertUser(user); HttpHeaders headers = new HttpHeaders(); headers.setLocation(ucBuilder.path("/user/{id}").buildAndExpand(user.getId()).toUri()); return new ResponseEntity<Void>(headers, HttpStatus.CREATED); }