001: /* Copyright (c) 2001 - 2007 TOPP - www.openplans.org. All rights reserved.
002: * This code is licensed under the GPL 2.0 license, availible at the root
003: * application directory.
004: */
005: package org.vfny.geoserver.action;
006:
007: import org.apache.struts.action.Action;
008: import org.geoserver.wfs.WFS;
009: import org.springframework.web.struts.ActionSupport;
010: import org.vfny.geoserver.global.ApplicationState;
011: import org.vfny.geoserver.global.GeoServer;
012: import org.vfny.geoserver.global.UserContainer;
013: import org.vfny.geoserver.global.WCS;
014: import org.vfny.geoserver.global.WMS;
015: import org.vfny.geoserver.util.Requests;
016: import java.util.logging.Logger;
017: import javax.servlet.http.HttpServletRequest;
018:
019: /**
020: * GeoServerAction is a common super class used by STRUTS Actions.
021: *
022: * <p>
023: * GeoServerAction is used to store shared services, such as looking up the
024: * GeoServer Application.
025: * </p>
026: * Capabilities:
027: *
028: * <ul>
029: * <li>
030: * LoggedIn: Convience routines for checking if User has been Authenticated.
031: * These will need to be extended in the future if we allow User based
032: * Capabilities documents.
033: * </li>
034: * <li>
035: * GeoServer (Application) Access: Convience routines have been writen to allow
036: * access to the GeoServer Application from the Web Container.
037: * </li>
038: * </ul>
039: *
040: * Example Use:
041: * <pre><code>
042: * class MyAction extends GeoServerAction {
043: * ...
044: * }
045: * </code></pre>
046: *
047: * <p>
048: * Please remember that Actions (like servlets) should never make use of
049: * instance variables in order to remain thread-safe.
050: * </p>
051: *
052: * <p>
053: * The Services provided by this class are convience methods for the Services
054: * provided by the Requests utiltiy class.
055: * </p>
056: *
057: * @author Jody Garnett, Refractions Research, Inc.
058: * @author $Author: cholmesny $ (last modification)
059: * @version $Id: GeoServerAction.java 7746 2007-11-13 15:38:35Z aaime $
060: */
061: public class GeoServerAction extends ActionSupport {
062: /** Class logger */
063: protected static Logger LOGGER = org.geotools.util.logging.Logging
064: .getLogger("org.vfny.geoserver.action");
065:
066: // /**
067: // * Logs the user out from the current Session.
068: // *
069: // * @param request DOCUMENT ME!
070: // */
071: // public void logOut(HttpServletRequest request) {
072: // Requests.logOut(request);
073: // }
074: //
075: // /**
076: // * Tests if the user has logged onto the current Session
077: // *
078: // * @param request DOCUMENT ME!
079: // *
080: // * @return DOCUMENT ME!
081: // */
082: // public boolean isLoggedIn(HttpServletRequest request) {
083: // return Requests.isLoggedIn(request);
084: // }
085:
086: /**
087: * Aquire type safe session information in a UserContainer.
088: *
089: * <p>
090: * Please note that the UserContainer may be lazyly created.
091: * </p>
092: *
093: * @param request Http Request used to aquire session reference
094: *
095: * @return UserContainer containing typesafe session information.
096: */
097: public UserContainer getUserContainer(HttpServletRequest request) {
098: return Requests.getUserContainer(request);
099: }
100:
101: /**
102: * Aquire WMS from Web Container.
103: *
104: * <p>
105: * The WMS instance is create by a STRUTS plug-in and is available
106: * through the Web container. (Test cases may seed the request object with
107: * a Mock WebContainer and a Mock WMS)
108: * </p>
109: *
110: * @param request HttpServletRequest used to aquire session reference
111: *
112: * @return WMS instance for this Web Application
113: */
114: public WMS getWMS(HttpServletRequest request) {
115: return (WMS) getWebApplicationContext().getBean("wms");
116: }
117:
118: /**
119: * Aquire WCS from Web Container.
120: *
121: * <p>
122: * The WCS instance is create by a STRUTS plug-in and is available
123: * through the Web container. (Test cases may seed the request object with
124: * a Mock WebContainer and a Mock WMS)
125: * </p>
126: *
127: * @param request HttpServletRequest used to aquire session reference
128: *
129: * @return WCS instance for this Web Application
130: */
131: public WCS getWCS(HttpServletRequest request) {
132: return (WCS) getWebApplicationContext().getBean("wcs");
133: }
134:
135: /**
136: * Aquire WFS from Web Container.
137: *
138: * <p>
139: * The WFS instance is create by a STRUTS plug-in and is available
140: * through the Web container. (Test cases may seed the request object with
141: * a Mock WebContainer and a Mock WFS)
142: * </p>
143: *
144: * @param request HttpServletRequest used to aquire session reference
145: *
146: * @return WFS instance for this Web Application
147: */
148: public WFS getWFS(HttpServletRequest request) {
149: return (WFS) getWebApplicationContext().getBean("wfs");
150: }
151:
152: /**
153: * Aquire global configuration from the Spring context.
154:
155: * @return Global configuration of this web app
156: */
157: public GeoServer getGeoServer() {
158: return (GeoServer) getWebApplicationContext().getBean(
159: "geoServer");
160: }
161:
162: /**
163: * Access GeoServer Application State from the WebContainer.
164: *
165: * @param request DOCUMENT ME!
166: *
167: * @return Configuration model for Catalog information.
168: */
169: protected ApplicationState getApplicationState(
170: HttpServletRequest request) {
171: return (ApplicationState) getWebApplicationContext().getBean(
172: "applicationState");
173: }
174: }
|