@Override protected void handleErrorResponse() throws IOException, ServiceException { try { switch (httpConn.getResponseCode()) { case HttpURLConnection.HTTP_MOVED_PERM: case HttpURLConnection.HTTP_MOVED_TEMP: throw new RedirectRequiredException(httpConn); } super.handleErrorResponse(); } catch (AuthenticationException e) { // Throw a more specific exception for session expiration. String msg = e.getMessage(); if (msg != null && msg.contains("Token expired")) { SessionExpiredException se = new SessionExpiredException(e.getMessage()); se.setResponse(e.getResponseContentType(), e.getResponseBody()); throw se; } throw e; } } }
@Override protected void handleErrorResponse() throws IOException, ServiceException { try { switch (httpConn.getResponseCode()) { case HttpURLConnection.HTTP_MOVED_PERM: case HttpURLConnection.HTTP_MOVED_TEMP: throw new RedirectRequiredException(httpConn); } super.handleErrorResponse(); } catch (AuthenticationException e) { // Throw a more specific exception for session expiration. String msg = e.getMessage(); if (msg != null && msg.contains("Token expired")) { SessionExpiredException se = new SessionExpiredException(e.getMessage()); se.setResponse(e.getResponseContentType(), e.getResponseBody()); throw se; } throw e; } } }
@Override protected void handleErrorResponse() throws IOException, ServiceException { try { switch (httpConn.getResponseCode()) { case HttpURLConnection.HTTP_MOVED_PERM: case HttpURLConnection.HTTP_MOVED_TEMP: throw new RedirectRequiredException(httpConn); } super.handleErrorResponse(); } catch (AuthenticationException e) { // Throw a more specific exception for session expiration. String msg = e.getMessage(); if ((msg != null && msg.contains("Token expired")) || (this.authToken != null && this.authToken instanceof OAuth2Token)) { SessionExpiredException se = new SessionExpiredException(e.getMessage()); se.setResponse(e.getResponseContentType(), e.getResponseBody()); throw se; } throw e; } } }