changeset 154:d6b82c585f1f

Bugfix NPE was thrown when an Exception occured in the Called ArtifactDatabase-Server issue58. gnv/trunk@260 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Tim Englich <tim.englich@intevation.de>
date Thu, 22 Oct 2009 12:21:53 +0000
parents 48f538077aea
children b0de3644af61
files gnv/ChangeLog gnv/src/main/java/de/intevation/gnv/action/NextArtifactStepAction.java gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/DefaultArtifactDatabaseClient.java
diffstat 3 files changed, 55 insertions(+), 41 deletions(-) [+]
line wrap: on
line diff
--- a/gnv/ChangeLog	Wed Oct 21 08:20:06 2009 +0000
+++ b/gnv/ChangeLog	Thu Oct 22 12:21:53 2009 +0000
@@ -1,3 +1,8 @@
+2009-10-22  Tim Englich  <tim.englich@intevation.de>
+
+	* src/main/java/de/intevation/gnv/action/NextArtifactStepAction.java (execute): 
+	   Bugfix NPE was thrown when an Exception occured in the Called ArtifactDatabase-Server issue58.
+
 2009-10-21  Tim Englich  <tim.englich@intevation.de>
 
 	* src/main/webapp/META-INF/context.xml: 
--- a/gnv/src/main/java/de/intevation/gnv/action/NextArtifactStepAction.java	Wed Oct 21 08:20:06 2009 +0000
+++ b/gnv/src/main/java/de/intevation/gnv/action/NextArtifactStepAction.java	Thu Oct 22 12:21:53 2009 +0000
@@ -103,26 +103,31 @@
                 }
 
                 Node currentUI = artifactDescription.getCurrentUI();
-                XSLTransformer transformer = new XSLTransformer();
-                String ui = transformer
-                        .transform(
-                                new XMLUtils().getNodeXPath(currentUI,
-                                        "dynamic"),
-                                "UTF-8",
-                                request
-                                        .getRealPath("WEB-INF/config/templates/describe-ui.xsl"));
-
-                request.setAttribute("ui", ui);
-
-                String staticUI = transformer
-                        .transform(
-                                new XMLUtils()
-                                        .getNodeXPath(currentUI, "static"),
-                                "UTF-8",
-                                request
-                                        .getRealPath("WEB-INF/config/templates/describe-ui-static.xsl"));
-                request.setAttribute("staticui", staticUI);
-
+                if (currentUI != null){
+                    XSLTransformer transformer = new XSLTransformer();
+                    Node dynamicUINode =  new XMLUtils().getNodeXPath(currentUI,"dynamic");
+                    if (dynamicUINode != null){
+                        String ui = transformer
+                                .transform(
+                                        dynamicUINode,
+                                        "UTF-8",
+                                        request
+                                                .getRealPath("WEB-INF/config/templates/describe-ui.xsl"));
+        
+                        request.setAttribute("ui", ui);
+                    }
+                    
+                    Node staticUINode = new XMLUtils().getNodeXPath(currentUI, "static");
+                    if (staticUINode != null){
+                        String staticUI = transformer
+                                .transform(
+                                        staticUINode,
+                                        "UTF-8",
+                                        request
+                                                .getRealPath("WEB-INF/config/templates/describe-ui-static.xsl"));
+                        request.setAttribute("staticui", staticUI);
+                    }
+                }
                 request.setAttribute("furthertargets",
                         (ad.getReachableStates() != null && !ad
                                 .getReachableStates().isEmpty()));
@@ -154,26 +159,31 @@
                 }
 
                 Node currentUI = artifactDescription.getCurrentUI();
-                XSLTransformer transformer = new XSLTransformer();
-                String ui = transformer
-                        .transform(
-                                new XMLUtils().getNodeXPath(currentUI,
-                                        "dynamic"),
-                                "UTF-8",
-                                request
-                                        .getRealPath("WEB-INF/config/templates/describe-ui.xsl"));
-
-                request.setAttribute("ui", ui);
-
-                String staticUI = transformer
-                        .transform(
-                                new XMLUtils()
-                                        .getNodeXPath(currentUI, "static"),
-                                "UTF-8",
-                                request
-                                        .getRealPath("WEB-INF/config/templates/describe-ui-static.xsl"));
-                request.setAttribute("staticui", staticUI);
-
+                if (currentUI != null){
+                    XSLTransformer transformer = new XSLTransformer();
+                    Node dynamicUINode =  new XMLUtils().getNodeXPath(currentUI,"dynamic");
+                    if (dynamicUINode != null){
+                        String ui = transformer
+                                .transform(
+                                        dynamicUINode,
+                                        "UTF-8",
+                                        request
+                                                .getRealPath("WEB-INF/config/templates/describe-ui.xsl"));
+        
+                        request.setAttribute("ui", ui);
+                    }
+                    
+                    Node staticUINode = new XMLUtils().getNodeXPath(currentUI, "static");
+                    if (staticUINode != null){
+                        String staticUI = transformer
+                                .transform(
+                                        staticUINode,
+                                        "UTF-8",
+                                        request
+                                                .getRealPath("WEB-INF/config/templates/describe-ui-static.xsl"));
+                        request.setAttribute("staticui", staticUI);
+                    }
+                }
                 request.setAttribute("furthertargets", false);
             }
             return super.execute(mapping, form, request, response);
--- a/gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/DefaultArtifactDatabaseClient.java	Wed Oct 21 08:20:06 2009 +0000
+++ b/gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/DefaultArtifactDatabaseClient.java	Thu Oct 22 12:21:53 2009 +0000
@@ -225,7 +225,6 @@
         if (response.getStatus().getCode() != 200){
             throw new IOException(response.getStatus().getDescription());
         }
-        // TODO RESPONSESTATUS AUSWERTEN.
         Representation output = response.getEntity();
         return output.getStream();
     }

http://dive4elements.wald.intevation.org