Java tutorial
/******************************************************************************* * Copyright (c) 2009 David Harrison. * All rights reserved. This program and the accompanying materials * are made available under the terms of the GNU Public License v3.0 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/gpl-3.0.html * * Contributors: * David Harrison - initial API and implementation ******************************************************************************/ package com.sfs.whichdoctor.search.http; import com.sfs.DataFilter; import com.sfs.beans.UserBean; import com.sfs.whichdoctor.beans.RotationBean; import com.sfs.whichdoctor.beans.SearchBean; import com.sfs.whichdoctor.search.sql.RotationSqlHandler; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import org.apache.commons.lang.StringUtils; /** * The Class RotationBasicInputHandler. * * @author David Harrison */ public class RotationBasicInputHandler extends InputHandlerBase { /** The rotation sql handler. */ @Resource private RotationSqlHandler rotationSqlHandler; /** * Process the incoming HttpRequest for search parameters. * * @param request the request * @param user the user * * @return the search bean */ public final SearchBean process(final HttpServletRequest request, final UserBean user) { SearchBean search = rotationSqlHandler.initiate(user); String strBasicSearch = DataFilter.getHtml(request.getParameter("Search")); RotationBean searchCriteria = (RotationBean) search.getSearchCriteria(); if (StringUtils.isNotBlank(strBasicSearch)) { // Replace ` with ' (` is given by dynamic searches in place of // ' due to Javascript issues searchCriteria.setBasicSearch(StringUtils.replace(strBasicSearch.trim(), "`", "'")); } search.setSearchCriteria(searchCriteria); return search; } /** * Process the incoming HttpRequest for search parameters. * * @param user the user * * @return the search bean */ public final SearchBean process(final UserBean user) { SearchBean search = rotationSqlHandler.initiate(user); RotationBean searchCriteria = (RotationBean) search.getSearchCriteria(); search.setSearchCriteria(searchCriteria); return search; } }