9158987c240f583c3ea4b795538f9e25c11021c9
[facebook-errors] / src / main / java / de / juplo / facebook / errors / OAuth2GraphApiErrorHandler.java
1 package de.juplo.facebook.errors;
2
3
4 import java.io.IOException;
5 import java.util.List;
6 import org.springframework.http.HttpStatus;
7 import org.springframework.http.client.ClientHttpResponse;
8 import org.springframework.http.converter.HttpMessageConverter;
9 import org.springframework.security.oauth2.client.http.OAuth2ErrorHandler;
10
11
12
13 /**
14  *
15  * @author Kai Moritz
16  */
17 public class OAuth2GraphApiErrorHandler extends OAuth2ErrorHandler
18 {
19   private final OAuth2ErrorHandler parent;
20
21
22   public OAuth2GraphApiErrorHandler(OAuth2ErrorHandler handler)
23   {
24     super(null);
25     parent = handler;
26   }
27
28
29   @Override
30   public boolean hasError(ClientHttpResponse response) throws IOException
31   {
32     return
33         HttpStatus.Series.CLIENT_ERROR.equals(response.getStatusCode().series())
34         || parent.hasError(response);
35   }
36
37   @Override
38   public void handleError(ClientHttpResponse response) throws IOException
39   {
40     GraphApiErrorHandler.handleError(parent, response);
41   }
42
43   @Override
44   public void setMessageConverters(List<HttpMessageConverter<?>> converters)
45   {
46     parent.setMessageConverters(converters);
47   }
48 }