List of usage examples for org.springframework.http HttpStatus ALREADY_REPORTED
HttpStatus ALREADY_REPORTED
To view the source code for org.springframework.http HttpStatus ALREADY_REPORTED.
Click Source Link
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 ava2s .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.opensearchserver.hadse.cluster.ClusterCatalog.java
final static HttpEntity<?> add(Collection<String> addresses) throws URISyntaxException, JsonGenerationException, JsonMappingException, IOException { lock.w.lock();// w w w . ja v a 2 s. c om try { for (String addr : addresses) if (addressMap.containsKey(addr)) return new ResponseEntity<String>("The address is already registered: " + addr, HttpStatus.ALREADY_REPORTED); NodeItem newNode = new NodeItem(addresses); nodes.add(newNode); for (String ad : addresses) { if (isLocal(ad)) { localNode = newNode; break; } } JsonUtils.mapper.writeValue(clusterFile, nodes); return new ResponseEntity<String>("Node registered", HttpStatus.ACCEPTED); } finally { lock.w.unlock(); } }
From source file:com.projectx.mvc.servicehandler.quickregister.QuickRegisterHandler.java
@Override public QuickRegisterSavedEntityDTO addNewCustomer(QuickRegisterEntity customerQuickRegisterEntity) throws QuickRegisterDetailsAlreadyPresentException { HttpEntity<QuickRegisterEntity> entity = new HttpEntity<QuickRegisterEntity>(customerQuickRegisterEntity); ResponseEntity<QuickRegisterSavedEntityDTO> result = restTemplate.exchange( env.getProperty("rest.host") + "/customer/quickregister", HttpMethod.POST, entity, QuickRegisterSavedEntityDTO.class); if (result.getStatusCode() == HttpStatus.CREATED) return result.getBody(); else if (result.getStatusCode() == HttpStatus.NOT_ACCEPTABLE) throw new ValidationFailedException(); else if (result.getStatusCode() == HttpStatus.ALREADY_REPORTED) throw new QuickRegisterDetailsAlreadyPresentException(); throw new ResourceNotFoundException(); }