Skip to content

Commit

Permalink
Revert catch block changes to findBySubject
Browse files Browse the repository at this point in the history
  • Loading branch information
Gcolon021 committed Oct 17, 2023
1 parent e1cd09b commit 2fc4cf3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,14 @@ protected UserRepository() {
}

public User findBySubject(String subject) {
try {
CriteriaQuery<User> query = em.getCriteriaBuilder().createQuery(User.class);
Root<User> queryRoot = query.from(User.class);
query.select(queryRoot);
CriteriaBuilder cb = cb();
return em.createQuery(query
.where(
eq(cb, queryRoot, "subject", subject)))
.getSingleResult();
} catch (NoResultException e) {
return null;
}
CriteriaQuery<User> query = em.getCriteriaBuilder().createQuery(User.class);
Root<User> queryRoot = query.from(User.class);
query.select(queryRoot);
CriteriaBuilder cb = cb();
return em.createQuery(query
.where(
eq(cb, queryRoot, "subject", subject)))
.getSingleResult();
}

public User findBySubjectAndConnection(String subject, String connectionId) {
Expand Down Expand Up @@ -81,7 +77,7 @@ public List<User> listUnmatchedByConnectionId(Connection connection) {
* @return
*/
public User findOrCreate(User inputUser) {
User user = null;
User user;
String subject = inputUser.getSubject();
try {
user = findBySubject(subject);
Expand All @@ -94,6 +90,7 @@ public User findOrCreate(User inputUser) {
user = createUser(inputUser);
} catch (NonUniqueResultException e) {
logger.error("findOrCreate() " + e.getClass().getSimpleName() + ": " + e.getMessage());
user = createUser(inputUser);
}
return user;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
@Produces("application/json")
public class AuthService {

private Logger logger = LoggerFactory.getLogger(this.getClass());
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Inject
AuthenticationService authenticationService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ private User createUserFromFENCEProfile(JsonNode node) {
* @param roleDescription Description of the Role
* @return boolean Whether the Role was successfully added to the User or not
*/
public boolean upsertRole(User u, String roleName, String roleDescription) {
private boolean upsertRole(User u, String roleName, String roleDescription) {
boolean status = false;
logger.debug("upsertRole() starting for user subject:"+u.getSubject());

Expand Down

0 comments on commit 2fc4cf3

Please sign in to comment.