Mercurial > dive4elements > gnv-client
comparison gnv/src/main/java/de/intevation/gnv/action/WMSAction.java @ 976:d1ed5c51c0de
Checkin of changes which are necessary for the checkin of Revision 1139.
gnv/trunk@1146 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Tim Englich <tim.englich@intevation.de> |
---|---|
date | Tue, 01 Jun 2010 17:46:03 +0000 |
parents | d91ffd0e8239 |
children | cfc7bd35ee0b |
comparison
equal
deleted
inserted
replaced
975:5779220ebb80 | 976:d1ed5c51c0de |
---|---|
1 package de.intevation.gnv.action; | 1 package de.intevation.gnv.action; |
2 | |
3 import java.text.DateFormat; | |
4 import java.util.ArrayList; | |
5 import java.util.Collection; | |
6 import java.util.Date; | |
7 import java.util.Iterator; | |
8 | |
9 import javax.servlet.http.HttpServletRequest; | |
10 import javax.servlet.http.HttpServletResponse; | |
11 | |
12 import org.apache.log4j.Logger; | |
13 import org.apache.struts.action.ActionForm; | |
14 import org.apache.struts.action.ActionForward; | |
15 import org.apache.struts.action.ActionMapping; | |
16 import org.w3c.dom.Document; | |
17 import org.w3c.dom.Node; | |
18 import org.w3c.dom.NodeList; | |
2 | 19 |
3 import de.intevation.gnv.action.sessionmodel.DiagrammOptions; | 20 import de.intevation.gnv.action.sessionmodel.DiagrammOptions; |
4 import de.intevation.gnv.action.sessionmodel.SessionModel; | 21 import de.intevation.gnv.action.sessionmodel.SessionModel; |
5 import de.intevation.gnv.action.sessionmodel.SessionModelFactory; | 22 import de.intevation.gnv.action.sessionmodel.SessionModelFactory; |
6 | |
7 import de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClient; | 23 import de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClient; |
8 import de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClientFactory; | 24 import de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClientFactory; |
9 | |
10 import de.intevation.gnv.artifactdatabase.objects.ArtifactObject; | 25 import de.intevation.gnv.artifactdatabase.objects.ArtifactObject; |
11 import de.intevation.gnv.artifactdatabase.objects.DefaultInputParameter; | 26 import de.intevation.gnv.artifactdatabase.objects.DefaultInputParameter; |
12 import de.intevation.gnv.artifactdatabase.objects.InputParameter; | 27 import de.intevation.gnv.artifactdatabase.objects.InputParameter; |
13 import de.intevation.gnv.artifactdatabase.objects.OutputMode; | 28 import de.intevation.gnv.artifactdatabase.objects.OutputMode; |
14 import de.intevation.gnv.artifactdatabase.objects.OutputParameter; | 29 import de.intevation.gnv.artifactdatabase.objects.OutputParameter; |
15 | 30 import de.intevation.gnv.artifactdatabase.objects.map.DefaultLayer; |
31 import de.intevation.gnv.artifactdatabase.objects.map.DefaultMapService; | |
32 import de.intevation.gnv.artifactdatabase.objects.map.Layer; | |
33 import de.intevation.gnv.artifactdatabase.objects.map.MapService; | |
16 import de.intevation.gnv.util.XMLUtils; | 34 import de.intevation.gnv.util.XMLUtils; |
17 | |
18 import java.text.DateFormat; | |
19 | |
20 import java.util.ArrayList; | |
21 import java.util.Collection; | |
22 import java.util.Date; | |
23 import java.util.Iterator; | |
24 | |
25 import javax.servlet.http.HttpServletRequest; | |
26 import javax.servlet.http.HttpServletResponse; | |
27 | |
28 import org.apache.log4j.Logger; | |
29 | |
30 import org.apache.struts.action.ActionForm; | |
31 import org.apache.struts.action.ActionForward; | |
32 import org.apache.struts.action.ActionMapping; | |
33 | |
34 import org.w3c.dom.Document; | |
35 | 35 |
36 /** | 36 /** |
37 * This controller is used to publish the results of the current artifact as | 37 * This controller is used to publish the results of the current artifact as |
38 * WMS. The wms export mode of the artifact server is triggered which feeds a | 38 * WMS. The wms export mode of the artifact server is triggered which feeds a |
39 * MapServer with the given shapefiles (path to the shapefiles is stored in the | 39 * MapServer with the given shapefiles (path to the shapefiles is stored in the |
48 "/art:meta/art:mapserver/art:server/text()"; | 48 "/art:meta/art:mapserver/art:server/text()"; |
49 | 49 |
50 public static final String XPATH_MAPSERVER_MAPFILE = | 50 public static final String XPATH_MAPSERVER_MAPFILE = |
51 "/art:meta/art:mapserver/art:map/text()"; | 51 "/art:meta/art:mapserver/art:map/text()"; |
52 | 52 |
53 public static final String XPATH_LAYERNODESET = | |
54 "/art:meta/art:layer"; | |
55 | |
53 public static final String XPATH_LAYER_TITLE = | 56 public static final String XPATH_LAYER_TITLE = |
54 "/art:meta/art:layer/art:title/text()"; | 57 "art:title/text()"; |
55 | 58 |
56 public static final String XPATH_LAYER_NAME = | 59 public static final String XPATH_LAYER_NAME = |
57 "/art:meta/art:layer/art:name/text()"; | 60 "art:name/text()"; |
58 | 61 |
59 public static final String XPATH_TTL = | 62 public static final String XPATH_TTL = |
60 "/art:meta/art:mapserver/art:ttl/text()"; | 63 "/art:meta/art:mapserver/art:ttl/text()"; |
61 | 64 |
62 /** | 65 /** |
120 getLocale(request)); | 123 getLocale(request)); |
121 ArtifactObject artifactfactory = sm.getSelectedArtifactFactory(); | 124 ArtifactObject artifactfactory = sm.getSelectedArtifactFactory(); |
122 | 125 |
123 // do wms publishing | 126 // do wms publishing |
124 Document meta = adc.publishWMS(artifactfactory,artifact,ips); | 127 Document meta = adc.publishWMS(artifactfactory,artifact,ips); |
128 | |
129 // read the Server-information | |
125 String mapserverPath = XMLUtils.getStringXPath( | 130 String mapserverPath = XMLUtils.getStringXPath( |
126 meta, XPATH_MAPSERVER_PATH); | 131 meta, XPATH_MAPSERVER_PATH); |
127 String mapfilePath = XMLUtils.getStringXPath( | 132 String mapfilePath = XMLUtils.getStringXPath( |
128 meta, XPATH_MAPSERVER_MAPFILE); | 133 meta, XPATH_MAPSERVER_MAPFILE); |
129 String layer = XMLUtils.getStringXPath( | |
130 meta, XPATH_LAYER_NAME); | |
131 String tmpTTL = XMLUtils.getStringXPath( | 134 String tmpTTL = XMLUtils.getStringXPath( |
132 meta, XPATH_TTL); | 135 meta, XPATH_TTL); |
133 layer = layer != null ? layer : artifact.getId(); | |
134 | |
135 String ttl = null; | 136 String ttl = null; |
136 if (tmpTTL != null) { | 137 if (tmpTTL != null) { |
137 DateFormat df = DateFormat.getDateTimeInstance( | 138 DateFormat df = DateFormat.getDateTimeInstance( |
138 DateFormat.LONG, | 139 DateFormat.LONG, |
139 DateFormat.LONG, | 140 DateFormat.LONG, |
152 } | 153 } |
153 | 154 |
154 if (logger.isDebugEnabled()) { | 155 if (logger.isDebugEnabled()) { |
155 logger.debug("Mapserver path: " + mapserverPath); | 156 logger.debug("Mapserver path: " + mapserverPath); |
156 logger.debug("Mapfile path: " + mapfilePath); | 157 logger.debug("Mapfile path: " + mapfilePath); |
157 logger.debug("Layer: " + layer); | |
158 logger.debug("Layer ttl: " + ttl); | 158 logger.debug("Layer ttl: " + ttl); |
159 } | 159 } |
160 | 160 // read the layer information |
161 request.setAttribute("wms", true); | 161 |
162 request.setAttribute("mapserver", mapserverPath); | 162 NodeList layerNodes = XMLUtils.getNodeSetXPath(meta, |
163 request.setAttribute("mapfile", mapfilePath); | 163 XPATH_LAYERNODESET); |
164 request.setAttribute("layer", layer); | 164 Collection<Layer> layers = null; |
165 request.setAttribute("ttl", ttl); | 165 if (layerNodes != null && layerNodes.getLength() > 0){ |
166 layers = new ArrayList<Layer>(layerNodes.getLength()); | |
167 for (int i = 0 ; i < layerNodes.getLength(); i++){ | |
168 Node tmpLayerNode = layerNodes.item(i); | |
169 String layerName = XMLUtils.getStringXPath( | |
170 tmpLayerNode, XPATH_LAYER_NAME); | |
171 String layerTitle = XMLUtils.getStringXPath( | |
172 tmpLayerNode, XPATH_LAYER_TITLE); | |
173 // TODO: write layerTitle to title and not to id | |
174 Layer currentLayer = new DefaultLayer(layerTitle, layerName, | |
175 false, null); | |
176 layers.add(currentLayer); | |
177 } | |
178 } | |
179 | |
180 | |
181 | |
182 | |
183 // TODO PUT MAPFILEPATH AND TTL to MapServiceObject | |
184 | |
166 if (mapserverPath != null && | 185 if (mapserverPath != null && |
167 mapfilePath != null && | 186 mapfilePath != null) { |
168 layer != null){ | |
169 request.setAttribute("wms_published", Boolean.TRUE); | 187 request.setAttribute("wms_published", Boolean.TRUE); |
188 | |
189 MapService mapService = new DefaultMapService("0815", layers, | |
190 "UMN", mapserverPath); | |
191 sm.setLocalMapService(mapService); | |
170 return super.execute(mapping, form, request, response); | 192 return super.execute(mapping, form, request, response); |
171 }else{ | 193 }else{ |
172 return super.execute(mapping, form, request, response); | 194 return super.execute(mapping, form, request, response); |
173 } | 195 } |
174 } | 196 } |