Project

General

Profile

« Previous | Next » 

Revision 4481

Added by daigle about 16 years ago

Fix the deploy directory autodiscovery code so that it works regardless of where the metacat application directory is.

View differences:

src/edu/ucsb/nceas/metacat/util/SystemUtil.java
26 26

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

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

  
......
286 288
	 * @param request
287 289
	 *            the http servlet request we will use to find the tomcat directory
288 290
	 * 
289
	 * @return a string holding the tomcat directory
291
	 * @return a string holding the web application directory
290 292
	 */
291 293
	public static String discoverDeployDir(HttpServletRequest request) {
292 294
		ServletContext servletContext = request.getSession()
293 295
				.getServletContext();
294 296
		String realPath = servletContext.getRealPath(".");
295
		String contextName = servletContext.getServletContextName();
296
		String serverInfo = servletContext.getServerInfo();
297 297
		String contextPath = request.getContextPath();
298
		String servletPath = request.getServletPath();
299 298
		
300 299
		logMetacat.debug("realPath: " + realPath);
301
		logMetacat.debug("contextName: " + contextName);
302
		logMetacat.debug("serverInfo: " + serverInfo);
303 300
		logMetacat.debug("contextPath: " + contextPath);
304
		logMetacat.debug("servletPath: " + servletPath);
301

  
302
		Pattern pattern = Pattern.compile(contextPath + "/\\.$");
303
		Matcher matcher = pattern.matcher(realPath);
305 304
		
306

  
305
		if (matcher.find()) {
306
			realPath = matcher.replaceFirst("");
307
		}
308
		
307 309
		return realPath;
308 310
	}
309 311

  

Also available in: Unified diff