Project

General

Profile

« Previous | Next » 

Revision 3011

Added by Duane Costa over 18 years ago

Add qformat parameter in call to executeAdvancedSearch() method.

Refactor code to get the relative paths of the resultset XSL and search results JSP from the MetacatHelper class rather than hard-coded.

View differences:

src/edu/ucsb/nceas/metacat/advancedsearch/AdvancedSearchServlet.java
51 51
   */
52 52
  private static final String CONFIG_DIR = "WEB-INF";
53 53
  private static final String CONFIG_NAME = "metacat.properties";
54
  static final long serialVersionUID = 0;  // Needed for Eclipse warning.
54 55
	   
55 56
  // Instance Variables
56 57
  private String contextString = "";
......
67 68
    RequestDispatcher dispatcher;
68 69
    HttpSession httpSession = request.getSession();
69 70
    Metacat metacat = (Metacat) httpSession.getAttribute("metacat");
71
    MetacatHelper metacatHelper = new MetacatHelper();
70 72
    String metacatURL;
73
    String qformat = (String) httpSession.getAttribute("qformat");
71 74
    String result;
72
    final String resultsJSP = "style/skins/default/advancedsearchresults.jsp";
73
    final String resultsXSL = "style/common/resultset.xsl";
75
    final String resultsJSP = metacatHelper.getResultsJSP();
74 76
    ServletContext servletContext = httpSession.getServletContext();
75
    String xslPath = servletContext.getRealPath(resultsXSL);
77
    String xslPath = metacatHelper.getResultsetXSL(request);
76 78

  
77 79
    // First check whether the metacat URL was set as a context-param.
78 80
    metacatURL = servletContext.getInitParameter("metacatURL");
......
80 82
    // If no metacat URL was configured, then derive the metacat URL from the
81 83
    // server name and server port.
82 84
    if (metacatURL == null || metacatURL.equals("")) {
83
      MetacatHelper metacatHelper = new MetacatHelper();
84 85
      String serverName = request.getServerName();
85 86
      int serverPort = request.getServerPort();
86 87
      metacatURL = 
87
    	  metacatHelper.constructMetacatURL(serverName, serverPort, contextString);
88
    	 metacatHelper.constructMetacatURL(serverName, serverPort, contextString);
88 89
    }
89 90

  
90 91
    // Get the advancedSearchBean object that has been loaded up with user
......
93 94
    advancedSearchBean = 
94 95
                (AdvancedSearchBean) request.getAttribute("advancedSearchBean");
95 96
    advancedSearch = new AdvancedSearch(advancedSearchBean);
96
    result = advancedSearch.executeAdvancedSearch(metacatURL, metacat, xslPath);
97
    result = advancedSearch.executeAdvancedSearch(metacatURL, metacat, 
98
                                                  qformat, xslPath);
97 99
    
98 100
    // Store the result HTML string in the request for retrieval by
99 101
    // the metacatpathqueryresults.jsp form.
......
109 111
   * @throws ServletException
110 112
   */
