01: /*
02: * Created on Feb 9, 2004
03: *
04: * To change the template for this generated file go to
05: * Window - Preferences - Java - Code Generation - Code and Comments
06: */
07: package org.vfny.geoserver.action.data;
08:
09: import org.apache.struts.action.ActionForm;
10: import org.apache.struts.action.ActionForward;
11: import org.apache.struts.action.ActionMapping;
12: import org.geotools.data.DataStore;
13: import org.geotools.data.FeatureSource;
14: import org.geotools.feature.FeatureType;
15: import org.vfny.geoserver.action.ConfigAction;
16: import org.vfny.geoserver.config.DataConfig;
17: import org.vfny.geoserver.config.DataStoreConfig;
18: import org.vfny.geoserver.config.FeatureTypeConfig;
19: import org.vfny.geoserver.global.UserContainer;
20: import org.vfny.geoserver.util.DataStoreUtils;
21: import java.io.IOException;
22: import javax.servlet.ServletException;
23: import javax.servlet.http.HttpServletRequest;
24: import javax.servlet.http.HttpServletResponse;
25:
26: /**
27: * CalculateBoundingBoxAction purpose.
28: * <p>
29: * Description of CalculateBoundingBoxAction ...
30: * </p>
31: *
32: * <p>
33: * Capabilities:
34: * </p>
35: * <ul>
36: * <li>
37: * Feature: description
38: * </li>
39: * </ul>
40: * <p>
41: * Example Use:
42: * </p>
43: * <pre><code>
44: * CalculateBoundingBoxAction x = new CalculateBoundingBoxAction(...);
45: * </code></pre>
46: *
47: * @author rgould, Refractions Research, Inc.
48: * @author $Author: dmzwiers $ (last modification)
49: * @version $Id: CalculateBoundingBoxAction.java 7693 2007-11-01 09:31:11Z aaime $
50: */
51: public final class CalculateBoundingBoxAction extends ConfigAction {
52: public ActionForward execute(ActionMapping mapping,
53: ActionForm form, UserContainer user,
54: HttpServletRequest request, HttpServletResponse response)
55: throws IOException, ServletException {
56: FeatureTypeConfig ftConfig = (FeatureTypeConfig) request
57: .getSession().getAttribute(
58: DataConfig.SELECTED_FEATURE_TYPE);
59: DataConfig dataConfig = getDataConfig();
60: DataStoreConfig dsConfig = dataConfig.getDataStore(ftConfig
61: .getDataStoreId());
62: DataStore dataStore = null;
63: try {
64: dataStore = dsConfig.findDataStore(request.getSession()
65: .getServletContext());
66: FeatureType featureType = dataStore.getSchema(ftConfig
67: .getName());
68: FeatureSource fs = dataStore.getFeatureSource(featureType
69: .getTypeName());
70:
71: ftConfig.setLatLongBBox(DataStoreUtils
72: .getBoundingBoxEnvelope(fs));
73: request.getSession().setAttribute(
74: DataConfig.SELECTED_FEATURE_TYPE, ftConfig);
75:
76: return mapping.findForward("config.data.type.editor");
77: } finally {
78: if (dataStore != null)
79: dataStore.dispose();
80: }
81: }
82: }
|