當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。