use of org.usermanagement.dao.entity.UserSettingEntity in project open-kilda by telstra.
the class UserService method saveOrUpdateSettings.
/**
* Save or update settings.
*
* @param userInfo the user info
* @return the user info
*/
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public UserInfo saveOrUpdateSettings(UserInfo userInfo) {
if (ValidatorUtil.isNull(userInfo.getUserId())) {
LOGGER.warn("Validation failed for user (id: " + userInfo.getUserId() + "). Error: " + messageUtil.getAttributeInvalid("user_id", userInfo.getUserId() + ""));
throw new RequestValidationException(messageUtil.getAttributeInvalid("user_id", userInfo.getUserId() + ""));
}
UserSettingEntity userSettingEntity = userSettingRepository.findOneByUserId(userInfo.getUserId());
if (userSettingEntity == null) {
userSettingEntity = new UserSettingEntity();
userSettingEntity.setUserId(userInfo.getUserId());
}
userSettingEntity.setSettings(IConstants.Settings.TOPOLOGY_SETTING);
userSettingEntity.setData(userInfo.getData());
userSettingEntity = userSettingRepository.save(userSettingEntity);
// activityLogger.log(ActivityType.UPDATE_USER_SETTINGS,
// userInfo.getUserId() + "");
LOGGER.info("User Settings saved successfully for user(user_id: " + userInfo.getUserId() + ").");
return userInfo;
}
Aggregations