deegree 2.5 (2011/06/29 09:44 build-8-official)

org.deegree.portal.standard.csw.control
Class SimpleSearchListener

java.lang.Object
  extended by org.deegree.enterprise.control.AbstractListener
      extended by org.deegree.portal.standard.csw.control.SimpleSearchListener
All Implemented Interfaces:
java.util.EventListener, WebListener
Direct Known Subclasses:
AddToShoppingCartListener, DetailedSearchListener, OverviewMetadataListener, SeriesChildrenSearchListener, TurnPageListener

public class SimpleSearchListener
extends AbstractListener

A ${type_name} class.
This listener does more than just search for data. It searches for data *and* then searches if there are services (WMS, WFS) available, which provide this data.

Version:
$Revision: 27569 $, $Date: 2010-10-28 08:57:50 +0200 (Do, 28 Okt 2010) $
Author:
Judit Mays, last edited by: $Author: apoth $

Field Summary
protected  CSWClientConfiguration config
           
static java.lang.String HTML_FRAGMENT
          used in jsp pages
protected  NamespaceContext nsContext
           
(package private) static java.lang.String RESULT_SEARCH
           
(package private) static java.lang.String RPC_CATALOG
           
(package private) static java.lang.String RPC_FORMAT
           
(package private) static java.lang.String SESSION_AVAILABLESERVICECATALOGS
           
(package private) static java.lang.String SESSION_DATARECORDS
           
(package private) static java.lang.String SESSION_REQUESTFORRESULTS
           
(package private) static java.lang.String SESSION_RESULTFORHITS
           
 
Constructor Summary
SimpleSearchListener()
           
 
Method Summary
 void actionPerformed(FormEvent event)
           
protected  java.util.List<DataSessionRecord> createDataSessionRecords(java.util.HashMap results)
          Created a list of DataSessionRecord from all the returned results
protected  java.lang.String createRequest(RPCStruct rpcStruct, java.lang.String format, java.lang.String resultType)
          This method creates a csw request with the RequestFactory of the passed format, using the paramter values passed in the rpcStruct.
protected  RPCStruct createRpcStructForServiceSearch(java.lang.String template, java.lang.String identifier)
          Creates an RPC request from the given template
protected  java.util.Map doServiceSearch(java.util.HashMap result, java.lang.String format, java.lang.String resultType)
          Invokes a GetRecords request with type RESULT to get the actual records for all the metadata returned during the GetRecords request with type HIT
protected  java.util.List extractMetadata(org.w3c.dom.Document doc)
          Extracts all Metadata nodes from the passed csw:GetRecordsResponse Document.
protected  java.util.List extractRPCCatalogs(RPCWebEvent rpcEvent)
          Extracts the catalog names from the first parameter of the params element within the passed rpcEvent.
protected  java.lang.Object extractRPCMember(RPCStruct struct, java.lang.String member)
          Extracts the member of the passed name from the passed struct.
protected  RPCParameter[] extractRPCParameters(RPCWebEvent rpcEvent)
          Extracts the parameters from the method call element within the passed rpcEvent.
protected  RPCStruct extractRPCStruct(RPCWebEvent rpcEvent, int index)
          Extracts the RPCStruct from the indicated parameter in the params element of the passed RPCWebEvent.
protected  java.lang.String extractValue(org.w3c.dom.Node node, java.lang.String xPath)
          Extracts node value
protected  java.lang.String getMetadataType(org.w3c.dom.Element docElem)
          Checks if the metadata is of series, dataset, application or service type
protected  java.lang.String getXPathToId(org.w3c.dom.Element docElem)
           
protected  java.lang.String getXPathToTitle(org.w3c.dom.Element docElement)
           
protected  void handleResult(java.lang.Object resultHits, java.lang.Object resultResults, java.lang.String pathToXslFile)
          Handles the result of the search requests and transforms the result to HTML using xslt, then saves the transformed result into the session
protected  boolean isKnownMetadataType(org.w3c.dom.Element docElem)
          Checks whether the metadata document is of a known type.
protected  java.util.HashMap performRequest(java.lang.String protocol, java.lang.String request, java.util.List catalogs)
          Performs the CSW request and returns the result as a HashMap
protected  void validateRequest(RPCWebEvent rpcEvent)
          Validates the rpc request and makes sure that all the needed parameters are included
 
Methods inherited from class org.deegree.enterprise.control.AbstractListener
getAlternativeNextPage, getHomePath, getInitParameter, getInitParameterList, getNextPage, getRequest, getReturnValue, gotoErrorPage, handle, setAlternativeNextPage, setDefaultAlternativeNextPage, setDefaultNextPage, setNextPage, setReturnValue, toModel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HTML_FRAGMENT

public static final java.lang.String HTML_FRAGMENT
used in jsp pages

See Also:
Constant Field Values

RESULT_SEARCH

static final java.lang.String RESULT_SEARCH
See Also:
Constant Field Values

RPC_CATALOG

static final java.lang.String RPC_CATALOG
See Also:
Constant Field Values

RPC_FORMAT

static final java.lang.String RPC_FORMAT
See Also:
Constant Field Values

SESSION_AVAILABLESERVICECATALOGS

static final java.lang.String SESSION_AVAILABLESERVICECATALOGS
See Also:
Constant Field Values

SESSION_DATARECORDS

static final java.lang.String SESSION_DATARECORDS
See Also:
Constant Field Values

SESSION_REQUESTFORRESULTS

static final java.lang.String SESSION_REQUESTFORRESULTS
See Also:
Constant Field Values

SESSION_RESULTFORHITS

static final java.lang.String SESSION_RESULTFORHITS
See Also:
Constant Field Values

config

protected CSWClientConfiguration config

nsContext

protected NamespaceContext nsContext
Constructor Detail

SimpleSearchListener

public SimpleSearchListener()
Method Detail

actionPerformed

public void actionPerformed(FormEvent event)
Specified by:
actionPerformed in interface WebListener
Specified by:
actionPerformed in class AbstractListener

validateRequest

protected void validateRequest(RPCWebEvent rpcEvent)
                        throws CatalogClientException
Validates the rpc request and makes sure that all the needed parameters are included

Parameters:
rpcEvent -
Throws:
CatalogClientException

createRequest

protected java.lang.String createRequest(RPCStruct rpcStruct,
                                         java.lang.String format,
                                         java.lang.String resultType)
                                  throws CatalogClientException
This method creates a csw request with the RequestFactory of the passed format, using the paramter values passed in the rpcStruct. (csw:GetRecords request, if the passed resultType is HITS or RESULTS, and csw:GetRecordsById request, if the passed resultType is null).

Parameters:
rpcStruct - The struct contains parameter values to be used in the RequestFactory.
format - The format determines the RequestFactory to be used.
resultType - The type of desired result. Possible values are HITS or RESULTS or null.
Returns:
Returns the xml encoded request as String.
Throws:
CatalogClientException

performRequest

protected java.util.HashMap performRequest(java.lang.String protocol,
                                           java.lang.String request,
                                           java.util.List catalogs)
                                    throws CatalogClientException
Performs the CSW request and returns the result as a HashMap

Parameters:
protocol -
request -
catalogs -
Returns:
Returns a HashMap, which contains one key-value-pair for each catalogue, that has been searched. The key is the name of the catalogue. The value is the doc Document, that contains the number of matches (resultType="HITS"), or 1 to n metadata entries (resultType="RESULTS")
Throws:
CatalogClientException

handleResult

protected void handleResult(java.lang.Object resultHits,
                            java.lang.Object resultResults,
                            java.lang.String pathToXslFile)
                     throws XMLParsingException,
                            CatalogClientException
Handles the result of the search requests and transforms the result to HTML using xslt, then saves the transformed result into the session

Parameters:
resultHits -
resultResults -
pathToXslFile - e.g. file://$iGeoPortal_home$/WEB-INF/conf/igeoportal/metaList2html.xsl
Throws:
XMLParsingException - if the documents contained in resultHits don't have the expected structure.
CatalogClientException

createDataSessionRecords

protected java.util.List<DataSessionRecord> createDataSessionRecords(java.util.HashMap results)
                                                              throws CatalogClientException
Created a list of DataSessionRecord from all the returned results

Parameters:
results -
Returns:
Returns a List of distinct DataSessionRecords for all metadata elements within the passed results.
Throws:
CatalogClientException - if the identifier or the title of a metadata element could not be extracted.

extractMetadata

protected java.util.List extractMetadata(org.w3c.dom.Document doc)
                                  throws CatalogClientException,
                                         XMLParsingException
