use of org.usermanagement.dao.entity.RoleEntity in project open-kilda by telstra.
the class UserConversionUtil method toUserInfo.
/**
* To user info.
*
* @param userEntity the user entity
* @return the user info
*/
public static UserInfo toUserInfo(final UserEntity userEntity) {
UserInfo userInfo = null;
if (userEntity != null) {
userInfo = new UserInfo();
userInfo.setName(userEntity.getName());
userInfo.setEmail(userEntity.getEmail().toLowerCase());
userInfo.setUsername(userEntity.getUsername().toLowerCase());
userInfo.setIs2FaEnabled(userEntity.getIs2FaEnabled());
userInfo.setStatus(userEntity.getStatusEntity().getStatus());
userInfo.setUserId(userEntity.getUserId());
Set<String> roles = new HashSet<>();
if (!ValidatorUtil.isNull(userEntity.getRoles())) {
for (RoleEntity roleEntity : userEntity.getRoles()) {
roles.add(roleEntity.getName());
}
userInfo.setRoles(roles);
}
}
return userInfo;
}
Aggregations