当前位置: 首页>>代码示例>>Java>>正文


Java HttpStatus.NOT_ACCEPTABLE属性代码示例

本文整理汇总了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);
}
 
开发者ID:JUGIstanbul,项目名称:second-opinion-api,代码行数:22,代码来源:MedicController.java

示例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;
}
 
开发者ID:KobePig,项目名称:NutriBuddi,代码行数:16,代码来源:PasswordValidationRule.java

示例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;
}
 
开发者ID:KobePig,项目名称:NutriBuddi,代码行数:17,代码来源:EatsController.java

示例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;
}
 
开发者ID:KobePig,项目名称:NutriBuddi,代码行数:17,代码来源:EatsController.java

示例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;
}
 
开发者ID:KobePig,项目名称:NutriBuddi,代码行数:11,代码来源:GenderValidationRule.java

示例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;
}
 
开发者ID:KobePig,项目名称:NutriBuddi,代码行数:11,代码来源:LastNameValidationRule.java

示例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);
    }
}
 
开发者ID:KobePig,项目名称:NutriBuddi,代码行数:13,代码来源:AddNewEmailValidationRule.java

示例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;
}
 
开发者ID:KobePig,项目名称:NutriBuddi,代码行数:11,代码来源:HeightValidationRule.java

示例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;
}
 
开发者ID:KobePig,项目名称:NutriBuddi,代码行数:11,代码来源:AgeValidationRule.java

示例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;
}
 
开发者ID:KobePig,项目名称:NutriBuddi,代码行数:11,代码来源:FirstNameValidationRule.java

示例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;
}
 
开发者ID:KobePig,项目名称:NutriBuddi,代码行数:11,代码来源:WeightValidationRule.java

示例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);
    }
}
 
开发者ID:KobePig,项目名称:NutriBuddi,代码行数:13,代码来源:UpdateEmailValidationRule.java

示例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);
}
 
开发者ID:KobePig,项目名称:NutriBuddi,代码行数:28,代码来源:EatsController.java

示例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;
}
 
开发者ID:KobePig,项目名称:NutriBuddi,代码行数:34,代码来源:EatsController.java

示例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);
}
 
开发者ID:KobePig,项目名称:NutriBuddi,代码行数:10,代码来源:FoodController.java


注:本文中的org.springframework.http.HttpStatus.NOT_ACCEPTABLE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。