Extracts all Metadata nodes from the passed csw:GetRecordsResponse Document.

Parameters:
doc - The csw:GetRecordsResponse Document from which to extract the Metadata nodes.
Returns:
Returns a NodeList of Metadata Elements for the passed Document.
Throws:
CatalogClientException - if metadata nodes could not be extracted from the passed Document.
XMLParsingException

extractValue

protected java.lang.String extractValue(org.w3c.dom.Node node,
                                        java.lang.String xPath)
                                 throws CatalogClientException,
                                        XMLParsingException
Extracts node value

Parameters:
node -
xPath -
Returns:
Returns the value for the passed node and xPath.
Throws:
CatalogClientException
XMLParsingException

doServiceSearch

protected java.util.Map doServiceSearch(java.util.HashMap result,
                                        java.lang.String format,
                                        java.lang.String resultType)
                                 throws CatalogClientException
Invokes a GetRecords request with type RESULT to get the actual records for all the metadata returned during the GetRecords request with type HIT

Parameters:
result - HashMap containing data catalog names (as keys) and GetRecordResponse Documents (as values).
format - some service format like "ISO19119"
resultType - either "HITS" or "RESULTS".
Returns:
Returns a Map that contains the title extracted from the passed document (as key) and a List of all corresponding available service catalogs (as value).
Throws:
CatalogClientException

createRpcStructForServiceSearch

protected RPCStruct createRpcStructForServiceSearch(java.lang.String template,
                                                    java.lang.String identifier)
                                             throws CatalogClientException,
                                                    RPCException
Creates an RPC request from the given template

Parameters:
template -
identifier -
Returns:
Returns the new rpcStruct.
Throws:
CatalogClientException
RPCException

extractRPCParameters

protected RPCParameter[] extractRPCParameters(RPCWebEvent rpcEvent)
                                       throws CatalogClientException
Extracts the parameters from the method call element within the passed rpcEvent.

Parameters:
rpcEvent -
Returns:
Returns the parameters as array of RPCParameter.
Throws:
CatalogClientException

extractRPCCatalogs

protected java.util.List extractRPCCatalogs(RPCWebEvent rpcEvent)
                                     throws CatalogClientException
Extracts the catalog names from the first parameter of the params element within the passed rpcEvent.

Parameters:
rpcEvent -
Returns:
Returns the catalogue names as array of String.
Throws:
CatalogClientException

extractRPCStruct

protected RPCStruct extractRPCStruct(RPCWebEvent rpcEvent,
                                     int index)
                              throws CatalogClientException
Extracts the RPCStruct from the indicated parameter in the params element of the passed RPCWebEvent.

Parameters:
rpcEvent - The RPCWebEvent, that contains the RPCStruct to extract.
index - The index of the parameter from which to extract the RPCStruct (starting with 0).
Returns:
Returns the RPCStruct from the indicated params element.
Throws:
CatalogClientException

extractRPCMember

protected java.lang.Object extractRPCMember(RPCStruct struct,
                                            java.lang.String member)
                                     throws CatalogClientException
Extracts the member of the passed name from the passed struct.

Parameters:
struct - The rpcStruct to extract the passed member from.
member - The Member to extract from the passed rpcStruct.
Returns:
Returns the member value object.
Throws:
CatalogClientException

getMetadataType

protected java.lang.String getMetadataType(org.w3c.dom.Element docElem)
Checks if the metadata is of series, dataset, application or service type

Parameters:
docElem -
Returns:
"service": if the metadata is a service "dataset": if the metadata is a dataset "series" : if the metadata is a datasetCollection (series)

isKnownMetadataType

protected boolean isKnownMetadataType(org.w3c.dom.Element docElem)
Checks whether the metadata document is of a known type. The known types are "series", "dataset", "service" and "application"

Parameters:
docElem -
Returns:
true if it is a known metadata type, false otherwise

getXPathToId

protected java.lang.String getXPathToId(org.w3c.dom.Element docElem)
Parameters:
docElem -
Returns:
xPath to the record identifier

getXPathToTitle

protected java.lang.String getXPathToTitle(org.w3c.dom.Element docElement)
Parameters:
docElement -
Returns:
xPath to record title

deegree 2.5 (2011/06/29 09:44 build-8-official)

an open source project founded by lat/lon, Bonn, Germany.
For more information visit: http://www.deegree.org