111 113
  public void init(ServletConfig config) throws ServletException {
112
	ServletContext context = null;
114
    ServletContext context = null;
113 115
    String dirPath;
114 116
    Options options = null;
115 117

  
src/edu/ucsb/nceas/metacat/advancedsearch/BrowseServlet.java
52 52
   */
53 53
  private static final String CONFIG_DIR = "WEB-INF";
54 54
  private static final String CONFIG_NAME = "metacat.properties";
55
  static final long serialVersionUID = 0;  // Needed for Eclipse warning.
55 56
		   
56 57
  // Instance Variables
57 58
  private String contextString = "";
......
68 69
    RequestDispatcher dispatcher;
69 70
    HttpSession httpSession = request.getSession();
70 71
    Metacat metacat = (Metacat) httpSession.getAttribute("metacat");
72
    MetacatHelper metacatHelper = new MetacatHelper();
71 73
    String metacatURL;
74
    String qformat = (String) httpSession.getAttribute("qformat");
72 75
    String result = "";
73
    final String resultsJSP = "style/skins/default/advancedsearchresults.jsp";
76
    final String resultsJSP = metacatHelper.getResultsJSP();
74 77
    ServletContext servletContext = httpSession.getServletContext();
75
    String stylesheet = (String) httpSession.getAttribute("stylesheet");
76
    String xslPath = servletContext.getRealPath("style/common/resultset.xsl");
78
    String xslPath = metacatHelper.getResultsetXSL(request);
77 79

  
78 80
    // First check whether the metacat URL was set as a context-param.
79 81
    metacatURL = servletContext.getInitParameter("metacatURL");
......
81 83
    // If no metacat URL was configured, then derive the metacat URL from the
82 84
    // server name and server port.
83 85
    if (metacatURL == null || metacatURL.equals("")) {
84
      MetacatHelper metacatHelper = new MetacatHelper();
85 86
      String serverName = request.getServerName();
86 87
      int serverPort = request.getServerPort();
87 88
      metacatURL = 
88
    	  metacatHelper.constructMetacatURL(serverName, serverPort, contextString);
89
    	 metacatHelper.constructMetacatURL(serverName, serverPort, contextString);
89 90
    }
90 91

  
91 92
    // Tell the web server that the response is HTML
......
94 95
    // Fetch the browseValue parameter from the request and execute a search
95 96
    advancedSearch = new AdvancedSearch(null);
96 97
    browseValue = request.getParameter("browseValue");
97
    result = advancedSearch.executeSearch(metacatURL, metacat, xslPath, 
98
                                          browseValue);
98
    result = advancedSearch.executeSearch(metacatURL, metacat, qformat,
99
                                          xslPath, browseValue);
99 100

  
100 101
    // Store the result HTML string in the request for retrieval by
101 102
    // the metacatpathqueryresults.jsp form.
src/edu/ucsb/nceas/metacat/advancedsearch/SearchServlet.java
51 51
   */
52 52
  private static final String CONFIG_DIR = "WEB-INF";
53 53
  private static final String CONFIG_NAME = "metacat.properties";
54
  static final long serialVersionUID = 0;  // Needed for Eclipse warning.
54 55
			   
55 56
  // Instance Variables
56 57
  private String contextString = "";
......
66 67
    RequestDispatcher dispatcher;
67 68
    HttpSession httpSession = request.getSession();
68 69
    Metacat metacat = (Metacat) httpSession.getAttribute("metacat");
70
    MetacatHelper metacatHelper = new MetacatHelper();
69 71
    String metacatURL;
72
    String qformat = (String) httpSession.getAttribute("qformat");
70 73
    String result = "";
71
    final String resultsJSP = "style/skins/default/advancedsearchresults.jsp";
74
    final String resultsJSP = metacatHelper.getResultsJSP();
72 75
    String searchValue;
73 76
    ServletContext servletContext = httpSession.getServletContext();
74
    String stylesheet = (String) httpSession.getAttribute("stylesheet");
75
    String xslPath = servletContext.getRealPath("style/common/resultset.xsl");
77
    String xslPath = metacatHelper.getResultsetXSL(request);
76 78

  
77 79
    // First check whether the metacat URL was set as a context-param.
78 80
    metacatURL = servletContext.getInitParameter("metacatURL");
......
80 82
    // If no metacat URL was configured, then derive the metacat URL from the
81 83
    // server name and server port.
82 84
    if (metacatURL == null || metacatURL.equals("")) {
83
      MetacatHelper metacatHelper = new MetacatHelper();
84 85
      String serverName = request.getServerName();
85 86
      int serverPort = request.getServerPort();
86 87
      metacatURL = 
87
          metacatHelper.constructMetacatURL(serverName, serverPort, contextString);
88
       metacatHelper.constructMetacatURL(serverName, serverPort, contextString);
88 89
    }
89 90

  
90 91
    // Tell the web server that the response is HTML
......
94 95
    advancedSearch = new AdvancedSearch(null);
95 96
    searchValue = request.getParameter("searchValue");
96 97
    System.err.println("Search Servlet: " + searchValue);
97
    result = advancedSearch.executeSearch(metacatURL, metacat, xslPath, searchValue);
98
    result = advancedSearch.executeSearch(metacatURL, metacat, qformat, 
99
                                          xslPath, searchValue);
98 100

  
99 101
    // Store the result HTML string in the request for retrieval by
100 102
    // the metacatpathqueryresults.jsp form.

Also available in: Unified diff