return getDao().getUserDao().getById(id);
}
@Override
public ServiceResponse save(Map<String, String> vo) {
UserEntity user = null;
if (!StringUtils.isEmpty(vo.get("id"))) {
user = getDao().getUserDao().getById(Long.valueOf(vo.get("id")));
}
if (user == null) {
user = new UserEntity();
}
user.setName(vo.get("name"));
if (!StringUtils.isEmpty(vo.get("email"))) {
user.setEmail(vo.get("email").toLowerCase());
}
if (!StringUtils.isEmpty(vo.get("password"))) {
user.setPassword(BCrypt.hashpw(vo.get("password"),
BCrypt.gensalt()));
}
if (!StringUtils.isEmpty(vo.get("role"))) {
user.setRole(UserRole.valueOf(vo.get("role")));
}
if (!StringUtils.isEmpty(vo.get("timezone"))) {
user.setTimezone(vo.get("timezone"));
}
if (!StringUtils.isEmpty(vo.get("disabled"))) {
user.setDisabled(ParamUtil.getBoolean(vo.get("disabled"), false));
}
List<String> errors = getBusiness().getUserBusiness()
.validateBeforeUpdate(user);
if (errors.isEmpty()) {
getDao().getUserDao().save(user);