Commit 86fb8ad9 authored by Daniel Gerhardt's avatar Daniel Gerhardt
Browse files

Catch exception caused when user retrieval from Stud.IP fails with 500

parent 3f7359d8
...@@ -145,22 +145,26 @@ public class StudipRestConnectorDaoImpl implements ConnectorDao { ...@@ -145,22 +145,26 @@ public class StudipRestConnectorDaoImpl implements ConnectorDao {
private StudipUser getUserByName(String username) { private StudipUser getUserByName(String username) {
logger.trace("Retrieve user {}", username); logger.trace("Retrieve user {}", username);
ResponseEntity<StudipUsersWrapper> usersWrapperEntity = restTemplate.exchange( try {
userSearchUri, ResponseEntity<StudipUsersWrapper> usersWrapperEntity = restTemplate.exchange(
HttpMethod.GET, userSearchUri,
new HttpEntity<Void>(getAuthorizationHeader()), HttpMethod.GET,
StudipUsersWrapper.class, new HttpEntity<Void>(getAuthorizationHeader()),
username StudipUsersWrapper.class,
); username
);
for (StudipUser user : usersWrapperEntity.getBody().getUsers()) { for (StudipUser user : usersWrapperEntity.getBody().getUsers()) {
if (username.equals(user.getUsername())) { if (username.equals(user.getUsername())) {
logger.trace("Username {} belongs to user {}", username, user); logger.trace("Username {} belongs to user {}", username, user);
return user; return user;
}
} }
logger.trace("No user was found for username {}", username);
} catch (RestClientException e) {
logger.error("Connector failed to retrieve user's ID from Stud.IP: {}", e.getMessage());
} }
logger.trace("No user was found for username {}", username);
return null; return null;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment