# HG changeset patch # User Tim Englich # Date 1254824337 0 # Node ID f35b7d7a04d6375998bbda797d3a19987cfb804d # Parent 3bbb95f43549a2ec50a5ae1ce883afe2db7d36fe 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 diff -r 3bbb95f43549 -r f35b7d7a04d6 gnv/ChangeLog --- 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 + + * 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 * Changelog -> ChangeLog: Moved to make eclipse happier. diff -r 3bbb95f43549 -r f35b7d7a04d6 gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/DefaultArtifactDatabaseClient.java --- 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();