# HG changeset patch # User Tim Englich # Date 1257956642 0 # Node ID 1fe52a0cbd1f87b17376d9e239f1c9505f004833 # Parent 3be414dc974ab1bb7f5be0c6aa70c3f2e676019e Catch NPE and tell the user that the Session has expired. issue80 gnv/trunk@324 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 3be414dc974a -r 1fe52a0cbd1f gnv/ChangeLog --- a/gnv/ChangeLog Wed Nov 11 13:20:34 2009 +0000 +++ b/gnv/ChangeLog Wed Nov 11 16:24:02 2009 +0000 @@ -1,5 +1,9 @@ 2009-11-11 Tim Englich + * src/main/java/de/intevation/gnv/action/NextArtifactStepAction.java (execute): + Catch NPE and tell the user that the Session has expired. issue80 + +2009-11-11 Tim Englich * src/main/webapp/WEB-INF/config/templates/describe-ui-static.xsl: Remove
Tag after Input-Elements * src/main/webapp/WEB-INF/config/templates/describe-ui.xsl: diff -r 3be414dc974a -r 1fe52a0cbd1f gnv/src/main/java/de/intevation/gnv/action/NextArtifactStepAction.java --- a/gnv/src/main/java/de/intevation/gnv/action/NextArtifactStepAction.java Wed Nov 11 13:20:34 2009 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/action/NextArtifactStepAction.java Wed Nov 11 16:24:02 2009 +0000 @@ -59,133 +59,140 @@ SessionModel sm = SessionModelFactory.getInstance() .getSessionModel(request); ArtifactDescription ad = sm.getArtifactDescription(); - Collection inputParameter = ad.getInputParameter(); - Collection ips = null; - if (inputParameter != null) { - ips = new ArrayList(inputParameter.size()); - Iterator it = inputParameter.iterator(); - while (it.hasNext()) { - String name = it.next(); - String[] values = request.getParameterValues(name); - InputParameter ip = new DefaultInputParameter(name, values); - ips.add(ip); - } - } - ArtifactDatabaseClient adc = ArtifactDatabaseClientFactory - .getInstance() - .getArtifactDatabaseClient(getLocale(request)); - if (ad.getReachableStates() != null - && !ad.getReachableStates().isEmpty()) { - // TODO: Woher kommt der zu erreichende Status; - String target = null; - if (ad.getReachableStates().size() > 1) { - target = request.getParameter("product"); // TODO HACK for - // Propducts every - // other Step has - // currently only - // one reachable - // state. - } else { - target = ad.getReachableStates().iterator().next(); - } - - ArtifactDescription artifactDescription; - try { - artifactDescription = adc.doNextStep(sm.getSelectedArtifactFactory(), - sm.getCurrentArtifact(), - target, ips); - } catch (Exception e) { - log.error(e, e); - request.setAttribute( - CommunicationKeys.REQUEST_EXCEPTION_MESSAGE_ID, e - .getMessage()); - artifactDescription = sm.getArtifactDescription(); - } - - Node currentUI = artifactDescription.getCurrentUI(); - 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); + if (ad != null){ + Collection inputParameter = ad.getInputParameter(); + Collection ips = null; + if (inputParameter != null) { + ips = new ArrayList(inputParameter.size()); + Iterator it = inputParameter.iterator(); + while (it.hasNext()) { + String name = it.next(); + String[] values = request.getParameterValues(name); + InputParameter ip = new DefaultInputParameter(name, values); + ips.add(ip); } } - request.setAttribute("furthertargets", - (ad.getReachableStates() != null && !ad - .getReachableStates().isEmpty())); - - } else { - // statistic abholen und in das sessionmodell schreiben. - ArtifactDescription artifactDescription; - try{ - adc.doFeed(sm.getSelectedArtifactFactory(), sm - .getCurrentArtifact(), ips); - - Collection statistics = adc - .calculateStatistics(sm.getSelectedArtifactFactory(), - sm.getCurrentArtifact()); - sm.setStatistics(statistics); - artifactDescription = adc - .getCurrentStepDescription(sm - .getSelectedArtifactFactory(), sm - .getCurrentArtifact(), - true); - - request.setAttribute("diagramm", true); - - } catch (Exception e) { - log.error(e, e); - request.setAttribute( - CommunicationKeys.REQUEST_EXCEPTION_MESSAGE_ID, e - .getMessage()); - artifactDescription = sm.getArtifactDescription(); + ArtifactDatabaseClient adc = ArtifactDatabaseClientFactory + .getInstance() + .getArtifactDatabaseClient(getLocale(request)); + if (ad.getReachableStates() != null + && !ad.getReachableStates().isEmpty()) { + // TODO: Woher kommt der zu erreichende Status; + String target = null; + if (ad.getReachableStates().size() > 1) { + target = request.getParameter("product"); // TODO HACK for + // Propducts every + // other Step has + // currently only + // one reachable + // state. + } else { + target = ad.getReachableStates().iterator().next(); + } + + ArtifactDescription artifactDescription; + try { + artifactDescription = adc.doNextStep(sm.getSelectedArtifactFactory(), + sm.getCurrentArtifact(), + target, ips); + } catch (Exception e) { + log.error(e, e); + request.setAttribute( + CommunicationKeys.REQUEST_EXCEPTION_MESSAGE_ID, e + .getMessage()); + artifactDescription = sm.getArtifactDescription(); + } + + Node currentUI = artifactDescription.getCurrentUI(); + 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())); + + } else { + // statistic abholen und in das sessionmodell schreiben. + ArtifactDescription artifactDescription; + try{ + adc.doFeed(sm.getSelectedArtifactFactory(), sm + .getCurrentArtifact(), ips); + + Collection statistics = adc + .calculateStatistics(sm.getSelectedArtifactFactory(), + sm.getCurrentArtifact()); + sm.setStatistics(statistics); + artifactDescription = adc + .getCurrentStepDescription(sm + .getSelectedArtifactFactory(), sm + .getCurrentArtifact(), + true); + + request.setAttribute("diagramm", true); + + } catch (Exception e) { + log.error(e, e); + request.setAttribute( + CommunicationKeys.REQUEST_EXCEPTION_MESSAGE_ID, e + .getMessage()); + artifactDescription = sm.getArtifactDescription(); + } + + Node currentUI = artifactDescription.getCurrentUI(); + 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); } - - Node currentUI = artifactDescription.getCurrentUI(); - 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); + }else{ + log.warn("SessionTimeout has occured"); + request.setAttribute(CommunicationKeys.REQUEST_EXCEPTION_MESSAGE_ID, + "SessionTimeout has occured"); + new FetchArtifactFactoriesAction().execute(mapping, form, request, response); } return super.execute(mapping, form, request, response); }