001 //$$HeaderURL$$
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 package org.deegree.portal.standard.csw.control;
038
039 import java.util.List;
040
041 import org.deegree.enterprise.control.RPCParameter;
042 import org.deegree.enterprise.control.RPCStruct;
043 import org.deegree.enterprise.control.RPCWebEvent;
044 import org.deegree.i18n.Messages;
045 import org.deegree.portal.standard.csw.CatalogClientException;
046
047 /**
048 * This class is used in case a data series is found to display all its datasets So it receives a data series ID and
049 * query all its children
050 *
051 * @author <a href="mailto:elmasry@lat-lon.de">Moataz Elmasry</a>
052 * @author last edited by: $Author: mschneider $
053 *
054 * @version $Revision: 18195 $, $Date: 2009-06-18 17:55:39 +0200 (Do, 18. Jun 2009) $
055 */
056 public class SeriesChildrenSearchListener extends SimpleSearchListener {
057
058 /**
059 *
060 * @param rpcEvent
061 * @throws CatalogClientException
062 */
063 @Override
064 protected void validateRequest( RPCWebEvent rpcEvent )
065 throws CatalogClientException {
066
067 RPCParameter[] params = extractRPCParameters( rpcEvent );
068
069 // validity check for number of parameters in RPCMethodCall
070 if ( params.length != 2 ) {
071 throw new CatalogClientException( Messages.getMessage( "IGEO_STD_CSW_ERROR_WRONG_NUMB_PARAMS", "2",
072 params.length ) );
073 }
074
075 RPCStruct rpcStruct = extractRPCStruct( rpcEvent, 1 );
076 String rpcFormat = (String) extractRPCMember( rpcStruct, RPC_FORMAT );
077 String rpcProtocol = (String) extractRPCMember( rpcStruct, Constants.RPC_PROTOCOL );
078 if ( rpcFormat == null || rpcProtocol == null ) {
079 throw new CatalogClientException( Messages.getMessage( "IGEO_STD_CSW_MISSING_PARAM", "Format, protocol" ) );
080 }
081 String rpcSeriesIdentifier = (String) extractRPCMember( rpcStruct, Constants.RPC_DATASERIES );
082 if ( rpcSeriesIdentifier == null ) {
083 throw new CatalogClientException( Messages.getMessage( "IGEO_STD_CSW_MISSING_PARAM",
084 "series file identifier" ) );
085 }
086
087 // go through each catalog of the rpc and validate
088 List rpcCatalogs = extractRPCCatalogs( rpcEvent );
089 String rpc_catalog = null;
090 for ( int i = 0; i < rpcCatalogs.size(); i++ ) {
091 rpc_catalog = (String) rpcCatalogs.get( i );
092
093 // validity check for catalog
094 String[] catalogs = config.getCatalogNames();
095 boolean containsCatalog = false;
096 for ( int j = 0; j < catalogs.length; j++ ) {
097 if ( catalogs[j].equals( rpc_catalog ) ) {
098 containsCatalog = true;
099 }
100 }
101 if ( !containsCatalog ) {
102 throw new CatalogClientException( Messages.getMessage( "IGEO_STD_CSW_WRONG_CAT", rpc_catalog ) );
103 }
104
105 // validity check for format
106 // is requested catalog capable to serve requested metadata format?
107 List formats = config.getCatalogFormats( rpc_catalog );
108 if ( formats == null || !formats.contains( rpcFormat ) ) {
109 throw new CatalogClientException( Messages.getMessage( "IGEO_STD_CSW_WRONG_FORMAT", rpc_catalog,
110 rpcFormat ) );
111 }
112
113 // validity check for protocol
114 // is requested catalog reachable through requested protocol?
115 List protocols = config.getCatalogProtocols( rpc_catalog );
116 if ( !protocols.contains( rpcProtocol ) ) {
117 throw new CatalogClientException( Messages.getMessage( "IGEO_STD_CSW_WRONG_PROTOCOL", rpc_catalog,
118 rpcProtocol ) );
119 }
120 }
121 }
122
123 }