]> source.dussan.org Git - gitblit.git/commitdiff
Switch web.xml baseFolder from context-param to env-entry
authorJames Moger <james.moger@gitblit.com>
Wed, 2 Oct 2013 21:12:18 +0000 (17:12 -0400)
committerJames Moger <james.moger@gitblit.com>
Wed, 2 Oct 2013 21:12:18 +0000 (17:12 -0400)
Change-Id: Id18077126e984a767725cf9e8d8eb531a14e1713

releases.moxie
src/main/java/WEB-INF/web.xml
src/main/java/com/gitblit/GitBlit.java

index 87d178a778ca5ce0a4a54d636e776557919e810c..c231a290746c7fbb36ae868d70d10cc3ec1fe080 100644 (file)
@@ -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
 }
 
 #
index d4acb049ad4bcf4f697a22e68a91c1cae4723993..6e24326b2004edc95d02f030c77b90ee28b5aa7e 100644 (file)
                review the defaults for any new settings.  Settings are always versioned\r
                with a SINCE x.y.z attribute and also noted in the release changelog.\r
                -->\r
-       <context-param>\r
-               <param-name>baseFolder</param-name>\r
-               <param-value>${contextFolder}/WEB-INF/data</param-value>\r
-       </context-param>\r
+       <env-entry>\r
+               <description>The base folder is used to specify the root location of your Gitblit data.</description>\r
+               <env-entry-name>baseFolder</env-entry-name>\r
+               <env-entry-type>java.lang.String</env-entry-type>\r
+               <env-entry-value>${contextFolder}/WEB-INF/data</env-entry-value>\r
+       </env-entry>\r
        \r
        <!-- Gitblit Displayname -->\r
        <display-name>\r
index 5eec7a9350dd25e204ac8b0f109069a1e5407a6b..7f82432d32679abf3bc307462a552ab502b17c76 100644 (file)
@@ -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();