001 //$HeadURL: https://svn.wald.intevation.org/svn/deegree/base/branches/2.3_testing/src/org/deegree/enterprise/control/WebEvent.java $
002 /*----------------------------------------------------------------------------
003 This file is part of deegree, http://deegree.org/
004 Copyright (C) 2001-2009 by:
005 Department of Geography, University of Bonn
006 and
007 lat/lon GmbH
008
009 This library is free software; you can redistribute it and/or modify it under
010 the terms of the GNU Lesser General Public License as published by the Free
011 Software Foundation; either version 2.1 of the License, or (at your option)
012 any later version.
013 This library is distributed in the hope that it will be useful, but WITHOUT
014 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
015 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
016 details.
017 You should have received a copy of the GNU Lesser General Public License
018 along with this library; if not, write to the Free Software Foundation, Inc.,
019 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
020
021 Contact information:
022
023 lat/lon GmbH
024 Aennchenstr. 19, 53177 Bonn
025 Germany
026 http://lat-lon.de/
027
028 Department of Geography, University of Bonn
029 Prof. Dr. Klaus Greve
030 Postfach 1147, 53001 Bonn
031 Germany
032 http://www.geographie.uni-bonn.de/deegree/
033
034 e-mail: info@deegree.org
035 ----------------------------------------------------------------------------*/
036
037 // $Id: WebEvent.java 18195 2009-06-18 15:55:39Z mschneider $
038 package org.deegree.enterprise.control;
039
040 // JDK 1.3
041 import java.util.Enumeration;
042 import java.util.EventObject;
043 import java.util.Properties;
044
045 import javax.servlet.http.HttpServletRequest;
046
047 /**
048 *
049 * @author <a href="mailto:tfriebe@gmx.net">Torsten Friebe</a>
050 * @author <a href="mailto:poth@lat-lon.de">Andreas Poth</a>
051 *
052 * @version $Revision: 18195 $
053 */
054 public class WebEvent extends EventObject implements FormEvent {
055 /**
056 *
057 */
058 private static final long serialVersionUID = 706936738051288390L;
059
060 /**
061 * Creates a new WebEvent object.
062 *
063 * @param request
064 */
065 public WebEvent( HttpServletRequest request ) {
066 super( request );
067 }
068
069 /**
070 * @return the parameters
071 */
072 public Properties getParameter() {
073 return this._getParameters( this._getRequest() );
074 }
075
076 /**
077 * @return the document path
078 */
079 public String getDocumentPath() {
080 return this._getRequest().getRequestURI();
081 }
082
083 /**
084 * @return the request user
085 */
086 public RequestUser getRequestUser() {
087 return this._getRequestUser( this._getRequest() );
088 }
089
090 @Override
091 public String toString() {
092 return this.getClass().getName().concat( " [ " ).concat( getDocumentPath() ).concat( " ]" );
093 }
094
095 /**
096 * Returns a list of Properties with key value pairs created out of the incoming POST paramteres.
097 */
098 private Properties _getParameters( HttpServletRequest request ) {
099 Properties p = new Properties();
100
101 for ( Enumeration<?> e = request.getParameterNames(); e.hasMoreElements(); ) {
102 String key = (String) e.nextElement();
103 p.setProperty( key, request.getParameter( key ) );
104 }
105
106 return p;
107 }
108
109 private RequestUser _getRequestUser( HttpServletRequest request ) {
110 return new RequestUser( request );
111 }
112
113 private HttpServletRequest _getRequest() {
114 return (HttpServletRequest) getSource();
115 }
116
117 /** @link dependency */
118
119 /* #RequestUser lnkRequestUser; */
120 }