changeset 122:9b1e165bf7d7

Mit 3.2.x zusammenführen
author Gernot Belger <g.belger@bjoernsen.de>
date Wed, 15 Jul 2020 11:57:47 +0200
parents 5aad20399cbd (diff) e1199a5be8b2 (current diff)
children
files
diffstat 2 files changed, 20 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/org/dive4elements/artifacts/httpclient/http/HttpClientImpl.java	Thu Jun 04 19:38:46 2020 +0200
+++ b/src/main/java/org/dive4elements/artifacts/httpclient/http/HttpClientImpl.java	Wed Jul 15 11:57:47 2020 +0200
@@ -39,6 +39,7 @@
 import org.dive4elements.artifacts.httpclient.objects.ArtifactFactory;
 import org.dive4elements.artifacts.httpclient.utils.ArtifactProtocolUtils;
 import org.dive4elements.artifacts.httpclient.utils.ArtifactCreator;
+import org.dive4elements.artifacts.httpclient.utils.XMLUtils;
 
 /**
  * Client to artifact-server.
@@ -146,15 +147,23 @@
 
         try {
             String   url    = serverUrl + "/create";
-            Document result = (Document) handler.handle(doPost(url, doc));
+            Response response = doPost(url, doc);
+            try {
+                Document result = (Document) handler.handle(response);
 
-            return creator == null
-                ? ArtifactProtocolUtils.extractArtifact(result)
-                : creator.create(result);
+                return creator == null
+                    ? ArtifactProtocolUtils.extractArtifact(result)
+                    : creator.create(result);
+            }
+            catch (IOException e) {
+                String entityAsText = response.getEntityAsText();
+                throw new ConnectionException(
+                        "Connection to server failed. No Artifact created. Response was: " + entityAsText, e);
+            }
         }
         catch (IOException ioe) {
             throw new ConnectionException(
-                "Connection to server failed. No Artifact created.");
+                "Connection to server failed. No Artifact created.\n" + XMLUtils.toString(doc), ioe);
         }
     }
 
--- a/src/main/java/org/dive4elements/artifacts/httpclient/http/response/DocumentResponseHandler.java	Thu Jun 04 19:38:46 2020 +0200
+++ b/src/main/java/org/dive4elements/artifacts/httpclient/http/response/DocumentResponseHandler.java	Wed Jul 15 11:57:47 2020 +0200
@@ -9,24 +9,19 @@
 
 import java.io.IOException;
 
+import org.dive4elements.artifacts.httpclient.utils.XMLUtils;
 import org.restlet.Response;
 import org.restlet.representation.Representation;
 
-import org.dive4elements.artifacts.httpclient.utils.XMLUtils;
-
-
 /**
  * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
  */
 public class DocumentResponseHandler implements ResponseHandler {
 
-    public DocumentResponseHandler() {
-    }
-
     @Override
-    public Object handle(Response response) throws IOException {
-        Representation output = response.getEntity();
-        return XMLUtils.readDocument(output.getStream());
+    public Object handle(final Response response) throws IOException {
+        final Representation output = response.getEntity();
+            // FIXME: stream not closed?
+            return XMLUtils.readDocument(output.getStream());
     }
-}
-// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:
+}
\ No newline at end of file

http://dive4elements.wald.intevation.org