ranger-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mad...@apache.org
Subject git commit: Determining webapp folder from startup script location.
Date Sat, 01 Nov 2014 18:06:09 GMT
Repository: incubator-argus
Updated Branches:
  refs/heads/master 6dc34963f -> c62c5e165


Determining webapp folder from startup script location.

Signed-off-by: Madhan Neethiraj <madhan@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/incubator-argus/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-argus/commit/c62c5e16
Tree: http://git-wip-us.apache.org/repos/asf/incubator-argus/tree/c62c5e16
Diff: http://git-wip-us.apache.org/repos/asf/incubator-argus/diff/c62c5e16

Branch: refs/heads/master
Commit: c62c5e1652469b008af1823c86a48d0b75e99b97
Parents: 6dc3496
Author: Don Bosco Durai <bosco@apache.org>
Authored: Fri Oct 31 23:25:55 2014 -0700
Committer: Madhan Neethiraj <madhan@apache.org>
Committed: Sat Nov 1 11:05:22 2014 -0700

----------------------------------------------------------------------
 .../conf/ranger_webserver.properties            |  6 ------
 .../xasecure/server/tomcat/EmbededServer.java   | 21 ++++++++++++++++++--
 2 files changed, 19 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/c62c5e16/embededwebserver/conf/ranger_webserver.properties
----------------------------------------------------------------------
diff --git a/embededwebserver/conf/ranger_webserver.properties b/embededwebserver/conf/ranger_webserver.properties
index 6051093..7c98687 100644
--- a/embededwebserver/conf/ranger_webserver.properties
+++ b/embededwebserver/conf/ranger_webserver.properties
@@ -37,9 +37,3 @@ https.attrib.keystoreFile=/etc/ranger/admin/keys/server.jks
 #
 accesslog.dateformat=yyyy-MM-dd
 accesslog.pattern=%h %l %u %t "%r" %s %b "%{Referer}i" "%{User-Agent}i"
-
-#
-# Root Context Application
-#
-#TODO: Need to update this to reflect apache path
-xa.webapp.dir=/usr/hdp/current/ranger-admin/ews/webapp

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/c62c5e16/embededwebserver/src/main/java/com/xasecure/server/tomcat/EmbededServer.java
----------------------------------------------------------------------
diff --git a/embededwebserver/src/main/java/com/xasecure/server/tomcat/EmbededServer.java
b/embededwebserver/src/main/java/com/xasecure/server/tomcat/EmbededServer.java
index ca26852..7adc1aa 100644
--- a/embededwebserver/src/main/java/com/xasecure/server/tomcat/EmbededServer.java
+++ b/embededwebserver/src/main/java/com/xasecure/server/tomcat/EmbededServer.java
@@ -138,7 +138,19 @@ public class EmbededServer {
 		server.getHost().getPipeline().addValve(valve);
 		
 		try {
-			Context webappCtx = server.addWebapp("/",  new File(getConfig("xa.webapp.dir")).getAbsolutePath())
;
+			String webapp_dir= getConfig("xa.webapp.dir");
+			if( webapp_dir == null || webapp_dir.trim().isEmpty()) {
+				//If webapp location property is not set, then let's dervice from catalina_base
+				String catalina_base = getConfig("catalina.base");
+				if( catalina_base == null || catalina_base.trim().isEmpty()) {
+					LOG.severe("Tomcat Server failed to start: catalina.base and/or xa.webapp.dir is not
set") ;
+					System.exit(1);
+				}
+				webapp_dir = catalina_base + File.separator + "webapp";
+				LOG.info("Deriving webapp folder from catalina.base property. folder=" + webapp_dir);
+			}
+			LOG.info("Webapp folder=" + webapp_dir);
+			Context webappCtx = server.addWebapp("/",  new File(webapp_dir).getAbsolutePath()) ;
 			webappCtx.init() ;
 		} catch (ServletException e1) {
 			LOG.severe("Tomcat Server failed to add webapp:" + e1.toString()) ;
@@ -159,7 +171,12 @@ public class EmbededServer {
 	
 	
 	protected String getConfig(String key) {
-		return serverConfigProperties.getProperty(key) ;
+		String value = serverConfigProperties.getProperty(key) ;
+		if ( value == null || value.trim().isEmpty()) {
+			//Value not found in properties file, let's try to get from System's property
+			value = System.getProperty(key);
+		}
+		return value;
 	}
 	
 	protected String getConfig(String key, String defaultValue) {


Mime
View raw message