Mercurial > dive4elements > gnv-client
diff gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/DefaultArtifactDatabaseClient.java @ 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 | 23a4f196d7d6 |
children | d6b82c585f1f |
line wrap: on
line diff
--- 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();