a0b5e453aa4bb7228cdd330928329292547e71c8
[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 import org.springframework.web.client.ResponseErrorHandler;
11
12
13
14 /**
15  *
16  * @author Kai Moritz
17  */
18 public class OAuth2GraphApiErrorHandler extends OAuth2ErrorHandler
19 {
20   private final OAuth2ErrorHandler parent;
21
22
23   public OAuth2GraphApiErrorHandler(OAuth2ErrorHandler handler)
24   {
25     super(null);
26     parent = handler;
27   }
28
29
30   @Override
31   public boolean hasError(ClientHttpResponse response) throws IOException
32   {
33     return
34         HttpStatus.Series.CLIENT_ERROR.equals(response.getStatusCode().series())
35         || parent.hasError(response);
36   }
37
38   @Override
39   public void handleError(ClientHttpResponse response) throws IOException
40   {
41     GraphApiErrorHandler.handleError(parent, response);
42   }
43
44   @Override
45   public void setMessageConverters(List<HttpMessageConverter<?>> converters)
46   {
47     parent.setMessageConverters(converters);
48   }
49 }