|
|
@@ -168,7 +168,7 @@ public class GitblitContext extends GuiceServletContextListener { |
|
|
|
// if the base folder dosen't match the default assume they don't want to use express, |
|
|
|
// this allows for other containers to customise the basefolder per context. |
|
|
|
String defaultBase = Constants.contextFolder$ + "/WEB-INF/data"; |
|
|
|
String base = System.getProperty("GITBLIT_HOME",lookupBaseFolderFromJndi()); |
|
|
|
String base = getBaseFolderPath(defaultBase); |
|
|
|
if (!StringUtils.isEmpty(System.getenv("OPENSHIFT_DATA_DIR")) && defaultBase.equals(base)) { |
|
|
|
// RedHat OpenShift |
|
|
|
baseFolder = configureExpress(context, webxmlSettings, contextFolder, runtimeSettings); |
|
|
@@ -235,6 +235,24 @@ public class GitblitContext extends GuiceServletContextListener { |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
protected String getBaseFolderPath(String defaultBaseFolder) { |
|
|
|
// try a system property or a JNDI property |
|
|
|
String specifiedBaseFolder = System.getProperty("GITBLIT_HOME", lookupBaseFolderFromJndi()); |
|
|
|
|
|
|
|
if (!StringUtils.isEmpty(System.getenv("GITBLIT_HOME"))) { |
|
|
|
// try an environment variable |
|
|
|
specifiedBaseFolder = System.getenv("GITBLIT_HOME"); |
|
|
|
} |
|
|
|
|
|
|
|
if (!StringUtils.isEmpty(specifiedBaseFolder)) { |
|
|
|
// use specified base folder path |
|
|
|
return specifiedBaseFolder; |
|
|
|
} |
|
|
|
|
|
|
|
// use default base folder path |
|
|
|
return defaultBaseFolder; |
|
|
|
} |
|
|
|
|
|
|
|
protected <X extends IManager> X loadManager(Injector injector, Class<X> clazz) { |
|
|
|
X x = injector.getInstance(clazz); |
|
|
|
return x; |
|
|
@@ -328,9 +346,9 @@ public class GitblitContext extends GuiceServletContextListener { |
|
|
|
logger.debug("configuring Gitblit WAR"); |
|
|
|
logger.info("WAR contextFolder is " + ((contextFolder != null) ? contextFolder.getAbsolutePath() : "<empty>")); |
|
|
|
|
|
|
|
String path = webxmlSettings.getString(Constants.baseFolder, Constants.contextFolder$ + "/WEB-INF/data"); |
|
|
|
String webXmlPath = webxmlSettings.getString(Constants.baseFolder, Constants.contextFolder$ + "/WEB-INF/data"); |
|
|
|
|
|
|
|
if (path.contains(Constants.contextFolder$) && contextFolder == null) { |
|
|
|
if (webXmlPath.contains(Constants.contextFolder$) && contextFolder == null) { |
|
|
|
// warn about null contextFolder (issue-199) |
|
|
|
logger.error(""); |
|
|
|
logger.error(MessageFormat.format("\"{0}\" depends on \"{1}\" but \"{2}\" is returning NULL for \"{1}\"!", |
|
|
@@ -340,18 +358,15 @@ public class GitblitContext extends GuiceServletContextListener { |
|
|
|
logger.error(""); |
|
|
|
} |
|
|
|
|
|
|
|
String externalBase = System.getProperty("GITBLIT_HOME", lookupBaseFolderFromJndi()); |
|
|
|
if (!StringUtils.isEmpty(externalBase)) { |
|
|
|
path = externalBase; |
|
|
|
} |
|
|
|
String baseFolderPath = getBaseFolderPath(webXmlPath); |
|
|
|
|
|
|
|
File base = com.gitblit.utils.FileUtils.resolveParameter(Constants.contextFolder$, contextFolder, path); |
|
|
|
base.mkdirs(); |
|
|
|
File baseFolder = com.gitblit.utils.FileUtils.resolveParameter(Constants.contextFolder$, contextFolder, baseFolderPath); |
|
|
|
baseFolder.mkdirs(); |
|
|
|
|
|
|
|
// try to extract the data folder resource to the baseFolder |
|
|
|
File localSettings = new File(base, "gitblit.properties"); |
|
|
|
File localSettings = new File(baseFolder, "gitblit.properties"); |
|
|
|
if (!localSettings.exists()) { |
|
|
|
extractResources(context, "/WEB-INF/data/", base); |
|
|
|
extractResources(context, "/WEB-INF/data/", baseFolder); |
|
|
|
} |
|
|
|
|
|
|
|
// delegate all config to baseFolder/gitblit.properties file |
|
|
@@ -363,7 +378,7 @@ public class GitblitContext extends GuiceServletContextListener { |
|
|
|
// the target file for runtimeSettings is set to "localSettings". |
|
|
|
runtimeSettings.merge(fileSettings); |
|
|
|
|
|
|
|
return base; |
|
|
|
return baseFolder; |
|
|
|
} |
|
|
|
|
|
|
|
/** |