Mercurial > dive4elements > gnv-client
changeset 1005:397b4cb8589b
Prevent NPE if the Mapviewer has delivered no Geometry.
gnv/trunk@1215 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Tim Englich <tim.englich@intevation.de> |
---|---|
date | Tue, 15 Jun 2010 07:49:06 +0000 |
parents | a0d16ccb82ba |
children | 237c73a2b0dd |
files | gnv/ChangeLog gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/DefaultArtifactDatabaseClient.java |
diffstat | 2 files changed, 47 insertions(+), 43 deletions(-) [+] |
line wrap: on
line diff
--- a/gnv/ChangeLog Tue Jun 15 05:26:44 2010 +0000 +++ b/gnv/ChangeLog Tue Jun 15 07:49:06 2010 +0000 @@ -1,3 +1,10 @@ +2010-06-15 Tim Englich <tim.englich@intevation.de> + + ISSUE 278: Again: Because something was wrong with r1202. + + * src/main/java/de/intevation/gnv/artifactdatabase/client/DefaultArtifactDatabaseClient.java: + Prevent NPE if the Mapviewer has delivered no Geometry. + 2010-06-15 Sascha L. Teichmann <sascha.teichmann@intevation.de> * src/main/webapp/WEB-INF/config/templates/describe-ui.xsl:
--- a/gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/DefaultArtifactDatabaseClient.java Tue Jun 15 05:26:44 2010 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/DefaultArtifactDatabaseClient.java Tue Jun 15 07:49:06 2010 +0000 @@ -1,8 +1,36 @@ package de.intevation.gnv.artifactdatabase.client; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Locale; +import java.util.Map; + +import org.apache.log4j.Logger; +import org.restlet.Client; +import org.restlet.data.ClientInfo; +import org.restlet.data.Language; +import org.restlet.data.Method; +import org.restlet.data.Preference; +import org.restlet.data.Protocol; +import org.restlet.data.Request; +import org.restlet.data.Response; +import org.restlet.representation.Representation; +import org.restlet.representation.StringRepresentation; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + import de.intevation.gnv.artifactdatabase.client.exception.ArtifactDatabaseClientException; import de.intevation.gnv.artifactdatabase.client.exception.ArtifactDatabaseInputException; - import de.intevation.gnv.artifactdatabase.objects.Artifact; import de.intevation.gnv.artifactdatabase.objects.ArtifactDescription; import de.intevation.gnv.artifactdatabase.objects.ArtifactFactory; @@ -19,49 +47,12 @@ import de.intevation.gnv.artifactdatabase.objects.OutputParameter; import de.intevation.gnv.artifactdatabase.objects.ParametrizedArtifactFactory; import de.intevation.gnv.artifactdatabase.objects.ParametrizedArtifactObject; - import de.intevation.gnv.artifactdatabase.objects.map.Layer; import de.intevation.gnv.artifactdatabase.objects.map.MapService; - import de.intevation.gnv.propertiesreader.PropertiesReader; import de.intevation.gnv.propertiesreader.PropertiesReaderFactory; - import de.intevation.gnv.util.XMLUtils; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.io.OutputStreamWriter; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Locale; -import java.util.Map; - -import org.apache.log4j.Logger; - -import org.restlet.Client; - -import org.restlet.data.ClientInfo; -import org.restlet.data.Language; -import org.restlet.data.Method; -import org.restlet.data.Preference; -import org.restlet.data.Protocol; -import org.restlet.data.Request; -import org.restlet.data.Response; - -import org.restlet.representation.Representation; -import org.restlet.representation.StringRepresentation; - -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - /** * The default implementation of <code>ArtifactDatabaseClient</code> which * implements methods to communicate via HTTP protocol with the artifact server. @@ -274,6 +265,11 @@ private InputStream doPostRequest(String requestUrl, Document requestBody) throws IOException { + + log.debug("URL: "+ requestUrl); + log.debug("Body"); + log.debug(XMLUtils.writeDocument2String(requestBody)); + Client client = new Client(Protocol.HTTP); Request request = initialize(new Request(Method.POST, requestUrl)); String documentBody = XMLUtils.writeDocument2String(requestBody); @@ -1091,11 +1087,12 @@ Node rootNode = this.createArtifactElement(document, "GetMetaData"); document.appendChild(rootNode); - Element locationNode = this.createArtifactElement(document, "location"); - locationNode.setAttribute("srs", srs); - locationNode.appendChild(document.createTextNode(geometry)); - rootNode.appendChild(locationNode); - + if (geometry != null){ + Element locationNode = this.createArtifactElement(document, "location"); + locationNode.setAttribute("srs", srs); + locationNode.appendChild(document.createTextNode(geometry)); + rootNode.appendChild(locationNode); + } Element mapServicesNode = this.createArtifactElement(document, "mapservices"); Iterator<MapService> it = mapServices.iterator();