Mercurial > dive4elements > river
changeset 4488:5041105d2edd
Check if response code from GGInA is 200 OK
Only parse the GGInA response if the status code is 200 OK. This improves the
error message if GGInA is not available and shows the real reason instead of a
JDOM error while parsing the response.
author | Björn Ricks <bjoern.ricks@intevation.de> |
---|---|
date | Wed, 14 Nov 2012 10:36:21 +0100 |
parents | a08d25476f0a |
children | fea3e4b6faba |
files | flys-client/src/main/java/de/intevation/flys/client/server/auth/was/Authenticator.java |
diffstat | 1 files changed, 7 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/server/auth/was/Authenticator.java Wed Nov 14 10:38:33 2012 +0100 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/auth/was/Authenticator.java Wed Nov 14 10:36:21 2012 +0100 @@ -5,6 +5,7 @@ import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; +import org.apache.http.StatusLine; import org.apache.http.client.HttpClient; import org.apache.http.conn.scheme.Scheme; import org.apache.http.conn.ssl.SSLSocketFactory; @@ -39,6 +40,12 @@ Request httpget = new Request("https://geoportal.bafg.de/" + "administration/WAS", username, password, encoding); HttpResponse response = httpclient.execute(httpget); + StatusLine stline = response.getStatusLine(); + if (stline.getStatusCode() != 200) { + throw new AuthenticationException("GGInA Server Error. " + + "Statuscode: " + stline.getStatusCode() + + ". Reason: " + stline.getReasonPhrase()); + } HttpEntity entity = response.getEntity(); if (entity == null) { //FIXME throw AuthenticationException