summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Moger <james.moger@gitblit.com>2013-10-02 17:12:18 -0400
committerJames Moger <james.moger@gitblit.com>2013-10-02 17:12:18 -0400
commit06718be43c345d74f24288d7b8477d2237ce7358 (patch)
treebbef87d2effb92123b14abe9c26cdca3602f8804
parent31f305c2c9d1737dbcd4e3cac051cceb31d1cb1e (diff)
downloadgitblit-06718be43c345d74f24288d7b8477d2237ce7358.tar.gz
gitblit-06718be43c345d74f24288d7b8477d2237ce7358.zip
Switch web.xml baseFolder from context-param to env-entry
Change-Id: Id18077126e984a767725cf9e8d8eb531a14e1713
-rw-r--r--releases.moxie2
-rw-r--r--src/main/java/WEB-INF/web.xml10
-rw-r--r--src/main/java/com/gitblit/GitBlit.java15
3 files changed, 23 insertions, 4 deletions
diff --git a/releases.moxie b/releases.moxie
index 87d178a7..c231a290 100644
--- a/releases.moxie
+++ b/releases.moxie
@@ -19,6 +19,7 @@ r20: {
- Dashboard and Activity pages now obey the web.generateActivityGraph setting (issue-310)
- Do not log passwords on failed authentication attempts (issue-316)
- Updated default binary and Lucene ignore extensions
+ - Change the WAR baseFolder context parameter to a JNDI env-entry to improve enterprise deployments
additions:
- Added branch graph image servlet based on EGit's branch graph renderer (issue-194)
- Added option to render Markdown commit messages (issue-203)
@@ -40,6 +41,7 @@ r20: {
- Bret Ikehara
- Chad Horohoe
- Domingo Oropeza
+ - Chris Graham
}
#
diff --git a/src/main/java/WEB-INF/web.xml b/src/main/java/WEB-INF/web.xml
index d4acb049..6e24326b 100644
--- a/src/main/java/WEB-INF/web.xml
+++ b/src/main/java/WEB-INF/web.xml
@@ -22,10 +22,12 @@
review the defaults for any new settings. Settings are always versioned
with a SINCE x.y.z attribute and also noted in the release changelog.
-->
- <context-param>
- <param-name>baseFolder</param-name>
- <param-value>${contextFolder}/WEB-INF/data</param-value>
- </context-param>
+ <env-entry>
+ <description>The base folder is used to specify the root location of your Gitblit data.</description>
+ <env-entry-name>baseFolder</env-entry-name>
+ <env-entry-type>java.lang.String</env-entry-type>
+ <env-entry-value>${contextFolder}/WEB-INF/data</env-entry-value>
+ </env-entry>
<!-- Gitblit Displayname -->
<display-name>
diff --git a/src/main/java/com/gitblit/GitBlit.java b/src/main/java/com/gitblit/GitBlit.java
index 5eec7a93..7f82432d 100644
--- a/src/main/java/com/gitblit/GitBlit.java
+++ b/src/main/java/com/gitblit/GitBlit.java
@@ -62,6 +62,9 @@ import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMultipart;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
@@ -3776,6 +3779,18 @@ public class GitBlit implements ServletContextListener {
logger.error("");
}
+ try {
+ // try to lookup JNDI env-entry for the baseFolder
+ InitialContext ic = new InitialContext();
+ Context env = (Context) ic.lookup("java:comp/env");
+ String val = (String) env.lookup("baseFolder");
+ if (!StringUtils.isEmpty(val)) {
+ path = val;
+ }
+ } catch (NamingException n) {
+ logger.error("Failed to get JNDI env-entry: " + n.getExplanation());
+ }
+
File base = com.gitblit.utils.FileUtils.resolveParameter(Constants.contextFolder$, contextFolder, path);
base.mkdirs();