Class UserConfigService
java.lang.Object
org.ntnu.idi.idatt2106.sparesti.sparestibackend.service.UserConfigService
Service class for handling business logic related to Userconfig entity and DTO's
- Since:
- 19.4.24
- Version:
- 1.0
- Author:
- Yasin M.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateChallengeConfig
(String username, ChallengeConfigDTO challengeConfigDTO) Creates a challenge config for a usergetChallengeConfig
(String username) Gets the challenge config of a usergetUserConfig
(String username) Gets the config of a userupdateChallengeConfig
(String username, ChallengeConfigDTO challengeConfigDTO) Method will reset all challenge type configs.
-
Constructor Details
-
UserConfigService
public UserConfigService()
-
-
Method Details
-
getUserConfig
public UserConfigDTO getUserConfig(String username) throws UserNotFoundException, ConfigNotFoundException Gets the config of a user- Parameters:
username
- Username of user- Returns:
- UserConfig for the user
- Throws:
UserNotFoundException
- If the user could not be found from the usernameConfigNotFoundException
- If the user has yet to set up their config
-
createChallengeConfig
public ChallengeConfigDTO createChallengeConfig(String username, ChallengeConfigDTO challengeConfigDTO) throws UserNotFoundException, ObjectNotValidException Creates a challenge config for a user- Parameters:
username
- Username of userchallengeConfigDTO
- The user's new challenge config info- Returns:
- Created config info
- Throws:
UserNotFoundException
- If the user could not be found by the usernameObjectNotValidException
- If the config dto fields are invalid
-
getChallengeConfig
public ChallengeConfigDTO getChallengeConfig(String username) throws ChallengeConfigNotFoundException, UserNotFoundException Gets the challenge config of a user- Parameters:
username
- Username of user- Returns:
- Challenge config of user
- Throws:
ChallengeConfigNotFoundException
- If the user has yet to set up their challenge configUserNotFoundException
- If the user could not be found from the username
-
updateChallengeConfig
public ChallengeConfigDTO updateChallengeConfig(String username, ChallengeConfigDTO challengeConfigDTO) throws UserNotFoundException, ObjectNotValidException Method will reset all challenge type configs. make sure to send intact challenge type configs in the dto. This behaviour can be disabled, by ignoring the challenge type dtos in the mapper.- Parameters:
username
- Username of userchallengeConfigDTO
- Challenge config with new changes- Returns:
- Updated challenge config
- Throws:
UserNotFoundException
- If the user could not be found from the usernameObjectNotValidException
- If the dto fields are invalid
-