changeset 47:f35b7d7a04d6

Read the Status-Code from the Response and throw an Exception which Message will be visualized in the GUI. gnv/issue18 gnv/trunk@189 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Tim Englich <tim.englich@intevation.de>
date Tue, 06 Oct 2009 10:18:57 +0000
parents 3bbb95f43549
children 60c8f5edf742
files gnv/ChangeLog gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/DefaultArtifactDatabaseClient.java
diffstat 2 files changed, 14 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/gnv/ChangeLog	Tue Oct 06 10:14:19 2009 +0000
+++ b/gnv/ChangeLog	Tue Oct 06 10:18:57 2009 +0000
@@ -1,3 +1,9 @@
+2009-10-06  Tim Englich  <tim.englich@intevation.de>
+
+	* src/main/java/de/intevation/gnv/artifactdatabase/client/DefaultArtifactDatabaseClient.java (doGetRequestInternal) Edited: 
+	  Read the Status-Code from the Response and throw an Exception 
+	  which Message will be visualized in the GUI. gnv/issue18
+
 2009-10-08	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* Changelog -> ChangeLog: Moved to make eclipse happier.
--- a/gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/DefaultArtifactDatabaseClient.java	Tue Oct 06 10:14:19 2009 +0000
+++ b/gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/DefaultArtifactDatabaseClient.java	Tue Oct 06 10:18:57 2009 +0000
@@ -118,6 +118,7 @@
             }
         } catch (IOException e) {
             log.error(e, e);
+            throw new ArtifactDatabaseClientException(e);
         }
         return resultValues;
     }
@@ -189,7 +190,7 @@
      * @return
      */
     private Representation doGetRequestInternal(String requestUrl,
-                                                Document requestBody) {
+                                                Document requestBody) throws IOException {
         Client client = new Client(Protocol.HTTP);
         Request request = initialize(new Request(Method.GET, requestUrl));
         if (requestBody != null) {
@@ -200,7 +201,9 @@
             request.setEntity(representation);
         }
         Response response = client.handle(request);
-        // TODO RESPONSESTATUS AUSWERTEN.
+        if (response.getStatus().getCode() != 200){
+            throw new IOException(response.getStatus().getDescription());
+        }
         Representation output = response.getEntity();
         return output;
     }
@@ -219,6 +222,9 @@
         Representation representation = new StringRepresentation(documentBody);
         request.setEntity(representation);
         Response response = client.handle(request);
+        if (response.getStatus().getCode() != 200){
+            throw new IOException(response.getStatus().getDescription());
+        }
         // TODO RESPONSESTATUS AUSWERTEN.
         Representation output = response.getEntity();
         return output.getStream();

http://dive4elements.wald.intevation.org