Skip to content

Commit 9ee0397

Browse files
committed
Fixes #145
1 parent 24d5417 commit 9ee0397

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/main/java/aa/aggregators/institution/InstitutionAttributeAggregator.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@
88
import com.fasterxml.jackson.databind.ObjectMapper;
99
import lombok.SneakyThrows;
1010
import org.springframework.core.io.Resource;
11+
import org.springframework.http.HttpStatus;
1112
import org.springframework.http.client.support.BasicAuthenticationInterceptor;
1213
import org.springframework.util.CollectionUtils;
14+
import org.springframework.web.client.HttpStatusCodeException;
15+
import org.springframework.web.client.RestClientException;
1316
import org.springframework.web.client.RestTemplate;
1417

1518
import java.util.ArrayList;
@@ -66,13 +69,15 @@ public List<UserAttribute> aggregate(List<UserAttribute> input, Map<String, List
6669
try {
6770
body = restTemplate.getForEntity(url, Map.class).getBody();
6871
} 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);
7074
// 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)) {
7276
LOG.info(msg + " 404 Not Found");
7377
} else {
7478
LOG.error(msg, e);
7579
}
80+
return errorResponse(input);
7681
}
7782

7883
LOG.debug("Received response {} from {} for SP {}", body, institutionEndpoint.getBaseURL(), spEntityID);

0 commit comments

Comments
 (0)