Mercurial > dive4elements > gnv-client
changeset 1028:41234fcf4c7e
Some Bugfixes which prevent Exceptions executing the Examples in the config-manual
gnv-artifacts/trunk@1052 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Tim Englich <tim.englich@intevation.de> |
---|---|
date | Tue, 04 May 2010 12:40:21 +0000 |
parents | f08908d4df50 |
children | a5e0384fe464 |
files | gnv-artifacts/ChangeLog gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/GNVProductArtifactFactory.java gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/fis/SelectProductArtifact.java |
diffstat | 3 files changed, 69 insertions(+), 68 deletions(-) [+] |
line wrap: on
line diff
--- a/gnv-artifacts/ChangeLog Wed Apr 28 17:00:11 2010 +0000 +++ b/gnv-artifacts/ChangeLog Tue May 04 12:40:21 2010 +0000 @@ -1,3 +1,13 @@ +2010-05-04 Tim Englich <tim.englich@intevation.de> + + * src/main/java/de/intevation/gnv/artifacts/fis/SelectProductArtifact.java (appendSelectProducts): + BUGFIX: Added NULL-Check to Variable products to prevent NPEs if + no Products are configured to the FIS. + * src/main/java/de/intevation/gnv/artifacts/GNVProductArtifactFactory.java (parseProductFactories): + BUGFIX: Trim Classname to prevent ClassNotFound-Exceptions if the + Configuration contains whitespaces in the XML-Element which configures the + Artifact. + 2010-04-28 Ingo Weinzierl <ingo.weinzierl@intevation.de> * doc/conf/maptemplates/layer_polygon.vm: Do not use point symbols to draw
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/GNVProductArtifactFactory.java Wed Apr 28 17:00:11 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/GNVProductArtifactFactory.java Tue May 04 12:40:21 2010 +0000 @@ -1,18 +1,5 @@ package de.intevation.gnv.artifacts; -import de.intevation.artifactdatabase.DefaultArtifactFactory; -import de.intevation.artifactdatabase.ProxyArtifact; -import de.intevation.artifactdatabase.XMLUtils; - -import de.intevation.artifacts.Artifact; -import de.intevation.artifacts.ArtifactFactory; - -import de.intevation.gnv.artifacts.fis.SelectProductArtifact; - -import de.intevation.gnv.artifacts.fis.product.DefaultProduct; - -import de.intevation.gnv.state.DefaultInputData; - import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -21,11 +8,19 @@ import javax.xml.xpath.XPathConstants; import org.apache.log4j.Logger; - import org.w3c.dom.Document; import org.w3c.dom.Node; import org.w3c.dom.NodeList; +import de.intevation.artifactdatabase.DefaultArtifactFactory; +import de.intevation.artifactdatabase.ProxyArtifact; +import de.intevation.artifactdatabase.XMLUtils; +import de.intevation.artifacts.Artifact; +import de.intevation.artifacts.ArtifactFactory; +import de.intevation.gnv.artifacts.fis.SelectProductArtifact; +import de.intevation.gnv.artifacts.fis.product.DefaultProduct; +import de.intevation.gnv.state.DefaultInputData; + /** * This factory is called to create a {@link * de.intevation.gnv.artifacts.fis.SelectProductArtifact} which lets the user @@ -134,7 +129,7 @@ Node factoryNode = (Node) XMLUtils.xpath( product, XPATH_PRODUCT_FACTORY, XPathConstants.NODE); - String factoryClass = factoryNode.getTextContent(); + String factoryClass = factoryNode.getTextContent().trim(); if (factoryClass == null || factoryClass.equals("")) { logger.warn("No artifact factory class found for " + name);
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/fis/SelectProductArtifact.java Wed Apr 28 17:00:11 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/fis/SelectProductArtifact.java Tue May 04 12:40:21 2010 +0000 @@ -1,29 +1,7 @@ package de.intevation.gnv.artifacts.fis; -import de.intevation.artifactdatabase.ProxyArtifact; -import de.intevation.artifactdatabase.XMLUtils; - -import de.intevation.artifacts.Artifact; -import de.intevation.artifacts.ArtifactFactory; -import de.intevation.artifacts.ArtifactNamespaceContext; -import de.intevation.artifacts.CallContext; -import de.intevation.artifacts.CallMeta; - -import de.intevation.gnv.artifacts.GNVArtifactBase; -import de.intevation.gnv.artifacts.GNVDefaultArtifact; -import de.intevation.gnv.artifacts.GNVProductArtifactFactory; -import de.intevation.gnv.artifacts.PreSettingArtifact; - -import de.intevation.gnv.artifacts.fis.product.Product; - -import de.intevation.gnv.artifacts.ressource.RessourceFactory; - -import de.intevation.gnv.state.DefaultInputData; -import de.intevation.gnv.state.InputData; - import java.io.IOException; import java.io.OutputStream; - import java.util.Collection; import java.util.HashMap; import java.util.Iterator; @@ -32,12 +10,27 @@ import javax.xml.xpath.XPathConstants; import org.apache.log4j.Logger; - import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; +import de.intevation.artifactdatabase.ProxyArtifact; +import de.intevation.artifactdatabase.XMLUtils; +import de.intevation.artifacts.Artifact; +import de.intevation.artifacts.ArtifactFactory; +import de.intevation.artifacts.ArtifactNamespaceContext; +import de.intevation.artifacts.CallContext; +import de.intevation.artifacts.CallMeta; +import de.intevation.gnv.artifacts.GNVArtifactBase; +import de.intevation.gnv.artifacts.GNVDefaultArtifact; +import de.intevation.gnv.artifacts.GNVProductArtifactFactory; +import de.intevation.gnv.artifacts.PreSettingArtifact; +import de.intevation.gnv.artifacts.fis.product.Product; +import de.intevation.gnv.artifacts.ressource.RessourceFactory; +import de.intevation.gnv.state.DefaultInputData; +import de.intevation.gnv.state.InputData; + /** * This artifact is used to handle to input/output at the beginning of a * parameterization when no product has been selected so far. After the user @@ -386,22 +379,24 @@ Node parent, Object context ) { - Iterator iter = products.values().iterator(); - - XMLUtils.ElementCreator creator = new XMLUtils.ElementCreator( - document, - ArtifactNamespaceContext.NAMESPACE_URI, - ArtifactNamespaceContext.NAMESPACE_PREFIX - ); + if (products != null && !products.isEmpty()){ + Iterator iter = products.values().iterator(); - while(iter.hasNext()) { - Product prod = (Product) iter.next(); - String name = prod.getName(); + XMLUtils.ElementCreator creator = new XMLUtils.ElementCreator( + document, + ArtifactNamespaceContext.NAMESPACE_URI, + ArtifactNamespaceContext.NAMESPACE_PREFIX + ); - Element current = creator.create("state"); - creator.addAttr(current, "name", name); - creator.addAttr(current, "description", name); - parent.appendChild(current); + while(iter.hasNext()) { + Product prod = (Product) iter.next(); + String name = prod.getName(); + + Element current = creator.create("state"); + creator.addAttr(current, "name", name); + creator.addAttr(current, "description", name); + parent.appendChild(current); + } } } @@ -441,23 +436,24 @@ Element choiceNode = creator.create("choices"); selectNode.appendChild(lableNode); selectNode.appendChild(choiceNode); + if (products != null && !products.isEmpty()){ + Iterator it = products.values().iterator(); + while (it.hasNext()) { + Product p = (Product) it.next(); + Element itemNode = creator.create("item"); + Element choiceLableNode = creator.create("label"); + choiceLableNode.setTextContent(ressource.getRessource( + callMeta.getLanguages(), + p.getName(), + p.getName() + )); + itemNode.appendChild(choiceLableNode); - Iterator it = products.values().iterator(); - while (it.hasNext()) { - Product p = (Product) it.next(); - Element itemNode = creator.create("item"); - Element choiceLableNode = creator.create("label"); - choiceLableNode.setTextContent(ressource.getRessource( - callMeta.getLanguages(), - p.getName(), - p.getName() - )); - itemNode.appendChild(choiceLableNode); - - Element choiceValueNode = creator.create("value"); - choiceValueNode.setTextContent(p.getName()); - itemNode.appendChild(choiceValueNode); - choiceNode.appendChild(itemNode); + Element choiceValueNode = creator.create("value"); + choiceValueNode.setTextContent(p.getName()); + itemNode.appendChild(choiceValueNode); + choiceNode.appendChild(itemNode); + } } node.appendChild(selectNode);