List of usage examples for org.springframework.http HttpStatus NOT_ACCEPTABLE
HttpStatus NOT_ACCEPTABLE
To view the source code for org.springframework.http HttpStatus NOT_ACCEPTABLE.
Click Source Link
From source file:org.oncoblocks.centromere.web.exceptions.MalformedEntityException.java
public MalformedEntityException(Integer code, String message, String developerMessage, String moreInfoUrl) { super(HttpStatus.NOT_ACCEPTABLE, code, message, developerMessage, moreInfoUrl); }
From source file:edu.eci.arsw.blindway.controller.UsuarioController.java
@RequestMapping(value = "/registro", method = RequestMethod.POST) public ResponseEntity<?> manejadorPostRecursoUsuario(String nombre, int edad, String genero, String nickname, String contrasena, String correoElectronico) { try {/*from w w w.ja va2s .c om*/ stub.registroUsuario(nombre, edad, genero, nickname, contrasena, correoElectronico); return new ResponseEntity<>("El usuario fue creado satisfactoriamente.", HttpStatus.CREATED); } catch (RegistroUsuarioException ex) { return new ResponseEntity<>(ex.getMessage(), HttpStatus.NOT_ACCEPTABLE); } }
From source file:edu.eci.arsw.blindway.controller.SalaController.java
@RequestMapping(path = "/creacion/{nick}", method = RequestMethod.GET) public ResponseEntity<?> manejadorGetRecursoSalaCreacion(@PathVariable String nick) { try {/*w w w . ja v a 2s . c o m*/ Usuario u = StubUsuario.getInstance().cargarUsuarioPorNick(nick); int id = StubSala.getInstance().crearSala(u); return new ResponseEntity<>(StubSala.getInstance().obtenerSala(id), HttpStatus.ACCEPTED); } catch (RegistroUsuarioException | CreacionSalaException ex) { Logger.getLogger(SalasController.class.getName()).log(Level.SEVERE, null, ex); return new ResponseEntity<>(ex.getMessage(), HttpStatus.NOT_ACCEPTABLE); } }
From source file:edu.eci.arsw.blindway.controller.UsuarioController.java
@RequestMapping(value = "/login/{user}/{pswd}", method = RequestMethod.GET) public ResponseEntity<?> manejadorPostRecursoUsuario(@PathVariable String user, @PathVariable String pswd) { try {/*ww w. j av a 2s. com*/ return new ResponseEntity<>(stub.cargarUsuarioLogeado(user, pswd), HttpStatus.ACCEPTED); } catch (RegistroUsuarioException ex) { return new ResponseEntity<>(ex.getMessage(), HttpStatus.NOT_ACCEPTABLE); } }
From source file:edu.eci.arsw.blindway.controller.SalasController.java
@RequestMapping(path = "/choose/{nick}/{id}", method = RequestMethod.GET) public ResponseEntity<?> manejadorUnionSalas(@PathVariable String nick, @PathVariable Integer id) { try {/*from w w w. j a v a 2s .c om*/ Usuario u = StubUsuario.getInstance().cargarUsuarioPorNick(nick); Sala s = salas.obtenerSala(id); return new ResponseEntity<>(s.ingresarSala(u, ""), HttpStatus.ACCEPTED); } catch (CreacionSalaException | RegistroUsuarioException ex) { return new ResponseEntity<>(HttpStatus.NOT_ACCEPTABLE); } }
From source file:com.sms.server.controller.UserController.java
@RequestMapping(value = "/{username}", method = RequestMethod.PUT, headers = { "Content-type=application/json" }) @ResponseBody/*from w w w . j av a 2 s. c o m*/ public ResponseEntity<String> updateUser(@RequestBody User update, @PathVariable("username") String username) { User user = userDao.getUserByUsername(username); if (user == null) { return new ResponseEntity<String>("Username does not exist.", HttpStatus.BAD_REQUEST); } if (username.equals("admin")) { return new ResponseEntity<String>("You are not authenticated to perform this operation.", HttpStatus.FORBIDDEN); } // Update user details if (update.getUsername() != null) { // Check username is available if (userDao.getUserByUsername(user.getUsername()) != null) { return new ResponseEntity<String>("Username already exists.", HttpStatus.NOT_ACCEPTABLE); } else { user.setUsername(update.getUsername()); } } if (update.getPassword() != null) { user.setPassword(update.getPassword()); } if (update.getEnabled() != null) { user.setEnabled(update.getEnabled()); } // Update database if (!userDao.updateUser(user, username)) { LogService.getInstance().addLogEntry(LogService.Level.ERROR, CLASS_NAME, "Error updating user '" + user.getUsername() + "'.", null); return new ResponseEntity<String>("Error updating user details.", HttpStatus.INTERNAL_SERVER_ERROR); } LogService.getInstance().addLogEntry(LogService.Level.INFO, CLASS_NAME, "User '" + user.getUsername() + "' updated successfully.", null); return new ResponseEntity<String>("User details updated successfully.", HttpStatus.ACCEPTED); }
From source file:org.lecture.controller.BaseController.java
@ExceptionHandler(NotCreatedException.class) @ResponseStatus(HttpStatus.NOT_ACCEPTABLE) public String handleNotCreated(NotCreatedException ex) { return "couldn't create resource"; }
From source file:edu.eci.arsw.blindway.controller.SalaController.java
@RequestMapping(path = "/obtencion/{id}", method = RequestMethod.GET) public ResponseEntity<?> manejadorGetRecursoSalaCreacion(@PathVariable Integer id) { try {/*from w w w . jav a 2s . c om*/ return new ResponseEntity<>(StubSala.getInstance().obtenerSala(id), HttpStatus.ACCEPTED); } catch (CreacionSalaException ex) { Logger.getLogger(SalasController.class.getName()).log(Level.SEVERE, null, ex); return new ResponseEntity<>(ex.getMessage(), HttpStatus.NOT_ACCEPTABLE); } }
From source file:com.hp.autonomy.frontend.find.hod.configuration.HodConfigurationController.java
@SuppressWarnings("ProhibitedExceptionDeclared") @RequestMapping(value = "/config", method = { RequestMethod.POST, RequestMethod.PUT }) @ResponseBody/*w w w . j ava 2s .c o m*/ public ResponseEntity<?> saveConfig(@RequestBody final ConfigResponse<HodFindConfig> configResponse) throws Exception { try { log.info(Markers.AUDIT, "REQUESTED CHANGE APPLICATION CONFIGURATION"); configService.updateConfig(configResponse.getConfig()); log.info(Markers.AUDIT, "CHANGED APPLICATION CONFIGURATION"); return new ResponseEntity<>(configService.getConfigResponse(), HttpStatus.OK); } catch (final ConfigException ce) { log.info(Markers.AUDIT, "CHANGE APPLICATION CONFIGURATION FAILED"); return new ResponseEntity<>(Collections.singletonMap("exception", ce.getMessage()), HttpStatus.NOT_ACCEPTABLE); } catch (final ConfigValidationException cve) { log.info(Markers.AUDIT, "CHANGE APPLICATION CONFIGURATION FAILED"); return new ResponseEntity<>(Collections.singletonMap("validation", cve.getValidationErrors()), HttpStatus.NOT_ACCEPTABLE); } }
From source file:com.sms.server.controller.AdminController.java
@RequestMapping(value = "/user", method = RequestMethod.POST, headers = { "Content-type=application/json" }) @ResponseBody//from w ww . ja v a 2s . co m public ResponseEntity<String> createUser(@RequestBody User user) { // Check mandatory fields. if (user.getUsername() == null || user.getPassword() == null) { return new ResponseEntity<>("Missing required parameter.", HttpStatus.BAD_REQUEST); } // Check unique fields if (userDao.getUserByUsername(user.getUsername()) != null) { return new ResponseEntity<>("Username already exists.", HttpStatus.NOT_ACCEPTABLE); } // Add user to the database. if (!userDao.createUser(user)) { LogService.getInstance().addLogEntry(Level.ERROR, CLASS_NAME, "Error adding user '" + user.getUsername() + "' to database.", null); return new ResponseEntity<>("Error adding user to database.", HttpStatus.INTERNAL_SERVER_ERROR); } LogService.getInstance().addLogEntry(Level.INFO, CLASS_NAME, "User '" + user.getUsername() + "' created successfully.", null); return new ResponseEntity<>("User created successfully.", HttpStatus.CREATED); }