001 //$HeadURL: https://svn.wald.intevation.org/svn/deegree/base/branches/2.4_testing/src/org/deegree/enterprise/control/AbstractDBListener.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 package org.deegree.enterprise.control;
037
038 import java.util.HashMap;
039
040 import org.deegree.portal.PortalException;
041
042 /**
043 * The class listens to the get request against iso 19115 formated metadata here the result shall be
044 * returned in full format
045 *
046 * <p>
047 * ---------------------------------------------------------------------
048 * </p>
049 *
050 * @author <a href="mailto:poth@lat-lon.de">Andreas Poth</a>
051 * @version $Revision: 18195 $ $Date: 2009-06-18 17:55:39 +0200 (Do, 18. Jun 2009) $
052 */
053 public abstract class AbstractDBListener extends AbstractListener {
054
055 /**
056 * This method is called either to search for metadata or to lookup keywords from the thesaurus
057 */
058 public void actionPerformed( FormEvent event ) {
059
060 RPCWebEvent rpcEvent = (RPCWebEvent) event;
061
062 try {
063 validateRequest( rpcEvent );
064 } catch ( Exception e ) {
065 gotoErrorPage( "Invalid Operations: " + e.toString() );
066 return;
067 }
068
069 HashMap result = null;
070 try {
071 result = performRequest( rpcEvent );
072 } catch ( Exception e ) {
073 e.printStackTrace();
074 gotoErrorPage( "Invalid Operations: " + e.toString() );
075 return;
076 }
077
078 Object res = null;
079 try {
080 res = validateResult( result );
081 } catch ( Exception e ) {
082 e.printStackTrace();
083 gotoErrorPage( "Invalid Result: " + e.toString() );
084 return;
085 }
086
087 try {
088 handleResult( res );
089 } catch ( Exception e ) {
090 gotoErrorPage( "Error handling result: " + e.toString() );
091 return;
092 }
093
094 }
095
096 /**
097 * validates the request to be performed.
098 *
099 * @param event
100 * event object containing the request to be performed
101 */
102 protected abstract void validateRequest( RPCWebEvent event )
103 throws PortalException;
104
105 /**
106 * creates a request from the <tt>RPCWebEvent</tt> passed to this listener
107 *
108 * @param rpcEvent
109 * event object containing the request to be performed
110 * @return string representation of a request
111 * @exception PortalException
112 * will be throwns if it is impossible to create the request
113 */
114 protected abstract HashMap createRequest( RPCWebEvent rpcEvent )
115 throws PortalException;
116
117 /**
118 * performs the request contained in the passed <tt>RPCWebEvent</tt>
119 *
120 * @param event
121 * event object containing the request to be performed
122 * @return result of the GetRecord request
123 * @exception PortalException
124 */
125 protected abstract HashMap performRequest( RPCWebEvent event )
126 throws PortalException;
127
128 /**
129 * validates the result of the catalog request and returns an <tt>Object</tt> depending on the
130 * results content.
131 *
132 * @param result
133 * result to a request
134 * @return validated result to a request
135 * @exception PortalException
136 */
137 protected abstract Object validateResult( HashMap result )
138 throws PortalException;
139
140 /**
141 * handles the result of a 'FULL' catalog query
142 *
143 * @param result
144 * result to a GetRecord request
145 */
146 protected abstract void handleResult( Object result )
147 throws PortalException;
148
149 }