Project

General

Profile

1
/**
2
 *  '$RCSfile$'
3
 *    Purpose: A Class that implements system utility methods 
4
 *  Copyright: 2008 Regents of the University of California and the
5
 *             National Center for Ecological Analysis and Synthesis
6
 *    Authors: Michael Daigle
7
 * 
8
 *   '$Author: leinfelder $'
9
 *     '$Date: 2015-11-03 14:36:34 -0800 (Tue, 03 Nov 2015) $'
10
 * '$Revision: 9391 $'
11
 *
12
 * This program is free software; you can redistribute it and/or modify
13
 * it under the terms of the GNU General Public License as published by
14
 * the Free Software Foundation; either version 2 of the License, or
15
 * (at your option) any later version.
16
 *
17
 * This program is distributed in the hope that it will be useful,
18
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
 * GNU General Public License for more details.
21
 *
22
 * You should have received a copy of the GNU General Public License
23
 * along with this program; if not, write to the Free Software
24
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
25
 */
26

    
27
package edu.ucsb.nceas.metacat.util;
28

    
29
import java.util.Vector;
30
import java.util.regex.Matcher;
31
import java.util.regex.Pattern;
32
import javax.servlet.ServletContext;
33
import javax.servlet.http.HttpServletRequest;
34

    
35
import org.apache.log4j.Logger;
36

    
37
import edu.ucsb.nceas.metacat.MetacatVersion;
38
import edu.ucsb.nceas.metacat.properties.PropertyService;
39
import edu.ucsb.nceas.metacat.service.ServiceService;
40
import edu.ucsb.nceas.metacat.shared.MetacatUtilException;
41
import edu.ucsb.nceas.metacat.shared.ServiceException;
42
import edu.ucsb.nceas.utilities.FileUtil;
43
import edu.ucsb.nceas.utilities.PropertyNotFoundException;
44
import edu.ucsb.nceas.utilities.StringUtil;
45
import edu.ucsb.nceas.utilities.UtilException;
46

    
47
public class SystemUtil {
48

    
49
	private static Logger logMetacat = Logger.getLogger(SystemUtil.class);
50
	private static String METACAT_SERVLET = "metacat";
51
//	private static String METACAT_WEB_SERVLET = "metacatweb";
52
	private static int OS_CLASS = 0;
53
	
54
	// Class of OS.  If we need more granularity, we should create a version
55
	// list and access it separately.
56
	public static int WIN_OS = 1;
57
	public static int LINUX_OS = 2;
58
	public static int MAC_OS = 3;
59
	public static int OTHER_OS = 4;
60
	
61
	/**
62
	 * private constructor - all methods are static so there is no no need to
63
	 * instantiate.
64
	 */
65
	private SystemUtil() {}
66

    
67
	/**
68
	 * Get the OS for this system.
69
	 * @return an integer representing the class of OS.  Possibilities are:
70
	 *     WIN_OS = 1;
71
	 *     LINUX_OS = 2;
72
	 *     MAC_OS = 3;
73
	 *     OTHER_OS = 4;
74
	 */
75
	public static int getOsClass() {
76
		if (OS_CLASS > 0) {
77
			return OS_CLASS;
78
		}
79
		
80
		String osName = System.getProperty("os.name");
81
		if (osName.startsWith("Windows")) {
82
			OS_CLASS =  WIN_OS;
83
		} else if (osName.startsWith("Linux")) {
84
			OS_CLASS =  LINUX_OS;
85
		} else if (osName.startsWith("Mac")) {
86
			OS_CLASS =  MAC_OS;
87
		} else if (osName.startsWith("Mac")) {
88
			OS_CLASS =  OTHER_OS;
89
		}
90
		
91
		return OS_CLASS;
92
	}
93
	
94
	/**
95
	 * Attempt to discover the server name. The name is retrieved from the http
96
	 * servlet request. This is used by configuration routines before the port
97
	 * has been populated in metacat.properties. it is possible the port that
98
	 * the user configures might be different than the name we get here. You
99
	 * should use getServerPort() instead of this method whenever possible.
100
	 * 
101
	 * @param request
102
	 *            the http servlet request we will use to find the server name
103
	 * 
104
	 * @return a string holding the server name
105
	 */
106
	public static String discoverServerName(HttpServletRequest request) {
107
		String serverName = request.getServerName();
108

    
109
		return serverName;
110
	}
111

    
112
	/**
113
	 * Attempt to discover the server port. The port is retrieved from the http
114
	 * servlet request. This is used by configuration routines before the port
115
	 * has been populated in metacat.properties. it is possible the port that
116
	 * the user configures might be different than the port we get here. You
117
	 * should use getServerPort() instead of this method whenever possible.
118
	 * 
119
	 * @param request
120
	 *            the http servlet request we will use to find the server port
121
	 * 
122
	 * @return a string holding the server port
123
	 */
124
	public static String discoverServerPort(HttpServletRequest request) {
125
		return Integer.toString(request.getServerPort());
126
	}
127
	
128
	/**
129
	 * Attempt to discover the server ssl port. The ssl port is assumed using
130
	 * the standard port. This is used by configuration routines before the port
131
	 * has been populated in metacat.properties. it is possible the prot that
132
	 * the user configures might be different than the port we get here. You
133
	 * should use getServerSSLPort() instead of this method whenever possible.
134
	 * 
135
	 * @param request
136
	 *            the http servlet request we will use to find the server port
137
	 * 
138
	 * @return a string holding the server ssl port
139
	 */
140
	public static String discoverServerSSLPort(HttpServletRequest request) {
141
		String serverPort = discoverServerPort(request);
142

    
143
		if (serverPort.length() == 4 && serverPort.charAt(0) == '8') {
144
			return "8443";
145
		}
146

    
147
		return "443";
148
	}
149

    
150
	/**
151
	 * Get the server URL which is made up of the server name + : + the http
152
	 * port number. Note that if the port is 80, it is left off.
153
	 * 
154
	 * @return string holding the server URL
155
	 */
156
	public static String getServerURL() throws PropertyNotFoundException {
157
	    String httpPort = PropertyService.getProperty("server.httpPort");
158
	    
159
	    String serverURL = "http://";
160
	    if(httpPort.equals("443") || httpPort.equals("8443"))
161
	    {
162
	        serverURL = "https://";
163
	    }
164
	    
165
	    serverURL += PropertyService.getProperty("server.name");
166
		
167
		if (!httpPort.equals("80") && !httpPort.equals("443")) {
168
			serverURL += ":" + httpPort;
169
		}
170

    
171
		return serverURL;
172
	}
173

    
174
	/**
175
	 * Get the secure server URL which is made up of the server name + : + the
176
	 * https port number. Note that if the port is 443, it is left off.
177
	 * 
178
	 * @return string holding the server URL
179
	 */
180
	public static String getSecureServerURL() throws PropertyNotFoundException {
181
		String ServerURL = "https://" + getSecureServer();
182
		return ServerURL;
183
	}
184
	
185
	/**
186
	 * Get the secure server  which is made up of the server name + : + the
187
	 * https port number. Note that if the port is 443, it is left off.
188
	 * NOTE: does NOT include "https://"
189
	 * @see getSecureServerURL()
190
	 * 
191
	 * @return string holding the secure server
192
	 */
193
	public static String getSecureServer() throws PropertyNotFoundException {
194
		String server = PropertyService.getProperty("server.name");
195
		String httpPort = PropertyService.getProperty("server.httpSSLPort");
196
		if (!httpPort.equals("443")) {
197
			server = server + ":" + httpPort;
198
		}
199

    
200
		return server;
201
	}
202

    
203
	/**
204
	 * Get the CGI URL which is made up of the server URL + file separator + the
205
	 * CGI directory
206
	 * 
207
	 * @return string holding the server URL
208
	 */
209
	public static String getCGI_URL() throws PropertyNotFoundException{
210
		return getContextURL() 
211
				+ PropertyService.getProperty("application.cgiDir");
212
	}
213

    
214
	/**
215
	 * Get the server URL with the context. This is made up of the server URL +
216
	 * file separator + the context
217
	 * 
218
	 * @return string holding the server URL with context
219
	 */
220
	public static String getContextURL() throws PropertyNotFoundException {
221
		return getServerURL() + "/"
222
				+ PropertyService.getProperty("application.context");
223
	}
224
	
225
	/**
226
	 * Get the secure server URL with the context. This is made up of the secure server URL +
227
	 * file separator + the context
228
	 * 
229
	 * @return string holding the server URL with context
230
	 */
231
	public static String getSecureContextURL() throws PropertyNotFoundException {
232
		return getSecureServerURL() + "/"
233
				+ PropertyService.getProperty("application.context");
234
	}
235

    
236
	/**
237
	 * Get the servlet URL. This is made up of the server URL with context +
238
	 * file separator + the metacat servlet name
239
	 * 
240
	 * @return string holding the servlet URL
241
	 */
242
	public static String getServletURL() throws PropertyNotFoundException {
243
		return getContextURL() + "/" + METACAT_SERVLET;
244
	}
245
	
246
//	/**
247
//	 * Get the web front end servlet URL. This is made up of the server URL with 
248
//	 * context + file separator + the metacat web servlet name
249
//	 * 
250
//	 * @return string holding the web servlet URL
251
//	 */
252
//	public static String getWebServletURL() throws PropertyNotFoundException {
253
//		return getContextURL() + "/" + METACAT_WEB_SERVLET;
254
//	}
255

    
256
	/**
257
	 * Get the style skins URL. This is made up of the server URL with context +
258
	 * file separator + "style" + file separator + "skins"
259
	 * 
260
	 * @return string holding the style skins URL
261
	 */
262
	public static String getStyleSkinsURL() throws PropertyNotFoundException {
263
		return getContextURL() + "/" + "style" + "/" + "skins";
264
	}
265

    
266
	/**
267
	 * Get the style common URL. This is made up of the server URL with context +
268
	 * file separator + "style" + file separator + "common"
269
	 * 
270
	 * @return string holding the style common URL
271
	 */
272
	public static String getStyleCommonURL() throws PropertyNotFoundException {
273
		return getContextURL() + "/" + "style" + "/" + "common";
274
	}
275
	
276
	/**
277
	 * Get the metacat version by getting the string representation from
278
	 * metacat.properties and instantiating a MetacatVersion object.
279
	 * The info is set in build.properties and then populated into metacat.properties
280
	 * at build time using Ant token replacement.
281
	 * 
282
	 * @return a MetacatVersion object holding metacat version information
283
	 */
284
	public static MetacatVersion getMetacatVersion() throws PropertyNotFoundException {
285
		String metacatVersionString = 
286
			PropertyService.getProperty("application.metacatVersion");
287
		return new MetacatVersion(metacatVersionString);
288
	}
289
	
290
	/**
291
	 * Gets a string that holds some description about the release. Typically this is 
292
	 * used during release candidates for display purposes and might hold something
293
	 * like "Release Candidate 1".  Normally it is empty for final production release.
294
	 * The info is set in build.properties and then populated into metacat.properties
295
	 * at build time using Ant token replacement.
296
	 * 
297
	 * @return a MetacatVersion object holding metacat version information
298
	 */
299
	public static String getMetacatReleaseInfo() throws PropertyNotFoundException {
300
		return PropertyService.getProperty("application.metacatReleaseInfo");
301
	}
302

    
303
	/**
304
	 * Get the context directory. This is made up of the deployment directory + file
305
	 * separator + context
306
	 * 
307
	 * @return string holding the context directory
308
	 */
309
	public static String getContextDir() throws PropertyNotFoundException {
310
		return PropertyService.getProperty("application.deployDir") + FileUtil.getFS()
311
				+ PropertyService.getProperty("application.context");
312
	}
313

    
314
	/**
315
	 * Attempt to discover the context for this application. This is a best
316
	 * guess scenario. It is used by configuration routines before the context
317
	 * has been populated in metacat.properties. You should always use
318
	 * getApplicationContext() instead of this method if possible.
319
	 * 
320
	 * @param servletContext
321
	 *            the servlet context we will use to find the application context
322
	 * 
323
	 * @return a string holding the context
324
	 */
325
	public static String discoverApplicationContext(ServletContext servletContext) {
326
		String applicationContext = "";
327
		String realPath = servletContext.getRealPath("/");
328

    
329
		if (realPath.charAt(realPath.length() - 1) == '/') {
330
			realPath = realPath.substring(0, realPath.length() - 1);
331
		}
332
		
333
		int lastSlashIndex = realPath.lastIndexOf('/');
334
		if (lastSlashIndex != -1) {
335
			applicationContext = realPath.substring(lastSlashIndex + 1);
336
		}
337
				
338
		logMetacat.debug("application context: " + applicationContext);
339

    
340
		return applicationContext;
341
	}
342
	
343
	/**
344
	 * Gets the stored backup location.  This location is held in a file at
345
	 * <user_home>/.<application_context>/backup-location
346
	 * 
347
	 * @return a string holding the backup location.  Null if none could be found.
348
	 */
349
	public static String getStoredBackupDir() throws MetacatUtilException {
350
		String applicationContext = null;
351
		try {
352
			applicationContext = ServiceService.getRealApplicationContext();
353
			// Check if there is a file at
354
			// <user_home>/<application_context>/backup-location. If so, it
355
			// should contain one line that is a file that points to a writable
356
			// directory. If that is true, use that value as the backup dir.
357
			String storedBackupFileLoc = getUserHomeDir() + FileUtil.getFS() + "."
358
					+ applicationContext + FileUtil.getFS() + "backup-location";
359
			if (FileUtil.getFileStatus(storedBackupFileLoc) >= FileUtil.EXISTS_READABLE) {
360
				String storedBackupDirLoc = FileUtil
361
						.readFileToString(storedBackupFileLoc);
362
				if (FileUtil.isDirectory(storedBackupDirLoc)
363
						&& FileUtil.getFileStatus(storedBackupDirLoc) > FileUtil.EXISTS_READABLE) {
364
					return storedBackupDirLoc;
365
				}
366
			}
367
		} catch (UtilException ue) {
368
			logMetacat.warn("Utility problem finding backup location: " + ue.getMessage());
369
		} catch (ServiceException se) {
370
			logMetacat.warn("Could not get real application context: " + se.getMessage());
371
		}
372
		return null;
373
	}
374
	
375
	public static void writeStoredBackupFile(String backupPath) throws MetacatUtilException {
376
		String applicationContext = null;
377
		try {
378
			applicationContext = ServiceService.getRealApplicationContext();
379
			// Write the backup path to
380
			// <user_home>/.<application_context>/backup-location. 
381
			String storedBackupFileDir = getUserHomeDir() + FileUtil.getFS() + "." + applicationContext;
382
			String storedBackupFileLoc = storedBackupFileDir + FileUtil.getFS() + "backup-location";
383
			if (!FileUtil.isDirectory(storedBackupFileDir)) {
384
				FileUtil.createDirectory(storedBackupFileDir);
385
			}
386
			if (FileUtil.getFileStatus(storedBackupFileLoc) == FileUtil.DOES_NOT_EXIST) {
387
				FileUtil.createFile(storedBackupFileLoc);
388
			}		
389
			if (FileUtil.getFileStatus(storedBackupFileLoc) < FileUtil.EXISTS_READ_WRITABLE) {
390
				throw new UtilException("Stored backup location file is not writable: " + storedBackupFileLoc);
391
			}
392
			
393
			FileUtil.writeFile(storedBackupFileLoc, backupPath);
394
			
395
		} catch (UtilException ue) {
396
			logMetacat.warn("Utility error writing backup file: " + ue.getMessage());
397
		} catch (ServiceException se) {
398
			logMetacat.warn("Service error getting real application context: " + se.getMessage());
399
		} 
400
	}
401
	
402
	/**
403
	 * Attempt to discover the external (to the metacat installation)
404
	 * directory where metacat will hold backup files.   This functionality 
405
	 * is used to populate the configuration utility initially.  The user 
406
	 * can change the directory manually, so you can't rely on this method 
407
	 * to give you the actual directory.  Here are the steps taken to discover
408
	 * the directory:
409
	 * 
410
     * -- 1) Look for an existing hidden (.<application_context>) directory in a default system directory.  Get 
411
	 *       the default base directory for the OS.  (See application.windowsBackupBaseDir and 
412
	 *       application.linuxBackupBaseDir in metacat.properties.)  If a directory called 
413
	 *       <base_dir>/metacat/.<application_context> exists, return <base_dir>/metacat.
414
	 * -- 2) Otherwise, look for an existing hidden (.metacat) directory in the user directory. If a directory 
415
	 *       called <user_dir>/metacat/.<application_context> exists for the user that started tomcat, 
416
	 *       return <user_dir>/metacat.
417
	 * -- 3) Otherwise, look for an existing metacat directory in a default system directory.  Get 
418
	 *       the default base directory for the OS.  (See application.windowsBackupBaseDir and 
419
	 *       application.linuxBackupBaseDir in metacat.properties.)  If a directory called 
420
	 *       <base_dir>/metacat exists, return <base_dir>/metacat.
421
	 * -- 4) Otherwise, look for an existing metacat directory in the user directory. If a directory 
422
	 *       called <user_dir>/metacat/ exists for the user that started tomcat, return <user_dir>/metacat.
423
	 * -- 5) Otherwise, is the <base_dir> writable by the user that started tomcat?  If so, return 
424
	 *       <base_dir>/metacat
425
	 * -- 6) Does the <user_home> exist?  If so, return <user_home>/metacat
426
	 * -- 7) Otherwise, return null
427
	 *    
428
	 * @return a string holding the backup directory path
429
	 */
430
	public static String discoverExternalDir() throws MetacatUtilException {
431
		String applicationContext = null; 
432
		
433
		try {
434
			applicationContext = ServiceService.getRealApplicationContext();
435
			
436
			// Set the default location using the os
437
			String systemDir = "";
438
			if (getOsClass() == WIN_OS) {
439
				systemDir = "C:\\Program Files";
440
			} else {
441
				systemDir = "/var";
442
			}	
443
			String systemMetacatDir = systemDir + FileUtil.getFS() + "metacat";
444
			String systemBackupDir = systemMetacatDir + FileUtil.getFS() + "."
445
					+ applicationContext;
446

    
447
			String userHomeDir = getUserHomeDir();
448
			String userHomeMetacatDir = userHomeDir + FileUtil.getFS() + "metacat";
449
			String userHomeBackupDir = userHomeMetacatDir + FileUtil.getFS() + "." + applicationContext;
450

    
451
			// If <system_dir>/metacat/.<application_context> exists writable, 
452
			// return <system_dir>/metacat
453
			if ((FileUtil.getFileStatus(systemBackupDir) >= FileUtil.EXISTS_READ_WRITABLE)) {
454
				return systemMetacatDir;
455
			}
456

    
457
			// Otherwise if <user_dir>/metacat/.<application_context> exists writable, return
458
			// <user_dir>/metacat
459
			if ((FileUtil.getFileStatus(userHomeBackupDir) >= FileUtil.EXISTS_READ_WRITABLE)) {
460
				return userHomeMetacatDir;
461
			}
462

    
463
			// Otherwise if <system_dir>/metacat exists writable, create 
464
			// <system_dir>/metacat/.<application_context> and return <system_dir>/metacat
465
			if ((FileUtil.getFileStatus(systemMetacatDir) >= FileUtil.EXISTS_READ_WRITABLE)) {
466
				// go ahead and create the backup hidden dir
467
				FileUtil.createDirectory(systemBackupDir);
468
				return systemMetacatDir;
469
			}
470

    
471
			// Otherwise if <user_dir>/metacat exists writable, create 
472
			// <user_dir>/metacat/.<application_context> and return <user_dir>/metacat
473
			if ((FileUtil.getFileStatus(userHomeMetacatDir) >= FileUtil.EXISTS_READ_WRITABLE)) {
474
				// go ahead and create the backup hidden dir
475
				FileUtil.createDirectory(userHomeBackupDir);
476
				return userHomeMetacatDir;
477
			}
478
			
479
			// Otherwise if <system_dir> exists, create 
480
			// <system_dir>/metacat/.<application_context> and return <system_dir>/metacat
481
			if ((FileUtil.getFileStatus(systemDir) >= FileUtil.EXISTS_READ_WRITABLE)) {
482
				// go ahead and create the backup hidden dir
483
				FileUtil.createDirectory(systemBackupDir);
484
				return systemMetacatDir;
485
			}
486

    
487
			// Otherwise if <user_dir> exists, return <user_dir> create 
488
			// <user_dir>/metacat/.<application_context> and return <user_dir>/metacat
489
			if ((FileUtil.getFileStatus(userHomeDir) >= FileUtil.EXISTS_READ_WRITABLE)) {
490
				// go ahead and create the backup hidden dir
491
				FileUtil.createDirectory(userHomeBackupDir);
492
				return userHomeMetacatDir;
493
			}
494

    
495
		} catch (ServiceException se) {
496
			logMetacat.warn("Could not get real application context: " + se.getMessage());
497
		} catch (UtilException ue) {
498
			logMetacat.warn("Could not create directory: " + ue.getMessage());
499
		} 
500
		
501
		// Otherwise, return userHomeDir
502
		return null;
503
	}
504
	
505
	/**
506
	 * Store the location of the backup file location into a file at 
507
	 * <user_home>/<application_dir>/backup-location
508
	 * 
509
	 * @param externalDir the backup file location.
510
	 */
511
	public static void storeExternalDirLocation(String externalDir) {
512
		if (getUserHomeDir() != null) {
513
			String applicationContext = null;
514
			String storedBackupLocDir = null;
515
			String storedBackupLocFile = null;
516
			try {
517
				applicationContext = ServiceService.getRealApplicationContext();
518
				storedBackupLocDir = getUserHomeDir() + FileUtil.getFS() + "."
519
						+ applicationContext;
520
				storedBackupLocFile = storedBackupLocDir + FileUtil.getFS()
521
						+ "backup-location";
522
			
523
				FileUtil.createDirectory(storedBackupLocDir);
524
				FileUtil.writeFile(storedBackupLocFile, externalDir);
525
			} catch (ServiceException se) {
526
				logMetacat.error("Could not get real application directory while trying to write "
527
							+ "stored backup directory: "+ storedBackupLocFile + " : " + se.getMessage());
528
			} catch (UtilException ue) {
529
				logMetacat.error("Could not write backup location file into "
530
						+ "stored backup directory: "+ storedBackupLocFile + " : " + ue.getMessage());
531
			}
532
		} else {
533
			logMetacat.warn("Could not write out stored backup directory." 
534
					+ " User directory does not exist");
535
		}
536
	}
537

    
538
	/**
539
	 * Get the style skins directory. This is made up of the tomcat directory
540
	 * with context + file separator + "style" + file separator + "skins"
541
	 * 
542
	 * @return string holding the style skins directory
543
	 */
544
	public static String getStyleSkinsDir() throws PropertyNotFoundException {
545
		return getContextDir() + FileUtil.getFS() + "style" + FileUtil.getFS()
546
				+ "skins";
547
	}
548

    
549
	/**
550
	 * Get the SQL directory. This is made up of the context directory + file
551
	 * separator + sql
552
	 * 
553
	 * @return string holding the sql directory
554
	 */
555
	public static String getSQLDir() throws PropertyNotFoundException {
556
		return getContextDir() + FileUtil.getFS() + "WEB-INF" + FileUtil.getFS() + "sql";
557
	}
558

    
559
	/**
560
	 * Get the default style URL from metacat.properties.
561
	 * 
562
	 * @return string holding the default style URL
563
	 */
564
	public static String getDefaultStyleURL() throws PropertyNotFoundException {
565
		return getStyleCommonURL() + "/"
566
				+ PropertyService.getProperty("application.default-style");
567
	}
568

    
569
	/**
570
	 * Attempt to discover the deployment directory for this application. This is a
571
	 * best guess scenario. It is used by configuration routines before the
572
	 * deployment directory has been populated in metacat.properties. 
573
	 * 
574
	 * @param request
575
	 *            the http servlet request we will use to find the tomcat directory
576
	 * 
577
	 * @return a string holding the web application directory
578
	 */
579
	public static String discoverDeployDir(HttpServletRequest request) {
580
		ServletContext servletContext = request.getSession()
581
				.getServletContext();
582
		String realPath = servletContext.getRealPath(".");
583
		String contextPath = request.getContextPath();
584
		
585
		logMetacat.debug("realPath: " + realPath);
586
		logMetacat.debug("contextPath: " + contextPath);
587

    
588
		Pattern pattern = Pattern.compile(contextPath + "/\\.$");
589
		Matcher matcher = pattern.matcher(realPath);
590
		
591
		if (matcher.find()) {
592
			realPath = matcher.replaceFirst("");
593
		}
594
		
595
		return realPath;
596
	}
597
	
598
	/**
599
	 * Get the current user's home directory
600
	 * 
601
	 * @return a string holding the home directory
602
	 */
603
	public static String getUserHomeDir() {
604
		return System.getProperty("user.home");
605
	}
606
	
607
	/**
608
	 * Get a list of xml paths that need to be indexed
609
	 */
610
	public static Vector<String> getPathsForIndexing() throws MetacatUtilException {
611
		Vector <String> indexPaths = null;
612
		try {
613
			indexPaths = 
614
				StringUtil.toVector(PropertyService.getProperty("xml.indexPaths"), ',');
615
		} catch (PropertyNotFoundException pnfe) {
616
			throw new MetacatUtilException("could not get index paths: " + pnfe.getMessage());
617
		}
618
		
619
		return indexPaths;
620
	}
621
	
622
	/**
623
	 * Get the url pointing to the user management page.
624
	 * @return the url.
625
	 * @throws PropertyNotFoundException
626
	 */
627
	public static String getUserManagementUrl() throws PropertyNotFoundException {
628
	    return PropertyService.getProperty("auth.userManagementUrl");
629
	}
630
 }
(18-18/18)