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:edu.eci.cosw.restcontrollers.ClienteRest.java
@RequestMapping(value = "/", method = RequestMethod.POST) public ResponseEntity<?> persist(@RequestBody Cliente c) { if (sf.existeCliente(c.getIdcliente())) { return new ResponseEntity<>(HttpStatus.CONFLICT); } else {// w w w . j av a 2 s .c o m sf.guardarCliente(c); } return new ResponseEntity<>(HttpStatus.CREATED); }
From source file:com.coffeebeans.services.controller.base.BaseController.java
@ResponseBody @ExceptionHandler(DuplicateEntryException.class) @ResponseStatus(value = HttpStatus.CONFLICT) ErrorResponse handleException(DuplicateEntryException e) { return new ErrorResponse(HttpStatus.CONFLICT.toString(), e.getMessage(), "Duplicated User"); }
From source file:com.opensearchserver.hadse.index.IndexCatalog.java
public final static ResponseEntity<?> create(String indexName, int shards, int replicas) throws HadseIndexException, JsonGenerationException, JsonMappingException, IOException { File indexDirectory = new File(Hadse.data_dir, indexName); if (indexDirectory.exists()) return new ResponseEntity<Object>(HttpStatus.CONFLICT); if (!indexDirectory.mkdir()) return new ResponseEntity<String>("Unable to create the index directory", HttpStatus.INTERNAL_SERVER_ERROR); IndexItem indexItem = IndexItem.get(indexName); for (int shard = 1; shard <= shards; shard++) { String shardName = Integer.toString(shard); ShardDef shardDef = ShardDef.write(indexDirectory, shardName, ClusterCatalog.nextShardCandidate()); indexItem.add(ShardItem.load(shardDef, indexDirectory)); }/*from w ww . j a v a 2 s . c om*/ return new ResponseEntity<String>("Index created: " + indexName, HttpStatus.CREATED); }
From source file:com.bofa.sstradingreport.support.ExceptionHandlerAdvice.java
@ExceptionHandler(DataIntegrityViolationException.class) public ResponseEntity<String> handleDataIntegrityViolationException(DataIntegrityViolationException e) throws Exception { return new ResponseEntity<>(HttpStatus.CONFLICT); }
From source file:com.agroservices.restcontrollers.VentasRest.java
@RequestMapping(value = "/", method = RequestMethod.POST) public ResponseEntity<?> notificarVenta(@RequestBody Venta v) { try {/*w w w .ja va2 s. c o m*/ vf.guardarVenta(v); } catch (Exception e) { System.out.println(e.getMessage()); return new ResponseEntity<>(HttpStatus.CONFLICT); } return new ResponseEntity<>(HttpStatus.CREATED); }
From source file:com.agroservices.restcontrollers.CampesinoRest.java
@RequestMapping(value = "/", method = RequestMethod.POST) public ResponseEntity<?> persist(@RequestBody Campesino c) { try {/* w w w .j av a2s. c om*/ cf.guardarCampesino(c); } catch (Exception e) { System.out.println(e.getMessage()); return new ResponseEntity<>(HttpStatus.CONFLICT); } return new ResponseEntity<>(HttpStatus.CREATED); }
From source file:com.sentinel.web.controllers.RegistrationController.java
@RequestMapping(value = "/user", method = RequestMethod.POST) @ResponseBody/*from ww w . j a va 2 s . c om*/ public ResponseEntity<Void> createUser(@RequestBody UserForm accountDto, UriComponentsBuilder ucBuilder) { LOG.debug("Registring new user"); final User registered = createUserAccount(accountDto); if (registered == null) { return new ResponseEntity<Void>(HttpStatus.CONFLICT); } /* if (userService.isUserExist(user)) { System.out.println("A User with name " + user.getUsername() + " already exist"); } */ userService.saveRegisteredUser(registered); HttpHeaders headers = new HttpHeaders(); headers.setLocation(ucBuilder.path("/user/{id}").buildAndExpand(registered.getId()).toUri());//TODO return new ResponseEntity<Void>(headers, HttpStatus.CREATED); }
From source file:gt.dakaik.exceptions.ManejadorExcepciones.java
@ResponseBody @ExceptionHandler(GeneralException.class) @ResponseStatus(HttpStatus.CONFLICT) Map<String, String> generalExceptionHandler(GeneralException ex) { Map<String, String> res = new HashMap<>(); res.put("error", "Error de Servicio"); res.put("entidad", ex.getMessage()); StringWriter errors = new StringWriter(); ex.printStackTrace(new PrintWriter(errors)); String err = errors.toString(); eLog.error(err);//from w w w. j av a 2 s. c o m return res; }
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 source file:com.redblackit.web.test.RestTemplateTestHelperTest.java
/** * Method returning parameters, which also sets up the servlets to use *//* w ww. j ava2 s. com*/ @Parameters public static List<Object[]> getParameters() throws Exception { final String[] methods = { "GET", "POST", "PUT", "DELETE", "HEAD", "OPTIONS" }; final HttpStatus[][] codes = { { HttpStatus.INTERNAL_SERVER_ERROR, HttpStatus.INTERNAL_SERVER_ERROR, HttpStatus.INTERNAL_SERVER_ERROR, HttpStatus.INTERNAL_SERVER_ERROR, HttpStatus.INTERNAL_SERVER_ERROR, HttpStatus.INTERNAL_SERVER_ERROR }, { HttpStatus.NOT_FOUND, HttpStatus.FORBIDDEN, HttpStatus.CONFLICT, HttpStatus.INTERNAL_SERVER_ERROR, HttpStatus.METHOD_NOT_ALLOWED, HttpStatus.PRECONDITION_FAILED }, { HttpStatus.NOT_FOUND, HttpStatus.INTERNAL_SERVER_ERROR, HttpStatus.INTERNAL_SERVER_ERROR, HttpStatus.INTERNAL_SERVER_ERROR, HttpStatus.NOT_FOUND, HttpStatus.NOT_FOUND } }; ServletContextHandler jettyContext = new ServletContextHandler(ServletContextHandler.SESSIONS); jettyContext.setContextPath("/"); server.setHandler(jettyContext); List<Object[]> parameters = new ArrayList<Object[]>(); for (int i = 0; i < codes.length; ++i) { String url = "/test" + i; Map<String, HttpStatus> mcmap = new HashMap<String, HttpStatus>(); for (int j = 0; j < methods.length; ++j) { mcmap.put(methods[j], codes[i][j]); } jettyContext.addServlet(new ServletHolder(new StatusCodeServlet(mcmap)), url); parameters.add(new Object[] { BASE_URL + url, mcmap }); } server.start(); int i = 0; while (!server.isStarted() && i < 20) { Thread.sleep(200); ++i; } if (!server.isStarted()) { Assert.fail("server not started"); } return parameters; }