Skip to content

Commit

Permalink
SHIBUI-1740
Browse files Browse the repository at this point in the history
fixing bug with users/roles due to hashcode
  • Loading branch information
chasegawa committed Jul 2, 2021
1 parent e69f569 commit b592f38
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import edu.internet2.tier.shibboleth.admin.ui.security.repository.UserRepository;
import edu.internet2.tier.shibboleth.admin.ui.security.service.UserService;
import groovy.util.logging.Slf4j;
import jline.internal.Log;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -67,7 +68,14 @@ private User findUserOrThrowHttp404(String username) {
@Transactional(readOnly = true)
@GetMapping
public List<User> getAll() {
return userRepository.findAll();
try {
List<User> results = userRepository.findAll();
return results;
}
catch (Exception e) {
Log.error("Unable to fetch users because: {}", e.getMessage());
throw e;
}
}

@Transactional(readOnly = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public class User extends AbstractAuditable {
private String password;

@Transient
@EqualsAndHashCode.Exclude
private String role;

@JsonIgnore
Expand All @@ -69,6 +70,13 @@ public class User extends AbstractAuditable {
@Column(nullable = false, unique = true)
private String username;

public String getGroupId() {
if (groupId == null && group != null) {
groupId = group.getResourceId();
}
return groupId;
}

public String getRole() {
if (StringUtils.isBlank(this.role)) {
Set<Role> roles = this.getRoles();
Expand All @@ -79,4 +87,11 @@ public String getRole() {
}
return this.role;
}

public void setGroup(Group assignedGroup) {
this.group = assignedGroup;
if (group != null) {
groupId = group.getResourceId();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
* @author Dmitriy Kopylenko
*/
public interface UserRepository extends JpaRepository<User, Long> {

Optional<User> findByUsername(String username);
Set<User> findByRoles_Name(String roleName);
}

0 comments on commit b592f38

Please sign in to comment.