Mercurial > dive4elements > gnv-client
comparison gnv/src/main/java/de/intevation/gnv/action/NextArtifactStepAction.java @ 163:1fe52a0cbd1f
Catch NPE and tell the user that the Session has expired. issue80
gnv/trunk@324 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Tim Englich <tim.englich@intevation.de> |
---|---|
date | Wed, 11 Nov 2009 16:24:02 +0000 |
parents | 013d47662161 |
children | 5570d9b3282f |
comparison
equal
deleted
inserted
replaced
162:3be414dc974a | 163:1fe52a0cbd1f |
---|---|
57 HttpServletResponse response) throws Exception { | 57 HttpServletResponse response) throws Exception { |
58 log.debug("NextArtifactStepAction.execute"); | 58 log.debug("NextArtifactStepAction.execute"); |
59 SessionModel sm = SessionModelFactory.getInstance() | 59 SessionModel sm = SessionModelFactory.getInstance() |
60 .getSessionModel(request); | 60 .getSessionModel(request); |
61 ArtifactDescription ad = sm.getArtifactDescription(); | 61 ArtifactDescription ad = sm.getArtifactDescription(); |
62 Collection<String> inputParameter = ad.getInputParameter(); | 62 if (ad != null){ |
63 Collection<InputParameter> ips = null; | 63 Collection<String> inputParameter = ad.getInputParameter(); |
64 if (inputParameter != null) { | 64 Collection<InputParameter> ips = null; |
65 ips = new ArrayList<InputParameter>(inputParameter.size()); | 65 if (inputParameter != null) { |
66 Iterator<String> it = inputParameter.iterator(); | 66 ips = new ArrayList<InputParameter>(inputParameter.size()); |
67 while (it.hasNext()) { | 67 Iterator<String> it = inputParameter.iterator(); |
68 String name = it.next(); | 68 while (it.hasNext()) { |
69 String[] values = request.getParameterValues(name); | 69 String name = it.next(); |
70 InputParameter ip = new DefaultInputParameter(name, values); | 70 String[] values = request.getParameterValues(name); |
71 ips.add(ip); | 71 InputParameter ip = new DefaultInputParameter(name, values); |
72 ips.add(ip); | |
73 } | |
72 } | 74 } |
73 } | 75 ArtifactDatabaseClient adc = ArtifactDatabaseClientFactory |
74 ArtifactDatabaseClient adc = ArtifactDatabaseClientFactory | 76 .getInstance() |
75 .getInstance() | 77 .getArtifactDatabaseClient(getLocale(request)); |
76 .getArtifactDatabaseClient(getLocale(request)); | 78 if (ad.getReachableStates() != null |
77 if (ad.getReachableStates() != null | 79 && !ad.getReachableStates().isEmpty()) { |
78 && !ad.getReachableStates().isEmpty()) { | 80 // TODO: Woher kommt der zu erreichende Status; |
79 // TODO: Woher kommt der zu erreichende Status; | 81 String target = null; |
80 String target = null; | 82 if (ad.getReachableStates().size() > 1) { |
81 if (ad.getReachableStates().size() > 1) { | 83 target = request.getParameter("product"); // TODO HACK for |
82 target = request.getParameter("product"); // TODO HACK for | 84 // Propducts every |
83 // Propducts every | 85 // other Step has |
84 // other Step has | 86 // currently only |
85 // currently only | 87 // one reachable |
86 // one reachable | 88 // state. |
87 // state. | 89 } else { |
90 target = ad.getReachableStates().iterator().next(); | |
91 } | |
92 | |
93 ArtifactDescription artifactDescription; | |
94 try { | |
95 artifactDescription = adc.doNextStep(sm.getSelectedArtifactFactory(), | |
96 sm.getCurrentArtifact(), | |
97 target, ips); | |
98 } catch (Exception e) { | |
99 log.error(e, e); | |
100 request.setAttribute( | |
101 CommunicationKeys.REQUEST_EXCEPTION_MESSAGE_ID, e | |
102 .getMessage()); | |
103 artifactDescription = sm.getArtifactDescription(); | |
104 } | |
105 | |
106 Node currentUI = artifactDescription.getCurrentUI(); | |
107 if (currentUI != null){ | |
108 XSLTransformer transformer = new XSLTransformer(); | |
109 Node dynamicUINode = new XMLUtils().getNodeXPath(currentUI,"dynamic"); | |
110 if (dynamicUINode != null){ | |
111 String ui = transformer | |
112 .transform( | |
113 dynamicUINode, | |
114 "UTF-8", | |
115 request | |
116 .getRealPath("WEB-INF/config/templates/describe-ui.xsl")); | |
117 | |
118 request.setAttribute("ui", ui); | |
119 } | |
120 | |
121 Node staticUINode = new XMLUtils().getNodeXPath(currentUI, "static"); | |
122 if (staticUINode != null){ | |
123 String staticUI = transformer | |
124 .transform( | |
125 staticUINode, | |
126 "UTF-8", | |
127 request | |
128 .getRealPath("WEB-INF/config/templates/describe-ui-static.xsl")); | |
129 request.setAttribute("staticui", staticUI); | |
130 } | |
131 } | |
132 request.setAttribute("furthertargets", | |
133 (ad.getReachableStates() != null && !ad | |
134 .getReachableStates().isEmpty())); | |
135 | |
88 } else { | 136 } else { |
89 target = ad.getReachableStates().iterator().next(); | 137 // statistic abholen und in das sessionmodell schreiben. |
138 ArtifactDescription artifactDescription; | |
139 try{ | |
140 adc.doFeed(sm.getSelectedArtifactFactory(), sm | |
141 .getCurrentArtifact(), ips); | |
142 | |
143 Collection<ArtifactStatisticValue> statistics = adc | |
144 .calculateStatistics(sm.getSelectedArtifactFactory(), | |
145 sm.getCurrentArtifact()); | |
146 sm.setStatistics(statistics); | |
147 artifactDescription = adc | |
148 .getCurrentStepDescription(sm | |
149 .getSelectedArtifactFactory(), sm | |
150 .getCurrentArtifact(), | |
151 true); | |
152 | |
153 request.setAttribute("diagramm", true); | |
154 | |
155 } catch (Exception e) { | |
156 log.error(e, e); | |
157 request.setAttribute( | |
158 CommunicationKeys.REQUEST_EXCEPTION_MESSAGE_ID, e | |
159 .getMessage()); | |
160 artifactDescription = sm.getArtifactDescription(); | |
161 } | |
162 | |
163 Node currentUI = artifactDescription.getCurrentUI(); | |
164 if (currentUI != null){ | |
165 XSLTransformer transformer = new XSLTransformer(); | |
166 Node dynamicUINode = new XMLUtils().getNodeXPath(currentUI,"dynamic"); | |
167 if (dynamicUINode != null){ | |
168 String ui = transformer | |
169 .transform( | |
170 dynamicUINode, | |
171 "UTF-8", | |
172 request | |
173 .getRealPath("WEB-INF/config/templates/describe-ui.xsl")); | |
174 | |
175 request.setAttribute("ui", ui); | |
176 } | |
177 | |
178 Node staticUINode = new XMLUtils().getNodeXPath(currentUI, "static"); | |
179 if (staticUINode != null){ | |
180 String staticUI = transformer | |
181 .transform( | |
182 staticUINode, | |
183 "UTF-8", | |
184 request | |
185 .getRealPath("WEB-INF/config/templates/describe-ui-static.xsl")); | |
186 request.setAttribute("staticui", staticUI); | |
187 } | |
188 } | |
189 request.setAttribute("furthertargets", false); | |
90 } | 190 } |
91 | 191 }else{ |
92 ArtifactDescription artifactDescription; | 192 log.warn("SessionTimeout has occured"); |
93 try { | 193 request.setAttribute(CommunicationKeys.REQUEST_EXCEPTION_MESSAGE_ID, |
94 artifactDescription = adc.doNextStep(sm.getSelectedArtifactFactory(), | 194 "SessionTimeout has occured"); |
95 sm.getCurrentArtifact(), | 195 new FetchArtifactFactoriesAction().execute(mapping, form, request, response); |
96 target, ips); | |
97 } catch (Exception e) { | |
98 log.error(e, e); | |
99 request.setAttribute( | |
100 CommunicationKeys.REQUEST_EXCEPTION_MESSAGE_ID, e | |
101 .getMessage()); | |
102 artifactDescription = sm.getArtifactDescription(); | |
103 } | |
104 | |
105 Node currentUI = artifactDescription.getCurrentUI(); | |
106 if (currentUI != null){ | |
107 XSLTransformer transformer = new XSLTransformer(); | |
108 Node dynamicUINode = new XMLUtils().getNodeXPath(currentUI,"dynamic"); | |
109 if (dynamicUINode != null){ | |
110 String ui = transformer | |
111 .transform( | |
112 dynamicUINode, | |
113 "UTF-8", | |
114 request | |
115 .getRealPath("WEB-INF/config/templates/describe-ui.xsl")); | |
116 | |
117 request.setAttribute("ui", ui); | |
118 } | |
119 | |
120 Node staticUINode = new XMLUtils().getNodeXPath(currentUI, "static"); | |
121 if (staticUINode != null){ | |
122 String staticUI = transformer | |
123 .transform( | |
124 staticUINode, | |
125 "UTF-8", | |
126 request | |
127 .getRealPath("WEB-INF/config/templates/describe-ui-static.xsl")); | |
128 request.setAttribute("staticui", staticUI); | |
129 } | |
130 } | |
131 request.setAttribute("furthertargets", | |
132 (ad.getReachableStates() != null && !ad | |
133 .getReachableStates().isEmpty())); | |
134 | |
135 } else { | |
136 // statistic abholen und in das sessionmodell schreiben. | |
137 ArtifactDescription artifactDescription; | |
138 try{ | |
139 adc.doFeed(sm.getSelectedArtifactFactory(), sm | |
140 .getCurrentArtifact(), ips); | |
141 | |
142 Collection<ArtifactStatisticValue> statistics = adc | |
143 .calculateStatistics(sm.getSelectedArtifactFactory(), | |
144 sm.getCurrentArtifact()); | |
145 sm.setStatistics(statistics); | |
146 artifactDescription = adc | |
147 .getCurrentStepDescription(sm | |
148 .getSelectedArtifactFactory(), sm | |
149 .getCurrentArtifact(), | |
150 true); | |
151 | |
152 request.setAttribute("diagramm", true); | |
153 | |
154 } catch (Exception e) { | |
155 log.error(e, e); | |
156 request.setAttribute( | |
157 CommunicationKeys.REQUEST_EXCEPTION_MESSAGE_ID, e | |
158 .getMessage()); | |
159 artifactDescription = sm.getArtifactDescription(); | |
160 } | |
161 | |
162 Node currentUI = artifactDescription.getCurrentUI(); | |
163 if (currentUI != null){ | |
164 XSLTransformer transformer = new XSLTransformer(); | |
165 Node dynamicUINode = new XMLUtils().getNodeXPath(currentUI,"dynamic"); | |
166 if (dynamicUINode != null){ | |
167 String ui = transformer | |
168 .transform( | |
169 dynamicUINode, | |
170 "UTF-8", | |
171 request | |
172 .getRealPath("WEB-INF/config/templates/describe-ui.xsl")); | |
173 | |
174 request.setAttribute("ui", ui); | |
175 } | |
176 | |
177 Node staticUINode = new XMLUtils().getNodeXPath(currentUI, "static"); | |
178 if (staticUINode != null){ | |
179 String staticUI = transformer | |
180 .transform( | |
181 staticUINode, | |
182 "UTF-8", | |
183 request | |
184 .getRealPath("WEB-INF/config/templates/describe-ui-static.xsl")); | |
185 request.setAttribute("staticui", staticUI); | |
186 } | |
187 } | |
188 request.setAttribute("furthertargets", false); | |
189 } | 196 } |
190 return super.execute(mapping, form, request, response); | 197 return super.execute(mapping, form, request, response); |
191 } | 198 } |
192 | 199 |
193 } | 200 } |