com.epnet.eit.web
Class SearchRequestHelper

java.lang.Object
  extended bycom.epnet.eit.web.SearchRequestHelper

public class SearchRequestHelper
extends java.lang.Object

Helper class to service a search request


Constructor Summary
SearchRequestHelper(java.lang.String recordsPerPage)
          Creates a new instance of RequestHelper
 
Method Summary
protected  java.lang.String getFirstAN(java.lang.String xml)
          Gets the first article id (AN) from the search XML.
protected  java.lang.String getPage(javax.servlet.http.HttpServletRequest request)
          Get the proper page according to request
protected  java.lang.String getParameter(javax.servlet.http.HttpServletRequest request, java.lang.String param, boolean mandatory)
          This method throws an exception if a mandatory parameter is not found
protected  boolean isSingleRecordResult(java.lang.String xml)
          Quickly analizes the XML to determine if it is a one-hit record search.
protected  boolean isValidRequest(javax.servlet.http.HttpServletRequest request)
          Verifies that the request contains al least the main parameters: db and query
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SearchRequestHelper

public SearchRequestHelper(java.lang.String recordsPerPage)
                    throws java.lang.Exception
Creates a new instance of RequestHelper

Parameters:
recordsPerPage - Records per page for pagination
Throws:
java.lang.Exception - If records per page provided is not a valid number
Method Detail

getParameter

protected java.lang.String getParameter(javax.servlet.http.HttpServletRequest request,
                                        java.lang.String param,
                                        boolean mandatory)
                                 throws javax.servlet.ServletException
This method throws an exception if a mandatory parameter is not found

Parameters:
request - The HttpServletRequest received
param - parameter to retrieve from request.
mandatory - if parameter to retrive if mandatory. This indicates the object to throw an Exception if true not found.
Returns:
parameter or null if not found and not mandatory
Throws:
javax.servlet.ServletException - If parameter not found and mandatory

getPage

protected java.lang.String getPage(javax.servlet.http.HttpServletRequest request)
Get the proper page according to request

Parameters:
request - request
Returns:
page or null if not found or incorrect page provided

isValidRequest

protected boolean isValidRequest(javax.servlet.http.HttpServletRequest request)
Verifies that the request contains al least the main parameters: db and query

Parameters:
request - The HttpServletRequest received
Returns:
true - if at least mandatory parameters are included in the request. false - otherwise

isSingleRecordResult

protected boolean isSingleRecordResult(java.lang.String xml)
Quickly analizes the XML to determine if it is a one-hit record search.

Parameters:
xml - search xml
Returns:
true if only one hit, false otherwise

getFirstAN

protected java.lang.String getFirstAN(java.lang.String xml)
Gets the first article id (AN) from the search XML. If isSingleRecordResult is true, this one may be used to get that single AN.

Parameters:
xml - search xml
Returns:
AN