01: /*
02: * CVS information:
03: * $RCSfile$
04: * $Source$
05: * $Date: 2005-08-10 16:00:46 +0200 (Mi, 10 Aug 2005) $
06: * $Author: til132 $
07: * $Revision: 155 $
08: */
09: package net.sf.regain.search.config;
10:
11: import java.io.File;
12:
13: import net.sf.regain.RegainException;
14: import net.sf.regain.util.sharedtag.PageRequest;
15:
16: /**
17: * Loads the search config from a XML file. The location of the XML file is
18: * specified by the init parameter "searchConfigFile".
19: *
20: * @author Tilman Schneider, STZ-IDA an der FH Karlsruhe
21: */
22: public class DefaultSearchConfigFactory implements SearchConfigFactory {
23:
24: /**
25: * Creates the configuration of the search mask.
26: *
27: * @param request The page request. Used to get the "configFile" init
28: * parameter, which holds the name of the configuration file.
29: * @return The configuration of the search mask.
30: * @throws RegainException If loading failed.
31: */
32: public SearchConfig createSearchConfig(PageRequest request)
33: throws RegainException {
34: String configFileName = request
35: .getInitParameter("searchConfigFile");
36: if (configFileName == null) {
37: throw new RegainException(
38: "The init parameter 'searchConfigFile' was not specified.");
39: }
40:
41: File configFile = new File(request.getWorkingDir(),
42: configFileName);
43: try {
44: return new XmlSearchConfig(configFile);
45: } catch (RegainException exc) {
46: throw new RegainException(
47: "Loading configuration file failed: "
48: + configFile.getAbsolutePath(), exc);
49: }
50: }
51:
52: }
|