本文整理汇总了Java中org.springframework.http.HttpStatus.NOT_ACCEPTABLE属性的典型用法代码示例。如果您正苦于以下问题:Java HttpStatus.NOT_ACCEPTABLE属性的具体用法?Java HttpStatus.NOT_ACCEPTABLE怎么用?Java HttpStatus.NOT_ACCEPTABLE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.springframework.http.HttpStatus
的用法示例。
在下文中一共展示了HttpStatus.NOT_ACCEPTABLE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: saveMedic
@PostMapping
public ResponseEntity<?> saveMedic(@RequestBody Medic medic, BindingResult result) {
medicValidator.validate(medic, result);
if (result.hasErrors()) {
return new ResponseEntity<>(result.getAllErrors(), HttpStatus.NOT_ACCEPTABLE);
}
Medic newMedic = medicService.save(medic);
if (newMedic != null) {
final URI location = ServletUriComponentsBuilder.fromCurrentServletMapping().path("/v1/medics/{id}").build()
.expand(newMedic.getId()).toUri();
final HttpHeaders headers = new HttpHeaders();
headers.setLocation(location);
return new ResponseEntity<Void>(headers, HttpStatus.CREATED);
}
return new ResponseEntity<Void>(HttpStatus.SERVICE_UNAVAILABLE);
}
示例2: validate
@Override
public ValidationResponse validate(UserVO user) {
String password = user.getPassword();
String password2 = user.getPassword2();
ValidationResponse validationResponse;
if (!password.equals("")) {
if (password.equals(password2)) {
validationResponse = new ValidationResponse("OK password", HttpStatus.OK);
} else {
validationResponse = new ValidationResponse("Passwords must match", HttpStatus.NOT_ACCEPTABLE);
}
} else {
validationResponse = new ValidationResponse("Password required", HttpStatus.NOT_ACCEPTABLE);
}
return validationResponse;
}
示例3: getEatsByFoodName
@GetMapping(path="/getEatsByFoodName")
@ResponseBody
public ResponseEntity<Object> getEatsByFoodName(@RequestParam String foodName){
ResponseEntity response;
List<Eats> eats;
if(foodName != null && foodName != ""){
try{
eats = eatsRepository.findByFoodName(foodName);
response = new ResponseEntity<>(eats, HttpStatus.OK);
}catch(Exception e){
response = new ResponseEntity<>("Error with request", HttpStatus.BAD_REQUEST);
}
} else {
response = new ResponseEntity<>("Foodname cannot be empty", HttpStatus.NOT_ACCEPTABLE);
}
return response;
}
示例4: getEatsByEmail
@GetMapping(path="/getEatsByEmail")
@ResponseBody
public ResponseEntity<Object> getEatsByEmail(@RequestParam String email){
ResponseEntity response;
List<Eats> eats;
if(email != null && email != ""){
try{
eats = eatsRepository.findByEmail(email);
response = new ResponseEntity<>(eats, HttpStatus.OK);
}catch(Exception e){
response = new ResponseEntity<>("Error with request", HttpStatus.BAD_REQUEST);
}
} else {
response = new ResponseEntity<>("Email cannot be empty", HttpStatus.NOT_ACCEPTABLE);
}
return response;
}
示例5: validate
@Override
public ValidationResponse validate(UserVO user) {
ValidationResponse validationResponse;
String gender = user.getGender();
if (!gender.equals("")) {
validationResponse = new ValidationResponse("OK gender", HttpStatus.ACCEPTED);
} else {
validationResponse = new ValidationResponse("Gender required", HttpStatus.NOT_ACCEPTABLE);
}
return validationResponse;
}
示例6: validate
@Override
public ValidationResponse validate(UserVO user) {
ValidationResponse validationResponse;
String lastName = user.getUserName();
if (!lastName.equals("")) {
validationResponse = new ValidationResponse("OK", HttpStatus.ACCEPTED);
} else {
validationResponse = new ValidationResponse("Last name required", HttpStatus.NOT_ACCEPTABLE);
}
return validationResponse;
}
示例7: validate
@Override
public ValidationResponse validate(UserVO user) {
String email = user.getEmail();
if (!email.equals("")) {
if (user.getUserRepository().findByEmail(email) == null) {
return new ValidationResponse("OK email", HttpStatus.OK);
} else {
return new ValidationResponse("Email is already registered", HttpStatus.NOT_ACCEPTABLE);
}
} else {
return new ValidationResponse("Valid email required", HttpStatus.NOT_ACCEPTABLE);
}
}
示例8: validate
@Override
public ValidationResponse validate(UserVO user) {
ValidationResponse validationResponse;
String height = user.getHeight();
if (!height.equals("")) {
validationResponse = new ValidationResponse("OK height", HttpStatus.ACCEPTED);
} else {
validationResponse = new ValidationResponse("Height required", HttpStatus.NOT_ACCEPTABLE);
}
return validationResponse;
}
示例9: validate
@Override
public ValidationResponse validate(UserVO user) {
ValidationResponse validationResponse;
String age = user.getAge();
if (!age.equals("")) {
validationResponse = new ValidationResponse("OK age", HttpStatus.ACCEPTED);
} else {
validationResponse = new ValidationResponse("Age required", HttpStatus.NOT_ACCEPTABLE);
}
return validationResponse;
}
示例10: validate
@Override
public ValidationResponse validate(UserVO user) {
ValidationResponse validationResponse;
String firstName = user.getFirst();
if (!firstName.equals("")) {
validationResponse = new ValidationResponse("OK first", HttpStatus.ACCEPTED);
} else {
validationResponse = new ValidationResponse("First name required", HttpStatus.NOT_ACCEPTABLE);
}
return validationResponse;
}
示例11: validate
@Override
public ValidationResponse validate(UserVO user) {
ValidationResponse validationResponse;
String weight = user.getWeight();
if (!weight.equals("")) {
validationResponse = new ValidationResponse("OK weight", HttpStatus.ACCEPTED);
} else {
validationResponse = new ValidationResponse("Weight required", HttpStatus.NOT_ACCEPTABLE);
}
return validationResponse;
}
示例12: validate
@Override
public ValidationResponse validate(UserVO user) {
String email = user.getEmail();
if (!email.equals("")) {
if (user.getUserRepository().findByEmail(email) == null) {
return new ValidationResponse("No such user found with this email", HttpStatus.NOT_ACCEPTABLE);
} else {
return new ValidationResponse("OK email", HttpStatus.OK);
}
} else {
return new ValidationResponse("Valid email required", HttpStatus.NOT_ACCEPTABLE);
}
}
示例13: addNewEats
@GetMapping(path="/addNewEats") // Map ONLY GET Requests
@ResponseBody
public ResponseEntity<Object> addNewEats (@RequestParam String email
, @RequestParam String numServings
, @RequestParam String foodName) {
int s;
try {
s = Integer.parseInt(numServings);
} catch (NumberFormatException e ) {
return new ResponseEntity<>("Number of servings is invalid", HttpStatus.NOT_ACCEPTABLE);
}
if (userRepository.findByEmail(email) == null) {
return new ResponseEntity<>("Email does not exist", HttpStatus.NOT_ACCEPTABLE);
}
if (foodRepository.findByFoodName(foodName) == null) {
return new ResponseEntity<>(foodName + " does not exist", HttpStatus.NOT_ACCEPTABLE);
}
if (email.equals("[email protected]")) {
return new ResponseEntity<>("[email protected] TERMINATION SCHEDULED. NUTRITIONAL MAINTENANCE IRRELLEVANT", HttpStatus.I_AM_A_TEAPOT);
}
Eats eats = new Eats(userRepository.findByEmail(email), s, foodRepository.findByFoodName(foodName));
eatsRepository.save(eats);
return new ResponseEntity<>("Eat transaction added", HttpStatus.OK);
}
示例14: getEatsByDateRangeAndEmail
@GetMapping(path="/getEatsByDatesAndEmail")
@ResponseBody
public ResponseEntity<Object> getEatsByDateRangeAndEmail(@RequestParam String startDate, @RequestParam String endDate, @RequestParam String email){
ResponseEntity<Object> response = null;
if(startDate == null || startDate == ""){
response = new ResponseEntity<>("start date cannot be empty", HttpStatus.NOT_ACCEPTABLE);
}
if(endDate == "" || endDate != null ){
response = new ResponseEntity<>("end date cannot be empty", HttpStatus.NOT_ACCEPTABLE);
} else {
try {
Date start = Date.valueOf(startDate);
Date end = Date.valueOf(endDate);
if(!start.before(end)){
response = new ResponseEntity<>("start date must be before end date", HttpStatus.NOT_ACCEPTABLE);
}
} catch(Exception e){
response = new ResponseEntity<>("date(s) are not valid dates", HttpStatus.NOT_ACCEPTABLE);
System.out.println(e.getMessage());
}
}
if(email == "" || email == null){
response = new ResponseEntity<>("email cannot be empty", HttpStatus.NOT_ACCEPTABLE);
}
List<Eats> eats = eatsRepository.findBetweenDateRangeAndEmail(startDate, endDate, email);
if(eats.size() > 0){
response = new ResponseEntity<>(eats, HttpStatus.OK);
}
else if(eats.size() == 0){
response = new ResponseEntity<>("No records exist", HttpStatus.OK);
}
return response;
}
示例15: getFoodNutrition
@GetMapping(path="/getFoodNutrition") // Map ONLY GET Requests
@ResponseBody
public ResponseEntity<Object> getFoodNutrition (@RequestParam String foodName) {
if (foodRepository.findByFoodName(foodName) == null) {
return new ResponseEntity<>(foodName + " does not exist", HttpStatus.NOT_ACCEPTABLE);
}
return new ResponseEntity<>(foodRepository.findByFoodName(foodName), HttpStatus.OK);
}