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:de.codecentric.boot.admin.controller.RegistryController.java
/** * Register an application within this admin application. * /* www. jav a 2 s. c om*/ * @param app The application infos. * @return The registered application. */ @RequestMapping(value = "/api/applications", method = RequestMethod.POST) public ResponseEntity<Application> register(@RequestBody Application app) { LOGGER.debug("Register application {}", app.toString()); try { Application registeredApp = registry.register(app); return new ResponseEntity<Application>(registeredApp, HttpStatus.CREATED); } catch (ApplicationRegistryConflictException ex) { return new ResponseEntity<Application>(HttpStatus.CONFLICT); } }
From source file:org.trustedanalytics.examples.hbase.api.ExceptionHandlerAdvice.java
@ExceptionHandler({ TableExistsException.class, NoSuchColumnFamilyException.class }) @ResponseStatus(HttpStatus.CONFLICT) @ResponseBody/* w w w . jav a 2 s. c o m*/ public String handleConflict(Exception ex) { LOG.error("Resource already exists", ex); return ex.getMessage(); }
From source file:com.agroservices.restcontrollers.ComprasRest.java
/** * Mtodo encargado de definir si la informacin correspindiente a la tarjeta es valida * @param elemento la informacion de la tarjeta que debe ser aprobada * @return tranBancaria objeto que representa la transccion bancaria correspondiente a la compra *///from w w w . j av a2 s . co m @RequestMapping(value = "/tarjetaValidacion/", method = RequestMethod.POST) public ResponseEntity<?> validarTarjeta(@RequestBody informacionTarjeta elemento) { System.out.println("Elemento tarjtea:" + elemento.getNumero()); if (ef.validarTarjeta(elemento)) { TransaccionBancaria tranBacaria = new TransaccionBancaria( "TBOK" + String.valueOf(elemento.getNumero() * 2), null); return new ResponseEntity<>(tranBacaria, HttpStatus.OK); } else { return new ResponseEntity<>(HttpStatus.CONFLICT); } }
From source file:co.agileventure.jwtauth.web.controller.UserProcessorImpl.java
public ResponseEntity processUser(final HttpServletRequest request, final User.Provider provider, final String id, final String displayName, final String email, final String picture, final String name, final String givenName, final String familyName) throws JOSEException, ParseException { User user = null;//from www . j av a 2 s . com switch (provider) { case FACEBOOK: user = userService.findByFacebook(id); break; case GOOGLE: user = userService.findByGoogle(id); break; default: return new ResponseEntity<String>("Unknown OAUTH2.0 Provider", HttpStatus.NOT_FOUND); } //If not found by provider try to find it by email if (user == null && StringUtils.isNotEmpty(email)) { user = userService.findByEmail(email); } // Step 3a. If user is already signed in then link accounts. User userToSave; final String authHeader = request.getHeader(AuthUtils.AUTH_HEADER_KEY); if (StringUtils.isNotBlank(authHeader)) { if (user == null) { return new ResponseEntity<String>(String.format(CONFLICT_MSG, provider.capitalize()), HttpStatus.CONFLICT); } final String subject = AuthUtils.getSubject(authHeader); final User foundUser = userService.findOne(subject); if (foundUser == null) { return new ResponseEntity<String>(NOT_FOUND_MSG, HttpStatus.NOT_FOUND); } userToSave = foundUser; boolean updated = setUserProvider(provider, userToSave, id); if (userToSave.getDisplayName() == null) { userToSave.setDisplayName(displayName); updated = true; } if (userToSave.getPicture() == null) { userToSave.setPicture(picture); updated = true; } if (updated) { userToSave = userService.save(userToSave); } } else { // Step 3b. Create a new user account or return an existing one. if (user != null) { userToSave = user; if (setUserProvider(provider, userToSave, id)) { if (userToSave.getPicture() == null) { userToSave.setPicture(picture); } userToSave = userService.save(userToSave); } } else { userToSave = new User(); userToSave.setId(UUID.randomUUID().toString()); userToSave.setDisplayName(displayName); userToSave.setEmail(email); userToSave.setName(name); userToSave.setGivenName(givenName); userToSave.setPicture(picture); userToSave.setFamilyName(familyName); setUserProvider(provider, userToSave, id); userToSave = userService.save(userToSave); } } Token token = AuthUtils.createToken(request.getRemoteHost(), userToSave.getId()); return new ResponseEntity<Token>(token, HttpStatus.OK); }
From source file:com.trafficfine.controller.TrafficFineController.java
/** * /*from ww w. j a va 2 s . c o m*/ * @param infraction * @param ucBuilder * @return */ @RequestMapping(value = "/api/infracao/", method = RequestMethod.POST) public ResponseEntity<Void> createInfraction(@RequestBody Infraction infraction, UriComponentsBuilder ucBuilder) { logger.info("Creating infraction: " + infraction.getPlaca()); if (trafficFineService.isInfractionExist(infraction)) { logger.info("A infraction with license plate " + infraction.getPlaca() + " already exist"); return new ResponseEntity<Void>(HttpStatus.CONFLICT); } trafficFineService.saveInfraction(infraction); HttpHeaders header = new HttpHeaders(); header.setLocation(ucBuilder.path("/").buildAndExpand(infraction.getId()).toUri()); return new ResponseEntity<Void>(header, HttpStatus.CREATED); }
From source file:io.sevenluck.chat.controller.ChatRoomController.java
@ExceptionHandler @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) public ResponseEntity<?> handleException(ChatRoomAlreadyExists e) { logger.error("validate:", e.getMessage()); return new ResponseEntity<>(ExceptionDTO.newConflictInstance(e.getMessage()), new HttpHeaders(), HttpStatus.CONFLICT); }
From source file:com.agroservices.restcontrollers.DespachoRest.java
@RequestMapping(value = "/{id}/seRecogio", method = RequestMethod.POST) public ResponseEntity<?> modificarEstadoRecogida(@PathVariable int id, @RequestBody Despacho des) { boolean ans = df.setEstadoRecogida(id, des.isSeRecogio()); if (ans) {/*from w ww . j av a2 s.c o m*/ return new ResponseEntity<>(HttpStatus.CREATED); } return new ResponseEntity<>(HttpStatus.CONFLICT); }
From source file:de.codecentric.boot.admin.controller.RegistryControllerTest.java
@Test public void register_sameUrl() { controller.register(new Application("http://localhost", "FOO")); ResponseEntity<?> response = controller.register(new Application("http://localhost", "BAR")); assertEquals(HttpStatus.CONFLICT, response.getStatusCode()); }
From source file:ca.qhrtech.controllers.UserController.java
@ApiMethod(description = "Add a new User to BGL") @RequestMapping(value = "/user", method = RequestMethod.POST) public ResponseEntity<BGLUser> createUser(@RequestBody BGLUser user) { if (!userService.doesUserExist(user)) { user.setJoinDate(LocalDateTime.now()); String hash = new BCryptPasswordEncoder().encode(user.getPassword()); user.setPassword(hash);/*from w w w . ja v a2s. com*/ BGLUser newUser = userService.saveUser(user); return new ResponseEntity<>(newUser, HttpStatus.CREATED); } return new ResponseEntity<>(HttpStatus.CONFLICT); }
From source file:org.trustedanalytics.user.invite.RestErrorHandler.java
@ResponseBody @ResponseStatus(HttpStatus.CONFLICT) @ExceptionHandler(UserExistsException.class) public UserConflictResponse userExists(UserExistsException e) throws IOException { return UserConflictResponse.of(UserConflictResponse.ConflictedField.USER, e.getMessage()); }