Revision 1951
Added by Matt Jones over 20 years ago
MetaCatUtil.java | ||
---|---|---|
40 | 40 |
import java.util.Vector; |
41 | 41 |
|
42 | 42 |
import edu.ucsb.nceas.dbadapter.AbstractDatabase; |
43 |
import edu.ucsb.nceas.utilities.Options; |
|
43 | 44 |
|
44 | 45 |
/** |
45 | 46 |
* A suite of utility classes for the metadata catalog server |
... | ... | |
47 | 48 |
public class MetaCatUtil { |
48 | 49 |
|
49 | 50 |
public static AbstractDatabase dbAdapter; |
50 |
private static PropertyResourceBundle options = null; |
|
51 |
private static String propertiesFile = "edu.ucsb.nceas.metacat.metacat"; |
|
51 |
private static Options options = null; |
|
52 | 52 |
private static boolean debug = true; |
53 | 53 |
|
54 | 54 |
//private Hashtable connectionPool = new Hashtable(); |
... | ... | |
91 | 91 |
* Utility method to get an option value from the properties file |
92 | 92 |
* |
93 | 93 |
* @param optionName the name of the option requested |
94 |
* @return the String value for the option, or null if not set |
|
94 | 95 |
*/ |
95 | 96 |
public static String getOption(String optionName) { |
96 |
// Get the configuration file information |
|
97 | 97 |
if (options == null) { |
98 |
options = (PropertyResourceBundle) |
|
99 |
PropertyResourceBundle.getBundle(propertiesFile); |
|
98 |
options = Options.getInstance(); |
|
100 | 99 |
} |
101 |
String value = (String)options.handleGetObject(optionName);
|
|
100 |
String value = options.getOption(optionName);
|
|
102 | 101 |
return value; |
103 | 102 |
} |
104 | 103 |
|
105 |
/** |
|
106 |
* Utility method to get an option value from a properties file |
|
107 |
* |
|
108 |
* @param optionName the name of the option requested |
|
109 |
* @param propFile the name of the file where to get the properties from |
|
110 |
*/ |
|
111 |
public String getOption(String optionName, String propFile) { |
|
112 |
// Get the configuration file information |
|
113 |
PropertyResourceBundle options = (PropertyResourceBundle) |
|
114 |
PropertyResourceBundle.getBundle(propFile); |
|
115 |
String value = (String)options.handleGetObject(optionName); |
|
116 |
return value; |
|
117 |
} |
|
118 |
|
|
119 |
|
|
120 |
|
|
121 |
|
|
122 | 104 |
/** Utility method to convert a file handle into a URL */ |
123 | 105 |
public static URL fileToURL(File file) |
124 | 106 |
{ |
... | ... | |
238 | 220 |
|
239 | 221 |
public static Vector getOptionList(String optiontext) |
240 | 222 |
{ |
241 |
Vector options = new Vector(); |
|
223 |
Vector optionsVector = new Vector();
|
|
242 | 224 |
if(optiontext.indexOf(",") == -1) |
243 | 225 |
{ |
244 |
options.addElement(optiontext); |
|
245 |
return options; |
|
226 |
optionsVector.addElement(optiontext);
|
|
227 |
return optionsVector;
|
|
246 | 228 |
} |
247 | 229 |
|
248 | 230 |
while(optiontext.indexOf(",") != -1) |
249 | 231 |
{ |
250 | 232 |
String s = optiontext.substring(0, optiontext.indexOf(",")); |
251 |
options.addElement(s.trim()); |
|
233 |
optionsVector.addElement(s.trim());
|
|
252 | 234 |
optiontext = optiontext.substring(optiontext.indexOf(",") + 1, |
253 | 235 |
optiontext.length()); |
254 | 236 |
if(optiontext.indexOf(",") == -1) |
255 | 237 |
{ //catch the last list entry |
256 |
options.addElement(optiontext.trim()); |
|
238 |
optionsVector.addElement(optiontext.trim());
|
|
257 | 239 |
} |
258 | 240 |
} |
259 |
return options; |
|
241 |
return optionsVector;
|
|
260 | 242 |
} |
261 | 243 |
|
262 | 244 |
/** Normalizes the given string. Taken from configXML.java*/ |
Also available in: Unified diff
Moved the metacat.properties file from the jar file to now be located in
the tomcat context directory in WEB-INF. Now the metacat configuration is
editable in place. This change depends on a new Options.java class in the
utilities module, so be sure you do a "clean" build in metacat so that you
pick up this new class. This satisfies needs for bug 1230.