Javadoc
[mkjsf-moved-to-github.git] / src / main / java / com / indexdata / mkjsf / pazpar2 / Pz2Service.java
1 package com.indexdata.mkjsf.pazpar2;\r
2 \r
3 import java.io.Serializable;\r
4 import java.lang.annotation.Retention;\r
5 import java.lang.annotation.Target;\r
6 import java.util.ArrayList;\r
7 import java.util.Arrays;\r
8 import java.util.HashMap;\r
9 import java.util.List;\r
10 import java.util.Map;\r
11 import java.util.StringTokenizer;\r
12 \r
13 import javax.annotation.PostConstruct;\r
14 import javax.enterprise.context.SessionScoped;\r
15 import javax.enterprise.inject.Produces;\r
16 import javax.faces.context.FacesContext;\r
17 import javax.inject.Inject;\r
18 import javax.inject.Named;\r
19 import javax.inject.Qualifier;\r
20 \r
21 import org.apache.log4j.Logger;\r
22 \r
23 import com.indexdata.mkjsf.config.Configurable;\r
24 import com.indexdata.mkjsf.config.Configuration;\r
25 import com.indexdata.mkjsf.config.ConfigurationReader;\r
26 import com.indexdata.mkjsf.controls.ResultsPager;\r
27 import com.indexdata.mkjsf.errors.ConfigurationError;\r
28 import com.indexdata.mkjsf.errors.ConfigurationException;\r
29 import com.indexdata.mkjsf.errors.ErrorCentral;\r
30 import com.indexdata.mkjsf.errors.ErrorHelper;\r
31 import com.indexdata.mkjsf.errors.MissingConfigurationContextException;\r
32 import com.indexdata.mkjsf.pazpar2.commands.Pazpar2Commands;\r
33 import com.indexdata.mkjsf.pazpar2.data.RecordResponse;\r
34 import com.indexdata.mkjsf.pazpar2.data.Responses;\r
35 import com.indexdata.mkjsf.pazpar2.state.StateListener;\r
36 import com.indexdata.mkjsf.pazpar2.state.StateManager;\r
37 import com.indexdata.mkjsf.utils.Utils;\r
38 \r
39 /**  \r
40  * Pz2Service is the main controller of the search logic, used for selecting the service \r
41  * type (which can be done by configuration and/or run-time), selecting which search client \r
42  * to use, and performing high-level control of request cycles and state management. \r
43  * <p>\r
44  * Command and response beans are also obtained through Pz2Service - although it is \r
45  * transparent to the UI that they are retrieved through this object.\r
46  * </p>\r
47  * <p>\r
48  * Pz2Service is exposed to the UI as <code>pz2</code>. However, if the service is pre-configured, \r
49  * the Faces pages might never need to reference <code>pz2</code> explicitly. Indirectly they will, \r
50  * though, if the polling mechanism in the tag <code>&lt;pz2utils:pz2watch&gt;</code> is used.\r
51  * \r
52  * \r
53  **/ \r
54 @Named("pz2") @SessionScoped\r
55 public class Pz2Service implements StateListener, Configurable, Serializable {\r
56 \r
57   private static final String MODULE_NAME = "service";\r
58   private static String SERVICE_TYPE_TBD = "TBD", SERVICE_TYPE_PZ2 = "PZ2", SERVICE_TYPE_SP = "SP";\r
59   private static final List<String> serviceTypes = \r
60                 Arrays.asList(SERVICE_TYPE_PZ2,SERVICE_TYPE_SP,SERVICE_TYPE_TBD);\r
61   private String serviceType = SERVICE_TYPE_TBD;\r
62   private List<String> serviceProxyUrls = new ArrayList<String>();\r
63   public static final String SERVICE_PROXY_URL_LIST = "SERVICE_PROXY_URL_LIST";\r
64   private List<String> pazpar2Urls = new ArrayList<String>();\r
65   public static final String PAZPAR2_URL_LIST = "PAZPAR2_URL_LIST";\r
66 \r
67   private static final long serialVersionUID = 3440277287081557861L;\r
68   private static Logger logger = Logger.getLogger(Pz2Service.class);  \r
69   protected Pz2Client pz2Client = null;\r
70   protected ServiceProxyClient spClient = null;\r
71   protected SearchClient searchClient = null;  \r
72     \r
73   @Inject ConfigurationReader configurator;\r
74   \r
75   private StateManager stateMgr = null;\r
76   private Pazpar2Commands pzreq = null;\r
77   private Responses pzresp = null;\r
78   private ErrorCentral errors = null;  \r
79   \r
80   protected ResultsPager pager = null; \r
81   \r
82   protected ErrorHelper errorHelper = null;\r
83               \r
84   public Pz2Service () {\r
85     logger.info("Instantiating pz2 bean [" + Utils.objectId(this) + "]");    \r
86   }\r
87   \r
88   public static Pz2Service get() {\r
89     FacesContext context = FacesContext.getCurrentInstance();\r
90     return (Pz2Service) context.getApplication().evaluateExpressionGet(context, "#{pz2}", Object.class); \r
91   }\r
92     \r
93   @PostConstruct\r
94   public void postConstruct() throws MissingConfigurationContextException {    \r
95     logger.info("Pz2Service PostConstruct of " + this);\r
96     stateMgr = new StateManager();\r
97     pzreq = new Pazpar2Commands();\r
98     pzresp = new Responses();    \r
99     errors = new ErrorCentral(); \r
100     pzresp.setErrorHelper(errors.getHelper());\r
101     \r
102     logger.debug("Pz2Service PostConstruct: Configurator is " + configurator);\r
103     logger.debug(Utils.objectId(this) + " will instantiate a Pz2Client next.");    \r
104     pz2Client = new Pz2Client();\r
105     spClient = new ServiceProxyClient();\r
106     stateMgr.addStateListener(this);\r
107     try {\r
108       configureClient(pz2Client,configurator);      \r
109       configureClient(spClient,configurator);\r
110       this.configure(configurator);\r
111     } catch (MissingConfigurationContextException mcc) {\r
112       logger.info("No configuration context available at this point");\r
113       logger.debug("Configuration invoked from a Servlet filter before application start?");\r
114       throw mcc;\r
115     } catch (ConfigurationException e) {\r
116       logger.warn("There was a problem configuring the Pz2Service and/or clients (\"pz2\")");\r
117       e.printStackTrace();\r
118     }     \r
119   }\r
120   \r
121   @Qualifier\r
122   @Target({java.lang.annotation.ElementType.TYPE,\r
123            java.lang.annotation.ElementType.METHOD,\r
124            java.lang.annotation.ElementType.PARAMETER,\r
125            java.lang.annotation.ElementType.FIELD})\r
126   @Retention(java.lang.annotation.RetentionPolicy.RUNTIME)\r
127   public  @interface Preferred{}\r
128   \r
129   @Produces @Preferred @SessionScoped @Named("pzresp") public Responses getPzresp () {\r
130     logger.trace("Producing pzresp");\r
131     return pzresp;\r
132   }\r
133   \r
134   @Produces @Preferred @SessionScoped @Named("pzreq") public Pazpar2Commands getPzreq () {\r
135     logger.trace("Producing pzreq");\r
136     return pzreq;\r
137   }\r
138   \r
139   @Produces @Preferred @SessionScoped @Named("errors") public ErrorCentral getErrors() {\r
140     logger.trace("Producing errors");\r
141     return errors;\r
142   }\r
143   \r
144   @Produces @Preferred @SessionScoped @Named("stateMgr") public StateManager getStateMgr() {\r
145     logger.trace("Producing stateMgr");\r
146     return stateMgr;\r
147   }\r
148   \r
149   /**\r
150    * Configures the selected search client using the selected configuration reader.\r
151    * \r
152    * The configuration reader is select deploy-time - by configuration in the application's beans.xml.\r
153    * \r
154    * @param client search client to use\r
155    * @param configReader the selected configuration mechanism\r
156    * @throws MissingConfigurationContextException if this object is injected before there is a Faces context\r
157    * for example in a Servlet filter.\r
158    */\r
159   public void configureClient(SearchClient client, ConfigurationReader configReader)  throws MissingConfigurationContextException {\r
160     logger.debug(Utils.objectId(this) + " will configure search client for the session");\r
161     try {\r
162       client.configure(configReader);\r
163     } catch (MissingConfigurationContextException mcce) {\r
164       logger.info("No Faces context is available to the configurator at this time of invocation");\r
165       throw mcce;\r
166     } catch (ConfigurationException e) {\r
167       logger.debug("Pz2Service adding configuration error");\r
168       errors.addConfigurationError(new ConfigurationError("Search Client","Configuration",e.getMessage()));                \r
169     }\r
170     logger.info(configReader.document());\r
171     pzresp.getSp().resetAuthAndBeyond(true);    \r
172   }\r
173   \r
174   public void resetSearchAndRecordCommands () {\r
175     pzreq.getRecord().removeParametersInState();\r
176     pzreq.getSearch().removeParametersInState();   \r
177   }\r
178      \r
179   \r
180   /**\r
181    * Updates display data objects by simultaneously issuing the following Pazpar2 commands: \r
182    * 'show', 'stat', 'termlist' and 'bytarget'. \r
183    * <p>\r
184    * If there are outstanding changes to the search command, a search\r
185    * will be issued before the updates are performed. Outstanding changes could come \r
186    * from the UI changing a search parameter and not executing search before starting \r
187    * the update cycle - OR - it could come from the user clicking the browsers back/forward\r
188    * buttons. \r
189    * </p>\r
190    * <p>\r
191    * This method is invoked from the composite 'pz2watch', which uses Ajax\r
192    * to keep invoking this method until it returns '0' (for zero active clients).\r
193    * </p>\r
194    * <p>\r
195    * UI components that display data from show, stat, termlist or bytarget, \r
196    * should be re-rendered after each update. \r
197    * </p>\r
198    * Example of invocation in UI:\r
199    * <pre>\r
200    *    &lt;pz2utils:pz2watch id="pz2watch"\r
201    *       renderWhileActiveclients="myshowui mystatui mytermsui" /&lt; \r
202    *       \r
203    *    &lt;h:form&gt;\r
204    *     &lt;h:inputText id="query" value="#{pzreq.search.query}" size="50"/&gt;                            \r
205    *      &lt;h:commandButton id="button" value="Search"&gt;              \r
206    *       &lt;f:ajax execute="query" render="${pz2.watchActiveclients}"/&gt;\r
207    *      &lt;/h:commandButton&gt;\r
208    *     &lt;/h:form&gt;\r
209    * </pre>\r
210    * The expression pz2.watchActiveClients will invoke the method repeatedly, and the\r
211    * UI sections myshowui, mystatui, and mytermsui will be rendered on each poll. \r
212    * \r
213    * @return a count of the remaining active clients from the most recent search. \r
214    */  \r
215   public String update () {\r
216     logger.debug("Updating show,stat,termlist,bytarget from pazpar2");\r
217     if (errors.hasConfigurationErrors()) {\r
218       logger.error("Ignoring show,stat,termlist,bytarget commands due to configuration errors.");\r
219       return "";\r
220     } else if (pzresp.getSearch().hasApplicationError()) {\r
221       logger.error("Ignoring show,stat,termlist,bytarget commands due to problem with most recent search.");\r
222       return "";\r
223     } else if (!hasQuery()) {\r
224       logger.debug("Ignoring show,stat,termlist,bytarget commands because there is not yet a query.");\r
225       return "";\r
226     } else {\r
227       return update("show,stat,termlist,bytarget");\r
228     }\r
229   }\r
230      \r
231   /**\r
232    * Simultaneously refreshes the data objects listed in 'commands' from pazpar2, potentially running a\r
233    * search or a record command first if any of these two commands have outstanding parameter changes.\r
234    * \r
235    * @param commands, a comma-separated list of Pazpar2 commands to execute\r
236    * \r
237    * @return Number of activeclients at the time of the 'show' command,\r
238    *         or 'new' if search was just initiated.\r
239    */\r
240   public String update (String commands) {\r
241     logger.debug("Request to update: " + commands);\r
242     try {\r
243       if (commands.equals("search")) {\r
244         pzreq.getSearch().run();\r
245         pzresp.getSearch().setIsNew(false);\r
246         return "new";\r
247       } else if (commands.equals("record")) {\r
248         pzreq.getRecord().run();\r
249         return pzresp.getRecord().getActiveClients();\r
250       } else if (pzresp.getSearch().isNew()) {\r
251         // For returning notification of 'search started' quickly to UI\r
252         logger.info("New search. Marking it old, then returning 'new' to trigger another round-trip.");\r
253         pzresp.getSearch().setIsNew(false);\r
254         return "new";\r
255       } else {\r
256         handleQueryStateChanges(commands);\r
257         if (pzresp.getSearch().hasApplicationError()) {\r
258           logger.error("The command(s) " + commands + " cancelled because the latest search command had an error.");\r
259           return "0";\r
260         } else if (errors.hasConfigurationErrors()) {\r
261           logger.error("The command(s) " + commands + " cancelled due to configuration errors.");\r
262           return "0";\r
263         } else {\r
264           logger.debug("Processing request for " + commands); \r
265           List<CommandThread> threadList = new ArrayList<CommandThread>();\r
266           StringTokenizer tokens = new StringTokenizer(commands,",");\r
267           while (tokens.hasMoreElements()) {          \r
268             threadList.add(new CommandThread(pzreq.getCommand(tokens.nextToken()),searchClient,Pz2Service.get().getPzresp()));            \r
269           }\r
270           for (CommandThread thread : threadList) {\r
271             thread.start();\r
272           }\r
273           for (CommandThread thread : threadList) {\r
274             try {\r
275               thread.join();\r
276             } catch (InterruptedException e) {\r
277               e.printStackTrace();\r
278             }\r
279           }\r
280           return pzresp.getActiveClients();\r
281         }\r
282       }  \r
283     } catch (ClassCastException cce) {\r
284       cce.printStackTrace();    \r
285       return "";\r
286     } catch (NullPointerException npe) {\r
287       npe.printStackTrace();\r
288       return "";\r
289     } catch (Exception e) {\r
290       e.printStackTrace();\r
291       return "";\r
292     }\r
293     \r
294   }\r
295   \r
296   /**\r
297    * This methods main purpose is to support browser history.\r
298    *  \r
299    * When the browsers back or forward buttons are pressed, a  \r
300    * re-search /might/ be required - namely if the query changes.\r
301    * So, as the UI requests updates of the page (show,facets,\r
302    * etc) this method checks if a search must be executed\r
303    * before those updates are performed.\r
304    *  \r
305    * It will consequently also run a search if the UI updates a\r
306    * search parameter without actually explicitly executing the search \r
307    * before setting of the polling.\r
308    *  \r
309    * @see {@link com.indexdata.mkjsf.pazpar2.state.StateManager#setCurrentStateKey} \r
310    * @param commands\r
311    */\r
312   protected void handleQueryStateChanges (String commands) {\r
313     if (stateMgr.hasPendingStateChange("search") && hasQuery()) { \r
314       logger.info("Triggered search: Found pending search change [" + pzreq.getCommand("search").toString() + "], doing search before updating " + commands);      \r
315       pzreq.getSearch().run();\r
316       pzresp.getSearch().setIsNew(false);\r
317     } \r
318     if (stateMgr.hasPendingStateChange("record") && ! commands.equals("record")) {        \r
319       logger.debug("Found pending record ID change. Doing record before updating " + commands);\r
320       stateMgr.hasPendingStateChange("record",false);\r
321       pzreq.getRecord().run();\r
322     }\r
323   }\r
324       \r
325   @Override\r
326   public void stateUpdated(String commandName) {\r
327     logger.debug("State change reported for [" + commandName + "]");\r
328     if (commandName.equals("show")) {\r
329       logger.debug("Updating show");\r
330       update(commandName);\r
331     } \r
332   }\r
333 \r
334       \r
335   /**\r
336    * Will retrieve -- or alternatively remove -- the record with the given \r
337    * recid from memory.\r
338    * \r
339    * A pazpar2 'record' command will then be issued. The part of the UI \r
340    * showing record data should thus be re-rendered.\r
341    *  \r
342    * @param recid\r
343    * @return\r
344    */\r
345   public String toggleRecord (String recId) {\r
346     if (hasRecord(recId)) {\r
347       pzreq.getRecord().removeParameters();  \r
348       pzresp.put("record", new RecordResponse());\r
349       return "";\r
350     } else {\r
351       pzreq.getRecord().setId(recId);\r
352       pzreq.getRecord().run();\r
353       return pzresp.getRecord().getActiveClients();\r
354     }\r
355   }\r
356   \r
357   /**\r
358    * Resolves whether the back-end has a record with the given recid in memory \r
359    * \r
360    * @return true if the bean currently holds the record with recid\r
361    */  \r
362   public boolean hasRecord (String recId) {\r
363     return pzreq.getCommand("record").hasParameters() && pzresp.getRecord().getRecId().equals(recId);\r
364   }\r
365         \r
366   /**\r
367    * Returns the current hash key, used for internal session state tracking\r
368    * and potentially for browser history entries\r
369    * \r
370    * A UI author would not normally be concerned with retrieving this. It's used by the\r
371    * framework internally\r
372    *  \r
373    * @return string that can be used for browsers window.location.hash\r
374    */\r
375   public String getCurrentStateKey () {    \r
376     return stateMgr.getCurrentState().getKey();\r
377   }\r
378       \r
379   /**\r
380    * Sets the current state key, i.e. when user clicks back or forward in browser history.\r
381    * Would normally be automatically handled by the frameworks components.\r
382    *  \r
383    * @param key corresponding to browsers hash string\r
384    */\r
385   public void setCurrentStateKey(String key) {       \r
386     stateMgr.setCurrentStateKey(key);\r
387   }\r
388       \r
389   protected boolean hasQuery() {        \r
390     return pzreq.getCommand("search").hasParameterValue("query"); \r
391   }\r
392     \r
393   /**\r
394    * Returns a component for drawing a pager to navigate by.\r
395    * @return ResultsPager pager component\r
396    */\r
397   public ResultsPager getPager () {\r
398     if (pager == null) {\r
399       pager = new ResultsPager(pzresp);      \r
400     } \r
401     return pager;      \r
402   }\r
403   \r
404  /**\r
405   * Initiates a pager object, a component holding the data to draw a sequence\r
406   * of page numbers to navigate by and mechanisms to navigate with\r
407   * \r
408   * @param pageRange number of pages to display in the pager\r
409   * @return ResultsPager the initiated pager component\r
410   */\r
411   public ResultsPager setPager (int pageRange) {\r
412     pager =  new ResultsPager(pzresp,pageRange,pzreq);\r
413     return pager;\r
414   }\r
415      \r
416   public void setServiceProxyUrl(String url) {\r
417     searchClient = spClient;\r
418     setServiceType(SERVICE_TYPE_SP);\r
419     setServiceUrl(url);\r
420   }\r
421   \r
422   public String getServiceProxyUrl () {\r
423     if (isServiceProxyService()) {\r
424       return spClient.getServiceUrl();\r
425     } else {\r
426       return "";\r
427     }\r
428   }\r
429   \r
430   public void setPazpar2Url(String url) {\r
431     searchClient = pz2Client;\r
432     setServiceType(SERVICE_TYPE_PZ2);\r
433     setServiceUrl(url);\r
434   }\r
435   \r
436   public String getPazpar2Url() {\r
437     if (isPazpar2Service()) {\r
438       return pz2Client.getServiceUrl();\r
439     } else {\r
440       return "";\r
441     }\r
442   }\r
443 \r
444   public void setServiceUrl(String url) {\r
445     if (url!=null && searchClient != null && !url.equals(searchClient.getServiceUrl())) {\r
446       pzreq.getRecord().removeParametersInState();\r
447       pzreq.getSearch().removeParametersInState();\r
448       pzresp.getSp().resetAuthAndBeyond(true);      \r
449       searchClient.setServiceUrl(url);\r
450     }    \r
451   }\r
452   \r
453   public String getServiceUrl() {\r
454     return (searchClient!=null ? searchClient.getServiceUrl() : "");\r
455   }\r
456   \r
457   public void setServiceId () {\r
458     pzreq.getRecord().removeParametersInState();\r
459     pzreq.getSearch().removeParametersInState();\r
460     pzresp.resetSearchAndBeyond();\r
461     pz2Client.setServiceId(pzreq.getInit().getService());\r
462   }\r
463   \r
464   public String getServiceId () {\r
465     return pzreq.getInit().getService();\r
466   }\r
467   \r
468   public boolean getServiceUrlIsDefined() {\r
469     return (searchClient != null && searchClient.hasServiceUrl());\r
470   }\r
471   \r
472   public List<String> getServiceProxyUrls() {\r
473     List<String> urls = new ArrayList<String>();\r
474     urls.add("");\r
475     urls.addAll(serviceProxyUrls);\r
476     return urls;\r
477   }\r
478   \r
479   public List<String> getPazpar2Urls () {\r
480     List<String> urls = new ArrayList<String>();\r
481     urls.add("");\r
482     urls.addAll(pazpar2Urls);\r
483     return urls;\r
484   }\r
485   \r
486   public String getServiceType () {\r
487     return serviceType;\r
488   }\r
489   \r
490   public boolean isPazpar2Service () {\r
491     return serviceType.equals(SERVICE_TYPE_PZ2);\r
492   }\r
493   \r
494   public boolean isServiceProxyService() {\r
495     return serviceType.equals(SERVICE_TYPE_SP);\r
496   }\r
497   \r
498   public boolean serviceIsToBeDecided () {\r
499     return serviceType.equals(SERVICE_TYPE_TBD);\r
500   }\r
501   \r
502   public ServiceProxyClient getSpClient () {\r
503     return spClient;\r
504   }  \r
505   \r
506   public boolean getAuthenticationRequired () {\r
507     return spClient.isAuthenticatingClient();\r
508   }\r
509 \r
510   public String getCheckHistory () {\r
511     return ":pz2watch:stateForm:windowlocationhash";\r
512   }\r
513     \r
514   public String getWatchActiveclients () {\r
515     return ":pz2watch:activeclientsForm:activeclientsField";\r
516   }\r
517   \r
518   public String getWatchActiveclientsRecord () {\r
519     return ":pz2watch:activeclientsForm:activeclientsFieldRecord";\r
520   }\r
521 \r
522   @Override\r
523   public void configure(ConfigurationReader reader)\r
524       throws ConfigurationException {\r
525     Configuration config = reader.getConfiguration(this);\r
526     if (config == null) {\r
527       serviceType = SERVICE_TYPE_TBD;\r
528     } else {\r
529       String service = config.get("TYPE");\r
530       if (service == null || service.length()==0) {\r
531         serviceType = SERVICE_TYPE_TBD;\r
532       } else if (serviceTypes.contains(service.toUpperCase())) {        \r
533         setServiceType(service.toUpperCase());\r
534       } else {\r
535         logger.error("Unknown serviceType type in configuration [" + service + "], can be one of " + serviceTypes);\r
536         serviceType = SERVICE_TYPE_TBD;\r
537       }\r
538       serviceProxyUrls = config.getMultiProperty(SERVICE_PROXY_URL_LIST,",");\r
539       pazpar2Urls = config.getMultiProperty(PAZPAR2_URL_LIST, ",");\r
540     }\r
541     logger.info(reader.document());\r
542     logger.info("Service Type is configured to " + serviceType);\r
543     \r
544   }\r
545 \r
546   @Override\r
547   public Map<String, String> getDefaults() {\r
548     return new HashMap<String,String>();\r
549   }\r
550 \r
551   @Override\r
552   public String getModuleName() {\r
553     return MODULE_NAME;\r
554   }\r
555 \r
556   @Override\r
557   public List<String> documentConfiguration() {\r
558     return new ArrayList<String>();\r
559   }\r
560 \r
561   public void setServiceTypePZ2() {\r
562     setServiceType(SERVICE_TYPE_PZ2);    \r
563   }\r
564 \r
565   public void setServiceTypeSP() {\r
566     setServiceType(SERVICE_TYPE_SP);        \r
567   }\r
568 \r
569   public void setServiceTypeTBD() {\r
570     setServiceType(SERVICE_TYPE_TBD);    \r
571   }\r
572   \r
573   private void setServiceType(String type) {\r
574     if (!serviceType.equals(type)  &&\r
575         !serviceType.equals(SERVICE_TYPE_TBD)) {\r
576       resetSearchAndRecordCommands();\r
577       pzresp.getSp().resetAuthAndBeyond(true);\r
578     }\r
579     serviceType = type;\r
580     if (serviceType.equals(SERVICE_TYPE_PZ2)) {\r
581       searchClient = pz2Client;\r
582       logger.info("Setting a Pazpar2 client to serve requests.");\r
583     } else if (serviceType.equals(SERVICE_TYPE_SP)) {\r
584       searchClient = spClient;\r
585       logger.info("Setting a Service Proxy client to serve requests.");\r
586     } else {\r
587       logger.info("Clearing search client. No client defined to serve requests at this point.");\r
588       searchClient = null;\r
589     }\r
590   }\r
591   \r
592   public SearchClient getSearchClient() {\r
593     return searchClient;\r
594   }\r
595   \r
596 }\r