Mercurial > dive4elements > gnv-client
changeset 680:ba3370dbc8c5
Parse time to live of a wms-layer from meta document and show it in html gui (issue197).
gnv/trunk@830 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 26 Mar 2010 09:22:32 +0000 |
parents | 4eccd03394ac |
children | 15ac78a91d1b |
files | gnv/ChangeLog gnv/src/main/java/de/intevation/gnv/action/WMSAction.java gnv/src/main/resources/applicationMessages.properties gnv/src/main/resources/applicationMessages_en.properties gnv/src/main/webapp/WEB-INF/jsp/wmslayout.jsp gnv/src/main/webapp/styles/default.css |
diffstat | 6 files changed, 53 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/gnv/ChangeLog Mon Mar 22 11:42:15 2010 +0000 +++ b/gnv/ChangeLog Fri Mar 26 09:22:32 2010 +0000 @@ -1,3 +1,20 @@ +2010-03-26 Ingo Weinzierl <ingo.weinzierl@intevation.de> + + Issue197 + + * src/main/java/de/intevation/gnv/action/WMSAction.java: Parse the time to + live of an artifact from meta document and set an attribute 'ttl' of the + request object. + + * src/main/webapp/WEB-INF/jsp/wmslayout.jsp: Added a new row showing + the time to live beneath the layer name and wms url. + + * src/main/resources/applicationMessages_en.properties, + src/main/resources/applicationMessages.properties: Added new label for + availability of an artifact/wms-layer. + + * src/main/webapp/styles/default.css: Moved OpenLayers map a bit south. + 2010-03-22 Ingo Weinzierl <ingo.weinzierl@intevation.de> * src/main/java/de/intevation/gnv/artifactdatabase/client/DefaultArtifactDatabaseClient.java:
--- a/gnv/src/main/java/de/intevation/gnv/action/WMSAction.java Mon Mar 22 11:42:15 2010 +0000 +++ b/gnv/src/main/java/de/intevation/gnv/action/WMSAction.java Fri Mar 26 09:22:32 2010 +0000 @@ -1,7 +1,9 @@ package de.intevation.gnv.action; +import java.text.DateFormat; import java.util.ArrayList; import java.util.Collection; +import java.util.Date; import java.util.Iterator; import javax.servlet.http.HttpServletRequest; @@ -39,6 +41,9 @@ public static final String XPATH_LAYER_TITLE = "/art:meta/art:layer/art:title/text()"; + public static final String XPATH_LAYER_TTL = + "/art:meta/art:layer/art:ttl/text()"; + /** * the logger, used to log exceptions and additonaly information */ @@ -108,18 +113,41 @@ meta, XPATH_MAPSERVER_MAPFILE); String layer = XMLUtils.getStringXPath( meta, XPATH_LAYER_TITLE); + String tmpTTL = XMLUtils.getStringXPath( + meta, XPATH_LAYER_TTL); layer = layer != null ? layer : artifact.getId(); + String ttl = null; + if (tmpTTL != null) { + DateFormat df = DateFormat.getDateTimeInstance( + DateFormat.LONG, + DateFormat.LONG, + request.getLocale()); + + try { + long tmp = Long.parseLong(tmpTTL); + ttl = df.format(new Date(tmp)); + } + catch (NumberFormatException nfe) { + logger.error("Error while parsing time to live."); + logger.error(nfe,nfe); + + ttl = ""; + } + } + if (logger.isDebugEnabled()) { logger.debug("Mapserver path: " + mapserverPath); logger.debug("Mapfile path: " + mapfilePath); logger.debug("Layer title: " + layer); + logger.debug("Layer ttl: " + ttl); } request.setAttribute("wms", true); request.setAttribute("mapserver", mapserverPath); request.setAttribute("mapfile", mapfilePath); request.setAttribute("layer", layer); + request.setAttribute("ttl", ttl); if (mapserverPath != null && mapfilePath != null && layer != null){
--- a/gnv/src/main/resources/applicationMessages.properties Mon Mar 22 11:42:15 2010 +0000 +++ b/gnv/src/main/resources/applicationMessages.properties Fri Mar 26 09:22:32 2010 +0000 @@ -71,6 +71,7 @@ # wms gnviewer.wms.server.path=URL des WMS gnviewer.wms.server.layer=Name des Layers +gnviewer.wms.layer.ttl=Layer ist g\u00fcltig bis gnviewer.wms.options.header.title=WMS Optionen # attachedOutputOptions
--- a/gnv/src/main/resources/applicationMessages_en.properties Mon Mar 22 11:42:15 2010 +0000 +++ b/gnv/src/main/resources/applicationMessages_en.properties Fri Mar 26 09:22:32 2010 +0000 @@ -71,6 +71,7 @@ # wms gnviewer.wms.server.path=WMS URL gnviewer.wms.server.layer=Layername +gnviewer.wms.layer.ttl=Layer is valid to gnviewer.wms.options.header.title=WMS Optionen # attachedOutputOptions
--- a/gnv/src/main/webapp/WEB-INF/jsp/wmslayout.jsp Mon Mar 22 11:42:15 2010 +0000 +++ b/gnv/src/main/webapp/WEB-INF/jsp/wmslayout.jsp Fri Mar 26 09:22:32 2010 +0000 @@ -5,6 +5,7 @@ String serverPath = (String) request.getAttribute("mapserver"); String mapfilePath = (String) request.getAttribute("mapfile"); String layerName = (String) request.getAttribute("layer"); + String timeToLive = (String) request.getAttribute("ttl"); %> <html xmlns="http://www.w3.org/1999/xhtml"> @@ -76,6 +77,10 @@ <td class="parameter"><bean:message key="gnviewer.wms.server.layer"/>:</td> <td class="wmsvalue"><%=layerName%></td> </tr> + <tr> + <td class="parameter"><bean:message key="gnviewer.wms.layer.ttl"/>:</td> + <td class="wmsvalue"><%=timeToLive%></td> + </tr> </table> </div> <div id="map"></div>