|
8 | 8 | import com.fasterxml.jackson.databind.ObjectMapper; |
9 | 9 | import lombok.SneakyThrows; |
10 | 10 | import org.springframework.core.io.Resource; |
| 11 | +import org.springframework.http.HttpStatus; |
11 | 12 | import org.springframework.http.client.support.BasicAuthenticationInterceptor; |
12 | 13 | import org.springframework.util.CollectionUtils; |
| 14 | +import org.springframework.web.client.HttpStatusCodeException; |
| 15 | +import org.springframework.web.client.RestClientException; |
13 | 16 | import org.springframework.web.client.RestTemplate; |
14 | 17 |
|
15 | 18 | import java.util.ArrayList; |
@@ -66,13 +69,15 @@ public List<UserAttribute> aggregate(List<UserAttribute> input, Map<String, List |
66 | 69 | try { |
67 | 70 | body = restTemplate.getForEntity(url, Map.class).getBody(); |
68 | 71 | } catch (RuntimeException e) { |
69 | | - String msg = String.format("InstitutionEndpoint %s configured for: %s, returned an error", institutionEndpoint, spEntityID); |
| 72 | + String msg = String.format("InstitutionEndpoint %s configured for: %s, returned an error", |
| 73 | + institutionEndpoint, spEntityID); |
70 | 74 | // A 404 if the user wasn't found is not an error |
71 | | - if (e.getStatusCode().value() == 404) { |
| 75 | + if (e instanceof HttpStatusCodeException && ((HttpStatusCodeException) e).getStatusCode().equals(HttpStatus.NOT_FOUND)) { |
72 | 76 | LOG.info(msg + " 404 Not Found"); |
73 | 77 | } else { |
74 | 78 | LOG.error(msg, e); |
75 | 79 | } |
| 80 | + return errorResponse(input); |
76 | 81 | } |
77 | 82 |
|
78 | 83 | LOG.debug("Received response {} from {} for SP {}", body, institutionEndpoint.getBaseURL(), spEntityID); |
|
0 commit comments