Mercurial > dive4elements > gnv-client
changeset 991:33198e55371c
Improved session handling in the gui. If a session has timed out, the user gets to the start point - the fis selection.
gnv/trunk@1192 c6561f87-3c4e-4783-a992-168aeb5c3f6f
line wrap: on
line diff
--- a/gnv/ChangeLog Thu Jun 10 09:54:58 2010 +0000 +++ b/gnv/ChangeLog Thu Jun 10 15:13:08 2010 +0000 @@ -1,3 +1,42 @@ +2010-06-10 Ingo Weinzierl <ingo.weinzierl@intevation.de> + + * src/main/java/de/intevation/gnv/action/ArtifactDatabaseActionBase.java: + New methods for session validation. Method isSessionExhausted(.) returns + true, if the session of the user is new. Another medhod returns the + ActionForward for selecting a fis - which is the start point of our + application. + + * src/main/java/de/intevation/gnv/action/ChangeOptionsAction.java, + src/main/java/de/intevation/gnv/action/DoExportAction.java, + src/main/java/de/intevation/gnv/action/SwitchLanguageAction.java, + src/main/java/de/intevation/gnv/action/WMSAction.java, + src/main/java/de/intevation/gnv/action/ShowStatisticAction.java, + src/main/java/de/intevation/gnv/action/DescribeUIAction.java, + src/main/java/de/intevation/gnv/action/LoadAction.java, + src/main/java/de/intevation/gnv/action/CreateHistogramAction.java, + src/main/java/de/intevation/gnv/action/DoOutputAction.java, + src/main/java/de/intevation/gnv/action/CreateChartAction.java, + src/main/java/de/intevation/gnv/action/PreviousArtifactStepAction.java, + src/main/java/de/intevation/gnv/action/NextArtifactStepAction.java, + src/main/java/de/intevation/gnv/action/StoreAction.java: Validate the + session before doing some other stuff. If the session is exhausted, we + will return to the start point - the fis selection. + + * src/main/webapp/WEB-INF/jsp/index.jsp: Renders an error message if the + session of the user is exhausted. There will be no link to return to the + last point in the parameterization. + + * src/main/java/de/intevation/gnv/action/CommunicationKeys.java: A new key + for session errors. + + * src/main/resources/applicationMessages.properties, + src/main/resources/applicationMessages_en.properties: An error message for + a session that timed out. + + * src/main/webapp/WEB-INF/config/struts-config.xml: Added a new forward to + the export action that makes it possible to step back to the fis + selection. + 2010-06-10 Ingo Weinzierl <ingo.weinzierl@intevation.de> Issue177 - Messages for Java heap size errors.
--- a/gnv/src/main/java/de/intevation/gnv/action/ArtifactDatabaseActionBase.java Thu Jun 10 09:54:58 2010 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/action/ArtifactDatabaseActionBase.java Thu Jun 10 15:13:08 2010 +0000 @@ -2,6 +2,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; import org.apache.log4j.Logger; import org.apache.struts.action.Action; @@ -94,5 +95,27 @@ return good; } + + + protected boolean isSessionExhausted(HttpServletRequest request) { + HttpSession session = request.getSession(); + return session.isNew(); + } + + + protected ActionForward sessionExhaustedForward( + ActionMapping mapping, ActionForm form, + HttpServletRequest request, HttpServletResponse response) + throws Exception + { + request.setAttribute( + CommunicationKeys.REQUEST_EXCEPTION_SESSION_ID, + "SessionTimeout has occured"); + + log.warn("Session timed out."); + + return new FetchArtifactFactoriesAction().execute( + mapping, form, request, response); + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/gnv/src/main/java/de/intevation/gnv/action/ChangeOptionsAction.java Thu Jun 10 09:54:58 2010 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/action/ChangeOptionsAction.java Thu Jun 10 15:13:08 2010 +0000 @@ -48,6 +48,10 @@ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { + if (isSessionExhausted(request)) { + return sessionExhaustedForward(mapping, form, request, response); + } + log.debug("NextArtifactStepAction.execute"); try { SessionModel sm = SessionModelFactory.getInstance()
--- a/gnv/src/main/java/de/intevation/gnv/action/CommunicationKeys.java Thu Jun 10 09:54:58 2010 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/action/CommunicationKeys.java Thu Jun 10 15:13:08 2010 +0000 @@ -12,6 +12,9 @@ */ public final static String REQUEST_EXCEPTION_MESSAGE_ID = "request_exception_message_id"; + + public final static String REQUEST_EXCEPTION_SESSION_ID = "request_exception_session_id"; + /** * Key used to store exceptions relating to wrong user input. */
--- a/gnv/src/main/java/de/intevation/gnv/action/CreateChartAction.java Thu Jun 10 09:54:58 2010 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/action/CreateChartAction.java Thu Jun 10 15:13:08 2010 +0000 @@ -41,6 +41,10 @@ HttpServletRequest request, HttpServletResponse response) throws Exception { + if (isSessionExhausted(request)) { + return sessionExhaustedForward(mapping, form, request, response); + } + logger.debug("Create chart."); SessionModel sm = SessionModelFactory.getInstance().getSessionModel(
--- a/gnv/src/main/java/de/intevation/gnv/action/CreateHistogramAction.java Thu Jun 10 09:54:58 2010 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/action/CreateHistogramAction.java Thu Jun 10 15:13:08 2010 +0000 @@ -41,6 +41,10 @@ HttpServletRequest request, HttpServletResponse response) throws Exception { + if (isSessionExhausted(request)) { + return sessionExhaustedForward(mapping, form, request, response); + } + logger.debug("Create histogram."); SessionModel sm = SessionModelFactory.getInstance().getSessionModel(
--- a/gnv/src/main/java/de/intevation/gnv/action/DescribeUIAction.java Thu Jun 10 09:54:58 2010 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/action/DescribeUIAction.java Thu Jun 10 15:13:08 2010 +0000 @@ -5,6 +5,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; import javax.xml.xpath.XPathConstants; import org.apache.log4j.Logger; @@ -66,6 +67,15 @@ HttpServletResponse response ) throws Exception { + HttpSession session = request.getSession(); + // TODO REMOVE THIS: FOR TESTING + session.setMaxInactiveInterval(15); + + if (isSessionExhausted(request)) { + // session timed out before + return sessionExhaustedForward(mapping, form, request, response); + } + logger.info("describe user interface"); try { // render describe document and create user interface
--- a/gnv/src/main/java/de/intevation/gnv/action/DoExportAction.java Thu Jun 10 09:54:58 2010 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/action/DoExportAction.java Thu Jun 10 15:13:08 2010 +0000 @@ -56,6 +56,10 @@ HttpServletResponse response) throws Exception { + if (isSessionExhausted(request)) { + return sessionExhaustedForward(mapping, form, request, response); + } + try { String target = request.getParameter("target"); String mimeType = request.getParameter("mimetype");
--- a/gnv/src/main/java/de/intevation/gnv/action/DoOutputAction.java Thu Jun 10 09:54:58 2010 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/action/DoOutputAction.java Thu Jun 10 15:13:08 2010 +0000 @@ -52,6 +52,10 @@ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { + if (isSessionExhausted(request)) { + return sessionExhaustedForward(mapping, form, request, response); + } + log.debug("DoOutputAction.execute"); try { String target = request.getParameter("target");
--- a/gnv/src/main/java/de/intevation/gnv/action/LoadAction.java Thu Jun 10 09:54:58 2010 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/action/LoadAction.java Thu Jun 10 15:13:08 2010 +0000 @@ -59,6 +59,10 @@ HttpServletResponse response) throws Exception { + if (isSessionExhausted(request)) { + return sessionExhaustedForward(mapping, form, request, response); + } + logger.info("Import artifact."); ServletFileUpload upload = new ServletFileUpload();
--- a/gnv/src/main/java/de/intevation/gnv/action/NextArtifactStepAction.java Thu Jun 10 09:54:58 2010 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/action/NextArtifactStepAction.java Thu Jun 10 15:13:08 2010 +0000 @@ -127,8 +127,6 @@ } catch (ArtifactDatabaseInputException e) { - log.debug("================ CATCH ME ======================"); - log.debug("===== ERROR MSG: " + e.getMessage()); log.error(e, e); request.setAttribute( CommunicationKeys.REQUEST_EXCEPTION_INPUT_ID, @@ -145,9 +143,7 @@ } }else{ log.warn("SessionTimeout has occured"); - request.setAttribute(CommunicationKeys.REQUEST_EXCEPTION_MESSAGE_ID, - "SessionTimeout has occured"); - new FetchArtifactFactoriesAction().execute(mapping, form, request, response); + return sessionExhaustedForward(mapping, form, request, response); } return super.execute(mapping, form, request, response); }
--- a/gnv/src/main/java/de/intevation/gnv/action/PreviousArtifactStepAction.java Thu Jun 10 09:54:58 2010 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/action/PreviousArtifactStepAction.java Thu Jun 10 15:13:08 2010 +0000 @@ -58,12 +58,10 @@ if (ad == null) { logger.warn("Session timed out."); request.setAttribute( - CommunicationKeys.REQUEST_EXCEPTION_MESSAGE_ID, + CommunicationKeys.REQUEST_EXCEPTION_SESSION_ID, "SessionTimeout has occured"); - new FetchArtifactFactoriesAction().execute( + return new FetchArtifactFactoriesAction().execute( mapping, form, request, response); - - return super.execute(mapping, form, request, response); } // TODO check if target is reachable
--- a/gnv/src/main/java/de/intevation/gnv/action/ShowStatisticAction.java Thu Jun 10 09:54:58 2010 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/action/ShowStatisticAction.java Thu Jun 10 15:13:08 2010 +0000 @@ -46,6 +46,10 @@ HttpServletResponse response ) throws Exception { + if (isSessionExhausted(request)) { + return sessionExhaustedForward(mapping, form, request, response); + } + logger.info("show statistic"); SessionModel sm = SessionModelFactory.getInstance().getSessionModel( request);
--- a/gnv/src/main/java/de/intevation/gnv/action/StoreAction.java Thu Jun 10 09:54:58 2010 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/action/StoreAction.java Thu Jun 10 15:13:08 2010 +0000 @@ -46,6 +46,10 @@ HttpServletResponse response) throws Exception { + if (isSessionExhausted(request)) { + return sessionExhaustedForward(mapping, form, request, response); + } + SessionModelFactory sf = SessionModelFactory.getInstance(); SessionModel sm = sf.getSessionModel(request);
--- a/gnv/src/main/java/de/intevation/gnv/action/SwitchLanguageAction.java Thu Jun 10 09:54:58 2010 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/action/SwitchLanguageAction.java Thu Jun 10 15:13:08 2010 +0000 @@ -34,6 +34,10 @@ HttpServletResponse response ) throws Exception { + if (isSessionExhausted(request)) { + return sessionExhaustedForward(mapping, form, request, response); + } + SessionModelFactory factory = SessionModelFactory.getInstance(); SessionModel sm = factory.getSessionModel(request); Locale locale = switchLanguage(sm.getCurrentLocale());
--- a/gnv/src/main/java/de/intevation/gnv/action/WMSAction.java Thu Jun 10 09:54:58 2010 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/action/WMSAction.java Thu Jun 10 15:13:08 2010 +0000 @@ -81,6 +81,10 @@ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { + if (isSessionExhausted(request)) { + return sessionExhaustedForward(mapping, form, request, response); + } + logger.debug("WMSAction.execute"); try { SessionModel sm = SessionModelFactory.getInstance().getSessionModel(
--- a/gnv/src/main/resources/applicationMessages.properties Thu Jun 10 09:54:58 2010 +0000 +++ b/gnv/src/main/resources/applicationMessages.properties Thu Jun 10 15:13:08 2010 +0000 @@ -127,6 +127,7 @@ no.such.factory=Ung\u00fcltiges Artefakt Dokument gefunden. java.io.ioexception..no.such.artifact=Ihr Artefakt ist ung\u00fcltig oder bereits abgelaufen. java.io.ioexception..java.heap.space =Es ist ein interner Serverfehler aufgetreten. Bitte benachrichtigen Sie den Support. +sessiontimeout.has.occured=Ihre Sitzung ist abgelaufen. # the map client gnvview.mapclient.fullscreen = Vollbild
--- a/gnv/src/main/resources/applicationMessages_en.properties Thu Jun 10 09:54:58 2010 +0000 +++ b/gnv/src/main/resources/applicationMessages_en.properties Thu Jun 10 15:13:08 2010 +0000 @@ -125,6 +125,7 @@ no.such.factory=Invalid artifact found. java.io.ioexception..no.such.artifact=Your artifact is invalid or out of date. java.io.ioexception..java.heap.space = An internal server error has occurred. Please contact the support. +sessiontimeout.has.occured=Your session timed out. # the map client gnvview.mapclient.fullscreen = Full screen
--- a/gnv/src/main/webapp/WEB-INF/config/struts-config.xml Thu Jun 10 09:54:58 2010 +0000 +++ b/gnv/src/main/webapp/WEB-INF/config/struts-config.xml Thu Jun 10 15:13:08 2010 +0000 @@ -169,6 +169,9 @@ type="de.intevation.gnv.action.DoExportAction" scope="request" validate="false"> + <forward + name="success" + path="/WEB-INF/jsp/mainlayout.jsp"/> </action> <action path="/changeOptions" type="de.intevation.gnv.action.ChangeOptionsAction"
--- a/gnv/src/main/webapp/WEB-INF/jsp/index.jsp Thu Jun 10 09:54:58 2010 +0000 +++ b/gnv/src/main/webapp/WEB-INF/jsp/index.jsp Thu Jun 10 15:13:08 2010 +0000 @@ -33,6 +33,10 @@ exceptionMessage = (exceptionMessage != null ? exceptionMessage.toString().replaceAll(" ", ".").replaceAll(":",".").toLowerCase() : null); exceptionMessage = (exceptionMessage != null && exceptionMessage.toString().endsWith(".") ? exceptionMessage.toString().substring(0,exceptionMessage.toString().length()-1) : exceptionMessage); + Object sessionException = request.getAttribute(CommunicationKeys.REQUEST_EXCEPTION_SESSION_ID); + sessionException = (sessionException != null ? sessionException.toString().replaceAll(" ", ".").replaceAll(":",".").toLowerCase() : null); + sessionException = (sessionException != null && sessionException.toString().endsWith(".") ? sessionException.toString().substring(0,sessionException.toString().length()-1) : sessionException); + boolean showmapviewercallBody = request.getAttribute("MAPVIEWERCALL") != null; String exceptionProject = (String) request.getAttribute(CommunicationKeys.REQUEST_EXCEPTION_PROJECT); @@ -139,6 +143,11 @@ </p> </div> <%}%> + <%if (sessionException != null){ %> + <div class="errormsg" id="load_error"> + <bean-el:message key="<%=sessionException.toString()%>"/> + </div> + <%}%> <%if (chart != null) {%> <%-- render chart options if existing for this state --%> <jsp:include page="includes/display_diagramm_inc.jsp"></jsp:include>